@xata.io/client 0.0.0-alpha.vf350c0a → 0.0.0-alpha.vf45a2df
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 +120 -0
- package/README.md +271 -1
- package/Usage.md +395 -0
- package/dist/index.cjs +260 -134
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +397 -127
- package/dist/index.mjs +258 -135
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -3
- package/tsconfig.json +1 -0
package/dist/index.d.ts
CHANGED
@@ -6,6 +6,9 @@ declare type FetchImpl = (url: string, init?: {
|
|
6
6
|
ok: boolean;
|
7
7
|
status: number;
|
8
8
|
json(): Promise<any>;
|
9
|
+
headers?: {
|
10
|
+
get(name: string): string | null;
|
11
|
+
};
|
9
12
|
}>;
|
10
13
|
declare type WorkspaceApiUrlBuilder = (path: string, pathParams: Record<string, string>) => string;
|
11
14
|
declare type FetcherExtraProps = {
|
@@ -268,6 +271,21 @@ declare type SortExpression = string[] | {
|
|
268
271
|
[key: string]: SortOrder;
|
269
272
|
}[];
|
270
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';
|
271
289
|
/**
|
272
290
|
* @minProperties 1
|
273
291
|
*/
|
@@ -281,6 +299,10 @@ declare type FilterExpression = {
|
|
281
299
|
} & {
|
282
300
|
[key: string]: FilterColumn;
|
283
301
|
};
|
302
|
+
declare type HighlightExpression = {
|
303
|
+
enabled?: boolean;
|
304
|
+
encodeHTML?: boolean;
|
305
|
+
};
|
284
306
|
declare type FilterList = FilterExpression | FilterExpression[];
|
285
307
|
declare type FilterColumn = FilterColumnIncludes | FilterPredicate | FilterList;
|
286
308
|
/**
|
@@ -366,6 +388,11 @@ declare type XataRecord$1 = {
|
|
366
388
|
xata: {
|
367
389
|
version: number;
|
368
390
|
table?: string;
|
391
|
+
highlight?: {
|
392
|
+
[key: string]: string[] | {
|
393
|
+
[key: string]: any;
|
394
|
+
};
|
395
|
+
};
|
369
396
|
warnings?: string[];
|
370
397
|
};
|
371
398
|
} & {
|
@@ -409,7 +436,10 @@ type schemas_TableMigration = TableMigration;
|
|
409
436
|
type schemas_ColumnMigration = ColumnMigration;
|
410
437
|
type schemas_SortExpression = SortExpression;
|
411
438
|
type schemas_SortOrder = SortOrder;
|
439
|
+
type schemas_FuzzinessExpression = FuzzinessExpression;
|
440
|
+
type schemas_PrefixExpression = PrefixExpression;
|
412
441
|
type schemas_FilterExpression = FilterExpression;
|
442
|
+
type schemas_HighlightExpression = HighlightExpression;
|
413
443
|
type schemas_FilterList = FilterList;
|
414
444
|
type schemas_FilterColumn = FilterColumn;
|
415
445
|
type schemas_FilterColumnIncludes = FilterColumnIncludes;
|
@@ -462,7 +492,10 @@ declare namespace schemas {
|
|
462
492
|
schemas_ColumnMigration as ColumnMigration,
|
463
493
|
schemas_SortExpression as SortExpression,
|
464
494
|
schemas_SortOrder as SortOrder,
|
495
|
+
schemas_FuzzinessExpression as FuzzinessExpression,
|
496
|
+
schemas_PrefixExpression as PrefixExpression,
|
465
497
|
schemas_FilterExpression as FilterExpression,
|
498
|
+
schemas_HighlightExpression as HighlightExpression,
|
466
499
|
schemas_FilterList as FilterList,
|
467
500
|
schemas_FilterColumn as FilterColumn,
|
468
501
|
schemas_FilterColumnIncludes as FilterColumnIncludes,
|
@@ -1151,14 +1184,15 @@ declare type ResolveBranchVariables = {
|
|
1151
1184
|
} & FetcherExtraProps;
|
1152
1185
|
/**
|
1153
1186
|
* In order to resolve the database branch, the following algorithm is used:
|
1154
|
-
* * if the `gitBranch` is found in the [git branches mapping](), the associated Xata branch is returned
|
1187
|
+
* * if the `gitBranch` was provided and is found in the [git branches mapping](/api-reference/dbs/db_name/gitBranches), the associated Xata branch is returned
|
1155
1188
|
* * else, if a Xata branch with the exact same name as `gitBranch` exists, return it
|
1156
|
-
* * else,
|
1189
|
+
* * else, if `fallbackBranch` is provided and a branch with that name exists, return it
|
1190
|
+
* * else, return the default branch of the DB (`main` or the first branch)
|
1157
1191
|
*
|
1158
1192
|
* Example call:
|
1159
1193
|
*
|
1160
1194
|
* ```json
|
1161
|
-
* // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test
|
1195
|
+
* // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test&fallbackBranch=tsg
|
1162
1196
|
* ```
|
1163
1197
|
*
|
1164
1198
|
* Example response:
|
@@ -1458,8 +1492,9 @@ declare type UpdateTableVariables = {
|
|
1458
1492
|
*
|
1459
1493
|
* In the example below, we rename a table from “users” to “people”:
|
1460
1494
|
*
|
1461
|
-
* ```
|
1462
|
-
* PATCH /db/test:main/tables/users
|
1495
|
+
* ```json
|
1496
|
+
* // PATCH /db/test:main/tables/users
|
1497
|
+
*
|
1463
1498
|
* {
|
1464
1499
|
* "name": "people"
|
1465
1500
|
* }
|
@@ -1867,7 +1902,7 @@ declare type QueryTableVariables = {
|
|
1867
1902
|
* {
|
1868
1903
|
* "columns": [...],
|
1869
1904
|
* "filter": {
|
1870
|
-
* "$all": [...]
|
1905
|
+
* "$all": [...],
|
1871
1906
|
* "$any": [...]
|
1872
1907
|
* ...
|
1873
1908
|
* },
|
@@ -2005,7 +2040,7 @@ declare type QueryTableVariables = {
|
|
2005
2040
|
* {
|
2006
2041
|
* "name": "Kilian",
|
2007
2042
|
* "address": {
|
2008
|
-
* "street": "New street"
|
2043
|
+
* "street": "New street"
|
2009
2044
|
* }
|
2010
2045
|
* }
|
2011
2046
|
* ```
|
@@ -2014,10 +2049,7 @@ declare type QueryTableVariables = {
|
|
2014
2049
|
*
|
2015
2050
|
* ```json
|
2016
2051
|
* {
|
2017
|
-
* "columns": [
|
2018
|
-
* "*",
|
2019
|
-
* "team.name"
|
2020
|
-
* ]
|
2052
|
+
* "columns": ["*", "team.name"]
|
2021
2053
|
* }
|
2022
2054
|
* ```
|
2023
2055
|
*
|
@@ -2035,7 +2067,7 @@ declare type QueryTableVariables = {
|
|
2035
2067
|
* "team": {
|
2036
2068
|
* "id": "XX",
|
2037
2069
|
* "xata": {
|
2038
|
-
* "version": 0
|
2070
|
+
* "version": 0
|
2039
2071
|
* },
|
2040
2072
|
* "name": "first team"
|
2041
2073
|
* }
|
@@ -2046,10 +2078,7 @@ declare type QueryTableVariables = {
|
|
2046
2078
|
*
|
2047
2079
|
* ```json
|
2048
2080
|
* {
|
2049
|
-
* "columns": [
|
2050
|
-
* "*",
|
2051
|
-
* "team.*"
|
2052
|
-
* ]
|
2081
|
+
* "columns": ["*", "team.*"]
|
2053
2082
|
* }
|
2054
2083
|
* ```
|
2055
2084
|
*
|
@@ -2067,7 +2096,7 @@ declare type QueryTableVariables = {
|
|
2067
2096
|
* "team": {
|
2068
2097
|
* "id": "XX",
|
2069
2098
|
* "xata": {
|
2070
|
-
* "version": 0
|
2099
|
+
* "version": 0
|
2071
2100
|
* },
|
2072
2101
|
* "name": "first team",
|
2073
2102
|
* "code": "A1",
|
@@ -2117,7 +2146,7 @@ declare type QueryTableVariables = {
|
|
2117
2146
|
* ```json
|
2118
2147
|
* {
|
2119
2148
|
* "filter": {
|
2120
|
-
*
|
2149
|
+
* "name": "r2"
|
2121
2150
|
* }
|
2122
2151
|
* }
|
2123
2152
|
* ```
|
@@ -2139,7 +2168,7 @@ declare type QueryTableVariables = {
|
|
2139
2168
|
* ```json
|
2140
2169
|
* {
|
2141
2170
|
* "filter": {
|
2142
|
-
*
|
2171
|
+
* "settings.plan": "free"
|
2143
2172
|
* }
|
2144
2173
|
* }
|
2145
2174
|
* ```
|
@@ -2149,8 +2178,8 @@ declare type QueryTableVariables = {
|
|
2149
2178
|
* "filter": {
|
2150
2179
|
* "settings": {
|
2151
2180
|
* "plan": "free"
|
2152
|
-
* }
|
2153
|
-
* }
|
2181
|
+
* }
|
2182
|
+
* }
|
2154
2183
|
* }
|
2155
2184
|
* ```
|
2156
2185
|
*
|
@@ -2159,8 +2188,8 @@ declare type QueryTableVariables = {
|
|
2159
2188
|
* ```json
|
2160
2189
|
* {
|
2161
2190
|
* "filter": {
|
2162
|
-
* "settings.plan": {"$any": ["free", "paid"]}
|
2163
|
-
* }
|
2191
|
+
* "settings.plan": { "$any": ["free", "paid"] }
|
2192
|
+
* }
|
2164
2193
|
* }
|
2165
2194
|
* ```
|
2166
2195
|
*
|
@@ -2169,9 +2198,9 @@ declare type QueryTableVariables = {
|
|
2169
2198
|
* ```json
|
2170
2199
|
* {
|
2171
2200
|
* "filter": {
|
2172
|
-
*
|
2173
|
-
*
|
2174
|
-
* }
|
2201
|
+
* "settings.dark": true,
|
2202
|
+
* "settings.plan": "free"
|
2203
|
+
* }
|
2175
2204
|
* }
|
2176
2205
|
* ```
|
2177
2206
|
*
|
@@ -2182,11 +2211,11 @@ declare type QueryTableVariables = {
|
|
2182
2211
|
* ```json
|
2183
2212
|
* {
|
2184
2213
|
* "filter": {
|
2185
|
-
*
|
2186
|
-
*
|
2187
|
-
*
|
2188
|
-
*
|
2189
|
-
* }
|
2214
|
+
* "$any": {
|
2215
|
+
* "settings.dark": true,
|
2216
|
+
* "settings.plan": "free"
|
2217
|
+
* }
|
2218
|
+
* }
|
2190
2219
|
* }
|
2191
2220
|
* ```
|
2192
2221
|
*
|
@@ -2197,10 +2226,10 @@ declare type QueryTableVariables = {
|
|
2197
2226
|
* "filter": {
|
2198
2227
|
* "$any": [
|
2199
2228
|
* {
|
2200
|
-
* "name": "r1"
|
2229
|
+
* "name": "r1"
|
2201
2230
|
* },
|
2202
2231
|
* {
|
2203
|
-
* "name": "r2"
|
2232
|
+
* "name": "r2"
|
2204
2233
|
* }
|
2205
2234
|
* ]
|
2206
2235
|
* }
|
@@ -2212,7 +2241,7 @@ declare type QueryTableVariables = {
|
|
2212
2241
|
* ```json
|
2213
2242
|
* {
|
2214
2243
|
* "filter": {
|
2215
|
-
* "$exists": "settings"
|
2244
|
+
* "$exists": "settings"
|
2216
2245
|
* }
|
2217
2246
|
* }
|
2218
2247
|
* ```
|
@@ -2224,10 +2253,10 @@ declare type QueryTableVariables = {
|
|
2224
2253
|
* "filter": {
|
2225
2254
|
* "$all": [
|
2226
2255
|
* {
|
2227
|
-
* "$exists": "settings"
|
2256
|
+
* "$exists": "settings"
|
2228
2257
|
* },
|
2229
2258
|
* {
|
2230
|
-
* "$exists": "name"
|
2259
|
+
* "$exists": "name"
|
2231
2260
|
* }
|
2232
2261
|
* ]
|
2233
2262
|
* }
|
@@ -2239,7 +2268,7 @@ declare type QueryTableVariables = {
|
|
2239
2268
|
* ```json
|
2240
2269
|
* {
|
2241
2270
|
* "filter": {
|
2242
|
-
* "$notExists": "settings"
|
2271
|
+
* "$notExists": "settings"
|
2243
2272
|
* }
|
2244
2273
|
* }
|
2245
2274
|
* ```
|
@@ -2266,22 +2295,28 @@ declare type QueryTableVariables = {
|
|
2266
2295
|
* {
|
2267
2296
|
* "filter": {
|
2268
2297
|
* "<column_name>": {
|
2269
|
-
*
|
2298
|
+
* "$pattern": "v*alu?"
|
2270
2299
|
* }
|
2271
2300
|
* }
|
2272
2301
|
* }
|
2273
2302
|
* ```
|
2274
2303
|
*
|
2304
|
+
* The `$pattern` operator accepts two wildcard characters:
|
2305
|
+
* * `*` matches zero or more characters
|
2306
|
+
* * `?` matches exactly one character
|
2307
|
+
*
|
2308
|
+
* If you want to match a string that contains a wildcard character, you can escape them using a backslash (`\`). You can escape a backslash by usign another backslash.
|
2309
|
+
*
|
2275
2310
|
* We could also have `$endsWith` and `$startsWith` operators:
|
2276
2311
|
*
|
2277
2312
|
* ```json
|
2278
2313
|
* {
|
2279
2314
|
* "filter": {
|
2280
2315
|
* "<column_name>": {
|
2281
|
-
*
|
2316
|
+
* "$endsWith": ".gz"
|
2282
2317
|
* },
|
2283
2318
|
* "<column_name>": {
|
2284
|
-
*
|
2319
|
+
* "$startsWith": "tmp-"
|
2285
2320
|
* }
|
2286
2321
|
* }
|
2287
2322
|
* }
|
@@ -2292,10 +2327,10 @@ declare type QueryTableVariables = {
|
|
2292
2327
|
* ```json
|
2293
2328
|
* {
|
2294
2329
|
* "filter": {
|
2295
|
-
*
|
2296
|
-
*
|
2297
|
-
*
|
2298
|
-
*
|
2330
|
+
* "<column_name>": {
|
2331
|
+
* "$ge": 0,
|
2332
|
+
* "$lt": 100
|
2333
|
+
* }
|
2299
2334
|
* }
|
2300
2335
|
* }
|
2301
2336
|
* ```
|
@@ -2313,7 +2348,6 @@ declare type QueryTableVariables = {
|
|
2313
2348
|
* ```
|
2314
2349
|
* The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
|
2315
2350
|
*
|
2316
|
-
*
|
2317
2351
|
* #### Negations
|
2318
2352
|
*
|
2319
2353
|
* A general `$not` operator can inverse any operation.
|
@@ -2338,15 +2372,21 @@ declare type QueryTableVariables = {
|
|
2338
2372
|
* {
|
2339
2373
|
* "filter": {
|
2340
2374
|
* "$not": {
|
2341
|
-
* "$any": [
|
2342
|
-
*
|
2343
|
-
*
|
2344
|
-
*
|
2345
|
-
*
|
2346
|
-
*
|
2347
|
-
*
|
2348
|
-
*
|
2349
|
-
*
|
2375
|
+
* "$any": [
|
2376
|
+
* {
|
2377
|
+
* "<column_name1>": "value1"
|
2378
|
+
* },
|
2379
|
+
* {
|
2380
|
+
* "$all": [
|
2381
|
+
* {
|
2382
|
+
* "<column_name2>": "value2"
|
2383
|
+
* },
|
2384
|
+
* {
|
2385
|
+
* "<column_name3>": "value3"
|
2386
|
+
* }
|
2387
|
+
* ]
|
2388
|
+
* }
|
2389
|
+
* ]
|
2350
2390
|
* }
|
2351
2391
|
* }
|
2352
2392
|
* }
|
@@ -2401,8 +2441,8 @@ declare type QueryTableVariables = {
|
|
2401
2441
|
* "<array name>": {
|
2402
2442
|
* "$includes": {
|
2403
2443
|
* "$all": [
|
2404
|
-
* {"$contains": "label"},
|
2405
|
-
* {"$not": {"$endsWith": "-debug"}}
|
2444
|
+
* { "$contains": "label" },
|
2445
|
+
* { "$not": { "$endsWith": "-debug" } }
|
2406
2446
|
* ]
|
2407
2447
|
* }
|
2408
2448
|
* }
|
@@ -2422,9 +2462,7 @@ declare type QueryTableVariables = {
|
|
2422
2462
|
* {
|
2423
2463
|
* "filter": {
|
2424
2464
|
* "settings.labels": {
|
2425
|
-
* "$includesAll": [
|
2426
|
-
* {"$contains": "label"},
|
2427
|
-
* ]
|
2465
|
+
* "$includesAll": [{ "$contains": "label" }]
|
2428
2466
|
* }
|
2429
2467
|
* }
|
2430
2468
|
* }
|
@@ -2472,7 +2510,6 @@ declare type QueryTableVariables = {
|
|
2472
2510
|
* }
|
2473
2511
|
* ```
|
2474
2512
|
*
|
2475
|
-
*
|
2476
2513
|
* ### Pagination
|
2477
2514
|
*
|
2478
2515
|
* We offer cursor pagination and offset pagination. The offset pagination is limited
|
@@ -2538,8 +2575,8 @@ declare type QueryTableVariables = {
|
|
2538
2575
|
* can be queried by update `page.after` to the returned cursor while keeping the
|
2539
2576
|
* `page.before` cursor from the first range query.
|
2540
2577
|
*
|
2541
|
-
* The `filter` , `columns`,
|
2542
|
-
* encoded with the cursor.
|
2578
|
+
* The `filter` , `columns`, `sort` , and `page.size` configuration will be
|
2579
|
+
* encoded with the cursor. The pagination request will be invalid if
|
2543
2580
|
* `filter` or `sort` is set. The columns returned and page size can be changed
|
2544
2581
|
* anytime by passing the `columns` or `page.size` settings to the next query.
|
2545
2582
|
*
|
@@ -2576,6 +2613,40 @@ declare type QueryTableVariables = {
|
|
2576
2613
|
* ```
|
2577
2614
|
*/
|
2578
2615
|
declare const queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
2616
|
+
declare type SearchTablePathParams = {
|
2617
|
+
dbBranchName: DBBranchName;
|
2618
|
+
tableName: TableName;
|
2619
|
+
workspace: string;
|
2620
|
+
};
|
2621
|
+
declare type SearchTableError = ErrorWrapper<{
|
2622
|
+
status: 400;
|
2623
|
+
payload: BadRequestError;
|
2624
|
+
} | {
|
2625
|
+
status: 401;
|
2626
|
+
payload: AuthError;
|
2627
|
+
} | {
|
2628
|
+
status: 404;
|
2629
|
+
payload: SimpleError;
|
2630
|
+
}>;
|
2631
|
+
declare type SearchTableRequestBody = {
|
2632
|
+
query: string;
|
2633
|
+
fuzziness?: FuzzinessExpression;
|
2634
|
+
prefix?: PrefixExpression;
|
2635
|
+
filter?: FilterExpression;
|
2636
|
+
highlight?: HighlightExpression;
|
2637
|
+
};
|
2638
|
+
declare type SearchTableVariables = {
|
2639
|
+
body: SearchTableRequestBody;
|
2640
|
+
pathParams: SearchTablePathParams;
|
2641
|
+
} & FetcherExtraProps;
|
2642
|
+
/**
|
2643
|
+
* Run a free text search operation in a particular table.
|
2644
|
+
*
|
2645
|
+
* The endpoint accepts a `query` parameter that is used for the free text search and a set of structured filters (via the `filter` parameter) that are applied before the search. The `filter` parameter uses the same syntax as the [query endpoint](/api-reference/db/db_branch_name/tables/table_name/) with the following exceptions:
|
2646
|
+
* * filters `$contains`, `$startsWith`, `$endsWith` don't work on columns of type `text`
|
2647
|
+
* * filtering on columns of type `multiple` is currently unsupported
|
2648
|
+
*/
|
2649
|
+
declare const searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
|
2579
2650
|
declare type SearchBranchPathParams = {
|
2580
2651
|
dbBranchName: DBBranchName;
|
2581
2652
|
workspace: string;
|
@@ -2591,9 +2662,13 @@ declare type SearchBranchError = ErrorWrapper<{
|
|
2591
2662
|
payload: SimpleError;
|
2592
2663
|
}>;
|
2593
2664
|
declare type SearchBranchRequestBody = {
|
2594
|
-
tables?: string
|
2665
|
+
tables?: (string | {
|
2666
|
+
table: string;
|
2667
|
+
filter?: FilterExpression;
|
2668
|
+
})[];
|
2595
2669
|
query: string;
|
2596
|
-
fuzziness?:
|
2670
|
+
fuzziness?: FuzzinessExpression;
|
2671
|
+
highlight?: HighlightExpression;
|
2597
2672
|
};
|
2598
2673
|
declare type SearchBranchVariables = {
|
2599
2674
|
body: SearchBranchRequestBody;
|
@@ -2668,6 +2743,7 @@ declare const operationsByTag: {
|
|
2668
2743
|
getRecord: (variables: GetRecordVariables) => Promise<XataRecord$1>;
|
2669
2744
|
bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
|
2670
2745
|
queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
2746
|
+
searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
|
2671
2747
|
searchBranch: (variables: SearchBranchVariables) => Promise<SearchResponse>;
|
2672
2748
|
};
|
2673
2749
|
};
|
@@ -2732,7 +2808,7 @@ declare class DatabaseApi {
|
|
2732
2808
|
getGitBranchesMapping(workspace: WorkspaceID, dbName: DBName): Promise<ListGitBranchesResponse>;
|
2733
2809
|
addGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, body: AddGitBranchesEntryRequestBody): Promise<AddGitBranchesEntryResponse>;
|
2734
2810
|
removeGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<void>;
|
2735
|
-
resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch
|
2811
|
+
resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch?: string, fallbackBranch?: string): Promise<ResolveBranchResponse>;
|
2736
2812
|
}
|
2737
2813
|
declare class BranchApi {
|
2738
2814
|
private extraProps;
|
@@ -2773,6 +2849,7 @@ declare class RecordsApi {
|
|
2773
2849
|
getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: GetRecordRequestBody): Promise<XataRecord$1>;
|
2774
2850
|
bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[]): Promise<BulkInsertTableRecordsResponse>;
|
2775
2851
|
queryTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: QueryTableRequestBody): Promise<QueryResponse>;
|
2852
|
+
searchTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: SearchTableRequestBody): Promise<SearchResponse>;
|
2776
2853
|
searchBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, query: SearchBranchRequestBody): Promise<SearchResponse>;
|
2777
2854
|
}
|
2778
2855
|
|
@@ -2794,19 +2871,20 @@ declare type RequiredBy<T, K extends keyof T> = T & {
|
|
2794
2871
|
};
|
2795
2872
|
declare type GetArrayInnerType<T extends readonly any[]> = T[number];
|
2796
2873
|
declare type SingleOrArray<T> = T | T[];
|
2874
|
+
declare type OmitBy<T, K extends keyof T> = T extends any ? Omit<T, K> : never;
|
2797
2875
|
|
2798
2876
|
declare type SelectableColumn<O, RecursivePath extends any[] = []> = '*' | 'id' | DataProps<O> | NestedColumns<O, RecursivePath>;
|
2799
2877
|
declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord & UnionToIntersection<Values<{
|
2800
2878
|
[K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord;
|
2801
2879
|
}>>;
|
2802
|
-
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
|
2803
|
-
V: ValueAtColumn<
|
2804
|
-
} : never
|
2880
|
+
declare type ValueAtColumn<O, P extends SelectableColumn<O>> = P extends '*' ? Values<O> : P extends 'id' ? string : P extends keyof O ? O[P] : P extends `${infer K}.${infer V}` ? K extends keyof O ? Values<NonNullable<O[K]> extends infer Item ? Item extends Record<string, any> ? V extends SelectableColumn<Item> ? {
|
2881
|
+
V: ValueAtColumn<Item, V>;
|
2882
|
+
} : never : O[K] : never> : never : never;
|
2805
2883
|
declare type MAX_RECURSION = 5;
|
2806
2884
|
declare type NestedColumns<O, RecursivePath extends any[]> = RecursivePath['length'] extends MAX_RECURSION ? never : If<IsObject<O>, Values<{
|
2807
|
-
[K in DataProps<O>]:
|
2808
|
-
If<IsObject<
|
2809
|
-
K
|
2885
|
+
[K in DataProps<O>]: NonNullable<O[K]> extends infer Item ? If<IsArray<Item>, K, // If the property is an array, we stop recursion. We don't support object arrays yet
|
2886
|
+
If<IsObject<Item>, Item extends XataRecord ? SelectableColumn<Item, [...RecursivePath, Item]> extends infer Column ? Column extends string ? K | `${K}.${Column}` : never : never : Item extends Date ? K : `${K}.${StringKeys<Item> | '*'}`, // This allows usage of objects that are not links
|
2887
|
+
K>> : never;
|
2810
2888
|
}>, never>;
|
2811
2889
|
declare type DataProps<O> = Exclude<StringKeys<O>, StringKeys<XataRecord>>;
|
2812
2890
|
declare type NestedValueAtColumn<O, Key extends SelectableColumn<O>> = Key extends `${infer N}.${infer M}` ? N extends DataProps<O> ? {
|
@@ -2833,16 +2911,11 @@ interface BaseData {
|
|
2833
2911
|
/**
|
2834
2912
|
* Represents a persisted record from the database.
|
2835
2913
|
*/
|
2836
|
-
interface XataRecord extends Identifiable {
|
2914
|
+
interface XataRecord<ExtraMetadata extends Record<string, unknown> = Record<string, unknown>> extends Identifiable {
|
2837
2915
|
/**
|
2838
|
-
*
|
2916
|
+
* Get metadata of this record.
|
2839
2917
|
*/
|
2840
|
-
|
2841
|
-
/**
|
2842
|
-
* Number that is increased every time the record is updated.
|
2843
|
-
*/
|
2844
|
-
version: number;
|
2845
|
-
};
|
2918
|
+
getMetadata(): XataRecordMetadata & ExtraMetadata;
|
2846
2919
|
/**
|
2847
2920
|
* Retrieves a refreshed copy of the current record from the database.
|
2848
2921
|
*/
|
@@ -2850,7 +2923,7 @@ interface XataRecord extends Identifiable {
|
|
2850
2923
|
/**
|
2851
2924
|
* Performs a partial update of the current record. On success a new object is
|
2852
2925
|
* returned and the current object is not mutated.
|
2853
|
-
* @param
|
2926
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
2854
2927
|
* @returns A new record containing the latest values for all the columns of the current record.
|
2855
2928
|
*/
|
2856
2929
|
update(partialUpdate: Partial<EditableData<Omit<this, keyof XataRecord>>>): Promise<Readonly<SelectedPick<this, ['*']>>>;
|
@@ -2869,19 +2942,26 @@ declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update
|
|
2869
2942
|
/**
|
2870
2943
|
* Performs a partial update of the current record. On success a new object is
|
2871
2944
|
* returned and the current object is not mutated.
|
2872
|
-
* @param
|
2945
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
2873
2946
|
* @returns A new record containing the latest values for all the columns of the current record.
|
2874
2947
|
*/
|
2875
2948
|
update(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
2876
2949
|
};
|
2950
|
+
declare type XataRecordMetadata = {
|
2951
|
+
/**
|
2952
|
+
* Number that is increased every time the record is updated.
|
2953
|
+
*/
|
2954
|
+
version: number;
|
2955
|
+
warnings?: string[];
|
2956
|
+
};
|
2877
2957
|
declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
|
2878
2958
|
declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
|
2879
2959
|
declare type EditableData<O extends BaseData> = {
|
2880
2960
|
[K in keyof O]: O[K] extends XataRecord ? {
|
2881
2961
|
id: string;
|
2882
|
-
} : NonNullable<O[K]> extends XataRecord ? {
|
2962
|
+
} | string : NonNullable<O[K]> extends XataRecord ? {
|
2883
2963
|
id: string;
|
2884
|
-
} | null | undefined : O[K];
|
2964
|
+
} | string | null | undefined : O[K];
|
2885
2965
|
};
|
2886
2966
|
|
2887
2967
|
/**
|
@@ -2957,8 +3037,8 @@ declare type ValueTypeFilters<T> = T | T extends string ? StringTypeFilter : T e
|
|
2957
3037
|
],
|
2958
3038
|
}
|
2959
3039
|
*/
|
2960
|
-
declare type AggregatorFilter<
|
2961
|
-
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<
|
3040
|
+
declare type AggregatorFilter<T> = {
|
3041
|
+
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<T>>;
|
2962
3042
|
};
|
2963
3043
|
/**
|
2964
3044
|
* Existance filter
|
@@ -2973,10 +3053,10 @@ declare type BaseApiFilter<Record> = PropertyAccessFilter<Record> | AggregatorFi
|
|
2973
3053
|
* Injects the Api filters on nested properties
|
2974
3054
|
* Example: { filter: { settings: { plan: { $any: ['free', 'trial'] } } } }
|
2975
3055
|
*/
|
2976
|
-
declare type NestedApiFilter<T> =
|
3056
|
+
declare type NestedApiFilter<T> = {
|
2977
3057
|
[key in keyof T]?: T[key] extends Record<string, any> ? SingleOrArray<Filter<T[key]>> : PropertyFilter<T[key]>;
|
2978
|
-
}
|
2979
|
-
declare type Filter<
|
3058
|
+
};
|
3059
|
+
declare type Filter<T> = T extends Record<string, any> ? BaseApiFilter<T> | NestedApiFilter<T> : PropertyFilter<T>;
|
2980
3060
|
|
2981
3061
|
declare type SortDirection = 'asc' | 'desc';
|
2982
3062
|
declare type SortFilterExtended<T extends XataRecord> = {
|
@@ -2988,13 +3068,21 @@ declare type SortFilterBase<T extends XataRecord> = {
|
|
2988
3068
|
[Key in StringKeys<T>]: SortDirection;
|
2989
3069
|
};
|
2990
3070
|
|
2991
|
-
declare type
|
2992
|
-
page?: PaginationOptions;
|
3071
|
+
declare type BaseOptions<T extends XataRecord> = {
|
2993
3072
|
columns?: NonEmptyArray<SelectableColumn<T>>;
|
3073
|
+
cache?: number;
|
3074
|
+
};
|
3075
|
+
declare type CursorQueryOptions = {
|
3076
|
+
pagination?: CursorNavigationOptions & OffsetNavigationOptions;
|
3077
|
+
filter?: never;
|
3078
|
+
sort?: never;
|
3079
|
+
};
|
3080
|
+
declare type OffsetQueryOptions<T extends XataRecord> = {
|
3081
|
+
pagination?: OffsetNavigationOptions;
|
2994
3082
|
filter?: FilterExpression;
|
2995
3083
|
sort?: SortFilter<T> | SortFilter<T>[];
|
2996
|
-
cache?: number;
|
2997
3084
|
};
|
3085
|
+
declare type QueryOptions<T extends XataRecord> = BaseOptions<T> & (CursorQueryOptions | OffsetQueryOptions<T>);
|
2998
3086
|
/**
|
2999
3087
|
* Query objects contain the information of all filters, sorting, etc. to be included in the database query.
|
3000
3088
|
*
|
@@ -3004,8 +3092,8 @@ declare type QueryOptions<T extends XataRecord> = {
|
|
3004
3092
|
declare class Query<Record extends XataRecord, Result extends XataRecord = Record> implements Paginable<Record, Result> {
|
3005
3093
|
#private;
|
3006
3094
|
readonly meta: PaginationQueryMeta;
|
3007
|
-
readonly records: Result
|
3008
|
-
constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>,
|
3095
|
+
readonly records: RecordArray<Result>;
|
3096
|
+
constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, rawParent?: Partial<QueryOptions<Record>>);
|
3009
3097
|
getQueryOptions(): QueryOptions<Record>;
|
3010
3098
|
key(): string;
|
3011
3099
|
/**
|
@@ -3037,18 +3125,28 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
3037
3125
|
*
|
3038
3126
|
* ```
|
3039
3127
|
* query.filter("columnName", columnValue)
|
3040
|
-
* query.filter(
|
3041
|
-
*
|
3042
|
-
*
|
3128
|
+
* query.filter("columnName", operator(columnValue)) // Use gt, gte, lt, lte, startsWith,...
|
3129
|
+
* ```
|
3130
|
+
*
|
3131
|
+
* @param column The name of the column to filter.
|
3132
|
+
* @param value The value to filter.
|
3133
|
+
* @returns A new Query object.
|
3134
|
+
*/
|
3135
|
+
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
|
3136
|
+
/**
|
3137
|
+
* Builds a new query object adding one or more constraints. Examples:
|
3138
|
+
*
|
3139
|
+
* ```
|
3140
|
+
* query.filter({ "columnName": columnValue })
|
3043
3141
|
* query.filter({
|
3044
3142
|
* "columnName": operator(columnValue) // Use gt, gte, lt, lte, startsWith,...
|
3045
3143
|
* })
|
3046
3144
|
* ```
|
3047
3145
|
*
|
3146
|
+
* @param filters A filter object
|
3048
3147
|
* @returns A new Query object.
|
3049
3148
|
*/
|
3050
3149
|
filter(filters: Filter<Record>): Query<Record, Result>;
|
3051
|
-
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
|
3052
3150
|
/**
|
3053
3151
|
* Builds a new query with a new sort option.
|
3054
3152
|
* @param column The column name.
|
@@ -3062,48 +3160,148 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
3062
3160
|
* @returns A new Query object.
|
3063
3161
|
*/
|
3064
3162
|
select<K extends SelectableColumn<Record>>(columns: NonEmptyArray<K>): Query<Record, SelectedPick<Record, NonEmptyArray<K>>>;
|
3163
|
+
/**
|
3164
|
+
* Get paginated results
|
3165
|
+
*
|
3166
|
+
* @returns A page of results
|
3167
|
+
*/
|
3065
3168
|
getPaginated(): Promise<Page<Record, Result>>;
|
3066
|
-
|
3169
|
+
/**
|
3170
|
+
* Get paginated results
|
3171
|
+
*
|
3172
|
+
* @param options Pagination options
|
3173
|
+
* @returns A page of results
|
3174
|
+
*/
|
3175
|
+
getPaginated(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
|
3176
|
+
/**
|
3177
|
+
* Get paginated results
|
3178
|
+
*
|
3179
|
+
* @param options Pagination options
|
3180
|
+
* @returns A page of results
|
3181
|
+
*/
|
3067
3182
|
getPaginated<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<Page<Record, SelectedPick<Record, typeof options['columns']>>>;
|
3183
|
+
/**
|
3184
|
+
* Get results in an iterator
|
3185
|
+
*
|
3186
|
+
* @async
|
3187
|
+
* @returns Async interable of results
|
3188
|
+
*/
|
3068
3189
|
[Symbol.asyncIterator](): AsyncIterableIterator<Result>;
|
3069
|
-
|
3070
|
-
|
3071
|
-
|
3190
|
+
/**
|
3191
|
+
* Build an iterator of results
|
3192
|
+
*
|
3193
|
+
* @returns Async generator of results array
|
3194
|
+
*/
|
3195
|
+
getIterator(): AsyncGenerator<Result[]>;
|
3196
|
+
/**
|
3197
|
+
* Build an iterator of results
|
3198
|
+
*
|
3199
|
+
* @param options Pagination options with batchSize
|
3200
|
+
* @returns Async generator of results array
|
3201
|
+
*/
|
3202
|
+
getIterator(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
|
3203
|
+
batchSize?: number;
|
3204
|
+
}): AsyncGenerator<Result[]>;
|
3205
|
+
/**
|
3206
|
+
* Build an iterator of results
|
3207
|
+
*
|
3208
|
+
* @param options Pagination options with batchSize
|
3209
|
+
* @returns Async generator of results array
|
3210
|
+
*/
|
3211
|
+
getIterator<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
|
3212
|
+
batchSize?: number;
|
3213
|
+
}>(options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
|
3214
|
+
/**
|
3215
|
+
* Performs the query in the database and returns a set of results.
|
3216
|
+
* @returns An array of records from the database.
|
3217
|
+
*/
|
3218
|
+
getMany(): Promise<RecordArray<Result>>;
|
3072
3219
|
/**
|
3073
3220
|
* Performs the query in the database and returns a set of results.
|
3074
3221
|
* @param options Additional options to be used when performing the query.
|
3075
3222
|
* @returns An array of records from the database.
|
3076
3223
|
*/
|
3077
|
-
getMany(): Promise<Result
|
3078
|
-
|
3079
|
-
|
3224
|
+
getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<RecordArray<Result>>;
|
3225
|
+
/**
|
3226
|
+
* Performs the query in the database and returns a set of results.
|
3227
|
+
* @param options Additional options to be used when performing the query.
|
3228
|
+
* @returns An array of records from the database.
|
3229
|
+
*/
|
3230
|
+
getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<RecordArray<SelectedPick<Record, typeof options['columns']>>>;
|
3231
|
+
/**
|
3232
|
+
* Performs the query in the database and returns all the results.
|
3233
|
+
* Warning: If there are a large number of results, this method can have performance implications.
|
3234
|
+
* @returns An array of records from the database.
|
3235
|
+
*/
|
3236
|
+
getAll(): Promise<Result[]>;
|
3080
3237
|
/**
|
3081
3238
|
* Performs the query in the database and returns all the results.
|
3082
3239
|
* Warning: If there are a large number of results, this method can have performance implications.
|
3083
3240
|
* @param options Additional options to be used when performing the query.
|
3084
3241
|
* @returns An array of records from the database.
|
3085
3242
|
*/
|
3086
|
-
getAll(
|
3087
|
-
|
3088
|
-
|
3243
|
+
getAll(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
|
3244
|
+
batchSize?: number;
|
3245
|
+
}): Promise<Result[]>;
|
3089
3246
|
/**
|
3090
|
-
* Performs the query in the database and returns the
|
3247
|
+
* Performs the query in the database and returns all the results.
|
3248
|
+
* Warning: If there are a large number of results, this method can have performance implications.
|
3091
3249
|
* @param options Additional options to be used when performing the query.
|
3250
|
+
* @returns An array of records from the database.
|
3251
|
+
*/
|
3252
|
+
getAll<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
|
3253
|
+
batchSize?: number;
|
3254
|
+
}>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
|
3255
|
+
/**
|
3256
|
+
* Performs the query in the database and returns the first result.
|
3092
3257
|
* @returns The first record that matches the query, or null if no record matched the query.
|
3093
3258
|
*/
|
3094
3259
|
getFirst(): Promise<Result | null>;
|
3095
|
-
|
3096
|
-
|
3260
|
+
/**
|
3261
|
+
* Performs the query in the database and returns the first result.
|
3262
|
+
* @param options Additional options to be used when performing the query.
|
3263
|
+
* @returns The first record that matches the query, or null if no record matched the query.
|
3264
|
+
*/
|
3265
|
+
getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
|
3266
|
+
/**
|
3267
|
+
* Performs the query in the database and returns the first result.
|
3268
|
+
* @param options Additional options to be used when performing the query.
|
3269
|
+
* @returns The first record that matches the query, or null if no record matched the query.
|
3270
|
+
*/
|
3271
|
+
getFirst<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
|
3097
3272
|
/**
|
3098
3273
|
* Builds a new query object adding a cache TTL in milliseconds.
|
3099
3274
|
* @param ttl The cache TTL in milliseconds.
|
3100
3275
|
* @returns A new Query object.
|
3101
3276
|
*/
|
3102
3277
|
cache(ttl: number): Query<Record, Result>;
|
3278
|
+
/**
|
3279
|
+
* Retrieve next page of records
|
3280
|
+
*
|
3281
|
+
* @returns A new page object.
|
3282
|
+
*/
|
3103
3283
|
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3284
|
+
/**
|
3285
|
+
* Retrieve previous page of records
|
3286
|
+
*
|
3287
|
+
* @returns A new page object
|
3288
|
+
*/
|
3104
3289
|
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3290
|
+
/**
|
3291
|
+
* Retrieve first page of records
|
3292
|
+
*
|
3293
|
+
* @returns A new page object
|
3294
|
+
*/
|
3105
3295
|
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3296
|
+
/**
|
3297
|
+
* Retrieve last page of records
|
3298
|
+
*
|
3299
|
+
* @returns A new page object
|
3300
|
+
*/
|
3106
3301
|
lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3302
|
+
/**
|
3303
|
+
* @returns Boolean indicating if there is a next page
|
3304
|
+
*/
|
3107
3305
|
hasNextPage(): boolean;
|
3108
3306
|
}
|
3109
3307
|
|
@@ -3115,7 +3313,7 @@ declare type PaginationQueryMeta = {
|
|
3115
3313
|
};
|
3116
3314
|
interface Paginable<Record extends XataRecord, Result extends XataRecord = Record> {
|
3117
3315
|
meta: PaginationQueryMeta;
|
3118
|
-
records: Result
|
3316
|
+
records: RecordArray<Result>;
|
3119
3317
|
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3120
3318
|
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3121
3319
|
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
@@ -3135,7 +3333,7 @@ declare class Page<Record extends XataRecord, Result extends XataRecord = Record
|
|
3135
3333
|
/**
|
3136
3334
|
* The set of results for this page.
|
3137
3335
|
*/
|
3138
|
-
readonly records: Result
|
3336
|
+
readonly records: RecordArray<Result>;
|
3139
3337
|
constructor(query: Query<Record, Result>, meta: PaginationQueryMeta, records?: Result[]);
|
3140
3338
|
/**
|
3141
3339
|
* Retrieves the next page of results.
|
@@ -3183,11 +3381,44 @@ declare type OffsetNavigationOptions = {
|
|
3183
3381
|
size?: number;
|
3184
3382
|
offset?: number;
|
3185
3383
|
};
|
3186
|
-
declare type PaginationOptions = CursorNavigationOptions & OffsetNavigationOptions;
|
3187
3384
|
declare const PAGINATION_MAX_SIZE = 200;
|
3188
|
-
declare const PAGINATION_DEFAULT_SIZE =
|
3385
|
+
declare const PAGINATION_DEFAULT_SIZE = 20;
|
3189
3386
|
declare const PAGINATION_MAX_OFFSET = 800;
|
3190
3387
|
declare const PAGINATION_DEFAULT_OFFSET = 0;
|
3388
|
+
declare function isCursorPaginationOptions(options: Record<string, unknown> | undefined | null): options is CursorNavigationOptions;
|
3389
|
+
declare class RecordArray<Result extends XataRecord> extends Array<Result> {
|
3390
|
+
#private;
|
3391
|
+
constructor(page: Paginable<any, Result>, overrideRecords?: Result[]);
|
3392
|
+
static parseConstructorParams(...args: any[]): any[];
|
3393
|
+
/**
|
3394
|
+
* Retrieve next page of records
|
3395
|
+
*
|
3396
|
+
* @returns A new array of objects
|
3397
|
+
*/
|
3398
|
+
nextPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3399
|
+
/**
|
3400
|
+
* Retrieve previous page of records
|
3401
|
+
*
|
3402
|
+
* @returns A new array of objects
|
3403
|
+
*/
|
3404
|
+
previousPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3405
|
+
/**
|
3406
|
+
* Retrieve first page of records
|
3407
|
+
*
|
3408
|
+
* @returns A new array of objects
|
3409
|
+
*/
|
3410
|
+
firstPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3411
|
+
/**
|
3412
|
+
* Retrieve last page of records
|
3413
|
+
*
|
3414
|
+
* @returns A new array of objects
|
3415
|
+
*/
|
3416
|
+
lastPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3417
|
+
/**
|
3418
|
+
* @returns Boolean indicating if there is a next page
|
3419
|
+
*/
|
3420
|
+
hasNextPage(): boolean;
|
3421
|
+
}
|
3191
3422
|
|
3192
3423
|
/**
|
3193
3424
|
* Common interface for performing operations on a table.
|
@@ -3213,6 +3444,24 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
3213
3444
|
* @returns The persisted record for the given id or null if the record could not be found.
|
3214
3445
|
*/
|
3215
3446
|
abstract read(id: string): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
|
3447
|
+
/**
|
3448
|
+
* Queries multiple records from the table given their unique id.
|
3449
|
+
* @param ids The unique ids array.
|
3450
|
+
* @returns The persisted records for the given ids (if a record could not be found it is not returned).
|
3451
|
+
*/
|
3452
|
+
abstract read(ids: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3453
|
+
/**
|
3454
|
+
* Queries a single record from the table by the id in the object.
|
3455
|
+
* @param object Object containing the id of the record.
|
3456
|
+
* @returns The persisted record for the given id or null if the record could not be found.
|
3457
|
+
*/
|
3458
|
+
abstract read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
|
3459
|
+
/**
|
3460
|
+
* Queries multiple records from the table by the ids in the objects.
|
3461
|
+
* @param objects Array of objects containing the ids of the records.
|
3462
|
+
* @returns The persisted records for the given ids (if a record could not be found it is not returned).
|
3463
|
+
*/
|
3464
|
+
abstract read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3216
3465
|
/**
|
3217
3466
|
* Partially update a single record.
|
3218
3467
|
* @param object An object with its id and the columns to be updated.
|
@@ -3285,7 +3534,9 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
3285
3534
|
* @returns The found records.
|
3286
3535
|
*/
|
3287
3536
|
abstract search(query: string, options?: {
|
3288
|
-
fuzziness?:
|
3537
|
+
fuzziness?: FuzzinessExpression;
|
3538
|
+
highlight?: HighlightExpression;
|
3539
|
+
filter?: Filter<Record>;
|
3289
3540
|
}): Promise<SelectedPick<Record, ['*']>[]>;
|
3290
3541
|
abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
3291
3542
|
}
|
@@ -3297,10 +3548,13 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
|
|
3297
3548
|
db: SchemaPluginResult<any>;
|
3298
3549
|
pluginOptions: XataPluginOptions;
|
3299
3550
|
});
|
3300
|
-
create(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']
|
3301
|
-
create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']
|
3302
|
-
create(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']
|
3551
|
+
create(object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3552
|
+
create(recordId: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3553
|
+
create(objects: EditableData<Data>[]): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
|
3303
3554
|
read(recordId: string): Promise<SelectedPick<Record, ['*']> | null>;
|
3555
|
+
read(recordIds: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3556
|
+
read(object: Identifiable): Promise<SelectedPick<Record, ['*']> | null>;
|
3557
|
+
read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3304
3558
|
update(object: Partial<EditableData<Data>> & Identifiable): Promise<SelectedPick<Record, ['*']>>;
|
3305
3559
|
update(recordId: string, object: Partial<EditableData<Data>>): Promise<SelectedPick<Record, ['*']>>;
|
3306
3560
|
update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<SelectedPick<Record, ['*']>[]>;
|
@@ -3309,7 +3563,9 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
|
|
3309
3563
|
createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
|
3310
3564
|
delete(a: string | Identifiable | Array<string | Identifiable>): Promise<void>;
|
3311
3565
|
search(query: string, options?: {
|
3312
|
-
fuzziness?:
|
3566
|
+
fuzziness?: FuzzinessExpression;
|
3567
|
+
highlight?: HighlightExpression;
|
3568
|
+
filter?: Filter<Record>;
|
3313
3569
|
}): Promise<SelectedPick<Record, ['*']>[]>;
|
3314
3570
|
query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
3315
3571
|
}
|
@@ -3403,18 +3659,24 @@ declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends Xat
|
|
3403
3659
|
}
|
3404
3660
|
|
3405
3661
|
declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
|
3406
|
-
fuzziness?:
|
3407
|
-
|
3662
|
+
fuzziness?: FuzzinessExpression;
|
3663
|
+
highlight?: HighlightExpression;
|
3664
|
+
tables?: Array<Tables | Values<{
|
3665
|
+
[Model in GetArrayInnerType<NonNullable<Tables[]>>]: {
|
3666
|
+
table: Model;
|
3667
|
+
filter?: Filter<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
|
3668
|
+
};
|
3669
|
+
}>>;
|
3408
3670
|
};
|
3409
3671
|
declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
|
3410
3672
|
all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
|
3411
|
-
[Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']
|
3673
|
+
[Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]: {
|
3412
3674
|
table: Model;
|
3413
3675
|
record: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
|
3414
3676
|
};
|
3415
3677
|
}>[]>;
|
3416
3678
|
byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
|
3417
|
-
[Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']
|
3679
|
+
[Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
|
3418
3680
|
}>;
|
3419
3681
|
};
|
3420
3682
|
declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
@@ -3423,11 +3685,19 @@ declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends Xat
|
|
3423
3685
|
constructor(db: SchemaPluginResult<Schemas>);
|
3424
3686
|
build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
|
3425
3687
|
}
|
3426
|
-
declare type SearchXataRecord = XataRecord
|
3427
|
-
|
3428
|
-
|
3688
|
+
declare type SearchXataRecord = XataRecord<SearchExtraProperties>;
|
3689
|
+
declare type SearchExtraProperties = {
|
3690
|
+
table: string;
|
3691
|
+
highlight?: {
|
3692
|
+
[key: string]: string[] | {
|
3693
|
+
[key: string]: any;
|
3694
|
+
};
|
3429
3695
|
};
|
3430
3696
|
};
|
3697
|
+
declare type ReturnTable<Table, Tables> = Table extends Tables ? Table : never;
|
3698
|
+
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 {
|
3699
|
+
table: infer Table;
|
3700
|
+
} ? ReturnTable<Table, Tables> : never;
|
3431
3701
|
|
3432
3702
|
declare type BranchStrategyValue = string | undefined | null;
|
3433
3703
|
declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
|
@@ -3470,4 +3740,4 @@ declare class XataError extends Error {
|
|
3470
3740
|
constructor(message: string, status: number);
|
3471
3741
|
}
|
3472
3742
|
|
3473
|
-
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,
|
3743
|
+
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, RecordArray, 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 };
|