@xata.io/client 0.8.4 → 0.10.0

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
@@ -19,11 +19,39 @@ declare type ErrorWrapper<TError> = TError | {
19
19
  payload: string;
20
20
  };
21
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
+ }
48
+
22
49
  declare abstract class XataPlugin {
23
50
  abstract build(options: XataPluginOptions): unknown | Promise<unknown>;
24
51
  }
25
52
  declare type XataPluginOptions = {
26
53
  getFetchProps: () => Promise<FetcherExtraProps>;
54
+ cache: CacheImpl;
27
55
  };
28
56
 
29
57
  /**
@@ -110,6 +138,12 @@ declare type ListBranchesResponse = {
110
138
  displayName: string;
111
139
  branches: Branch[];
112
140
  };
141
+ declare type ListGitBranchesResponse = {
142
+ mapping: {
143
+ gitBranch: string;
144
+ xataBranch: string;
145
+ }[];
146
+ };
113
147
  declare type Branch = {
114
148
  name: string;
115
149
  createdAt: DateTime;
@@ -158,7 +192,7 @@ declare type Table = {
158
192
  */
159
193
  declare type Column = {
160
194
  name: string;
161
- type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object';
195
+ type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object' | 'datetime';
162
196
  link?: {
163
197
  table: string;
164
198
  };
@@ -354,6 +388,7 @@ type schemas_WorkspaceMembers = WorkspaceMembers;
354
388
  type schemas_InviteKey = InviteKey;
355
389
  type schemas_ListDatabasesResponse = ListDatabasesResponse;
356
390
  type schemas_ListBranchesResponse = ListBranchesResponse;
391
+ type schemas_ListGitBranchesResponse = ListGitBranchesResponse;
357
392
  type schemas_Branch = Branch;
358
393
  type schemas_BranchMetadata = BranchMetadata;
359
394
  type schemas_DBBranch = DBBranch;
@@ -406,6 +441,7 @@ declare namespace schemas {
406
441
  schemas_InviteKey as InviteKey,
407
442
  schemas_ListDatabasesResponse as ListDatabasesResponse,
408
443
  schemas_ListBranchesResponse as ListBranchesResponse,
444
+ schemas_ListGitBranchesResponse as ListGitBranchesResponse,
409
445
  schemas_Branch as Branch,
410
446
  schemas_BranchMetadata as BranchMetadata,
411
447
  schemas_DBBranch as DBBranch,
@@ -982,6 +1018,162 @@ declare type DeleteDatabaseVariables = {
982
1018
  * Delete a database and all of its branches and tables permanently.
983
1019
  */
984
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>;
985
1177
  declare type GetBranchDetailsPathParams = {
986
1178
  dbBranchName: DBBranchName;
987
1179
  workspace: string;
@@ -1721,7 +1913,11 @@ declare type QueryTableVariables = {
1721
1913
  * "link": {
1722
1914
  * "table": "users"
1723
1915
  * }
1724
- * }
1916
+ * },
1917
+ * {
1918
+ * "name": "foundedDate",
1919
+ * "type": "datetime"
1920
+ * },
1725
1921
  * ]
1726
1922
  * },
1727
1923
  * {
@@ -1874,7 +2070,8 @@ declare type QueryTableVariables = {
1874
2070
  * "version": 0,
1875
2071
  * },
1876
2072
  * "name": "first team",
1877
- * "code": "A1"
2073
+ * "code": "A1",
2074
+ * "foundedDate": "2020-03-04T10:43:54.32Z"
1878
2075
  * }
1879
2076
  * }
1880
2077
  * ```
@@ -1889,7 +2086,7 @@ declare type QueryTableVariables = {
1889
2086
  * `$none`, etc.
1890
2087
  *
1891
2088
  * All operators start with an `$` to differentiate them from column names
1892
- * (which are not allowed to start with an dollar sign).
2089
+ * (which are not allowed to start with a dollar sign).
1893
2090
  *
1894
2091
  * #### Exact matching and control operators
1895
2092
  *
@@ -2090,7 +2287,7 @@ declare type QueryTableVariables = {
2090
2287
  * }
2091
2288
  * ```
2092
2289
  *
2093
- * #### Numeric ranges
2290
+ * #### Numeric or datetime ranges
2094
2291
  *
2095
2292
  * ```json
2096
2293
  * {
@@ -2102,7 +2299,18 @@ declare type QueryTableVariables = {
2102
2299
  * }
2103
2300
  * }
2104
2301
  * ```
2105
- *
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
+ * ```
2106
2314
  * The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
2107
2315
  *
2108
2316
  *
@@ -2422,6 +2630,10 @@ declare const operationsByTag: {
2422
2630
  getDatabaseList: (variables: GetDatabaseListVariables) => Promise<ListDatabasesResponse>;
2423
2631
  createDatabase: (variables: CreateDatabaseVariables) => Promise<CreateDatabaseResponse>;
2424
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>;
2425
2637
  };
2426
2638
  branch: {
2427
2639
  getBranchList: (variables: GetBranchListVariables) => Promise<ListBranchesResponse>;
@@ -2472,6 +2684,9 @@ interface XataApiClientOptions {
2472
2684
  apiKey?: string;
2473
2685
  host?: HostProvider;
2474
2686
  }
2687
+ /**
2688
+ * @deprecated Use XataApiPlugin instead
2689
+ */
2475
2690
  declare class XataApiClient {
2476
2691
  #private;
2477
2692
  constructor(options?: XataApiClientOptions);
@@ -2514,6 +2729,10 @@ declare class DatabaseApi {
2514
2729
  getDatabaseList(workspace: WorkspaceID): Promise<ListDatabasesResponse>;
2515
2730
  createDatabase(workspace: WorkspaceID, dbName: DBName, options?: CreateDatabaseRequestBody): Promise<CreateDatabaseResponse>;
2516
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>;
2517
2736
  }
2518
2737
  declare class BranchApi {
2519
2738
  private extraProps;
@@ -2575,7 +2794,7 @@ declare type RequiredBy<T, K extends keyof T> = T & {
2575
2794
  };
2576
2795
  declare type GetArrayInnerType<T extends readonly any[]> = T[number];
2577
2796
  declare type SingleOrArray<T> = T | T[];
2578
- declare type Dictionary<T> = Record<string, T>;
2797
+ declare type OmitBy<T, K extends keyof T> = T extends any ? Omit<T, K> : never;
2579
2798
 
2580
2799
  declare type SelectableColumn<O, RecursivePath extends any[] = []> = '*' | 'id' | DataProps<O> | NestedColumns<O, RecursivePath>;
2581
2800
  declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord & UnionToIntersection<Values<{
@@ -2770,12 +2989,21 @@ declare type SortFilterBase<T extends XataRecord> = {
2770
2989
  [Key in StringKeys<T>]: SortDirection;
2771
2990
  };
2772
2991
 
2773
- declare type QueryOptions<T extends XataRecord> = {
2774
- page?: PaginationOptions;
2992
+ declare type BaseOptions<T extends XataRecord> = {
2775
2993
  columns?: NonEmptyArray<SelectableColumn<T>>;
2994
+ cache?: number;
2995
+ };
2996
+ declare type CursorQueryOptions = {
2997
+ pagination?: CursorNavigationOptions & OffsetNavigationOptions;
2998
+ filter?: never;
2999
+ sort?: never;
3000
+ };
3001
+ declare type OffsetQueryOptions<T extends XataRecord> = {
3002
+ pagination?: OffsetNavigationOptions;
2776
3003
  filter?: FilterExpression;
2777
3004
  sort?: SortFilter<T> | SortFilter<T>[];
2778
3005
  };
3006
+ declare type QueryOptions<T extends XataRecord> = BaseOptions<T> & (CursorQueryOptions | OffsetQueryOptions<T>);
2779
3007
  /**
2780
3008
  * Query objects contain the information of all filters, sorting, etc. to be included in the database query.
2781
3009
  *
@@ -2788,6 +3016,7 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
2788
3016
  readonly records: Result[];
2789
3017
  constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, parent?: Partial<QueryOptions<Record>>);
2790
3018
  getQueryOptions(): QueryOptions<Record>;
3019
+ key(): string;
2791
3020
  /**
2792
3021
  * Builds a new query object representing a logical OR between the given subqueries.
2793
3022
  * @param queries An array of subqueries.
@@ -2843,19 +3072,23 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
2843
3072
  */
2844
3073
  select<K extends SelectableColumn<Record>>(columns: NonEmptyArray<K>): Query<Record, SelectedPick<Record, NonEmptyArray<K>>>;
2845
3074
  getPaginated(): Promise<Page<Record, Result>>;
2846
- getPaginated(options: Omit<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
3075
+ getPaginated(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
2847
3076
  getPaginated<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<Page<Record, SelectedPick<Record, typeof options['columns']>>>;
2848
3077
  [Symbol.asyncIterator](): AsyncIterableIterator<Result>;
2849
- getIterator(chunk: number): AsyncGenerator<Result[]>;
2850
- getIterator(chunk: number, options: Omit<QueryOptions<Record>, 'columns' | 'page'>): AsyncGenerator<Result[]>;
2851
- getIterator<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(chunk: number, options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
3078
+ getIterator(): AsyncGenerator<Result[]>;
3079
+ getIterator(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
3080
+ batchSize?: number;
3081
+ }): AsyncGenerator<Result[]>;
3082
+ getIterator<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
3083
+ batchSize?: number;
3084
+ }>(options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
2852
3085
  /**
2853
3086
  * Performs the query in the database and returns a set of results.
2854
3087
  * @param options Additional options to be used when performing the query.
2855
3088
  * @returns An array of records from the database.
2856
3089
  */
2857
3090
  getMany(): Promise<Result[]>;
2858
- getMany(options: Omit<QueryOptions<Record>, 'columns'>): Promise<Result[]>;
3091
+ getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Result[]>;
2859
3092
  getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
2860
3093
  /**
2861
3094
  * Performs the query in the database and returns all the results.
@@ -2863,17 +3096,27 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
2863
3096
  * @param options Additional options to be used when performing the query.
2864
3097
  * @returns An array of records from the database.
2865
3098
  */
2866
- getAll(chunk?: number): Promise<Result[]>;
2867
- getAll(chunk: number | undefined, options: Omit<QueryOptions<Record>, 'columns' | 'page'>): Promise<Result[]>;
2868
- getAll<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(chunk: number | undefined, options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
3099
+ getAll(): Promise<Result[]>;
3100
+ getAll(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
3101
+ batchSize?: number;
3102
+ }): Promise<Result[]>;
3103
+ getAll<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
3104
+ batchSize?: number;
3105
+ }>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
2869
3106
  /**
2870
3107
  * Performs the query in the database and returns the first result.
2871
3108
  * @param options Additional options to be used when performing the query.
2872
3109
  * @returns The first record that matches the query, or null if no record matched the query.
2873
3110
  */
2874
- getOne(): Promise<Result | null>;
2875
- getOne(options: Omit<QueryOptions<Record>, 'columns' | 'page'>): Promise<Result | null>;
2876
- getOne<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
3111
+ getFirst(): Promise<Result | null>;
3112
+ getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
3113
+ getFirst<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
3114
+ /**
3115
+ * Builds a new query object adding a cache TTL in milliseconds.
3116
+ * @param ttl The cache TTL in milliseconds.
3117
+ * @returns A new Query object.
3118
+ */
3119
+ cache(ttl: number): Query<Record, Result>;
2877
3120
  nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
2878
3121
  previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
2879
3122
  firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
@@ -2957,14 +3200,11 @@ declare type OffsetNavigationOptions = {
2957
3200
  size?: number;
2958
3201
  offset?: number;
2959
3202
  };
2960
- declare type PaginationOptions = CursorNavigationOptions & OffsetNavigationOptions;
2961
3203
  declare const PAGINATION_MAX_SIZE = 200;
2962
3204
  declare const PAGINATION_DEFAULT_SIZE = 200;
2963
3205
  declare const PAGINATION_MAX_OFFSET = 800;
2964
3206
  declare const PAGINATION_DEFAULT_OFFSET = 0;
2965
3207
 
2966
- declare type TableLink = string[];
2967
- declare type LinkDictionary = Dictionary<TableLink[]>;
2968
3208
  /**
2969
3209
  * Common interface for performing operations on a table.
2970
3210
  */
@@ -3070,9 +3310,8 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
3070
3310
  db: SchemaPluginResult<any>;
3071
3311
  constructor(options: {
3072
3312
  table: string;
3073
- links?: LinkDictionary;
3074
- getFetchProps: () => Promise<FetcherExtraProps>;
3075
3313
  db: SchemaPluginResult<any>;
3314
+ pluginOptions: XataPluginOptions;
3076
3315
  });
3077
3316
  create(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3078
3317
  create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
@@ -3084,7 +3323,7 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
3084
3323
  createOrUpdate(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3085
3324
  createOrUpdate(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3086
3325
  createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
3087
- delete(recordId: string | Identifiable | Array<string | Identifiable>): Promise<void>;
3326
+ delete(a: string | Identifiable | Array<string | Identifiable>): Promise<void>;
3088
3327
  search(query: string, options?: {
3089
3328
  fuzziness?: number;
3090
3329
  }): Promise<SelectedPick<Record, ['*']>[]>;
@@ -3166,16 +3405,17 @@ declare const includesAny: <T>(value: T) => ArrayFilter<T>;
3166
3405
 
3167
3406
  declare type SchemaDefinition = {
3168
3407
  table: string;
3169
- links?: LinkDictionary;
3170
3408
  };
3171
3409
  declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
3172
3410
  [Key in keyof Schemas]: Repository<Schemas[Key]>;
3411
+ } & {
3412
+ [key: string]: Repository<XataRecord$1>;
3173
3413
  };
3174
3414
  declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
3175
3415
  #private;
3176
- private links?;
3177
- constructor(links?: LinkDictionary | undefined);
3178
- build(options: XataPluginOptions): SchemaPluginResult<Schemas>;
3416
+ private tableNames?;
3417
+ constructor(tableNames?: string[] | undefined);
3418
+ build(pluginOptions: XataPluginOptions): SchemaPluginResult<Schemas>;
3179
3419
  }
3180
3420
 
3181
3421
  declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
@@ -3196,8 +3436,7 @@ declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
3196
3436
  declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
3197
3437
  #private;
3198
3438
  private db;
3199
- private links;
3200
- constructor(db: SchemaPluginResult<Schemas>, links: LinkDictionary);
3439
+ constructor(db: SchemaPluginResult<Schemas>);
3201
3440
  build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
3202
3441
  }
3203
3442
  declare type SearchXataRecord = XataRecord & {
@@ -3216,10 +3455,11 @@ declare type BaseClientOptions = {
3216
3455
  apiKey?: string;
3217
3456
  databaseURL?: string;
3218
3457
  branch?: BranchStrategyOption;
3458
+ cache?: CacheImpl;
3219
3459
  };
3220
3460
  declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
3221
3461
  interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
3222
- new <Schemas extends Record<string, BaseData>>(options?: Partial<BaseClientOptions>, links?: LinkDictionary): Omit<{
3462
+ new <Schemas extends Record<string, BaseData> = {}>(options?: Partial<BaseClientOptions>, tables?: string[]): Omit<{
3223
3463
  db: Awaited<ReturnType<SchemaPlugin<Schemas>['build']>>;
3224
3464
  search: Awaited<ReturnType<SearchPlugin<Schemas>['build']>>;
3225
3465
  }, keyof Plugins> & {
@@ -3235,7 +3475,7 @@ declare type BranchResolutionOptions = {
3235
3475
  apiKey?: string;
3236
3476
  fetchImpl?: FetchImpl;
3237
3477
  };
3238
- declare function getCurrentBranchName(options?: BranchResolutionOptions): Promise<string | undefined>;
3478
+ declare function getCurrentBranchName(options?: BranchResolutionOptions): Promise<string>;
3239
3479
  declare function getCurrentBranchDetails(options?: BranchResolutionOptions): Promise<DBBranch | null>;
3240
3480
  declare function getDatabaseURL(): string | undefined;
3241
3481
 
@@ -3246,4 +3486,4 @@ declare class XataError extends Error {
3246
3486
  constructor(message: string, status: number);
3247
3487
  }
3248
3488
 
3249
- export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsResponse, BulkInsertTableRecordsVariables, CancelWorkspaceMemberInviteError, CancelWorkspaceMemberInvitePathParams, CancelWorkspaceMemberInviteVariables, ClientConstructor, CreateBranchError, CreateBranchPathParams, CreateBranchQueryParams, CreateBranchRequestBody, CreateBranchVariables, CreateDatabaseError, CreateDatabasePathParams, CreateDatabaseRequestBody, CreateDatabaseResponse, CreateDatabaseVariables, CreateTableError, CreateTablePathParams, CreateTableVariables, CreateUserAPIKeyError, CreateUserAPIKeyPathParams, CreateUserAPIKeyResponse, CreateUserAPIKeyVariables, CreateWorkspaceError, CreateWorkspaceVariables, CursorNavigationOptions, DeleteBranchError, DeleteBranchPathParams, DeleteBranchVariables, DeleteColumnError, DeleteColumnPathParams, DeleteColumnVariables, DeleteDatabaseError, DeleteDatabasePathParams, DeleteDatabaseVariables, DeleteRecordError, DeleteRecordPathParams, DeleteRecordVariables, DeleteTableError, DeleteTablePathParams, DeleteTableVariables, DeleteUserAPIKeyError, DeleteUserAPIKeyPathParams, DeleteUserAPIKeyVariables, DeleteUserError, DeleteUserVariables, DeleteWorkspaceError, DeleteWorkspacePathParams, DeleteWorkspaceVariables, EditableData, ExecuteBranchMigrationPlanError, ExecuteBranchMigrationPlanPathParams, ExecuteBranchMigrationPlanRequestBody, ExecuteBranchMigrationPlanVariables, FetchImpl, FetcherExtraProps, GetBranchDetailsError, GetBranchDetailsPathParams, GetBranchDetailsVariables, GetBranchListError, GetBranchListPathParams, GetBranchListVariables, GetBranchMetadataError, GetBranchMetadataPathParams, GetBranchMetadataVariables, GetBranchMigrationHistoryError, GetBranchMigrationHistoryPathParams, GetBranchMigrationHistoryRequestBody, GetBranchMigrationHistoryResponse, GetBranchMigrationHistoryVariables, GetBranchMigrationPlanError, GetBranchMigrationPlanPathParams, GetBranchMigrationPlanVariables, GetBranchStatsError, GetBranchStatsPathParams, GetBranchStatsResponse, GetBranchStatsVariables, GetColumnError, GetColumnPathParams, GetColumnVariables, GetDatabaseListError, GetDatabaseListPathParams, GetDatabaseListVariables, GetRecordError, GetRecordPathParams, GetRecordRequestBody, GetRecordVariables, GetTableColumnsError, GetTableColumnsPathParams, GetTableColumnsResponse, GetTableColumnsVariables, GetTableSchemaError, GetTableSchemaPathParams, GetTableSchemaResponse, GetTableSchemaVariables, GetUserAPIKeysError, GetUserAPIKeysResponse, GetUserAPIKeysVariables, GetUserError, GetUserVariables, GetWorkspaceError, GetWorkspaceMembersListError, GetWorkspaceMembersListPathParams, GetWorkspaceMembersListVariables, GetWorkspacePathParams, GetWorkspaceVariables, GetWorkspacesListError, GetWorkspacesListResponse, GetWorkspacesListVariables, Identifiable, InsertRecordError, InsertRecordPathParams, InsertRecordResponse, InsertRecordVariables, InsertRecordWithIDError, InsertRecordWithIDPathParams, InsertRecordWithIDQueryParams, InsertRecordWithIDVariables, InviteWorkspaceMemberError, InviteWorkspaceMemberPathParams, InviteWorkspaceMemberRequestBody, InviteWorkspaceMemberVariables, LinkDictionary, OffsetNavigationOptions, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Paginable, PaginationOptions, PaginationQueryMeta, Query, QueryTableError, QueryTablePathParams, QueryTableRequestBody, QueryTableVariables, RemoveWorkspaceMemberError, RemoveWorkspaceMemberPathParams, RemoveWorkspaceMemberVariables, Repository, ResendWorkspaceMemberInviteError, ResendWorkspaceMemberInvitePathParams, ResendWorkspaceMemberInviteVariables, responses as Responses, RestRepository, SchemaDefinition, SchemaPlugin, SchemaPluginResult, schemas as Schemas, SearchBranchError, SearchBranchPathParams, SearchBranchRequestBody, SearchBranchVariables, SearchOptions, SearchPlugin, SearchPluginResult, SelectableColumn, SelectedPick, SetTableSchemaError, SetTableSchemaPathParams, SetTableSchemaRequestBody, SetTableSchemaVariables, UpdateBranchMetadataError, UpdateBranchMetadataPathParams, UpdateBranchMetadataVariables, UpdateColumnError, UpdateColumnPathParams, UpdateColumnRequestBody, UpdateColumnVariables, UpdateRecordWithIDError, UpdateRecordWithIDPathParams, UpdateRecordWithIDQueryParams, UpdateRecordWithIDVariables, UpdateTableError, UpdateTablePathParams, UpdateTableRequestBody, UpdateTableVariables, UpdateUserError, UpdateUserVariables, UpdateWorkspaceError, UpdateWorkspaceMemberRoleError, UpdateWorkspaceMemberRolePathParams, UpdateWorkspaceMemberRoleRequestBody, UpdateWorkspaceMemberRoleVariables, UpdateWorkspacePathParams, UpdateWorkspaceVariables, UpsertRecordWithIDError, UpsertRecordWithIDPathParams, UpsertRecordWithIDQueryParams, UpsertRecordWithIDVariables, ValueAtColumn, XataApiClient, XataApiClientOptions, XataApiPlugin, XataError, XataPlugin, XataPluginOptions, XataRecord, acceptWorkspaceMemberInvite, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeWorkspaceMember, resendWorkspaceMemberInvite, searchBranch, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
3489
+ 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, 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 };