@xata.io/client 0.8.3 → 0.9.1

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
@@ -14,12 +14,44 @@ declare type FetcherExtraProps = {
14
14
  fetchImpl: FetchImpl;
15
15
  apiKey: string;
16
16
  };
17
+ declare type ErrorWrapper<TError> = TError | {
18
+ status: 'unknown';
19
+ payload: string;
20
+ };
21
+
22
+ interface CacheImpl {
23
+ cacheRecords: boolean;
24
+ defaultQueryTTL: number;
25
+ getAll(): Promise<Record<string, unknown>>;
26
+ get: <T>(key: string) => Promise<T | null>;
27
+ set: <T>(key: string, value: T) => Promise<void>;
28
+ delete: (key: string) => Promise<void>;
29
+ clear: () => Promise<void>;
30
+ }
31
+ interface SimpleCacheOptions {
32
+ max?: number;
33
+ cacheRecords?: boolean;
34
+ defaultQueryTTL?: number;
35
+ }
36
+ declare class SimpleCache implements CacheImpl {
37
+ #private;
38
+ capacity: number;
39
+ cacheRecords: boolean;
40
+ defaultQueryTTL: number;
41
+ constructor(options?: SimpleCacheOptions);
42
+ getAll(): Promise<Record<string, unknown>>;
43
+ get<T>(key: string): Promise<T | null>;
44
+ set<T>(key: string, value: T): Promise<void>;
45
+ delete(key: string): Promise<void>;
46
+ clear(): Promise<void>;
47
+ }
17
48
 
18
49
  declare abstract class XataPlugin {
19
50
  abstract build(options: XataPluginOptions): unknown | Promise<unknown>;
20
51
  }
21
52
  declare type XataPluginOptions = {
22
53
  getFetchProps: () => Promise<FetcherExtraProps>;
54
+ cache: CacheImpl;
23
55
  };
24
56
 
25
57
  /**
@@ -106,6 +138,12 @@ declare type ListBranchesResponse = {
106
138
  displayName: string;
107
139
  branches: Branch[];
108
140
  };
141
+ declare type ListGitBranchesResponse = {
142
+ mapping: {
143
+ gitBranch: string;
144
+ xataBranch: string;
145
+ }[];
146
+ };
109
147
  declare type Branch = {
110
148
  name: string;
111
149
  createdAt: DateTime;
@@ -154,7 +192,7 @@ declare type Table = {
154
192
  */
155
193
  declare type Column = {
156
194
  name: string;
157
- type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object';
195
+ type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object' | 'datetime';
158
196
  link?: {
159
197
  table: string;
160
198
  };
@@ -350,6 +388,7 @@ type schemas_WorkspaceMembers = WorkspaceMembers;
350
388
  type schemas_InviteKey = InviteKey;
351
389
  type schemas_ListDatabasesResponse = ListDatabasesResponse;
352
390
  type schemas_ListBranchesResponse = ListBranchesResponse;
391
+ type schemas_ListGitBranchesResponse = ListGitBranchesResponse;
353
392
  type schemas_Branch = Branch;
354
393
  type schemas_BranchMetadata = BranchMetadata;
355
394
  type schemas_DBBranch = DBBranch;
@@ -402,6 +441,7 @@ declare namespace schemas {
402
441
  schemas_InviteKey as InviteKey,
403
442
  schemas_ListDatabasesResponse as ListDatabasesResponse,
404
443
  schemas_ListBranchesResponse as ListBranchesResponse,
444
+ schemas_ListGitBranchesResponse as ListGitBranchesResponse,
405
445
  schemas_Branch as Branch,
406
446
  schemas_BranchMetadata as BranchMetadata,
407
447
  schemas_DBBranch as DBBranch,
@@ -520,11 +560,31 @@ declare namespace responses {
520
560
  * @version 1.0
521
561
  */
522
562
 
563
+ declare type GetUserError = ErrorWrapper<{
564
+ status: 400;
565
+ payload: BadRequestError;
566
+ } | {
567
+ status: 401;
568
+ payload: AuthError;
569
+ } | {
570
+ status: 404;
571
+ payload: SimpleError;
572
+ }>;
523
573
  declare type GetUserVariables = FetcherExtraProps;
524
574
  /**
525
575
  * Return details of the user making the request
526
576
  */
527
577
  declare const getUser: (variables: GetUserVariables) => Promise<UserWithID>;
578
+ declare type UpdateUserError = ErrorWrapper<{
579
+ status: 400;
580
+ payload: BadRequestError;
581
+ } | {
582
+ status: 401;
583
+ payload: AuthError;
584
+ } | {
585
+ status: 404;
586
+ payload: SimpleError;
587
+ }>;
528
588
  declare type UpdateUserVariables = {
529
589
  body: User;
530
590
  } & FetcherExtraProps;
@@ -532,11 +592,31 @@ declare type UpdateUserVariables = {
532
592
  * Update user info
533
593
  */
534
594
  declare const updateUser: (variables: UpdateUserVariables) => Promise<UserWithID>;
595
+ declare type DeleteUserError = ErrorWrapper<{
596
+ status: 400;
597
+ payload: BadRequestError;
598
+ } | {
599
+ status: 401;
600
+ payload: AuthError;
601
+ } | {
602
+ status: 404;
603
+ payload: SimpleError;
604
+ }>;
535
605
  declare type DeleteUserVariables = FetcherExtraProps;
536
606
  /**
537
607
  * Delete the user making the request
538
608
  */
539
609
  declare const deleteUser: (variables: DeleteUserVariables) => Promise<undefined>;
610
+ declare type GetUserAPIKeysError = ErrorWrapper<{
611
+ status: 400;
612
+ payload: BadRequestError;
613
+ } | {
614
+ status: 401;
615
+ payload: AuthError;
616
+ } | {
617
+ status: 404;
618
+ payload: SimpleError;
619
+ }>;
540
620
  declare type GetUserAPIKeysResponse = {
541
621
  keys: {
542
622
  name: string;
@@ -551,6 +631,16 @@ declare const getUserAPIKeys: (variables: GetUserAPIKeysVariables) => Promise<Ge
551
631
  declare type CreateUserAPIKeyPathParams = {
552
632
  keyName: APIKeyName;
553
633
  };
634
+ declare type CreateUserAPIKeyError = ErrorWrapper<{
635
+ status: 400;
636
+ payload: BadRequestError;
637
+ } | {
638
+ status: 401;
639
+ payload: AuthError;
640
+ } | {
641
+ status: 404;
642
+ payload: SimpleError;
643
+ }>;
554
644
  declare type CreateUserAPIKeyResponse = {
555
645
  name: string;
556
646
  key: string;
@@ -566,6 +656,16 @@ declare const createUserAPIKey: (variables: CreateUserAPIKeyVariables) => Promis
566
656
  declare type DeleteUserAPIKeyPathParams = {
567
657
  keyName: APIKeyName;
568
658
  };
659
+ declare type DeleteUserAPIKeyError = ErrorWrapper<{
660
+ status: 400;
661
+ payload: BadRequestError;
662
+ } | {
663
+ status: 401;
664
+ payload: AuthError;
665
+ } | {
666
+ status: 404;
667
+ payload: SimpleError;
668
+ }>;
569
669
  declare type DeleteUserAPIKeyVariables = {
570
670
  pathParams: DeleteUserAPIKeyPathParams;
571
671
  } & FetcherExtraProps;
@@ -573,6 +673,16 @@ declare type DeleteUserAPIKeyVariables = {
573
673
  * Delete an existing API key
574
674
  */
575
675
  declare const deleteUserAPIKey: (variables: DeleteUserAPIKeyVariables) => Promise<undefined>;
676
+ declare type CreateWorkspaceError = ErrorWrapper<{
677
+ status: 400;
678
+ payload: BadRequestError;
679
+ } | {
680
+ status: 401;
681
+ payload: AuthError;
682
+ } | {
683
+ status: 404;
684
+ payload: SimpleError;
685
+ }>;
576
686
  declare type CreateWorkspaceVariables = {
577
687
  body: WorkspaceMeta;
578
688
  } & FetcherExtraProps;
@@ -580,6 +690,16 @@ declare type CreateWorkspaceVariables = {
580
690
  * Creates a new workspace with the user requesting it as its single owner.
581
691
  */
582
692
  declare const createWorkspace: (variables: CreateWorkspaceVariables) => Promise<Workspace>;
693
+ declare type GetWorkspacesListError = ErrorWrapper<{
694
+ status: 400;
695
+ payload: BadRequestError;
696
+ } | {
697
+ status: 401;
698
+ payload: AuthError;
699
+ } | {
700
+ status: 404;
701
+ payload: SimpleError;
702
+ }>;
583
703
  declare type GetWorkspacesListResponse = {
584
704
  workspaces: {
585
705
  id: WorkspaceID;
@@ -596,6 +716,16 @@ declare const getWorkspacesList: (variables: GetWorkspacesListVariables) => Prom
596
716
  declare type GetWorkspacePathParams = {
597
717
  workspaceId: WorkspaceID;
598
718
  };
719
+ declare type GetWorkspaceError = ErrorWrapper<{
720
+ status: 400;
721
+ payload: BadRequestError;
722
+ } | {
723
+ status: 401;
724
+ payload: AuthError;
725
+ } | {
726
+ status: 404;
727
+ payload: SimpleError;
728
+ }>;
599
729
  declare type GetWorkspaceVariables = {
600
730
  pathParams: GetWorkspacePathParams;
601
731
  } & FetcherExtraProps;
@@ -606,6 +736,16 @@ declare const getWorkspace: (variables: GetWorkspaceVariables) => Promise<Worksp
606
736
  declare type UpdateWorkspacePathParams = {
607
737
  workspaceId: WorkspaceID;
608
738
  };
739
+ declare type UpdateWorkspaceError = ErrorWrapper<{
740
+ status: 400;
741
+ payload: BadRequestError;
742
+ } | {
743
+ status: 401;
744
+ payload: AuthError;
745
+ } | {
746
+ status: 404;
747
+ payload: SimpleError;
748
+ }>;
609
749
  declare type UpdateWorkspaceVariables = {
610
750
  body: WorkspaceMeta;
611
751
  pathParams: UpdateWorkspacePathParams;
@@ -617,6 +757,16 @@ declare const updateWorkspace: (variables: UpdateWorkspaceVariables) => Promise<
617
757
  declare type DeleteWorkspacePathParams = {
618
758
  workspaceId: WorkspaceID;
619
759
  };
760
+ declare type DeleteWorkspaceError = ErrorWrapper<{
761
+ status: 400;
762
+ payload: BadRequestError;
763
+ } | {
764
+ status: 401;
765
+ payload: AuthError;
766
+ } | {
767
+ status: 404;
768
+ payload: SimpleError;
769
+ }>;
620
770
  declare type DeleteWorkspaceVariables = {
621
771
  pathParams: DeleteWorkspacePathParams;
622
772
  } & FetcherExtraProps;
@@ -627,6 +777,16 @@ declare const deleteWorkspace: (variables: DeleteWorkspaceVariables) => Promise<
627
777
  declare type GetWorkspaceMembersListPathParams = {
628
778
  workspaceId: WorkspaceID;
629
779
  };
780
+ declare type GetWorkspaceMembersListError = ErrorWrapper<{
781
+ status: 400;
782
+ payload: BadRequestError;
783
+ } | {
784
+ status: 401;
785
+ payload: AuthError;
786
+ } | {
787
+ status: 404;
788
+ payload: SimpleError;
789
+ }>;
630
790
  declare type GetWorkspaceMembersListVariables = {
631
791
  pathParams: GetWorkspaceMembersListPathParams;
632
792
  } & FetcherExtraProps;
@@ -638,6 +798,16 @@ declare type UpdateWorkspaceMemberRolePathParams = {
638
798
  workspaceId: WorkspaceID;
639
799
  userId: UserID;
640
800
  };
801
+ declare type UpdateWorkspaceMemberRoleError = ErrorWrapper<{
802
+ status: 400;
803
+ payload: BadRequestError;
804
+ } | {
805
+ status: 401;
806
+ payload: AuthError;
807
+ } | {
808
+ status: 404;
809
+ payload: SimpleError;
810
+ }>;
641
811
  declare type UpdateWorkspaceMemberRoleRequestBody = {
642
812
  role: Role;
643
813
  };
@@ -653,6 +823,16 @@ declare type RemoveWorkspaceMemberPathParams = {
653
823
  workspaceId: WorkspaceID;
654
824
  userId: UserID;
655
825
  };
826
+ declare type RemoveWorkspaceMemberError = ErrorWrapper<{
827
+ status: 400;
828
+ payload: BadRequestError;
829
+ } | {
830
+ status: 401;
831
+ payload: AuthError;
832
+ } | {
833
+ status: 404;
834
+ payload: SimpleError;
835
+ }>;
656
836
  declare type RemoveWorkspaceMemberVariables = {
657
837
  pathParams: RemoveWorkspaceMemberPathParams;
658
838
  } & FetcherExtraProps;
@@ -663,6 +843,16 @@ declare const removeWorkspaceMember: (variables: RemoveWorkspaceMemberVariables)
663
843
  declare type InviteWorkspaceMemberPathParams = {
664
844
  workspaceId: WorkspaceID;
665
845
  };
846
+ declare type InviteWorkspaceMemberError = ErrorWrapper<{
847
+ status: 400;
848
+ payload: BadRequestError;
849
+ } | {
850
+ status: 401;
851
+ payload: AuthError;
852
+ } | {
853
+ status: 404;
854
+ payload: SimpleError;
855
+ }>;
666
856
  declare type InviteWorkspaceMemberRequestBody = {
667
857
  email: string;
668
858
  role: Role;
@@ -679,6 +869,16 @@ declare type CancelWorkspaceMemberInvitePathParams = {
679
869
  workspaceId: WorkspaceID;
680
870
  inviteId: InviteID;
681
871
  };
872
+ declare type CancelWorkspaceMemberInviteError = ErrorWrapper<{
873
+ status: 400;
874
+ payload: BadRequestError;
875
+ } | {
876
+ status: 401;
877
+ payload: AuthError;
878
+ } | {
879
+ status: 404;
880
+ payload: SimpleError;
881
+ }>;
682
882
  declare type CancelWorkspaceMemberInviteVariables = {
683
883
  pathParams: CancelWorkspaceMemberInvitePathParams;
684
884
  } & FetcherExtraProps;
@@ -690,6 +890,16 @@ declare type ResendWorkspaceMemberInvitePathParams = {
690
890
  workspaceId: WorkspaceID;
691
891
  inviteId: InviteID;
692
892
  };
893
+ declare type ResendWorkspaceMemberInviteError = ErrorWrapper<{
894
+ status: 400;
895
+ payload: BadRequestError;
896
+ } | {
897
+ status: 401;
898
+ payload: AuthError;
899
+ } | {
900
+ status: 404;
901
+ payload: SimpleError;
902
+ }>;
693
903
  declare type ResendWorkspaceMemberInviteVariables = {
694
904
  pathParams: ResendWorkspaceMemberInvitePathParams;
695
905
  } & FetcherExtraProps;
@@ -701,6 +911,16 @@ declare type AcceptWorkspaceMemberInvitePathParams = {
701
911
  workspaceId: WorkspaceID;
702
912
  inviteKey: InviteKey;
703
913
  };
914
+ declare type AcceptWorkspaceMemberInviteError = ErrorWrapper<{
915
+ status: 400;
916
+ payload: BadRequestError;
917
+ } | {
918
+ status: 401;
919
+ payload: AuthError;
920
+ } | {
921
+ status: 404;
922
+ payload: SimpleError;
923
+ }>;
704
924
  declare type AcceptWorkspaceMemberInviteVariables = {
705
925
  pathParams: AcceptWorkspaceMemberInvitePathParams;
706
926
  } & FetcherExtraProps;
@@ -711,6 +931,13 @@ declare const acceptWorkspaceMemberInvite: (variables: AcceptWorkspaceMemberInvi
711
931
  declare type GetDatabaseListPathParams = {
712
932
  workspace: string;
713
933
  };
934
+ declare type GetDatabaseListError = ErrorWrapper<{
935
+ status: 400;
936
+ payload: BadRequestError;
937
+ } | {
938
+ status: 401;
939
+ payload: AuthError;
940
+ }>;
714
941
  declare type GetDatabaseListVariables = {
715
942
  pathParams: GetDatabaseListPathParams;
716
943
  } & FetcherExtraProps;
@@ -722,6 +949,16 @@ declare type GetBranchListPathParams = {
722
949
  dbName: DBName;
723
950
  workspace: string;
724
951
  };
952
+ declare type GetBranchListError = ErrorWrapper<{
953
+ status: 400;
954
+ payload: BadRequestError;
955
+ } | {
956
+ status: 401;
957
+ payload: AuthError;
958
+ } | {
959
+ status: 404;
960
+ payload: SimpleError;
961
+ }>;
725
962
  declare type GetBranchListVariables = {
726
963
  pathParams: GetBranchListPathParams;
727
964
  } & FetcherExtraProps;
@@ -733,6 +970,13 @@ declare type CreateDatabasePathParams = {
733
970
  dbName: DBName;
734
971
  workspace: string;
735
972
  };
973
+ declare type CreateDatabaseError = ErrorWrapper<{
974
+ status: 400;
975
+ payload: BadRequestError;
976
+ } | {
977
+ status: 401;
978
+ payload: AuthError;
979
+ }>;
736
980
  declare type CreateDatabaseResponse = {
737
981
  databaseName: string;
738
982
  branchName?: string;
@@ -757,6 +1001,16 @@ declare type DeleteDatabasePathParams = {
757
1001
  dbName: DBName;
758
1002
  workspace: string;
759
1003
  };
1004
+ declare type DeleteDatabaseError = ErrorWrapper<{
1005
+ status: 400;
1006
+ payload: BadRequestError;
1007
+ } | {
1008
+ status: 401;
1009
+ payload: AuthError;
1010
+ } | {
1011
+ status: 404;
1012
+ payload: SimpleError;
1013
+ }>;
760
1014
  declare type DeleteDatabaseVariables = {
761
1015
  pathParams: DeleteDatabasePathParams;
762
1016
  } & FetcherExtraProps;
@@ -764,10 +1018,176 @@ declare type DeleteDatabaseVariables = {
764
1018
  * Delete a database and all of its branches and tables permanently.
765
1019
  */
766
1020
  declare const deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
1021
+ declare type GetGitBranchesMappingPathParams = {
1022
+ dbName: DBName;
1023
+ workspace: string;
1024
+ };
1025
+ declare type GetGitBranchesMappingError = ErrorWrapper<{
1026
+ status: 400;
1027
+ payload: BadRequestError;
1028
+ } | {
1029
+ status: 401;
1030
+ payload: AuthError;
1031
+ }>;
1032
+ declare type GetGitBranchesMappingVariables = {
1033
+ pathParams: GetGitBranchesMappingPathParams;
1034
+ } & FetcherExtraProps;
1035
+ /**
1036
+ * Lists all the git branches in the mapping, and their associated Xata branches.
1037
+ *
1038
+ * Example response:
1039
+ *
1040
+ * ```json
1041
+ * {
1042
+ * "mappings": [
1043
+ * {
1044
+ * "gitBranch": "main",
1045
+ * "xataBranch": "main"
1046
+ * },
1047
+ * {
1048
+ * "gitBranch": "gitBranch1",
1049
+ * "xataBranch": "xataBranch1"
1050
+ * }
1051
+ * {
1052
+ * "gitBranch": "xataBranch2",
1053
+ * "xataBranch": "xataBranch2"
1054
+ * }
1055
+ * ]
1056
+ * }
1057
+ * ```
1058
+ */
1059
+ declare const getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
1060
+ declare type AddGitBranchesEntryPathParams = {
1061
+ dbName: DBName;
1062
+ workspace: string;
1063
+ };
1064
+ declare type AddGitBranchesEntryError = ErrorWrapper<{
1065
+ status: 400;
1066
+ payload: BadRequestError;
1067
+ } | {
1068
+ status: 401;
1069
+ payload: AuthError;
1070
+ }>;
1071
+ declare type AddGitBranchesEntryResponse = {
1072
+ warning?: string;
1073
+ };
1074
+ declare type AddGitBranchesEntryRequestBody = {
1075
+ gitBranch: string;
1076
+ xataBranch: BranchName;
1077
+ };
1078
+ declare type AddGitBranchesEntryVariables = {
1079
+ body: AddGitBranchesEntryRequestBody;
1080
+ pathParams: AddGitBranchesEntryPathParams;
1081
+ } & FetcherExtraProps;
1082
+ /**
1083
+ * Adds an entry to the mapping of git branches to Xata branches. The git branch and the Xata branch must be present in the body of the request. If the Xata branch doesn't exist, a 400 error is returned.
1084
+ *
1085
+ * If the git branch is already present in the mapping, the old entry is overwritten, and a warning message is included in the response. If the git branch is added and didn't exist before, the response code is 204. If the git branch existed and it was overwritten, the response code is 201.
1086
+ *
1087
+ * Example request:
1088
+ *
1089
+ * ```json
1090
+ * // POST https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches
1091
+ * {
1092
+ * "gitBranch": "fix/bug123",
1093
+ * "xataBranch": "fix_bug"
1094
+ * }
1095
+ * ```
1096
+ */
1097
+ declare const addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
1098
+ declare type RemoveGitBranchesEntryPathParams = {
1099
+ dbName: DBName;
1100
+ workspace: string;
1101
+ };
1102
+ declare type RemoveGitBranchesEntryQueryParams = {
1103
+ gitBranch: string;
1104
+ };
1105
+ declare type RemoveGitBranchesEntryError = ErrorWrapper<{
1106
+ status: 400;
1107
+ payload: BadRequestError;
1108
+ } | {
1109
+ status: 401;
1110
+ payload: AuthError;
1111
+ }>;
1112
+ declare type RemoveGitBranchesEntryVariables = {
1113
+ pathParams: RemoveGitBranchesEntryPathParams;
1114
+ queryParams: RemoveGitBranchesEntryQueryParams;
1115
+ } & FetcherExtraProps;
1116
+ /**
1117
+ * Removes an entry from the mapping of git branches to Xata branches. The name of the git branch must be passed as a query parameter. If the git branch is not found, the endpoint returns a 404 status code.
1118
+ *
1119
+ * Example request:
1120
+ *
1121
+ * ```json
1122
+ * // DELETE https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches?gitBranch=fix%2Fbug123
1123
+ * ```
1124
+ */
1125
+ declare const removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
1126
+ declare type ResolveBranchPathParams = {
1127
+ dbName: DBName;
1128
+ workspace: string;
1129
+ };
1130
+ declare type ResolveBranchQueryParams = {
1131
+ gitBranch?: string;
1132
+ fallbackBranch?: string;
1133
+ };
1134
+ declare type ResolveBranchError = ErrorWrapper<{
1135
+ status: 400;
1136
+ payload: BadRequestError;
1137
+ } | {
1138
+ status: 401;
1139
+ payload: AuthError;
1140
+ }>;
1141
+ declare type ResolveBranchResponse = {
1142
+ branch: string;
1143
+ reason: {
1144
+ code: 'FOUND_IN_MAPPING' | 'BRANCH_EXISTS' | 'FALLBACK_BRANCH' | 'DEFAULT_BRANCH';
1145
+ message: string;
1146
+ };
1147
+ };
1148
+ declare type ResolveBranchVariables = {
1149
+ pathParams: ResolveBranchPathParams;
1150
+ queryParams?: ResolveBranchQueryParams;
1151
+ } & FetcherExtraProps;
1152
+ /**
1153
+ * 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
1155
+ * * 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)
1157
+ *
1158
+ * Example call:
1159
+ *
1160
+ * ```json
1161
+ * // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test?fallbackBranch=tsg
1162
+ * ```
1163
+ *
1164
+ * Example response:
1165
+ *
1166
+ * ```json
1167
+ * {
1168
+ * "branch": "main",
1169
+ * "reason": {
1170
+ * "code": "DEFAULT_BRANCH",
1171
+ * "message": "Default branch for this database (main)"
1172
+ * }
1173
+ * }
1174
+ * ```
1175
+ */
1176
+ declare const resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
767
1177
  declare type GetBranchDetailsPathParams = {
768
1178
  dbBranchName: DBBranchName;
769
1179
  workspace: string;
770
1180
  };
1181
+ declare type GetBranchDetailsError = ErrorWrapper<{
1182
+ status: 400;
1183
+ payload: BadRequestError;
1184
+ } | {
1185
+ status: 401;
1186
+ payload: AuthError;
1187
+ } | {
1188
+ status: 404;
1189
+ payload: SimpleError;
1190
+ }>;
771
1191
  declare type GetBranchDetailsVariables = {
772
1192
  pathParams: GetBranchDetailsPathParams;
773
1193
  } & FetcherExtraProps;
@@ -779,6 +1199,16 @@ declare type CreateBranchPathParams = {
779
1199
  declare type CreateBranchQueryParams = {
780
1200
  from?: string;
781
1201
  };
1202
+ declare type CreateBranchError = ErrorWrapper<{
1203
+ status: 400;
1204
+ payload: BadRequestError;
1205
+ } | {
1206
+ status: 401;
1207
+ payload: AuthError;
1208
+ } | {
1209
+ status: 404;
1210
+ payload: SimpleError;
1211
+ }>;
782
1212
  declare type CreateBranchRequestBody = {
783
1213
  from?: string;
784
1214
  metadata?: BranchMetadata;
@@ -793,6 +1223,16 @@ declare type DeleteBranchPathParams = {
793
1223
  dbBranchName: DBBranchName;
794
1224
  workspace: string;
795
1225
  };
1226
+ declare type DeleteBranchError = ErrorWrapper<{
1227
+ status: 400;
1228
+ payload: BadRequestError;
1229
+ } | {
1230
+ status: 401;
1231
+ payload: AuthError;
1232
+ } | {
1233
+ status: 404;
1234
+ payload: SimpleError;
1235
+ }>;
796
1236
  declare type DeleteBranchVariables = {
797
1237
  pathParams: DeleteBranchPathParams;
798
1238
  } & FetcherExtraProps;
@@ -804,6 +1244,16 @@ declare type UpdateBranchMetadataPathParams = {
804
1244
  dbBranchName: DBBranchName;
805
1245
  workspace: string;
806
1246
  };
1247
+ declare type UpdateBranchMetadataError = ErrorWrapper<{
1248
+ status: 400;
1249
+ payload: BadRequestError;
1250
+ } | {
1251
+ status: 401;
1252
+ payload: AuthError;
1253
+ } | {
1254
+ status: 404;
1255
+ payload: SimpleError;
1256
+ }>;
807
1257
  declare type UpdateBranchMetadataVariables = {
808
1258
  body?: BranchMetadata;
809
1259
  pathParams: UpdateBranchMetadataPathParams;
@@ -816,6 +1266,16 @@ declare type GetBranchMetadataPathParams = {
816
1266
  dbBranchName: DBBranchName;
817
1267
  workspace: string;
818
1268
  };
1269
+ declare type GetBranchMetadataError = ErrorWrapper<{
1270
+ status: 400;
1271
+ payload: BadRequestError;
1272
+ } | {
1273
+ status: 401;
1274
+ payload: AuthError;
1275
+ } | {
1276
+ status: 404;
1277
+ payload: SimpleError;
1278
+ }>;
819
1279
  declare type GetBranchMetadataVariables = {
820
1280
  pathParams: GetBranchMetadataPathParams;
821
1281
  } & FetcherExtraProps;
@@ -824,6 +1284,16 @@ declare type GetBranchMigrationHistoryPathParams = {
824
1284
  dbBranchName: DBBranchName;
825
1285
  workspace: string;
826
1286
  };
1287
+ declare type GetBranchMigrationHistoryError = ErrorWrapper<{
1288
+ status: 400;
1289
+ payload: BadRequestError;
1290
+ } | {
1291
+ status: 401;
1292
+ payload: AuthError;
1293
+ } | {
1294
+ status: 404;
1295
+ payload: SimpleError;
1296
+ }>;
827
1297
  declare type GetBranchMigrationHistoryResponse = {
828
1298
  startedFrom?: StartedFromMetadata;
829
1299
  migrations?: BranchMigration[];
@@ -841,6 +1311,16 @@ declare type ExecuteBranchMigrationPlanPathParams = {
841
1311
  dbBranchName: DBBranchName;
842
1312
  workspace: string;
843
1313
  };
1314
+ declare type ExecuteBranchMigrationPlanError = ErrorWrapper<{
1315
+ status: 400;
1316
+ payload: BadRequestError;
1317
+ } | {
1318
+ status: 401;
1319
+ payload: AuthError;
1320
+ } | {
1321
+ status: 404;
1322
+ payload: SimpleError;
1323
+ }>;
844
1324
  declare type ExecuteBranchMigrationPlanRequestBody = {
845
1325
  version: number;
846
1326
  migration: BranchMigration;
@@ -857,6 +1337,16 @@ declare type GetBranchMigrationPlanPathParams = {
857
1337
  dbBranchName: DBBranchName;
858
1338
  workspace: string;
859
1339
  };
1340
+ declare type GetBranchMigrationPlanError = ErrorWrapper<{
1341
+ status: 400;
1342
+ payload: BadRequestError;
1343
+ } | {
1344
+ status: 401;
1345
+ payload: AuthError;
1346
+ } | {
1347
+ status: 404;
1348
+ payload: SimpleError;
1349
+ }>;
860
1350
  declare type GetBranchMigrationPlanVariables = {
861
1351
  body: Schema;
862
1352
  pathParams: GetBranchMigrationPlanPathParams;
@@ -869,6 +1359,16 @@ declare type GetBranchStatsPathParams = {
869
1359
  dbBranchName: DBBranchName;
870
1360
  workspace: string;
871
1361
  };
1362
+ declare type GetBranchStatsError = ErrorWrapper<{
1363
+ status: 400;
1364
+ payload: SimpleError;
1365
+ } | {
1366
+ status: 401;
1367
+ payload: AuthError;
1368
+ } | {
1369
+ status: 404;
1370
+ payload: SimpleError;
1371
+ }>;
872
1372
  declare type GetBranchStatsResponse = {
873
1373
  timestamp: string;
874
1374
  interval: string;
@@ -892,6 +1392,19 @@ declare type CreateTablePathParams = {
892
1392
  tableName: TableName;
893
1393
  workspace: string;
894
1394
  };
1395
+ declare type CreateTableError = ErrorWrapper<{
1396
+ status: 400;
1397
+ payload: BadRequestError;
1398
+ } | {
1399
+ status: 401;
1400
+ payload: AuthError;
1401
+ } | {
1402
+ status: 404;
1403
+ payload: SimpleError;
1404
+ } | {
1405
+ status: 422;
1406
+ payload: SimpleError;
1407
+ }>;
895
1408
  declare type CreateTableVariables = {
896
1409
  pathParams: CreateTablePathParams;
897
1410
  } & FetcherExtraProps;
@@ -904,6 +1417,13 @@ declare type DeleteTablePathParams = {
904
1417
  tableName: TableName;
905
1418
  workspace: string;
906
1419
  };
1420
+ declare type DeleteTableError = ErrorWrapper<{
1421
+ status: 400;
1422
+ payload: BadRequestError;
1423
+ } | {
1424
+ status: 401;
1425
+ payload: AuthError;
1426
+ }>;
907
1427
  declare type DeleteTableVariables = {
908
1428
  pathParams: DeleteTablePathParams;
909
1429
  } & FetcherExtraProps;
@@ -916,6 +1436,16 @@ declare type UpdateTablePathParams = {
916
1436
  tableName: TableName;
917
1437
  workspace: string;
918
1438
  };
1439
+ declare type UpdateTableError = ErrorWrapper<{
1440
+ status: 400;
1441
+ payload: BadRequestError;
1442
+ } | {
1443
+ status: 401;
1444
+ payload: AuthError;
1445
+ } | {
1446
+ status: 404;
1447
+ payload: SimpleError;
1448
+ }>;
919
1449
  declare type UpdateTableRequestBody = {
920
1450
  name: string;
921
1451
  };
@@ -941,6 +1471,16 @@ declare type GetTableSchemaPathParams = {
941
1471
  tableName: TableName;
942
1472
  workspace: string;
943
1473
  };
1474
+ declare type GetTableSchemaError = ErrorWrapper<{
1475
+ status: 400;
1476
+ payload: BadRequestError;
1477
+ } | {
1478
+ status: 401;
1479
+ payload: AuthError;
1480
+ } | {
1481
+ status: 404;
1482
+ payload: SimpleError;
1483
+ }>;
944
1484
  declare type GetTableSchemaResponse = {
945
1485
  columns: Column[];
946
1486
  };
@@ -953,6 +1493,19 @@ declare type SetTableSchemaPathParams = {
953
1493
  tableName: TableName;
954
1494
  workspace: string;
955
1495
  };
1496
+ declare type SetTableSchemaError = ErrorWrapper<{
1497
+ status: 400;
1498
+ payload: BadRequestError;
1499
+ } | {
1500
+ status: 401;
1501
+ payload: AuthError;
1502
+ } | {
1503
+ status: 404;
1504
+ payload: SimpleError;
1505
+ } | {
1506
+ status: 409;
1507
+ payload: SimpleError;
1508
+ }>;
956
1509
  declare type SetTableSchemaRequestBody = {
957
1510
  columns: Column[];
958
1511
  };
@@ -966,6 +1519,16 @@ declare type GetTableColumnsPathParams = {
966
1519
  tableName: TableName;
967
1520
  workspace: string;
968
1521
  };
1522
+ declare type GetTableColumnsError = ErrorWrapper<{
1523
+ status: 400;
1524
+ payload: BadRequestError;
1525
+ } | {
1526
+ status: 401;
1527
+ payload: AuthError;
1528
+ } | {
1529
+ status: 404;
1530
+ payload: SimpleError;
1531
+ }>;
969
1532
  declare type GetTableColumnsResponse = {
970
1533
  columns: Column[];
971
1534
  };
@@ -982,6 +1545,16 @@ declare type AddTableColumnPathParams = {
982
1545
  tableName: TableName;
983
1546
  workspace: string;
984
1547
  };
1548
+ declare type AddTableColumnError = ErrorWrapper<{
1549
+ status: 400;
1550
+ payload: BadRequestError;
1551
+ } | {
1552
+ status: 401;
1553
+ payload: AuthError;
1554
+ } | {
1555
+ status: 404;
1556
+ payload: SimpleError;
1557
+ }>;
985
1558
  declare type AddTableColumnVariables = {
986
1559
  body: Column;
987
1560
  pathParams: AddTableColumnPathParams;
@@ -998,6 +1571,16 @@ declare type GetColumnPathParams = {
998
1571
  columnName: ColumnName;
999
1572
  workspace: string;
1000
1573
  };
1574
+ declare type GetColumnError = ErrorWrapper<{
1575
+ status: 400;
1576
+ payload: BadRequestError;
1577
+ } | {
1578
+ status: 401;
1579
+ payload: AuthError;
1580
+ } | {
1581
+ status: 404;
1582
+ payload: SimpleError;
1583
+ }>;
1001
1584
  declare type GetColumnVariables = {
1002
1585
  pathParams: GetColumnPathParams;
1003
1586
  } & FetcherExtraProps;
@@ -1011,6 +1594,16 @@ declare type DeleteColumnPathParams = {
1011
1594
  columnName: ColumnName;
1012
1595
  workspace: string;
1013
1596
  };
1597
+ declare type DeleteColumnError = ErrorWrapper<{
1598
+ status: 400;
1599
+ payload: BadRequestError;
1600
+ } | {
1601
+ status: 401;
1602
+ payload: AuthError;
1603
+ } | {
1604
+ status: 404;
1605
+ payload: SimpleError;
1606
+ }>;
1014
1607
  declare type DeleteColumnVariables = {
1015
1608
  pathParams: DeleteColumnPathParams;
1016
1609
  } & FetcherExtraProps;
@@ -1024,6 +1617,16 @@ declare type UpdateColumnPathParams = {
1024
1617
  columnName: ColumnName;
1025
1618
  workspace: string;
1026
1619
  };
1620
+ declare type UpdateColumnError = ErrorWrapper<{
1621
+ status: 400;
1622
+ payload: BadRequestError;
1623
+ } | {
1624
+ status: 401;
1625
+ payload: AuthError;
1626
+ } | {
1627
+ status: 404;
1628
+ payload: SimpleError;
1629
+ }>;
1027
1630
  declare type UpdateColumnRequestBody = {
1028
1631
  name: string;
1029
1632
  };
@@ -1040,6 +1643,16 @@ declare type InsertRecordPathParams = {
1040
1643
  tableName: TableName;
1041
1644
  workspace: string;
1042
1645
  };
1646
+ declare type InsertRecordError = ErrorWrapper<{
1647
+ status: 400;
1648
+ payload: BadRequestError;
1649
+ } | {
1650
+ status: 401;
1651
+ payload: AuthError;
1652
+ } | {
1653
+ status: 404;
1654
+ payload: SimpleError;
1655
+ }>;
1043
1656
  declare type InsertRecordResponse = {
1044
1657
  id: string;
1045
1658
  xata: {
@@ -1064,6 +1677,19 @@ declare type InsertRecordWithIDQueryParams = {
1064
1677
  createOnly?: boolean;
1065
1678
  ifVersion?: number;
1066
1679
  };
1680
+ declare type InsertRecordWithIDError = ErrorWrapper<{
1681
+ status: 400;
1682
+ payload: BadRequestError;
1683
+ } | {
1684
+ status: 401;
1685
+ payload: AuthError;
1686
+ } | {
1687
+ status: 404;
1688
+ payload: SimpleError;
1689
+ } | {
1690
+ status: 422;
1691
+ payload: SimpleError;
1692
+ }>;
1067
1693
  declare type InsertRecordWithIDVariables = {
1068
1694
  body?: Record<string, any>;
1069
1695
  pathParams: InsertRecordWithIDPathParams;
@@ -1082,6 +1708,19 @@ declare type UpdateRecordWithIDPathParams = {
1082
1708
  declare type UpdateRecordWithIDQueryParams = {
1083
1709
  ifVersion?: number;
1084
1710
  };
1711
+ declare type UpdateRecordWithIDError = ErrorWrapper<{
1712
+ status: 400;
1713
+ payload: BadRequestError;
1714
+ } | {
1715
+ status: 401;
1716
+ payload: AuthError;
1717
+ } | {
1718
+ status: 404;
1719
+ payload: SimpleError;
1720
+ } | {
1721
+ status: 422;
1722
+ payload: SimpleError;
1723
+ }>;
1085
1724
  declare type UpdateRecordWithIDVariables = {
1086
1725
  body?: Record<string, any>;
1087
1726
  pathParams: UpdateRecordWithIDPathParams;
@@ -1097,6 +1736,19 @@ declare type UpsertRecordWithIDPathParams = {
1097
1736
  declare type UpsertRecordWithIDQueryParams = {
1098
1737
  ifVersion?: number;
1099
1738
  };
1739
+ declare type UpsertRecordWithIDError = ErrorWrapper<{
1740
+ status: 400;
1741
+ payload: BadRequestError;
1742
+ } | {
1743
+ status: 401;
1744
+ payload: AuthError;
1745
+ } | {
1746
+ status: 404;
1747
+ payload: SimpleError;
1748
+ } | {
1749
+ status: 422;
1750
+ payload: SimpleError;
1751
+ }>;
1100
1752
  declare type UpsertRecordWithIDVariables = {
1101
1753
  body?: Record<string, any>;
1102
1754
  pathParams: UpsertRecordWithIDPathParams;
@@ -1109,6 +1761,16 @@ declare type DeleteRecordPathParams = {
1109
1761
  recordId: RecordID;
1110
1762
  workspace: string;
1111
1763
  };
1764
+ declare type DeleteRecordError = ErrorWrapper<{
1765
+ status: 400;
1766
+ payload: BadRequestError;
1767
+ } | {
1768
+ status: 401;
1769
+ payload: AuthError;
1770
+ } | {
1771
+ status: 404;
1772
+ payload: SimpleError;
1773
+ }>;
1112
1774
  declare type DeleteRecordVariables = {
1113
1775
  pathParams: DeleteRecordPathParams;
1114
1776
  } & FetcherExtraProps;
@@ -1119,6 +1781,16 @@ declare type GetRecordPathParams = {
1119
1781
  recordId: RecordID;
1120
1782
  workspace: string;
1121
1783
  };
1784
+ declare type GetRecordError = ErrorWrapper<{
1785
+ status: 400;
1786
+ payload: BadRequestError;
1787
+ } | {
1788
+ status: 401;
1789
+ payload: AuthError;
1790
+ } | {
1791
+ status: 404;
1792
+ payload: SimpleError;
1793
+ }>;
1122
1794
  declare type GetRecordRequestBody = {
1123
1795
  columns?: ColumnsFilter;
1124
1796
  };
@@ -1135,6 +1807,16 @@ declare type BulkInsertTableRecordsPathParams = {
1135
1807
  tableName: TableName;
1136
1808
  workspace: string;
1137
1809
  };
1810
+ declare type BulkInsertTableRecordsError = ErrorWrapper<{
1811
+ status: 400;
1812
+ payload: BulkError;
1813
+ } | {
1814
+ status: 401;
1815
+ payload: AuthError;
1816
+ } | {
1817
+ status: 404;
1818
+ payload: SimpleError;
1819
+ }>;
1138
1820
  declare type BulkInsertTableRecordsResponse = {
1139
1821
  recordIDs: string[];
1140
1822
  };
@@ -1154,6 +1836,16 @@ declare type QueryTablePathParams = {
1154
1836
  tableName: TableName;
1155
1837
  workspace: string;
1156
1838
  };
1839
+ declare type QueryTableError = ErrorWrapper<{
1840
+ status: 400;
1841
+ payload: BadRequestError;
1842
+ } | {
1843
+ status: 401;
1844
+ payload: AuthError;
1845
+ } | {
1846
+ status: 404;
1847
+ payload: SimpleError;
1848
+ }>;
1157
1849
  declare type QueryTableRequestBody = {
1158
1850
  filter?: FilterExpression;
1159
1851
  sort?: SortExpression;
@@ -1221,7 +1913,11 @@ declare type QueryTableVariables = {
1221
1913
  * "link": {
1222
1914
  * "table": "users"
1223
1915
  * }
1224
- * }
1916
+ * },
1917
+ * {
1918
+ * "name": "foundedDate",
1919
+ * "type": "datetime"
1920
+ * },
1225
1921
  * ]
1226
1922
  * },
1227
1923
  * {
@@ -1374,7 +2070,8 @@ declare type QueryTableVariables = {
1374
2070
  * "version": 0,
1375
2071
  * },
1376
2072
  * "name": "first team",
1377
- * "code": "A1"
2073
+ * "code": "A1",
2074
+ * "foundedDate": "2020-03-04T10:43:54.32Z"
1378
2075
  * }
1379
2076
  * }
1380
2077
  * ```
@@ -1389,7 +2086,7 @@ declare type QueryTableVariables = {
1389
2086
  * `$none`, etc.
1390
2087
  *
1391
2088
  * All operators start with an `$` to differentiate them from column names
1392
- * (which are not allowed to start with an dollar sign).
2089
+ * (which are not allowed to start with a dollar sign).
1393
2090
  *
1394
2091
  * #### Exact matching and control operators
1395
2092
  *
@@ -1590,7 +2287,7 @@ declare type QueryTableVariables = {
1590
2287
  * }
1591
2288
  * ```
1592
2289
  *
1593
- * #### Numeric ranges
2290
+ * #### Numeric or datetime ranges
1594
2291
  *
1595
2292
  * ```json
1596
2293
  * {
@@ -1602,7 +2299,18 @@ declare type QueryTableVariables = {
1602
2299
  * }
1603
2300
  * }
1604
2301
  * ```
1605
- *
2302
+ * Date ranges support the same operators, with the date using the format defined in
2303
+ * [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339):
2304
+ * ```json
2305
+ * {
2306
+ * "filter": {
2307
+ * "<column_name>": {
2308
+ * "$gt": "2019-10-12T07:20:50.52Z",
2309
+ * "$lt": "2021-10-12T07:20:50.52Z"
2310
+ * }
2311
+ * }
2312
+ * }
2313
+ * ```
1606
2314
  * The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
1607
2315
  *
1608
2316
  *
@@ -1872,6 +2580,16 @@ declare type SearchBranchPathParams = {
1872
2580
  dbBranchName: DBBranchName;
1873
2581
  workspace: string;
1874
2582
  };
2583
+ declare type SearchBranchError = ErrorWrapper<{
2584
+ status: 400;
2585
+ payload: BadRequestError;
2586
+ } | {
2587
+ status: 401;
2588
+ payload: AuthError;
2589
+ } | {
2590
+ status: 404;
2591
+ payload: SimpleError;
2592
+ }>;
1875
2593
  declare type SearchBranchRequestBody = {
1876
2594
  tables?: string[];
1877
2595
  query: string;
@@ -1912,6 +2630,10 @@ declare const operationsByTag: {
1912
2630
  getDatabaseList: (variables: GetDatabaseListVariables) => Promise<ListDatabasesResponse>;
1913
2631
  createDatabase: (variables: CreateDatabaseVariables) => Promise<CreateDatabaseResponse>;
1914
2632
  deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
2633
+ getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
2634
+ addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
2635
+ removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
2636
+ resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
1915
2637
  };
1916
2638
  branch: {
1917
2639
  getBranchList: (variables: GetBranchListVariables) => Promise<ListBranchesResponse>;
@@ -1962,9 +2684,12 @@ interface XataApiClientOptions {
1962
2684
  apiKey?: string;
1963
2685
  host?: HostProvider;
1964
2686
  }
2687
+ /**
2688
+ * @deprecated Use XataApiPlugin instead
2689
+ */
1965
2690
  declare class XataApiClient {
1966
2691
  #private;
1967
- constructor(options: XataApiClientOptions);
2692
+ constructor(options?: XataApiClientOptions);
1968
2693
  get user(): UserApi;
1969
2694
  get workspaces(): WorkspaceApi;
1970
2695
  get databases(): DatabaseApi;
@@ -2004,6 +2729,10 @@ declare class DatabaseApi {
2004
2729
  getDatabaseList(workspace: WorkspaceID): Promise<ListDatabasesResponse>;
2005
2730
  createDatabase(workspace: WorkspaceID, dbName: DBName, options?: CreateDatabaseRequestBody): Promise<CreateDatabaseResponse>;
2006
2731
  deleteDatabase(workspace: WorkspaceID, dbName: DBName): Promise<void>;
2732
+ getGitBranchesMapping(workspace: WorkspaceID, dbName: DBName): Promise<ListGitBranchesResponse>;
2733
+ addGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, body: AddGitBranchesEntryRequestBody): Promise<AddGitBranchesEntryResponse>;
2734
+ removeGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<void>;
2735
+ resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<ResolveBranchResponse>;
2007
2736
  }
2008
2737
  declare class BranchApi {
2009
2738
  private extraProps;
@@ -2063,6 +2792,7 @@ declare type NonEmptyArray<T> = T[] & {
2063
2792
  declare type RequiredBy<T, K extends keyof T> = T & {
2064
2793
  [P in K]-?: NonNullable<T[P]>;
2065
2794
  };
2795
+ declare type GetArrayInnerType<T extends readonly any[]> = T[number];
2066
2796
  declare type SingleOrArray<T> = T | T[];
2067
2797
  declare type Dictionary<T> = Record<string, T>;
2068
2798
 
@@ -2264,6 +2994,7 @@ declare type QueryOptions<T extends XataRecord> = {
2264
2994
  columns?: NonEmptyArray<SelectableColumn<T>>;
2265
2995
  filter?: FilterExpression;
2266
2996
  sort?: SortFilter<T> | SortFilter<T>[];
2997
+ cache?: number;
2267
2998
  };
2268
2999
  /**
2269
3000
  * Query objects contain the information of all filters, sorting, etc. to be included in the database query.
@@ -2277,6 +3008,7 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
2277
3008
  readonly records: Result[];
2278
3009
  constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, parent?: Partial<QueryOptions<Record>>);
2279
3010
  getQueryOptions(): QueryOptions<Record>;
3011
+ key(): string;
2280
3012
  /**
2281
3013
  * Builds a new query object representing a logical OR between the given subqueries.
2282
3014
  * @param queries An array of subqueries.
@@ -2360,9 +3092,15 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
2360
3092
  * @param options Additional options to be used when performing the query.
2361
3093
  * @returns The first record that matches the query, or null if no record matched the query.
2362
3094
  */
2363
- getOne(): Promise<Result | null>;
2364
- getOne(options: Omit<QueryOptions<Record>, 'columns' | 'page'>): Promise<Result | null>;
2365
- getOne<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
3095
+ getFirst(): Promise<Result | null>;
3096
+ getFirst(options: Omit<QueryOptions<Record>, 'columns' | 'page'>): Promise<Result | null>;
3097
+ getFirst<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
3098
+ /**
3099
+ * Builds a new query object adding a cache TTL in milliseconds.
3100
+ * @param ttl The cache TTL in milliseconds.
3101
+ * @returns A new Query object.
3102
+ */
3103
+ cache(ttl: number): Query<Record, Result>;
2366
3104
  nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
2367
3105
  previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
2368
3106
  firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
@@ -2560,8 +3298,8 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
2560
3298
  constructor(options: {
2561
3299
  table: string;
2562
3300
  links?: LinkDictionary;
2563
- getFetchProps: () => Promise<FetcherExtraProps>;
2564
3301
  db: SchemaPluginResult<any>;
3302
+ pluginOptions: XataPluginOptions;
2565
3303
  });
2566
3304
  create(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
2567
3305
  create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
@@ -2573,7 +3311,7 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
2573
3311
  createOrUpdate(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
2574
3312
  createOrUpdate(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
2575
3313
  createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
2576
- delete(recordId: string | Identifiable | Array<string | Identifiable>): Promise<void>;
3314
+ delete(a: string | Identifiable | Array<string | Identifiable>): Promise<void>;
2577
3315
  search(query: string, options?: {
2578
3316
  fuzziness?: number;
2579
3317
  }): Promise<SelectedPick<Record, ['*']>[]>;
@@ -2659,38 +3397,44 @@ declare type SchemaDefinition = {
2659
3397
  };
2660
3398
  declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
2661
3399
  [Key in keyof Schemas]: Repository<Schemas[Key]>;
3400
+ } & {
3401
+ [key: string]: Repository<XataRecord$1>;
2662
3402
  };
2663
3403
  declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
2664
3404
  #private;
2665
3405
  private links?;
2666
- constructor(links?: LinkDictionary | undefined);
2667
- build(options: XataPluginOptions): SchemaPluginResult<Schemas>;
3406
+ private tableNames?;
3407
+ constructor(links?: LinkDictionary | undefined, tableNames?: string[] | undefined);
3408
+ build(pluginOptions: XataPluginOptions): SchemaPluginResult<Schemas>;
2668
3409
  }
2669
3410
 
3411
+ declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
3412
+ fuzziness?: number;
3413
+ tables?: Tables[];
3414
+ };
3415
+ declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
3416
+ all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
3417
+ [Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]: {
3418
+ table: Model;
3419
+ record: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
3420
+ };
3421
+ }>[]>;
3422
+ byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
3423
+ [Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
3424
+ }>;
3425
+ };
2670
3426
  declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
2671
3427
  #private;
2672
- build({ getFetchProps }: XataPluginOptions): {
2673
- all: <Tables extends Extract<keyof Schemas, string>>(query: string, options?: {
2674
- fuzziness?: number | undefined;
2675
- tables?: Tables[] | undefined;
2676
- }) => Promise<Values<{ [Model in Tables]: {
2677
- table: Model;
2678
- record: Awaited<SelectedPick<Schemas[Model] & XataRecord & {
2679
- xata: {
2680
- table: string;
2681
- };
2682
- }, ["*"]>>;
2683
- }; }>[]>;
2684
- byTable: <Tables_1 extends Extract<keyof Schemas, string>>(query: string, options?: {
2685
- fuzziness?: number | undefined;
2686
- tables?: Tables_1[] | undefined;
2687
- }) => Promise<{ [Model_1 in Tables_1]: SelectedPick<Schemas[Model_1] & XataRecord & {
2688
- xata: {
2689
- table: string;
2690
- };
2691
- }, ["*"]>[]; }>;
2692
- };
3428
+ private db;
3429
+ private links;
3430
+ constructor(db: SchemaPluginResult<Schemas>, links: LinkDictionary);
3431
+ build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
2693
3432
  }
3433
+ declare type SearchXataRecord = XataRecord & {
3434
+ xata: {
3435
+ table: string;
3436
+ };
3437
+ };
2694
3438
 
2695
3439
  declare type BranchStrategyValue = string | undefined | null;
2696
3440
  declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
@@ -2702,10 +3446,11 @@ declare type BaseClientOptions = {
2702
3446
  apiKey?: string;
2703
3447
  databaseURL?: string;
2704
3448
  branch?: BranchStrategyOption;
3449
+ cache?: CacheImpl;
2705
3450
  };
2706
3451
  declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
2707
3452
  interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
2708
- new <Schemas extends Record<string, BaseData>>(options?: Partial<BaseClientOptions>, links?: LinkDictionary): Omit<{
3453
+ new <Schemas extends Record<string, BaseData> = {}>(options?: Partial<BaseClientOptions>, links?: LinkDictionary): Omit<{
2709
3454
  db: Awaited<ReturnType<SchemaPlugin<Schemas>['build']>>;
2710
3455
  search: Awaited<ReturnType<SearchPlugin<Schemas>['build']>>;
2711
3456
  }, keyof Plugins> & {
@@ -2721,9 +3466,10 @@ declare type BranchResolutionOptions = {
2721
3466
  apiKey?: string;
2722
3467
  fetchImpl?: FetchImpl;
2723
3468
  };
2724
- declare function getCurrentBranchName(options?: BranchResolutionOptions): Promise<string | undefined>;
3469
+ declare function getCurrentBranchName(options?: BranchResolutionOptions): Promise<string>;
2725
3470
  declare function getCurrentBranchDetails(options?: BranchResolutionOptions): Promise<DBBranch | null>;
2726
3471
  declare function getDatabaseURL(): string | undefined;
3472
+
2727
3473
  declare function getAPIKey(): string | undefined;
2728
3474
 
2729
3475
  declare class XataError extends Error {
@@ -2731,4 +3477,4 @@ declare class XataError extends Error {
2731
3477
  constructor(message: string, status: number);
2732
3478
  }
2733
3479
 
2734
- export { AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsResponse, BulkInsertTableRecordsVariables, CancelWorkspaceMemberInvitePathParams, CancelWorkspaceMemberInviteVariables, ClientConstructor, CreateBranchPathParams, CreateBranchQueryParams, CreateBranchRequestBody, CreateBranchVariables, CreateDatabasePathParams, CreateDatabaseRequestBody, CreateDatabaseResponse, CreateDatabaseVariables, CreateTablePathParams, CreateTableVariables, CreateUserAPIKeyPathParams, CreateUserAPIKeyResponse, CreateUserAPIKeyVariables, CreateWorkspaceVariables, CursorNavigationOptions, DeleteBranchPathParams, DeleteBranchVariables, DeleteColumnPathParams, DeleteColumnVariables, DeleteDatabasePathParams, DeleteDatabaseVariables, DeleteRecordPathParams, DeleteRecordVariables, DeleteTablePathParams, DeleteTableVariables, DeleteUserAPIKeyPathParams, DeleteUserAPIKeyVariables, DeleteUserVariables, DeleteWorkspacePathParams, DeleteWorkspaceVariables, EditableData, ExecuteBranchMigrationPlanPathParams, ExecuteBranchMigrationPlanRequestBody, ExecuteBranchMigrationPlanVariables, FetchImpl, FetcherExtraProps, GetBranchDetailsPathParams, GetBranchDetailsVariables, GetBranchListPathParams, GetBranchListVariables, GetBranchMetadataPathParams, GetBranchMetadataVariables, GetBranchMigrationHistoryPathParams, GetBranchMigrationHistoryRequestBody, GetBranchMigrationHistoryResponse, GetBranchMigrationHistoryVariables, GetBranchMigrationPlanPathParams, GetBranchMigrationPlanVariables, GetBranchStatsPathParams, GetBranchStatsResponse, GetBranchStatsVariables, GetColumnPathParams, GetColumnVariables, GetDatabaseListPathParams, GetDatabaseListVariables, GetRecordPathParams, GetRecordRequestBody, GetRecordVariables, GetTableColumnsPathParams, GetTableColumnsResponse, GetTableColumnsVariables, GetTableSchemaPathParams, GetTableSchemaResponse, GetTableSchemaVariables, GetUserAPIKeysResponse, GetUserAPIKeysVariables, GetUserVariables, GetWorkspaceMembersListPathParams, GetWorkspaceMembersListVariables, GetWorkspacePathParams, GetWorkspaceVariables, GetWorkspacesListResponse, GetWorkspacesListVariables, Identifiable, InsertRecordPathParams, InsertRecordResponse, InsertRecordVariables, InsertRecordWithIDPathParams, InsertRecordWithIDQueryParams, InsertRecordWithIDVariables, InviteWorkspaceMemberPathParams, InviteWorkspaceMemberRequestBody, InviteWorkspaceMemberVariables, LinkDictionary, OffsetNavigationOptions, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Paginable, PaginationOptions, PaginationQueryMeta, Query, QueryTablePathParams, QueryTableRequestBody, QueryTableVariables, RemoveWorkspaceMemberPathParams, RemoveWorkspaceMemberVariables, Repository, ResendWorkspaceMemberInvitePathParams, ResendWorkspaceMemberInviteVariables, responses as Responses, RestRepository, SchemaDefinition, SchemaPlugin, SchemaPluginResult, schemas as Schemas, SearchBranchPathParams, SearchBranchRequestBody, SearchBranchVariables, SearchPlugin, SelectableColumn, SelectedPick, SetTableSchemaPathParams, SetTableSchemaRequestBody, SetTableSchemaVariables, UpdateBranchMetadataPathParams, UpdateBranchMetadataVariables, UpdateColumnPathParams, UpdateColumnRequestBody, UpdateColumnVariables, UpdateRecordWithIDPathParams, UpdateRecordWithIDQueryParams, UpdateRecordWithIDVariables, UpdateTablePathParams, UpdateTableRequestBody, UpdateTableVariables, UpdateUserVariables, UpdateWorkspaceMemberRolePathParams, UpdateWorkspaceMemberRoleRequestBody, UpdateWorkspaceMemberRoleVariables, UpdateWorkspacePathParams, UpdateWorkspaceVariables, UpsertRecordWithIDPathParams, UpsertRecordWithIDQueryParams, UpsertRecordWithIDVariables, ValueAtColumn, XataApiClient, XataApiClientOptions, XataApiPlugin, XataError, XataPlugin, XataPluginOptions, XataRecord, acceptWorkspaceMemberInvite, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeWorkspaceMember, resendWorkspaceMemberInvite, searchBranch, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
3480
+ export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddGitBranchesEntryError, AddGitBranchesEntryPathParams, AddGitBranchesEntryRequestBody, AddGitBranchesEntryResponse, AddGitBranchesEntryVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsResponse, BulkInsertTableRecordsVariables, CacheImpl, CancelWorkspaceMemberInviteError, CancelWorkspaceMemberInvitePathParams, CancelWorkspaceMemberInviteVariables, ClientConstructor, CreateBranchError, CreateBranchPathParams, CreateBranchQueryParams, CreateBranchRequestBody, CreateBranchVariables, CreateDatabaseError, CreateDatabasePathParams, CreateDatabaseRequestBody, CreateDatabaseResponse, CreateDatabaseVariables, CreateTableError, CreateTablePathParams, CreateTableVariables, CreateUserAPIKeyError, CreateUserAPIKeyPathParams, CreateUserAPIKeyResponse, CreateUserAPIKeyVariables, CreateWorkspaceError, CreateWorkspaceVariables, CursorNavigationOptions, DeleteBranchError, DeleteBranchPathParams, DeleteBranchVariables, DeleteColumnError, DeleteColumnPathParams, DeleteColumnVariables, DeleteDatabaseError, DeleteDatabasePathParams, DeleteDatabaseVariables, DeleteRecordError, DeleteRecordPathParams, DeleteRecordVariables, DeleteTableError, DeleteTablePathParams, DeleteTableVariables, DeleteUserAPIKeyError, DeleteUserAPIKeyPathParams, DeleteUserAPIKeyVariables, DeleteUserError, DeleteUserVariables, DeleteWorkspaceError, DeleteWorkspacePathParams, DeleteWorkspaceVariables, EditableData, ExecuteBranchMigrationPlanError, ExecuteBranchMigrationPlanPathParams, ExecuteBranchMigrationPlanRequestBody, ExecuteBranchMigrationPlanVariables, FetchImpl, FetcherExtraProps, GetBranchDetailsError, GetBranchDetailsPathParams, GetBranchDetailsVariables, GetBranchListError, GetBranchListPathParams, GetBranchListVariables, GetBranchMetadataError, GetBranchMetadataPathParams, GetBranchMetadataVariables, GetBranchMigrationHistoryError, GetBranchMigrationHistoryPathParams, GetBranchMigrationHistoryRequestBody, GetBranchMigrationHistoryResponse, GetBranchMigrationHistoryVariables, GetBranchMigrationPlanError, GetBranchMigrationPlanPathParams, GetBranchMigrationPlanVariables, GetBranchStatsError, GetBranchStatsPathParams, GetBranchStatsResponse, GetBranchStatsVariables, GetColumnError, GetColumnPathParams, GetColumnVariables, GetDatabaseListError, GetDatabaseListPathParams, GetDatabaseListVariables, GetGitBranchesMappingError, GetGitBranchesMappingPathParams, GetGitBranchesMappingVariables, GetRecordError, GetRecordPathParams, GetRecordRequestBody, GetRecordVariables, GetTableColumnsError, GetTableColumnsPathParams, GetTableColumnsResponse, GetTableColumnsVariables, GetTableSchemaError, GetTableSchemaPathParams, GetTableSchemaResponse, GetTableSchemaVariables, GetUserAPIKeysError, GetUserAPIKeysResponse, GetUserAPIKeysVariables, GetUserError, GetUserVariables, GetWorkspaceError, GetWorkspaceMembersListError, GetWorkspaceMembersListPathParams, GetWorkspaceMembersListVariables, GetWorkspacePathParams, GetWorkspaceVariables, GetWorkspacesListError, GetWorkspacesListResponse, GetWorkspacesListVariables, Identifiable, InsertRecordError, InsertRecordPathParams, InsertRecordResponse, InsertRecordVariables, InsertRecordWithIDError, InsertRecordWithIDPathParams, InsertRecordWithIDQueryParams, InsertRecordWithIDVariables, InviteWorkspaceMemberError, InviteWorkspaceMemberPathParams, InviteWorkspaceMemberRequestBody, InviteWorkspaceMemberVariables, LinkDictionary, OffsetNavigationOptions, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Paginable, PaginationOptions, PaginationQueryMeta, Query, QueryTableError, QueryTablePathParams, QueryTableRequestBody, QueryTableVariables, RemoveGitBranchesEntryError, RemoveGitBranchesEntryPathParams, RemoveGitBranchesEntryQueryParams, RemoveGitBranchesEntryVariables, RemoveWorkspaceMemberError, RemoveWorkspaceMemberPathParams, RemoveWorkspaceMemberVariables, Repository, ResendWorkspaceMemberInviteError, ResendWorkspaceMemberInvitePathParams, ResendWorkspaceMemberInviteVariables, ResolveBranchError, ResolveBranchPathParams, ResolveBranchQueryParams, ResolveBranchResponse, ResolveBranchVariables, responses as Responses, RestRepository, SchemaDefinition, SchemaPlugin, SchemaPluginResult, schemas as Schemas, SearchBranchError, SearchBranchPathParams, SearchBranchRequestBody, SearchBranchVariables, SearchOptions, SearchPlugin, SearchPluginResult, SelectableColumn, SelectedPick, SetTableSchemaError, SetTableSchemaPathParams, SetTableSchemaRequestBody, SetTableSchemaVariables, SimpleCache, SimpleCacheOptions, UpdateBranchMetadataError, UpdateBranchMetadataPathParams, UpdateBranchMetadataVariables, UpdateColumnError, UpdateColumnPathParams, UpdateColumnRequestBody, UpdateColumnVariables, UpdateRecordWithIDError, UpdateRecordWithIDPathParams, UpdateRecordWithIDQueryParams, UpdateRecordWithIDVariables, UpdateTableError, UpdateTablePathParams, UpdateTableRequestBody, UpdateTableVariables, UpdateUserError, UpdateUserVariables, UpdateWorkspaceError, UpdateWorkspaceMemberRoleError, UpdateWorkspaceMemberRolePathParams, UpdateWorkspaceMemberRoleRequestBody, UpdateWorkspaceMemberRoleVariables, UpdateWorkspacePathParams, UpdateWorkspaceVariables, UpsertRecordWithIDError, UpsertRecordWithIDPathParams, UpsertRecordWithIDQueryParams, UpsertRecordWithIDVariables, ValueAtColumn, XataApiClient, XataApiClientOptions, XataApiPlugin, XataError, XataPlugin, XataPluginOptions, XataRecord, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };