@xata.io/client 0.0.0-alpha.vf27674a → 0.0.0-alpha.vf3111df

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,16 +131,20 @@ 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;
@@ -268,6 +281,21 @@ declare type SortExpression = string[] | {
268
281
  [key: string]: SortOrder;
269
282
  }[];
270
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';
271
299
  /**
272
300
  * @minProperties 1
273
301
  */
@@ -281,6 +309,48 @@ declare type FilterExpression = {
281
309
  } & {
282
310
  [key: string]: FilterColumn;
283
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
+ };
284
354
  declare type FilterList = FilterExpression | FilterExpression[];
285
355
  declare type FilterColumn = FilterColumnIncludes | FilterPredicate | FilterList;
286
356
  /**
@@ -337,7 +407,24 @@ declare type PageConfig = {
337
407
  size?: number;
338
408
  offset?: number;
339
409
  };
340
- 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
+ };
341
428
  /**
342
429
  * @pattern [a-zA-Z0-9_-~:]+
343
430
  */
@@ -359,16 +446,9 @@ declare type RecordsMetadata = {
359
446
  };
360
447
  };
361
448
  /**
362
- * Xata Table Record
449
+ * Xata Table Record Metadata
363
450
  */
364
- declare type XataRecord$1 = {
365
- id: RecordID;
366
- xata: {
367
- version: number;
368
- table?: string;
369
- warnings?: string[];
370
- };
371
- } & {
451
+ declare type XataRecord$1 = RecordMeta & {
372
452
  [key: string]: any;
373
453
  };
374
454
 
@@ -386,6 +466,7 @@ type schemas_InviteID = InviteID;
386
466
  type schemas_WorkspaceInvite = WorkspaceInvite;
387
467
  type schemas_WorkspaceMembers = WorkspaceMembers;
388
468
  type schemas_InviteKey = InviteKey;
469
+ type schemas_DatabaseMetadata = DatabaseMetadata;
389
470
  type schemas_ListDatabasesResponse = ListDatabasesResponse;
390
471
  type schemas_ListBranchesResponse = ListBranchesResponse;
391
472
  type schemas_ListGitBranchesResponse = ListGitBranchesResponse;
@@ -409,7 +490,11 @@ type schemas_TableMigration = TableMigration;
409
490
  type schemas_ColumnMigration = ColumnMigration;
410
491
  type schemas_SortExpression = SortExpression;
411
492
  type schemas_SortOrder = SortOrder;
493
+ type schemas_FuzzinessExpression = FuzzinessExpression;
494
+ type schemas_PrefixExpression = PrefixExpression;
412
495
  type schemas_FilterExpression = FilterExpression;
496
+ type schemas_HighlightExpression = HighlightExpression;
497
+ type schemas_BoosterExpression = BoosterExpression;
413
498
  type schemas_FilterList = FilterList;
414
499
  type schemas_FilterColumn = FilterColumn;
415
500
  type schemas_FilterColumnIncludes = FilterColumnIncludes;
@@ -419,7 +504,8 @@ type schemas_FilterPredicateRangeOp = FilterPredicateRangeOp;
419
504
  type schemas_FilterRangeValue = FilterRangeValue;
420
505
  type schemas_FilterValue = FilterValue;
421
506
  type schemas_PageConfig = PageConfig;
422
- type schemas_ColumnsFilter = ColumnsFilter;
507
+ type schemas_ColumnsProjection = ColumnsProjection;
508
+ type schemas_RecordMeta = RecordMeta;
423
509
  type schemas_RecordID = RecordID;
424
510
  type schemas_TableRename = TableRename;
425
511
  type schemas_RecordsMetadata = RecordsMetadata;
@@ -439,6 +525,7 @@ declare namespace schemas {
439
525
  schemas_WorkspaceInvite as WorkspaceInvite,
440
526
  schemas_WorkspaceMembers as WorkspaceMembers,
441
527
  schemas_InviteKey as InviteKey,
528
+ schemas_DatabaseMetadata as DatabaseMetadata,
442
529
  schemas_ListDatabasesResponse as ListDatabasesResponse,
443
530
  schemas_ListBranchesResponse as ListBranchesResponse,
444
531
  schemas_ListGitBranchesResponse as ListGitBranchesResponse,
@@ -462,7 +549,14 @@ declare namespace schemas {
462
549
  schemas_ColumnMigration as ColumnMigration,
463
550
  schemas_SortExpression as SortExpression,
464
551
  schemas_SortOrder as SortOrder,
552
+ schemas_FuzzinessExpression as FuzzinessExpression,
553
+ schemas_PrefixExpression as PrefixExpression,
465
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,
466
560
  schemas_FilterList as FilterList,
467
561
  schemas_FilterColumn as FilterColumn,
468
562
  schemas_FilterColumnIncludes as FilterColumnIncludes,
@@ -472,7 +566,8 @@ declare namespace schemas {
472
566
  schemas_FilterRangeValue as FilterRangeValue,
473
567
  schemas_FilterValue as FilterValue,
474
568
  schemas_PageConfig as PageConfig,
475
- schemas_ColumnsFilter as ColumnsFilter,
569
+ schemas_ColumnsProjection as ColumnsProjection,
570
+ schemas_RecordMeta as RecordMeta,
476
571
  schemas_RecordID as RecordID,
477
572
  schemas_TableRename as TableRename,
478
573
  schemas_RecordsMetadata as RecordsMetadata,
@@ -507,11 +602,17 @@ declare type BulkError = {
507
602
  status?: number;
508
603
  }[];
509
604
  };
605
+ declare type BulkInsertResponse = {
606
+ recordIDs: string[];
607
+ } | {
608
+ records: XataRecord$1[];
609
+ };
510
610
  declare type BranchMigrationPlan = {
511
611
  version: number;
512
612
  migration: BranchMigration;
513
613
  };
514
- declare type RecordUpdateResponse = {
614
+ declare type RecordResponse = XataRecord$1;
615
+ declare type RecordUpdateResponse = XataRecord$1 | {
515
616
  id: string;
516
617
  xata: {
517
618
  version: number;
@@ -535,7 +636,9 @@ type responses_SimpleError = SimpleError;
535
636
  type responses_BadRequestError = BadRequestError;
536
637
  type responses_AuthError = AuthError;
537
638
  type responses_BulkError = BulkError;
639
+ type responses_BulkInsertResponse = BulkInsertResponse;
538
640
  type responses_BranchMigrationPlan = BranchMigrationPlan;
641
+ type responses_RecordResponse = RecordResponse;
539
642
  type responses_RecordUpdateResponse = RecordUpdateResponse;
540
643
  type responses_QueryResponse = QueryResponse;
541
644
  type responses_SearchResponse = SearchResponse;
@@ -546,7 +649,9 @@ declare namespace responses {
546
649
  responses_BadRequestError as BadRequestError,
547
650
  responses_AuthError as AuthError,
548
651
  responses_BulkError as BulkError,
652
+ responses_BulkInsertResponse as BulkInsertResponse,
549
653
  responses_BranchMigrationPlan as BranchMigrationPlan,
654
+ responses_RecordResponse as RecordResponse,
550
655
  responses_RecordUpdateResponse as RecordUpdateResponse,
551
656
  responses_QueryResponse as QueryResponse,
552
657
  responses_SearchResponse as SearchResponse,
@@ -852,6 +957,9 @@ declare type InviteWorkspaceMemberError = ErrorWrapper<{
852
957
  } | {
853
958
  status: 404;
854
959
  payload: SimpleError;
960
+ } | {
961
+ status: 409;
962
+ payload: SimpleError;
855
963
  }>;
856
964
  declare type InviteWorkspaceMemberRequestBody = {
857
965
  email: string;
@@ -865,6 +973,34 @@ declare type InviteWorkspaceMemberVariables = {
865
973
  * Invite some user to join the workspace with the given role
866
974
  */
867
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>;
868
1004
  declare type CancelWorkspaceMemberInvitePathParams = {
869
1005
  workspaceId: WorkspaceID;
870
1006
  inviteId: InviteID;
@@ -1018,6 +1154,27 @@ declare type DeleteDatabaseVariables = {
1018
1154
  * Delete a database and all of its branches and tables permanently.
1019
1155
  */
1020
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>;
1021
1178
  declare type GetGitBranchesMappingPathParams = {
1022
1179
  dbName: DBName;
1023
1180
  workspace: string;
@@ -1151,9 +1308,10 @@ declare type ResolveBranchVariables = {
1151
1308
  } & FetcherExtraProps;
1152
1309
  /**
1153
1310
  * In order to resolve the database branch, the following algorithm is used:
1154
- * * if the `gitBranch` is found in the [git branches mapping](), the associated Xata branch is returned
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
1155
1312
  * * else, if a Xata branch with the exact same name as `gitBranch` exists, return it
1156
- * * else, return the default branch of the DB (currently `main` or the first branch)
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)
1157
1315
  *
1158
1316
  * Example call:
1159
1317
  *
@@ -1209,6 +1367,10 @@ declare type CreateBranchError = ErrorWrapper<{
1209
1367
  status: 404;
1210
1368
  payload: SimpleError;
1211
1369
  }>;
1370
+ declare type CreateBranchResponse = {
1371
+ databaseName: string;
1372
+ branchName: string;
1373
+ };
1212
1374
  declare type CreateBranchRequestBody = {
1213
1375
  from?: string;
1214
1376
  metadata?: BranchMetadata;
@@ -1218,7 +1380,7 @@ declare type CreateBranchVariables = {
1218
1380
  pathParams: CreateBranchPathParams;
1219
1381
  queryParams?: CreateBranchQueryParams;
1220
1382
  } & FetcherExtraProps;
1221
- declare const createBranch: (variables: CreateBranchVariables) => Promise<undefined>;
1383
+ declare const createBranch: (variables: CreateBranchVariables) => Promise<CreateBranchResponse>;
1222
1384
  declare type DeleteBranchPathParams = {
1223
1385
  dbBranchName: DBBranchName;
1224
1386
  workspace: string;
@@ -1405,13 +1567,17 @@ declare type CreateTableError = ErrorWrapper<{
1405
1567
  status: 422;
1406
1568
  payload: SimpleError;
1407
1569
  }>;
1570
+ declare type CreateTableResponse = {
1571
+ branchName: string;
1572
+ tableName: string;
1573
+ };
1408
1574
  declare type CreateTableVariables = {
1409
1575
  pathParams: CreateTablePathParams;
1410
1576
  } & FetcherExtraProps;
1411
1577
  /**
1412
1578
  * Creates a new table with the given name. Returns 422 if a table with the same name already exists.
1413
1579
  */
1414
- declare const createTable: (variables: CreateTableVariables) => Promise<undefined>;
1580
+ declare const createTable: (variables: CreateTableVariables) => Promise<CreateTableResponse>;
1415
1581
  declare type DeleteTablePathParams = {
1416
1582
  dbBranchName: DBBranchName;
1417
1583
  tableName: TableName;
@@ -1644,6 +1810,9 @@ declare type InsertRecordPathParams = {
1644
1810
  tableName: TableName;
1645
1811
  workspace: string;
1646
1812
  };
1813
+ declare type InsertRecordQueryParams = {
1814
+ columns?: ColumnsProjection;
1815
+ };
1647
1816
  declare type InsertRecordError = ErrorWrapper<{
1648
1817
  status: 400;
1649
1818
  payload: BadRequestError;
@@ -1654,20 +1823,15 @@ declare type InsertRecordError = ErrorWrapper<{
1654
1823
  status: 404;
1655
1824
  payload: SimpleError;
1656
1825
  }>;
1657
- declare type InsertRecordResponse = {
1658
- id: string;
1659
- xata: {
1660
- version: number;
1661
- };
1662
- };
1663
1826
  declare type InsertRecordVariables = {
1664
1827
  body?: Record<string, any>;
1665
1828
  pathParams: InsertRecordPathParams;
1829
+ queryParams?: InsertRecordQueryParams;
1666
1830
  } & FetcherExtraProps;
1667
1831
  /**
1668
1832
  * Insert a new Record into the Table
1669
1833
  */
1670
- declare const insertRecord: (variables: InsertRecordVariables) => Promise<InsertRecordResponse>;
1834
+ declare const insertRecord: (variables: InsertRecordVariables) => Promise<RecordUpdateResponse>;
1671
1835
  declare type InsertRecordWithIDPathParams = {
1672
1836
  dbBranchName: DBBranchName;
1673
1837
  tableName: TableName;
@@ -1675,6 +1839,7 @@ declare type InsertRecordWithIDPathParams = {
1675
1839
  workspace: string;
1676
1840
  };
1677
1841
  declare type InsertRecordWithIDQueryParams = {
1842
+ columns?: ColumnsProjection;
1678
1843
  createOnly?: boolean;
1679
1844
  ifVersion?: number;
1680
1845
  };
@@ -1707,6 +1872,7 @@ declare type UpdateRecordWithIDPathParams = {
1707
1872
  workspace: string;
1708
1873
  };
1709
1874
  declare type UpdateRecordWithIDQueryParams = {
1875
+ columns?: ColumnsProjection;
1710
1876
  ifVersion?: number;
1711
1877
  };
1712
1878
  declare type UpdateRecordWithIDError = ErrorWrapper<{
@@ -1735,6 +1901,7 @@ declare type UpsertRecordWithIDPathParams = {
1735
1901
  workspace: string;
1736
1902
  };
1737
1903
  declare type UpsertRecordWithIDQueryParams = {
1904
+ columns?: ColumnsProjection;
1738
1905
  ifVersion?: number;
1739
1906
  };
1740
1907
  declare type UpsertRecordWithIDError = ErrorWrapper<{
@@ -1762,6 +1929,9 @@ declare type DeleteRecordPathParams = {
1762
1929
  recordId: RecordID;
1763
1930
  workspace: string;
1764
1931
  };
1932
+ declare type DeleteRecordQueryParams = {
1933
+ columns?: ColumnsProjection;
1934
+ };
1765
1935
  declare type DeleteRecordError = ErrorWrapper<{
1766
1936
  status: 400;
1767
1937
  payload: BadRequestError;
@@ -1774,14 +1944,18 @@ declare type DeleteRecordError = ErrorWrapper<{
1774
1944
  }>;
1775
1945
  declare type DeleteRecordVariables = {
1776
1946
  pathParams: DeleteRecordPathParams;
1947
+ queryParams?: DeleteRecordQueryParams;
1777
1948
  } & FetcherExtraProps;
1778
- declare const deleteRecord: (variables: DeleteRecordVariables) => Promise<undefined>;
1949
+ declare const deleteRecord: (variables: DeleteRecordVariables) => Promise<XataRecord$1>;
1779
1950
  declare type GetRecordPathParams = {
1780
1951
  dbBranchName: DBBranchName;
1781
1952
  tableName: TableName;
1782
1953
  recordId: RecordID;
1783
1954
  workspace: string;
1784
1955
  };
1956
+ declare type GetRecordQueryParams = {
1957
+ columns?: ColumnsProjection;
1958
+ };
1785
1959
  declare type GetRecordError = ErrorWrapper<{
1786
1960
  status: 400;
1787
1961
  payload: BadRequestError;
@@ -1792,12 +1966,9 @@ declare type GetRecordError = ErrorWrapper<{
1792
1966
  status: 404;
1793
1967
  payload: SimpleError;
1794
1968
  }>;
1795
- declare type GetRecordRequestBody = {
1796
- columns?: ColumnsFilter;
1797
- };
1798
1969
  declare type GetRecordVariables = {
1799
- body?: GetRecordRequestBody;
1800
1970
  pathParams: GetRecordPathParams;
1971
+ queryParams?: GetRecordQueryParams;
1801
1972
  } & FetcherExtraProps;
1802
1973
  /**
1803
1974
  * Retrieve record by ID
@@ -1808,6 +1979,9 @@ declare type BulkInsertTableRecordsPathParams = {
1808
1979
  tableName: TableName;
1809
1980
  workspace: string;
1810
1981
  };
1982
+ declare type BulkInsertTableRecordsQueryParams = {
1983
+ columns?: ColumnsProjection;
1984
+ };
1811
1985
  declare type BulkInsertTableRecordsError = ErrorWrapper<{
1812
1986
  status: 400;
1813
1987
  payload: BulkError;
@@ -1817,21 +1991,22 @@ declare type BulkInsertTableRecordsError = ErrorWrapper<{
1817
1991
  } | {
1818
1992
  status: 404;
1819
1993
  payload: SimpleError;
1994
+ } | {
1995
+ status: 422;
1996
+ payload: SimpleError;
1820
1997
  }>;
1821
- declare type BulkInsertTableRecordsResponse = {
1822
- recordIDs: string[];
1823
- };
1824
1998
  declare type BulkInsertTableRecordsRequestBody = {
1825
1999
  records: Record<string, any>[];
1826
2000
  };
1827
2001
  declare type BulkInsertTableRecordsVariables = {
1828
2002
  body: BulkInsertTableRecordsRequestBody;
1829
2003
  pathParams: BulkInsertTableRecordsPathParams;
2004
+ queryParams?: BulkInsertTableRecordsQueryParams;
1830
2005
  } & FetcherExtraProps;
1831
2006
  /**
1832
2007
  * Bulk insert records
1833
2008
  */
1834
- declare const bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
2009
+ declare const bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertResponse>;
1835
2010
  declare type QueryTablePathParams = {
1836
2011
  dbBranchName: DBBranchName;
1837
2012
  tableName: TableName;
@@ -1851,7 +2026,7 @@ declare type QueryTableRequestBody = {
1851
2026
  filter?: FilterExpression;
1852
2027
  sort?: SortExpression;
1853
2028
  page?: PageConfig;
1854
- columns?: ColumnsFilter;
2029
+ columns?: ColumnsProjection;
1855
2030
  };
1856
2031
  declare type QueryTableVariables = {
1857
2032
  body?: QueryTableRequestBody;
@@ -2261,12 +2436,18 @@ declare type QueryTableVariables = {
2261
2436
  * {
2262
2437
  * "filter": {
2263
2438
  * "<column_name>": {
2264
- * "$pattern": "v*alue*"
2439
+ * "$pattern": "v*alu?"
2265
2440
  * }
2266
2441
  * }
2267
2442
  * }
2268
2443
  * ```
2269
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
+ *
2270
2451
  * We could also have `$endsWith` and `$startsWith` operators:
2271
2452
  *
2272
2453
  * ```json
@@ -2573,6 +2754,41 @@ declare type QueryTableVariables = {
2573
2754
  * ```
2574
2755
  */
2575
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>;
2576
2792
  declare type SearchBranchPathParams = {
2577
2793
  dbBranchName: DBBranchName;
2578
2794
  workspace: string;
@@ -2588,9 +2804,14 @@ declare type SearchBranchError = ErrorWrapper<{
2588
2804
  payload: SimpleError;
2589
2805
  }>;
2590
2806
  declare type SearchBranchRequestBody = {
2591
- tables?: string[];
2807
+ tables?: (string | {
2808
+ table: string;
2809
+ filter?: FilterExpression;
2810
+ boosters?: BoosterExpression[];
2811
+ })[];
2592
2812
  query: string;
2593
- fuzziness?: number;
2813
+ fuzziness?: FuzzinessExpression;
2814
+ highlight?: HighlightExpression;
2594
2815
  };
2595
2816
  declare type SearchBranchVariables = {
2596
2817
  body: SearchBranchRequestBody;
@@ -2619,6 +2840,7 @@ declare const operationsByTag: {
2619
2840
  updateWorkspaceMemberRole: (variables: UpdateWorkspaceMemberRoleVariables) => Promise<undefined>;
2620
2841
  removeWorkspaceMember: (variables: RemoveWorkspaceMemberVariables) => Promise<undefined>;
2621
2842
  inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<WorkspaceInvite>;
2843
+ updateWorkspaceMemberInvite: (variables: UpdateWorkspaceMemberInviteVariables) => Promise<WorkspaceInvite>;
2622
2844
  cancelWorkspaceMemberInvite: (variables: CancelWorkspaceMemberInviteVariables) => Promise<undefined>;
2623
2845
  resendWorkspaceMemberInvite: (variables: ResendWorkspaceMemberInviteVariables) => Promise<undefined>;
2624
2846
  acceptWorkspaceMemberInvite: (variables: AcceptWorkspaceMemberInviteVariables) => Promise<undefined>;
@@ -2627,6 +2849,7 @@ declare const operationsByTag: {
2627
2849
  getDatabaseList: (variables: GetDatabaseListVariables) => Promise<ListDatabasesResponse>;
2628
2850
  createDatabase: (variables: CreateDatabaseVariables) => Promise<CreateDatabaseResponse>;
2629
2851
  deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
2852
+ getDatabaseMetadata: (variables: GetDatabaseMetadataVariables) => Promise<DatabaseMetadata>;
2630
2853
  getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
2631
2854
  addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
2632
2855
  removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
@@ -2635,7 +2858,7 @@ declare const operationsByTag: {
2635
2858
  branch: {
2636
2859
  getBranchList: (variables: GetBranchListVariables) => Promise<ListBranchesResponse>;
2637
2860
  getBranchDetails: (variables: GetBranchDetailsVariables) => Promise<DBBranch>;
2638
- createBranch: (variables: CreateBranchVariables) => Promise<undefined>;
2861
+ createBranch: (variables: CreateBranchVariables) => Promise<CreateBranchResponse>;
2639
2862
  deleteBranch: (variables: DeleteBranchVariables) => Promise<undefined>;
2640
2863
  updateBranchMetadata: (variables: UpdateBranchMetadataVariables) => Promise<undefined>;
2641
2864
  getBranchMetadata: (variables: GetBranchMetadataVariables) => Promise<BranchMetadata>;
@@ -2645,7 +2868,7 @@ declare const operationsByTag: {
2645
2868
  getBranchStats: (variables: GetBranchStatsVariables) => Promise<GetBranchStatsResponse>;
2646
2869
  };
2647
2870
  table: {
2648
- createTable: (variables: CreateTableVariables) => Promise<undefined>;
2871
+ createTable: (variables: CreateTableVariables) => Promise<CreateTableResponse>;
2649
2872
  deleteTable: (variables: DeleteTableVariables) => Promise<undefined>;
2650
2873
  updateTable: (variables: UpdateTableVariables) => Promise<undefined>;
2651
2874
  getTableSchema: (variables: GetTableSchemaVariables) => Promise<GetTableSchemaResponse>;
@@ -2657,14 +2880,15 @@ declare const operationsByTag: {
2657
2880
  updateColumn: (variables: UpdateColumnVariables) => Promise<MigrationIdResponse>;
2658
2881
  };
2659
2882
  records: {
2660
- insertRecord: (variables: InsertRecordVariables) => Promise<InsertRecordResponse>;
2883
+ insertRecord: (variables: InsertRecordVariables) => Promise<RecordUpdateResponse>;
2661
2884
  insertRecordWithID: (variables: InsertRecordWithIDVariables) => Promise<RecordUpdateResponse>;
2662
2885
  updateRecordWithID: (variables: UpdateRecordWithIDVariables) => Promise<RecordUpdateResponse>;
2663
2886
  upsertRecordWithID: (variables: UpsertRecordWithIDVariables) => Promise<RecordUpdateResponse>;
2664
- deleteRecord: (variables: DeleteRecordVariables) => Promise<undefined>;
2887
+ deleteRecord: (variables: DeleteRecordVariables) => Promise<XataRecord$1>;
2665
2888
  getRecord: (variables: GetRecordVariables) => Promise<XataRecord$1>;
2666
- bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
2889
+ bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertResponse>;
2667
2890
  queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
2891
+ searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
2668
2892
  searchBranch: (variables: SearchBranchVariables) => Promise<SearchResponse>;
2669
2893
  };
2670
2894
  };
@@ -2680,6 +2904,7 @@ interface XataApiClientOptions {
2680
2904
  fetch?: FetchImpl;
2681
2905
  apiKey?: string;
2682
2906
  host?: HostProvider;
2907
+ trace?: TraceFunction;
2683
2908
  }
2684
2909
  /**
2685
2910
  * @deprecated Use XataApiPlugin instead
@@ -2716,6 +2941,7 @@ declare class WorkspaceApi {
2716
2941
  updateWorkspaceMemberRole(workspaceId: WorkspaceID, userId: UserID, role: Role): Promise<void>;
2717
2942
  removeWorkspaceMember(workspaceId: WorkspaceID, userId: UserID): Promise<void>;
2718
2943
  inviteWorkspaceMember(workspaceId: WorkspaceID, email: string, role: Role): Promise<WorkspaceInvite>;
2944
+ updateWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID, role: Role): Promise<WorkspaceInvite>;
2719
2945
  cancelWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID): Promise<void>;
2720
2946
  resendWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID): Promise<void>;
2721
2947
  acceptWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteKey: InviteKey): Promise<void>;
@@ -2726,17 +2952,18 @@ declare class DatabaseApi {
2726
2952
  getDatabaseList(workspace: WorkspaceID): Promise<ListDatabasesResponse>;
2727
2953
  createDatabase(workspace: WorkspaceID, dbName: DBName, options?: CreateDatabaseRequestBody): Promise<CreateDatabaseResponse>;
2728
2954
  deleteDatabase(workspace: WorkspaceID, dbName: DBName): Promise<void>;
2955
+ getDatabaseMetadata(workspace: WorkspaceID, dbName: DBName): Promise<DatabaseMetadata>;
2729
2956
  getGitBranchesMapping(workspace: WorkspaceID, dbName: DBName): Promise<ListGitBranchesResponse>;
2730
2957
  addGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, body: AddGitBranchesEntryRequestBody): Promise<AddGitBranchesEntryResponse>;
2731
2958
  removeGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<void>;
2732
- resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<ResolveBranchResponse>;
2959
+ resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch?: string, fallbackBranch?: string): Promise<ResolveBranchResponse>;
2733
2960
  }
2734
2961
  declare class BranchApi {
2735
2962
  private extraProps;
2736
2963
  constructor(extraProps: FetcherExtraProps);
2737
2964
  getBranchList(workspace: WorkspaceID, dbName: DBName): Promise<ListBranchesResponse>;
2738
2965
  getBranchDetails(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<DBBranch>;
2739
- createBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, from?: string, options?: CreateBranchRequestBody): Promise<void>;
2966
+ createBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, from?: string, options?: CreateBranchRequestBody): Promise<CreateBranchResponse>;
2740
2967
  deleteBranch(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<void>;
2741
2968
  updateBranchMetadata(workspace: WorkspaceID, database: DBName, branch: BranchName, metadata?: BranchMetadata): Promise<void>;
2742
2969
  getBranchMetadata(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<BranchMetadata>;
@@ -2748,7 +2975,7 @@ declare class BranchApi {
2748
2975
  declare class TableApi {
2749
2976
  private extraProps;
2750
2977
  constructor(extraProps: FetcherExtraProps);
2751
- createTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<void>;
2978
+ createTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<CreateTableResponse>;
2752
2979
  deleteTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<void>;
2753
2980
  updateTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, options: UpdateTableRequestBody): Promise<void>;
2754
2981
  getTableSchema(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<GetTableSchemaResponse>;
@@ -2762,14 +2989,15 @@ declare class TableApi {
2762
2989
  declare class RecordsApi {
2763
2990
  private extraProps;
2764
2991
  constructor(extraProps: FetcherExtraProps);
2765
- insertRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, record: Record<string, any>): Promise<InsertRecordResponse>;
2992
+ insertRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, record: Record<string, any>, options?: InsertRecordQueryParams): Promise<RecordUpdateResponse>;
2766
2993
  insertRecordWithID(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, record: Record<string, any>, options?: InsertRecordWithIDQueryParams): Promise<RecordUpdateResponse>;
2767
2994
  updateRecordWithID(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, record: Record<string, any>, options?: UpdateRecordWithIDQueryParams): Promise<RecordUpdateResponse>;
2768
2995
  upsertRecordWithID(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, record: Record<string, any>, options?: UpsertRecordWithIDQueryParams): Promise<RecordUpdateResponse>;
2769
- deleteRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID): Promise<void>;
2770
- getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: GetRecordRequestBody): Promise<XataRecord$1>;
2771
- bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[]): Promise<BulkInsertTableRecordsResponse>;
2996
+ deleteRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: DeleteRecordQueryParams): Promise<RecordUpdateResponse>;
2997
+ getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: GetRecordQueryParams): Promise<XataRecord$1>;
2998
+ bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[], options?: BulkInsertTableRecordsQueryParams): Promise<BulkInsertResponse>;
2772
2999
  queryTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: QueryTableRequestBody): Promise<QueryResponse>;
3000
+ searchTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: SearchTableRequestBody): Promise<SearchResponse>;
2773
3001
  searchBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, query: SearchBranchRequestBody): Promise<SearchResponse>;
2774
3002
  }
2775
3003
 
@@ -2783,28 +3011,29 @@ declare type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) ex
2783
3011
  declare type If<Condition, Then, Else> = Condition extends true ? Then : Else;
2784
3012
  declare type IsObject<T> = T extends Record<string, any> ? true : false;
2785
3013
  declare type IsArray<T> = T extends Array<any> ? true : false;
2786
- declare type NonEmptyArray<T> = T[] & {
2787
- 0: T;
2788
- };
2789
3014
  declare type RequiredBy<T, K extends keyof T> = T & {
2790
3015
  [P in K]-?: NonNullable<T[P]>;
2791
3016
  };
2792
3017
  declare type GetArrayInnerType<T extends readonly any[]> = T[number];
2793
3018
  declare type SingleOrArray<T> = T | T[];
2794
3019
  declare type OmitBy<T, K extends keyof T> = T extends any ? Omit<T, K> : never;
3020
+ declare type Without<T, U> = {
3021
+ [P in Exclude<keyof T, keyof U>]?: never;
3022
+ };
3023
+ declare type ExclusiveOr<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
2795
3024
 
2796
3025
  declare type SelectableColumn<O, RecursivePath extends any[] = []> = '*' | 'id' | DataProps<O> | NestedColumns<O, RecursivePath>;
2797
- declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord & UnionToIntersection<Values<{
2798
- [K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord;
3026
+ declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord<O> & UnionToIntersection<Values<{
3027
+ [K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord<O>;
2799
3028
  }>>;
2800
- 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]> ? {
2801
- V: ValueAtColumn<O[K], V>;
2802
- } : never) : O[K]> : never : never;
3029
+ 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> ? {
3030
+ V: ValueAtColumn<Item, V>;
3031
+ } : never : O[K] : never> : never : never;
2803
3032
  declare type MAX_RECURSION = 5;
2804
3033
  declare type NestedColumns<O, RecursivePath extends any[]> = RecursivePath['length'] extends MAX_RECURSION ? never : If<IsObject<O>, Values<{
2805
- [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
2806
- 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
2807
- K>>;
3034
+ [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
3035
+ 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
3036
+ K>> : never;
2808
3037
  }>, never>;
2809
3038
  declare type DataProps<O> = Exclude<StringKeys<O>, StringKeys<XataRecord>>;
2810
3039
  declare type NestedValueAtColumn<O, Key extends SelectableColumn<O>> = Key extends `${infer N}.${infer M}` ? N extends DataProps<O> ? {
@@ -2831,27 +3060,37 @@ interface BaseData {
2831
3060
  /**
2832
3061
  * Represents a persisted record from the database.
2833
3062
  */
2834
- interface XataRecord extends Identifiable {
3063
+ interface XataRecord<OriginalRecord extends XataRecord<any> = XataRecord<any>> extends Identifiable {
2835
3064
  /**
2836
- * Metadata of this record.
3065
+ * Get metadata of this record.
2837
3066
  */
2838
- xata: {
2839
- /**
2840
- * Number that is increased every time the record is updated.
2841
- */
2842
- version: number;
2843
- };
3067
+ getMetadata(): XataRecordMetadata;
3068
+ /**
3069
+ * Retrieves a refreshed copy of the current record from the database.
3070
+ * @param columns The columns to retrieve. If not specified, all first level properties are retrieved.
3071
+ * @returns The persisted record with the selected columns.
3072
+ */
3073
+ read<K extends SelectableColumn<OriginalRecord>>(columns: K[]): Promise<Readonly<SelectedPick<OriginalRecord, typeof columns>> | null>;
2844
3074
  /**
2845
3075
  * Retrieves a refreshed copy of the current record from the database.
3076
+ * @returns The persisted record with all first level properties.
2846
3077
  */
2847
- read(): Promise<Readonly<SelectedPick<this, ['*']>> | null>;
3078
+ read(): Promise<Readonly<SelectedPick<OriginalRecord, ['*']>> | null>;
2848
3079
  /**
2849
3080
  * Performs a partial update of the current record. On success a new object is
2850
3081
  * returned and the current object is not mutated.
2851
- * @param data The columns and their values that have to be updated.
2852
- * @returns A new record containing the latest values for all the columns of the current record.
3082
+ * @param partialUpdate The columns and their values that have to be updated.
3083
+ * @param columns The columns to retrieve. If not specified, all first level properties are retrieved.
3084
+ * @returns The persisted record with the selected columns.
3085
+ */
3086
+ update<K extends SelectableColumn<OriginalRecord>>(partialUpdate: Partial<EditableData<Omit<OriginalRecord, keyof XataRecord>>>, columns: K[]): Promise<Readonly<SelectedPick<OriginalRecord, typeof columns>>>;
3087
+ /**
3088
+ * Performs a partial update of the current record. On success a new object is
3089
+ * returned and the current object is not mutated.
3090
+ * @param partialUpdate The columns and their values that have to be updated.
3091
+ * @returns The persisted record with all first level properties.
2853
3092
  */
2854
- update(partialUpdate: Partial<EditableData<Omit<this, keyof XataRecord>>>): Promise<Readonly<SelectedPick<this, ['*']>>>;
3093
+ update(partialUpdate: Partial<EditableData<Omit<OriginalRecord, keyof XataRecord>>>): Promise<Readonly<SelectedPick<OriginalRecord, ['*']>>>;
2855
3094
  /**
2856
3095
  * Performs a deletion of the current record in the database.
2857
3096
  *
@@ -2863,23 +3102,36 @@ declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update
2863
3102
  /**
2864
3103
  * Retrieves a refreshed copy of the current record from the database.
2865
3104
  */
2866
- read(): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3105
+ read<K extends SelectableColumn<Record>>(columns?: K[]): Promise<Readonly<SelectedPick<Record, typeof columns extends SelectableColumn<Record>[] ? typeof columns : ['*']>> | null>;
2867
3106
  /**
2868
3107
  * Performs a partial update of the current record. On success a new object is
2869
3108
  * returned and the current object is not mutated.
2870
- * @param data The columns and their values that have to be updated.
3109
+ * @param partialUpdate The columns and their values that have to be updated.
2871
3110
  * @returns A new record containing the latest values for all the columns of the current record.
2872
3111
  */
2873
- update(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3112
+ update<K extends SelectableColumn<Record>>(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>, columns?: K[]): Promise<Readonly<SelectedPick<Record, typeof columns extends SelectableColumn<Record>[] ? typeof columns : ['*']>>>;
3113
+ /**
3114
+ * Performs a deletion of the current record in the database.
3115
+ *
3116
+ * @throws If the record was already deleted or if an error happened while performing the deletion.
3117
+ */
3118
+ delete(): Promise<void>;
3119
+ };
3120
+ declare type XataRecordMetadata = {
3121
+ /**
3122
+ * Number that is increased every time the record is updated.
3123
+ */
3124
+ version: number;
3125
+ warnings?: string[];
2874
3126
  };
2875
3127
  declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
2876
3128
  declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
2877
3129
  declare type EditableData<O extends BaseData> = {
2878
3130
  [K in keyof O]: O[K] extends XataRecord ? {
2879
3131
  id: string;
2880
- } : NonNullable<O[K]> extends XataRecord ? {
3132
+ } | string : NonNullable<O[K]> extends XataRecord ? {
2881
3133
  id: string;
2882
- } | null | undefined : O[K];
3134
+ } | string | null | undefined : O[K];
2883
3135
  };
2884
3136
 
2885
3137
  /**
@@ -2955,8 +3207,8 @@ declare type ValueTypeFilters<T> = T | T extends string ? StringTypeFilter : T e
2955
3207
  ],
2956
3208
  }
2957
3209
  */
2958
- declare type AggregatorFilter<Record> = {
2959
- [key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<Record>>;
3210
+ declare type AggregatorFilter<T> = {
3211
+ [key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<T>>;
2960
3212
  };
2961
3213
  /**
2962
3214
  * Existance filter
@@ -2971,10 +3223,88 @@ declare type BaseApiFilter<Record> = PropertyAccessFilter<Record> | AggregatorFi
2971
3223
  * Injects the Api filters on nested properties
2972
3224
  * Example: { filter: { settings: { plan: { $any: ['free', 'trial'] } } } }
2973
3225
  */
2974
- declare type NestedApiFilter<T> = T extends Record<string, any> ? {
3226
+ declare type NestedApiFilter<T> = {
2975
3227
  [key in keyof T]?: T[key] extends Record<string, any> ? SingleOrArray<Filter<T[key]>> : PropertyFilter<T[key]>;
2976
- } : PropertyFilter<T>;
2977
- declare type Filter<Record> = BaseApiFilter<Record> | NestedApiFilter<Record>;
3228
+ };
3229
+ declare type Filter<T> = T extends Record<string, any> ? BaseApiFilter<T> | NestedApiFilter<T> : PropertyFilter<T>;
3230
+
3231
+ declare type DateBooster = {
3232
+ origin?: string;
3233
+ scale: string;
3234
+ decay: number;
3235
+ };
3236
+ declare type NumericBooster = {
3237
+ factor: number;
3238
+ };
3239
+ declare type ValueBooster<T extends string | number | boolean> = {
3240
+ value: T;
3241
+ factor: number;
3242
+ };
3243
+ declare type Boosters<O extends XataRecord> = Values<{
3244
+ [K in SelectableColumn<O>]: NonNullable<ValueAtColumn<O, K>> extends Date ? {
3245
+ dateBooster: {
3246
+ column: K;
3247
+ } & DateBooster;
3248
+ } : NonNullable<ValueAtColumn<O, K>> extends number ? ExclusiveOr<{
3249
+ numericBooster?: {
3250
+ column: K;
3251
+ } & NumericBooster;
3252
+ }, {
3253
+ valueBooster?: {
3254
+ column: K;
3255
+ } & ValueBooster<number>;
3256
+ }> : NonNullable<ValueAtColumn<O, K>> extends string | boolean ? {
3257
+ valueBooster: {
3258
+ column: K;
3259
+ } & ValueBooster<NonNullable<ValueAtColumn<O, K>>>;
3260
+ } : never;
3261
+ }>;
3262
+
3263
+ declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
3264
+ fuzziness?: FuzzinessExpression;
3265
+ prefix?: PrefixExpression;
3266
+ highlight?: HighlightExpression;
3267
+ tables?: Array<Tables | Values<{
3268
+ [Model in GetArrayInnerType<NonNullable<Tables[]>>]: {
3269
+ table: Model;
3270
+ filter?: Filter<SelectedPick<Schemas[Model] & XataRecord, ['*']>>;
3271
+ boosters?: Boosters<Schemas[Model] & XataRecord>[];
3272
+ };
3273
+ }>>;
3274
+ };
3275
+ declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
3276
+ all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
3277
+ [Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]: {
3278
+ table: Model;
3279
+ record: Awaited<SearchXataRecord<SelectedPick<Schemas[Model] & XataRecord, ['*']>>>;
3280
+ };
3281
+ }>[]>;
3282
+ byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
3283
+ [Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]?: Awaited<SearchXataRecord<SelectedPick<Schemas[Model] & XataRecord, ['*']>>[]>;
3284
+ }>;
3285
+ };
3286
+ declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
3287
+ #private;
3288
+ private db;
3289
+ constructor(db: SchemaPluginResult<Schemas>, schemaTables?: Schemas.Table[]);
3290
+ build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
3291
+ }
3292
+ declare type SearchXataRecord<Record extends XataRecord> = Omit<Record, 'getMetadata'> & {
3293
+ getMetadata: () => XataRecordMetadata & SearchExtraProperties;
3294
+ };
3295
+ declare type SearchExtraProperties = {
3296
+ table: string;
3297
+ highlight?: {
3298
+ [key: string]: string[] | {
3299
+ [key: string]: any;
3300
+ };
3301
+ };
3302
+ score?: number;
3303
+ };
3304
+ declare type ReturnTable<Table, Tables> = Table extends Tables ? Table : never;
3305
+ 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 {
3306
+ table: infer Table;
3307
+ } ? ReturnTable<Table, Tables> : never;
2978
3308
 
2979
3309
  declare type SortDirection = 'asc' | 'desc';
2980
3310
  declare type SortFilterExtended<T extends XataRecord> = {
@@ -2987,7 +3317,7 @@ declare type SortFilterBase<T extends XataRecord> = {
2987
3317
  };
2988
3318
 
2989
3319
  declare type BaseOptions<T extends XataRecord> = {
2990
- columns?: NonEmptyArray<SelectableColumn<T>>;
3320
+ columns?: SelectableColumn<T>[];
2991
3321
  cache?: number;
2992
3322
  };
2993
3323
  declare type CursorQueryOptions = {
@@ -3010,8 +3340,8 @@ declare type QueryOptions<T extends XataRecord> = BaseOptions<T> & (CursorQueryO
3010
3340
  declare class Query<Record extends XataRecord, Result extends XataRecord = Record> implements Paginable<Record, Result> {
3011
3341
  #private;
3012
3342
  readonly meta: PaginationQueryMeta;
3013
- readonly records: Result[];
3014
- constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, parent?: Partial<QueryOptions<Record>>);
3343
+ readonly records: RecordArray<Result>;
3344
+ constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, rawParent?: Partial<QueryOptions<Record>>);
3015
3345
  getQueryOptions(): QueryOptions<Record>;
3016
3346
  key(): string;
3017
3347
  /**
@@ -3043,81 +3373,183 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
3043
3373
  *
3044
3374
  * ```
3045
3375
  * query.filter("columnName", columnValue)
3046
- * query.filter({
3047
- * "columnName": columnValue
3048
- * })
3376
+ * query.filter("columnName", operator(columnValue)) // Use gt, gte, lt, lte, startsWith,...
3377
+ * ```
3378
+ *
3379
+ * @param column The name of the column to filter.
3380
+ * @param value The value to filter.
3381
+ * @returns A new Query object.
3382
+ */
3383
+ filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
3384
+ /**
3385
+ * Builds a new query object adding one or more constraints. Examples:
3386
+ *
3387
+ * ```
3388
+ * query.filter({ "columnName": columnValue })
3049
3389
  * query.filter({
3050
3390
  * "columnName": operator(columnValue) // Use gt, gte, lt, lte, startsWith,...
3051
3391
  * })
3052
3392
  * ```
3053
3393
  *
3394
+ * @param filters A filter object
3054
3395
  * @returns A new Query object.
3055
3396
  */
3056
3397
  filter(filters: Filter<Record>): Query<Record, Result>;
3057
- filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
3058
3398
  /**
3059
3399
  * Builds a new query with a new sort option.
3060
3400
  * @param column The column name.
3061
3401
  * @param direction The direction. Either ascending or descending.
3062
3402
  * @returns A new Query object.
3063
3403
  */
3064
- sort<F extends SelectableColumn<Record>>(column: F, direction: SortDirection): Query<Record, Result>;
3404
+ sort<F extends SelectableColumn<Record>>(column: F, direction?: SortDirection): Query<Record, Result>;
3065
3405
  /**
3066
3406
  * Builds a new query specifying the set of columns to be returned in the query response.
3067
3407
  * @param columns Array of column names to be returned by the query.
3068
3408
  * @returns A new Query object.
3069
3409
  */
3070
- select<K extends SelectableColumn<Record>>(columns: NonEmptyArray<K>): Query<Record, SelectedPick<Record, NonEmptyArray<K>>>;
3410
+ select<K extends SelectableColumn<Record>>(columns: K[]): Query<Record, SelectedPick<Record, K[]>>;
3411
+ /**
3412
+ * Get paginated results
3413
+ *
3414
+ * @returns A page of results
3415
+ */
3071
3416
  getPaginated(): Promise<Page<Record, Result>>;
3417
+ /**
3418
+ * Get paginated results
3419
+ *
3420
+ * @param options Pagination options
3421
+ * @returns A page of results
3422
+ */
3072
3423
  getPaginated(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
3424
+ /**
3425
+ * Get paginated results
3426
+ *
3427
+ * @param options Pagination options
3428
+ * @returns A page of results
3429
+ */
3073
3430
  getPaginated<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<Page<Record, SelectedPick<Record, typeof options['columns']>>>;
3431
+ /**
3432
+ * Get results in an iterator
3433
+ *
3434
+ * @async
3435
+ * @returns Async interable of results
3436
+ */
3074
3437
  [Symbol.asyncIterator](): AsyncIterableIterator<Result>;
3438
+ /**
3439
+ * Build an iterator of results
3440
+ *
3441
+ * @returns Async generator of results array
3442
+ */
3075
3443
  getIterator(): AsyncGenerator<Result[]>;
3444
+ /**
3445
+ * Build an iterator of results
3446
+ *
3447
+ * @param options Pagination options with batchSize
3448
+ * @returns Async generator of results array
3449
+ */
3076
3450
  getIterator(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
3077
3451
  batchSize?: number;
3078
3452
  }): AsyncGenerator<Result[]>;
3453
+ /**
3454
+ * Build an iterator of results
3455
+ *
3456
+ * @param options Pagination options with batchSize
3457
+ * @returns Async generator of results array
3458
+ */
3079
3459
  getIterator<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
3080
3460
  batchSize?: number;
3081
3461
  }>(options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
3462
+ /**
3463
+ * Performs the query in the database and returns a set of results.
3464
+ * @returns An array of records from the database.
3465
+ */
3466
+ getMany(): Promise<RecordArray<Result>>;
3082
3467
  /**
3083
3468
  * Performs the query in the database and returns a set of results.
3084
3469
  * @param options Additional options to be used when performing the query.
3085
3470
  * @returns An array of records from the database.
3086
3471
  */
3087
- getMany(): Promise<Result[]>;
3088
- getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Result[]>;
3089
- getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
3472
+ getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<RecordArray<SelectedPick<Record, typeof options['columns']>>>;
3473
+ /**
3474
+ * Performs the query in the database and returns a set of results.
3475
+ * @param options Additional options to be used when performing the query.
3476
+ * @returns An array of records from the database.
3477
+ */
3478
+ getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<RecordArray<Result>>;
3090
3479
  /**
3091
3480
  * Performs the query in the database and returns all the results.
3092
3481
  * Warning: If there are a large number of results, this method can have performance implications.
3093
- * @param options Additional options to be used when performing the query.
3094
3482
  * @returns An array of records from the database.
3095
3483
  */
3096
3484
  getAll(): Promise<Result[]>;
3097
- getAll(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
3098
- batchSize?: number;
3099
- }): Promise<Result[]>;
3485
+ /**
3486
+ * Performs the query in the database and returns all the results.
3487
+ * Warning: If there are a large number of results, this method can have performance implications.
3488
+ * @param options Additional options to be used when performing the query.
3489
+ * @returns An array of records from the database.
3490
+ */
3100
3491
  getAll<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
3101
3492
  batchSize?: number;
3102
3493
  }>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
3103
3494
  /**
3104
- * Performs the query in the database and returns the first result.
3495
+ * Performs the query in the database and returns all the results.
3496
+ * Warning: If there are a large number of results, this method can have performance implications.
3105
3497
  * @param options Additional options to be used when performing the query.
3498
+ * @returns An array of records from the database.
3499
+ */
3500
+ getAll(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
3501
+ batchSize?: number;
3502
+ }): Promise<Result[]>;
3503
+ /**
3504
+ * Performs the query in the database and returns the first result.
3106
3505
  * @returns The first record that matches the query, or null if no record matched the query.
3107
3506
  */
3108
3507
  getFirst(): Promise<Result | null>;
3109
- getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
3508
+ /**
3509
+ * Performs the query in the database and returns the first result.
3510
+ * @param options Additional options to be used when performing the query.
3511
+ * @returns The first record that matches the query, or null if no record matched the query.
3512
+ */
3110
3513
  getFirst<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
3514
+ /**
3515
+ * Performs the query in the database and returns the first result.
3516
+ * @param options Additional options to be used when performing the query.
3517
+ * @returns The first record that matches the query, or null if no record matched the query.
3518
+ */
3519
+ getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
3111
3520
  /**
3112
3521
  * Builds a new query object adding a cache TTL in milliseconds.
3113
3522
  * @param ttl The cache TTL in milliseconds.
3114
3523
  * @returns A new Query object.
3115
3524
  */
3116
3525
  cache(ttl: number): Query<Record, Result>;
3526
+ /**
3527
+ * Retrieve next page of records
3528
+ *
3529
+ * @returns A new page object.
3530
+ */
3117
3531
  nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3532
+ /**
3533
+ * Retrieve previous page of records
3534
+ *
3535
+ * @returns A new page object
3536
+ */
3118
3537
  previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3538
+ /**
3539
+ * Retrieve first page of records
3540
+ *
3541
+ * @returns A new page object
3542
+ */
3119
3543
  firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3544
+ /**
3545
+ * Retrieve last page of records
3546
+ *
3547
+ * @returns A new page object
3548
+ */
3120
3549
  lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3550
+ /**
3551
+ * @returns Boolean indicating if there is a next page
3552
+ */
3121
3553
  hasNextPage(): boolean;
3122
3554
  }
3123
3555
 
@@ -3129,7 +3561,7 @@ declare type PaginationQueryMeta = {
3129
3561
  };
3130
3562
  interface Paginable<Record extends XataRecord, Result extends XataRecord = Record> {
3131
3563
  meta: PaginationQueryMeta;
3132
- records: Result[];
3564
+ records: RecordArray<Result>;
3133
3565
  nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3134
3566
  previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3135
3567
  firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
@@ -3149,7 +3581,7 @@ declare class Page<Record extends XataRecord, Result extends XataRecord = Record
3149
3581
  /**
3150
3582
  * The set of results for this page.
3151
3583
  */
3152
- readonly records: Result[];
3584
+ readonly records: RecordArray<Result>;
3153
3585
  constructor(query: Query<Record, Result>, meta: PaginationQueryMeta, records?: Result[]);
3154
3586
  /**
3155
3587
  * Retrieves the next page of results.
@@ -3198,40 +3630,153 @@ declare type OffsetNavigationOptions = {
3198
3630
  offset?: number;
3199
3631
  };
3200
3632
  declare const PAGINATION_MAX_SIZE = 200;
3201
- declare const PAGINATION_DEFAULT_SIZE = 200;
3633
+ declare const PAGINATION_DEFAULT_SIZE = 20;
3202
3634
  declare const PAGINATION_MAX_OFFSET = 800;
3203
3635
  declare const PAGINATION_DEFAULT_OFFSET = 0;
3636
+ declare function isCursorPaginationOptions(options: Record<string, unknown> | undefined | null): options is CursorNavigationOptions;
3637
+ declare class RecordArray<Result extends XataRecord> extends Array<Result> {
3638
+ #private;
3639
+ constructor(page: Paginable<any, Result>, overrideRecords?: Result[]);
3640
+ static parseConstructorParams(...args: any[]): any[];
3641
+ toArray(): Result[];
3642
+ map<U>(callbackfn: (value: Result, index: number, array: Result[]) => U, thisArg?: any): U[];
3643
+ /**
3644
+ * Retrieve next page of records
3645
+ *
3646
+ * @returns A new array of objects
3647
+ */
3648
+ nextPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3649
+ /**
3650
+ * Retrieve previous page of records
3651
+ *
3652
+ * @returns A new array of objects
3653
+ */
3654
+ previousPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3655
+ /**
3656
+ * Retrieve first page of records
3657
+ *
3658
+ * @returns A new array of objects
3659
+ */
3660
+ firstPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3661
+ /**
3662
+ * Retrieve last page of records
3663
+ *
3664
+ * @returns A new array of objects
3665
+ */
3666
+ lastPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3667
+ /**
3668
+ * @returns Boolean indicating if there is a next page
3669
+ */
3670
+ hasNextPage(): boolean;
3671
+ }
3204
3672
 
3205
3673
  /**
3206
3674
  * Common interface for performing operations on a table.
3207
3675
  */
3208
3676
  declare abstract class Repository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, Readonly<SelectedPick<Record, ['*']>>> {
3209
- abstract create(object: EditableData<Data> & Partial<Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3677
+ abstract create<K extends SelectableColumn<Record>>(object: Omit<EditableData<Data>, 'id'> & Partial<Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3678
+ abstract create(object: Omit<EditableData<Data>, 'id'> & Partial<Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3210
3679
  /**
3211
3680
  * Creates a single record in the table with a unique id.
3212
3681
  * @param id The unique id.
3213
3682
  * @param object Object containing the column names with their values to be stored in the table.
3683
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3214
3684
  * @returns The full persisted record.
3215
3685
  */
3216
- abstract create(id: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3686
+ abstract create<K extends SelectableColumn<Record>>(id: string, object: Omit<EditableData<Data>, 'id'>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3687
+ /**
3688
+ * Creates a single record in the table with a unique id.
3689
+ * @param id The unique id.
3690
+ * @param object Object containing the column names with their values to be stored in the table.
3691
+ * @returns The full persisted record.
3692
+ */
3693
+ abstract create(id: string, object: Omit<EditableData<Data>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3217
3694
  /**
3218
3695
  * Creates multiple records in the table.
3219
3696
  * @param objects Array of objects with the column names and the values to be stored in the table.
3220
- * @returns Array of the persisted records.
3697
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3698
+ * @returns Array of the persisted records in order.
3221
3699
  */
3222
- abstract create(objects: Array<EditableData<Data> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3700
+ abstract create<K extends SelectableColumn<Record>>(objects: Array<Omit<EditableData<Data>, 'id'> & Partial<Identifiable>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3701
+ /**
3702
+ * Creates multiple records in the table.
3703
+ * @param objects Array of objects with the column names and the values to be stored in the table.
3704
+ * @returns Array of the persisted records in order.
3705
+ */
3706
+ abstract create(objects: Array<Omit<EditableData<Data>, 'id'> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3707
+ /**
3708
+ * Queries a single record from the table given its unique id.
3709
+ * @param id The unique id.
3710
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3711
+ * @returns The persisted record for the given id or null if the record could not be found.
3712
+ */
3713
+ abstract read<K extends SelectableColumn<Record>>(id: string, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns> | null>>;
3223
3714
  /**
3224
3715
  * Queries a single record from the table given its unique id.
3225
3716
  * @param id The unique id.
3226
3717
  * @returns The persisted record for the given id or null if the record could not be found.
3227
3718
  */
3228
3719
  abstract read(id: string): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
3720
+ /**
3721
+ * Queries multiple records from the table given their unique id.
3722
+ * @param ids The unique ids array.
3723
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3724
+ * @returns The persisted records for the given ids in order (if a record could not be found null is returned).
3725
+ */
3726
+ abstract read<K extends SelectableColumn<Record>>(ids: string[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3727
+ /**
3728
+ * Queries multiple records from the table given their unique id.
3729
+ * @param ids The unique ids array.
3730
+ * @returns The persisted records for the given ids in order (if a record could not be found null is returned).
3731
+ */
3732
+ abstract read(ids: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3733
+ /**
3734
+ * Queries a single record from the table by the id in the object.
3735
+ * @param object Object containing the id of the record.
3736
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3737
+ * @returns The persisted record for the given id or null if the record could not be found.
3738
+ */
3739
+ abstract read<K extends SelectableColumn<Record>>(object: Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns> | null>>;
3740
+ /**
3741
+ * Queries a single record from the table by the id in the object.
3742
+ * @param object Object containing the id of the record.
3743
+ * @returns The persisted record for the given id or null if the record could not be found.
3744
+ */
3745
+ abstract read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
3746
+ /**
3747
+ * Queries multiple records from the table by the ids in the objects.
3748
+ * @param objects Array of objects containing the ids of the records.
3749
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3750
+ * @returns The persisted records for the given ids in order (if a record could not be found null is returned).
3751
+ */
3752
+ abstract read<K extends SelectableColumn<Record>>(objects: Identifiable[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3753
+ /**
3754
+ * Queries multiple records from the table by the ids in the objects.
3755
+ * @param objects Array of objects containing the ids of the records.
3756
+ * @returns The persisted records for the given ids in order (if a record could not be found null is returned).
3757
+ */
3758
+ abstract read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3759
+ /**
3760
+ * Partially update a single record.
3761
+ * @param object An object with its id and the columns to be updated.
3762
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3763
+ * @returns The full persisted record.
3764
+ */
3765
+ abstract update<K extends SelectableColumn<Record>>(object: Partial<EditableData<Data>> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3229
3766
  /**
3230
3767
  * Partially update a single record.
3231
3768
  * @param object An object with its id and the columns to be updated.
3232
3769
  * @returns The full persisted record.
3233
3770
  */
3234
3771
  abstract update(object: Partial<EditableData<Data>> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3772
+ /**
3773
+ * Partially update a single record given its unique id.
3774
+ * @param id The unique id.
3775
+ * @param object The column names and their values that have to be updated.
3776
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3777
+ * @returns The full persisted record.
3778
+ */
3779
+ abstract update<K extends SelectableColumn<Record>>(id: string, object: Partial<EditableData<Data>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3235
3780
  /**
3236
3781
  * Partially update a single record given its unique id.
3237
3782
  * @param id The unique id.
@@ -3242,9 +3787,24 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3242
3787
  /**
3243
3788
  * Partially updates multiple records.
3244
3789
  * @param objects An array of objects with their ids and columns to be updated.
3245
- * @returns Array of the persisted records.
3790
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3791
+ * @returns Array of the persisted records in order.
3792
+ */
3793
+ abstract update<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Data>> & Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3794
+ /**
3795
+ * Partially updates multiple records.
3796
+ * @param objects An array of objects with their ids and columns to be updated.
3797
+ * @returns Array of the persisted records in order.
3246
3798
  */
3247
3799
  abstract update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3800
+ /**
3801
+ * Creates or updates a single record. If a record exists with the given id,
3802
+ * it will be update, otherwise a new record will be created.
3803
+ * @param object Object containing the column names with their values to be persisted in the table.
3804
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3805
+ * @returns The full persisted record.
3806
+ */
3807
+ abstract createOrUpdate<K extends SelectableColumn<Record>>(object: EditableData<Data> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3248
3808
  /**
3249
3809
  * Creates or updates a single record. If a record exists with the given id,
3250
3810
  * it will be update, otherwise a new record will be created.
@@ -3252,6 +3812,15 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3252
3812
  * @returns The full persisted record.
3253
3813
  */
3254
3814
  abstract createOrUpdate(object: EditableData<Data> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3815
+ /**
3816
+ * Creates or updates a single record. If a record exists with the given id,
3817
+ * it will be update, otherwise a new record will be created.
3818
+ * @param id A unique id.
3819
+ * @param object The column names and the values to be persisted.
3820
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3821
+ * @returns The full persisted record.
3822
+ */
3823
+ abstract createOrUpdate<K extends SelectableColumn<Record>>(id: string, object: Omit<EditableData<Data>, 'id'>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3255
3824
  /**
3256
3825
  * Creates or updates a single record. If a record exists with the given id,
3257
3826
  * it will be update, otherwise a new record will be created.
@@ -3259,7 +3828,15 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3259
3828
  * @param object The column names and the values to be persisted.
3260
3829
  * @returns The full persisted record.
3261
3830
  */
3262
- abstract createOrUpdate(id: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3831
+ abstract createOrUpdate(id: string, object: Omit<EditableData<Data>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3832
+ /**
3833
+ * Creates or updates a single record. If a record exists with the given id,
3834
+ * it will be update, otherwise a new record will be created.
3835
+ * @param objects Array of objects with the column names and the values to be stored in the table.
3836
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3837
+ * @returns Array of the persisted records.
3838
+ */
3839
+ abstract createOrUpdate<K extends SelectableColumn<Record>>(objects: Array<EditableData<Data> & Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3263
3840
  /**
3264
3841
  * Creates or updates a single record. If a record exists with the given id,
3265
3842
  * it will be update, otherwise a new record will be created.
@@ -3298,35 +3875,112 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3298
3875
  * @returns The found records.
3299
3876
  */
3300
3877
  abstract search(query: string, options?: {
3301
- fuzziness?: number;
3302
- }): Promise<SelectedPick<Record, ['*']>[]>;
3878
+ fuzziness?: FuzzinessExpression;
3879
+ prefix?: PrefixExpression;
3880
+ highlight?: HighlightExpression;
3881
+ filter?: Filter<Record>;
3882
+ boosters?: Boosters<Record>[];
3883
+ }): Promise<SearchXataRecord<SelectedPick<Record, ['*']>>[]>;
3303
3884
  abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
3304
3885
  }
3305
3886
  declare class RestRepository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, SelectedPick<Record, ['*']>> implements Repository<Data, Record> {
3306
3887
  #private;
3307
- db: SchemaPluginResult<any>;
3308
3888
  constructor(options: {
3309
3889
  table: string;
3310
3890
  db: SchemaPluginResult<any>;
3311
3891
  pluginOptions: XataPluginOptions;
3892
+ schemaTables?: Table[];
3312
3893
  });
3313
- create(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3314
- create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3315
- create(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
3316
- read(recordId: string): Promise<SelectedPick<Record, ['*']> | null>;
3894
+ create(object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3895
+ create(recordId: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3896
+ create(objects: EditableData<Data>[]): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3897
+ create<K extends SelectableColumn<Record>>(object: EditableData<Data>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3898
+ create<K extends SelectableColumn<Record>>(recordId: string, object: EditableData<Data>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3899
+ create<K extends SelectableColumn<Record>>(objects: EditableData<Data>[], columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3900
+ read(recordId: string): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3901
+ read(recordIds: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3902
+ read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3903
+ read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3904
+ read<K extends SelectableColumn<Record>>(recordId: string, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3905
+ read<K extends SelectableColumn<Record>>(recordIds: string[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>>>>;
3906
+ read<K extends SelectableColumn<Record>>(object: Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3907
+ read<K extends SelectableColumn<Record>>(objects: Identifiable[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>>>>;
3317
3908
  update(object: Partial<EditableData<Data>> & Identifiable): Promise<SelectedPick<Record, ['*']>>;
3318
3909
  update(recordId: string, object: Partial<EditableData<Data>>): Promise<SelectedPick<Record, ['*']>>;
3319
3910
  update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<SelectedPick<Record, ['*']>[]>;
3911
+ update<K extends SelectableColumn<Record>>(object: Partial<EditableData<Data>> & Identifiable, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
3912
+ update<K extends SelectableColumn<Record>>(recordId: string, object: Partial<EditableData<Data>>, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
3913
+ update<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Data>> & Identifiable>, columns: K[]): Promise<SelectedPick<Record, typeof columns>[]>;
3320
3914
  createOrUpdate(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3321
3915
  createOrUpdate(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3322
3916
  createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
3917
+ createOrUpdate<K extends SelectableColumn<Record>>(object: EditableData<Data>, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
3918
+ createOrUpdate<K extends SelectableColumn<Record>>(recordId: string, object: EditableData<Data>, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
3919
+ createOrUpdate<K extends SelectableColumn<Record>>(objects: EditableData<Data>[], columns: K[]): Promise<SelectedPick<Record, typeof columns>[]>;
3323
3920
  delete(a: string | Identifiable | Array<string | Identifiable>): Promise<void>;
3324
3921
  search(query: string, options?: {
3325
- fuzziness?: number;
3326
- }): Promise<SelectedPick<Record, ['*']>[]>;
3922
+ fuzziness?: FuzzinessExpression;
3923
+ prefix?: PrefixExpression;
3924
+ highlight?: HighlightExpression;
3925
+ filter?: Filter<Record>;
3926
+ boosters?: Boosters<Record>[];
3927
+ }): Promise<any>;
3327
3928
  query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
3328
3929
  }
3329
3930
 
3931
+ declare type BaseSchema = {
3932
+ name: string;
3933
+ columns: readonly ({
3934
+ name: string;
3935
+ type: Column['type'];
3936
+ } | {
3937
+ name: string;
3938
+ type: 'link';
3939
+ link: {
3940
+ table: string;
3941
+ };
3942
+ } | {
3943
+ name: string;
3944
+ type: 'object';
3945
+ columns: {
3946
+ name: string;
3947
+ type: string;
3948
+ }[];
3949
+ })[];
3950
+ };
3951
+ declare type SchemaInference<T extends readonly BaseSchema[]> = T extends never[] ? Record<string, Record<string, any>> : T extends readonly unknown[] ? T[number] extends {
3952
+ name: string;
3953
+ columns: readonly unknown[];
3954
+ } ? {
3955
+ [K in T[number]['name']]: TableType<T[number], K>;
3956
+ } : never : never;
3957
+ declare type TableType<Tables, TableName> = Tables & {
3958
+ name: TableName;
3959
+ } extends infer Table ? Table extends {
3960
+ name: string;
3961
+ columns: infer Columns;
3962
+ } ? Columns extends readonly unknown[] ? Columns[number] extends {
3963
+ name: string;
3964
+ type: string;
3965
+ } ? Identifiable & {
3966
+ [K in Columns[number]['name']]?: PropertyType<Tables, Columns[number], K>;
3967
+ } : never : never : never : never;
3968
+ declare type PropertyType<Tables, Properties, PropertyName> = Properties & {
3969
+ name: PropertyName;
3970
+ } extends infer Property ? Property extends {
3971
+ name: string;
3972
+ type: infer Type;
3973
+ link?: {
3974
+ table: infer LinkedTable;
3975
+ };
3976
+ columns?: infer ObjectColumns;
3977
+ } ? (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 {
3978
+ name: string;
3979
+ type: string;
3980
+ } ? {
3981
+ [K in ObjectColumns[number]['name']]?: PropertyType<Tables, ObjectColumns[number], K>;
3982
+ } : never : never : Type extends 'link' ? TableType<Tables, LinkedTable> & XataRecord : never) | null : never : never;
3983
+
3330
3984
  /**
3331
3985
  * Operator to restrict results to only values that are greater than the given value.
3332
3986
  */
@@ -3410,38 +4064,10 @@ declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
3410
4064
  };
3411
4065
  declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
3412
4066
  #private;
3413
- private tableNames?;
3414
- constructor(tableNames?: string[] | undefined);
4067
+ constructor(schemaTables?: Schemas.Table[]);
3415
4068
  build(pluginOptions: XataPluginOptions): SchemaPluginResult<Schemas>;
3416
4069
  }
3417
4070
 
3418
- declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
3419
- fuzziness?: number;
3420
- tables?: Tables[];
3421
- };
3422
- declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
3423
- all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
3424
- [Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]: {
3425
- table: Model;
3426
- record: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
3427
- };
3428
- }>[]>;
3429
- byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
3430
- [Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
3431
- }>;
3432
- };
3433
- declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
3434
- #private;
3435
- private db;
3436
- constructor(db: SchemaPluginResult<Schemas>);
3437
- build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
3438
- }
3439
- declare type SearchXataRecord = XataRecord & {
3440
- xata: {
3441
- table: string;
3442
- };
3443
- };
3444
-
3445
4071
  declare type BranchStrategyValue = string | undefined | null;
3446
4072
  declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
3447
4073
  declare type BranchStrategy = BranchStrategyValue | BranchStrategyBuilder;
@@ -3453,35 +4079,129 @@ declare type BaseClientOptions = {
3453
4079
  databaseURL?: string;
3454
4080
  branch?: BranchStrategyOption;
3455
4081
  cache?: CacheImpl;
4082
+ trace?: TraceFunction;
3456
4083
  };
3457
4084
  declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
3458
4085
  interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
3459
- new <Schemas extends Record<string, BaseData> = {}>(options?: Partial<BaseClientOptions>, tables?: string[]): Omit<{
3460
- db: Awaited<ReturnType<SchemaPlugin<Schemas>['build']>>;
3461
- search: Awaited<ReturnType<SearchPlugin<Schemas>['build']>>;
4086
+ new <T extends readonly BaseSchema[]>(options?: Partial<BaseClientOptions>, schemaTables?: T): Omit<{
4087
+ db: Awaited<ReturnType<SchemaPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
4088
+ search: Awaited<ReturnType<SearchPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
3462
4089
  }, keyof Plugins> & {
3463
4090
  [Key in StringKeys<NonNullable<Plugins>>]: Awaited<ReturnType<NonNullable<Plugins>[Key]['build']>>;
4091
+ } & {
4092
+ getConfig(): Promise<{
4093
+ databaseURL: string;
4094
+ branch: string;
4095
+ }>;
3464
4096
  };
3465
4097
  }
3466
4098
  declare const BaseClient_base: ClientConstructor<{}>;
3467
- declare class BaseClient extends BaseClient_base<Record<string, any>> {
4099
+ declare class BaseClient extends BaseClient_base<[]> {
4100
+ }
4101
+
4102
+ declare class Serializer {
4103
+ classes: Record<string, any>;
4104
+ add(clazz: any): void;
4105
+ toJSON<T>(data: T): string;
4106
+ fromJSON<T>(json: string): T;
3468
4107
  }
4108
+ declare const serialize: <T>(data: T) => string;
4109
+ declare const deserialize: <T>(json: string) => T;
3469
4110
 
3470
- declare const defaultBranch = "main";
3471
4111
  declare type BranchResolutionOptions = {
3472
4112
  databaseURL?: string;
3473
4113
  apiKey?: string;
3474
4114
  fetchImpl?: FetchImpl;
3475
4115
  };
3476
- declare function getCurrentBranchName(options?: BranchResolutionOptions): Promise<string | undefined>;
4116
+ declare function getCurrentBranchName(options?: BranchResolutionOptions): Promise<string>;
3477
4117
  declare function getCurrentBranchDetails(options?: BranchResolutionOptions): Promise<DBBranch | null>;
3478
4118
  declare function getDatabaseURL(): string | undefined;
3479
4119
 
3480
4120
  declare function getAPIKey(): string | undefined;
3481
4121
 
4122
+ interface Body {
4123
+ arrayBuffer(): Promise<ArrayBuffer>;
4124
+ blob(): Promise<Blob>;
4125
+ formData(): Promise<FormData>;
4126
+ json(): Promise<any>;
4127
+ text(): Promise<string>;
4128
+ }
4129
+ interface Blob {
4130
+ readonly size: number;
4131
+ readonly type: string;
4132
+ arrayBuffer(): Promise<ArrayBuffer>;
4133
+ slice(start?: number, end?: number, contentType?: string): Blob;
4134
+ text(): Promise<string>;
4135
+ }
4136
+ /** Provides information about files and allows JavaScript in a web page to access their content. */
4137
+ interface File extends Blob {
4138
+ readonly lastModified: number;
4139
+ readonly name: string;
4140
+ readonly webkitRelativePath: string;
4141
+ }
4142
+ declare type FormDataEntryValue = File | string;
4143
+ /** 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". */
4144
+ interface FormData {
4145
+ append(name: string, value: string | Blob, fileName?: string): void;
4146
+ delete(name: string): void;
4147
+ get(name: string): FormDataEntryValue | null;
4148
+ getAll(name: string): FormDataEntryValue[];
4149
+ has(name: string): boolean;
4150
+ set(name: string, value: string | Blob, fileName?: string): void;
4151
+ forEach(callbackfn: (value: FormDataEntryValue, key: string, parent: FormData) => void, thisArg?: any): void;
4152
+ }
4153
+ /** 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. */
4154
+ interface Headers {
4155
+ append(name: string, value: string): void;
4156
+ delete(name: string): void;
4157
+ get(name: string): string | null;
4158
+ has(name: string): boolean;
4159
+ set(name: string, value: string): void;
4160
+ forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void;
4161
+ }
4162
+ interface Request extends Body {
4163
+ /** Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching. */
4164
+ readonly cache: 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload';
4165
+ /** 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. */
4166
+ readonly credentials: 'include' | 'omit' | 'same-origin';
4167
+ /** Returns the kind of resource requested by request, e.g., "document" or "script". */
4168
+ readonly destination: '' | 'audio' | 'audioworklet' | 'document' | 'embed' | 'font' | 'frame' | 'iframe' | 'image' | 'manifest' | 'object' | 'paintworklet' | 'report' | 'script' | 'sharedworker' | 'style' | 'track' | 'video' | 'worker' | 'xslt';
4169
+ /** 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. */
4170
+ readonly headers: Headers;
4171
+ /** 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] */
4172
+ readonly integrity: string;
4173
+ /** Returns a boolean indicating whether or not request can outlive the global in which it was created. */
4174
+ readonly keepalive: boolean;
4175
+ /** Returns request's HTTP method, which is "GET" by default. */
4176
+ readonly method: string;
4177
+ /** 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. */
4178
+ readonly mode: 'cors' | 'navigate' | 'no-cors' | 'same-origin';
4179
+ /** 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. */
4180
+ readonly redirect: 'error' | 'follow' | 'manual';
4181
+ /** 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. */
4182
+ readonly referrer: string;
4183
+ /** Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer. */
4184
+ readonly referrerPolicy: '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
4185
+ /** Returns the URL of request as a string. */
4186
+ readonly url: string;
4187
+ clone(): Request;
4188
+ }
4189
+
4190
+ declare type XataWorkerContext<XataClient> = {
4191
+ xata: XataClient;
4192
+ request: Request;
4193
+ env: Record<string, string | undefined>;
4194
+ };
4195
+ declare type RemoveFirst<T> = T extends [any, ...infer U] ? U : never;
4196
+ declare type WorkerRunnerConfig = {
4197
+ workspace: string;
4198
+ worker: string;
4199
+ };
4200
+ 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>>>;
4201
+
3482
4202
  declare class XataError extends Error {
3483
4203
  readonly status: number;
3484
4204
  constructor(message: string, status: number);
3485
4205
  }
3486
4206
 
3487
- export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddGitBranchesEntryError, AddGitBranchesEntryPathParams, AddGitBranchesEntryRequestBody, AddGitBranchesEntryResponse, AddGitBranchesEntryVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsResponse, BulkInsertTableRecordsVariables, CacheImpl, CancelWorkspaceMemberInviteError, CancelWorkspaceMemberInvitePathParams, CancelWorkspaceMemberInviteVariables, ClientConstructor, CreateBranchError, CreateBranchPathParams, CreateBranchQueryParams, CreateBranchRequestBody, CreateBranchVariables, CreateDatabaseError, CreateDatabasePathParams, CreateDatabaseRequestBody, CreateDatabaseResponse, CreateDatabaseVariables, CreateTableError, CreateTablePathParams, CreateTableVariables, CreateUserAPIKeyError, CreateUserAPIKeyPathParams, CreateUserAPIKeyResponse, CreateUserAPIKeyVariables, CreateWorkspaceError, CreateWorkspaceVariables, CursorNavigationOptions, DeleteBranchError, DeleteBranchPathParams, DeleteBranchVariables, DeleteColumnError, DeleteColumnPathParams, DeleteColumnVariables, DeleteDatabaseError, DeleteDatabasePathParams, DeleteDatabaseVariables, DeleteRecordError, DeleteRecordPathParams, DeleteRecordVariables, DeleteTableError, DeleteTablePathParams, DeleteTableVariables, DeleteUserAPIKeyError, DeleteUserAPIKeyPathParams, DeleteUserAPIKeyVariables, DeleteUserError, DeleteUserVariables, DeleteWorkspaceError, DeleteWorkspacePathParams, DeleteWorkspaceVariables, EditableData, ExecuteBranchMigrationPlanError, ExecuteBranchMigrationPlanPathParams, ExecuteBranchMigrationPlanRequestBody, ExecuteBranchMigrationPlanVariables, FetchImpl, FetcherExtraProps, GetBranchDetailsError, GetBranchDetailsPathParams, GetBranchDetailsVariables, GetBranchListError, GetBranchListPathParams, GetBranchListVariables, GetBranchMetadataError, GetBranchMetadataPathParams, GetBranchMetadataVariables, GetBranchMigrationHistoryError, GetBranchMigrationHistoryPathParams, GetBranchMigrationHistoryRequestBody, GetBranchMigrationHistoryResponse, GetBranchMigrationHistoryVariables, GetBranchMigrationPlanError, GetBranchMigrationPlanPathParams, GetBranchMigrationPlanVariables, GetBranchStatsError, GetBranchStatsPathParams, GetBranchStatsResponse, GetBranchStatsVariables, GetColumnError, GetColumnPathParams, GetColumnVariables, GetDatabaseListError, GetDatabaseListPathParams, GetDatabaseListVariables, GetGitBranchesMappingError, GetGitBranchesMappingPathParams, GetGitBranchesMappingVariables, GetRecordError, GetRecordPathParams, GetRecordRequestBody, GetRecordVariables, GetTableColumnsError, GetTableColumnsPathParams, GetTableColumnsResponse, GetTableColumnsVariables, GetTableSchemaError, GetTableSchemaPathParams, GetTableSchemaResponse, GetTableSchemaVariables, GetUserAPIKeysError, GetUserAPIKeysResponse, GetUserAPIKeysVariables, GetUserError, GetUserVariables, GetWorkspaceError, GetWorkspaceMembersListError, GetWorkspaceMembersListPathParams, GetWorkspaceMembersListVariables, GetWorkspacePathParams, GetWorkspaceVariables, GetWorkspacesListError, GetWorkspacesListResponse, GetWorkspacesListVariables, Identifiable, InsertRecordError, InsertRecordPathParams, InsertRecordResponse, InsertRecordVariables, InsertRecordWithIDError, InsertRecordWithIDPathParams, InsertRecordWithIDQueryParams, InsertRecordWithIDVariables, InviteWorkspaceMemberError, InviteWorkspaceMemberPathParams, InviteWorkspaceMemberRequestBody, InviteWorkspaceMemberVariables, OffsetNavigationOptions, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Paginable, PaginationQueryMeta, Query, QueryTableError, QueryTablePathParams, QueryTableRequestBody, QueryTableVariables, RemoveGitBranchesEntryError, RemoveGitBranchesEntryPathParams, RemoveGitBranchesEntryQueryParams, RemoveGitBranchesEntryVariables, RemoveWorkspaceMemberError, RemoveWorkspaceMemberPathParams, RemoveWorkspaceMemberVariables, Repository, ResendWorkspaceMemberInviteError, ResendWorkspaceMemberInvitePathParams, ResendWorkspaceMemberInviteVariables, ResolveBranchError, ResolveBranchPathParams, ResolveBranchQueryParams, ResolveBranchResponse, ResolveBranchVariables, responses as Responses, RestRepository, SchemaDefinition, SchemaPlugin, SchemaPluginResult, schemas as Schemas, SearchBranchError, SearchBranchPathParams, SearchBranchRequestBody, SearchBranchVariables, SearchOptions, SearchPlugin, SearchPluginResult, SelectableColumn, SelectedPick, SetTableSchemaError, SetTableSchemaPathParams, SetTableSchemaRequestBody, SetTableSchemaVariables, SimpleCache, SimpleCacheOptions, UpdateBranchMetadataError, UpdateBranchMetadataPathParams, UpdateBranchMetadataVariables, UpdateColumnError, UpdateColumnPathParams, UpdateColumnRequestBody, UpdateColumnVariables, UpdateRecordWithIDError, UpdateRecordWithIDPathParams, UpdateRecordWithIDQueryParams, UpdateRecordWithIDVariables, UpdateTableError, UpdateTablePathParams, UpdateTableRequestBody, UpdateTableVariables, UpdateUserError, UpdateUserVariables, UpdateWorkspaceError, UpdateWorkspaceMemberRoleError, UpdateWorkspaceMemberRolePathParams, UpdateWorkspaceMemberRoleRequestBody, UpdateWorkspaceMemberRoleVariables, UpdateWorkspacePathParams, UpdateWorkspaceVariables, UpsertRecordWithIDError, UpsertRecordWithIDPathParams, UpsertRecordWithIDQueryParams, UpsertRecordWithIDVariables, ValueAtColumn, XataApiClient, XataApiClientOptions, XataApiPlugin, XataError, XataPlugin, XataPluginOptions, XataRecord, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, defaultBranch, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
4207
+ 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, 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, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };