@xata.io/client 0.0.0-alpha.vf976907 → 0.0.0-alpha.vfae42b5
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 +34 -0
- package/README.md +258 -1
- package/dist/index.cjs +133 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +304 -106
- package/dist/index.mjs +132 -66
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -2
- package/tsconfig.json +1 -0
package/dist/index.d.ts
CHANGED
@@ -268,6 +268,17 @@ declare type SortExpression = string[] | {
|
|
268
268
|
[key: string]: SortOrder;
|
269
269
|
}[];
|
270
270
|
declare type SortOrder = 'asc' | 'desc';
|
271
|
+
/**
|
272
|
+
* Maximum [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) for the search terms. The Levenshtein
|
273
|
+
* distance is the number of one charcter changes needed to make two strings equal. The default is 1, meaning that single
|
274
|
+
* character typos per word are tollerated by search. You can set it to 0 to remove the typo tollerance or set it to 2
|
275
|
+
* to allow two typos in a word.
|
276
|
+
*
|
277
|
+
* @default 1
|
278
|
+
* @maximum 2
|
279
|
+
* @minimum 0
|
280
|
+
*/
|
281
|
+
declare type FuzzinessExpression = number;
|
271
282
|
/**
|
272
283
|
* @minProperties 1
|
273
284
|
*/
|
@@ -281,6 +292,10 @@ declare type FilterExpression = {
|
|
281
292
|
} & {
|
282
293
|
[key: string]: FilterColumn;
|
283
294
|
};
|
295
|
+
declare type HighlightExpression = {
|
296
|
+
enabled?: boolean;
|
297
|
+
encodeHTML?: boolean;
|
298
|
+
};
|
284
299
|
declare type FilterList = FilterExpression | FilterExpression[];
|
285
300
|
declare type FilterColumn = FilterColumnIncludes | FilterPredicate | FilterList;
|
286
301
|
/**
|
@@ -366,6 +381,11 @@ declare type XataRecord$1 = {
|
|
366
381
|
xata: {
|
367
382
|
version: number;
|
368
383
|
table?: string;
|
384
|
+
highlight?: {
|
385
|
+
[key: string]: string[] | {
|
386
|
+
[key: string]: any;
|
387
|
+
};
|
388
|
+
};
|
369
389
|
warnings?: string[];
|
370
390
|
};
|
371
391
|
} & {
|
@@ -409,7 +429,9 @@ type schemas_TableMigration = TableMigration;
|
|
409
429
|
type schemas_ColumnMigration = ColumnMigration;
|
410
430
|
type schemas_SortExpression = SortExpression;
|
411
431
|
type schemas_SortOrder = SortOrder;
|
432
|
+
type schemas_FuzzinessExpression = FuzzinessExpression;
|
412
433
|
type schemas_FilterExpression = FilterExpression;
|
434
|
+
type schemas_HighlightExpression = HighlightExpression;
|
413
435
|
type schemas_FilterList = FilterList;
|
414
436
|
type schemas_FilterColumn = FilterColumn;
|
415
437
|
type schemas_FilterColumnIncludes = FilterColumnIncludes;
|
@@ -462,7 +484,9 @@ declare namespace schemas {
|
|
462
484
|
schemas_ColumnMigration as ColumnMigration,
|
463
485
|
schemas_SortExpression as SortExpression,
|
464
486
|
schemas_SortOrder as SortOrder,
|
487
|
+
schemas_FuzzinessExpression as FuzzinessExpression,
|
465
488
|
schemas_FilterExpression as FilterExpression,
|
489
|
+
schemas_HighlightExpression as HighlightExpression,
|
466
490
|
schemas_FilterList as FilterList,
|
467
491
|
schemas_FilterColumn as FilterColumn,
|
468
492
|
schemas_FilterColumnIncludes as FilterColumnIncludes,
|
@@ -1151,14 +1175,15 @@ declare type ResolveBranchVariables = {
|
|
1151
1175
|
} & FetcherExtraProps;
|
1152
1176
|
/**
|
1153
1177
|
* 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
|
1178
|
+
* * if the `gitBranch` was provided and is found in the [git branches mapping](/api-reference/dbs/db_name/gitBranches), the associated Xata branch is returned
|
1155
1179
|
* * else, if a Xata branch with the exact same name as `gitBranch` exists, return it
|
1156
|
-
* * else,
|
1180
|
+
* * else, if `fallbackBranch` is provided and a branch with that name exists, return it
|
1181
|
+
* * else, return the default branch of the DB (`main` or the first branch)
|
1157
1182
|
*
|
1158
1183
|
* Example call:
|
1159
1184
|
*
|
1160
1185
|
* ```json
|
1161
|
-
* // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test
|
1186
|
+
* // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test&fallbackBranch=tsg
|
1162
1187
|
* ```
|
1163
1188
|
*
|
1164
1189
|
* Example response:
|
@@ -1458,8 +1483,9 @@ declare type UpdateTableVariables = {
|
|
1458
1483
|
*
|
1459
1484
|
* In the example below, we rename a table from “users” to “people”:
|
1460
1485
|
*
|
1461
|
-
* ```
|
1462
|
-
* PATCH /db/test:main/tables/users
|
1486
|
+
* ```json
|
1487
|
+
* // PATCH /db/test:main/tables/users
|
1488
|
+
*
|
1463
1489
|
* {
|
1464
1490
|
* "name": "people"
|
1465
1491
|
* }
|
@@ -1867,7 +1893,7 @@ declare type QueryTableVariables = {
|
|
1867
1893
|
* {
|
1868
1894
|
* "columns": [...],
|
1869
1895
|
* "filter": {
|
1870
|
-
* "$all": [...]
|
1896
|
+
* "$all": [...],
|
1871
1897
|
* "$any": [...]
|
1872
1898
|
* ...
|
1873
1899
|
* },
|
@@ -2005,7 +2031,7 @@ declare type QueryTableVariables = {
|
|
2005
2031
|
* {
|
2006
2032
|
* "name": "Kilian",
|
2007
2033
|
* "address": {
|
2008
|
-
* "street": "New street"
|
2034
|
+
* "street": "New street"
|
2009
2035
|
* }
|
2010
2036
|
* }
|
2011
2037
|
* ```
|
@@ -2014,10 +2040,7 @@ declare type QueryTableVariables = {
|
|
2014
2040
|
*
|
2015
2041
|
* ```json
|
2016
2042
|
* {
|
2017
|
-
* "columns": [
|
2018
|
-
* "*",
|
2019
|
-
* "team.name"
|
2020
|
-
* ]
|
2043
|
+
* "columns": ["*", "team.name"]
|
2021
2044
|
* }
|
2022
2045
|
* ```
|
2023
2046
|
*
|
@@ -2035,7 +2058,7 @@ declare type QueryTableVariables = {
|
|
2035
2058
|
* "team": {
|
2036
2059
|
* "id": "XX",
|
2037
2060
|
* "xata": {
|
2038
|
-
* "version": 0
|
2061
|
+
* "version": 0
|
2039
2062
|
* },
|
2040
2063
|
* "name": "first team"
|
2041
2064
|
* }
|
@@ -2046,10 +2069,7 @@ declare type QueryTableVariables = {
|
|
2046
2069
|
*
|
2047
2070
|
* ```json
|
2048
2071
|
* {
|
2049
|
-
* "columns": [
|
2050
|
-
* "*",
|
2051
|
-
* "team.*"
|
2052
|
-
* ]
|
2072
|
+
* "columns": ["*", "team.*"]
|
2053
2073
|
* }
|
2054
2074
|
* ```
|
2055
2075
|
*
|
@@ -2067,7 +2087,7 @@ declare type QueryTableVariables = {
|
|
2067
2087
|
* "team": {
|
2068
2088
|
* "id": "XX",
|
2069
2089
|
* "xata": {
|
2070
|
-
* "version": 0
|
2090
|
+
* "version": 0
|
2071
2091
|
* },
|
2072
2092
|
* "name": "first team",
|
2073
2093
|
* "code": "A1",
|
@@ -2117,7 +2137,7 @@ declare type QueryTableVariables = {
|
|
2117
2137
|
* ```json
|
2118
2138
|
* {
|
2119
2139
|
* "filter": {
|
2120
|
-
*
|
2140
|
+
* "name": "r2"
|
2121
2141
|
* }
|
2122
2142
|
* }
|
2123
2143
|
* ```
|
@@ -2139,7 +2159,7 @@ declare type QueryTableVariables = {
|
|
2139
2159
|
* ```json
|
2140
2160
|
* {
|
2141
2161
|
* "filter": {
|
2142
|
-
*
|
2162
|
+
* "settings.plan": "free"
|
2143
2163
|
* }
|
2144
2164
|
* }
|
2145
2165
|
* ```
|
@@ -2149,8 +2169,8 @@ declare type QueryTableVariables = {
|
|
2149
2169
|
* "filter": {
|
2150
2170
|
* "settings": {
|
2151
2171
|
* "plan": "free"
|
2152
|
-
* }
|
2153
|
-
* }
|
2172
|
+
* }
|
2173
|
+
* }
|
2154
2174
|
* }
|
2155
2175
|
* ```
|
2156
2176
|
*
|
@@ -2159,8 +2179,8 @@ declare type QueryTableVariables = {
|
|
2159
2179
|
* ```json
|
2160
2180
|
* {
|
2161
2181
|
* "filter": {
|
2162
|
-
* "settings.plan": {"$any": ["free", "paid"]}
|
2163
|
-
* }
|
2182
|
+
* "settings.plan": { "$any": ["free", "paid"] }
|
2183
|
+
* }
|
2164
2184
|
* }
|
2165
2185
|
* ```
|
2166
2186
|
*
|
@@ -2169,9 +2189,9 @@ declare type QueryTableVariables = {
|
|
2169
2189
|
* ```json
|
2170
2190
|
* {
|
2171
2191
|
* "filter": {
|
2172
|
-
*
|
2173
|
-
*
|
2174
|
-
* }
|
2192
|
+
* "settings.dark": true,
|
2193
|
+
* "settings.plan": "free"
|
2194
|
+
* }
|
2175
2195
|
* }
|
2176
2196
|
* ```
|
2177
2197
|
*
|
@@ -2182,11 +2202,11 @@ declare type QueryTableVariables = {
|
|
2182
2202
|
* ```json
|
2183
2203
|
* {
|
2184
2204
|
* "filter": {
|
2185
|
-
*
|
2186
|
-
*
|
2187
|
-
*
|
2188
|
-
*
|
2189
|
-
* }
|
2205
|
+
* "$any": {
|
2206
|
+
* "settings.dark": true,
|
2207
|
+
* "settings.plan": "free"
|
2208
|
+
* }
|
2209
|
+
* }
|
2190
2210
|
* }
|
2191
2211
|
* ```
|
2192
2212
|
*
|
@@ -2197,10 +2217,10 @@ declare type QueryTableVariables = {
|
|
2197
2217
|
* "filter": {
|
2198
2218
|
* "$any": [
|
2199
2219
|
* {
|
2200
|
-
* "name": "r1"
|
2220
|
+
* "name": "r1"
|
2201
2221
|
* },
|
2202
2222
|
* {
|
2203
|
-
* "name": "r2"
|
2223
|
+
* "name": "r2"
|
2204
2224
|
* }
|
2205
2225
|
* ]
|
2206
2226
|
* }
|
@@ -2212,7 +2232,7 @@ declare type QueryTableVariables = {
|
|
2212
2232
|
* ```json
|
2213
2233
|
* {
|
2214
2234
|
* "filter": {
|
2215
|
-
* "$exists": "settings"
|
2235
|
+
* "$exists": "settings"
|
2216
2236
|
* }
|
2217
2237
|
* }
|
2218
2238
|
* ```
|
@@ -2224,10 +2244,10 @@ declare type QueryTableVariables = {
|
|
2224
2244
|
* "filter": {
|
2225
2245
|
* "$all": [
|
2226
2246
|
* {
|
2227
|
-
* "$exists": "settings"
|
2247
|
+
* "$exists": "settings"
|
2228
2248
|
* },
|
2229
2249
|
* {
|
2230
|
-
* "$exists": "name"
|
2250
|
+
* "$exists": "name"
|
2231
2251
|
* }
|
2232
2252
|
* ]
|
2233
2253
|
* }
|
@@ -2239,7 +2259,7 @@ declare type QueryTableVariables = {
|
|
2239
2259
|
* ```json
|
2240
2260
|
* {
|
2241
2261
|
* "filter": {
|
2242
|
-
* "$notExists": "settings"
|
2262
|
+
* "$notExists": "settings"
|
2243
2263
|
* }
|
2244
2264
|
* }
|
2245
2265
|
* ```
|
@@ -2266,22 +2286,28 @@ declare type QueryTableVariables = {
|
|
2266
2286
|
* {
|
2267
2287
|
* "filter": {
|
2268
2288
|
* "<column_name>": {
|
2269
|
-
*
|
2289
|
+
* "$pattern": "v*alu?"
|
2270
2290
|
* }
|
2271
2291
|
* }
|
2272
2292
|
* }
|
2273
2293
|
* ```
|
2274
2294
|
*
|
2295
|
+
* The `$pattern` operator accepts two wildcard characters:
|
2296
|
+
* * `*` matches zero or more characters
|
2297
|
+
* * `?` matches exactly one character
|
2298
|
+
*
|
2299
|
+
* If you want to match a string that contains a wildcard character, you can escape them using a backslash (`\`). You can escape a backslash by usign another backslash.
|
2300
|
+
*
|
2275
2301
|
* We could also have `$endsWith` and `$startsWith` operators:
|
2276
2302
|
*
|
2277
2303
|
* ```json
|
2278
2304
|
* {
|
2279
2305
|
* "filter": {
|
2280
2306
|
* "<column_name>": {
|
2281
|
-
*
|
2307
|
+
* "$endsWith": ".gz"
|
2282
2308
|
* },
|
2283
2309
|
* "<column_name>": {
|
2284
|
-
*
|
2310
|
+
* "$startsWith": "tmp-"
|
2285
2311
|
* }
|
2286
2312
|
* }
|
2287
2313
|
* }
|
@@ -2292,10 +2318,10 @@ declare type QueryTableVariables = {
|
|
2292
2318
|
* ```json
|
2293
2319
|
* {
|
2294
2320
|
* "filter": {
|
2295
|
-
*
|
2296
|
-
*
|
2297
|
-
*
|
2298
|
-
*
|
2321
|
+
* "<column_name>": {
|
2322
|
+
* "$ge": 0,
|
2323
|
+
* "$lt": 100
|
2324
|
+
* }
|
2299
2325
|
* }
|
2300
2326
|
* }
|
2301
2327
|
* ```
|
@@ -2313,7 +2339,6 @@ declare type QueryTableVariables = {
|
|
2313
2339
|
* ```
|
2314
2340
|
* The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
|
2315
2341
|
*
|
2316
|
-
*
|
2317
2342
|
* #### Negations
|
2318
2343
|
*
|
2319
2344
|
* A general `$not` operator can inverse any operation.
|
@@ -2338,15 +2363,21 @@ declare type QueryTableVariables = {
|
|
2338
2363
|
* {
|
2339
2364
|
* "filter": {
|
2340
2365
|
* "$not": {
|
2341
|
-
* "$any": [
|
2342
|
-
*
|
2343
|
-
*
|
2344
|
-
*
|
2345
|
-
*
|
2346
|
-
*
|
2347
|
-
*
|
2348
|
-
*
|
2349
|
-
*
|
2366
|
+
* "$any": [
|
2367
|
+
* {
|
2368
|
+
* "<column_name1>": "value1"
|
2369
|
+
* },
|
2370
|
+
* {
|
2371
|
+
* "$all": [
|
2372
|
+
* {
|
2373
|
+
* "<column_name2>": "value2"
|
2374
|
+
* },
|
2375
|
+
* {
|
2376
|
+
* "<column_name3>": "value3"
|
2377
|
+
* }
|
2378
|
+
* ]
|
2379
|
+
* }
|
2380
|
+
* ]
|
2350
2381
|
* }
|
2351
2382
|
* }
|
2352
2383
|
* }
|
@@ -2401,8 +2432,8 @@ declare type QueryTableVariables = {
|
|
2401
2432
|
* "<array name>": {
|
2402
2433
|
* "$includes": {
|
2403
2434
|
* "$all": [
|
2404
|
-
* {"$contains": "label"},
|
2405
|
-
* {"$not": {"$endsWith": "-debug"}}
|
2435
|
+
* { "$contains": "label" },
|
2436
|
+
* { "$not": { "$endsWith": "-debug" } }
|
2406
2437
|
* ]
|
2407
2438
|
* }
|
2408
2439
|
* }
|
@@ -2422,9 +2453,7 @@ declare type QueryTableVariables = {
|
|
2422
2453
|
* {
|
2423
2454
|
* "filter": {
|
2424
2455
|
* "settings.labels": {
|
2425
|
-
* "$includesAll": [
|
2426
|
-
* {"$contains": "label"},
|
2427
|
-
* ]
|
2456
|
+
* "$includesAll": [{ "$contains": "label" }]
|
2428
2457
|
* }
|
2429
2458
|
* }
|
2430
2459
|
* }
|
@@ -2472,7 +2501,6 @@ declare type QueryTableVariables = {
|
|
2472
2501
|
* }
|
2473
2502
|
* ```
|
2474
2503
|
*
|
2475
|
-
*
|
2476
2504
|
* ### Pagination
|
2477
2505
|
*
|
2478
2506
|
* We offer cursor pagination and offset pagination. The offset pagination is limited
|
@@ -2538,8 +2566,8 @@ declare type QueryTableVariables = {
|
|
2538
2566
|
* can be queried by update `page.after` to the returned cursor while keeping the
|
2539
2567
|
* `page.before` cursor from the first range query.
|
2540
2568
|
*
|
2541
|
-
* The `filter` , `columns`,
|
2542
|
-
* encoded with the cursor.
|
2569
|
+
* The `filter` , `columns`, `sort` , and `page.size` configuration will be
|
2570
|
+
* encoded with the cursor. The pagination request will be invalid if
|
2543
2571
|
* `filter` or `sort` is set. The columns returned and page size can be changed
|
2544
2572
|
* anytime by passing the `columns` or `page.size` settings to the next query.
|
2545
2573
|
*
|
@@ -2576,6 +2604,39 @@ declare type QueryTableVariables = {
|
|
2576
2604
|
* ```
|
2577
2605
|
*/
|
2578
2606
|
declare const queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
2607
|
+
declare type SearchTablePathParams = {
|
2608
|
+
dbBranchName: DBBranchName;
|
2609
|
+
tableName: TableName;
|
2610
|
+
workspace: string;
|
2611
|
+
};
|
2612
|
+
declare type SearchTableError = ErrorWrapper<{
|
2613
|
+
status: 400;
|
2614
|
+
payload: BadRequestError;
|
2615
|
+
} | {
|
2616
|
+
status: 401;
|
2617
|
+
payload: AuthError;
|
2618
|
+
} | {
|
2619
|
+
status: 404;
|
2620
|
+
payload: SimpleError;
|
2621
|
+
}>;
|
2622
|
+
declare type SearchTableRequestBody = {
|
2623
|
+
query: string;
|
2624
|
+
fuzziness?: FuzzinessExpression;
|
2625
|
+
filter?: FilterExpression;
|
2626
|
+
highlight?: HighlightExpression;
|
2627
|
+
};
|
2628
|
+
declare type SearchTableVariables = {
|
2629
|
+
body: SearchTableRequestBody;
|
2630
|
+
pathParams: SearchTablePathParams;
|
2631
|
+
} & FetcherExtraProps;
|
2632
|
+
/**
|
2633
|
+
* Run a free text search operation in a particular table.
|
2634
|
+
*
|
2635
|
+
* The endpoint accepts a `query` parameter that is used for the free text search and a set of structured filters (via the `filter` parameter) that are applied before the search. The `filter` parameter uses the same syntax as the [query endpoint](/api-reference/db/db_branch_name/tables/table_name/) with the following exceptions:
|
2636
|
+
* * filters `$contains`, `$startsWith`, `$endsWith` don't work on columns of type `text`
|
2637
|
+
* * filtering on columns of type `multiple` is currently unsupported
|
2638
|
+
*/
|
2639
|
+
declare const searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
|
2579
2640
|
declare type SearchBranchPathParams = {
|
2580
2641
|
dbBranchName: DBBranchName;
|
2581
2642
|
workspace: string;
|
@@ -2591,9 +2652,13 @@ declare type SearchBranchError = ErrorWrapper<{
|
|
2591
2652
|
payload: SimpleError;
|
2592
2653
|
}>;
|
2593
2654
|
declare type SearchBranchRequestBody = {
|
2594
|
-
tables?: string
|
2655
|
+
tables?: (string | {
|
2656
|
+
table: string;
|
2657
|
+
filter?: FilterExpression;
|
2658
|
+
})[];
|
2595
2659
|
query: string;
|
2596
|
-
fuzziness?:
|
2660
|
+
fuzziness?: FuzzinessExpression;
|
2661
|
+
highlight?: HighlightExpression;
|
2597
2662
|
};
|
2598
2663
|
declare type SearchBranchVariables = {
|
2599
2664
|
body: SearchBranchRequestBody;
|
@@ -2668,6 +2733,7 @@ declare const operationsByTag: {
|
|
2668
2733
|
getRecord: (variables: GetRecordVariables) => Promise<XataRecord$1>;
|
2669
2734
|
bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
|
2670
2735
|
queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
2736
|
+
searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
|
2671
2737
|
searchBranch: (variables: SearchBranchVariables) => Promise<SearchResponse>;
|
2672
2738
|
};
|
2673
2739
|
};
|
@@ -2773,6 +2839,7 @@ declare class RecordsApi {
|
|
2773
2839
|
getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: GetRecordRequestBody): Promise<XataRecord$1>;
|
2774
2840
|
bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[]): Promise<BulkInsertTableRecordsResponse>;
|
2775
2841
|
queryTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: QueryTableRequestBody): Promise<QueryResponse>;
|
2842
|
+
searchTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: SearchTableRequestBody): Promise<SearchResponse>;
|
2776
2843
|
searchBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, query: SearchBranchRequestBody): Promise<SearchResponse>;
|
2777
2844
|
}
|
2778
2845
|
|
@@ -2800,24 +2867,25 @@ declare type SelectableColumn<O, RecursivePath extends any[] = []> = '*' | 'id'
|
|
2800
2867
|
declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord & UnionToIntersection<Values<{
|
2801
2868
|
[K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord;
|
2802
2869
|
}>>;
|
2803
|
-
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
|
2804
|
-
V: ValueAtColumn<O[K]
|
2805
|
-
} : never
|
2870
|
+
declare type ValueAtColumn<O, P extends SelectableColumn<O>> = P extends '*' ? Values<O> : P extends 'id' ? string : P extends keyof O ? O[P] : P extends `${infer K}.${infer V}` ? K extends keyof O ? Values<RemoveNullable<O[K]> extends Record<string, any> ? V extends SelectableColumn<RemoveNullable<O[K]>> ? {
|
2871
|
+
V: ValueAtColumn<RemoveNullable<O[K]>, V>;
|
2872
|
+
} : never : O[K]> : never : never;
|
2806
2873
|
declare type MAX_RECURSION = 5;
|
2807
2874
|
declare type NestedColumns<O, RecursivePath extends any[]> = RecursivePath['length'] extends MAX_RECURSION ? never : If<IsObject<O>, Values<{
|
2808
|
-
[K in DataProps<O>]: If<IsArray<
|
2809
|
-
If<IsObject<
|
2875
|
+
[K in DataProps<O>]: If<IsArray<RemoveNullable<O[K]>>, K, // If the property is an array, we stop recursion. We don't support object arrays yet
|
2876
|
+
If<IsObject<RemoveNullable<O[K]>>, RemoveNullable<O[K]> extends XataRecord ? SelectableColumn<RemoveNullable<O[K]>, [...RecursivePath, O[K]]> extends infer Column ? Column extends string ? K | `${K}.${Column}` : never : never : `${K}.${StringKeys<RemoveNullable<O[K]>> | '*'}`, // This allows usage of objects that are not links
|
2810
2877
|
K>>;
|
2811
2878
|
}>, never>;
|
2812
2879
|
declare type DataProps<O> = Exclude<StringKeys<O>, StringKeys<XataRecord>>;
|
2813
2880
|
declare type NestedValueAtColumn<O, Key extends SelectableColumn<O>> = Key extends `${infer N}.${infer M}` ? N extends DataProps<O> ? {
|
2814
|
-
[K in N]: M extends SelectableColumn<
|
2881
|
+
[K in N]: M extends SelectableColumn<RemoveNullable<O[K]>> ? RemoveNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], NestedValueAtColumn<RemoveNullable<O[K]>, M> & XataRecord> : ForwardNullable<O[K], NestedValueAtColumn<RemoveNullable<O[K]>, M>> : unknown;
|
2815
2882
|
} : unknown : Key extends DataProps<O> ? {
|
2816
|
-
[K in Key]:
|
2883
|
+
[K in Key]: RemoveNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], SelectedPick<RemoveNullable<O[K]>, ['*']>> : O[K];
|
2817
2884
|
} : Key extends '*' ? {
|
2818
|
-
[K in StringKeys<O>]:
|
2885
|
+
[K in StringKeys<O>]: RemoveNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], Link<RemoveNullable<O[K]>>> : O[K];
|
2819
2886
|
} : unknown;
|
2820
|
-
declare type
|
2887
|
+
declare type RemoveNullable<T> = T extends null | undefined ? never : T;
|
2888
|
+
declare type ForwardNullable<T, R> = T extends RemoveNullable<T> ? R : R | null;
|
2821
2889
|
|
2822
2890
|
/**
|
2823
2891
|
* Represents an identifiable record from the database.
|
@@ -2834,16 +2902,11 @@ interface BaseData {
|
|
2834
2902
|
/**
|
2835
2903
|
* Represents a persisted record from the database.
|
2836
2904
|
*/
|
2837
|
-
interface XataRecord extends Identifiable {
|
2905
|
+
interface XataRecord<ExtraMetadata extends Record<string, unknown> = Record<string, unknown>> extends Identifiable {
|
2838
2906
|
/**
|
2839
|
-
*
|
2907
|
+
* Get metadata of this record.
|
2840
2908
|
*/
|
2841
|
-
|
2842
|
-
/**
|
2843
|
-
* Number that is increased every time the record is updated.
|
2844
|
-
*/
|
2845
|
-
version: number;
|
2846
|
-
};
|
2909
|
+
getMetadata(): XataRecordMetadata & ExtraMetadata;
|
2847
2910
|
/**
|
2848
2911
|
* Retrieves a refreshed copy of the current record from the database.
|
2849
2912
|
*/
|
@@ -2851,7 +2914,7 @@ interface XataRecord extends Identifiable {
|
|
2851
2914
|
/**
|
2852
2915
|
* Performs a partial update of the current record. On success a new object is
|
2853
2916
|
* returned and the current object is not mutated.
|
2854
|
-
* @param
|
2917
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
2855
2918
|
* @returns A new record containing the latest values for all the columns of the current record.
|
2856
2919
|
*/
|
2857
2920
|
update(partialUpdate: Partial<EditableData<Omit<this, keyof XataRecord>>>): Promise<Readonly<SelectedPick<this, ['*']>>>;
|
@@ -2870,11 +2933,18 @@ declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update
|
|
2870
2933
|
/**
|
2871
2934
|
* Performs a partial update of the current record. On success a new object is
|
2872
2935
|
* returned and the current object is not mutated.
|
2873
|
-
* @param
|
2936
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
2874
2937
|
* @returns A new record containing the latest values for all the columns of the current record.
|
2875
2938
|
*/
|
2876
2939
|
update(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
2877
2940
|
};
|
2941
|
+
declare type XataRecordMetadata = {
|
2942
|
+
/**
|
2943
|
+
* Number that is increased every time the record is updated.
|
2944
|
+
*/
|
2945
|
+
version: number;
|
2946
|
+
warnings?: string[];
|
2947
|
+
};
|
2878
2948
|
declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
|
2879
2949
|
declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
|
2880
2950
|
declare type EditableData<O extends BaseData> = {
|
@@ -2958,8 +3028,8 @@ declare type ValueTypeFilters<T> = T | T extends string ? StringTypeFilter : T e
|
|
2958
3028
|
],
|
2959
3029
|
}
|
2960
3030
|
*/
|
2961
|
-
declare type AggregatorFilter<
|
2962
|
-
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<
|
3031
|
+
declare type AggregatorFilter<T> = {
|
3032
|
+
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<T>>;
|
2963
3033
|
};
|
2964
3034
|
/**
|
2965
3035
|
* Existance filter
|
@@ -2974,10 +3044,10 @@ declare type BaseApiFilter<Record> = PropertyAccessFilter<Record> | AggregatorFi
|
|
2974
3044
|
* Injects the Api filters on nested properties
|
2975
3045
|
* Example: { filter: { settings: { plan: { $any: ['free', 'trial'] } } } }
|
2976
3046
|
*/
|
2977
|
-
declare type NestedApiFilter<T> =
|
3047
|
+
declare type NestedApiFilter<T> = {
|
2978
3048
|
[key in keyof T]?: T[key] extends Record<string, any> ? SingleOrArray<Filter<T[key]>> : PropertyFilter<T[key]>;
|
2979
|
-
}
|
2980
|
-
declare type Filter<
|
3049
|
+
};
|
3050
|
+
declare type Filter<T> = T extends Record<string, any> ? BaseApiFilter<T> | NestedApiFilter<T> : PropertyFilter<T>;
|
2981
3051
|
|
2982
3052
|
declare type SortDirection = 'asc' | 'desc';
|
2983
3053
|
declare type SortFilterExtended<T extends XataRecord> = {
|
@@ -3014,7 +3084,7 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
3014
3084
|
#private;
|
3015
3085
|
readonly meta: PaginationQueryMeta;
|
3016
3086
|
readonly records: Result[];
|
3017
|
-
constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>,
|
3087
|
+
constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, rawParent?: Partial<QueryOptions<Record>>);
|
3018
3088
|
getQueryOptions(): QueryOptions<Record>;
|
3019
3089
|
key(): string;
|
3020
3090
|
/**
|
@@ -3046,18 +3116,28 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
3046
3116
|
*
|
3047
3117
|
* ```
|
3048
3118
|
* query.filter("columnName", columnValue)
|
3049
|
-
* query.filter(
|
3050
|
-
*
|
3051
|
-
*
|
3119
|
+
* query.filter("columnName", operator(columnValue)) // Use gt, gte, lt, lte, startsWith,...
|
3120
|
+
* ```
|
3121
|
+
*
|
3122
|
+
* @param column The name of the column to filter.
|
3123
|
+
* @param value The value to filter.
|
3124
|
+
* @returns A new Query object.
|
3125
|
+
*/
|
3126
|
+
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
|
3127
|
+
/**
|
3128
|
+
* Builds a new query object adding one or more constraints. Examples:
|
3129
|
+
*
|
3130
|
+
* ```
|
3131
|
+
* query.filter({ "columnName": columnValue })
|
3052
3132
|
* query.filter({
|
3053
3133
|
* "columnName": operator(columnValue) // Use gt, gte, lt, lte, startsWith,...
|
3054
3134
|
* })
|
3055
3135
|
* ```
|
3056
3136
|
*
|
3137
|
+
* @param filters A filter object
|
3057
3138
|
* @returns A new Query object.
|
3058
3139
|
*/
|
3059
3140
|
filter(filters: Filter<Record>): Query<Record, Result>;
|
3060
|
-
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
|
3061
3141
|
/**
|
3062
3142
|
* Builds a new query with a new sort option.
|
3063
3143
|
* @param column The column name.
|
@@ -3071,45 +3151,114 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
3071
3151
|
* @returns A new Query object.
|
3072
3152
|
*/
|
3073
3153
|
select<K extends SelectableColumn<Record>>(columns: NonEmptyArray<K>): Query<Record, SelectedPick<Record, NonEmptyArray<K>>>;
|
3154
|
+
/**
|
3155
|
+
* Get paginated results
|
3156
|
+
*
|
3157
|
+
* @returns A page of results
|
3158
|
+
*/
|
3074
3159
|
getPaginated(): Promise<Page<Record, Result>>;
|
3160
|
+
/**
|
3161
|
+
* Get paginated results
|
3162
|
+
*
|
3163
|
+
* @param options Pagination options
|
3164
|
+
* @returns A page of results
|
3165
|
+
*/
|
3075
3166
|
getPaginated(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
|
3167
|
+
/**
|
3168
|
+
* Get paginated results
|
3169
|
+
*
|
3170
|
+
* @param options Pagination options
|
3171
|
+
* @returns A page of results
|
3172
|
+
*/
|
3076
3173
|
getPaginated<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<Page<Record, SelectedPick<Record, typeof options['columns']>>>;
|
3174
|
+
/**
|
3175
|
+
* Get results in an iterator
|
3176
|
+
*
|
3177
|
+
* @async
|
3178
|
+
* @returns Async interable of results
|
3179
|
+
*/
|
3077
3180
|
[Symbol.asyncIterator](): AsyncIterableIterator<Result>;
|
3181
|
+
/**
|
3182
|
+
* Build an iterator of results
|
3183
|
+
*
|
3184
|
+
* @returns Async generator of results array
|
3185
|
+
*/
|
3078
3186
|
getIterator(): AsyncGenerator<Result[]>;
|
3187
|
+
/**
|
3188
|
+
* Build an iterator of results
|
3189
|
+
*
|
3190
|
+
* @param options Pagination options with batchSize
|
3191
|
+
* @returns Async generator of results array
|
3192
|
+
*/
|
3079
3193
|
getIterator(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
|
3080
3194
|
batchSize?: number;
|
3081
3195
|
}): AsyncGenerator<Result[]>;
|
3196
|
+
/**
|
3197
|
+
* Build an iterator of results
|
3198
|
+
*
|
3199
|
+
* @param options Pagination options with batchSize
|
3200
|
+
* @returns Async generator of results array
|
3201
|
+
*/
|
3082
3202
|
getIterator<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
|
3083
3203
|
batchSize?: number;
|
3084
3204
|
}>(options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
|
3085
3205
|
/**
|
3086
3206
|
* Performs the query in the database and returns a set of results.
|
3087
|
-
* @param options Additional options to be used when performing the query.
|
3088
3207
|
* @returns An array of records from the database.
|
3089
3208
|
*/
|
3090
3209
|
getMany(): Promise<Result[]>;
|
3210
|
+
/**
|
3211
|
+
* Performs the query in the database and returns a set of results.
|
3212
|
+
* @param options Additional options to be used when performing the query.
|
3213
|
+
* @returns An array of records from the database.
|
3214
|
+
*/
|
3091
3215
|
getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Result[]>;
|
3216
|
+
/**
|
3217
|
+
* Performs the query in the database and returns a set of results.
|
3218
|
+
* @param options Additional options to be used when performing the query.
|
3219
|
+
* @returns An array of records from the database.
|
3220
|
+
*/
|
3092
3221
|
getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
|
3093
3222
|
/**
|
3094
3223
|
* Performs the query in the database and returns all the results.
|
3095
3224
|
* Warning: If there are a large number of results, this method can have performance implications.
|
3096
|
-
* @param options Additional options to be used when performing the query.
|
3097
3225
|
* @returns An array of records from the database.
|
3098
3226
|
*/
|
3099
3227
|
getAll(): Promise<Result[]>;
|
3228
|
+
/**
|
3229
|
+
* Performs the query in the database and returns all the results.
|
3230
|
+
* Warning: If there are a large number of results, this method can have performance implications.
|
3231
|
+
* @param options Additional options to be used when performing the query.
|
3232
|
+
* @returns An array of records from the database.
|
3233
|
+
*/
|
3100
3234
|
getAll(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
|
3101
3235
|
batchSize?: number;
|
3102
3236
|
}): Promise<Result[]>;
|
3237
|
+
/**
|
3238
|
+
* Performs the query in the database and returns all the results.
|
3239
|
+
* Warning: If there are a large number of results, this method can have performance implications.
|
3240
|
+
* @param options Additional options to be used when performing the query.
|
3241
|
+
* @returns An array of records from the database.
|
3242
|
+
*/
|
3103
3243
|
getAll<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
|
3104
3244
|
batchSize?: number;
|
3105
3245
|
}>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
|
3106
3246
|
/**
|
3107
3247
|
* Performs the query in the database and returns the first result.
|
3108
|
-
* @param options Additional options to be used when performing the query.
|
3109
3248
|
* @returns The first record that matches the query, or null if no record matched the query.
|
3110
3249
|
*/
|
3111
3250
|
getFirst(): Promise<Result | null>;
|
3251
|
+
/**
|
3252
|
+
* Performs the query in the database and returns the first result.
|
3253
|
+
* @param options Additional options to be used when performing the query.
|
3254
|
+
* @returns The first record that matches the query, or null if no record matched the query.
|
3255
|
+
*/
|
3112
3256
|
getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
|
3257
|
+
/**
|
3258
|
+
* Performs the query in the database and returns the first result.
|
3259
|
+
* @param options Additional options to be used when performing the query.
|
3260
|
+
* @returns The first record that matches the query, or null if no record matched the query.
|
3261
|
+
*/
|
3113
3262
|
getFirst<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
|
3114
3263
|
/**
|
3115
3264
|
* Builds a new query object adding a cache TTL in milliseconds.
|
@@ -3117,10 +3266,33 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
3117
3266
|
* @returns A new Query object.
|
3118
3267
|
*/
|
3119
3268
|
cache(ttl: number): Query<Record, Result>;
|
3269
|
+
/**
|
3270
|
+
* Retrieve next page of records
|
3271
|
+
*
|
3272
|
+
* @returns A new page object.
|
3273
|
+
*/
|
3120
3274
|
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3275
|
+
/**
|
3276
|
+
* Retrieve previous page of records
|
3277
|
+
*
|
3278
|
+
* @returns A new page object
|
3279
|
+
*/
|
3121
3280
|
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3281
|
+
/**
|
3282
|
+
* Retrieve first page of records
|
3283
|
+
*
|
3284
|
+
* @returns A new page object
|
3285
|
+
*/
|
3122
3286
|
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3287
|
+
/**
|
3288
|
+
* Retrieve last page of records
|
3289
|
+
*
|
3290
|
+
* @returns A new page object
|
3291
|
+
*/
|
3123
3292
|
lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3293
|
+
/**
|
3294
|
+
* @returns Boolean indicating if there is a next page
|
3295
|
+
*/
|
3124
3296
|
hasNextPage(): boolean;
|
3125
3297
|
}
|
3126
3298
|
|
@@ -3204,6 +3376,7 @@ declare const PAGINATION_MAX_SIZE = 200;
|
|
3204
3376
|
declare const PAGINATION_DEFAULT_SIZE = 200;
|
3205
3377
|
declare const PAGINATION_MAX_OFFSET = 800;
|
3206
3378
|
declare const PAGINATION_DEFAULT_OFFSET = 0;
|
3379
|
+
declare function isCursorPaginationOptions(options: Record<string, unknown> | undefined | null): options is CursorNavigationOptions;
|
3207
3380
|
|
3208
3381
|
/**
|
3209
3382
|
* Common interface for performing operations on a table.
|
@@ -3229,6 +3402,12 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
3229
3402
|
* @returns The persisted record for the given id or null if the record could not be found.
|
3230
3403
|
*/
|
3231
3404
|
abstract read(id: string): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
|
3405
|
+
/**
|
3406
|
+
* Queries multiple records from the table given their unique id.
|
3407
|
+
* @param ids The unique ids array.
|
3408
|
+
* @returns The persisted records for the given ids (if a record could not be found it is not returned).
|
3409
|
+
*/
|
3410
|
+
abstract read(ids: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3232
3411
|
/**
|
3233
3412
|
* Partially update a single record.
|
3234
3413
|
* @param object An object with its id and the columns to be updated.
|
@@ -3301,7 +3480,9 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
3301
3480
|
* @returns The found records.
|
3302
3481
|
*/
|
3303
3482
|
abstract search(query: string, options?: {
|
3304
|
-
fuzziness?:
|
3483
|
+
fuzziness?: FuzzinessExpression;
|
3484
|
+
highlight?: HighlightExpression;
|
3485
|
+
filter?: Filter<Record>;
|
3305
3486
|
}): Promise<SelectedPick<Record, ['*']>[]>;
|
3306
3487
|
abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
3307
3488
|
}
|
@@ -3317,6 +3498,7 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
|
|
3317
3498
|
create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
|
3318
3499
|
create(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
|
3319
3500
|
read(recordId: string): Promise<SelectedPick<Record, ['*']> | null>;
|
3501
|
+
read(recordIds: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3320
3502
|
update(object: Partial<EditableData<Data>> & Identifiable): Promise<SelectedPick<Record, ['*']>>;
|
3321
3503
|
update(recordId: string, object: Partial<EditableData<Data>>): Promise<SelectedPick<Record, ['*']>>;
|
3322
3504
|
update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<SelectedPick<Record, ['*']>[]>;
|
@@ -3325,7 +3507,9 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
|
|
3325
3507
|
createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
|
3326
3508
|
delete(a: string | Identifiable | Array<string | Identifiable>): Promise<void>;
|
3327
3509
|
search(query: string, options?: {
|
3328
|
-
fuzziness?:
|
3510
|
+
fuzziness?: FuzzinessExpression;
|
3511
|
+
highlight?: HighlightExpression;
|
3512
|
+
filter?: Filter<Record>;
|
3329
3513
|
}): Promise<SelectedPick<Record, ['*']>[]>;
|
3330
3514
|
query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
3331
3515
|
}
|
@@ -3419,18 +3603,24 @@ declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends Xat
|
|
3419
3603
|
}
|
3420
3604
|
|
3421
3605
|
declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
|
3422
|
-
fuzziness?:
|
3423
|
-
|
3606
|
+
fuzziness?: FuzzinessExpression;
|
3607
|
+
highlight?: HighlightExpression;
|
3608
|
+
tables?: Array<Tables | Values<{
|
3609
|
+
[Model in GetArrayInnerType<NonNullable<Tables[]>>]: {
|
3610
|
+
table: Model;
|
3611
|
+
filter?: Filter<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
|
3612
|
+
};
|
3613
|
+
}>>;
|
3424
3614
|
};
|
3425
3615
|
declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
|
3426
3616
|
all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
|
3427
|
-
[Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']
|
3617
|
+
[Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]: {
|
3428
3618
|
table: Model;
|
3429
3619
|
record: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
|
3430
3620
|
};
|
3431
3621
|
}>[]>;
|
3432
3622
|
byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
|
3433
|
-
[Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']
|
3623
|
+
[Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
|
3434
3624
|
}>;
|
3435
3625
|
};
|
3436
3626
|
declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
@@ -3439,11 +3629,19 @@ declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends Xat
|
|
3439
3629
|
constructor(db: SchemaPluginResult<Schemas>);
|
3440
3630
|
build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
|
3441
3631
|
}
|
3442
|
-
declare type SearchXataRecord = XataRecord
|
3443
|
-
|
3444
|
-
|
3632
|
+
declare type SearchXataRecord = XataRecord<SearchExtraProperties>;
|
3633
|
+
declare type SearchExtraProperties = {
|
3634
|
+
table: string;
|
3635
|
+
highlight?: {
|
3636
|
+
[key: string]: string[] | {
|
3637
|
+
[key: string]: any;
|
3638
|
+
};
|
3445
3639
|
};
|
3446
3640
|
};
|
3641
|
+
declare type ReturnTable<Table, Tables> = Table extends Tables ? Table : never;
|
3642
|
+
declare type ExtractTables<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>, TableOptions extends GetArrayInnerType<NonNullable<NonNullable<SearchOptions<Schemas, Tables>>['tables']>>> = TableOptions extends `${infer Table}` ? ReturnTable<Table, Tables> : TableOptions extends {
|
3643
|
+
table: infer Table;
|
3644
|
+
} ? ReturnTable<Table, Tables> : never;
|
3447
3645
|
|
3448
3646
|
declare type BranchStrategyValue = string | undefined | null;
|
3449
3647
|
declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
|
@@ -3486,4 +3684,4 @@ declare class XataError extends Error {
|
|
3486
3684
|
constructor(message: string, status: number);
|
3487
3685
|
}
|
3488
3686
|
|
3489
|
-
export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddGitBranchesEntryError, AddGitBranchesEntryPathParams, AddGitBranchesEntryRequestBody, AddGitBranchesEntryResponse, AddGitBranchesEntryVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsResponse, BulkInsertTableRecordsVariables, CacheImpl, CancelWorkspaceMemberInviteError, CancelWorkspaceMemberInvitePathParams, CancelWorkspaceMemberInviteVariables, ClientConstructor, CreateBranchError, CreateBranchPathParams, CreateBranchQueryParams, CreateBranchRequestBody, CreateBranchVariables, CreateDatabaseError, CreateDatabasePathParams, CreateDatabaseRequestBody, CreateDatabaseResponse, CreateDatabaseVariables, CreateTableError, CreateTablePathParams, CreateTableVariables, CreateUserAPIKeyError, CreateUserAPIKeyPathParams, CreateUserAPIKeyResponse, CreateUserAPIKeyVariables, CreateWorkspaceError, CreateWorkspaceVariables, CursorNavigationOptions, DeleteBranchError, DeleteBranchPathParams, DeleteBranchVariables, DeleteColumnError, DeleteColumnPathParams, DeleteColumnVariables, DeleteDatabaseError, DeleteDatabasePathParams, DeleteDatabaseVariables, DeleteRecordError, DeleteRecordPathParams, DeleteRecordVariables, DeleteTableError, DeleteTablePathParams, DeleteTableVariables, DeleteUserAPIKeyError, DeleteUserAPIKeyPathParams, DeleteUserAPIKeyVariables, DeleteUserError, DeleteUserVariables, DeleteWorkspaceError, DeleteWorkspacePathParams, DeleteWorkspaceVariables, EditableData, ExecuteBranchMigrationPlanError, ExecuteBranchMigrationPlanPathParams, ExecuteBranchMigrationPlanRequestBody, ExecuteBranchMigrationPlanVariables, FetchImpl, FetcherExtraProps, GetBranchDetailsError, GetBranchDetailsPathParams, GetBranchDetailsVariables, GetBranchListError, GetBranchListPathParams, GetBranchListVariables, GetBranchMetadataError, GetBranchMetadataPathParams, GetBranchMetadataVariables, GetBranchMigrationHistoryError, GetBranchMigrationHistoryPathParams, GetBranchMigrationHistoryRequestBody, GetBranchMigrationHistoryResponse, GetBranchMigrationHistoryVariables, GetBranchMigrationPlanError, GetBranchMigrationPlanPathParams, GetBranchMigrationPlanVariables, GetBranchStatsError, GetBranchStatsPathParams, GetBranchStatsResponse, GetBranchStatsVariables, GetColumnError, GetColumnPathParams, GetColumnVariables, GetDatabaseListError, GetDatabaseListPathParams, GetDatabaseListVariables, GetGitBranchesMappingError, GetGitBranchesMappingPathParams, GetGitBranchesMappingVariables, GetRecordError, GetRecordPathParams, GetRecordRequestBody, GetRecordVariables, GetTableColumnsError, GetTableColumnsPathParams, GetTableColumnsResponse, GetTableColumnsVariables, GetTableSchemaError, GetTableSchemaPathParams, GetTableSchemaResponse, GetTableSchemaVariables, GetUserAPIKeysError, GetUserAPIKeysResponse, GetUserAPIKeysVariables, GetUserError, GetUserVariables, GetWorkspaceError, GetWorkspaceMembersListError, GetWorkspaceMembersListPathParams, GetWorkspaceMembersListVariables, GetWorkspacePathParams, GetWorkspaceVariables, GetWorkspacesListError, GetWorkspacesListResponse, GetWorkspacesListVariables, Identifiable, InsertRecordError, InsertRecordPathParams, InsertRecordResponse, InsertRecordVariables, InsertRecordWithIDError, InsertRecordWithIDPathParams, InsertRecordWithIDQueryParams, InsertRecordWithIDVariables, InviteWorkspaceMemberError, InviteWorkspaceMemberPathParams, InviteWorkspaceMemberRequestBody, InviteWorkspaceMemberVariables, OffsetNavigationOptions, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Paginable, PaginationQueryMeta, Query, QueryTableError, QueryTablePathParams, QueryTableRequestBody, QueryTableVariables, RemoveGitBranchesEntryError, RemoveGitBranchesEntryPathParams, RemoveGitBranchesEntryQueryParams, RemoveGitBranchesEntryVariables, RemoveWorkspaceMemberError, RemoveWorkspaceMemberPathParams, RemoveWorkspaceMemberVariables, Repository, ResendWorkspaceMemberInviteError, ResendWorkspaceMemberInvitePathParams, ResendWorkspaceMemberInviteVariables, ResolveBranchError, ResolveBranchPathParams, ResolveBranchQueryParams, ResolveBranchResponse, ResolveBranchVariables, responses as Responses, RestRepository, SchemaDefinition, SchemaPlugin, SchemaPluginResult, schemas as Schemas, SearchBranchError, SearchBranchPathParams, SearchBranchRequestBody, SearchBranchVariables, SearchOptions, SearchPlugin, SearchPluginResult, SelectableColumn, SelectedPick, SetTableSchemaError, SetTableSchemaPathParams, SetTableSchemaRequestBody, SetTableSchemaVariables, SimpleCache, SimpleCacheOptions, UpdateBranchMetadataError, UpdateBranchMetadataPathParams, UpdateBranchMetadataVariables, UpdateColumnError, UpdateColumnPathParams, UpdateColumnRequestBody, UpdateColumnVariables, UpdateRecordWithIDError, UpdateRecordWithIDPathParams, UpdateRecordWithIDQueryParams, UpdateRecordWithIDVariables, UpdateTableError, UpdateTablePathParams, UpdateTableRequestBody, UpdateTableVariables, UpdateUserError, UpdateUserVariables, UpdateWorkspaceError, UpdateWorkspaceMemberRoleError, UpdateWorkspaceMemberRolePathParams, UpdateWorkspaceMemberRoleRequestBody, UpdateWorkspaceMemberRoleVariables, UpdateWorkspacePathParams, UpdateWorkspaceVariables, UpsertRecordWithIDError, UpsertRecordWithIDPathParams, UpsertRecordWithIDQueryParams, UpsertRecordWithIDVariables, ValueAtColumn, XataApiClient, XataApiClientOptions, XataApiPlugin, XataError, XataPlugin, XataPluginOptions, XataRecord, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
|
3687
|
+
export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddGitBranchesEntryError, AddGitBranchesEntryPathParams, AddGitBranchesEntryRequestBody, AddGitBranchesEntryResponse, AddGitBranchesEntryVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsResponse, BulkInsertTableRecordsVariables, CacheImpl, CancelWorkspaceMemberInviteError, CancelWorkspaceMemberInvitePathParams, CancelWorkspaceMemberInviteVariables, ClientConstructor, CreateBranchError, CreateBranchPathParams, CreateBranchQueryParams, CreateBranchRequestBody, CreateBranchVariables, CreateDatabaseError, CreateDatabasePathParams, CreateDatabaseRequestBody, CreateDatabaseResponse, CreateDatabaseVariables, CreateTableError, CreateTablePathParams, CreateTableVariables, CreateUserAPIKeyError, CreateUserAPIKeyPathParams, CreateUserAPIKeyResponse, CreateUserAPIKeyVariables, CreateWorkspaceError, CreateWorkspaceVariables, CursorNavigationOptions, DeleteBranchError, DeleteBranchPathParams, DeleteBranchVariables, DeleteColumnError, DeleteColumnPathParams, DeleteColumnVariables, DeleteDatabaseError, DeleteDatabasePathParams, DeleteDatabaseVariables, DeleteRecordError, DeleteRecordPathParams, DeleteRecordVariables, DeleteTableError, DeleteTablePathParams, DeleteTableVariables, DeleteUserAPIKeyError, DeleteUserAPIKeyPathParams, DeleteUserAPIKeyVariables, DeleteUserError, DeleteUserVariables, DeleteWorkspaceError, DeleteWorkspacePathParams, DeleteWorkspaceVariables, EditableData, ExecuteBranchMigrationPlanError, ExecuteBranchMigrationPlanPathParams, ExecuteBranchMigrationPlanRequestBody, ExecuteBranchMigrationPlanVariables, FetchImpl, FetcherExtraProps, GetBranchDetailsError, GetBranchDetailsPathParams, GetBranchDetailsVariables, GetBranchListError, GetBranchListPathParams, GetBranchListVariables, GetBranchMetadataError, GetBranchMetadataPathParams, GetBranchMetadataVariables, GetBranchMigrationHistoryError, GetBranchMigrationHistoryPathParams, GetBranchMigrationHistoryRequestBody, GetBranchMigrationHistoryResponse, GetBranchMigrationHistoryVariables, GetBranchMigrationPlanError, GetBranchMigrationPlanPathParams, GetBranchMigrationPlanVariables, GetBranchStatsError, GetBranchStatsPathParams, GetBranchStatsResponse, GetBranchStatsVariables, GetColumnError, GetColumnPathParams, GetColumnVariables, GetDatabaseListError, GetDatabaseListPathParams, GetDatabaseListVariables, GetGitBranchesMappingError, GetGitBranchesMappingPathParams, GetGitBranchesMappingVariables, GetRecordError, GetRecordPathParams, GetRecordRequestBody, GetRecordVariables, GetTableColumnsError, GetTableColumnsPathParams, GetTableColumnsResponse, GetTableColumnsVariables, GetTableSchemaError, GetTableSchemaPathParams, GetTableSchemaResponse, GetTableSchemaVariables, GetUserAPIKeysError, GetUserAPIKeysResponse, GetUserAPIKeysVariables, GetUserError, GetUserVariables, GetWorkspaceError, GetWorkspaceMembersListError, GetWorkspaceMembersListPathParams, GetWorkspaceMembersListVariables, GetWorkspacePathParams, GetWorkspaceVariables, GetWorkspacesListError, GetWorkspacesListResponse, GetWorkspacesListVariables, Identifiable, InsertRecordError, InsertRecordPathParams, InsertRecordResponse, InsertRecordVariables, InsertRecordWithIDError, InsertRecordWithIDPathParams, InsertRecordWithIDQueryParams, InsertRecordWithIDVariables, InviteWorkspaceMemberError, InviteWorkspaceMemberPathParams, InviteWorkspaceMemberRequestBody, InviteWorkspaceMemberVariables, OffsetNavigationOptions, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Paginable, PaginationQueryMeta, Query, QueryTableError, QueryTablePathParams, QueryTableRequestBody, QueryTableVariables, RemoveGitBranchesEntryError, RemoveGitBranchesEntryPathParams, RemoveGitBranchesEntryQueryParams, RemoveGitBranchesEntryVariables, RemoveWorkspaceMemberError, RemoveWorkspaceMemberPathParams, RemoveWorkspaceMemberVariables, Repository, ResendWorkspaceMemberInviteError, ResendWorkspaceMemberInvitePathParams, ResendWorkspaceMemberInviteVariables, ResolveBranchError, ResolveBranchPathParams, ResolveBranchQueryParams, ResolveBranchResponse, ResolveBranchVariables, responses as Responses, RestRepository, SchemaDefinition, SchemaPlugin, SchemaPluginResult, schemas as Schemas, SearchBranchError, SearchBranchPathParams, SearchBranchRequestBody, SearchBranchVariables, SearchOptions, SearchPlugin, SearchPluginResult, SearchTableError, SearchTablePathParams, SearchTableRequestBody, SearchTableVariables, SelectableColumn, SelectedPick, SetTableSchemaError, SetTableSchemaPathParams, SetTableSchemaRequestBody, SetTableSchemaVariables, SimpleCache, SimpleCacheOptions, UpdateBranchMetadataError, UpdateBranchMetadataPathParams, UpdateBranchMetadataVariables, UpdateColumnError, UpdateColumnPathParams, UpdateColumnRequestBody, UpdateColumnVariables, UpdateRecordWithIDError, UpdateRecordWithIDPathParams, UpdateRecordWithIDQueryParams, UpdateRecordWithIDVariables, UpdateTableError, UpdateTablePathParams, UpdateTableRequestBody, UpdateTableVariables, UpdateUserError, UpdateUserVariables, UpdateWorkspaceError, UpdateWorkspaceMemberRoleError, UpdateWorkspaceMemberRolePathParams, UpdateWorkspaceMemberRoleRequestBody, UpdateWorkspaceMemberRoleVariables, UpdateWorkspacePathParams, UpdateWorkspaceVariables, UpsertRecordWithIDError, UpsertRecordWithIDPathParams, UpsertRecordWithIDQueryParams, UpsertRecordWithIDVariables, ValueAtColumn, XataApiClient, XataApiClientOptions, XataApiPlugin, XataError, XataPlugin, XataPluginOptions, XataRecord, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
|