@xata.io/client 0.0.0-alpha.ved00a04 → 0.0.0-alpha.vedd7251
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 +76 -0
- package/README.md +258 -1
- package/dist/index.cjs +378 -219
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +532 -193
- package/dist/index.mjs +373 -217
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -2
- package/tsconfig.json +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -138,6 +138,12 @@ declare type ListBranchesResponse = {
|
|
|
138
138
|
displayName: string;
|
|
139
139
|
branches: Branch[];
|
|
140
140
|
};
|
|
141
|
+
declare type ListGitBranchesResponse = {
|
|
142
|
+
mapping: {
|
|
143
|
+
gitBranch: string;
|
|
144
|
+
xataBranch: string;
|
|
145
|
+
}[];
|
|
146
|
+
};
|
|
141
147
|
declare type Branch = {
|
|
142
148
|
name: string;
|
|
143
149
|
createdAt: DateTime;
|
|
@@ -186,7 +192,7 @@ declare type Table = {
|
|
|
186
192
|
*/
|
|
187
193
|
declare type Column = {
|
|
188
194
|
name: string;
|
|
189
|
-
type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object';
|
|
195
|
+
type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object' | 'datetime';
|
|
190
196
|
link?: {
|
|
191
197
|
table: string;
|
|
192
198
|
};
|
|
@@ -262,6 +268,17 @@ declare type SortExpression = string[] | {
|
|
|
262
268
|
[key: string]: SortOrder;
|
|
263
269
|
}[];
|
|
264
270
|
declare type SortOrder = 'asc' | 'desc';
|
|
271
|
+
/**
|
|
272
|
+
* Maximum [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) for the search terms. The Levenshtein
|
|
273
|
+
* distance is the number of one charcter changes needed to make two strings equal. The default is 1, meaning that single
|
|
274
|
+
* character typos per word are tollerated by search. You can set it to 0 to remove the typo tollerance or set it to 2
|
|
275
|
+
* to allow two typos in a word.
|
|
276
|
+
*
|
|
277
|
+
* @default 1
|
|
278
|
+
* @maximum 2
|
|
279
|
+
* @minimum 0
|
|
280
|
+
*/
|
|
281
|
+
declare type FuzzinessExpression = number;
|
|
265
282
|
/**
|
|
266
283
|
* @minProperties 1
|
|
267
284
|
*/
|
|
@@ -275,6 +292,10 @@ declare type FilterExpression = {
|
|
|
275
292
|
} & {
|
|
276
293
|
[key: string]: FilterColumn;
|
|
277
294
|
};
|
|
295
|
+
declare type HighlightExpression = {
|
|
296
|
+
enabled?: boolean;
|
|
297
|
+
encodeHTML?: boolean;
|
|
298
|
+
};
|
|
278
299
|
declare type FilterList = FilterExpression | FilterExpression[];
|
|
279
300
|
declare type FilterColumn = FilterColumnIncludes | FilterPredicate | FilterList;
|
|
280
301
|
/**
|
|
@@ -360,6 +381,11 @@ declare type XataRecord$1 = {
|
|
|
360
381
|
xata: {
|
|
361
382
|
version: number;
|
|
362
383
|
table?: string;
|
|
384
|
+
highlight?: {
|
|
385
|
+
[key: string]: string[] | {
|
|
386
|
+
[key: string]: any;
|
|
387
|
+
};
|
|
388
|
+
};
|
|
363
389
|
warnings?: string[];
|
|
364
390
|
};
|
|
365
391
|
} & {
|
|
@@ -382,6 +408,7 @@ type schemas_WorkspaceMembers = WorkspaceMembers;
|
|
|
382
408
|
type schemas_InviteKey = InviteKey;
|
|
383
409
|
type schemas_ListDatabasesResponse = ListDatabasesResponse;
|
|
384
410
|
type schemas_ListBranchesResponse = ListBranchesResponse;
|
|
411
|
+
type schemas_ListGitBranchesResponse = ListGitBranchesResponse;
|
|
385
412
|
type schemas_Branch = Branch;
|
|
386
413
|
type schemas_BranchMetadata = BranchMetadata;
|
|
387
414
|
type schemas_DBBranch = DBBranch;
|
|
@@ -402,7 +429,9 @@ type schemas_TableMigration = TableMigration;
|
|
|
402
429
|
type schemas_ColumnMigration = ColumnMigration;
|
|
403
430
|
type schemas_SortExpression = SortExpression;
|
|
404
431
|
type schemas_SortOrder = SortOrder;
|
|
432
|
+
type schemas_FuzzinessExpression = FuzzinessExpression;
|
|
405
433
|
type schemas_FilterExpression = FilterExpression;
|
|
434
|
+
type schemas_HighlightExpression = HighlightExpression;
|
|
406
435
|
type schemas_FilterList = FilterList;
|
|
407
436
|
type schemas_FilterColumn = FilterColumn;
|
|
408
437
|
type schemas_FilterColumnIncludes = FilterColumnIncludes;
|
|
@@ -434,6 +463,7 @@ declare namespace schemas {
|
|
|
434
463
|
schemas_InviteKey as InviteKey,
|
|
435
464
|
schemas_ListDatabasesResponse as ListDatabasesResponse,
|
|
436
465
|
schemas_ListBranchesResponse as ListBranchesResponse,
|
|
466
|
+
schemas_ListGitBranchesResponse as ListGitBranchesResponse,
|
|
437
467
|
schemas_Branch as Branch,
|
|
438
468
|
schemas_BranchMetadata as BranchMetadata,
|
|
439
469
|
schemas_DBBranch as DBBranch,
|
|
@@ -454,7 +484,9 @@ declare namespace schemas {
|
|
|
454
484
|
schemas_ColumnMigration as ColumnMigration,
|
|
455
485
|
schemas_SortExpression as SortExpression,
|
|
456
486
|
schemas_SortOrder as SortOrder,
|
|
487
|
+
schemas_FuzzinessExpression as FuzzinessExpression,
|
|
457
488
|
schemas_FilterExpression as FilterExpression,
|
|
489
|
+
schemas_HighlightExpression as HighlightExpression,
|
|
458
490
|
schemas_FilterList as FilterList,
|
|
459
491
|
schemas_FilterColumn as FilterColumn,
|
|
460
492
|
schemas_FilterColumnIncludes as FilterColumnIncludes,
|
|
@@ -1010,6 +1042,163 @@ declare type DeleteDatabaseVariables = {
|
|
|
1010
1042
|
* Delete a database and all of its branches and tables permanently.
|
|
1011
1043
|
*/
|
|
1012
1044
|
declare const deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
|
|
1045
|
+
declare type GetGitBranchesMappingPathParams = {
|
|
1046
|
+
dbName: DBName;
|
|
1047
|
+
workspace: string;
|
|
1048
|
+
};
|
|
1049
|
+
declare type GetGitBranchesMappingError = ErrorWrapper<{
|
|
1050
|
+
status: 400;
|
|
1051
|
+
payload: BadRequestError;
|
|
1052
|
+
} | {
|
|
1053
|
+
status: 401;
|
|
1054
|
+
payload: AuthError;
|
|
1055
|
+
}>;
|
|
1056
|
+
declare type GetGitBranchesMappingVariables = {
|
|
1057
|
+
pathParams: GetGitBranchesMappingPathParams;
|
|
1058
|
+
} & FetcherExtraProps;
|
|
1059
|
+
/**
|
|
1060
|
+
* Lists all the git branches in the mapping, and their associated Xata branches.
|
|
1061
|
+
*
|
|
1062
|
+
* Example response:
|
|
1063
|
+
*
|
|
1064
|
+
* ```json
|
|
1065
|
+
* {
|
|
1066
|
+
* "mappings": [
|
|
1067
|
+
* {
|
|
1068
|
+
* "gitBranch": "main",
|
|
1069
|
+
* "xataBranch": "main"
|
|
1070
|
+
* },
|
|
1071
|
+
* {
|
|
1072
|
+
* "gitBranch": "gitBranch1",
|
|
1073
|
+
* "xataBranch": "xataBranch1"
|
|
1074
|
+
* }
|
|
1075
|
+
* {
|
|
1076
|
+
* "gitBranch": "xataBranch2",
|
|
1077
|
+
* "xataBranch": "xataBranch2"
|
|
1078
|
+
* }
|
|
1079
|
+
* ]
|
|
1080
|
+
* }
|
|
1081
|
+
* ```
|
|
1082
|
+
*/
|
|
1083
|
+
declare const getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
|
|
1084
|
+
declare type AddGitBranchesEntryPathParams = {
|
|
1085
|
+
dbName: DBName;
|
|
1086
|
+
workspace: string;
|
|
1087
|
+
};
|
|
1088
|
+
declare type AddGitBranchesEntryError = ErrorWrapper<{
|
|
1089
|
+
status: 400;
|
|
1090
|
+
payload: BadRequestError;
|
|
1091
|
+
} | {
|
|
1092
|
+
status: 401;
|
|
1093
|
+
payload: AuthError;
|
|
1094
|
+
}>;
|
|
1095
|
+
declare type AddGitBranchesEntryResponse = {
|
|
1096
|
+
warning?: string;
|
|
1097
|
+
};
|
|
1098
|
+
declare type AddGitBranchesEntryRequestBody = {
|
|
1099
|
+
gitBranch: string;
|
|
1100
|
+
xataBranch: BranchName;
|
|
1101
|
+
};
|
|
1102
|
+
declare type AddGitBranchesEntryVariables = {
|
|
1103
|
+
body: AddGitBranchesEntryRequestBody;
|
|
1104
|
+
pathParams: AddGitBranchesEntryPathParams;
|
|
1105
|
+
} & FetcherExtraProps;
|
|
1106
|
+
/**
|
|
1107
|
+
* 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.
|
|
1108
|
+
*
|
|
1109
|
+
* 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.
|
|
1110
|
+
*
|
|
1111
|
+
* Example request:
|
|
1112
|
+
*
|
|
1113
|
+
* ```json
|
|
1114
|
+
* // POST https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches
|
|
1115
|
+
* {
|
|
1116
|
+
* "gitBranch": "fix/bug123",
|
|
1117
|
+
* "xataBranch": "fix_bug"
|
|
1118
|
+
* }
|
|
1119
|
+
* ```
|
|
1120
|
+
*/
|
|
1121
|
+
declare const addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
|
|
1122
|
+
declare type RemoveGitBranchesEntryPathParams = {
|
|
1123
|
+
dbName: DBName;
|
|
1124
|
+
workspace: string;
|
|
1125
|
+
};
|
|
1126
|
+
declare type RemoveGitBranchesEntryQueryParams = {
|
|
1127
|
+
gitBranch: string;
|
|
1128
|
+
};
|
|
1129
|
+
declare type RemoveGitBranchesEntryError = ErrorWrapper<{
|
|
1130
|
+
status: 400;
|
|
1131
|
+
payload: BadRequestError;
|
|
1132
|
+
} | {
|
|
1133
|
+
status: 401;
|
|
1134
|
+
payload: AuthError;
|
|
1135
|
+
}>;
|
|
1136
|
+
declare type RemoveGitBranchesEntryVariables = {
|
|
1137
|
+
pathParams: RemoveGitBranchesEntryPathParams;
|
|
1138
|
+
queryParams: RemoveGitBranchesEntryQueryParams;
|
|
1139
|
+
} & FetcherExtraProps;
|
|
1140
|
+
/**
|
|
1141
|
+
* 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.
|
|
1142
|
+
*
|
|
1143
|
+
* Example request:
|
|
1144
|
+
*
|
|
1145
|
+
* ```json
|
|
1146
|
+
* // DELETE https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches?gitBranch=fix%2Fbug123
|
|
1147
|
+
* ```
|
|
1148
|
+
*/
|
|
1149
|
+
declare const removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
|
|
1150
|
+
declare type ResolveBranchPathParams = {
|
|
1151
|
+
dbName: DBName;
|
|
1152
|
+
workspace: string;
|
|
1153
|
+
};
|
|
1154
|
+
declare type ResolveBranchQueryParams = {
|
|
1155
|
+
gitBranch?: string;
|
|
1156
|
+
fallbackBranch?: string;
|
|
1157
|
+
};
|
|
1158
|
+
declare type ResolveBranchError = ErrorWrapper<{
|
|
1159
|
+
status: 400;
|
|
1160
|
+
payload: BadRequestError;
|
|
1161
|
+
} | {
|
|
1162
|
+
status: 401;
|
|
1163
|
+
payload: AuthError;
|
|
1164
|
+
}>;
|
|
1165
|
+
declare type ResolveBranchResponse = {
|
|
1166
|
+
branch: string;
|
|
1167
|
+
reason: {
|
|
1168
|
+
code: 'FOUND_IN_MAPPING' | 'BRANCH_EXISTS' | 'FALLBACK_BRANCH' | 'DEFAULT_BRANCH';
|
|
1169
|
+
message: string;
|
|
1170
|
+
};
|
|
1171
|
+
};
|
|
1172
|
+
declare type ResolveBranchVariables = {
|
|
1173
|
+
pathParams: ResolveBranchPathParams;
|
|
1174
|
+
queryParams?: ResolveBranchQueryParams;
|
|
1175
|
+
} & FetcherExtraProps;
|
|
1176
|
+
/**
|
|
1177
|
+
* In order to resolve the database branch, the following algorithm is used:
|
|
1178
|
+
* * 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
|
|
1179
|
+
* * else, if a Xata branch with the exact same name as `gitBranch` exists, return it
|
|
1180
|
+
* * else, if `fallbackBranch` is provided and a branch with that name exists, return it
|
|
1181
|
+
* * else, return the default branch of the DB (`main` or the first branch)
|
|
1182
|
+
*
|
|
1183
|
+
* Example call:
|
|
1184
|
+
*
|
|
1185
|
+
* ```json
|
|
1186
|
+
* // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test&fallbackBranch=tsg
|
|
1187
|
+
* ```
|
|
1188
|
+
*
|
|
1189
|
+
* Example response:
|
|
1190
|
+
*
|
|
1191
|
+
* ```json
|
|
1192
|
+
* {
|
|
1193
|
+
* "branch": "main",
|
|
1194
|
+
* "reason": {
|
|
1195
|
+
* "code": "DEFAULT_BRANCH",
|
|
1196
|
+
* "message": "Default branch for this database (main)"
|
|
1197
|
+
* }
|
|
1198
|
+
* }
|
|
1199
|
+
* ```
|
|
1200
|
+
*/
|
|
1201
|
+
declare const resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
|
|
1013
1202
|
declare type GetBranchDetailsPathParams = {
|
|
1014
1203
|
dbBranchName: DBBranchName;
|
|
1015
1204
|
workspace: string;
|
|
@@ -1191,64 +1380,6 @@ declare type GetBranchMigrationPlanVariables = {
|
|
|
1191
1380
|
* Compute a migration plan from a target schema the branch should be migrated too.
|
|
1192
1381
|
*/
|
|
1193
1382
|
declare const getBranchMigrationPlan: (variables: GetBranchMigrationPlanVariables) => Promise<BranchMigrationPlan>;
|
|
1194
|
-
declare type CompareBranchSchemaPathParams = {
|
|
1195
|
-
dbBranchName: DBBranchName;
|
|
1196
|
-
branchName: BranchName;
|
|
1197
|
-
workspace: string;
|
|
1198
|
-
};
|
|
1199
|
-
declare type CompareBranchSchemaError = ErrorWrapper<{
|
|
1200
|
-
status: 400;
|
|
1201
|
-
payload: BadRequestError;
|
|
1202
|
-
} | {
|
|
1203
|
-
status: 401;
|
|
1204
|
-
payload: AuthError;
|
|
1205
|
-
} | {
|
|
1206
|
-
status: 404;
|
|
1207
|
-
payload: SimpleError;
|
|
1208
|
-
}>;
|
|
1209
|
-
declare type CompareBranchSchemaVariables = {
|
|
1210
|
-
body?: Record<string, any>;
|
|
1211
|
-
pathParams: CompareBranchSchemaPathParams;
|
|
1212
|
-
} & FetcherExtraProps;
|
|
1213
|
-
declare const compareBranchSchema: (variables: CompareBranchSchemaVariables) => Promise<Record<string, any>>;
|
|
1214
|
-
declare type UpdateBranchSchemaPathParams = {
|
|
1215
|
-
dbBranchName: DBBranchName;
|
|
1216
|
-
workspace: string;
|
|
1217
|
-
};
|
|
1218
|
-
declare type UpdateBranchSchemaError = ErrorWrapper<{
|
|
1219
|
-
status: 400;
|
|
1220
|
-
payload: BadRequestError;
|
|
1221
|
-
} | {
|
|
1222
|
-
status: 401;
|
|
1223
|
-
payload: AuthError;
|
|
1224
|
-
} | {
|
|
1225
|
-
status: 404;
|
|
1226
|
-
payload: SimpleError;
|
|
1227
|
-
}>;
|
|
1228
|
-
declare type UpdateBranchSchemaVariables = {
|
|
1229
|
-
body?: Record<string, any>;
|
|
1230
|
-
pathParams: UpdateBranchSchemaPathParams;
|
|
1231
|
-
} & FetcherExtraProps;
|
|
1232
|
-
declare const updateBranchSchema: (variables: UpdateBranchSchemaVariables) => Promise<Record<string, any>>;
|
|
1233
|
-
declare type GetBranchSchemaHistoryPathParams = {
|
|
1234
|
-
dbBranchName: DBBranchName;
|
|
1235
|
-
workspace: string;
|
|
1236
|
-
};
|
|
1237
|
-
declare type GetBranchSchemaHistoryError = ErrorWrapper<{
|
|
1238
|
-
status: 400;
|
|
1239
|
-
payload: BadRequestError;
|
|
1240
|
-
} | {
|
|
1241
|
-
status: 401;
|
|
1242
|
-
payload: AuthError;
|
|
1243
|
-
} | {
|
|
1244
|
-
status: 404;
|
|
1245
|
-
payload: SimpleError;
|
|
1246
|
-
}>;
|
|
1247
|
-
declare type GetBranchSchemaHistoryVariables = {
|
|
1248
|
-
body?: Record<string, any>;
|
|
1249
|
-
pathParams: GetBranchSchemaHistoryPathParams;
|
|
1250
|
-
} & FetcherExtraProps;
|
|
1251
|
-
declare const getBranchSchemaHistory: (variables: GetBranchSchemaHistoryVariables) => Promise<Record<string, any>>;
|
|
1252
1383
|
declare type GetBranchStatsPathParams = {
|
|
1253
1384
|
dbBranchName: DBBranchName;
|
|
1254
1385
|
workspace: string;
|
|
@@ -1352,8 +1483,9 @@ declare type UpdateTableVariables = {
|
|
|
1352
1483
|
*
|
|
1353
1484
|
* In the example below, we rename a table from “users” to “people”:
|
|
1354
1485
|
*
|
|
1355
|
-
* ```
|
|
1356
|
-
* PATCH /db/test:main/tables/users
|
|
1486
|
+
* ```json
|
|
1487
|
+
* // PATCH /db/test:main/tables/users
|
|
1488
|
+
*
|
|
1357
1489
|
* {
|
|
1358
1490
|
* "name": "people"
|
|
1359
1491
|
* }
|
|
@@ -1761,7 +1893,7 @@ declare type QueryTableVariables = {
|
|
|
1761
1893
|
* {
|
|
1762
1894
|
* "columns": [...],
|
|
1763
1895
|
* "filter": {
|
|
1764
|
-
* "$all": [...]
|
|
1896
|
+
* "$all": [...],
|
|
1765
1897
|
* "$any": [...]
|
|
1766
1898
|
* ...
|
|
1767
1899
|
* },
|
|
@@ -1807,7 +1939,11 @@ declare type QueryTableVariables = {
|
|
|
1807
1939
|
* "link": {
|
|
1808
1940
|
* "table": "users"
|
|
1809
1941
|
* }
|
|
1810
|
-
* }
|
|
1942
|
+
* },
|
|
1943
|
+
* {
|
|
1944
|
+
* "name": "foundedDate",
|
|
1945
|
+
* "type": "datetime"
|
|
1946
|
+
* },
|
|
1811
1947
|
* ]
|
|
1812
1948
|
* },
|
|
1813
1949
|
* {
|
|
@@ -1895,7 +2031,7 @@ declare type QueryTableVariables = {
|
|
|
1895
2031
|
* {
|
|
1896
2032
|
* "name": "Kilian",
|
|
1897
2033
|
* "address": {
|
|
1898
|
-
* "street": "New street"
|
|
2034
|
+
* "street": "New street"
|
|
1899
2035
|
* }
|
|
1900
2036
|
* }
|
|
1901
2037
|
* ```
|
|
@@ -1904,10 +2040,7 @@ declare type QueryTableVariables = {
|
|
|
1904
2040
|
*
|
|
1905
2041
|
* ```json
|
|
1906
2042
|
* {
|
|
1907
|
-
* "columns": [
|
|
1908
|
-
* "*",
|
|
1909
|
-
* "team.name"
|
|
1910
|
-
* ]
|
|
2043
|
+
* "columns": ["*", "team.name"]
|
|
1911
2044
|
* }
|
|
1912
2045
|
* ```
|
|
1913
2046
|
*
|
|
@@ -1925,7 +2058,7 @@ declare type QueryTableVariables = {
|
|
|
1925
2058
|
* "team": {
|
|
1926
2059
|
* "id": "XX",
|
|
1927
2060
|
* "xata": {
|
|
1928
|
-
* "version": 0
|
|
2061
|
+
* "version": 0
|
|
1929
2062
|
* },
|
|
1930
2063
|
* "name": "first team"
|
|
1931
2064
|
* }
|
|
@@ -1936,10 +2069,7 @@ declare type QueryTableVariables = {
|
|
|
1936
2069
|
*
|
|
1937
2070
|
* ```json
|
|
1938
2071
|
* {
|
|
1939
|
-
* "columns": [
|
|
1940
|
-
* "*",
|
|
1941
|
-
* "team.*"
|
|
1942
|
-
* ]
|
|
2072
|
+
* "columns": ["*", "team.*"]
|
|
1943
2073
|
* }
|
|
1944
2074
|
* ```
|
|
1945
2075
|
*
|
|
@@ -1957,10 +2087,11 @@ declare type QueryTableVariables = {
|
|
|
1957
2087
|
* "team": {
|
|
1958
2088
|
* "id": "XX",
|
|
1959
2089
|
* "xata": {
|
|
1960
|
-
* "version": 0
|
|
2090
|
+
* "version": 0
|
|
1961
2091
|
* },
|
|
1962
2092
|
* "name": "first team",
|
|
1963
|
-
* "code": "A1"
|
|
2093
|
+
* "code": "A1",
|
|
2094
|
+
* "foundedDate": "2020-03-04T10:43:54.32Z"
|
|
1964
2095
|
* }
|
|
1965
2096
|
* }
|
|
1966
2097
|
* ```
|
|
@@ -1975,7 +2106,7 @@ declare type QueryTableVariables = {
|
|
|
1975
2106
|
* `$none`, etc.
|
|
1976
2107
|
*
|
|
1977
2108
|
* All operators start with an `$` to differentiate them from column names
|
|
1978
|
-
* (which are not allowed to start with
|
|
2109
|
+
* (which are not allowed to start with a dollar sign).
|
|
1979
2110
|
*
|
|
1980
2111
|
* #### Exact matching and control operators
|
|
1981
2112
|
*
|
|
@@ -2006,7 +2137,7 @@ declare type QueryTableVariables = {
|
|
|
2006
2137
|
* ```json
|
|
2007
2138
|
* {
|
|
2008
2139
|
* "filter": {
|
|
2009
|
-
*
|
|
2140
|
+
* "name": "r2"
|
|
2010
2141
|
* }
|
|
2011
2142
|
* }
|
|
2012
2143
|
* ```
|
|
@@ -2028,7 +2159,7 @@ declare type QueryTableVariables = {
|
|
|
2028
2159
|
* ```json
|
|
2029
2160
|
* {
|
|
2030
2161
|
* "filter": {
|
|
2031
|
-
*
|
|
2162
|
+
* "settings.plan": "free"
|
|
2032
2163
|
* }
|
|
2033
2164
|
* }
|
|
2034
2165
|
* ```
|
|
@@ -2038,8 +2169,8 @@ declare type QueryTableVariables = {
|
|
|
2038
2169
|
* "filter": {
|
|
2039
2170
|
* "settings": {
|
|
2040
2171
|
* "plan": "free"
|
|
2041
|
-
* }
|
|
2042
|
-
* }
|
|
2172
|
+
* }
|
|
2173
|
+
* }
|
|
2043
2174
|
* }
|
|
2044
2175
|
* ```
|
|
2045
2176
|
*
|
|
@@ -2048,8 +2179,8 @@ declare type QueryTableVariables = {
|
|
|
2048
2179
|
* ```json
|
|
2049
2180
|
* {
|
|
2050
2181
|
* "filter": {
|
|
2051
|
-
* "settings.plan": {"$any": ["free", "paid"]}
|
|
2052
|
-
* }
|
|
2182
|
+
* "settings.plan": { "$any": ["free", "paid"] }
|
|
2183
|
+
* }
|
|
2053
2184
|
* }
|
|
2054
2185
|
* ```
|
|
2055
2186
|
*
|
|
@@ -2058,9 +2189,9 @@ declare type QueryTableVariables = {
|
|
|
2058
2189
|
* ```json
|
|
2059
2190
|
* {
|
|
2060
2191
|
* "filter": {
|
|
2061
|
-
*
|
|
2062
|
-
*
|
|
2063
|
-
* }
|
|
2192
|
+
* "settings.dark": true,
|
|
2193
|
+
* "settings.plan": "free"
|
|
2194
|
+
* }
|
|
2064
2195
|
* }
|
|
2065
2196
|
* ```
|
|
2066
2197
|
*
|
|
@@ -2071,11 +2202,11 @@ declare type QueryTableVariables = {
|
|
|
2071
2202
|
* ```json
|
|
2072
2203
|
* {
|
|
2073
2204
|
* "filter": {
|
|
2074
|
-
*
|
|
2075
|
-
*
|
|
2076
|
-
*
|
|
2077
|
-
*
|
|
2078
|
-
* }
|
|
2205
|
+
* "$any": {
|
|
2206
|
+
* "settings.dark": true,
|
|
2207
|
+
* "settings.plan": "free"
|
|
2208
|
+
* }
|
|
2209
|
+
* }
|
|
2079
2210
|
* }
|
|
2080
2211
|
* ```
|
|
2081
2212
|
*
|
|
@@ -2086,10 +2217,10 @@ declare type QueryTableVariables = {
|
|
|
2086
2217
|
* "filter": {
|
|
2087
2218
|
* "$any": [
|
|
2088
2219
|
* {
|
|
2089
|
-
* "name": "r1"
|
|
2220
|
+
* "name": "r1"
|
|
2090
2221
|
* },
|
|
2091
2222
|
* {
|
|
2092
|
-
* "name": "r2"
|
|
2223
|
+
* "name": "r2"
|
|
2093
2224
|
* }
|
|
2094
2225
|
* ]
|
|
2095
2226
|
* }
|
|
@@ -2101,7 +2232,7 @@ declare type QueryTableVariables = {
|
|
|
2101
2232
|
* ```json
|
|
2102
2233
|
* {
|
|
2103
2234
|
* "filter": {
|
|
2104
|
-
* "$exists": "settings"
|
|
2235
|
+
* "$exists": "settings"
|
|
2105
2236
|
* }
|
|
2106
2237
|
* }
|
|
2107
2238
|
* ```
|
|
@@ -2113,10 +2244,10 @@ declare type QueryTableVariables = {
|
|
|
2113
2244
|
* "filter": {
|
|
2114
2245
|
* "$all": [
|
|
2115
2246
|
* {
|
|
2116
|
-
* "$exists": "settings"
|
|
2247
|
+
* "$exists": "settings"
|
|
2117
2248
|
* },
|
|
2118
2249
|
* {
|
|
2119
|
-
* "$exists": "name"
|
|
2250
|
+
* "$exists": "name"
|
|
2120
2251
|
* }
|
|
2121
2252
|
* ]
|
|
2122
2253
|
* }
|
|
@@ -2128,7 +2259,7 @@ declare type QueryTableVariables = {
|
|
|
2128
2259
|
* ```json
|
|
2129
2260
|
* {
|
|
2130
2261
|
* "filter": {
|
|
2131
|
-
* "$notExists": "settings"
|
|
2262
|
+
* "$notExists": "settings"
|
|
2132
2263
|
* }
|
|
2133
2264
|
* }
|
|
2134
2265
|
* ```
|
|
@@ -2155,43 +2286,59 @@ declare type QueryTableVariables = {
|
|
|
2155
2286
|
* {
|
|
2156
2287
|
* "filter": {
|
|
2157
2288
|
* "<column_name>": {
|
|
2158
|
-
*
|
|
2289
|
+
* "$pattern": "v*alu?"
|
|
2159
2290
|
* }
|
|
2160
2291
|
* }
|
|
2161
2292
|
* }
|
|
2162
2293
|
* ```
|
|
2163
2294
|
*
|
|
2295
|
+
* The `$pattern` operator accepts two wildcard characters:
|
|
2296
|
+
* * `*` matches zero or more characters
|
|
2297
|
+
* * `?` matches exactly one character
|
|
2298
|
+
*
|
|
2299
|
+
* 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.
|
|
2300
|
+
*
|
|
2164
2301
|
* We could also have `$endsWith` and `$startsWith` operators:
|
|
2165
2302
|
*
|
|
2166
2303
|
* ```json
|
|
2167
2304
|
* {
|
|
2168
2305
|
* "filter": {
|
|
2169
2306
|
* "<column_name>": {
|
|
2170
|
-
*
|
|
2307
|
+
* "$endsWith": ".gz"
|
|
2171
2308
|
* },
|
|
2172
2309
|
* "<column_name>": {
|
|
2173
|
-
*
|
|
2310
|
+
* "$startsWith": "tmp-"
|
|
2174
2311
|
* }
|
|
2175
2312
|
* }
|
|
2176
2313
|
* }
|
|
2177
2314
|
* ```
|
|
2178
2315
|
*
|
|
2179
|
-
* #### Numeric ranges
|
|
2316
|
+
* #### Numeric or datetime ranges
|
|
2180
2317
|
*
|
|
2181
2318
|
* ```json
|
|
2182
2319
|
* {
|
|
2183
2320
|
* "filter": {
|
|
2184
|
-
*
|
|
2185
|
-
*
|
|
2186
|
-
*
|
|
2187
|
-
*
|
|
2321
|
+
* "<column_name>": {
|
|
2322
|
+
* "$ge": 0,
|
|
2323
|
+
* "$lt": 100
|
|
2324
|
+
* }
|
|
2325
|
+
* }
|
|
2326
|
+
* }
|
|
2327
|
+
* ```
|
|
2328
|
+
* Date ranges support the same operators, with the date using the format defined in
|
|
2329
|
+
* [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339):
|
|
2330
|
+
* ```json
|
|
2331
|
+
* {
|
|
2332
|
+
* "filter": {
|
|
2333
|
+
* "<column_name>": {
|
|
2334
|
+
* "$gt": "2019-10-12T07:20:50.52Z",
|
|
2335
|
+
* "$lt": "2021-10-12T07:20:50.52Z"
|
|
2336
|
+
* }
|
|
2188
2337
|
* }
|
|
2189
2338
|
* }
|
|
2190
2339
|
* ```
|
|
2191
|
-
*
|
|
2192
2340
|
* The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
|
|
2193
2341
|
*
|
|
2194
|
-
*
|
|
2195
2342
|
* #### Negations
|
|
2196
2343
|
*
|
|
2197
2344
|
* A general `$not` operator can inverse any operation.
|
|
@@ -2216,15 +2363,21 @@ declare type QueryTableVariables = {
|
|
|
2216
2363
|
* {
|
|
2217
2364
|
* "filter": {
|
|
2218
2365
|
* "$not": {
|
|
2219
|
-
* "$any": [
|
|
2220
|
-
*
|
|
2221
|
-
*
|
|
2222
|
-
*
|
|
2223
|
-
*
|
|
2224
|
-
*
|
|
2225
|
-
*
|
|
2226
|
-
*
|
|
2227
|
-
*
|
|
2366
|
+
* "$any": [
|
|
2367
|
+
* {
|
|
2368
|
+
* "<column_name1>": "value1"
|
|
2369
|
+
* },
|
|
2370
|
+
* {
|
|
2371
|
+
* "$all": [
|
|
2372
|
+
* {
|
|
2373
|
+
* "<column_name2>": "value2"
|
|
2374
|
+
* },
|
|
2375
|
+
* {
|
|
2376
|
+
* "<column_name3>": "value3"
|
|
2377
|
+
* }
|
|
2378
|
+
* ]
|
|
2379
|
+
* }
|
|
2380
|
+
* ]
|
|
2228
2381
|
* }
|
|
2229
2382
|
* }
|
|
2230
2383
|
* }
|
|
@@ -2279,8 +2432,8 @@ declare type QueryTableVariables = {
|
|
|
2279
2432
|
* "<array name>": {
|
|
2280
2433
|
* "$includes": {
|
|
2281
2434
|
* "$all": [
|
|
2282
|
-
* {"$contains": "label"},
|
|
2283
|
-
* {"$not": {"$endsWith": "-debug"}}
|
|
2435
|
+
* { "$contains": "label" },
|
|
2436
|
+
* { "$not": { "$endsWith": "-debug" } }
|
|
2284
2437
|
* ]
|
|
2285
2438
|
* }
|
|
2286
2439
|
* }
|
|
@@ -2300,9 +2453,7 @@ declare type QueryTableVariables = {
|
|
|
2300
2453
|
* {
|
|
2301
2454
|
* "filter": {
|
|
2302
2455
|
* "settings.labels": {
|
|
2303
|
-
* "$includesAll": [
|
|
2304
|
-
* {"$contains": "label"},
|
|
2305
|
-
* ]
|
|
2456
|
+
* "$includesAll": [{ "$contains": "label" }]
|
|
2306
2457
|
* }
|
|
2307
2458
|
* }
|
|
2308
2459
|
* }
|
|
@@ -2350,7 +2501,6 @@ declare type QueryTableVariables = {
|
|
|
2350
2501
|
* }
|
|
2351
2502
|
* ```
|
|
2352
2503
|
*
|
|
2353
|
-
*
|
|
2354
2504
|
* ### Pagination
|
|
2355
2505
|
*
|
|
2356
2506
|
* We offer cursor pagination and offset pagination. The offset pagination is limited
|
|
@@ -2416,8 +2566,8 @@ declare type QueryTableVariables = {
|
|
|
2416
2566
|
* can be queried by update `page.after` to the returned cursor while keeping the
|
|
2417
2567
|
* `page.before` cursor from the first range query.
|
|
2418
2568
|
*
|
|
2419
|
-
* The `filter` , `columns`,
|
|
2420
|
-
* encoded with the cursor.
|
|
2569
|
+
* The `filter` , `columns`, `sort` , and `page.size` configuration will be
|
|
2570
|
+
* encoded with the cursor. The pagination request will be invalid if
|
|
2421
2571
|
* `filter` or `sort` is set. The columns returned and page size can be changed
|
|
2422
2572
|
* anytime by passing the `columns` or `page.size` settings to the next query.
|
|
2423
2573
|
*
|
|
@@ -2454,6 +2604,39 @@ declare type QueryTableVariables = {
|
|
|
2454
2604
|
* ```
|
|
2455
2605
|
*/
|
|
2456
2606
|
declare const queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
|
2607
|
+
declare type SearchTablePathParams = {
|
|
2608
|
+
dbBranchName: DBBranchName;
|
|
2609
|
+
tableName: TableName;
|
|
2610
|
+
workspace: string;
|
|
2611
|
+
};
|
|
2612
|
+
declare type SearchTableError = ErrorWrapper<{
|
|
2613
|
+
status: 400;
|
|
2614
|
+
payload: BadRequestError;
|
|
2615
|
+
} | {
|
|
2616
|
+
status: 401;
|
|
2617
|
+
payload: AuthError;
|
|
2618
|
+
} | {
|
|
2619
|
+
status: 404;
|
|
2620
|
+
payload: SimpleError;
|
|
2621
|
+
}>;
|
|
2622
|
+
declare type SearchTableRequestBody = {
|
|
2623
|
+
query: string;
|
|
2624
|
+
fuzziness?: FuzzinessExpression;
|
|
2625
|
+
filter?: FilterExpression;
|
|
2626
|
+
highlight?: HighlightExpression;
|
|
2627
|
+
};
|
|
2628
|
+
declare type SearchTableVariables = {
|
|
2629
|
+
body: SearchTableRequestBody;
|
|
2630
|
+
pathParams: SearchTablePathParams;
|
|
2631
|
+
} & FetcherExtraProps;
|
|
2632
|
+
/**
|
|
2633
|
+
* Run a free text search operation in a particular table.
|
|
2634
|
+
*
|
|
2635
|
+
* 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:
|
|
2636
|
+
* * filters `$contains`, `$startsWith`, `$endsWith` don't work on columns of type `text`
|
|
2637
|
+
* * filtering on columns of type `multiple` is currently unsupported
|
|
2638
|
+
*/
|
|
2639
|
+
declare const searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
|
|
2457
2640
|
declare type SearchBranchPathParams = {
|
|
2458
2641
|
dbBranchName: DBBranchName;
|
|
2459
2642
|
workspace: string;
|
|
@@ -2469,9 +2652,13 @@ declare type SearchBranchError = ErrorWrapper<{
|
|
|
2469
2652
|
payload: SimpleError;
|
|
2470
2653
|
}>;
|
|
2471
2654
|
declare type SearchBranchRequestBody = {
|
|
2472
|
-
tables?: string
|
|
2655
|
+
tables?: (string | {
|
|
2656
|
+
table: string;
|
|
2657
|
+
filter?: FilterExpression;
|
|
2658
|
+
})[];
|
|
2473
2659
|
query: string;
|
|
2474
|
-
fuzziness?:
|
|
2660
|
+
fuzziness?: FuzzinessExpression;
|
|
2661
|
+
highlight?: HighlightExpression;
|
|
2475
2662
|
};
|
|
2476
2663
|
declare type SearchBranchVariables = {
|
|
2477
2664
|
body: SearchBranchRequestBody;
|
|
@@ -2508,6 +2695,10 @@ declare const operationsByTag: {
|
|
|
2508
2695
|
getDatabaseList: (variables: GetDatabaseListVariables) => Promise<ListDatabasesResponse>;
|
|
2509
2696
|
createDatabase: (variables: CreateDatabaseVariables) => Promise<CreateDatabaseResponse>;
|
|
2510
2697
|
deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
|
|
2698
|
+
getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
|
|
2699
|
+
addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
|
|
2700
|
+
removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
|
|
2701
|
+
resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
|
|
2511
2702
|
};
|
|
2512
2703
|
branch: {
|
|
2513
2704
|
getBranchList: (variables: GetBranchListVariables) => Promise<ListBranchesResponse>;
|
|
@@ -2519,9 +2710,6 @@ declare const operationsByTag: {
|
|
|
2519
2710
|
getBranchMigrationHistory: (variables: GetBranchMigrationHistoryVariables) => Promise<GetBranchMigrationHistoryResponse>;
|
|
2520
2711
|
executeBranchMigrationPlan: (variables: ExecuteBranchMigrationPlanVariables) => Promise<undefined>;
|
|
2521
2712
|
getBranchMigrationPlan: (variables: GetBranchMigrationPlanVariables) => Promise<BranchMigrationPlan>;
|
|
2522
|
-
compareBranchSchema: (variables: CompareBranchSchemaVariables) => Promise<Record<string, any>>;
|
|
2523
|
-
updateBranchSchema: (variables: UpdateBranchSchemaVariables) => Promise<Record<string, any>>;
|
|
2524
|
-
getBranchSchemaHistory: (variables: GetBranchSchemaHistoryVariables) => Promise<Record<string, any>>;
|
|
2525
2713
|
getBranchStats: (variables: GetBranchStatsVariables) => Promise<GetBranchStatsResponse>;
|
|
2526
2714
|
};
|
|
2527
2715
|
table: {
|
|
@@ -2545,6 +2733,7 @@ declare const operationsByTag: {
|
|
|
2545
2733
|
getRecord: (variables: GetRecordVariables) => Promise<XataRecord$1>;
|
|
2546
2734
|
bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
|
|
2547
2735
|
queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
|
2736
|
+
searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
|
|
2548
2737
|
searchBranch: (variables: SearchBranchVariables) => Promise<SearchResponse>;
|
|
2549
2738
|
};
|
|
2550
2739
|
};
|
|
@@ -2561,6 +2750,9 @@ interface XataApiClientOptions {
|
|
|
2561
2750
|
apiKey?: string;
|
|
2562
2751
|
host?: HostProvider;
|
|
2563
2752
|
}
|
|
2753
|
+
/**
|
|
2754
|
+
* @deprecated Use XataApiPlugin instead
|
|
2755
|
+
*/
|
|
2564
2756
|
declare class XataApiClient {
|
|
2565
2757
|
#private;
|
|
2566
2758
|
constructor(options?: XataApiClientOptions);
|
|
@@ -2603,6 +2795,10 @@ declare class DatabaseApi {
|
|
|
2603
2795
|
getDatabaseList(workspace: WorkspaceID): Promise<ListDatabasesResponse>;
|
|
2604
2796
|
createDatabase(workspace: WorkspaceID, dbName: DBName, options?: CreateDatabaseRequestBody): Promise<CreateDatabaseResponse>;
|
|
2605
2797
|
deleteDatabase(workspace: WorkspaceID, dbName: DBName): Promise<void>;
|
|
2798
|
+
getGitBranchesMapping(workspace: WorkspaceID, dbName: DBName): Promise<ListGitBranchesResponse>;
|
|
2799
|
+
addGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, body: AddGitBranchesEntryRequestBody): Promise<AddGitBranchesEntryResponse>;
|
|
2800
|
+
removeGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<void>;
|
|
2801
|
+
resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<ResolveBranchResponse>;
|
|
2606
2802
|
}
|
|
2607
2803
|
declare class BranchApi {
|
|
2608
2804
|
private extraProps;
|
|
@@ -2643,6 +2839,7 @@ declare class RecordsApi {
|
|
|
2643
2839
|
getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: GetRecordRequestBody): Promise<XataRecord$1>;
|
|
2644
2840
|
bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[]): Promise<BulkInsertTableRecordsResponse>;
|
|
2645
2841
|
queryTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: QueryTableRequestBody): Promise<QueryResponse>;
|
|
2842
|
+
searchTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: SearchTableRequestBody): Promise<SearchResponse>;
|
|
2646
2843
|
searchBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, query: SearchBranchRequestBody): Promise<SearchResponse>;
|
|
2647
2844
|
}
|
|
2648
2845
|
|
|
@@ -2664,30 +2861,31 @@ declare type RequiredBy<T, K extends keyof T> = T & {
|
|
|
2664
2861
|
};
|
|
2665
2862
|
declare type GetArrayInnerType<T extends readonly any[]> = T[number];
|
|
2666
2863
|
declare type SingleOrArray<T> = T | T[];
|
|
2667
|
-
declare type
|
|
2864
|
+
declare type OmitBy<T, K extends keyof T> = T extends any ? Omit<T, K> : never;
|
|
2668
2865
|
|
|
2669
2866
|
declare type SelectableColumn<O, RecursivePath extends any[] = []> = '*' | 'id' | DataProps<O> | NestedColumns<O, RecursivePath>;
|
|
2670
2867
|
declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord & UnionToIntersection<Values<{
|
|
2671
2868
|
[K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord;
|
|
2672
2869
|
}>>;
|
|
2673
|
-
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
|
|
2674
|
-
V: ValueAtColumn<O[K]
|
|
2675
|
-
} : never
|
|
2870
|
+
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<RemoveNullable<O[K]> extends Record<string, any> ? V extends SelectableColumn<RemoveNullable<O[K]>> ? {
|
|
2871
|
+
V: ValueAtColumn<RemoveNullable<O[K]>, V>;
|
|
2872
|
+
} : never : O[K]> : never : never;
|
|
2676
2873
|
declare type MAX_RECURSION = 5;
|
|
2677
2874
|
declare type NestedColumns<O, RecursivePath extends any[]> = RecursivePath['length'] extends MAX_RECURSION ? never : If<IsObject<O>, Values<{
|
|
2678
|
-
[K in DataProps<O>]: If<IsArray<
|
|
2679
|
-
If<IsObject<
|
|
2875
|
+
[K in DataProps<O>]: If<IsArray<RemoveNullable<O[K]>>, K, // If the property is an array, we stop recursion. We don't support object arrays yet
|
|
2876
|
+
If<IsObject<RemoveNullable<O[K]>>, RemoveNullable<O[K]> extends XataRecord ? SelectableColumn<RemoveNullable<O[K]>, [...RecursivePath, O[K]]> extends infer Column ? Column extends string ? K | `${K}.${Column}` : never : never : `${K}.${StringKeys<RemoveNullable<O[K]>> | '*'}`, // This allows usage of objects that are not links
|
|
2680
2877
|
K>>;
|
|
2681
2878
|
}>, never>;
|
|
2682
2879
|
declare type DataProps<O> = Exclude<StringKeys<O>, StringKeys<XataRecord>>;
|
|
2683
2880
|
declare type NestedValueAtColumn<O, Key extends SelectableColumn<O>> = Key extends `${infer N}.${infer M}` ? N extends DataProps<O> ? {
|
|
2684
|
-
[K in N]: M extends SelectableColumn<
|
|
2881
|
+
[K in N]: M extends SelectableColumn<RemoveNullable<O[K]>> ? RemoveNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], NestedValueAtColumn<RemoveNullable<O[K]>, M> & XataRecord> : ForwardNullable<O[K], NestedValueAtColumn<RemoveNullable<O[K]>, M>> : unknown;
|
|
2685
2882
|
} : unknown : Key extends DataProps<O> ? {
|
|
2686
|
-
[K in Key]:
|
|
2883
|
+
[K in Key]: RemoveNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], SelectedPick<RemoveNullable<O[K]>, ['*']>> : O[K];
|
|
2687
2884
|
} : Key extends '*' ? {
|
|
2688
|
-
[K in StringKeys<O>]:
|
|
2885
|
+
[K in StringKeys<O>]: RemoveNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], Link<RemoveNullable<O[K]>>> : O[K];
|
|
2689
2886
|
} : unknown;
|
|
2690
|
-
declare type
|
|
2887
|
+
declare type RemoveNullable<T> = T extends null | undefined ? never : T;
|
|
2888
|
+
declare type ForwardNullable<T, R> = T extends RemoveNullable<T> ? R : R | null;
|
|
2691
2889
|
|
|
2692
2890
|
/**
|
|
2693
2891
|
* Represents an identifiable record from the database.
|
|
@@ -2704,16 +2902,11 @@ interface BaseData {
|
|
|
2704
2902
|
/**
|
|
2705
2903
|
* Represents a persisted record from the database.
|
|
2706
2904
|
*/
|
|
2707
|
-
interface XataRecord extends Identifiable {
|
|
2905
|
+
interface XataRecord<ExtraMetadata extends Record<string, unknown> = Record<string, unknown>> extends Identifiable {
|
|
2708
2906
|
/**
|
|
2709
|
-
*
|
|
2907
|
+
* Get metadata of this record.
|
|
2710
2908
|
*/
|
|
2711
|
-
|
|
2712
|
-
/**
|
|
2713
|
-
* Number that is increased every time the record is updated.
|
|
2714
|
-
*/
|
|
2715
|
-
version: number;
|
|
2716
|
-
};
|
|
2909
|
+
getMetadata(): XataRecordMetadata & ExtraMetadata;
|
|
2717
2910
|
/**
|
|
2718
2911
|
* Retrieves a refreshed copy of the current record from the database.
|
|
2719
2912
|
*/
|
|
@@ -2721,7 +2914,7 @@ interface XataRecord extends Identifiable {
|
|
|
2721
2914
|
/**
|
|
2722
2915
|
* Performs a partial update of the current record. On success a new object is
|
|
2723
2916
|
* returned and the current object is not mutated.
|
|
2724
|
-
* @param
|
|
2917
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
|
2725
2918
|
* @returns A new record containing the latest values for all the columns of the current record.
|
|
2726
2919
|
*/
|
|
2727
2920
|
update(partialUpdate: Partial<EditableData<Omit<this, keyof XataRecord>>>): Promise<Readonly<SelectedPick<this, ['*']>>>;
|
|
@@ -2740,11 +2933,18 @@ declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update
|
|
|
2740
2933
|
/**
|
|
2741
2934
|
* Performs a partial update of the current record. On success a new object is
|
|
2742
2935
|
* returned and the current object is not mutated.
|
|
2743
|
-
* @param
|
|
2936
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
|
2744
2937
|
* @returns A new record containing the latest values for all the columns of the current record.
|
|
2745
2938
|
*/
|
|
2746
2939
|
update(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
|
2747
2940
|
};
|
|
2941
|
+
declare type XataRecordMetadata = {
|
|
2942
|
+
/**
|
|
2943
|
+
* Number that is increased every time the record is updated.
|
|
2944
|
+
*/
|
|
2945
|
+
version: number;
|
|
2946
|
+
warnings?: string[];
|
|
2947
|
+
};
|
|
2748
2948
|
declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
|
|
2749
2949
|
declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
|
|
2750
2950
|
declare type EditableData<O extends BaseData> = {
|
|
@@ -2828,8 +3028,8 @@ declare type ValueTypeFilters<T> = T | T extends string ? StringTypeFilter : T e
|
|
|
2828
3028
|
],
|
|
2829
3029
|
}
|
|
2830
3030
|
*/
|
|
2831
|
-
declare type AggregatorFilter<
|
|
2832
|
-
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<
|
|
3031
|
+
declare type AggregatorFilter<T> = {
|
|
3032
|
+
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<T>>;
|
|
2833
3033
|
};
|
|
2834
3034
|
/**
|
|
2835
3035
|
* Existance filter
|
|
@@ -2844,10 +3044,10 @@ declare type BaseApiFilter<Record> = PropertyAccessFilter<Record> | AggregatorFi
|
|
|
2844
3044
|
* Injects the Api filters on nested properties
|
|
2845
3045
|
* Example: { filter: { settings: { plan: { $any: ['free', 'trial'] } } } }
|
|
2846
3046
|
*/
|
|
2847
|
-
declare type NestedApiFilter<T> =
|
|
3047
|
+
declare type NestedApiFilter<T> = {
|
|
2848
3048
|
[key in keyof T]?: T[key] extends Record<string, any> ? SingleOrArray<Filter<T[key]>> : PropertyFilter<T[key]>;
|
|
2849
|
-
}
|
|
2850
|
-
declare type Filter<
|
|
3049
|
+
};
|
|
3050
|
+
declare type Filter<T> = T extends Record<string, any> ? BaseApiFilter<T> | NestedApiFilter<T> : PropertyFilter<T>;
|
|
2851
3051
|
|
|
2852
3052
|
declare type SortDirection = 'asc' | 'desc';
|
|
2853
3053
|
declare type SortFilterExtended<T extends XataRecord> = {
|
|
@@ -2859,13 +3059,21 @@ declare type SortFilterBase<T extends XataRecord> = {
|
|
|
2859
3059
|
[Key in StringKeys<T>]: SortDirection;
|
|
2860
3060
|
};
|
|
2861
3061
|
|
|
2862
|
-
declare type
|
|
2863
|
-
page?: PaginationOptions;
|
|
3062
|
+
declare type BaseOptions<T extends XataRecord> = {
|
|
2864
3063
|
columns?: NonEmptyArray<SelectableColumn<T>>;
|
|
3064
|
+
cache?: number;
|
|
3065
|
+
};
|
|
3066
|
+
declare type CursorQueryOptions = {
|
|
3067
|
+
pagination?: CursorNavigationOptions & OffsetNavigationOptions;
|
|
3068
|
+
filter?: never;
|
|
3069
|
+
sort?: never;
|
|
3070
|
+
};
|
|
3071
|
+
declare type OffsetQueryOptions<T extends XataRecord> = {
|
|
3072
|
+
pagination?: OffsetNavigationOptions;
|
|
2865
3073
|
filter?: FilterExpression;
|
|
2866
3074
|
sort?: SortFilter<T> | SortFilter<T>[];
|
|
2867
|
-
cache?: number;
|
|
2868
3075
|
};
|
|
3076
|
+
declare type QueryOptions<T extends XataRecord> = BaseOptions<T> & (CursorQueryOptions | OffsetQueryOptions<T>);
|
|
2869
3077
|
/**
|
|
2870
3078
|
* Query objects contain the information of all filters, sorting, etc. to be included in the database query.
|
|
2871
3079
|
*
|
|
@@ -2876,7 +3084,7 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
|
2876
3084
|
#private;
|
|
2877
3085
|
readonly meta: PaginationQueryMeta;
|
|
2878
3086
|
readonly records: Result[];
|
|
2879
|
-
constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>,
|
|
3087
|
+
constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, rawParent?: Partial<QueryOptions<Record>>);
|
|
2880
3088
|
getQueryOptions(): QueryOptions<Record>;
|
|
2881
3089
|
key(): string;
|
|
2882
3090
|
/**
|
|
@@ -2908,18 +3116,28 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
|
2908
3116
|
*
|
|
2909
3117
|
* ```
|
|
2910
3118
|
* query.filter("columnName", columnValue)
|
|
2911
|
-
* query.filter(
|
|
2912
|
-
*
|
|
2913
|
-
*
|
|
3119
|
+
* query.filter("columnName", operator(columnValue)) // Use gt, gte, lt, lte, startsWith,...
|
|
3120
|
+
* ```
|
|
3121
|
+
*
|
|
3122
|
+
* @param column The name of the column to filter.
|
|
3123
|
+
* @param value The value to filter.
|
|
3124
|
+
* @returns A new Query object.
|
|
3125
|
+
*/
|
|
3126
|
+
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
|
|
3127
|
+
/**
|
|
3128
|
+
* Builds a new query object adding one or more constraints. Examples:
|
|
3129
|
+
*
|
|
3130
|
+
* ```
|
|
3131
|
+
* query.filter({ "columnName": columnValue })
|
|
2914
3132
|
* query.filter({
|
|
2915
3133
|
* "columnName": operator(columnValue) // Use gt, gte, lt, lte, startsWith,...
|
|
2916
3134
|
* })
|
|
2917
3135
|
* ```
|
|
2918
3136
|
*
|
|
3137
|
+
* @param filters A filter object
|
|
2919
3138
|
* @returns A new Query object.
|
|
2920
3139
|
*/
|
|
2921
3140
|
filter(filters: Filter<Record>): Query<Record, Result>;
|
|
2922
|
-
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
|
|
2923
3141
|
/**
|
|
2924
3142
|
* Builds a new query with a new sort option.
|
|
2925
3143
|
* @param column The column name.
|
|
@@ -2933,48 +3151,148 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
|
2933
3151
|
* @returns A new Query object.
|
|
2934
3152
|
*/
|
|
2935
3153
|
select<K extends SelectableColumn<Record>>(columns: NonEmptyArray<K>): Query<Record, SelectedPick<Record, NonEmptyArray<K>>>;
|
|
3154
|
+
/**
|
|
3155
|
+
* Get paginated results
|
|
3156
|
+
*
|
|
3157
|
+
* @returns A page of results
|
|
3158
|
+
*/
|
|
2936
3159
|
getPaginated(): Promise<Page<Record, Result>>;
|
|
2937
|
-
|
|
3160
|
+
/**
|
|
3161
|
+
* Get paginated results
|
|
3162
|
+
*
|
|
3163
|
+
* @param options Pagination options
|
|
3164
|
+
* @returns A page of results
|
|
3165
|
+
*/
|
|
3166
|
+
getPaginated(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
|
|
3167
|
+
/**
|
|
3168
|
+
* Get paginated results
|
|
3169
|
+
*
|
|
3170
|
+
* @param options Pagination options
|
|
3171
|
+
* @returns A page of results
|
|
3172
|
+
*/
|
|
2938
3173
|
getPaginated<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<Page<Record, SelectedPick<Record, typeof options['columns']>>>;
|
|
3174
|
+
/**
|
|
3175
|
+
* Get results in an iterator
|
|
3176
|
+
*
|
|
3177
|
+
* @async
|
|
3178
|
+
* @returns Async interable of results
|
|
3179
|
+
*/
|
|
2939
3180
|
[Symbol.asyncIterator](): AsyncIterableIterator<Result>;
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
3181
|
+
/**
|
|
3182
|
+
* Build an iterator of results
|
|
3183
|
+
*
|
|
3184
|
+
* @returns Async generator of results array
|
|
3185
|
+
*/
|
|
3186
|
+
getIterator(): AsyncGenerator<Result[]>;
|
|
3187
|
+
/**
|
|
3188
|
+
* Build an iterator of results
|
|
3189
|
+
*
|
|
3190
|
+
* @param options Pagination options with batchSize
|
|
3191
|
+
* @returns Async generator of results array
|
|
3192
|
+
*/
|
|
3193
|
+
getIterator(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
|
|
3194
|
+
batchSize?: number;
|
|
3195
|
+
}): 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 extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
|
|
3203
|
+
batchSize?: number;
|
|
3204
|
+
}>(options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
|
|
2943
3205
|
/**
|
|
2944
3206
|
* Performs the query in the database and returns a set of results.
|
|
2945
|
-
* @param options Additional options to be used when performing the query.
|
|
2946
3207
|
* @returns An array of records from the database.
|
|
2947
3208
|
*/
|
|
2948
3209
|
getMany(): Promise<Result[]>;
|
|
2949
|
-
|
|
3210
|
+
/**
|
|
3211
|
+
* Performs the query in the database and returns a set of results.
|
|
3212
|
+
* @param options Additional options to be used when performing the query.
|
|
3213
|
+
* @returns An array of records from the database.
|
|
3214
|
+
*/
|
|
3215
|
+
getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Result[]>;
|
|
3216
|
+
/**
|
|
3217
|
+
* Performs the query in the database and returns a set of results.
|
|
3218
|
+
* @param options Additional options to be used when performing the query.
|
|
3219
|
+
* @returns An array of records from the database.
|
|
3220
|
+
*/
|
|
2950
3221
|
getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
|
|
3222
|
+
/**
|
|
3223
|
+
* Performs the query in the database and returns all the results.
|
|
3224
|
+
* Warning: If there are a large number of results, this method can have performance implications.
|
|
3225
|
+
* @returns An array of records from the database.
|
|
3226
|
+
*/
|
|
3227
|
+
getAll(): Promise<Result[]>;
|
|
2951
3228
|
/**
|
|
2952
3229
|
* Performs the query in the database and returns all the results.
|
|
2953
3230
|
* Warning: If there are a large number of results, this method can have performance implications.
|
|
2954
3231
|
* @param options Additional options to be used when performing the query.
|
|
2955
3232
|
* @returns An array of records from the database.
|
|
2956
3233
|
*/
|
|
2957
|
-
getAll(
|
|
2958
|
-
|
|
2959
|
-
|
|
3234
|
+
getAll(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
|
|
3235
|
+
batchSize?: number;
|
|
3236
|
+
}): Promise<Result[]>;
|
|
2960
3237
|
/**
|
|
2961
|
-
* Performs the query in the database and returns the
|
|
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.
|
|
2962
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']>[]>;
|
|
3246
|
+
/**
|
|
3247
|
+
* Performs the query in the database and returns the first result.
|
|
2963
3248
|
* @returns The first record that matches the query, or null if no record matched the query.
|
|
2964
3249
|
*/
|
|
2965
3250
|
getFirst(): Promise<Result | null>;
|
|
2966
|
-
|
|
2967
|
-
|
|
3251
|
+
/**
|
|
3252
|
+
* Performs the query in the database and returns the first result.
|
|
3253
|
+
* @param options Additional options to be used when performing the query.
|
|
3254
|
+
* @returns The first record that matches the query, or null if no record matched the query.
|
|
3255
|
+
*/
|
|
3256
|
+
getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
|
|
3257
|
+
/**
|
|
3258
|
+
* Performs the query in the database and returns the first result.
|
|
3259
|
+
* @param options Additional options to be used when performing the query.
|
|
3260
|
+
* @returns The first record that matches the query, or null if no record matched the query.
|
|
3261
|
+
*/
|
|
3262
|
+
getFirst<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
|
|
2968
3263
|
/**
|
|
2969
3264
|
* Builds a new query object adding a cache TTL in milliseconds.
|
|
2970
3265
|
* @param ttl The cache TTL in milliseconds.
|
|
2971
3266
|
* @returns A new Query object.
|
|
2972
3267
|
*/
|
|
2973
3268
|
cache(ttl: number): Query<Record, Result>;
|
|
3269
|
+
/**
|
|
3270
|
+
* Retrieve next page of records
|
|
3271
|
+
*
|
|
3272
|
+
* @returns A new page object.
|
|
3273
|
+
*/
|
|
2974
3274
|
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
|
3275
|
+
/**
|
|
3276
|
+
* Retrieve previous page of records
|
|
3277
|
+
*
|
|
3278
|
+
* @returns A new page object
|
|
3279
|
+
*/
|
|
2975
3280
|
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
|
3281
|
+
/**
|
|
3282
|
+
* Retrieve first page of records
|
|
3283
|
+
*
|
|
3284
|
+
* @returns A new page object
|
|
3285
|
+
*/
|
|
2976
3286
|
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
|
3287
|
+
/**
|
|
3288
|
+
* Retrieve last page of records
|
|
3289
|
+
*
|
|
3290
|
+
* @returns A new page object
|
|
3291
|
+
*/
|
|
2977
3292
|
lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
|
3293
|
+
/**
|
|
3294
|
+
* @returns Boolean indicating if there is a next page
|
|
3295
|
+
*/
|
|
2978
3296
|
hasNextPage(): boolean;
|
|
2979
3297
|
}
|
|
2980
3298
|
|
|
@@ -3054,14 +3372,12 @@ declare type OffsetNavigationOptions = {
|
|
|
3054
3372
|
size?: number;
|
|
3055
3373
|
offset?: number;
|
|
3056
3374
|
};
|
|
3057
|
-
declare type PaginationOptions = CursorNavigationOptions & OffsetNavigationOptions;
|
|
3058
3375
|
declare const PAGINATION_MAX_SIZE = 200;
|
|
3059
3376
|
declare const PAGINATION_DEFAULT_SIZE = 200;
|
|
3060
3377
|
declare const PAGINATION_MAX_OFFSET = 800;
|
|
3061
3378
|
declare const PAGINATION_DEFAULT_OFFSET = 0;
|
|
3379
|
+
declare function isCursorPaginationOptions(options: Record<string, unknown> | undefined | null): options is CursorNavigationOptions;
|
|
3062
3380
|
|
|
3063
|
-
declare type TableLink = string[];
|
|
3064
|
-
declare type LinkDictionary = Dictionary<TableLink[]>;
|
|
3065
3381
|
/**
|
|
3066
3382
|
* Common interface for performing operations on a table.
|
|
3067
3383
|
*/
|
|
@@ -3086,6 +3402,12 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
|
3086
3402
|
* @returns The persisted record for the given id or null if the record could not be found.
|
|
3087
3403
|
*/
|
|
3088
3404
|
abstract read(id: string): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
|
|
3405
|
+
/**
|
|
3406
|
+
* Queries multiple records from the table given their unique id.
|
|
3407
|
+
* @param ids The unique ids array.
|
|
3408
|
+
* @returns The persisted records for the given ids (if a record could not be found it is not returned).
|
|
3409
|
+
*/
|
|
3410
|
+
abstract read(ids: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
|
3089
3411
|
/**
|
|
3090
3412
|
* Partially update a single record.
|
|
3091
3413
|
* @param object An object with its id and the columns to be updated.
|
|
@@ -3158,7 +3480,9 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
|
3158
3480
|
* @returns The found records.
|
|
3159
3481
|
*/
|
|
3160
3482
|
abstract search(query: string, options?: {
|
|
3161
|
-
fuzziness?:
|
|
3483
|
+
fuzziness?: FuzzinessExpression;
|
|
3484
|
+
highlight?: HighlightExpression;
|
|
3485
|
+
filter?: Filter<Record>;
|
|
3162
3486
|
}): Promise<SelectedPick<Record, ['*']>[]>;
|
|
3163
3487
|
abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
|
3164
3488
|
}
|
|
@@ -3167,7 +3491,6 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
|
|
|
3167
3491
|
db: SchemaPluginResult<any>;
|
|
3168
3492
|
constructor(options: {
|
|
3169
3493
|
table: string;
|
|
3170
|
-
links?: LinkDictionary;
|
|
3171
3494
|
db: SchemaPluginResult<any>;
|
|
3172
3495
|
pluginOptions: XataPluginOptions;
|
|
3173
3496
|
});
|
|
@@ -3175,6 +3498,7 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
|
|
|
3175
3498
|
create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
|
|
3176
3499
|
create(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
|
|
3177
3500
|
read(recordId: string): Promise<SelectedPick<Record, ['*']> | null>;
|
|
3501
|
+
read(recordIds: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
|
3178
3502
|
update(object: Partial<EditableData<Data>> & Identifiable): Promise<SelectedPick<Record, ['*']>>;
|
|
3179
3503
|
update(recordId: string, object: Partial<EditableData<Data>>): Promise<SelectedPick<Record, ['*']>>;
|
|
3180
3504
|
update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<SelectedPick<Record, ['*']>[]>;
|
|
@@ -3183,7 +3507,9 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
|
|
|
3183
3507
|
createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
|
|
3184
3508
|
delete(a: string | Identifiable | Array<string | Identifiable>): Promise<void>;
|
|
3185
3509
|
search(query: string, options?: {
|
|
3186
|
-
fuzziness?:
|
|
3510
|
+
fuzziness?: FuzzinessExpression;
|
|
3511
|
+
highlight?: HighlightExpression;
|
|
3512
|
+
filter?: Filter<Record>;
|
|
3187
3513
|
}): Promise<SelectedPick<Record, ['*']>[]>;
|
|
3188
3514
|
query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
|
3189
3515
|
}
|
|
@@ -3263,46 +3589,59 @@ declare const includesAny: <T>(value: T) => ArrayFilter<T>;
|
|
|
3263
3589
|
|
|
3264
3590
|
declare type SchemaDefinition = {
|
|
3265
3591
|
table: string;
|
|
3266
|
-
links?: LinkDictionary;
|
|
3267
3592
|
};
|
|
3268
3593
|
declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
|
|
3269
3594
|
[Key in keyof Schemas]: Repository<Schemas[Key]>;
|
|
3595
|
+
} & {
|
|
3596
|
+
[key: string]: Repository<XataRecord$1>;
|
|
3270
3597
|
};
|
|
3271
3598
|
declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
|
3272
3599
|
#private;
|
|
3273
|
-
private links?;
|
|
3274
3600
|
private tableNames?;
|
|
3275
|
-
constructor(
|
|
3601
|
+
constructor(tableNames?: string[] | undefined);
|
|
3276
3602
|
build(pluginOptions: XataPluginOptions): SchemaPluginResult<Schemas>;
|
|
3277
3603
|
}
|
|
3278
3604
|
|
|
3279
3605
|
declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
|
|
3280
|
-
fuzziness?:
|
|
3281
|
-
|
|
3606
|
+
fuzziness?: FuzzinessExpression;
|
|
3607
|
+
highlight?: HighlightExpression;
|
|
3608
|
+
tables?: Array<Tables | Values<{
|
|
3609
|
+
[Model in GetArrayInnerType<NonNullable<Tables[]>>]: {
|
|
3610
|
+
table: Model;
|
|
3611
|
+
filter?: Filter<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
|
|
3612
|
+
};
|
|
3613
|
+
}>>;
|
|
3282
3614
|
};
|
|
3283
3615
|
declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
|
|
3284
3616
|
all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
|
|
3285
|
-
[Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']
|
|
3617
|
+
[Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]: {
|
|
3286
3618
|
table: Model;
|
|
3287
3619
|
record: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
|
|
3288
3620
|
};
|
|
3289
3621
|
}>[]>;
|
|
3290
3622
|
byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
|
|
3291
|
-
[Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']
|
|
3623
|
+
[Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
|
|
3292
3624
|
}>;
|
|
3293
3625
|
};
|
|
3294
3626
|
declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
|
3295
3627
|
#private;
|
|
3296
3628
|
private db;
|
|
3297
|
-
|
|
3298
|
-
constructor(db: SchemaPluginResult<Schemas>, links: LinkDictionary);
|
|
3629
|
+
constructor(db: SchemaPluginResult<Schemas>);
|
|
3299
3630
|
build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
|
|
3300
3631
|
}
|
|
3301
|
-
declare type SearchXataRecord = XataRecord
|
|
3302
|
-
|
|
3303
|
-
|
|
3632
|
+
declare type SearchXataRecord = XataRecord<SearchExtraProperties>;
|
|
3633
|
+
declare type SearchExtraProperties = {
|
|
3634
|
+
table: string;
|
|
3635
|
+
highlight?: {
|
|
3636
|
+
[key: string]: string[] | {
|
|
3637
|
+
[key: string]: any;
|
|
3638
|
+
};
|
|
3304
3639
|
};
|
|
3305
3640
|
};
|
|
3641
|
+
declare type ReturnTable<Table, Tables> = Table extends Tables ? Table : never;
|
|
3642
|
+
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 {
|
|
3643
|
+
table: infer Table;
|
|
3644
|
+
} ? ReturnTable<Table, Tables> : never;
|
|
3306
3645
|
|
|
3307
3646
|
declare type BranchStrategyValue = string | undefined | null;
|
|
3308
3647
|
declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
|
|
@@ -3318,7 +3657,7 @@ declare type BaseClientOptions = {
|
|
|
3318
3657
|
};
|
|
3319
3658
|
declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
|
|
3320
3659
|
interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
|
|
3321
|
-
new <Schemas extends Record<string, BaseData
|
|
3660
|
+
new <Schemas extends Record<string, BaseData> = {}>(options?: Partial<BaseClientOptions>, tables?: string[]): Omit<{
|
|
3322
3661
|
db: Awaited<ReturnType<SchemaPlugin<Schemas>['build']>>;
|
|
3323
3662
|
search: Awaited<ReturnType<SearchPlugin<Schemas>['build']>>;
|
|
3324
3663
|
}, keyof Plugins> & {
|
|
@@ -3345,4 +3684,4 @@ declare class XataError extends Error {
|
|
|
3345
3684
|
constructor(message: string, status: number);
|
|
3346
3685
|
}
|
|
3347
3686
|
|
|
3348
|
-
export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsResponse, BulkInsertTableRecordsVariables, CacheImpl, CancelWorkspaceMemberInviteError, CancelWorkspaceMemberInvitePathParams, CancelWorkspaceMemberInviteVariables, ClientConstructor,
|
|
3687
|
+
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, 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 };
|