@xata.io/client 0.0.0-alpha.vf4b92f1 → 0.0.0-alpha.vf603f80
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 +154 -0
- package/README.md +271 -1
- package/Usage.md +395 -0
- package/dist/index.cjs +652 -253
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +724 -89
- package/dist/index.mjs +623 -254
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -4
- 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 = {
|
@@ -138,6 +141,12 @@ declare type ListBranchesResponse = {
|
|
138
141
|
displayName: string;
|
139
142
|
branches: Branch[];
|
140
143
|
};
|
144
|
+
declare type ListGitBranchesResponse = {
|
145
|
+
mapping: {
|
146
|
+
gitBranch: string;
|
147
|
+
xataBranch: string;
|
148
|
+
}[];
|
149
|
+
};
|
141
150
|
declare type Branch = {
|
142
151
|
name: string;
|
143
152
|
createdAt: DateTime;
|
@@ -186,7 +195,7 @@ declare type Table = {
|
|
186
195
|
*/
|
187
196
|
declare type Column = {
|
188
197
|
name: string;
|
189
|
-
type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object';
|
198
|
+
type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object' | 'datetime';
|
190
199
|
link?: {
|
191
200
|
table: string;
|
192
201
|
};
|
@@ -262,6 +271,21 @@ declare type SortExpression = string[] | {
|
|
262
271
|
[key: string]: SortOrder;
|
263
272
|
}[];
|
264
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';
|
265
289
|
/**
|
266
290
|
* @minProperties 1
|
267
291
|
*/
|
@@ -275,6 +299,10 @@ declare type FilterExpression = {
|
|
275
299
|
} & {
|
276
300
|
[key: string]: FilterColumn;
|
277
301
|
};
|
302
|
+
declare type HighlightExpression = {
|
303
|
+
enabled?: boolean;
|
304
|
+
encodeHTML?: boolean;
|
305
|
+
};
|
278
306
|
declare type FilterList = FilterExpression | FilterExpression[];
|
279
307
|
declare type FilterColumn = FilterColumnIncludes | FilterPredicate | FilterList;
|
280
308
|
/**
|
@@ -360,6 +388,11 @@ declare type XataRecord$1 = {
|
|
360
388
|
xata: {
|
361
389
|
version: number;
|
362
390
|
table?: string;
|
391
|
+
highlight?: {
|
392
|
+
[key: string]: string[] | {
|
393
|
+
[key: string]: any;
|
394
|
+
};
|
395
|
+
};
|
363
396
|
warnings?: string[];
|
364
397
|
};
|
365
398
|
} & {
|
@@ -382,6 +415,7 @@ type schemas_WorkspaceMembers = WorkspaceMembers;
|
|
382
415
|
type schemas_InviteKey = InviteKey;
|
383
416
|
type schemas_ListDatabasesResponse = ListDatabasesResponse;
|
384
417
|
type schemas_ListBranchesResponse = ListBranchesResponse;
|
418
|
+
type schemas_ListGitBranchesResponse = ListGitBranchesResponse;
|
385
419
|
type schemas_Branch = Branch;
|
386
420
|
type schemas_BranchMetadata = BranchMetadata;
|
387
421
|
type schemas_DBBranch = DBBranch;
|
@@ -402,7 +436,10 @@ type schemas_TableMigration = TableMigration;
|
|
402
436
|
type schemas_ColumnMigration = ColumnMigration;
|
403
437
|
type schemas_SortExpression = SortExpression;
|
404
438
|
type schemas_SortOrder = SortOrder;
|
439
|
+
type schemas_FuzzinessExpression = FuzzinessExpression;
|
440
|
+
type schemas_PrefixExpression = PrefixExpression;
|
405
441
|
type schemas_FilterExpression = FilterExpression;
|
442
|
+
type schemas_HighlightExpression = HighlightExpression;
|
406
443
|
type schemas_FilterList = FilterList;
|
407
444
|
type schemas_FilterColumn = FilterColumn;
|
408
445
|
type schemas_FilterColumnIncludes = FilterColumnIncludes;
|
@@ -434,6 +471,7 @@ declare namespace schemas {
|
|
434
471
|
schemas_InviteKey as InviteKey,
|
435
472
|
schemas_ListDatabasesResponse as ListDatabasesResponse,
|
436
473
|
schemas_ListBranchesResponse as ListBranchesResponse,
|
474
|
+
schemas_ListGitBranchesResponse as ListGitBranchesResponse,
|
437
475
|
schemas_Branch as Branch,
|
438
476
|
schemas_BranchMetadata as BranchMetadata,
|
439
477
|
schemas_DBBranch as DBBranch,
|
@@ -454,7 +492,10 @@ declare namespace schemas {
|
|
454
492
|
schemas_ColumnMigration as ColumnMigration,
|
455
493
|
schemas_SortExpression as SortExpression,
|
456
494
|
schemas_SortOrder as SortOrder,
|
495
|
+
schemas_FuzzinessExpression as FuzzinessExpression,
|
496
|
+
schemas_PrefixExpression as PrefixExpression,
|
457
497
|
schemas_FilterExpression as FilterExpression,
|
498
|
+
schemas_HighlightExpression as HighlightExpression,
|
458
499
|
schemas_FilterList as FilterList,
|
459
500
|
schemas_FilterColumn as FilterColumn,
|
460
501
|
schemas_FilterColumnIncludes as FilterColumnIncludes,
|
@@ -844,6 +885,9 @@ declare type InviteWorkspaceMemberError = ErrorWrapper<{
|
|
844
885
|
} | {
|
845
886
|
status: 404;
|
846
887
|
payload: SimpleError;
|
888
|
+
} | {
|
889
|
+
status: 409;
|
890
|
+
payload: SimpleError;
|
847
891
|
}>;
|
848
892
|
declare type InviteWorkspaceMemberRequestBody = {
|
849
893
|
email: string;
|
@@ -857,6 +901,35 @@ declare type InviteWorkspaceMemberVariables = {
|
|
857
901
|
* Invite some user to join the workspace with the given role
|
858
902
|
*/
|
859
903
|
declare const inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<WorkspaceInvite>;
|
904
|
+
declare type UpdateWorkspaceMemberInvitePathParams = {
|
905
|
+
workspaceId: WorkspaceID;
|
906
|
+
inviteId: InviteID;
|
907
|
+
};
|
908
|
+
declare type UpdateWorkspaceMemberInviteError = ErrorWrapper<{
|
909
|
+
status: 400;
|
910
|
+
payload: BadRequestError;
|
911
|
+
} | {
|
912
|
+
status: 401;
|
913
|
+
payload: AuthError;
|
914
|
+
} | {
|
915
|
+
status: 404;
|
916
|
+
payload: SimpleError;
|
917
|
+
} | {
|
918
|
+
status: 422;
|
919
|
+
payload: SimpleError;
|
920
|
+
}>;
|
921
|
+
declare type UpdateWorkspaceMemberInviteRequestBody = {
|
922
|
+
role: Role;
|
923
|
+
};
|
924
|
+
declare type UpdateWorkspaceMemberInviteVariables = {
|
925
|
+
body: UpdateWorkspaceMemberInviteRequestBody;
|
926
|
+
pathParams: UpdateWorkspaceMemberInvitePathParams;
|
927
|
+
} & FetcherExtraProps;
|
928
|
+
/**
|
929
|
+
* This operation provides a way to update an existing invite. Updates are performed in-place; they do not
|
930
|
+
* change the invite link, the expiry time, nor do they re-notify the recipient of the invite.
|
931
|
+
*/
|
932
|
+
declare const updateWorkspaceMemberInvite: (variables: UpdateWorkspaceMemberInviteVariables) => Promise<WorkspaceInvite>;
|
860
933
|
declare type CancelWorkspaceMemberInvitePathParams = {
|
861
934
|
workspaceId: WorkspaceID;
|
862
935
|
inviteId: InviteID;
|
@@ -1010,6 +1083,163 @@ declare type DeleteDatabaseVariables = {
|
|
1010
1083
|
* Delete a database and all of its branches and tables permanently.
|
1011
1084
|
*/
|
1012
1085
|
declare const deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
|
1086
|
+
declare type GetGitBranchesMappingPathParams = {
|
1087
|
+
dbName: DBName;
|
1088
|
+
workspace: string;
|
1089
|
+
};
|
1090
|
+
declare type GetGitBranchesMappingError = ErrorWrapper<{
|
1091
|
+
status: 400;
|
1092
|
+
payload: BadRequestError;
|
1093
|
+
} | {
|
1094
|
+
status: 401;
|
1095
|
+
payload: AuthError;
|
1096
|
+
}>;
|
1097
|
+
declare type GetGitBranchesMappingVariables = {
|
1098
|
+
pathParams: GetGitBranchesMappingPathParams;
|
1099
|
+
} & FetcherExtraProps;
|
1100
|
+
/**
|
1101
|
+
* Lists all the git branches in the mapping, and their associated Xata branches.
|
1102
|
+
*
|
1103
|
+
* Example response:
|
1104
|
+
*
|
1105
|
+
* ```json
|
1106
|
+
* {
|
1107
|
+
* "mappings": [
|
1108
|
+
* {
|
1109
|
+
* "gitBranch": "main",
|
1110
|
+
* "xataBranch": "main"
|
1111
|
+
* },
|
1112
|
+
* {
|
1113
|
+
* "gitBranch": "gitBranch1",
|
1114
|
+
* "xataBranch": "xataBranch1"
|
1115
|
+
* }
|
1116
|
+
* {
|
1117
|
+
* "gitBranch": "xataBranch2",
|
1118
|
+
* "xataBranch": "xataBranch2"
|
1119
|
+
* }
|
1120
|
+
* ]
|
1121
|
+
* }
|
1122
|
+
* ```
|
1123
|
+
*/
|
1124
|
+
declare const getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
|
1125
|
+
declare type AddGitBranchesEntryPathParams = {
|
1126
|
+
dbName: DBName;
|
1127
|
+
workspace: string;
|
1128
|
+
};
|
1129
|
+
declare type AddGitBranchesEntryError = ErrorWrapper<{
|
1130
|
+
status: 400;
|
1131
|
+
payload: BadRequestError;
|
1132
|
+
} | {
|
1133
|
+
status: 401;
|
1134
|
+
payload: AuthError;
|
1135
|
+
}>;
|
1136
|
+
declare type AddGitBranchesEntryResponse = {
|
1137
|
+
warning?: string;
|
1138
|
+
};
|
1139
|
+
declare type AddGitBranchesEntryRequestBody = {
|
1140
|
+
gitBranch: string;
|
1141
|
+
xataBranch: BranchName;
|
1142
|
+
};
|
1143
|
+
declare type AddGitBranchesEntryVariables = {
|
1144
|
+
body: AddGitBranchesEntryRequestBody;
|
1145
|
+
pathParams: AddGitBranchesEntryPathParams;
|
1146
|
+
} & FetcherExtraProps;
|
1147
|
+
/**
|
1148
|
+
* 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.
|
1149
|
+
*
|
1150
|
+
* 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.
|
1151
|
+
*
|
1152
|
+
* Example request:
|
1153
|
+
*
|
1154
|
+
* ```json
|
1155
|
+
* // POST https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches
|
1156
|
+
* {
|
1157
|
+
* "gitBranch": "fix/bug123",
|
1158
|
+
* "xataBranch": "fix_bug"
|
1159
|
+
* }
|
1160
|
+
* ```
|
1161
|
+
*/
|
1162
|
+
declare const addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
|
1163
|
+
declare type RemoveGitBranchesEntryPathParams = {
|
1164
|
+
dbName: DBName;
|
1165
|
+
workspace: string;
|
1166
|
+
};
|
1167
|
+
declare type RemoveGitBranchesEntryQueryParams = {
|
1168
|
+
gitBranch: string;
|
1169
|
+
};
|
1170
|
+
declare type RemoveGitBranchesEntryError = ErrorWrapper<{
|
1171
|
+
status: 400;
|
1172
|
+
payload: BadRequestError;
|
1173
|
+
} | {
|
1174
|
+
status: 401;
|
1175
|
+
payload: AuthError;
|
1176
|
+
}>;
|
1177
|
+
declare type RemoveGitBranchesEntryVariables = {
|
1178
|
+
pathParams: RemoveGitBranchesEntryPathParams;
|
1179
|
+
queryParams: RemoveGitBranchesEntryQueryParams;
|
1180
|
+
} & FetcherExtraProps;
|
1181
|
+
/**
|
1182
|
+
* 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.
|
1183
|
+
*
|
1184
|
+
* Example request:
|
1185
|
+
*
|
1186
|
+
* ```json
|
1187
|
+
* // DELETE https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches?gitBranch=fix%2Fbug123
|
1188
|
+
* ```
|
1189
|
+
*/
|
1190
|
+
declare const removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
|
1191
|
+
declare type ResolveBranchPathParams = {
|
1192
|
+
dbName: DBName;
|
1193
|
+
workspace: string;
|
1194
|
+
};
|
1195
|
+
declare type ResolveBranchQueryParams = {
|
1196
|
+
gitBranch?: string;
|
1197
|
+
fallbackBranch?: string;
|
1198
|
+
};
|
1199
|
+
declare type ResolveBranchError = ErrorWrapper<{
|
1200
|
+
status: 400;
|
1201
|
+
payload: BadRequestError;
|
1202
|
+
} | {
|
1203
|
+
status: 401;
|
1204
|
+
payload: AuthError;
|
1205
|
+
}>;
|
1206
|
+
declare type ResolveBranchResponse = {
|
1207
|
+
branch: string;
|
1208
|
+
reason: {
|
1209
|
+
code: 'FOUND_IN_MAPPING' | 'BRANCH_EXISTS' | 'FALLBACK_BRANCH' | 'DEFAULT_BRANCH';
|
1210
|
+
message: string;
|
1211
|
+
};
|
1212
|
+
};
|
1213
|
+
declare type ResolveBranchVariables = {
|
1214
|
+
pathParams: ResolveBranchPathParams;
|
1215
|
+
queryParams?: ResolveBranchQueryParams;
|
1216
|
+
} & FetcherExtraProps;
|
1217
|
+
/**
|
1218
|
+
* In order to resolve the database branch, the following algorithm is used:
|
1219
|
+
* * 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
|
1220
|
+
* * else, if a Xata branch with the exact same name as `gitBranch` exists, return it
|
1221
|
+
* * else, if `fallbackBranch` is provided and a branch with that name exists, return it
|
1222
|
+
* * else, return the default branch of the DB (`main` or the first branch)
|
1223
|
+
*
|
1224
|
+
* Example call:
|
1225
|
+
*
|
1226
|
+
* ```json
|
1227
|
+
* // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test&fallbackBranch=tsg
|
1228
|
+
* ```
|
1229
|
+
*
|
1230
|
+
* Example response:
|
1231
|
+
*
|
1232
|
+
* ```json
|
1233
|
+
* {
|
1234
|
+
* "branch": "main",
|
1235
|
+
* "reason": {
|
1236
|
+
* "code": "DEFAULT_BRANCH",
|
1237
|
+
* "message": "Default branch for this database (main)"
|
1238
|
+
* }
|
1239
|
+
* }
|
1240
|
+
* ```
|
1241
|
+
*/
|
1242
|
+
declare const resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
|
1013
1243
|
declare type GetBranchDetailsPathParams = {
|
1014
1244
|
dbBranchName: DBBranchName;
|
1015
1245
|
workspace: string;
|
@@ -1653,6 +1883,9 @@ declare type BulkInsertTableRecordsError = ErrorWrapper<{
|
|
1653
1883
|
} | {
|
1654
1884
|
status: 404;
|
1655
1885
|
payload: SimpleError;
|
1886
|
+
} | {
|
1887
|
+
status: 422;
|
1888
|
+
payload: SimpleError;
|
1656
1889
|
}>;
|
1657
1890
|
declare type BulkInsertTableRecordsResponse = {
|
1658
1891
|
recordIDs: string[];
|
@@ -1750,7 +1983,11 @@ declare type QueryTableVariables = {
|
|
1750
1983
|
* "link": {
|
1751
1984
|
* "table": "users"
|
1752
1985
|
* }
|
1753
|
-
* }
|
1986
|
+
* },
|
1987
|
+
* {
|
1988
|
+
* "name": "foundedDate",
|
1989
|
+
* "type": "datetime"
|
1990
|
+
* },
|
1754
1991
|
* ]
|
1755
1992
|
* },
|
1756
1993
|
* {
|
@@ -1897,7 +2134,8 @@ declare type QueryTableVariables = {
|
|
1897
2134
|
* "version": 0
|
1898
2135
|
* },
|
1899
2136
|
* "name": "first team",
|
1900
|
-
* "code": "A1"
|
2137
|
+
* "code": "A1",
|
2138
|
+
* "foundedDate": "2020-03-04T10:43:54.32Z"
|
1901
2139
|
* }
|
1902
2140
|
* }
|
1903
2141
|
* ```
|
@@ -1912,7 +2150,7 @@ declare type QueryTableVariables = {
|
|
1912
2150
|
* `$none`, etc.
|
1913
2151
|
*
|
1914
2152
|
* All operators start with an `$` to differentiate them from column names
|
1915
|
-
* (which are not allowed to start with
|
2153
|
+
* (which are not allowed to start with a dollar sign).
|
1916
2154
|
*
|
1917
2155
|
* #### Exact matching and control operators
|
1918
2156
|
*
|
@@ -2092,12 +2330,18 @@ declare type QueryTableVariables = {
|
|
2092
2330
|
* {
|
2093
2331
|
* "filter": {
|
2094
2332
|
* "<column_name>": {
|
2095
|
-
* "$pattern": "v*
|
2333
|
+
* "$pattern": "v*alu?"
|
2096
2334
|
* }
|
2097
2335
|
* }
|
2098
2336
|
* }
|
2099
2337
|
* ```
|
2100
2338
|
*
|
2339
|
+
* The `$pattern` operator accepts two wildcard characters:
|
2340
|
+
* * `*` matches zero or more characters
|
2341
|
+
* * `?` matches exactly one character
|
2342
|
+
*
|
2343
|
+
* 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.
|
2344
|
+
*
|
2101
2345
|
* We could also have `$endsWith` and `$startsWith` operators:
|
2102
2346
|
*
|
2103
2347
|
* ```json
|
@@ -2113,7 +2357,7 @@ declare type QueryTableVariables = {
|
|
2113
2357
|
* }
|
2114
2358
|
* ```
|
2115
2359
|
*
|
2116
|
-
* #### Numeric ranges
|
2360
|
+
* #### Numeric or datetime ranges
|
2117
2361
|
*
|
2118
2362
|
* ```json
|
2119
2363
|
* {
|
@@ -2125,7 +2369,18 @@ declare type QueryTableVariables = {
|
|
2125
2369
|
* }
|
2126
2370
|
* }
|
2127
2371
|
* ```
|
2128
|
-
*
|
2372
|
+
* Date ranges support the same operators, with the date using the format defined in
|
2373
|
+
* [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339):
|
2374
|
+
* ```json
|
2375
|
+
* {
|
2376
|
+
* "filter": {
|
2377
|
+
* "<column_name>": {
|
2378
|
+
* "$gt": "2019-10-12T07:20:50.52Z",
|
2379
|
+
* "$lt": "2021-10-12T07:20:50.52Z"
|
2380
|
+
* }
|
2381
|
+
* }
|
2382
|
+
* }
|
2383
|
+
* ```
|
2129
2384
|
* The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
|
2130
2385
|
*
|
2131
2386
|
* #### Negations
|
@@ -2393,6 +2648,40 @@ declare type QueryTableVariables = {
|
|
2393
2648
|
* ```
|
2394
2649
|
*/
|
2395
2650
|
declare const queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
2651
|
+
declare type SearchTablePathParams = {
|
2652
|
+
dbBranchName: DBBranchName;
|
2653
|
+
tableName: TableName;
|
2654
|
+
workspace: string;
|
2655
|
+
};
|
2656
|
+
declare type SearchTableError = ErrorWrapper<{
|
2657
|
+
status: 400;
|
2658
|
+
payload: BadRequestError;
|
2659
|
+
} | {
|
2660
|
+
status: 401;
|
2661
|
+
payload: AuthError;
|
2662
|
+
} | {
|
2663
|
+
status: 404;
|
2664
|
+
payload: SimpleError;
|
2665
|
+
}>;
|
2666
|
+
declare type SearchTableRequestBody = {
|
2667
|
+
query: string;
|
2668
|
+
fuzziness?: FuzzinessExpression;
|
2669
|
+
prefix?: PrefixExpression;
|
2670
|
+
filter?: FilterExpression;
|
2671
|
+
highlight?: HighlightExpression;
|
2672
|
+
};
|
2673
|
+
declare type SearchTableVariables = {
|
2674
|
+
body: SearchTableRequestBody;
|
2675
|
+
pathParams: SearchTablePathParams;
|
2676
|
+
} & FetcherExtraProps;
|
2677
|
+
/**
|
2678
|
+
* Run a free text search operation in a particular table.
|
2679
|
+
*
|
2680
|
+
* 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:
|
2681
|
+
* * filters `$contains`, `$startsWith`, `$endsWith` don't work on columns of type `text`
|
2682
|
+
* * filtering on columns of type `multiple` is currently unsupported
|
2683
|
+
*/
|
2684
|
+
declare const searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
|
2396
2685
|
declare type SearchBranchPathParams = {
|
2397
2686
|
dbBranchName: DBBranchName;
|
2398
2687
|
workspace: string;
|
@@ -2408,9 +2697,13 @@ declare type SearchBranchError = ErrorWrapper<{
|
|
2408
2697
|
payload: SimpleError;
|
2409
2698
|
}>;
|
2410
2699
|
declare type SearchBranchRequestBody = {
|
2411
|
-
tables?: string
|
2700
|
+
tables?: (string | {
|
2701
|
+
table: string;
|
2702
|
+
filter?: FilterExpression;
|
2703
|
+
})[];
|
2412
2704
|
query: string;
|
2413
|
-
fuzziness?:
|
2705
|
+
fuzziness?: FuzzinessExpression;
|
2706
|
+
highlight?: HighlightExpression;
|
2414
2707
|
};
|
2415
2708
|
declare type SearchBranchVariables = {
|
2416
2709
|
body: SearchBranchRequestBody;
|
@@ -2439,6 +2732,7 @@ declare const operationsByTag: {
|
|
2439
2732
|
updateWorkspaceMemberRole: (variables: UpdateWorkspaceMemberRoleVariables) => Promise<undefined>;
|
2440
2733
|
removeWorkspaceMember: (variables: RemoveWorkspaceMemberVariables) => Promise<undefined>;
|
2441
2734
|
inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<WorkspaceInvite>;
|
2735
|
+
updateWorkspaceMemberInvite: (variables: UpdateWorkspaceMemberInviteVariables) => Promise<WorkspaceInvite>;
|
2442
2736
|
cancelWorkspaceMemberInvite: (variables: CancelWorkspaceMemberInviteVariables) => Promise<undefined>;
|
2443
2737
|
resendWorkspaceMemberInvite: (variables: ResendWorkspaceMemberInviteVariables) => Promise<undefined>;
|
2444
2738
|
acceptWorkspaceMemberInvite: (variables: AcceptWorkspaceMemberInviteVariables) => Promise<undefined>;
|
@@ -2447,6 +2741,10 @@ declare const operationsByTag: {
|
|
2447
2741
|
getDatabaseList: (variables: GetDatabaseListVariables) => Promise<ListDatabasesResponse>;
|
2448
2742
|
createDatabase: (variables: CreateDatabaseVariables) => Promise<CreateDatabaseResponse>;
|
2449
2743
|
deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
|
2744
|
+
getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
|
2745
|
+
addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
|
2746
|
+
removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
|
2747
|
+
resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
|
2450
2748
|
};
|
2451
2749
|
branch: {
|
2452
2750
|
getBranchList: (variables: GetBranchListVariables) => Promise<ListBranchesResponse>;
|
@@ -2481,6 +2779,7 @@ declare const operationsByTag: {
|
|
2481
2779
|
getRecord: (variables: GetRecordVariables) => Promise<XataRecord$1>;
|
2482
2780
|
bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
|
2483
2781
|
queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
2782
|
+
searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
|
2484
2783
|
searchBranch: (variables: SearchBranchVariables) => Promise<SearchResponse>;
|
2485
2784
|
};
|
2486
2785
|
};
|
@@ -2532,6 +2831,7 @@ declare class WorkspaceApi {
|
|
2532
2831
|
updateWorkspaceMemberRole(workspaceId: WorkspaceID, userId: UserID, role: Role): Promise<void>;
|
2533
2832
|
removeWorkspaceMember(workspaceId: WorkspaceID, userId: UserID): Promise<void>;
|
2534
2833
|
inviteWorkspaceMember(workspaceId: WorkspaceID, email: string, role: Role): Promise<WorkspaceInvite>;
|
2834
|
+
updateWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID, role: Role): Promise<WorkspaceInvite>;
|
2535
2835
|
cancelWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID): Promise<void>;
|
2536
2836
|
resendWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID): Promise<void>;
|
2537
2837
|
acceptWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteKey: InviteKey): Promise<void>;
|
@@ -2542,6 +2842,10 @@ declare class DatabaseApi {
|
|
2542
2842
|
getDatabaseList(workspace: WorkspaceID): Promise<ListDatabasesResponse>;
|
2543
2843
|
createDatabase(workspace: WorkspaceID, dbName: DBName, options?: CreateDatabaseRequestBody): Promise<CreateDatabaseResponse>;
|
2544
2844
|
deleteDatabase(workspace: WorkspaceID, dbName: DBName): Promise<void>;
|
2845
|
+
getGitBranchesMapping(workspace: WorkspaceID, dbName: DBName): Promise<ListGitBranchesResponse>;
|
2846
|
+
addGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, body: AddGitBranchesEntryRequestBody): Promise<AddGitBranchesEntryResponse>;
|
2847
|
+
removeGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<void>;
|
2848
|
+
resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch?: string, fallbackBranch?: string): Promise<ResolveBranchResponse>;
|
2545
2849
|
}
|
2546
2850
|
declare class BranchApi {
|
2547
2851
|
private extraProps;
|
@@ -2582,6 +2886,7 @@ declare class RecordsApi {
|
|
2582
2886
|
getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: GetRecordRequestBody): Promise<XataRecord$1>;
|
2583
2887
|
bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[]): Promise<BulkInsertTableRecordsResponse>;
|
2584
2888
|
queryTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: QueryTableRequestBody): Promise<QueryResponse>;
|
2889
|
+
searchTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: SearchTableRequestBody): Promise<SearchResponse>;
|
2585
2890
|
searchBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, query: SearchBranchRequestBody): Promise<SearchResponse>;
|
2586
2891
|
}
|
2587
2892
|
|
@@ -2603,20 +2908,20 @@ declare type RequiredBy<T, K extends keyof T> = T & {
|
|
2603
2908
|
};
|
2604
2909
|
declare type GetArrayInnerType<T extends readonly any[]> = T[number];
|
2605
2910
|
declare type SingleOrArray<T> = T | T[];
|
2606
|
-
declare type
|
2911
|
+
declare type OmitBy<T, K extends keyof T> = T extends any ? Omit<T, K> : never;
|
2607
2912
|
|
2608
2913
|
declare type SelectableColumn<O, RecursivePath extends any[] = []> = '*' | 'id' | DataProps<O> | NestedColumns<O, RecursivePath>;
|
2609
2914
|
declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord & UnionToIntersection<Values<{
|
2610
2915
|
[K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord;
|
2611
2916
|
}>>;
|
2612
|
-
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
|
2613
|
-
V: ValueAtColumn<
|
2614
|
-
} : never
|
2917
|
+
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> ? {
|
2918
|
+
V: ValueAtColumn<Item, V>;
|
2919
|
+
} : never : O[K] : never> : never : never;
|
2615
2920
|
declare type MAX_RECURSION = 5;
|
2616
2921
|
declare type NestedColumns<O, RecursivePath extends any[]> = RecursivePath['length'] extends MAX_RECURSION ? never : If<IsObject<O>, Values<{
|
2617
|
-
[K in DataProps<O>]:
|
2618
|
-
If<IsObject<
|
2619
|
-
K
|
2922
|
+
[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
|
2923
|
+
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
|
2924
|
+
K>> : never;
|
2620
2925
|
}>, never>;
|
2621
2926
|
declare type DataProps<O> = Exclude<StringKeys<O>, StringKeys<XataRecord>>;
|
2622
2927
|
declare type NestedValueAtColumn<O, Key extends SelectableColumn<O>> = Key extends `${infer N}.${infer M}` ? N extends DataProps<O> ? {
|
@@ -2643,16 +2948,11 @@ interface BaseData {
|
|
2643
2948
|
/**
|
2644
2949
|
* Represents a persisted record from the database.
|
2645
2950
|
*/
|
2646
|
-
interface XataRecord extends Identifiable {
|
2951
|
+
interface XataRecord<ExtraMetadata extends Record<string, unknown> = Record<string, unknown>> extends Identifiable {
|
2647
2952
|
/**
|
2648
|
-
*
|
2953
|
+
* Get metadata of this record.
|
2649
2954
|
*/
|
2650
|
-
|
2651
|
-
/**
|
2652
|
-
* Number that is increased every time the record is updated.
|
2653
|
-
*/
|
2654
|
-
version: number;
|
2655
|
-
};
|
2955
|
+
getMetadata(): XataRecordMetadata & ExtraMetadata;
|
2656
2956
|
/**
|
2657
2957
|
* Retrieves a refreshed copy of the current record from the database.
|
2658
2958
|
*/
|
@@ -2660,7 +2960,7 @@ interface XataRecord extends Identifiable {
|
|
2660
2960
|
/**
|
2661
2961
|
* Performs a partial update of the current record. On success a new object is
|
2662
2962
|
* returned and the current object is not mutated.
|
2663
|
-
* @param
|
2963
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
2664
2964
|
* @returns A new record containing the latest values for all the columns of the current record.
|
2665
2965
|
*/
|
2666
2966
|
update(partialUpdate: Partial<EditableData<Omit<this, keyof XataRecord>>>): Promise<Readonly<SelectedPick<this, ['*']>>>;
|
@@ -2679,19 +2979,26 @@ declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update
|
|
2679
2979
|
/**
|
2680
2980
|
* Performs a partial update of the current record. On success a new object is
|
2681
2981
|
* returned and the current object is not mutated.
|
2682
|
-
* @param
|
2982
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
2683
2983
|
* @returns A new record containing the latest values for all the columns of the current record.
|
2684
2984
|
*/
|
2685
2985
|
update(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
2686
2986
|
};
|
2987
|
+
declare type XataRecordMetadata = {
|
2988
|
+
/**
|
2989
|
+
* Number that is increased every time the record is updated.
|
2990
|
+
*/
|
2991
|
+
version: number;
|
2992
|
+
warnings?: string[];
|
2993
|
+
};
|
2687
2994
|
declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
|
2688
2995
|
declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
|
2689
2996
|
declare type EditableData<O extends BaseData> = {
|
2690
2997
|
[K in keyof O]: O[K] extends XataRecord ? {
|
2691
2998
|
id: string;
|
2692
|
-
} : NonNullable<O[K]> extends XataRecord ? {
|
2999
|
+
} | string : NonNullable<O[K]> extends XataRecord ? {
|
2693
3000
|
id: string;
|
2694
|
-
} | null | undefined : O[K];
|
3001
|
+
} | string | null | undefined : O[K];
|
2695
3002
|
};
|
2696
3003
|
|
2697
3004
|
/**
|
@@ -2767,8 +3074,8 @@ declare type ValueTypeFilters<T> = T | T extends string ? StringTypeFilter : T e
|
|
2767
3074
|
],
|
2768
3075
|
}
|
2769
3076
|
*/
|
2770
|
-
declare type AggregatorFilter<
|
2771
|
-
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<
|
3077
|
+
declare type AggregatorFilter<T> = {
|
3078
|
+
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<T>>;
|
2772
3079
|
};
|
2773
3080
|
/**
|
2774
3081
|
* Existance filter
|
@@ -2783,10 +3090,10 @@ declare type BaseApiFilter<Record> = PropertyAccessFilter<Record> | AggregatorFi
|
|
2783
3090
|
* Injects the Api filters on nested properties
|
2784
3091
|
* Example: { filter: { settings: { plan: { $any: ['free', 'trial'] } } } }
|
2785
3092
|
*/
|
2786
|
-
declare type NestedApiFilter<T> =
|
3093
|
+
declare type NestedApiFilter<T> = {
|
2787
3094
|
[key in keyof T]?: T[key] extends Record<string, any> ? SingleOrArray<Filter<T[key]>> : PropertyFilter<T[key]>;
|
2788
|
-
}
|
2789
|
-
declare type Filter<
|
3095
|
+
};
|
3096
|
+
declare type Filter<T> = T extends Record<string, any> ? BaseApiFilter<T> | NestedApiFilter<T> : PropertyFilter<T>;
|
2790
3097
|
|
2791
3098
|
declare type SortDirection = 'asc' | 'desc';
|
2792
3099
|
declare type SortFilterExtended<T extends XataRecord> = {
|
@@ -2798,13 +3105,21 @@ declare type SortFilterBase<T extends XataRecord> = {
|
|
2798
3105
|
[Key in StringKeys<T>]: SortDirection;
|
2799
3106
|
};
|
2800
3107
|
|
2801
|
-
declare type
|
2802
|
-
page?: PaginationOptions;
|
3108
|
+
declare type BaseOptions<T extends XataRecord> = {
|
2803
3109
|
columns?: NonEmptyArray<SelectableColumn<T>>;
|
3110
|
+
cache?: number;
|
3111
|
+
};
|
3112
|
+
declare type CursorQueryOptions = {
|
3113
|
+
pagination?: CursorNavigationOptions & OffsetNavigationOptions;
|
3114
|
+
filter?: never;
|
3115
|
+
sort?: never;
|
3116
|
+
};
|
3117
|
+
declare type OffsetQueryOptions<T extends XataRecord> = {
|
3118
|
+
pagination?: OffsetNavigationOptions;
|
2804
3119
|
filter?: FilterExpression;
|
2805
3120
|
sort?: SortFilter<T> | SortFilter<T>[];
|
2806
|
-
cache?: number;
|
2807
3121
|
};
|
3122
|
+
declare type QueryOptions<T extends XataRecord> = BaseOptions<T> & (CursorQueryOptions | OffsetQueryOptions<T>);
|
2808
3123
|
/**
|
2809
3124
|
* Query objects contain the information of all filters, sorting, etc. to be included in the database query.
|
2810
3125
|
*
|
@@ -2814,8 +3129,8 @@ declare type QueryOptions<T extends XataRecord> = {
|
|
2814
3129
|
declare class Query<Record extends XataRecord, Result extends XataRecord = Record> implements Paginable<Record, Result> {
|
2815
3130
|
#private;
|
2816
3131
|
readonly meta: PaginationQueryMeta;
|
2817
|
-
readonly records: Result
|
2818
|
-
constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>,
|
3132
|
+
readonly records: RecordArray<Result>;
|
3133
|
+
constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, rawParent?: Partial<QueryOptions<Record>>);
|
2819
3134
|
getQueryOptions(): QueryOptions<Record>;
|
2820
3135
|
key(): string;
|
2821
3136
|
/**
|
@@ -2847,18 +3162,28 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
2847
3162
|
*
|
2848
3163
|
* ```
|
2849
3164
|
* query.filter("columnName", columnValue)
|
2850
|
-
* query.filter(
|
2851
|
-
*
|
2852
|
-
*
|
3165
|
+
* query.filter("columnName", operator(columnValue)) // Use gt, gte, lt, lte, startsWith,...
|
3166
|
+
* ```
|
3167
|
+
*
|
3168
|
+
* @param column The name of the column to filter.
|
3169
|
+
* @param value The value to filter.
|
3170
|
+
* @returns A new Query object.
|
3171
|
+
*/
|
3172
|
+
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
|
3173
|
+
/**
|
3174
|
+
* Builds a new query object adding one or more constraints. Examples:
|
3175
|
+
*
|
3176
|
+
* ```
|
3177
|
+
* query.filter({ "columnName": columnValue })
|
2853
3178
|
* query.filter({
|
2854
3179
|
* "columnName": operator(columnValue) // Use gt, gte, lt, lte, startsWith,...
|
2855
3180
|
* })
|
2856
3181
|
* ```
|
2857
3182
|
*
|
3183
|
+
* @param filters A filter object
|
2858
3184
|
* @returns A new Query object.
|
2859
3185
|
*/
|
2860
3186
|
filter(filters: Filter<Record>): Query<Record, Result>;
|
2861
|
-
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
|
2862
3187
|
/**
|
2863
3188
|
* Builds a new query with a new sort option.
|
2864
3189
|
* @param column The column name.
|
@@ -2872,48 +3197,148 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
2872
3197
|
* @returns A new Query object.
|
2873
3198
|
*/
|
2874
3199
|
select<K extends SelectableColumn<Record>>(columns: NonEmptyArray<K>): Query<Record, SelectedPick<Record, NonEmptyArray<K>>>;
|
3200
|
+
/**
|
3201
|
+
* Get paginated results
|
3202
|
+
*
|
3203
|
+
* @returns A page of results
|
3204
|
+
*/
|
2875
3205
|
getPaginated(): Promise<Page<Record, Result>>;
|
2876
|
-
|
3206
|
+
/**
|
3207
|
+
* Get paginated results
|
3208
|
+
*
|
3209
|
+
* @param options Pagination options
|
3210
|
+
* @returns A page of results
|
3211
|
+
*/
|
3212
|
+
getPaginated(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
|
3213
|
+
/**
|
3214
|
+
* Get paginated results
|
3215
|
+
*
|
3216
|
+
* @param options Pagination options
|
3217
|
+
* @returns A page of results
|
3218
|
+
*/
|
2877
3219
|
getPaginated<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<Page<Record, SelectedPick<Record, typeof options['columns']>>>;
|
3220
|
+
/**
|
3221
|
+
* Get results in an iterator
|
3222
|
+
*
|
3223
|
+
* @async
|
3224
|
+
* @returns Async interable of results
|
3225
|
+
*/
|
2878
3226
|
[Symbol.asyncIterator](): AsyncIterableIterator<Result>;
|
2879
|
-
|
2880
|
-
|
2881
|
-
|
3227
|
+
/**
|
3228
|
+
* Build an iterator of results
|
3229
|
+
*
|
3230
|
+
* @returns Async generator of results array
|
3231
|
+
*/
|
3232
|
+
getIterator(): AsyncGenerator<Result[]>;
|
3233
|
+
/**
|
3234
|
+
* Build an iterator of results
|
3235
|
+
*
|
3236
|
+
* @param options Pagination options with batchSize
|
3237
|
+
* @returns Async generator of results array
|
3238
|
+
*/
|
3239
|
+
getIterator(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
|
3240
|
+
batchSize?: number;
|
3241
|
+
}): AsyncGenerator<Result[]>;
|
3242
|
+
/**
|
3243
|
+
* Build an iterator of results
|
3244
|
+
*
|
3245
|
+
* @param options Pagination options with batchSize
|
3246
|
+
* @returns Async generator of results array
|
3247
|
+
*/
|
3248
|
+
getIterator<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
|
3249
|
+
batchSize?: number;
|
3250
|
+
}>(options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
|
3251
|
+
/**
|
3252
|
+
* Performs the query in the database and returns a set of results.
|
3253
|
+
* @returns An array of records from the database.
|
3254
|
+
*/
|
3255
|
+
getMany(): Promise<RecordArray<Result>>;
|
3256
|
+
/**
|
3257
|
+
* Performs the query in the database and returns a set of results.
|
3258
|
+
* @param options Additional options to be used when performing the query.
|
3259
|
+
* @returns An array of records from the database.
|
3260
|
+
*/
|
3261
|
+
getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<RecordArray<SelectedPick<Record, typeof options['columns']>>>;
|
2882
3262
|
/**
|
2883
3263
|
* Performs the query in the database and returns a set of results.
|
2884
3264
|
* @param options Additional options to be used when performing the query.
|
2885
3265
|
* @returns An array of records from the database.
|
2886
3266
|
*/
|
2887
|
-
getMany(): Promise<Result
|
2888
|
-
|
2889
|
-
|
3267
|
+
getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<RecordArray<Result>>;
|
3268
|
+
/**
|
3269
|
+
* Performs the query in the database and returns all the results.
|
3270
|
+
* Warning: If there are a large number of results, this method can have performance implications.
|
3271
|
+
* @returns An array of records from the database.
|
3272
|
+
*/
|
3273
|
+
getAll(): Promise<Result[]>;
|
2890
3274
|
/**
|
2891
3275
|
* Performs the query in the database and returns all the results.
|
2892
3276
|
* Warning: If there are a large number of results, this method can have performance implications.
|
2893
3277
|
* @param options Additional options to be used when performing the query.
|
2894
3278
|
* @returns An array of records from the database.
|
2895
3279
|
*/
|
2896
|
-
getAll
|
2897
|
-
|
2898
|
-
|
3280
|
+
getAll<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
|
3281
|
+
batchSize?: number;
|
3282
|
+
}>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
|
2899
3283
|
/**
|
2900
|
-
* Performs the query in the database and returns the
|
3284
|
+
* Performs the query in the database and returns all the results.
|
3285
|
+
* Warning: If there are a large number of results, this method can have performance implications.
|
2901
3286
|
* @param options Additional options to be used when performing the query.
|
3287
|
+
* @returns An array of records from the database.
|
3288
|
+
*/
|
3289
|
+
getAll(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
|
3290
|
+
batchSize?: number;
|
3291
|
+
}): Promise<Result[]>;
|
3292
|
+
/**
|
3293
|
+
* Performs the query in the database and returns the first result.
|
2902
3294
|
* @returns The first record that matches the query, or null if no record matched the query.
|
2903
3295
|
*/
|
2904
3296
|
getFirst(): Promise<Result | null>;
|
2905
|
-
|
2906
|
-
|
3297
|
+
/**
|
3298
|
+
* Performs the query in the database and returns the first result.
|
3299
|
+
* @param options Additional options to be used when performing the query.
|
3300
|
+
* @returns The first record that matches the query, or null if no record matched the query.
|
3301
|
+
*/
|
3302
|
+
getFirst<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
|
3303
|
+
/**
|
3304
|
+
* Performs the query in the database and returns the first result.
|
3305
|
+
* @param options Additional options to be used when performing the query.
|
3306
|
+
* @returns The first record that matches the query, or null if no record matched the query.
|
3307
|
+
*/
|
3308
|
+
getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
|
2907
3309
|
/**
|
2908
3310
|
* Builds a new query object adding a cache TTL in milliseconds.
|
2909
3311
|
* @param ttl The cache TTL in milliseconds.
|
2910
3312
|
* @returns A new Query object.
|
2911
3313
|
*/
|
2912
3314
|
cache(ttl: number): Query<Record, Result>;
|
3315
|
+
/**
|
3316
|
+
* Retrieve next page of records
|
3317
|
+
*
|
3318
|
+
* @returns A new page object.
|
3319
|
+
*/
|
2913
3320
|
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3321
|
+
/**
|
3322
|
+
* Retrieve previous page of records
|
3323
|
+
*
|
3324
|
+
* @returns A new page object
|
3325
|
+
*/
|
2914
3326
|
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3327
|
+
/**
|
3328
|
+
* Retrieve first page of records
|
3329
|
+
*
|
3330
|
+
* @returns A new page object
|
3331
|
+
*/
|
2915
3332
|
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3333
|
+
/**
|
3334
|
+
* Retrieve last page of records
|
3335
|
+
*
|
3336
|
+
* @returns A new page object
|
3337
|
+
*/
|
2916
3338
|
lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3339
|
+
/**
|
3340
|
+
* @returns Boolean indicating if there is a next page
|
3341
|
+
*/
|
2917
3342
|
hasNextPage(): boolean;
|
2918
3343
|
}
|
2919
3344
|
|
@@ -2925,7 +3350,7 @@ declare type PaginationQueryMeta = {
|
|
2925
3350
|
};
|
2926
3351
|
interface Paginable<Record extends XataRecord, Result extends XataRecord = Record> {
|
2927
3352
|
meta: PaginationQueryMeta;
|
2928
|
-
records: Result
|
3353
|
+
records: RecordArray<Result>;
|
2929
3354
|
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2930
3355
|
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2931
3356
|
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
@@ -2945,7 +3370,7 @@ declare class Page<Record extends XataRecord, Result extends XataRecord = Record
|
|
2945
3370
|
/**
|
2946
3371
|
* The set of results for this page.
|
2947
3372
|
*/
|
2948
|
-
readonly records: Result
|
3373
|
+
readonly records: RecordArray<Result>;
|
2949
3374
|
constructor(query: Query<Record, Result>, meta: PaginationQueryMeta, records?: Result[]);
|
2950
3375
|
/**
|
2951
3376
|
* Retrieves the next page of results.
|
@@ -2993,38 +3418,89 @@ declare type OffsetNavigationOptions = {
|
|
2993
3418
|
size?: number;
|
2994
3419
|
offset?: number;
|
2995
3420
|
};
|
2996
|
-
declare type PaginationOptions = CursorNavigationOptions & OffsetNavigationOptions;
|
2997
3421
|
declare const PAGINATION_MAX_SIZE = 200;
|
2998
|
-
declare const PAGINATION_DEFAULT_SIZE =
|
3422
|
+
declare const PAGINATION_DEFAULT_SIZE = 20;
|
2999
3423
|
declare const PAGINATION_MAX_OFFSET = 800;
|
3000
3424
|
declare const PAGINATION_DEFAULT_OFFSET = 0;
|
3425
|
+
declare function isCursorPaginationOptions(options: Record<string, unknown> | undefined | null): options is CursorNavigationOptions;
|
3426
|
+
declare class RecordArray<Result extends XataRecord> extends Array<Result> {
|
3427
|
+
#private;
|
3428
|
+
constructor(page: Paginable<any, Result>, overrideRecords?: Result[]);
|
3429
|
+
static parseConstructorParams(...args: any[]): any[];
|
3430
|
+
toArray(): Result[];
|
3431
|
+
map<U>(callbackfn: (value: Result, index: number, array: Result[]) => U, thisArg?: any): U[];
|
3432
|
+
/**
|
3433
|
+
* Retrieve next page of records
|
3434
|
+
*
|
3435
|
+
* @returns A new array of objects
|
3436
|
+
*/
|
3437
|
+
nextPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3438
|
+
/**
|
3439
|
+
* Retrieve previous page of records
|
3440
|
+
*
|
3441
|
+
* @returns A new array of objects
|
3442
|
+
*/
|
3443
|
+
previousPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3444
|
+
/**
|
3445
|
+
* Retrieve first page of records
|
3446
|
+
*
|
3447
|
+
* @returns A new array of objects
|
3448
|
+
*/
|
3449
|
+
firstPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3450
|
+
/**
|
3451
|
+
* Retrieve last page of records
|
3452
|
+
*
|
3453
|
+
* @returns A new array of objects
|
3454
|
+
*/
|
3455
|
+
lastPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3456
|
+
/**
|
3457
|
+
* @returns Boolean indicating if there is a next page
|
3458
|
+
*/
|
3459
|
+
hasNextPage(): boolean;
|
3460
|
+
}
|
3001
3461
|
|
3002
|
-
declare type TableLink = string[];
|
3003
|
-
declare type LinkDictionary = Dictionary<TableLink[]>;
|
3004
3462
|
/**
|
3005
3463
|
* Common interface for performing operations on a table.
|
3006
3464
|
*/
|
3007
3465
|
declare abstract class Repository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, Readonly<SelectedPick<Record, ['*']>>> {
|
3008
|
-
abstract create(object: EditableData<Data> & Partial<Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3466
|
+
abstract create(object: Omit<EditableData<Data>, 'id'> & Partial<Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3009
3467
|
/**
|
3010
3468
|
* Creates a single record in the table with a unique id.
|
3011
3469
|
* @param id The unique id.
|
3012
3470
|
* @param object Object containing the column names with their values to be stored in the table.
|
3013
3471
|
* @returns The full persisted record.
|
3014
3472
|
*/
|
3015
|
-
abstract create(id: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3473
|
+
abstract create(id: string, object: Omit<EditableData<Data>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3016
3474
|
/**
|
3017
3475
|
* Creates multiple records in the table.
|
3018
3476
|
* @param objects Array of objects with the column names and the values to be stored in the table.
|
3019
3477
|
* @returns Array of the persisted records.
|
3020
3478
|
*/
|
3021
|
-
abstract create(objects: Array<EditableData<Data> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
|
3479
|
+
abstract create(objects: Array<Omit<EditableData<Data>, 'id'> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
|
3022
3480
|
/**
|
3023
3481
|
* Queries a single record from the table given its unique id.
|
3024
3482
|
* @param id The unique id.
|
3025
3483
|
* @returns The persisted record for the given id or null if the record could not be found.
|
3026
3484
|
*/
|
3027
3485
|
abstract read(id: string): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
|
3486
|
+
/**
|
3487
|
+
* Queries multiple records from the table given their unique id.
|
3488
|
+
* @param ids The unique ids array.
|
3489
|
+
* @returns The persisted records for the given ids (if a record could not be found it is not returned).
|
3490
|
+
*/
|
3491
|
+
abstract read(ids: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3492
|
+
/**
|
3493
|
+
* Queries a single record from the table by the id in the object.
|
3494
|
+
* @param object Object containing the id of the record.
|
3495
|
+
* @returns The persisted record for the given id or null if the record could not be found.
|
3496
|
+
*/
|
3497
|
+
abstract read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
|
3498
|
+
/**
|
3499
|
+
* Queries multiple records from the table by the ids in the objects.
|
3500
|
+
* @param objects Array of objects containing the ids of the records.
|
3501
|
+
* @returns The persisted records for the given ids (if a record could not be found it is not returned).
|
3502
|
+
*/
|
3503
|
+
abstract read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3028
3504
|
/**
|
3029
3505
|
* Partially update a single record.
|
3030
3506
|
* @param object An object with its id and the columns to be updated.
|
@@ -3058,7 +3534,7 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
3058
3534
|
* @param object The column names and the values to be persisted.
|
3059
3535
|
* @returns The full persisted record.
|
3060
3536
|
*/
|
3061
|
-
abstract createOrUpdate(id: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3537
|
+
abstract createOrUpdate(id: string, object: Omit<EditableData<Data>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3062
3538
|
/**
|
3063
3539
|
* Creates or updates a single record. If a record exists with the given id,
|
3064
3540
|
* it will be update, otherwise a new record will be created.
|
@@ -3097,7 +3573,9 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
3097
3573
|
* @returns The found records.
|
3098
3574
|
*/
|
3099
3575
|
abstract search(query: string, options?: {
|
3100
|
-
fuzziness?:
|
3576
|
+
fuzziness?: FuzzinessExpression;
|
3577
|
+
highlight?: HighlightExpression;
|
3578
|
+
filter?: Filter<Record>;
|
3101
3579
|
}): Promise<SelectedPick<Record, ['*']>[]>;
|
3102
3580
|
abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
3103
3581
|
}
|
@@ -3106,14 +3584,17 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
|
|
3106
3584
|
db: SchemaPluginResult<any>;
|
3107
3585
|
constructor(options: {
|
3108
3586
|
table: string;
|
3109
|
-
links?: LinkDictionary;
|
3110
3587
|
db: SchemaPluginResult<any>;
|
3111
3588
|
pluginOptions: XataPluginOptions;
|
3589
|
+
schemaTables?: Table[];
|
3112
3590
|
});
|
3113
|
-
create(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']
|
3114
|
-
create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']
|
3115
|
-
create(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']
|
3591
|
+
create(object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3592
|
+
create(recordId: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3593
|
+
create(objects: EditableData<Data>[]): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
|
3116
3594
|
read(recordId: string): Promise<SelectedPick<Record, ['*']> | null>;
|
3595
|
+
read(recordIds: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3596
|
+
read(object: Identifiable): Promise<SelectedPick<Record, ['*']> | null>;
|
3597
|
+
read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3117
3598
|
update(object: Partial<EditableData<Data>> & Identifiable): Promise<SelectedPick<Record, ['*']>>;
|
3118
3599
|
update(recordId: string, object: Partial<EditableData<Data>>): Promise<SelectedPick<Record, ['*']>>;
|
3119
3600
|
update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<SelectedPick<Record, ['*']>[]>;
|
@@ -3122,11 +3603,66 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
|
|
3122
3603
|
createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
|
3123
3604
|
delete(a: string | Identifiable | Array<string | Identifiable>): Promise<void>;
|
3124
3605
|
search(query: string, options?: {
|
3125
|
-
fuzziness?:
|
3606
|
+
fuzziness?: FuzzinessExpression;
|
3607
|
+
highlight?: HighlightExpression;
|
3608
|
+
filter?: Filter<Record>;
|
3126
3609
|
}): Promise<SelectedPick<Record, ['*']>[]>;
|
3127
3610
|
query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
3128
3611
|
}
|
3129
3612
|
|
3613
|
+
declare type BaseSchema = {
|
3614
|
+
name: string;
|
3615
|
+
columns: readonly ({
|
3616
|
+
name: string;
|
3617
|
+
type: Column['type'];
|
3618
|
+
} | {
|
3619
|
+
name: string;
|
3620
|
+
type: 'link';
|
3621
|
+
link: {
|
3622
|
+
table: string;
|
3623
|
+
};
|
3624
|
+
} | {
|
3625
|
+
name: string;
|
3626
|
+
type: 'object';
|
3627
|
+
columns: {
|
3628
|
+
name: string;
|
3629
|
+
type: string;
|
3630
|
+
}[];
|
3631
|
+
})[];
|
3632
|
+
};
|
3633
|
+
declare type SchemaInference<T extends readonly BaseSchema[]> = T extends never[] ? Record<string, Record<string, any>> : T extends readonly unknown[] ? T[number] extends {
|
3634
|
+
name: string;
|
3635
|
+
columns: readonly unknown[];
|
3636
|
+
} ? {
|
3637
|
+
[K in T[number]['name']]: TableType<T[number], K>;
|
3638
|
+
} : never : never;
|
3639
|
+
declare type TableType<Tables, TableName> = Tables & {
|
3640
|
+
name: TableName;
|
3641
|
+
} extends infer Table ? Table extends {
|
3642
|
+
name: string;
|
3643
|
+
columns: infer Columns;
|
3644
|
+
} ? Columns extends readonly unknown[] ? Columns[number] extends {
|
3645
|
+
name: string;
|
3646
|
+
type: string;
|
3647
|
+
} ? Identifiable & {
|
3648
|
+
[K in Columns[number]['name']]?: PropertyType<Tables, Columns[number], K>;
|
3649
|
+
} : never : never : never : never;
|
3650
|
+
declare type PropertyType<Tables, Properties, PropertyName> = Properties & {
|
3651
|
+
name: PropertyName;
|
3652
|
+
} extends infer Property ? Property extends {
|
3653
|
+
name: string;
|
3654
|
+
type: infer Type;
|
3655
|
+
link?: {
|
3656
|
+
table: infer LinkedTable;
|
3657
|
+
};
|
3658
|
+
columns?: infer ObjectColumns;
|
3659
|
+
} ? (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 {
|
3660
|
+
name: string;
|
3661
|
+
type: string;
|
3662
|
+
} ? {
|
3663
|
+
[K in ObjectColumns[number]['name']]?: PropertyType<Tables, ObjectColumns[number], K>;
|
3664
|
+
} : never : never : Type extends 'link' ? TableType<Tables, LinkedTable> & XataRecord : never) | null : never : never;
|
3665
|
+
|
3130
3666
|
/**
|
3131
3667
|
* Operator to restrict results to only values that are greater than the given value.
|
3132
3668
|
*/
|
@@ -3202,7 +3738,6 @@ declare const includesAny: <T>(value: T) => ArrayFilter<T>;
|
|
3202
3738
|
|
3203
3739
|
declare type SchemaDefinition = {
|
3204
3740
|
table: string;
|
3205
|
-
links?: LinkDictionary;
|
3206
3741
|
};
|
3207
3742
|
declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
|
3208
3743
|
[Key in keyof Schemas]: Repository<Schemas[Key]>;
|
@@ -3211,39 +3746,50 @@ declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
|
|
3211
3746
|
};
|
3212
3747
|
declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
3213
3748
|
#private;
|
3214
|
-
|
3215
|
-
private tableNames?;
|
3216
|
-
constructor(links?: LinkDictionary | undefined, tableNames?: string[] | undefined);
|
3749
|
+
constructor(schemaTables?: Schemas.Table[]);
|
3217
3750
|
build(pluginOptions: XataPluginOptions): SchemaPluginResult<Schemas>;
|
3218
3751
|
}
|
3219
3752
|
|
3220
3753
|
declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
|
3221
|
-
fuzziness?:
|
3222
|
-
|
3754
|
+
fuzziness?: FuzzinessExpression;
|
3755
|
+
highlight?: HighlightExpression;
|
3756
|
+
tables?: Array<Tables | Values<{
|
3757
|
+
[Model in GetArrayInnerType<NonNullable<Tables[]>>]: {
|
3758
|
+
table: Model;
|
3759
|
+
filter?: Filter<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
|
3760
|
+
};
|
3761
|
+
}>>;
|
3223
3762
|
};
|
3224
3763
|
declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
|
3225
3764
|
all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
|
3226
|
-
[Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']
|
3765
|
+
[Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]: {
|
3227
3766
|
table: Model;
|
3228
3767
|
record: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
|
3229
3768
|
};
|
3230
3769
|
}>[]>;
|
3231
3770
|
byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
|
3232
|
-
[Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']
|
3771
|
+
[Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
|
3233
3772
|
}>;
|
3234
3773
|
};
|
3235
3774
|
declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
3236
3775
|
#private;
|
3237
3776
|
private db;
|
3238
|
-
|
3239
|
-
constructor(db: SchemaPluginResult<Schemas>, links: LinkDictionary);
|
3777
|
+
constructor(db: SchemaPluginResult<Schemas>, schemaTables?: Schemas.Table[]);
|
3240
3778
|
build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
|
3241
3779
|
}
|
3242
|
-
declare type SearchXataRecord = XataRecord
|
3243
|
-
|
3244
|
-
|
3780
|
+
declare type SearchXataRecord = XataRecord<SearchExtraProperties>;
|
3781
|
+
declare type SearchExtraProperties = {
|
3782
|
+
table: string;
|
3783
|
+
highlight?: {
|
3784
|
+
[key: string]: string[] | {
|
3785
|
+
[key: string]: any;
|
3786
|
+
};
|
3245
3787
|
};
|
3246
3788
|
};
|
3789
|
+
declare type ReturnTable<Table, Tables> = Table extends Tables ? Table : never;
|
3790
|
+
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 {
|
3791
|
+
table: infer Table;
|
3792
|
+
} ? ReturnTable<Table, Tables> : never;
|
3247
3793
|
|
3248
3794
|
declare type BranchStrategyValue = string | undefined | null;
|
3249
3795
|
declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
|
@@ -3259,16 +3805,25 @@ declare type BaseClientOptions = {
|
|
3259
3805
|
};
|
3260
3806
|
declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
|
3261
3807
|
interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
|
3262
|
-
new <
|
3263
|
-
db: Awaited<ReturnType<SchemaPlugin<
|
3264
|
-
search: Awaited<ReturnType<SearchPlugin<
|
3808
|
+
new <T extends readonly BaseSchema[]>(options?: Partial<BaseClientOptions>, schemaTables?: T): Omit<{
|
3809
|
+
db: Awaited<ReturnType<SchemaPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
|
3810
|
+
search: Awaited<ReturnType<SearchPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
|
3265
3811
|
}, keyof Plugins> & {
|
3266
3812
|
[Key in StringKeys<NonNullable<Plugins>>]: Awaited<ReturnType<NonNullable<Plugins>[Key]['build']>>;
|
3267
3813
|
};
|
3268
3814
|
}
|
3269
3815
|
declare const BaseClient_base: ClientConstructor<{}>;
|
3270
|
-
declare class BaseClient extends BaseClient_base<
|
3816
|
+
declare class BaseClient extends BaseClient_base<[]> {
|
3817
|
+
}
|
3818
|
+
|
3819
|
+
declare class Serializer {
|
3820
|
+
classes: {};
|
3821
|
+
add(clazz: any): void;
|
3822
|
+
toJSON(data: any): string;
|
3823
|
+
fromJSON(json: any): any;
|
3271
3824
|
}
|
3825
|
+
declare const serialize: () => never;
|
3826
|
+
declare const deserialize: () => never;
|
3272
3827
|
|
3273
3828
|
declare type BranchResolutionOptions = {
|
3274
3829
|
databaseURL?: string;
|
@@ -3281,9 +3836,89 @@ declare function getDatabaseURL(): string | undefined;
|
|
3281
3836
|
|
3282
3837
|
declare function getAPIKey(): string | undefined;
|
3283
3838
|
|
3839
|
+
interface Body {
|
3840
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
3841
|
+
blob(): Promise<Blob>;
|
3842
|
+
formData(): Promise<FormData>;
|
3843
|
+
json(): Promise<any>;
|
3844
|
+
text(): Promise<string>;
|
3845
|
+
}
|
3846
|
+
interface Blob {
|
3847
|
+
readonly size: number;
|
3848
|
+
readonly type: string;
|
3849
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
3850
|
+
slice(start?: number, end?: number, contentType?: string): Blob;
|
3851
|
+
text(): Promise<string>;
|
3852
|
+
}
|
3853
|
+
/** Provides information about files and allows JavaScript in a web page to access their content. */
|
3854
|
+
interface File extends Blob {
|
3855
|
+
readonly lastModified: number;
|
3856
|
+
readonly name: string;
|
3857
|
+
readonly webkitRelativePath: string;
|
3858
|
+
}
|
3859
|
+
declare type FormDataEntryValue = File | string;
|
3860
|
+
/** Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data". */
|
3861
|
+
interface FormData {
|
3862
|
+
append(name: string, value: string | Blob, fileName?: string): void;
|
3863
|
+
delete(name: string): void;
|
3864
|
+
get(name: string): FormDataEntryValue | null;
|
3865
|
+
getAll(name: string): FormDataEntryValue[];
|
3866
|
+
has(name: string): boolean;
|
3867
|
+
set(name: string, value: string | Blob, fileName?: string): void;
|
3868
|
+
forEach(callbackfn: (value: FormDataEntryValue, key: string, parent: FormData) => void, thisArg?: any): void;
|
3869
|
+
}
|
3870
|
+
/** This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence. */
|
3871
|
+
interface Headers {
|
3872
|
+
append(name: string, value: string): void;
|
3873
|
+
delete(name: string): void;
|
3874
|
+
get(name: string): string | null;
|
3875
|
+
has(name: string): boolean;
|
3876
|
+
set(name: string, value: string): void;
|
3877
|
+
forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void;
|
3878
|
+
}
|
3879
|
+
interface Request extends Body {
|
3880
|
+
/** Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching. */
|
3881
|
+
readonly cache: 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload';
|
3882
|
+
/** Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. */
|
3883
|
+
readonly credentials: 'include' | 'omit' | 'same-origin';
|
3884
|
+
/** Returns the kind of resource requested by request, e.g., "document" or "script". */
|
3885
|
+
readonly destination: '' | 'audio' | 'audioworklet' | 'document' | 'embed' | 'font' | 'frame' | 'iframe' | 'image' | 'manifest' | 'object' | 'paintworklet' | 'report' | 'script' | 'sharedworker' | 'style' | 'track' | 'video' | 'worker' | 'xslt';
|
3886
|
+
/** Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header. */
|
3887
|
+
readonly headers: Headers;
|
3888
|
+
/** Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI] */
|
3889
|
+
readonly integrity: string;
|
3890
|
+
/** Returns a boolean indicating whether or not request can outlive the global in which it was created. */
|
3891
|
+
readonly keepalive: boolean;
|
3892
|
+
/** Returns request's HTTP method, which is "GET" by default. */
|
3893
|
+
readonly method: string;
|
3894
|
+
/** Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs. */
|
3895
|
+
readonly mode: 'cors' | 'navigate' | 'no-cors' | 'same-origin';
|
3896
|
+
/** Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default. */
|
3897
|
+
readonly redirect: 'error' | 'follow' | 'manual';
|
3898
|
+
/** Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and "about:client" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made. */
|
3899
|
+
readonly referrer: string;
|
3900
|
+
/** Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer. */
|
3901
|
+
readonly referrerPolicy: '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
3902
|
+
/** Returns the URL of request as a string. */
|
3903
|
+
readonly url: string;
|
3904
|
+
clone(): Request;
|
3905
|
+
}
|
3906
|
+
|
3907
|
+
declare type XataWorkerContext<XataClient> = {
|
3908
|
+
xata: XataClient;
|
3909
|
+
request: Request;
|
3910
|
+
env: Record<string, string | undefined>;
|
3911
|
+
};
|
3912
|
+
declare type RemoveFirst<T> = T extends [any, ...infer U] ? U : never;
|
3913
|
+
declare type WorkerRunnerConfig = {
|
3914
|
+
worker: string;
|
3915
|
+
publicKey: string;
|
3916
|
+
};
|
3917
|
+
declare function buildWorkerRunner<XataClient>(config: WorkerRunnerConfig): <WorkerFunction extends (ctx: XataWorkerContext<XataClient>, ...args: any[]) => any>(name: string, _worker: WorkerFunction) => (...args: RemoveFirst<Parameters<WorkerFunction>>) => Promise<Awaited<ReturnType<WorkerFunction>>>;
|
3918
|
+
|
3284
3919
|
declare class XataError extends Error {
|
3285
3920
|
readonly status: number;
|
3286
3921
|
constructor(message: string, status: number);
|
3287
3922
|
}
|
3288
3923
|
|
3289
|
-
export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, 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, 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,
|
3924
|
+
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, Serializer, SetTableSchemaError, SetTableSchemaPathParams, SetTableSchemaRequestBody, SetTableSchemaVariables, SimpleCache, SimpleCacheOptions, UpdateBranchMetadataError, UpdateBranchMetadataPathParams, UpdateBranchMetadataVariables, UpdateColumnError, UpdateColumnPathParams, UpdateColumnRequestBody, UpdateColumnVariables, UpdateRecordWithIDError, UpdateRecordWithIDPathParams, UpdateRecordWithIDQueryParams, UpdateRecordWithIDVariables, UpdateTableError, UpdateTablePathParams, UpdateTableRequestBody, UpdateTableVariables, UpdateUserError, UpdateUserVariables, UpdateWorkspaceError, UpdateWorkspaceMemberInviteError, UpdateWorkspaceMemberInvitePathParams, UpdateWorkspaceMemberInviteRequestBody, UpdateWorkspaceMemberInviteVariables, UpdateWorkspaceMemberRoleError, UpdateWorkspaceMemberRolePathParams, UpdateWorkspaceMemberRoleRequestBody, UpdateWorkspaceMemberRoleVariables, UpdateWorkspacePathParams, UpdateWorkspaceVariables, UpsertRecordWithIDError, UpsertRecordWithIDPathParams, UpsertRecordWithIDQueryParams, UpsertRecordWithIDVariables, ValueAtColumn, XataApiClient, XataApiClientOptions, XataApiPlugin, XataError, XataPlugin, XataPluginOptions, XataRecord, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
|