@xata.io/client 0.0.0-alpha.vf38f30b → 0.0.0-alpha.vf481c73
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/.eslintrc.cjs +1 -2
- package/CHANGELOG.md +136 -0
- package/README.md +271 -1
- package/Usage.md +395 -0
- package/dist/index.cjs +703 -270
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +692 -146
- package/dist/index.mjs +696 -271
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -3
- package/tsconfig.json +1 -0
package/dist/index.d.ts
CHANGED
@@ -6,6 +6,9 @@ declare type FetchImpl = (url: string, init?: {
|
|
6
6
|
ok: boolean;
|
7
7
|
status: number;
|
8
8
|
json(): Promise<any>;
|
9
|
+
headers?: {
|
10
|
+
get(name: string): string | null;
|
11
|
+
};
|
9
12
|
}>;
|
10
13
|
declare type WorkspaceApiUrlBuilder = (path: string, pathParams: Record<string, string>) => string;
|
11
14
|
declare type FetcherExtraProps = {
|
@@ -19,11 +22,39 @@ declare type ErrorWrapper<TError> = TError | {
|
|
19
22
|
payload: string;
|
20
23
|
};
|
21
24
|
|
25
|
+
interface CacheImpl {
|
26
|
+
cacheRecords: boolean;
|
27
|
+
defaultQueryTTL: number;
|
28
|
+
getAll(): Promise<Record<string, unknown>>;
|
29
|
+
get: <T>(key: string) => Promise<T | null>;
|
30
|
+
set: <T>(key: string, value: T) => Promise<void>;
|
31
|
+
delete: (key: string) => Promise<void>;
|
32
|
+
clear: () => Promise<void>;
|
33
|
+
}
|
34
|
+
interface SimpleCacheOptions {
|
35
|
+
max?: number;
|
36
|
+
cacheRecords?: boolean;
|
37
|
+
defaultQueryTTL?: number;
|
38
|
+
}
|
39
|
+
declare class SimpleCache implements CacheImpl {
|
40
|
+
#private;
|
41
|
+
capacity: number;
|
42
|
+
cacheRecords: boolean;
|
43
|
+
defaultQueryTTL: number;
|
44
|
+
constructor(options?: SimpleCacheOptions);
|
45
|
+
getAll(): Promise<Record<string, unknown>>;
|
46
|
+
get<T>(key: string): Promise<T | null>;
|
47
|
+
set<T>(key: string, value: T): Promise<void>;
|
48
|
+
delete(key: string): Promise<void>;
|
49
|
+
clear(): Promise<void>;
|
50
|
+
}
|
51
|
+
|
22
52
|
declare abstract class XataPlugin {
|
23
53
|
abstract build(options: XataPluginOptions): unknown | Promise<unknown>;
|
24
54
|
}
|
25
55
|
declare type XataPluginOptions = {
|
26
56
|
getFetchProps: () => Promise<FetcherExtraProps>;
|
57
|
+
cache: CacheImpl;
|
27
58
|
};
|
28
59
|
|
29
60
|
/**
|
@@ -110,6 +141,12 @@ declare type ListBranchesResponse = {
|
|
110
141
|
displayName: string;
|
111
142
|
branches: Branch[];
|
112
143
|
};
|
144
|
+
declare type ListGitBranchesResponse = {
|
145
|
+
mapping: {
|
146
|
+
gitBranch: string;
|
147
|
+
xataBranch: string;
|
148
|
+
}[];
|
149
|
+
};
|
113
150
|
declare type Branch = {
|
114
151
|
name: string;
|
115
152
|
createdAt: DateTime;
|
@@ -158,7 +195,7 @@ declare type Table = {
|
|
158
195
|
*/
|
159
196
|
declare type Column = {
|
160
197
|
name: string;
|
161
|
-
type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object';
|
198
|
+
type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object' | 'datetime';
|
162
199
|
link?: {
|
163
200
|
table: string;
|
164
201
|
};
|
@@ -234,6 +271,21 @@ declare type SortExpression = string[] | {
|
|
234
271
|
[key: string]: SortOrder;
|
235
272
|
}[];
|
236
273
|
declare type SortOrder = 'asc' | 'desc';
|
274
|
+
/**
|
275
|
+
* Maximum [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) for the search terms. The Levenshtein
|
276
|
+
* distance is the number of one charcter changes needed to make two strings equal. The default is 1, meaning that single
|
277
|
+
* character typos per word are tollerated by search. You can set it to 0 to remove the typo tollerance or set it to 2
|
278
|
+
* to allow two typos in a word.
|
279
|
+
*
|
280
|
+
* @default 1
|
281
|
+
* @maximum 2
|
282
|
+
* @minimum 0
|
283
|
+
*/
|
284
|
+
declare type FuzzinessExpression = number;
|
285
|
+
/**
|
286
|
+
* If the prefix type is set to "disabled" (the default), the search only matches full words. If the prefix type is set to "phrase", the search will return results that match prefixes of the search phrase.
|
287
|
+
*/
|
288
|
+
declare type PrefixExpression = 'phrase' | 'disabled';
|
237
289
|
/**
|
238
290
|
* @minProperties 1
|
239
291
|
*/
|
@@ -247,6 +299,10 @@ declare type FilterExpression = {
|
|
247
299
|
} & {
|
248
300
|
[key: string]: FilterColumn;
|
249
301
|
};
|
302
|
+
declare type HighlightExpression = {
|
303
|
+
enabled?: boolean;
|
304
|
+
encodeHTML?: boolean;
|
305
|
+
};
|
250
306
|
declare type FilterList = FilterExpression | FilterExpression[];
|
251
307
|
declare type FilterColumn = FilterColumnIncludes | FilterPredicate | FilterList;
|
252
308
|
/**
|
@@ -332,6 +388,11 @@ declare type XataRecord$1 = {
|
|
332
388
|
xata: {
|
333
389
|
version: number;
|
334
390
|
table?: string;
|
391
|
+
highlight?: {
|
392
|
+
[key: string]: string[] | {
|
393
|
+
[key: string]: any;
|
394
|
+
};
|
395
|
+
};
|
335
396
|
warnings?: string[];
|
336
397
|
};
|
337
398
|
} & {
|
@@ -354,6 +415,7 @@ type schemas_WorkspaceMembers = WorkspaceMembers;
|
|
354
415
|
type schemas_InviteKey = InviteKey;
|
355
416
|
type schemas_ListDatabasesResponse = ListDatabasesResponse;
|
356
417
|
type schemas_ListBranchesResponse = ListBranchesResponse;
|
418
|
+
type schemas_ListGitBranchesResponse = ListGitBranchesResponse;
|
357
419
|
type schemas_Branch = Branch;
|
358
420
|
type schemas_BranchMetadata = BranchMetadata;
|
359
421
|
type schemas_DBBranch = DBBranch;
|
@@ -374,7 +436,10 @@ type schemas_TableMigration = TableMigration;
|
|
374
436
|
type schemas_ColumnMigration = ColumnMigration;
|
375
437
|
type schemas_SortExpression = SortExpression;
|
376
438
|
type schemas_SortOrder = SortOrder;
|
439
|
+
type schemas_FuzzinessExpression = FuzzinessExpression;
|
440
|
+
type schemas_PrefixExpression = PrefixExpression;
|
377
441
|
type schemas_FilterExpression = FilterExpression;
|
442
|
+
type schemas_HighlightExpression = HighlightExpression;
|
378
443
|
type schemas_FilterList = FilterList;
|
379
444
|
type schemas_FilterColumn = FilterColumn;
|
380
445
|
type schemas_FilterColumnIncludes = FilterColumnIncludes;
|
@@ -406,6 +471,7 @@ declare namespace schemas {
|
|
406
471
|
schemas_InviteKey as InviteKey,
|
407
472
|
schemas_ListDatabasesResponse as ListDatabasesResponse,
|
408
473
|
schemas_ListBranchesResponse as ListBranchesResponse,
|
474
|
+
schemas_ListGitBranchesResponse as ListGitBranchesResponse,
|
409
475
|
schemas_Branch as Branch,
|
410
476
|
schemas_BranchMetadata as BranchMetadata,
|
411
477
|
schemas_DBBranch as DBBranch,
|
@@ -426,7 +492,10 @@ declare namespace schemas {
|
|
426
492
|
schemas_ColumnMigration as ColumnMigration,
|
427
493
|
schemas_SortExpression as SortExpression,
|
428
494
|
schemas_SortOrder as SortOrder,
|
495
|
+
schemas_FuzzinessExpression as FuzzinessExpression,
|
496
|
+
schemas_PrefixExpression as PrefixExpression,
|
429
497
|
schemas_FilterExpression as FilterExpression,
|
498
|
+
schemas_HighlightExpression as HighlightExpression,
|
430
499
|
schemas_FilterList as FilterList,
|
431
500
|
schemas_FilterColumn as FilterColumn,
|
432
501
|
schemas_FilterColumnIncludes as FilterColumnIncludes,
|
@@ -982,6 +1051,163 @@ declare type DeleteDatabaseVariables = {
|
|
982
1051
|
* Delete a database and all of its branches and tables permanently.
|
983
1052
|
*/
|
984
1053
|
declare const deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
|
1054
|
+
declare type GetGitBranchesMappingPathParams = {
|
1055
|
+
dbName: DBName;
|
1056
|
+
workspace: string;
|
1057
|
+
};
|
1058
|
+
declare type GetGitBranchesMappingError = ErrorWrapper<{
|
1059
|
+
status: 400;
|
1060
|
+
payload: BadRequestError;
|
1061
|
+
} | {
|
1062
|
+
status: 401;
|
1063
|
+
payload: AuthError;
|
1064
|
+
}>;
|
1065
|
+
declare type GetGitBranchesMappingVariables = {
|
1066
|
+
pathParams: GetGitBranchesMappingPathParams;
|
1067
|
+
} & FetcherExtraProps;
|
1068
|
+
/**
|
1069
|
+
* Lists all the git branches in the mapping, and their associated Xata branches.
|
1070
|
+
*
|
1071
|
+
* Example response:
|
1072
|
+
*
|
1073
|
+
* ```json
|
1074
|
+
* {
|
1075
|
+
* "mappings": [
|
1076
|
+
* {
|
1077
|
+
* "gitBranch": "main",
|
1078
|
+
* "xataBranch": "main"
|
1079
|
+
* },
|
1080
|
+
* {
|
1081
|
+
* "gitBranch": "gitBranch1",
|
1082
|
+
* "xataBranch": "xataBranch1"
|
1083
|
+
* }
|
1084
|
+
* {
|
1085
|
+
* "gitBranch": "xataBranch2",
|
1086
|
+
* "xataBranch": "xataBranch2"
|
1087
|
+
* }
|
1088
|
+
* ]
|
1089
|
+
* }
|
1090
|
+
* ```
|
1091
|
+
*/
|
1092
|
+
declare const getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
|
1093
|
+
declare type AddGitBranchesEntryPathParams = {
|
1094
|
+
dbName: DBName;
|
1095
|
+
workspace: string;
|
1096
|
+
};
|
1097
|
+
declare type AddGitBranchesEntryError = ErrorWrapper<{
|
1098
|
+
status: 400;
|
1099
|
+
payload: BadRequestError;
|
1100
|
+
} | {
|
1101
|
+
status: 401;
|
1102
|
+
payload: AuthError;
|
1103
|
+
}>;
|
1104
|
+
declare type AddGitBranchesEntryResponse = {
|
1105
|
+
warning?: string;
|
1106
|
+
};
|
1107
|
+
declare type AddGitBranchesEntryRequestBody = {
|
1108
|
+
gitBranch: string;
|
1109
|
+
xataBranch: BranchName;
|
1110
|
+
};
|
1111
|
+
declare type AddGitBranchesEntryVariables = {
|
1112
|
+
body: AddGitBranchesEntryRequestBody;
|
1113
|
+
pathParams: AddGitBranchesEntryPathParams;
|
1114
|
+
} & FetcherExtraProps;
|
1115
|
+
/**
|
1116
|
+
* 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.
|
1117
|
+
*
|
1118
|
+
* 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.
|
1119
|
+
*
|
1120
|
+
* Example request:
|
1121
|
+
*
|
1122
|
+
* ```json
|
1123
|
+
* // POST https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches
|
1124
|
+
* {
|
1125
|
+
* "gitBranch": "fix/bug123",
|
1126
|
+
* "xataBranch": "fix_bug"
|
1127
|
+
* }
|
1128
|
+
* ```
|
1129
|
+
*/
|
1130
|
+
declare const addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
|
1131
|
+
declare type RemoveGitBranchesEntryPathParams = {
|
1132
|
+
dbName: DBName;
|
1133
|
+
workspace: string;
|
1134
|
+
};
|
1135
|
+
declare type RemoveGitBranchesEntryQueryParams = {
|
1136
|
+
gitBranch: string;
|
1137
|
+
};
|
1138
|
+
declare type RemoveGitBranchesEntryError = ErrorWrapper<{
|
1139
|
+
status: 400;
|
1140
|
+
payload: BadRequestError;
|
1141
|
+
} | {
|
1142
|
+
status: 401;
|
1143
|
+
payload: AuthError;
|
1144
|
+
}>;
|
1145
|
+
declare type RemoveGitBranchesEntryVariables = {
|
1146
|
+
pathParams: RemoveGitBranchesEntryPathParams;
|
1147
|
+
queryParams: RemoveGitBranchesEntryQueryParams;
|
1148
|
+
} & FetcherExtraProps;
|
1149
|
+
/**
|
1150
|
+
* 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.
|
1151
|
+
*
|
1152
|
+
* Example request:
|
1153
|
+
*
|
1154
|
+
* ```json
|
1155
|
+
* // DELETE https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches?gitBranch=fix%2Fbug123
|
1156
|
+
* ```
|
1157
|
+
*/
|
1158
|
+
declare const removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
|
1159
|
+
declare type ResolveBranchPathParams = {
|
1160
|
+
dbName: DBName;
|
1161
|
+
workspace: string;
|
1162
|
+
};
|
1163
|
+
declare type ResolveBranchQueryParams = {
|
1164
|
+
gitBranch?: string;
|
1165
|
+
fallbackBranch?: string;
|
1166
|
+
};
|
1167
|
+
declare type ResolveBranchError = ErrorWrapper<{
|
1168
|
+
status: 400;
|
1169
|
+
payload: BadRequestError;
|
1170
|
+
} | {
|
1171
|
+
status: 401;
|
1172
|
+
payload: AuthError;
|
1173
|
+
}>;
|
1174
|
+
declare type ResolveBranchResponse = {
|
1175
|
+
branch: string;
|
1176
|
+
reason: {
|
1177
|
+
code: 'FOUND_IN_MAPPING' | 'BRANCH_EXISTS' | 'FALLBACK_BRANCH' | 'DEFAULT_BRANCH';
|
1178
|
+
message: string;
|
1179
|
+
};
|
1180
|
+
};
|
1181
|
+
declare type ResolveBranchVariables = {
|
1182
|
+
pathParams: ResolveBranchPathParams;
|
1183
|
+
queryParams?: ResolveBranchQueryParams;
|
1184
|
+
} & FetcherExtraProps;
|
1185
|
+
/**
|
1186
|
+
* In order to resolve the database branch, the following algorithm is used:
|
1187
|
+
* * if the `gitBranch` was provided and is found in the [git branches mapping](/api-reference/dbs/db_name/gitBranches), the associated Xata branch is returned
|
1188
|
+
* * else, if a Xata branch with the exact same name as `gitBranch` exists, return it
|
1189
|
+
* * else, if `fallbackBranch` is provided and a branch with that name exists, return it
|
1190
|
+
* * else, return the default branch of the DB (`main` or the first branch)
|
1191
|
+
*
|
1192
|
+
* Example call:
|
1193
|
+
*
|
1194
|
+
* ```json
|
1195
|
+
* // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test&fallbackBranch=tsg
|
1196
|
+
* ```
|
1197
|
+
*
|
1198
|
+
* Example response:
|
1199
|
+
*
|
1200
|
+
* ```json
|
1201
|
+
* {
|
1202
|
+
* "branch": "main",
|
1203
|
+
* "reason": {
|
1204
|
+
* "code": "DEFAULT_BRANCH",
|
1205
|
+
* "message": "Default branch for this database (main)"
|
1206
|
+
* }
|
1207
|
+
* }
|
1208
|
+
* ```
|
1209
|
+
*/
|
1210
|
+
declare const resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
|
985
1211
|
declare type GetBranchDetailsPathParams = {
|
986
1212
|
dbBranchName: DBBranchName;
|
987
1213
|
workspace: string;
|
@@ -1266,8 +1492,9 @@ declare type UpdateTableVariables = {
|
|
1266
1492
|
*
|
1267
1493
|
* In the example below, we rename a table from “users” to “people”:
|
1268
1494
|
*
|
1269
|
-
* ```
|
1270
|
-
* PATCH /db/test:main/tables/users
|
1495
|
+
* ```json
|
1496
|
+
* // PATCH /db/test:main/tables/users
|
1497
|
+
*
|
1271
1498
|
* {
|
1272
1499
|
* "name": "people"
|
1273
1500
|
* }
|
@@ -1675,7 +1902,7 @@ declare type QueryTableVariables = {
|
|
1675
1902
|
* {
|
1676
1903
|
* "columns": [...],
|
1677
1904
|
* "filter": {
|
1678
|
-
* "$all": [...]
|
1905
|
+
* "$all": [...],
|
1679
1906
|
* "$any": [...]
|
1680
1907
|
* ...
|
1681
1908
|
* },
|
@@ -1721,7 +1948,11 @@ declare type QueryTableVariables = {
|
|
1721
1948
|
* "link": {
|
1722
1949
|
* "table": "users"
|
1723
1950
|
* }
|
1724
|
-
* }
|
1951
|
+
* },
|
1952
|
+
* {
|
1953
|
+
* "name": "foundedDate",
|
1954
|
+
* "type": "datetime"
|
1955
|
+
* },
|
1725
1956
|
* ]
|
1726
1957
|
* },
|
1727
1958
|
* {
|
@@ -1809,7 +2040,7 @@ declare type QueryTableVariables = {
|
|
1809
2040
|
* {
|
1810
2041
|
* "name": "Kilian",
|
1811
2042
|
* "address": {
|
1812
|
-
* "street": "New street"
|
2043
|
+
* "street": "New street"
|
1813
2044
|
* }
|
1814
2045
|
* }
|
1815
2046
|
* ```
|
@@ -1818,10 +2049,7 @@ declare type QueryTableVariables = {
|
|
1818
2049
|
*
|
1819
2050
|
* ```json
|
1820
2051
|
* {
|
1821
|
-
* "columns": [
|
1822
|
-
* "*",
|
1823
|
-
* "team.name"
|
1824
|
-
* ]
|
2052
|
+
* "columns": ["*", "team.name"]
|
1825
2053
|
* }
|
1826
2054
|
* ```
|
1827
2055
|
*
|
@@ -1839,7 +2067,7 @@ declare type QueryTableVariables = {
|
|
1839
2067
|
* "team": {
|
1840
2068
|
* "id": "XX",
|
1841
2069
|
* "xata": {
|
1842
|
-
* "version": 0
|
2070
|
+
* "version": 0
|
1843
2071
|
* },
|
1844
2072
|
* "name": "first team"
|
1845
2073
|
* }
|
@@ -1850,10 +2078,7 @@ declare type QueryTableVariables = {
|
|
1850
2078
|
*
|
1851
2079
|
* ```json
|
1852
2080
|
* {
|
1853
|
-
* "columns": [
|
1854
|
-
* "*",
|
1855
|
-
* "team.*"
|
1856
|
-
* ]
|
2081
|
+
* "columns": ["*", "team.*"]
|
1857
2082
|
* }
|
1858
2083
|
* ```
|
1859
2084
|
*
|
@@ -1871,10 +2096,11 @@ declare type QueryTableVariables = {
|
|
1871
2096
|
* "team": {
|
1872
2097
|
* "id": "XX",
|
1873
2098
|
* "xata": {
|
1874
|
-
* "version": 0
|
2099
|
+
* "version": 0
|
1875
2100
|
* },
|
1876
2101
|
* "name": "first team",
|
1877
|
-
* "code": "A1"
|
2102
|
+
* "code": "A1",
|
2103
|
+
* "foundedDate": "2020-03-04T10:43:54.32Z"
|
1878
2104
|
* }
|
1879
2105
|
* }
|
1880
2106
|
* ```
|
@@ -1889,7 +2115,7 @@ declare type QueryTableVariables = {
|
|
1889
2115
|
* `$none`, etc.
|
1890
2116
|
*
|
1891
2117
|
* All operators start with an `$` to differentiate them from column names
|
1892
|
-
* (which are not allowed to start with
|
2118
|
+
* (which are not allowed to start with a dollar sign).
|
1893
2119
|
*
|
1894
2120
|
* #### Exact matching and control operators
|
1895
2121
|
*
|
@@ -1920,7 +2146,7 @@ declare type QueryTableVariables = {
|
|
1920
2146
|
* ```json
|
1921
2147
|
* {
|
1922
2148
|
* "filter": {
|
1923
|
-
*
|
2149
|
+
* "name": "r2"
|
1924
2150
|
* }
|
1925
2151
|
* }
|
1926
2152
|
* ```
|
@@ -1942,7 +2168,7 @@ declare type QueryTableVariables = {
|
|
1942
2168
|
* ```json
|
1943
2169
|
* {
|
1944
2170
|
* "filter": {
|
1945
|
-
*
|
2171
|
+
* "settings.plan": "free"
|
1946
2172
|
* }
|
1947
2173
|
* }
|
1948
2174
|
* ```
|
@@ -1952,8 +2178,8 @@ declare type QueryTableVariables = {
|
|
1952
2178
|
* "filter": {
|
1953
2179
|
* "settings": {
|
1954
2180
|
* "plan": "free"
|
1955
|
-
* }
|
1956
|
-
* }
|
2181
|
+
* }
|
2182
|
+
* }
|
1957
2183
|
* }
|
1958
2184
|
* ```
|
1959
2185
|
*
|
@@ -1962,8 +2188,8 @@ declare type QueryTableVariables = {
|
|
1962
2188
|
* ```json
|
1963
2189
|
* {
|
1964
2190
|
* "filter": {
|
1965
|
-
* "settings.plan": {"$any": ["free", "paid"]}
|
1966
|
-
* }
|
2191
|
+
* "settings.plan": { "$any": ["free", "paid"] }
|
2192
|
+
* }
|
1967
2193
|
* }
|
1968
2194
|
* ```
|
1969
2195
|
*
|
@@ -1972,9 +2198,9 @@ declare type QueryTableVariables = {
|
|
1972
2198
|
* ```json
|
1973
2199
|
* {
|
1974
2200
|
* "filter": {
|
1975
|
-
*
|
1976
|
-
*
|
1977
|
-
* }
|
2201
|
+
* "settings.dark": true,
|
2202
|
+
* "settings.plan": "free"
|
2203
|
+
* }
|
1978
2204
|
* }
|
1979
2205
|
* ```
|
1980
2206
|
*
|
@@ -1985,11 +2211,11 @@ declare type QueryTableVariables = {
|
|
1985
2211
|
* ```json
|
1986
2212
|
* {
|
1987
2213
|
* "filter": {
|
1988
|
-
*
|
1989
|
-
*
|
1990
|
-
*
|
1991
|
-
*
|
1992
|
-
* }
|
2214
|
+
* "$any": {
|
2215
|
+
* "settings.dark": true,
|
2216
|
+
* "settings.plan": "free"
|
2217
|
+
* }
|
2218
|
+
* }
|
1993
2219
|
* }
|
1994
2220
|
* ```
|
1995
2221
|
*
|
@@ -2000,10 +2226,10 @@ declare type QueryTableVariables = {
|
|
2000
2226
|
* "filter": {
|
2001
2227
|
* "$any": [
|
2002
2228
|
* {
|
2003
|
-
* "name": "r1"
|
2229
|
+
* "name": "r1"
|
2004
2230
|
* },
|
2005
2231
|
* {
|
2006
|
-
* "name": "r2"
|
2232
|
+
* "name": "r2"
|
2007
2233
|
* }
|
2008
2234
|
* ]
|
2009
2235
|
* }
|
@@ -2015,7 +2241,7 @@ declare type QueryTableVariables = {
|
|
2015
2241
|
* ```json
|
2016
2242
|
* {
|
2017
2243
|
* "filter": {
|
2018
|
-
* "$exists": "settings"
|
2244
|
+
* "$exists": "settings"
|
2019
2245
|
* }
|
2020
2246
|
* }
|
2021
2247
|
* ```
|
@@ -2027,10 +2253,10 @@ declare type QueryTableVariables = {
|
|
2027
2253
|
* "filter": {
|
2028
2254
|
* "$all": [
|
2029
2255
|
* {
|
2030
|
-
* "$exists": "settings"
|
2256
|
+
* "$exists": "settings"
|
2031
2257
|
* },
|
2032
2258
|
* {
|
2033
|
-
* "$exists": "name"
|
2259
|
+
* "$exists": "name"
|
2034
2260
|
* }
|
2035
2261
|
* ]
|
2036
2262
|
* }
|
@@ -2042,7 +2268,7 @@ declare type QueryTableVariables = {
|
|
2042
2268
|
* ```json
|
2043
2269
|
* {
|
2044
2270
|
* "filter": {
|
2045
|
-
* "$notExists": "settings"
|
2271
|
+
* "$notExists": "settings"
|
2046
2272
|
* }
|
2047
2273
|
* }
|
2048
2274
|
* ```
|
@@ -2069,43 +2295,59 @@ declare type QueryTableVariables = {
|
|
2069
2295
|
* {
|
2070
2296
|
* "filter": {
|
2071
2297
|
* "<column_name>": {
|
2072
|
-
*
|
2298
|
+
* "$pattern": "v*alu?"
|
2073
2299
|
* }
|
2074
2300
|
* }
|
2075
2301
|
* }
|
2076
2302
|
* ```
|
2077
2303
|
*
|
2304
|
+
* The `$pattern` operator accepts two wildcard characters:
|
2305
|
+
* * `*` matches zero or more characters
|
2306
|
+
* * `?` matches exactly one character
|
2307
|
+
*
|
2308
|
+
* If you want to match a string that contains a wildcard character, you can escape them using a backslash (`\`). You can escape a backslash by usign another backslash.
|
2309
|
+
*
|
2078
2310
|
* We could also have `$endsWith` and `$startsWith` operators:
|
2079
2311
|
*
|
2080
2312
|
* ```json
|
2081
2313
|
* {
|
2082
2314
|
* "filter": {
|
2083
2315
|
* "<column_name>": {
|
2084
|
-
*
|
2316
|
+
* "$endsWith": ".gz"
|
2085
2317
|
* },
|
2086
2318
|
* "<column_name>": {
|
2087
|
-
*
|
2319
|
+
* "$startsWith": "tmp-"
|
2088
2320
|
* }
|
2089
2321
|
* }
|
2090
2322
|
* }
|
2091
2323
|
* ```
|
2092
2324
|
*
|
2093
|
-
* #### Numeric ranges
|
2325
|
+
* #### Numeric or datetime ranges
|
2094
2326
|
*
|
2095
2327
|
* ```json
|
2096
2328
|
* {
|
2097
2329
|
* "filter": {
|
2098
|
-
*
|
2099
|
-
*
|
2100
|
-
*
|
2101
|
-
*
|
2330
|
+
* "<column_name>": {
|
2331
|
+
* "$ge": 0,
|
2332
|
+
* "$lt": 100
|
2333
|
+
* }
|
2334
|
+
* }
|
2335
|
+
* }
|
2336
|
+
* ```
|
2337
|
+
* Date ranges support the same operators, with the date using the format defined in
|
2338
|
+
* [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339):
|
2339
|
+
* ```json
|
2340
|
+
* {
|
2341
|
+
* "filter": {
|
2342
|
+
* "<column_name>": {
|
2343
|
+
* "$gt": "2019-10-12T07:20:50.52Z",
|
2344
|
+
* "$lt": "2021-10-12T07:20:50.52Z"
|
2345
|
+
* }
|
2102
2346
|
* }
|
2103
2347
|
* }
|
2104
2348
|
* ```
|
2105
|
-
*
|
2106
2349
|
* The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
|
2107
2350
|
*
|
2108
|
-
*
|
2109
2351
|
* #### Negations
|
2110
2352
|
*
|
2111
2353
|
* A general `$not` operator can inverse any operation.
|
@@ -2130,15 +2372,21 @@ declare type QueryTableVariables = {
|
|
2130
2372
|
* {
|
2131
2373
|
* "filter": {
|
2132
2374
|
* "$not": {
|
2133
|
-
* "$any": [
|
2134
|
-
*
|
2135
|
-
*
|
2136
|
-
*
|
2137
|
-
*
|
2138
|
-
*
|
2139
|
-
*
|
2140
|
-
*
|
2141
|
-
*
|
2375
|
+
* "$any": [
|
2376
|
+
* {
|
2377
|
+
* "<column_name1>": "value1"
|
2378
|
+
* },
|
2379
|
+
* {
|
2380
|
+
* "$all": [
|
2381
|
+
* {
|
2382
|
+
* "<column_name2>": "value2"
|
2383
|
+
* },
|
2384
|
+
* {
|
2385
|
+
* "<column_name3>": "value3"
|
2386
|
+
* }
|
2387
|
+
* ]
|
2388
|
+
* }
|
2389
|
+
* ]
|
2142
2390
|
* }
|
2143
2391
|
* }
|
2144
2392
|
* }
|
@@ -2193,8 +2441,8 @@ declare type QueryTableVariables = {
|
|
2193
2441
|
* "<array name>": {
|
2194
2442
|
* "$includes": {
|
2195
2443
|
* "$all": [
|
2196
|
-
* {"$contains": "label"},
|
2197
|
-
* {"$not": {"$endsWith": "-debug"}}
|
2444
|
+
* { "$contains": "label" },
|
2445
|
+
* { "$not": { "$endsWith": "-debug" } }
|
2198
2446
|
* ]
|
2199
2447
|
* }
|
2200
2448
|
* }
|
@@ -2214,9 +2462,7 @@ declare type QueryTableVariables = {
|
|
2214
2462
|
* {
|
2215
2463
|
* "filter": {
|
2216
2464
|
* "settings.labels": {
|
2217
|
-
* "$includesAll": [
|
2218
|
-
* {"$contains": "label"},
|
2219
|
-
* ]
|
2465
|
+
* "$includesAll": [{ "$contains": "label" }]
|
2220
2466
|
* }
|
2221
2467
|
* }
|
2222
2468
|
* }
|
@@ -2264,7 +2510,6 @@ declare type QueryTableVariables = {
|
|
2264
2510
|
* }
|
2265
2511
|
* ```
|
2266
2512
|
*
|
2267
|
-
*
|
2268
2513
|
* ### Pagination
|
2269
2514
|
*
|
2270
2515
|
* We offer cursor pagination and offset pagination. The offset pagination is limited
|
@@ -2330,8 +2575,8 @@ declare type QueryTableVariables = {
|
|
2330
2575
|
* can be queried by update `page.after` to the returned cursor while keeping the
|
2331
2576
|
* `page.before` cursor from the first range query.
|
2332
2577
|
*
|
2333
|
-
* The `filter` , `columns`,
|
2334
|
-
* encoded with the cursor.
|
2578
|
+
* The `filter` , `columns`, `sort` , and `page.size` configuration will be
|
2579
|
+
* encoded with the cursor. The pagination request will be invalid if
|
2335
2580
|
* `filter` or `sort` is set. The columns returned and page size can be changed
|
2336
2581
|
* anytime by passing the `columns` or `page.size` settings to the next query.
|
2337
2582
|
*
|
@@ -2368,6 +2613,40 @@ declare type QueryTableVariables = {
|
|
2368
2613
|
* ```
|
2369
2614
|
*/
|
2370
2615
|
declare const queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
2616
|
+
declare type SearchTablePathParams = {
|
2617
|
+
dbBranchName: DBBranchName;
|
2618
|
+
tableName: TableName;
|
2619
|
+
workspace: string;
|
2620
|
+
};
|
2621
|
+
declare type SearchTableError = ErrorWrapper<{
|
2622
|
+
status: 400;
|
2623
|
+
payload: BadRequestError;
|
2624
|
+
} | {
|
2625
|
+
status: 401;
|
2626
|
+
payload: AuthError;
|
2627
|
+
} | {
|
2628
|
+
status: 404;
|
2629
|
+
payload: SimpleError;
|
2630
|
+
}>;
|
2631
|
+
declare type SearchTableRequestBody = {
|
2632
|
+
query: string;
|
2633
|
+
fuzziness?: FuzzinessExpression;
|
2634
|
+
prefix?: PrefixExpression;
|
2635
|
+
filter?: FilterExpression;
|
2636
|
+
highlight?: HighlightExpression;
|
2637
|
+
};
|
2638
|
+
declare type SearchTableVariables = {
|
2639
|
+
body: SearchTableRequestBody;
|
2640
|
+
pathParams: SearchTablePathParams;
|
2641
|
+
} & FetcherExtraProps;
|
2642
|
+
/**
|
2643
|
+
* Run a free text search operation in a particular table.
|
2644
|
+
*
|
2645
|
+
* The endpoint accepts a `query` parameter that is used for the free text search and a set of structured filters (via the `filter` parameter) that are applied before the search. The `filter` parameter uses the same syntax as the [query endpoint](/api-reference/db/db_branch_name/tables/table_name/) with the following exceptions:
|
2646
|
+
* * filters `$contains`, `$startsWith`, `$endsWith` don't work on columns of type `text`
|
2647
|
+
* * filtering on columns of type `multiple` is currently unsupported
|
2648
|
+
*/
|
2649
|
+
declare const searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
|
2371
2650
|
declare type SearchBranchPathParams = {
|
2372
2651
|
dbBranchName: DBBranchName;
|
2373
2652
|
workspace: string;
|
@@ -2383,9 +2662,13 @@ declare type SearchBranchError = ErrorWrapper<{
|
|
2383
2662
|
payload: SimpleError;
|
2384
2663
|
}>;
|
2385
2664
|
declare type SearchBranchRequestBody = {
|
2386
|
-
tables?: string
|
2665
|
+
tables?: (string | {
|
2666
|
+
table: string;
|
2667
|
+
filter?: FilterExpression;
|
2668
|
+
})[];
|
2387
2669
|
query: string;
|
2388
|
-
fuzziness?:
|
2670
|
+
fuzziness?: FuzzinessExpression;
|
2671
|
+
highlight?: HighlightExpression;
|
2389
2672
|
};
|
2390
2673
|
declare type SearchBranchVariables = {
|
2391
2674
|
body: SearchBranchRequestBody;
|
@@ -2422,6 +2705,10 @@ declare const operationsByTag: {
|
|
2422
2705
|
getDatabaseList: (variables: GetDatabaseListVariables) => Promise<ListDatabasesResponse>;
|
2423
2706
|
createDatabase: (variables: CreateDatabaseVariables) => Promise<CreateDatabaseResponse>;
|
2424
2707
|
deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
|
2708
|
+
getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
|
2709
|
+
addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
|
2710
|
+
removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
|
2711
|
+
resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
|
2425
2712
|
};
|
2426
2713
|
branch: {
|
2427
2714
|
getBranchList: (variables: GetBranchListVariables) => Promise<ListBranchesResponse>;
|
@@ -2456,6 +2743,7 @@ declare const operationsByTag: {
|
|
2456
2743
|
getRecord: (variables: GetRecordVariables) => Promise<XataRecord$1>;
|
2457
2744
|
bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
|
2458
2745
|
queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
2746
|
+
searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
|
2459
2747
|
searchBranch: (variables: SearchBranchVariables) => Promise<SearchResponse>;
|
2460
2748
|
};
|
2461
2749
|
};
|
@@ -2472,6 +2760,9 @@ interface XataApiClientOptions {
|
|
2472
2760
|
apiKey?: string;
|
2473
2761
|
host?: HostProvider;
|
2474
2762
|
}
|
2763
|
+
/**
|
2764
|
+
* @deprecated Use XataApiPlugin instead
|
2765
|
+
*/
|
2475
2766
|
declare class XataApiClient {
|
2476
2767
|
#private;
|
2477
2768
|
constructor(options?: XataApiClientOptions);
|
@@ -2514,6 +2805,10 @@ declare class DatabaseApi {
|
|
2514
2805
|
getDatabaseList(workspace: WorkspaceID): Promise<ListDatabasesResponse>;
|
2515
2806
|
createDatabase(workspace: WorkspaceID, dbName: DBName, options?: CreateDatabaseRequestBody): Promise<CreateDatabaseResponse>;
|
2516
2807
|
deleteDatabase(workspace: WorkspaceID, dbName: DBName): Promise<void>;
|
2808
|
+
getGitBranchesMapping(workspace: WorkspaceID, dbName: DBName): Promise<ListGitBranchesResponse>;
|
2809
|
+
addGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, body: AddGitBranchesEntryRequestBody): Promise<AddGitBranchesEntryResponse>;
|
2810
|
+
removeGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<void>;
|
2811
|
+
resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch?: string, fallbackBranch?: string): Promise<ResolveBranchResponse>;
|
2517
2812
|
}
|
2518
2813
|
declare class BranchApi {
|
2519
2814
|
private extraProps;
|
@@ -2554,6 +2849,7 @@ declare class RecordsApi {
|
|
2554
2849
|
getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: GetRecordRequestBody): Promise<XataRecord$1>;
|
2555
2850
|
bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[]): Promise<BulkInsertTableRecordsResponse>;
|
2556
2851
|
queryTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: QueryTableRequestBody): Promise<QueryResponse>;
|
2852
|
+
searchTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: SearchTableRequestBody): Promise<SearchResponse>;
|
2557
2853
|
searchBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, query: SearchBranchRequestBody): Promise<SearchResponse>;
|
2558
2854
|
}
|
2559
2855
|
|
@@ -2575,20 +2871,20 @@ declare type RequiredBy<T, K extends keyof T> = T & {
|
|
2575
2871
|
};
|
2576
2872
|
declare type GetArrayInnerType<T extends readonly any[]> = T[number];
|
2577
2873
|
declare type SingleOrArray<T> = T | T[];
|
2578
|
-
declare type
|
2874
|
+
declare type OmitBy<T, K extends keyof T> = T extends any ? Omit<T, K> : never;
|
2579
2875
|
|
2580
2876
|
declare type SelectableColumn<O, RecursivePath extends any[] = []> = '*' | 'id' | DataProps<O> | NestedColumns<O, RecursivePath>;
|
2581
2877
|
declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord & UnionToIntersection<Values<{
|
2582
2878
|
[K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord;
|
2583
2879
|
}>>;
|
2584
|
-
declare type ValueAtColumn<O, P extends SelectableColumn<O>> = P extends '*' ? Values<O> : P extends 'id' ? string : P extends keyof O ? O[P] : P extends `${infer K}.${infer V}` ? K extends keyof O ? Values<O[K] extends
|
2585
|
-
V: ValueAtColumn<
|
2586
|
-
} : never
|
2880
|
+
declare type ValueAtColumn<O, P extends SelectableColumn<O>> = P extends '*' ? Values<O> : P extends 'id' ? string : P extends keyof O ? O[P] : P extends `${infer K}.${infer V}` ? K extends keyof O ? Values<NonNullable<O[K]> extends infer Item ? Item extends Record<string, any> ? V extends SelectableColumn<Item> ? {
|
2881
|
+
V: ValueAtColumn<Item, V>;
|
2882
|
+
} : never : O[K] : never> : never : never;
|
2587
2883
|
declare type MAX_RECURSION = 5;
|
2588
2884
|
declare type NestedColumns<O, RecursivePath extends any[]> = RecursivePath['length'] extends MAX_RECURSION ? never : If<IsObject<O>, Values<{
|
2589
|
-
[K in DataProps<O>]:
|
2590
|
-
If<IsObject<
|
2591
|
-
K
|
2885
|
+
[K in DataProps<O>]: NonNullable<O[K]> extends infer Item ? If<IsArray<Item>, K, // If the property is an array, we stop recursion. We don't support object arrays yet
|
2886
|
+
If<IsObject<Item>, Item extends XataRecord ? SelectableColumn<Item, [...RecursivePath, Item]> extends infer Column ? Column extends string ? K | `${K}.${Column}` : never : never : Item extends Date ? K : `${K}.${StringKeys<Item> | '*'}`, // This allows usage of objects that are not links
|
2887
|
+
K>> : never;
|
2592
2888
|
}>, never>;
|
2593
2889
|
declare type DataProps<O> = Exclude<StringKeys<O>, StringKeys<XataRecord>>;
|
2594
2890
|
declare type NestedValueAtColumn<O, Key extends SelectableColumn<O>> = Key extends `${infer N}.${infer M}` ? N extends DataProps<O> ? {
|
@@ -2615,16 +2911,11 @@ interface BaseData {
|
|
2615
2911
|
/**
|
2616
2912
|
* Represents a persisted record from the database.
|
2617
2913
|
*/
|
2618
|
-
interface XataRecord extends Identifiable {
|
2914
|
+
interface XataRecord<ExtraMetadata extends Record<string, unknown> = Record<string, unknown>> extends Identifiable {
|
2619
2915
|
/**
|
2620
|
-
*
|
2916
|
+
* Get metadata of this record.
|
2621
2917
|
*/
|
2622
|
-
|
2623
|
-
/**
|
2624
|
-
* Number that is increased every time the record is updated.
|
2625
|
-
*/
|
2626
|
-
version: number;
|
2627
|
-
};
|
2918
|
+
getMetadata(): XataRecordMetadata & ExtraMetadata;
|
2628
2919
|
/**
|
2629
2920
|
* Retrieves a refreshed copy of the current record from the database.
|
2630
2921
|
*/
|
@@ -2632,7 +2923,7 @@ interface XataRecord extends Identifiable {
|
|
2632
2923
|
/**
|
2633
2924
|
* Performs a partial update of the current record. On success a new object is
|
2634
2925
|
* returned and the current object is not mutated.
|
2635
|
-
* @param
|
2926
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
2636
2927
|
* @returns A new record containing the latest values for all the columns of the current record.
|
2637
2928
|
*/
|
2638
2929
|
update(partialUpdate: Partial<EditableData<Omit<this, keyof XataRecord>>>): Promise<Readonly<SelectedPick<this, ['*']>>>;
|
@@ -2651,19 +2942,26 @@ declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update
|
|
2651
2942
|
/**
|
2652
2943
|
* Performs a partial update of the current record. On success a new object is
|
2653
2944
|
* returned and the current object is not mutated.
|
2654
|
-
* @param
|
2945
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
2655
2946
|
* @returns A new record containing the latest values for all the columns of the current record.
|
2656
2947
|
*/
|
2657
2948
|
update(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
2658
2949
|
};
|
2950
|
+
declare type XataRecordMetadata = {
|
2951
|
+
/**
|
2952
|
+
* Number that is increased every time the record is updated.
|
2953
|
+
*/
|
2954
|
+
version: number;
|
2955
|
+
warnings?: string[];
|
2956
|
+
};
|
2659
2957
|
declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
|
2660
2958
|
declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
|
2661
2959
|
declare type EditableData<O extends BaseData> = {
|
2662
2960
|
[K in keyof O]: O[K] extends XataRecord ? {
|
2663
2961
|
id: string;
|
2664
|
-
} : NonNullable<O[K]> extends XataRecord ? {
|
2962
|
+
} | string : NonNullable<O[K]> extends XataRecord ? {
|
2665
2963
|
id: string;
|
2666
|
-
} | null | undefined : O[K];
|
2964
|
+
} | string | null | undefined : O[K];
|
2667
2965
|
};
|
2668
2966
|
|
2669
2967
|
/**
|
@@ -2739,8 +3037,8 @@ declare type ValueTypeFilters<T> = T | T extends string ? StringTypeFilter : T e
|
|
2739
3037
|
],
|
2740
3038
|
}
|
2741
3039
|
*/
|
2742
|
-
declare type AggregatorFilter<
|
2743
|
-
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<
|
3040
|
+
declare type AggregatorFilter<T> = {
|
3041
|
+
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<T>>;
|
2744
3042
|
};
|
2745
3043
|
/**
|
2746
3044
|
* Existance filter
|
@@ -2755,10 +3053,10 @@ declare type BaseApiFilter<Record> = PropertyAccessFilter<Record> | AggregatorFi
|
|
2755
3053
|
* Injects the Api filters on nested properties
|
2756
3054
|
* Example: { filter: { settings: { plan: { $any: ['free', 'trial'] } } } }
|
2757
3055
|
*/
|
2758
|
-
declare type NestedApiFilter<T> =
|
3056
|
+
declare type NestedApiFilter<T> = {
|
2759
3057
|
[key in keyof T]?: T[key] extends Record<string, any> ? SingleOrArray<Filter<T[key]>> : PropertyFilter<T[key]>;
|
2760
|
-
}
|
2761
|
-
declare type Filter<
|
3058
|
+
};
|
3059
|
+
declare type Filter<T> = T extends Record<string, any> ? BaseApiFilter<T> | NestedApiFilter<T> : PropertyFilter<T>;
|
2762
3060
|
|
2763
3061
|
declare type SortDirection = 'asc' | 'desc';
|
2764
3062
|
declare type SortFilterExtended<T extends XataRecord> = {
|
@@ -2770,12 +3068,21 @@ declare type SortFilterBase<T extends XataRecord> = {
|
|
2770
3068
|
[Key in StringKeys<T>]: SortDirection;
|
2771
3069
|
};
|
2772
3070
|
|
2773
|
-
declare type
|
2774
|
-
page?: PaginationOptions;
|
3071
|
+
declare type BaseOptions<T extends XataRecord> = {
|
2775
3072
|
columns?: NonEmptyArray<SelectableColumn<T>>;
|
3073
|
+
cache?: number;
|
3074
|
+
};
|
3075
|
+
declare type CursorQueryOptions = {
|
3076
|
+
pagination?: CursorNavigationOptions & OffsetNavigationOptions;
|
3077
|
+
filter?: never;
|
3078
|
+
sort?: never;
|
3079
|
+
};
|
3080
|
+
declare type OffsetQueryOptions<T extends XataRecord> = {
|
3081
|
+
pagination?: OffsetNavigationOptions;
|
2776
3082
|
filter?: FilterExpression;
|
2777
3083
|
sort?: SortFilter<T> | SortFilter<T>[];
|
2778
3084
|
};
|
3085
|
+
declare type QueryOptions<T extends XataRecord> = BaseOptions<T> & (CursorQueryOptions | OffsetQueryOptions<T>);
|
2779
3086
|
/**
|
2780
3087
|
* Query objects contain the information of all filters, sorting, etc. to be included in the database query.
|
2781
3088
|
*
|
@@ -2785,9 +3092,10 @@ declare type QueryOptions<T extends XataRecord> = {
|
|
2785
3092
|
declare class Query<Record extends XataRecord, Result extends XataRecord = Record> implements Paginable<Record, Result> {
|
2786
3093
|
#private;
|
2787
3094
|
readonly meta: PaginationQueryMeta;
|
2788
|
-
readonly records: Result
|
2789
|
-
constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>,
|
3095
|
+
readonly records: RecordArray<Result>;
|
3096
|
+
constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, rawParent?: Partial<QueryOptions<Record>>);
|
2790
3097
|
getQueryOptions(): QueryOptions<Record>;
|
3098
|
+
key(): string;
|
2791
3099
|
/**
|
2792
3100
|
* Builds a new query object representing a logical OR between the given subqueries.
|
2793
3101
|
* @param queries An array of subqueries.
|
@@ -2817,18 +3125,28 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
2817
3125
|
*
|
2818
3126
|
* ```
|
2819
3127
|
* query.filter("columnName", columnValue)
|
2820
|
-
* query.filter(
|
2821
|
-
*
|
2822
|
-
*
|
3128
|
+
* query.filter("columnName", operator(columnValue)) // Use gt, gte, lt, lte, startsWith,...
|
3129
|
+
* ```
|
3130
|
+
*
|
3131
|
+
* @param column The name of the column to filter.
|
3132
|
+
* @param value The value to filter.
|
3133
|
+
* @returns A new Query object.
|
3134
|
+
*/
|
3135
|
+
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
|
3136
|
+
/**
|
3137
|
+
* Builds a new query object adding one or more constraints. Examples:
|
3138
|
+
*
|
3139
|
+
* ```
|
3140
|
+
* query.filter({ "columnName": columnValue })
|
2823
3141
|
* query.filter({
|
2824
3142
|
* "columnName": operator(columnValue) // Use gt, gte, lt, lte, startsWith,...
|
2825
3143
|
* })
|
2826
3144
|
* ```
|
2827
3145
|
*
|
3146
|
+
* @param filters A filter object
|
2828
3147
|
* @returns A new Query object.
|
2829
3148
|
*/
|
2830
3149
|
filter(filters: Filter<Record>): Query<Record, Result>;
|
2831
|
-
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
|
2832
3150
|
/**
|
2833
3151
|
* Builds a new query with a new sort option.
|
2834
3152
|
* @param column The column name.
|
@@ -2842,42 +3160,148 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
2842
3160
|
* @returns A new Query object.
|
2843
3161
|
*/
|
2844
3162
|
select<K extends SelectableColumn<Record>>(columns: NonEmptyArray<K>): Query<Record, SelectedPick<Record, NonEmptyArray<K>>>;
|
3163
|
+
/**
|
3164
|
+
* Get paginated results
|
3165
|
+
*
|
3166
|
+
* @returns A page of results
|
3167
|
+
*/
|
2845
3168
|
getPaginated(): Promise<Page<Record, Result>>;
|
2846
|
-
|
3169
|
+
/**
|
3170
|
+
* Get paginated results
|
3171
|
+
*
|
3172
|
+
* @param options Pagination options
|
3173
|
+
* @returns A page of results
|
3174
|
+
*/
|
3175
|
+
getPaginated(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
|
3176
|
+
/**
|
3177
|
+
* Get paginated results
|
3178
|
+
*
|
3179
|
+
* @param options Pagination options
|
3180
|
+
* @returns A page of results
|
3181
|
+
*/
|
2847
3182
|
getPaginated<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<Page<Record, SelectedPick<Record, typeof options['columns']>>>;
|
3183
|
+
/**
|
3184
|
+
* Get results in an iterator
|
3185
|
+
*
|
3186
|
+
* @async
|
3187
|
+
* @returns Async interable of results
|
3188
|
+
*/
|
2848
3189
|
[Symbol.asyncIterator](): AsyncIterableIterator<Result>;
|
2849
|
-
|
2850
|
-
|
2851
|
-
|
3190
|
+
/**
|
3191
|
+
* Build an iterator of results
|
3192
|
+
*
|
3193
|
+
* @returns Async generator of results array
|
3194
|
+
*/
|
3195
|
+
getIterator(): AsyncGenerator<Result[]>;
|
3196
|
+
/**
|
3197
|
+
* Build an iterator of results
|
3198
|
+
*
|
3199
|
+
* @param options Pagination options with batchSize
|
3200
|
+
* @returns Async generator of results array
|
3201
|
+
*/
|
3202
|
+
getIterator(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
|
3203
|
+
batchSize?: number;
|
3204
|
+
}): AsyncGenerator<Result[]>;
|
3205
|
+
/**
|
3206
|
+
* Build an iterator of results
|
3207
|
+
*
|
3208
|
+
* @param options Pagination options with batchSize
|
3209
|
+
* @returns Async generator of results array
|
3210
|
+
*/
|
3211
|
+
getIterator<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
|
3212
|
+
batchSize?: number;
|
3213
|
+
}>(options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
|
3214
|
+
/**
|
3215
|
+
* Performs the query in the database and returns a set of results.
|
3216
|
+
* @returns An array of records from the database.
|
3217
|
+
*/
|
3218
|
+
getMany(): Promise<RecordArray<Result>>;
|
2852
3219
|
/**
|
2853
3220
|
* Performs the query in the database and returns a set of results.
|
2854
3221
|
* @param options Additional options to be used when performing the query.
|
2855
3222
|
* @returns An array of records from the database.
|
2856
3223
|
*/
|
2857
|
-
getMany(): Promise<
|
2858
|
-
|
2859
|
-
|
3224
|
+
getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<RecordArray<SelectedPick<Record, typeof options['columns']>>>;
|
3225
|
+
/**
|
3226
|
+
* Performs the query in the database and returns a set of results.
|
3227
|
+
* @param options Additional options to be used when performing the query.
|
3228
|
+
* @returns An array of records from the database.
|
3229
|
+
*/
|
3230
|
+
getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<RecordArray<Result>>;
|
3231
|
+
/**
|
3232
|
+
* Performs the query in the database and returns all the results.
|
3233
|
+
* Warning: If there are a large number of results, this method can have performance implications.
|
3234
|
+
* @returns An array of records from the database.
|
3235
|
+
*/
|
3236
|
+
getAll(): Promise<Result[]>;
|
3237
|
+
/**
|
3238
|
+
* Performs the query in the database and returns all the results.
|
3239
|
+
* Warning: If there are a large number of results, this method can have performance implications.
|
3240
|
+
* @param options Additional options to be used when performing the query.
|
3241
|
+
* @returns An array of records from the database.
|
3242
|
+
*/
|
3243
|
+
getAll<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
|
3244
|
+
batchSize?: number;
|
3245
|
+
}>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
|
2860
3246
|
/**
|
2861
3247
|
* Performs the query in the database and returns all the results.
|
2862
3248
|
* Warning: If there are a large number of results, this method can have performance implications.
|
2863
3249
|
* @param options Additional options to be used when performing the query.
|
2864
3250
|
* @returns An array of records from the database.
|
2865
3251
|
*/
|
2866
|
-
getAll(
|
2867
|
-
|
2868
|
-
|
3252
|
+
getAll(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
|
3253
|
+
batchSize?: number;
|
3254
|
+
}): Promise<Result[]>;
|
3255
|
+
/**
|
3256
|
+
* Performs the query in the database and returns the first result.
|
3257
|
+
* @returns The first record that matches the query, or null if no record matched the query.
|
3258
|
+
*/
|
3259
|
+
getFirst(): Promise<Result | null>;
|
3260
|
+
/**
|
3261
|
+
* Performs the query in the database and returns the first result.
|
3262
|
+
* @param options Additional options to be used when performing the query.
|
3263
|
+
* @returns The first record that matches the query, or null if no record matched the query.
|
3264
|
+
*/
|
3265
|
+
getFirst<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
|
2869
3266
|
/**
|
2870
3267
|
* Performs the query in the database and returns the first result.
|
2871
3268
|
* @param options Additional options to be used when performing the query.
|
2872
3269
|
* @returns The first record that matches the query, or null if no record matched the query.
|
2873
3270
|
*/
|
2874
|
-
|
2875
|
-
|
2876
|
-
|
3271
|
+
getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
|
3272
|
+
/**
|
3273
|
+
* Builds a new query object adding a cache TTL in milliseconds.
|
3274
|
+
* @param ttl The cache TTL in milliseconds.
|
3275
|
+
* @returns A new Query object.
|
3276
|
+
*/
|
3277
|
+
cache(ttl: number): Query<Record, Result>;
|
3278
|
+
/**
|
3279
|
+
* Retrieve next page of records
|
3280
|
+
*
|
3281
|
+
* @returns A new page object.
|
3282
|
+
*/
|
2877
3283
|
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3284
|
+
/**
|
3285
|
+
* Retrieve previous page of records
|
3286
|
+
*
|
3287
|
+
* @returns A new page object
|
3288
|
+
*/
|
2878
3289
|
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3290
|
+
/**
|
3291
|
+
* Retrieve first page of records
|
3292
|
+
*
|
3293
|
+
* @returns A new page object
|
3294
|
+
*/
|
2879
3295
|
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3296
|
+
/**
|
3297
|
+
* Retrieve last page of records
|
3298
|
+
*
|
3299
|
+
* @returns A new page object
|
3300
|
+
*/
|
2880
3301
|
lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3302
|
+
/**
|
3303
|
+
* @returns Boolean indicating if there is a next page
|
3304
|
+
*/
|
2881
3305
|
hasNextPage(): boolean;
|
2882
3306
|
}
|
2883
3307
|
|
@@ -2889,7 +3313,7 @@ declare type PaginationQueryMeta = {
|
|
2889
3313
|
};
|
2890
3314
|
interface Paginable<Record extends XataRecord, Result extends XataRecord = Record> {
|
2891
3315
|
meta: PaginationQueryMeta;
|
2892
|
-
records: Result
|
3316
|
+
records: RecordArray<Result>;
|
2893
3317
|
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2894
3318
|
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2895
3319
|
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
@@ -2909,7 +3333,7 @@ declare class Page<Record extends XataRecord, Result extends XataRecord = Record
|
|
2909
3333
|
/**
|
2910
3334
|
* The set of results for this page.
|
2911
3335
|
*/
|
2912
|
-
readonly records: Result
|
3336
|
+
readonly records: RecordArray<Result>;
|
2913
3337
|
constructor(query: Query<Record, Result>, meta: PaginationQueryMeta, records?: Result[]);
|
2914
3338
|
/**
|
2915
3339
|
* Retrieves the next page of results.
|
@@ -2957,14 +3381,45 @@ declare type OffsetNavigationOptions = {
|
|
2957
3381
|
size?: number;
|
2958
3382
|
offset?: number;
|
2959
3383
|
};
|
2960
|
-
declare type PaginationOptions = CursorNavigationOptions & OffsetNavigationOptions;
|
2961
3384
|
declare const PAGINATION_MAX_SIZE = 200;
|
2962
|
-
declare const PAGINATION_DEFAULT_SIZE =
|
3385
|
+
declare const PAGINATION_DEFAULT_SIZE = 20;
|
2963
3386
|
declare const PAGINATION_MAX_OFFSET = 800;
|
2964
3387
|
declare const PAGINATION_DEFAULT_OFFSET = 0;
|
3388
|
+
declare function isCursorPaginationOptions(options: Record<string, unknown> | undefined | null): options is CursorNavigationOptions;
|
3389
|
+
declare class RecordArray<Result extends XataRecord> extends Array<Result> {
|
3390
|
+
#private;
|
3391
|
+
constructor(page: Paginable<any, Result>, overrideRecords?: Result[]);
|
3392
|
+
static parseConstructorParams(...args: any[]): any[];
|
3393
|
+
/**
|
3394
|
+
* Retrieve next page of records
|
3395
|
+
*
|
3396
|
+
* @returns A new array of objects
|
3397
|
+
*/
|
3398
|
+
nextPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3399
|
+
/**
|
3400
|
+
* Retrieve previous page of records
|
3401
|
+
*
|
3402
|
+
* @returns A new array of objects
|
3403
|
+
*/
|
3404
|
+
previousPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3405
|
+
/**
|
3406
|
+
* Retrieve first page of records
|
3407
|
+
*
|
3408
|
+
* @returns A new array of objects
|
3409
|
+
*/
|
3410
|
+
firstPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3411
|
+
/**
|
3412
|
+
* Retrieve last page of records
|
3413
|
+
*
|
3414
|
+
* @returns A new array of objects
|
3415
|
+
*/
|
3416
|
+
lastPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3417
|
+
/**
|
3418
|
+
* @returns Boolean indicating if there is a next page
|
3419
|
+
*/
|
3420
|
+
hasNextPage(): boolean;
|
3421
|
+
}
|
2965
3422
|
|
2966
|
-
declare type TableLink = string[];
|
2967
|
-
declare type LinkDictionary = Dictionary<TableLink[]>;
|
2968
3423
|
/**
|
2969
3424
|
* Common interface for performing operations on a table.
|
2970
3425
|
*/
|
@@ -2989,6 +3444,24 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
2989
3444
|
* @returns The persisted record for the given id or null if the record could not be found.
|
2990
3445
|
*/
|
2991
3446
|
abstract read(id: string): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
|
3447
|
+
/**
|
3448
|
+
* Queries multiple records from the table given their unique id.
|
3449
|
+
* @param ids The unique ids array.
|
3450
|
+
* @returns The persisted records for the given ids (if a record could not be found it is not returned).
|
3451
|
+
*/
|
3452
|
+
abstract read(ids: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3453
|
+
/**
|
3454
|
+
* Queries a single record from the table by the id in the object.
|
3455
|
+
* @param object Object containing the id of the record.
|
3456
|
+
* @returns The persisted record for the given id or null if the record could not be found.
|
3457
|
+
*/
|
3458
|
+
abstract read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
|
3459
|
+
/**
|
3460
|
+
* Queries multiple records from the table by the ids in the objects.
|
3461
|
+
* @param objects Array of objects containing the ids of the records.
|
3462
|
+
* @returns The persisted records for the given ids (if a record could not be found it is not returned).
|
3463
|
+
*/
|
3464
|
+
abstract read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
2992
3465
|
/**
|
2993
3466
|
* Partially update a single record.
|
2994
3467
|
* @param object An object with its id and the columns to be updated.
|
@@ -3061,7 +3534,9 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
3061
3534
|
* @returns The found records.
|
3062
3535
|
*/
|
3063
3536
|
abstract search(query: string, options?: {
|
3064
|
-
fuzziness?:
|
3537
|
+
fuzziness?: FuzzinessExpression;
|
3538
|
+
highlight?: HighlightExpression;
|
3539
|
+
filter?: Filter<Record>;
|
3065
3540
|
}): Promise<SelectedPick<Record, ['*']>[]>;
|
3066
3541
|
abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
3067
3542
|
}
|
@@ -3070,27 +3545,85 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
|
|
3070
3545
|
db: SchemaPluginResult<any>;
|
3071
3546
|
constructor(options: {
|
3072
3547
|
table: string;
|
3073
|
-
links?: LinkDictionary;
|
3074
|
-
getFetchProps: () => Promise<FetcherExtraProps>;
|
3075
3548
|
db: SchemaPluginResult<any>;
|
3549
|
+
pluginOptions: XataPluginOptions;
|
3550
|
+
schemaTables?: Table[];
|
3076
3551
|
});
|
3077
|
-
create(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']
|
3078
|
-
create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']
|
3079
|
-
create(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']
|
3552
|
+
create(object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3553
|
+
create(recordId: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3554
|
+
create(objects: EditableData<Data>[]): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
|
3080
3555
|
read(recordId: string): Promise<SelectedPick<Record, ['*']> | null>;
|
3556
|
+
read(recordIds: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3557
|
+
read(object: Identifiable): Promise<SelectedPick<Record, ['*']> | null>;
|
3558
|
+
read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3081
3559
|
update(object: Partial<EditableData<Data>> & Identifiable): Promise<SelectedPick<Record, ['*']>>;
|
3082
3560
|
update(recordId: string, object: Partial<EditableData<Data>>): Promise<SelectedPick<Record, ['*']>>;
|
3083
3561
|
update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<SelectedPick<Record, ['*']>[]>;
|
3084
3562
|
createOrUpdate(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
|
3085
3563
|
createOrUpdate(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
|
3086
3564
|
createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
|
3087
|
-
delete(
|
3565
|
+
delete(a: string | Identifiable | Array<string | Identifiable>): Promise<void>;
|
3088
3566
|
search(query: string, options?: {
|
3089
|
-
fuzziness?:
|
3567
|
+
fuzziness?: FuzzinessExpression;
|
3568
|
+
highlight?: HighlightExpression;
|
3569
|
+
filter?: Filter<Record>;
|
3090
3570
|
}): Promise<SelectedPick<Record, ['*']>[]>;
|
3091
3571
|
query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
3092
3572
|
}
|
3093
3573
|
|
3574
|
+
declare type BaseSchema = {
|
3575
|
+
name: string;
|
3576
|
+
columns: readonly ({
|
3577
|
+
name: string;
|
3578
|
+
type: Column['type'];
|
3579
|
+
} | {
|
3580
|
+
name: string;
|
3581
|
+
type: 'link';
|
3582
|
+
link: {
|
3583
|
+
table: string;
|
3584
|
+
};
|
3585
|
+
} | {
|
3586
|
+
name: string;
|
3587
|
+
type: 'object';
|
3588
|
+
columns: {
|
3589
|
+
name: string;
|
3590
|
+
type: string;
|
3591
|
+
}[];
|
3592
|
+
})[];
|
3593
|
+
};
|
3594
|
+
declare type SchemaInference<T extends readonly BaseSchema[]> = T extends never[] ? Record<string, Record<string, any>> : T extends readonly unknown[] ? T[number] extends {
|
3595
|
+
name: string;
|
3596
|
+
columns: readonly unknown[];
|
3597
|
+
} ? {
|
3598
|
+
[K in T[number]['name']]: TableType<T[number], K>;
|
3599
|
+
} : never : never;
|
3600
|
+
declare type TableType<Tables, TableName> = Tables & {
|
3601
|
+
name: TableName;
|
3602
|
+
} extends infer Table ? Table extends {
|
3603
|
+
name: string;
|
3604
|
+
columns: infer Columns;
|
3605
|
+
} ? Columns extends readonly unknown[] ? Columns[number] extends {
|
3606
|
+
name: string;
|
3607
|
+
type: string;
|
3608
|
+
} ? Identifiable & {
|
3609
|
+
[K in Columns[number]['name']]?: PropertyType<Tables, Columns[number], K>;
|
3610
|
+
} : never : never : never : never;
|
3611
|
+
declare type PropertyType<Tables, Properties, PropertyName> = Properties & {
|
3612
|
+
name: PropertyName;
|
3613
|
+
} extends infer Property ? Property extends {
|
3614
|
+
name: string;
|
3615
|
+
type: infer Type;
|
3616
|
+
link?: {
|
3617
|
+
table: infer LinkedTable;
|
3618
|
+
};
|
3619
|
+
columns?: infer ObjectColumns;
|
3620
|
+
} ? (Type extends 'string' | 'text' | 'email' ? string : Type extends 'int' | 'float' ? number : Type extends 'bool' ? boolean : Type extends 'datetime' ? Date : Type extends 'multiple' ? string[] : Type extends 'object' ? ObjectColumns extends readonly unknown[] ? ObjectColumns[number] extends {
|
3621
|
+
name: string;
|
3622
|
+
type: string;
|
3623
|
+
} ? {
|
3624
|
+
[K in ObjectColumns[number]['name']]?: PropertyType<Tables, ObjectColumns[number], K>;
|
3625
|
+
} : never : never : Type extends 'link' ? TableType<Tables, LinkedTable> & XataRecord : never) | null : never : never;
|
3626
|
+
|
3094
3627
|
/**
|
3095
3628
|
* Operator to restrict results to only values that are greater than the given value.
|
3096
3629
|
*/
|
@@ -3166,46 +3699,58 @@ declare const includesAny: <T>(value: T) => ArrayFilter<T>;
|
|
3166
3699
|
|
3167
3700
|
declare type SchemaDefinition = {
|
3168
3701
|
table: string;
|
3169
|
-
links?: LinkDictionary;
|
3170
3702
|
};
|
3171
3703
|
declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
|
3172
3704
|
[Key in keyof Schemas]: Repository<Schemas[Key]>;
|
3705
|
+
} & {
|
3706
|
+
[key: string]: Repository<XataRecord$1>;
|
3173
3707
|
};
|
3174
3708
|
declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
3175
3709
|
#private;
|
3176
|
-
|
3177
|
-
|
3178
|
-
constructor(links?: LinkDictionary | undefined, tableNames?: string[] | undefined);
|
3179
|
-
build(options: XataPluginOptions): SchemaPluginResult<Schemas>;
|
3710
|
+
constructor(schemaTables?: Schemas.Table[]);
|
3711
|
+
build(pluginOptions: XataPluginOptions): SchemaPluginResult<Schemas>;
|
3180
3712
|
}
|
3181
3713
|
|
3182
3714
|
declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
|
3183
|
-
fuzziness?:
|
3184
|
-
|
3715
|
+
fuzziness?: FuzzinessExpression;
|
3716
|
+
highlight?: HighlightExpression;
|
3717
|
+
tables?: Array<Tables | Values<{
|
3718
|
+
[Model in GetArrayInnerType<NonNullable<Tables[]>>]: {
|
3719
|
+
table: Model;
|
3720
|
+
filter?: Filter<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
|
3721
|
+
};
|
3722
|
+
}>>;
|
3185
3723
|
};
|
3186
3724
|
declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
|
3187
3725
|
all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
|
3188
|
-
[Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']
|
3726
|
+
[Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]: {
|
3189
3727
|
table: Model;
|
3190
3728
|
record: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
|
3191
3729
|
};
|
3192
3730
|
}>[]>;
|
3193
3731
|
byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
|
3194
|
-
[Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']
|
3732
|
+
[Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
|
3195
3733
|
}>;
|
3196
3734
|
};
|
3197
3735
|
declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
3198
3736
|
#private;
|
3199
3737
|
private db;
|
3200
|
-
|
3201
|
-
constructor(db: SchemaPluginResult<Schemas>, links: LinkDictionary);
|
3738
|
+
constructor(db: SchemaPluginResult<Schemas>, schemaTables?: Schemas.Table[]);
|
3202
3739
|
build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
|
3203
3740
|
}
|
3204
|
-
declare type SearchXataRecord = XataRecord
|
3205
|
-
|
3206
|
-
|
3741
|
+
declare type SearchXataRecord = XataRecord<SearchExtraProperties>;
|
3742
|
+
declare type SearchExtraProperties = {
|
3743
|
+
table: string;
|
3744
|
+
highlight?: {
|
3745
|
+
[key: string]: string[] | {
|
3746
|
+
[key: string]: any;
|
3747
|
+
};
|
3207
3748
|
};
|
3208
3749
|
};
|
3750
|
+
declare type ReturnTable<Table, Tables> = Table extends Tables ? Table : never;
|
3751
|
+
declare type ExtractTables<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>, TableOptions extends GetArrayInnerType<NonNullable<NonNullable<SearchOptions<Schemas, Tables>>['tables']>>> = TableOptions extends `${infer Table}` ? ReturnTable<Table, Tables> : TableOptions extends {
|
3752
|
+
table: infer Table;
|
3753
|
+
} ? ReturnTable<Table, Tables> : never;
|
3209
3754
|
|
3210
3755
|
declare type BranchStrategyValue = string | undefined | null;
|
3211
3756
|
declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
|
@@ -3217,18 +3762,19 @@ declare type BaseClientOptions = {
|
|
3217
3762
|
apiKey?: string;
|
3218
3763
|
databaseURL?: string;
|
3219
3764
|
branch?: BranchStrategyOption;
|
3765
|
+
cache?: CacheImpl;
|
3220
3766
|
};
|
3221
3767
|
declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
|
3222
3768
|
interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
|
3223
|
-
new <
|
3224
|
-
db: Awaited<ReturnType<SchemaPlugin<
|
3225
|
-
search: Awaited<ReturnType<SearchPlugin<
|
3769
|
+
new <T extends readonly BaseSchema[]>(options?: Partial<BaseClientOptions>, schemaTables?: T): Omit<{
|
3770
|
+
db: Awaited<ReturnType<SchemaPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
|
3771
|
+
search: Awaited<ReturnType<SearchPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
|
3226
3772
|
}, keyof Plugins> & {
|
3227
3773
|
[Key in StringKeys<NonNullable<Plugins>>]: Awaited<ReturnType<NonNullable<Plugins>[Key]['build']>>;
|
3228
3774
|
};
|
3229
3775
|
}
|
3230
3776
|
declare const BaseClient_base: ClientConstructor<{}>;
|
3231
|
-
declare class BaseClient extends BaseClient_base<
|
3777
|
+
declare class BaseClient extends BaseClient_base<[]> {
|
3232
3778
|
}
|
3233
3779
|
|
3234
3780
|
declare type BranchResolutionOptions = {
|
@@ -3236,7 +3782,7 @@ declare type BranchResolutionOptions = {
|
|
3236
3782
|
apiKey?: string;
|
3237
3783
|
fetchImpl?: FetchImpl;
|
3238
3784
|
};
|
3239
|
-
declare function getCurrentBranchName(options?: BranchResolutionOptions): Promise<string
|
3785
|
+
declare function getCurrentBranchName(options?: BranchResolutionOptions): Promise<string>;
|
3240
3786
|
declare function getCurrentBranchDetails(options?: BranchResolutionOptions): Promise<DBBranch | null>;
|
3241
3787
|
declare function getDatabaseURL(): string | undefined;
|
3242
3788
|
|
@@ -3247,4 +3793,4 @@ declare class XataError extends Error {
|
|
3247
3793
|
constructor(message: string, status: number);
|
3248
3794
|
}
|
3249
3795
|
|
3250
|
-
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,
|
3796
|
+
export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddGitBranchesEntryError, AddGitBranchesEntryPathParams, AddGitBranchesEntryRequestBody, AddGitBranchesEntryResponse, AddGitBranchesEntryVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BaseSchema, 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, Link, OffsetNavigationOptions, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Paginable, PaginationQueryMeta, Query, QueryTableError, QueryTablePathParams, QueryTableRequestBody, QueryTableVariables, RecordArray, RemoveGitBranchesEntryError, RemoveGitBranchesEntryPathParams, RemoveGitBranchesEntryQueryParams, RemoveGitBranchesEntryVariables, RemoveWorkspaceMemberError, RemoveWorkspaceMemberPathParams, RemoveWorkspaceMemberVariables, Repository, ResendWorkspaceMemberInviteError, ResendWorkspaceMemberInvitePathParams, ResendWorkspaceMemberInviteVariables, ResolveBranchError, ResolveBranchPathParams, ResolveBranchQueryParams, ResolveBranchResponse, ResolveBranchVariables, responses as Responses, RestRepository, SchemaDefinition, SchemaInference, SchemaPlugin, SchemaPluginResult, schemas as Schemas, SearchBranchError, SearchBranchPathParams, SearchBranchRequestBody, SearchBranchVariables, SearchOptions, SearchPlugin, SearchPluginResult, SearchTableError, SearchTablePathParams, SearchTableRequestBody, SearchTableVariables, 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, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
|