@xata.io/client 0.0.0-alpha.vfd071d9 → 0.0.0-alpha.vfe4a947
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 +162 -0
- package/README.md +273 -1
- package/Usage.md +449 -0
- package/dist/index.cjs +915 -475
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +994 -242
- package/dist/index.mjs +882 -476
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -4
- package/tsconfig.json +1 -0
package/dist/index.d.ts
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
declare type AttributeDictionary = Record<string, string | number | boolean | undefined>;
|
2
|
+
declare type TraceFunction = <T>(name: string, fn: (options: {
|
3
|
+
setAttributes: (attrs: AttributeDictionary) => void;
|
4
|
+
onError: (message: string) => void;
|
5
|
+
}) => T, options?: AttributeDictionary) => Promise<T>;
|
6
|
+
|
1
7
|
declare type FetchImpl = (url: string, init?: {
|
2
8
|
body?: string;
|
3
9
|
headers?: Record<string, string>;
|
@@ -5,7 +11,11 @@ declare type FetchImpl = (url: string, init?: {
|
|
5
11
|
}) => Promise<{
|
6
12
|
ok: boolean;
|
7
13
|
status: number;
|
14
|
+
url: string;
|
8
15
|
json(): Promise<any>;
|
16
|
+
headers?: {
|
17
|
+
get(name: string): string | null;
|
18
|
+
};
|
9
19
|
}>;
|
10
20
|
declare type WorkspaceApiUrlBuilder = (path: string, pathParams: Record<string, string>) => string;
|
11
21
|
declare type FetcherExtraProps = {
|
@@ -13,6 +23,7 @@ declare type FetcherExtraProps = {
|
|
13
23
|
workspacesApiUrl: string | WorkspaceApiUrlBuilder;
|
14
24
|
fetchImpl: FetchImpl;
|
15
25
|
apiKey: string;
|
26
|
+
trace: TraceFunction;
|
16
27
|
};
|
17
28
|
declare type ErrorWrapper<TError> = TError | {
|
18
29
|
status: 'unknown';
|
@@ -20,7 +31,6 @@ declare type ErrorWrapper<TError> = TError | {
|
|
20
31
|
};
|
21
32
|
|
22
33
|
interface CacheImpl {
|
23
|
-
cacheRecords: boolean;
|
24
34
|
defaultQueryTTL: number;
|
25
35
|
getAll(): Promise<Record<string, unknown>>;
|
26
36
|
get: <T>(key: string) => Promise<T | null>;
|
@@ -30,13 +40,11 @@ interface CacheImpl {
|
|
30
40
|
}
|
31
41
|
interface SimpleCacheOptions {
|
32
42
|
max?: number;
|
33
|
-
cacheRecords?: boolean;
|
34
43
|
defaultQueryTTL?: number;
|
35
44
|
}
|
36
45
|
declare class SimpleCache implements CacheImpl {
|
37
46
|
#private;
|
38
47
|
capacity: number;
|
39
|
-
cacheRecords: boolean;
|
40
48
|
defaultQueryTTL: number;
|
41
49
|
constructor(options?: SimpleCacheOptions);
|
42
50
|
getAll(): Promise<Record<string, unknown>>;
|
@@ -52,6 +60,7 @@ declare abstract class XataPlugin {
|
|
52
60
|
declare type XataPluginOptions = {
|
53
61
|
getFetchProps: () => Promise<FetcherExtraProps>;
|
54
62
|
cache: CacheImpl;
|
63
|
+
trace?: TraceFunction;
|
55
64
|
};
|
56
65
|
|
57
66
|
/**
|
@@ -122,16 +131,20 @@ declare type WorkspaceMembers = {
|
|
122
131
|
* @pattern ^ik_[a-zA-Z0-9]+
|
123
132
|
*/
|
124
133
|
declare type InviteKey = string;
|
134
|
+
/**
|
135
|
+
* Metadata of databases
|
136
|
+
*/
|
137
|
+
declare type DatabaseMetadata = {
|
138
|
+
name: string;
|
139
|
+
displayName: string;
|
140
|
+
createdAt: DateTime;
|
141
|
+
numberOfBranches: number;
|
142
|
+
ui?: {
|
143
|
+
color?: string;
|
144
|
+
};
|
145
|
+
};
|
125
146
|
declare type ListDatabasesResponse = {
|
126
|
-
databases?:
|
127
|
-
name: string;
|
128
|
-
displayName: string;
|
129
|
-
createdAt: DateTime;
|
130
|
-
numberOfBranches: number;
|
131
|
-
ui?: {
|
132
|
-
color?: string;
|
133
|
-
};
|
134
|
-
}[];
|
147
|
+
databases?: DatabaseMetadata[];
|
135
148
|
};
|
136
149
|
declare type ListBranchesResponse = {
|
137
150
|
databaseName: string;
|
@@ -268,6 +281,21 @@ declare type SortExpression = string[] | {
|
|
268
281
|
[key: string]: SortOrder;
|
269
282
|
}[];
|
270
283
|
declare type SortOrder = 'asc' | 'desc';
|
284
|
+
/**
|
285
|
+
* Maximum [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) for the search terms. The Levenshtein
|
286
|
+
* distance is the number of one charcter changes needed to make two strings equal. The default is 1, meaning that single
|
287
|
+
* character typos per word are tollerated by search. You can set it to 0 to remove the typo tollerance or set it to 2
|
288
|
+
* to allow two typos in a word.
|
289
|
+
*
|
290
|
+
* @default 1
|
291
|
+
* @maximum 2
|
292
|
+
* @minimum 0
|
293
|
+
*/
|
294
|
+
declare type FuzzinessExpression = number;
|
295
|
+
/**
|
296
|
+
* 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.
|
297
|
+
*/
|
298
|
+
declare type PrefixExpression = 'phrase' | 'disabled';
|
271
299
|
/**
|
272
300
|
* @minProperties 1
|
273
301
|
*/
|
@@ -281,6 +309,48 @@ declare type FilterExpression = {
|
|
281
309
|
} & {
|
282
310
|
[key: string]: FilterColumn;
|
283
311
|
};
|
312
|
+
declare type HighlightExpression = {
|
313
|
+
enabled?: boolean;
|
314
|
+
encodeHTML?: boolean;
|
315
|
+
};
|
316
|
+
/**
|
317
|
+
* Booster Expression
|
318
|
+
*
|
319
|
+
* @x-go-type xata.BoosterExpression
|
320
|
+
*/
|
321
|
+
declare type BoosterExpression = {
|
322
|
+
valueBooster?: ValueBooster$1;
|
323
|
+
} | {
|
324
|
+
numericBooster?: NumericBooster$1;
|
325
|
+
} | {
|
326
|
+
dateBooster?: DateBooster$1;
|
327
|
+
};
|
328
|
+
/**
|
329
|
+
* Boost records with a particular value for a column.
|
330
|
+
*/
|
331
|
+
declare type ValueBooster$1 = {
|
332
|
+
column: string;
|
333
|
+
value: string | number | boolean;
|
334
|
+
factor: number;
|
335
|
+
};
|
336
|
+
/**
|
337
|
+
* Boost records based on the value of a numeric column.
|
338
|
+
*/
|
339
|
+
declare type NumericBooster$1 = {
|
340
|
+
column: string;
|
341
|
+
factor: number;
|
342
|
+
};
|
343
|
+
/**
|
344
|
+
* Boost records based on the value of a datetime column. It is configured via "origin", "scale", and "decay". The further away from the "origin",
|
345
|
+
* the more the score is decayed. The decay function uses an exponential function. For example if origin is "now", and scale is 10 days and decay is 0.5, it
|
346
|
+
* should be interpreted as: a record with a date 10 days before/after origin will score 2 times less than a record with the date at origin.
|
347
|
+
*/
|
348
|
+
declare type DateBooster$1 = {
|
349
|
+
column: string;
|
350
|
+
origin?: string;
|
351
|
+
scale: string;
|
352
|
+
decay: number;
|
353
|
+
};
|
284
354
|
declare type FilterList = FilterExpression | FilterExpression[];
|
285
355
|
declare type FilterColumn = FilterColumnIncludes | FilterPredicate | FilterList;
|
286
356
|
/**
|
@@ -337,7 +407,24 @@ declare type PageConfig = {
|
|
337
407
|
size?: number;
|
338
408
|
offset?: number;
|
339
409
|
};
|
340
|
-
declare type
|
410
|
+
declare type ColumnsProjection = string[];
|
411
|
+
/**
|
412
|
+
* Xata Table Record Metadata
|
413
|
+
*/
|
414
|
+
declare type RecordMeta = {
|
415
|
+
id: RecordID;
|
416
|
+
xata: {
|
417
|
+
version: number;
|
418
|
+
table?: string;
|
419
|
+
highlight?: {
|
420
|
+
[key: string]: string[] | {
|
421
|
+
[key: string]: any;
|
422
|
+
};
|
423
|
+
};
|
424
|
+
score?: number;
|
425
|
+
warnings?: string[];
|
426
|
+
};
|
427
|
+
};
|
341
428
|
/**
|
342
429
|
* @pattern [a-zA-Z0-9_-~:]+
|
343
430
|
*/
|
@@ -359,16 +446,9 @@ declare type RecordsMetadata = {
|
|
359
446
|
};
|
360
447
|
};
|
361
448
|
/**
|
362
|
-
* Xata Table Record
|
449
|
+
* Xata Table Record Metadata
|
363
450
|
*/
|
364
|
-
declare type XataRecord$1 = {
|
365
|
-
id: RecordID;
|
366
|
-
xata: {
|
367
|
-
version: number;
|
368
|
-
table?: string;
|
369
|
-
warnings?: string[];
|
370
|
-
};
|
371
|
-
} & {
|
451
|
+
declare type XataRecord$1 = RecordMeta & {
|
372
452
|
[key: string]: any;
|
373
453
|
};
|
374
454
|
|
@@ -386,6 +466,7 @@ type schemas_InviteID = InviteID;
|
|
386
466
|
type schemas_WorkspaceInvite = WorkspaceInvite;
|
387
467
|
type schemas_WorkspaceMembers = WorkspaceMembers;
|
388
468
|
type schemas_InviteKey = InviteKey;
|
469
|
+
type schemas_DatabaseMetadata = DatabaseMetadata;
|
389
470
|
type schemas_ListDatabasesResponse = ListDatabasesResponse;
|
390
471
|
type schemas_ListBranchesResponse = ListBranchesResponse;
|
391
472
|
type schemas_ListGitBranchesResponse = ListGitBranchesResponse;
|
@@ -409,7 +490,11 @@ type schemas_TableMigration = TableMigration;
|
|
409
490
|
type schemas_ColumnMigration = ColumnMigration;
|
410
491
|
type schemas_SortExpression = SortExpression;
|
411
492
|
type schemas_SortOrder = SortOrder;
|
493
|
+
type schemas_FuzzinessExpression = FuzzinessExpression;
|
494
|
+
type schemas_PrefixExpression = PrefixExpression;
|
412
495
|
type schemas_FilterExpression = FilterExpression;
|
496
|
+
type schemas_HighlightExpression = HighlightExpression;
|
497
|
+
type schemas_BoosterExpression = BoosterExpression;
|
413
498
|
type schemas_FilterList = FilterList;
|
414
499
|
type schemas_FilterColumn = FilterColumn;
|
415
500
|
type schemas_FilterColumnIncludes = FilterColumnIncludes;
|
@@ -419,7 +504,8 @@ type schemas_FilterPredicateRangeOp = FilterPredicateRangeOp;
|
|
419
504
|
type schemas_FilterRangeValue = FilterRangeValue;
|
420
505
|
type schemas_FilterValue = FilterValue;
|
421
506
|
type schemas_PageConfig = PageConfig;
|
422
|
-
type
|
507
|
+
type schemas_ColumnsProjection = ColumnsProjection;
|
508
|
+
type schemas_RecordMeta = RecordMeta;
|
423
509
|
type schemas_RecordID = RecordID;
|
424
510
|
type schemas_TableRename = TableRename;
|
425
511
|
type schemas_RecordsMetadata = RecordsMetadata;
|
@@ -439,6 +525,7 @@ declare namespace schemas {
|
|
439
525
|
schemas_WorkspaceInvite as WorkspaceInvite,
|
440
526
|
schemas_WorkspaceMembers as WorkspaceMembers,
|
441
527
|
schemas_InviteKey as InviteKey,
|
528
|
+
schemas_DatabaseMetadata as DatabaseMetadata,
|
442
529
|
schemas_ListDatabasesResponse as ListDatabasesResponse,
|
443
530
|
schemas_ListBranchesResponse as ListBranchesResponse,
|
444
531
|
schemas_ListGitBranchesResponse as ListGitBranchesResponse,
|
@@ -462,7 +549,14 @@ declare namespace schemas {
|
|
462
549
|
schemas_ColumnMigration as ColumnMigration,
|
463
550
|
schemas_SortExpression as SortExpression,
|
464
551
|
schemas_SortOrder as SortOrder,
|
552
|
+
schemas_FuzzinessExpression as FuzzinessExpression,
|
553
|
+
schemas_PrefixExpression as PrefixExpression,
|
465
554
|
schemas_FilterExpression as FilterExpression,
|
555
|
+
schemas_HighlightExpression as HighlightExpression,
|
556
|
+
schemas_BoosterExpression as BoosterExpression,
|
557
|
+
ValueBooster$1 as ValueBooster,
|
558
|
+
NumericBooster$1 as NumericBooster,
|
559
|
+
DateBooster$1 as DateBooster,
|
466
560
|
schemas_FilterList as FilterList,
|
467
561
|
schemas_FilterColumn as FilterColumn,
|
468
562
|
schemas_FilterColumnIncludes as FilterColumnIncludes,
|
@@ -472,7 +566,8 @@ declare namespace schemas {
|
|
472
566
|
schemas_FilterRangeValue as FilterRangeValue,
|
473
567
|
schemas_FilterValue as FilterValue,
|
474
568
|
schemas_PageConfig as PageConfig,
|
475
|
-
|
569
|
+
schemas_ColumnsProjection as ColumnsProjection,
|
570
|
+
schemas_RecordMeta as RecordMeta,
|
476
571
|
schemas_RecordID as RecordID,
|
477
572
|
schemas_TableRename as TableRename,
|
478
573
|
schemas_RecordsMetadata as RecordsMetadata,
|
@@ -507,11 +602,17 @@ declare type BulkError = {
|
|
507
602
|
status?: number;
|
508
603
|
}[];
|
509
604
|
};
|
605
|
+
declare type BulkInsertResponse = {
|
606
|
+
recordIDs: string[];
|
607
|
+
} | {
|
608
|
+
records: XataRecord$1[];
|
609
|
+
};
|
510
610
|
declare type BranchMigrationPlan = {
|
511
611
|
version: number;
|
512
612
|
migration: BranchMigration;
|
513
613
|
};
|
514
|
-
declare type
|
614
|
+
declare type RecordResponse = XataRecord$1;
|
615
|
+
declare type RecordUpdateResponse = XataRecord$1 | {
|
515
616
|
id: string;
|
516
617
|
xata: {
|
517
618
|
version: number;
|
@@ -535,7 +636,9 @@ type responses_SimpleError = SimpleError;
|
|
535
636
|
type responses_BadRequestError = BadRequestError;
|
536
637
|
type responses_AuthError = AuthError;
|
537
638
|
type responses_BulkError = BulkError;
|
639
|
+
type responses_BulkInsertResponse = BulkInsertResponse;
|
538
640
|
type responses_BranchMigrationPlan = BranchMigrationPlan;
|
641
|
+
type responses_RecordResponse = RecordResponse;
|
539
642
|
type responses_RecordUpdateResponse = RecordUpdateResponse;
|
540
643
|
type responses_QueryResponse = QueryResponse;
|
541
644
|
type responses_SearchResponse = SearchResponse;
|
@@ -546,7 +649,9 @@ declare namespace responses {
|
|
546
649
|
responses_BadRequestError as BadRequestError,
|
547
650
|
responses_AuthError as AuthError,
|
548
651
|
responses_BulkError as BulkError,
|
652
|
+
responses_BulkInsertResponse as BulkInsertResponse,
|
549
653
|
responses_BranchMigrationPlan as BranchMigrationPlan,
|
654
|
+
responses_RecordResponse as RecordResponse,
|
550
655
|
responses_RecordUpdateResponse as RecordUpdateResponse,
|
551
656
|
responses_QueryResponse as QueryResponse,
|
552
657
|
responses_SearchResponse as SearchResponse,
|
@@ -852,6 +957,9 @@ declare type InviteWorkspaceMemberError = ErrorWrapper<{
|
|
852
957
|
} | {
|
853
958
|
status: 404;
|
854
959
|
payload: SimpleError;
|
960
|
+
} | {
|
961
|
+
status: 409;
|
962
|
+
payload: SimpleError;
|
855
963
|
}>;
|
856
964
|
declare type InviteWorkspaceMemberRequestBody = {
|
857
965
|
email: string;
|
@@ -865,6 +973,34 @@ declare type InviteWorkspaceMemberVariables = {
|
|
865
973
|
* Invite some user to join the workspace with the given role
|
866
974
|
*/
|
867
975
|
declare const inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<WorkspaceInvite>;
|
976
|
+
declare type UpdateWorkspaceMemberInvitePathParams = {
|
977
|
+
workspaceId: WorkspaceID;
|
978
|
+
inviteId: InviteID;
|
979
|
+
};
|
980
|
+
declare type UpdateWorkspaceMemberInviteError = ErrorWrapper<{
|
981
|
+
status: 400;
|
982
|
+
payload: BadRequestError;
|
983
|
+
} | {
|
984
|
+
status: 401;
|
985
|
+
payload: AuthError;
|
986
|
+
} | {
|
987
|
+
status: 404;
|
988
|
+
payload: SimpleError;
|
989
|
+
} | {
|
990
|
+
status: 422;
|
991
|
+
payload: SimpleError;
|
992
|
+
}>;
|
993
|
+
declare type UpdateWorkspaceMemberInviteRequestBody = {
|
994
|
+
role: Role;
|
995
|
+
};
|
996
|
+
declare type UpdateWorkspaceMemberInviteVariables = {
|
997
|
+
body: UpdateWorkspaceMemberInviteRequestBody;
|
998
|
+
pathParams: UpdateWorkspaceMemberInvitePathParams;
|
999
|
+
} & FetcherExtraProps;
|
1000
|
+
/**
|
1001
|
+
* This operation provides a way to update an existing invite. Updates are performed in-place; they do not change the invite link, the expiry time, nor do they re-notify the recipient of the invite.
|
1002
|
+
*/
|
1003
|
+
declare const updateWorkspaceMemberInvite: (variables: UpdateWorkspaceMemberInviteVariables) => Promise<WorkspaceInvite>;
|
868
1004
|
declare type CancelWorkspaceMemberInvitePathParams = {
|
869
1005
|
workspaceId: WorkspaceID;
|
870
1006
|
inviteId: InviteID;
|
@@ -1018,6 +1154,27 @@ declare type DeleteDatabaseVariables = {
|
|
1018
1154
|
* Delete a database and all of its branches and tables permanently.
|
1019
1155
|
*/
|
1020
1156
|
declare const deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
|
1157
|
+
declare type GetDatabaseMetadataPathParams = {
|
1158
|
+
dbName: DBName;
|
1159
|
+
workspace: string;
|
1160
|
+
};
|
1161
|
+
declare type GetDatabaseMetadataError = ErrorWrapper<{
|
1162
|
+
status: 400;
|
1163
|
+
payload: BadRequestError;
|
1164
|
+
} | {
|
1165
|
+
status: 401;
|
1166
|
+
payload: AuthError;
|
1167
|
+
} | {
|
1168
|
+
status: 404;
|
1169
|
+
payload: SimpleError;
|
1170
|
+
}>;
|
1171
|
+
declare type GetDatabaseMetadataVariables = {
|
1172
|
+
pathParams: GetDatabaseMetadataPathParams;
|
1173
|
+
} & FetcherExtraProps;
|
1174
|
+
/**
|
1175
|
+
* Retrieve metadata of the given database
|
1176
|
+
*/
|
1177
|
+
declare const getDatabaseMetadata: (variables: GetDatabaseMetadataVariables) => Promise<DatabaseMetadata>;
|
1021
1178
|
declare type GetGitBranchesMappingPathParams = {
|
1022
1179
|
dbName: DBName;
|
1023
1180
|
workspace: string;
|
@@ -1151,14 +1308,15 @@ declare type ResolveBranchVariables = {
|
|
1151
1308
|
} & FetcherExtraProps;
|
1152
1309
|
/**
|
1153
1310
|
* 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
|
1311
|
+
* * 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
1312
|
* * else, if a Xata branch with the exact same name as `gitBranch` exists, return it
|
1156
|
-
* * else,
|
1313
|
+
* * else, if `fallbackBranch` is provided and a branch with that name exists, return it
|
1314
|
+
* * else, return the default branch of the DB (`main` or the first branch)
|
1157
1315
|
*
|
1158
1316
|
* Example call:
|
1159
1317
|
*
|
1160
1318
|
* ```json
|
1161
|
-
* // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test
|
1319
|
+
* // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test&fallbackBranch=tsg
|
1162
1320
|
* ```
|
1163
1321
|
*
|
1164
1322
|
* Example response:
|
@@ -1209,6 +1367,10 @@ declare type CreateBranchError = ErrorWrapper<{
|
|
1209
1367
|
status: 404;
|
1210
1368
|
payload: SimpleError;
|
1211
1369
|
}>;
|
1370
|
+
declare type CreateBranchResponse = {
|
1371
|
+
databaseName: string;
|
1372
|
+
branchName: string;
|
1373
|
+
};
|
1212
1374
|
declare type CreateBranchRequestBody = {
|
1213
1375
|
from?: string;
|
1214
1376
|
metadata?: BranchMetadata;
|
@@ -1218,7 +1380,7 @@ declare type CreateBranchVariables = {
|
|
1218
1380
|
pathParams: CreateBranchPathParams;
|
1219
1381
|
queryParams?: CreateBranchQueryParams;
|
1220
1382
|
} & FetcherExtraProps;
|
1221
|
-
declare const createBranch: (variables: CreateBranchVariables) => Promise<
|
1383
|
+
declare const createBranch: (variables: CreateBranchVariables) => Promise<CreateBranchResponse>;
|
1222
1384
|
declare type DeleteBranchPathParams = {
|
1223
1385
|
dbBranchName: DBBranchName;
|
1224
1386
|
workspace: string;
|
@@ -1405,13 +1567,17 @@ declare type CreateTableError = ErrorWrapper<{
|
|
1405
1567
|
status: 422;
|
1406
1568
|
payload: SimpleError;
|
1407
1569
|
}>;
|
1570
|
+
declare type CreateTableResponse = {
|
1571
|
+
branchName: string;
|
1572
|
+
tableName: string;
|
1573
|
+
};
|
1408
1574
|
declare type CreateTableVariables = {
|
1409
1575
|
pathParams: CreateTablePathParams;
|
1410
1576
|
} & FetcherExtraProps;
|
1411
1577
|
/**
|
1412
1578
|
* Creates a new table with the given name. Returns 422 if a table with the same name already exists.
|
1413
1579
|
*/
|
1414
|
-
declare const createTable: (variables: CreateTableVariables) => Promise<
|
1580
|
+
declare const createTable: (variables: CreateTableVariables) => Promise<CreateTableResponse>;
|
1415
1581
|
declare type DeleteTablePathParams = {
|
1416
1582
|
dbBranchName: DBBranchName;
|
1417
1583
|
tableName: TableName;
|
@@ -1458,8 +1624,9 @@ declare type UpdateTableVariables = {
|
|
1458
1624
|
*
|
1459
1625
|
* In the example below, we rename a table from “users” to “people”:
|
1460
1626
|
*
|
1461
|
-
* ```
|
1462
|
-
* PATCH /db/test:main/tables/users
|
1627
|
+
* ```json
|
1628
|
+
* // PATCH /db/test:main/tables/users
|
1629
|
+
*
|
1463
1630
|
* {
|
1464
1631
|
* "name": "people"
|
1465
1632
|
* }
|
@@ -1643,6 +1810,9 @@ declare type InsertRecordPathParams = {
|
|
1643
1810
|
tableName: TableName;
|
1644
1811
|
workspace: string;
|
1645
1812
|
};
|
1813
|
+
declare type InsertRecordQueryParams = {
|
1814
|
+
columns?: ColumnsProjection;
|
1815
|
+
};
|
1646
1816
|
declare type InsertRecordError = ErrorWrapper<{
|
1647
1817
|
status: 400;
|
1648
1818
|
payload: BadRequestError;
|
@@ -1653,20 +1823,15 @@ declare type InsertRecordError = ErrorWrapper<{
|
|
1653
1823
|
status: 404;
|
1654
1824
|
payload: SimpleError;
|
1655
1825
|
}>;
|
1656
|
-
declare type InsertRecordResponse = {
|
1657
|
-
id: string;
|
1658
|
-
xata: {
|
1659
|
-
version: number;
|
1660
|
-
};
|
1661
|
-
};
|
1662
1826
|
declare type InsertRecordVariables = {
|
1663
1827
|
body?: Record<string, any>;
|
1664
1828
|
pathParams: InsertRecordPathParams;
|
1829
|
+
queryParams?: InsertRecordQueryParams;
|
1665
1830
|
} & FetcherExtraProps;
|
1666
1831
|
/**
|
1667
1832
|
* Insert a new Record into the Table
|
1668
1833
|
*/
|
1669
|
-
declare const insertRecord: (variables: InsertRecordVariables) => Promise<
|
1834
|
+
declare const insertRecord: (variables: InsertRecordVariables) => Promise<RecordUpdateResponse>;
|
1670
1835
|
declare type InsertRecordWithIDPathParams = {
|
1671
1836
|
dbBranchName: DBBranchName;
|
1672
1837
|
tableName: TableName;
|
@@ -1674,6 +1839,7 @@ declare type InsertRecordWithIDPathParams = {
|
|
1674
1839
|
workspace: string;
|
1675
1840
|
};
|
1676
1841
|
declare type InsertRecordWithIDQueryParams = {
|
1842
|
+
columns?: ColumnsProjection;
|
1677
1843
|
createOnly?: boolean;
|
1678
1844
|
ifVersion?: number;
|
1679
1845
|
};
|
@@ -1706,6 +1872,7 @@ declare type UpdateRecordWithIDPathParams = {
|
|
1706
1872
|
workspace: string;
|
1707
1873
|
};
|
1708
1874
|
declare type UpdateRecordWithIDQueryParams = {
|
1875
|
+
columns?: ColumnsProjection;
|
1709
1876
|
ifVersion?: number;
|
1710
1877
|
};
|
1711
1878
|
declare type UpdateRecordWithIDError = ErrorWrapper<{
|
@@ -1734,6 +1901,7 @@ declare type UpsertRecordWithIDPathParams = {
|
|
1734
1901
|
workspace: string;
|
1735
1902
|
};
|
1736
1903
|
declare type UpsertRecordWithIDQueryParams = {
|
1904
|
+
columns?: ColumnsProjection;
|
1737
1905
|
ifVersion?: number;
|
1738
1906
|
};
|
1739
1907
|
declare type UpsertRecordWithIDError = ErrorWrapper<{
|
@@ -1761,6 +1929,9 @@ declare type DeleteRecordPathParams = {
|
|
1761
1929
|
recordId: RecordID;
|
1762
1930
|
workspace: string;
|
1763
1931
|
};
|
1932
|
+
declare type DeleteRecordQueryParams = {
|
1933
|
+
columns?: ColumnsProjection;
|
1934
|
+
};
|
1764
1935
|
declare type DeleteRecordError = ErrorWrapper<{
|
1765
1936
|
status: 400;
|
1766
1937
|
payload: BadRequestError;
|
@@ -1773,14 +1944,18 @@ declare type DeleteRecordError = ErrorWrapper<{
|
|
1773
1944
|
}>;
|
1774
1945
|
declare type DeleteRecordVariables = {
|
1775
1946
|
pathParams: DeleteRecordPathParams;
|
1947
|
+
queryParams?: DeleteRecordQueryParams;
|
1776
1948
|
} & FetcherExtraProps;
|
1777
|
-
declare const deleteRecord: (variables: DeleteRecordVariables) => Promise<
|
1949
|
+
declare const deleteRecord: (variables: DeleteRecordVariables) => Promise<XataRecord$1>;
|
1778
1950
|
declare type GetRecordPathParams = {
|
1779
1951
|
dbBranchName: DBBranchName;
|
1780
1952
|
tableName: TableName;
|
1781
1953
|
recordId: RecordID;
|
1782
1954
|
workspace: string;
|
1783
1955
|
};
|
1956
|
+
declare type GetRecordQueryParams = {
|
1957
|
+
columns?: ColumnsProjection;
|
1958
|
+
};
|
1784
1959
|
declare type GetRecordError = ErrorWrapper<{
|
1785
1960
|
status: 400;
|
1786
1961
|
payload: BadRequestError;
|
@@ -1791,12 +1966,9 @@ declare type GetRecordError = ErrorWrapper<{
|
|
1791
1966
|
status: 404;
|
1792
1967
|
payload: SimpleError;
|
1793
1968
|
}>;
|
1794
|
-
declare type GetRecordRequestBody = {
|
1795
|
-
columns?: ColumnsFilter;
|
1796
|
-
};
|
1797
1969
|
declare type GetRecordVariables = {
|
1798
|
-
body?: GetRecordRequestBody;
|
1799
1970
|
pathParams: GetRecordPathParams;
|
1971
|
+
queryParams?: GetRecordQueryParams;
|
1800
1972
|
} & FetcherExtraProps;
|
1801
1973
|
/**
|
1802
1974
|
* Retrieve record by ID
|
@@ -1807,6 +1979,9 @@ declare type BulkInsertTableRecordsPathParams = {
|
|
1807
1979
|
tableName: TableName;
|
1808
1980
|
workspace: string;
|
1809
1981
|
};
|
1982
|
+
declare type BulkInsertTableRecordsQueryParams = {
|
1983
|
+
columns?: ColumnsProjection;
|
1984
|
+
};
|
1810
1985
|
declare type BulkInsertTableRecordsError = ErrorWrapper<{
|
1811
1986
|
status: 400;
|
1812
1987
|
payload: BulkError;
|
@@ -1816,21 +1991,22 @@ declare type BulkInsertTableRecordsError = ErrorWrapper<{
|
|
1816
1991
|
} | {
|
1817
1992
|
status: 404;
|
1818
1993
|
payload: SimpleError;
|
1994
|
+
} | {
|
1995
|
+
status: 422;
|
1996
|
+
payload: SimpleError;
|
1819
1997
|
}>;
|
1820
|
-
declare type BulkInsertTableRecordsResponse = {
|
1821
|
-
recordIDs: string[];
|
1822
|
-
};
|
1823
1998
|
declare type BulkInsertTableRecordsRequestBody = {
|
1824
1999
|
records: Record<string, any>[];
|
1825
2000
|
};
|
1826
2001
|
declare type BulkInsertTableRecordsVariables = {
|
1827
2002
|
body: BulkInsertTableRecordsRequestBody;
|
1828
2003
|
pathParams: BulkInsertTableRecordsPathParams;
|
2004
|
+
queryParams?: BulkInsertTableRecordsQueryParams;
|
1829
2005
|
} & FetcherExtraProps;
|
1830
2006
|
/**
|
1831
2007
|
* Bulk insert records
|
1832
2008
|
*/
|
1833
|
-
declare const bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<
|
2009
|
+
declare const bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertResponse>;
|
1834
2010
|
declare type QueryTablePathParams = {
|
1835
2011
|
dbBranchName: DBBranchName;
|
1836
2012
|
tableName: TableName;
|
@@ -1850,7 +2026,7 @@ declare type QueryTableRequestBody = {
|
|
1850
2026
|
filter?: FilterExpression;
|
1851
2027
|
sort?: SortExpression;
|
1852
2028
|
page?: PageConfig;
|
1853
|
-
columns?:
|
2029
|
+
columns?: ColumnsProjection;
|
1854
2030
|
};
|
1855
2031
|
declare type QueryTableVariables = {
|
1856
2032
|
body?: QueryTableRequestBody;
|
@@ -1867,7 +2043,7 @@ declare type QueryTableVariables = {
|
|
1867
2043
|
* {
|
1868
2044
|
* "columns": [...],
|
1869
2045
|
* "filter": {
|
1870
|
-
* "$all": [...]
|
2046
|
+
* "$all": [...],
|
1871
2047
|
* "$any": [...]
|
1872
2048
|
* ...
|
1873
2049
|
* },
|
@@ -2005,7 +2181,7 @@ declare type QueryTableVariables = {
|
|
2005
2181
|
* {
|
2006
2182
|
* "name": "Kilian",
|
2007
2183
|
* "address": {
|
2008
|
-
* "street": "New street"
|
2184
|
+
* "street": "New street"
|
2009
2185
|
* }
|
2010
2186
|
* }
|
2011
2187
|
* ```
|
@@ -2014,10 +2190,7 @@ declare type QueryTableVariables = {
|
|
2014
2190
|
*
|
2015
2191
|
* ```json
|
2016
2192
|
* {
|
2017
|
-
* "columns": [
|
2018
|
-
* "*",
|
2019
|
-
* "team.name"
|
2020
|
-
* ]
|
2193
|
+
* "columns": ["*", "team.name"]
|
2021
2194
|
* }
|
2022
2195
|
* ```
|
2023
2196
|
*
|
@@ -2035,7 +2208,7 @@ declare type QueryTableVariables = {
|
|
2035
2208
|
* "team": {
|
2036
2209
|
* "id": "XX",
|
2037
2210
|
* "xata": {
|
2038
|
-
* "version": 0
|
2211
|
+
* "version": 0
|
2039
2212
|
* },
|
2040
2213
|
* "name": "first team"
|
2041
2214
|
* }
|
@@ -2046,10 +2219,7 @@ declare type QueryTableVariables = {
|
|
2046
2219
|
*
|
2047
2220
|
* ```json
|
2048
2221
|
* {
|
2049
|
-
* "columns": [
|
2050
|
-
* "*",
|
2051
|
-
* "team.*"
|
2052
|
-
* ]
|
2222
|
+
* "columns": ["*", "team.*"]
|
2053
2223
|
* }
|
2054
2224
|
* ```
|
2055
2225
|
*
|
@@ -2067,7 +2237,7 @@ declare type QueryTableVariables = {
|
|
2067
2237
|
* "team": {
|
2068
2238
|
* "id": "XX",
|
2069
2239
|
* "xata": {
|
2070
|
-
* "version": 0
|
2240
|
+
* "version": 0
|
2071
2241
|
* },
|
2072
2242
|
* "name": "first team",
|
2073
2243
|
* "code": "A1",
|
@@ -2117,7 +2287,7 @@ declare type QueryTableVariables = {
|
|
2117
2287
|
* ```json
|
2118
2288
|
* {
|
2119
2289
|
* "filter": {
|
2120
|
-
*
|
2290
|
+
* "name": "r2"
|
2121
2291
|
* }
|
2122
2292
|
* }
|
2123
2293
|
* ```
|
@@ -2139,7 +2309,7 @@ declare type QueryTableVariables = {
|
|
2139
2309
|
* ```json
|
2140
2310
|
* {
|
2141
2311
|
* "filter": {
|
2142
|
-
*
|
2312
|
+
* "settings.plan": "free"
|
2143
2313
|
* }
|
2144
2314
|
* }
|
2145
2315
|
* ```
|
@@ -2149,8 +2319,8 @@ declare type QueryTableVariables = {
|
|
2149
2319
|
* "filter": {
|
2150
2320
|
* "settings": {
|
2151
2321
|
* "plan": "free"
|
2152
|
-
* }
|
2153
|
-
* }
|
2322
|
+
* }
|
2323
|
+
* }
|
2154
2324
|
* }
|
2155
2325
|
* ```
|
2156
2326
|
*
|
@@ -2159,8 +2329,8 @@ declare type QueryTableVariables = {
|
|
2159
2329
|
* ```json
|
2160
2330
|
* {
|
2161
2331
|
* "filter": {
|
2162
|
-
* "settings.plan": {"$any": ["free", "paid"]}
|
2163
|
-
* }
|
2332
|
+
* "settings.plan": { "$any": ["free", "paid"] }
|
2333
|
+
* }
|
2164
2334
|
* }
|
2165
2335
|
* ```
|
2166
2336
|
*
|
@@ -2169,9 +2339,9 @@ declare type QueryTableVariables = {
|
|
2169
2339
|
* ```json
|
2170
2340
|
* {
|
2171
2341
|
* "filter": {
|
2172
|
-
*
|
2173
|
-
*
|
2174
|
-
* }
|
2342
|
+
* "settings.dark": true,
|
2343
|
+
* "settings.plan": "free"
|
2344
|
+
* }
|
2175
2345
|
* }
|
2176
2346
|
* ```
|
2177
2347
|
*
|
@@ -2182,11 +2352,11 @@ declare type QueryTableVariables = {
|
|
2182
2352
|
* ```json
|
2183
2353
|
* {
|
2184
2354
|
* "filter": {
|
2185
|
-
*
|
2186
|
-
*
|
2187
|
-
*
|
2188
|
-
*
|
2189
|
-
* }
|
2355
|
+
* "$any": {
|
2356
|
+
* "settings.dark": true,
|
2357
|
+
* "settings.plan": "free"
|
2358
|
+
* }
|
2359
|
+
* }
|
2190
2360
|
* }
|
2191
2361
|
* ```
|
2192
2362
|
*
|
@@ -2197,10 +2367,10 @@ declare type QueryTableVariables = {
|
|
2197
2367
|
* "filter": {
|
2198
2368
|
* "$any": [
|
2199
2369
|
* {
|
2200
|
-
* "name": "r1"
|
2370
|
+
* "name": "r1"
|
2201
2371
|
* },
|
2202
2372
|
* {
|
2203
|
-
* "name": "r2"
|
2373
|
+
* "name": "r2"
|
2204
2374
|
* }
|
2205
2375
|
* ]
|
2206
2376
|
* }
|
@@ -2212,7 +2382,7 @@ declare type QueryTableVariables = {
|
|
2212
2382
|
* ```json
|
2213
2383
|
* {
|
2214
2384
|
* "filter": {
|
2215
|
-
* "$exists": "settings"
|
2385
|
+
* "$exists": "settings"
|
2216
2386
|
* }
|
2217
2387
|
* }
|
2218
2388
|
* ```
|
@@ -2224,10 +2394,10 @@ declare type QueryTableVariables = {
|
|
2224
2394
|
* "filter": {
|
2225
2395
|
* "$all": [
|
2226
2396
|
* {
|
2227
|
-
* "$exists": "settings"
|
2397
|
+
* "$exists": "settings"
|
2228
2398
|
* },
|
2229
2399
|
* {
|
2230
|
-
* "$exists": "name"
|
2400
|
+
* "$exists": "name"
|
2231
2401
|
* }
|
2232
2402
|
* ]
|
2233
2403
|
* }
|
@@ -2239,7 +2409,7 @@ declare type QueryTableVariables = {
|
|
2239
2409
|
* ```json
|
2240
2410
|
* {
|
2241
2411
|
* "filter": {
|
2242
|
-
* "$notExists": "settings"
|
2412
|
+
* "$notExists": "settings"
|
2243
2413
|
* }
|
2244
2414
|
* }
|
2245
2415
|
* ```
|
@@ -2266,22 +2436,28 @@ declare type QueryTableVariables = {
|
|
2266
2436
|
* {
|
2267
2437
|
* "filter": {
|
2268
2438
|
* "<column_name>": {
|
2269
|
-
*
|
2439
|
+
* "$pattern": "v*alu?"
|
2270
2440
|
* }
|
2271
2441
|
* }
|
2272
2442
|
* }
|
2273
2443
|
* ```
|
2274
2444
|
*
|
2445
|
+
* The `$pattern` operator accepts two wildcard characters:
|
2446
|
+
* * `*` matches zero or more characters
|
2447
|
+
* * `?` matches exactly one character
|
2448
|
+
*
|
2449
|
+
* 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.
|
2450
|
+
*
|
2275
2451
|
* We could also have `$endsWith` and `$startsWith` operators:
|
2276
2452
|
*
|
2277
2453
|
* ```json
|
2278
2454
|
* {
|
2279
2455
|
* "filter": {
|
2280
2456
|
* "<column_name>": {
|
2281
|
-
*
|
2457
|
+
* "$endsWith": ".gz"
|
2282
2458
|
* },
|
2283
2459
|
* "<column_name>": {
|
2284
|
-
*
|
2460
|
+
* "$startsWith": "tmp-"
|
2285
2461
|
* }
|
2286
2462
|
* }
|
2287
2463
|
* }
|
@@ -2292,10 +2468,10 @@ declare type QueryTableVariables = {
|
|
2292
2468
|
* ```json
|
2293
2469
|
* {
|
2294
2470
|
* "filter": {
|
2295
|
-
*
|
2296
|
-
*
|
2297
|
-
*
|
2298
|
-
*
|
2471
|
+
* "<column_name>": {
|
2472
|
+
* "$ge": 0,
|
2473
|
+
* "$lt": 100
|
2474
|
+
* }
|
2299
2475
|
* }
|
2300
2476
|
* }
|
2301
2477
|
* ```
|
@@ -2313,7 +2489,6 @@ declare type QueryTableVariables = {
|
|
2313
2489
|
* ```
|
2314
2490
|
* The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
|
2315
2491
|
*
|
2316
|
-
*
|
2317
2492
|
* #### Negations
|
2318
2493
|
*
|
2319
2494
|
* A general `$not` operator can inverse any operation.
|
@@ -2338,15 +2513,21 @@ declare type QueryTableVariables = {
|
|
2338
2513
|
* {
|
2339
2514
|
* "filter": {
|
2340
2515
|
* "$not": {
|
2341
|
-
* "$any": [
|
2342
|
-
*
|
2343
|
-
*
|
2344
|
-
*
|
2345
|
-
*
|
2346
|
-
*
|
2347
|
-
*
|
2348
|
-
*
|
2349
|
-
*
|
2516
|
+
* "$any": [
|
2517
|
+
* {
|
2518
|
+
* "<column_name1>": "value1"
|
2519
|
+
* },
|
2520
|
+
* {
|
2521
|
+
* "$all": [
|
2522
|
+
* {
|
2523
|
+
* "<column_name2>": "value2"
|
2524
|
+
* },
|
2525
|
+
* {
|
2526
|
+
* "<column_name3>": "value3"
|
2527
|
+
* }
|
2528
|
+
* ]
|
2529
|
+
* }
|
2530
|
+
* ]
|
2350
2531
|
* }
|
2351
2532
|
* }
|
2352
2533
|
* }
|
@@ -2401,8 +2582,8 @@ declare type QueryTableVariables = {
|
|
2401
2582
|
* "<array name>": {
|
2402
2583
|
* "$includes": {
|
2403
2584
|
* "$all": [
|
2404
|
-
* {"$contains": "label"},
|
2405
|
-
* {"$not": {"$endsWith": "-debug"}}
|
2585
|
+
* { "$contains": "label" },
|
2586
|
+
* { "$not": { "$endsWith": "-debug" } }
|
2406
2587
|
* ]
|
2407
2588
|
* }
|
2408
2589
|
* }
|
@@ -2422,9 +2603,7 @@ declare type QueryTableVariables = {
|
|
2422
2603
|
* {
|
2423
2604
|
* "filter": {
|
2424
2605
|
* "settings.labels": {
|
2425
|
-
* "$includesAll": [
|
2426
|
-
* {"$contains": "label"},
|
2427
|
-
* ]
|
2606
|
+
* "$includesAll": [{ "$contains": "label" }]
|
2428
2607
|
* }
|
2429
2608
|
* }
|
2430
2609
|
* }
|
@@ -2472,7 +2651,6 @@ declare type QueryTableVariables = {
|
|
2472
2651
|
* }
|
2473
2652
|
* ```
|
2474
2653
|
*
|
2475
|
-
*
|
2476
2654
|
* ### Pagination
|
2477
2655
|
*
|
2478
2656
|
* We offer cursor pagination and offset pagination. The offset pagination is limited
|
@@ -2538,8 +2716,8 @@ declare type QueryTableVariables = {
|
|
2538
2716
|
* can be queried by update `page.after` to the returned cursor while keeping the
|
2539
2717
|
* `page.before` cursor from the first range query.
|
2540
2718
|
*
|
2541
|
-
* The `filter` , `columns`,
|
2542
|
-
* encoded with the cursor.
|
2719
|
+
* The `filter` , `columns`, `sort` , and `page.size` configuration will be
|
2720
|
+
* encoded with the cursor. The pagination request will be invalid if
|
2543
2721
|
* `filter` or `sort` is set. The columns returned and page size can be changed
|
2544
2722
|
* anytime by passing the `columns` or `page.size` settings to the next query.
|
2545
2723
|
*
|
@@ -2576,6 +2754,41 @@ declare type QueryTableVariables = {
|
|
2576
2754
|
* ```
|
2577
2755
|
*/
|
2578
2756
|
declare const queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
2757
|
+
declare type SearchTablePathParams = {
|
2758
|
+
dbBranchName: DBBranchName;
|
2759
|
+
tableName: TableName;
|
2760
|
+
workspace: string;
|
2761
|
+
};
|
2762
|
+
declare type SearchTableError = ErrorWrapper<{
|
2763
|
+
status: 400;
|
2764
|
+
payload: BadRequestError;
|
2765
|
+
} | {
|
2766
|
+
status: 401;
|
2767
|
+
payload: AuthError;
|
2768
|
+
} | {
|
2769
|
+
status: 404;
|
2770
|
+
payload: SimpleError;
|
2771
|
+
}>;
|
2772
|
+
declare type SearchTableRequestBody = {
|
2773
|
+
query: string;
|
2774
|
+
fuzziness?: FuzzinessExpression;
|
2775
|
+
prefix?: PrefixExpression;
|
2776
|
+
filter?: FilterExpression;
|
2777
|
+
highlight?: HighlightExpression;
|
2778
|
+
boosters?: BoosterExpression[];
|
2779
|
+
};
|
2780
|
+
declare type SearchTableVariables = {
|
2781
|
+
body: SearchTableRequestBody;
|
2782
|
+
pathParams: SearchTablePathParams;
|
2783
|
+
} & FetcherExtraProps;
|
2784
|
+
/**
|
2785
|
+
* Run a free text search operation in a particular table.
|
2786
|
+
*
|
2787
|
+
* 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:
|
2788
|
+
* * filters `$contains`, `$startsWith`, `$endsWith` don't work on columns of type `text`
|
2789
|
+
* * filtering on columns of type `multiple` is currently unsupported
|
2790
|
+
*/
|
2791
|
+
declare const searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
|
2579
2792
|
declare type SearchBranchPathParams = {
|
2580
2793
|
dbBranchName: DBBranchName;
|
2581
2794
|
workspace: string;
|
@@ -2591,9 +2804,14 @@ declare type SearchBranchError = ErrorWrapper<{
|
|
2591
2804
|
payload: SimpleError;
|
2592
2805
|
}>;
|
2593
2806
|
declare type SearchBranchRequestBody = {
|
2594
|
-
tables?: string
|
2807
|
+
tables?: (string | {
|
2808
|
+
table: string;
|
2809
|
+
filter?: FilterExpression;
|
2810
|
+
boosters?: BoosterExpression[];
|
2811
|
+
})[];
|
2595
2812
|
query: string;
|
2596
|
-
fuzziness?:
|
2813
|
+
fuzziness?: FuzzinessExpression;
|
2814
|
+
highlight?: HighlightExpression;
|
2597
2815
|
};
|
2598
2816
|
declare type SearchBranchVariables = {
|
2599
2817
|
body: SearchBranchRequestBody;
|
@@ -2622,6 +2840,7 @@ declare const operationsByTag: {
|
|
2622
2840
|
updateWorkspaceMemberRole: (variables: UpdateWorkspaceMemberRoleVariables) => Promise<undefined>;
|
2623
2841
|
removeWorkspaceMember: (variables: RemoveWorkspaceMemberVariables) => Promise<undefined>;
|
2624
2842
|
inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<WorkspaceInvite>;
|
2843
|
+
updateWorkspaceMemberInvite: (variables: UpdateWorkspaceMemberInviteVariables) => Promise<WorkspaceInvite>;
|
2625
2844
|
cancelWorkspaceMemberInvite: (variables: CancelWorkspaceMemberInviteVariables) => Promise<undefined>;
|
2626
2845
|
resendWorkspaceMemberInvite: (variables: ResendWorkspaceMemberInviteVariables) => Promise<undefined>;
|
2627
2846
|
acceptWorkspaceMemberInvite: (variables: AcceptWorkspaceMemberInviteVariables) => Promise<undefined>;
|
@@ -2630,6 +2849,7 @@ declare const operationsByTag: {
|
|
2630
2849
|
getDatabaseList: (variables: GetDatabaseListVariables) => Promise<ListDatabasesResponse>;
|
2631
2850
|
createDatabase: (variables: CreateDatabaseVariables) => Promise<CreateDatabaseResponse>;
|
2632
2851
|
deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
|
2852
|
+
getDatabaseMetadata: (variables: GetDatabaseMetadataVariables) => Promise<DatabaseMetadata>;
|
2633
2853
|
getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
|
2634
2854
|
addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
|
2635
2855
|
removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
|
@@ -2638,7 +2858,7 @@ declare const operationsByTag: {
|
|
2638
2858
|
branch: {
|
2639
2859
|
getBranchList: (variables: GetBranchListVariables) => Promise<ListBranchesResponse>;
|
2640
2860
|
getBranchDetails: (variables: GetBranchDetailsVariables) => Promise<DBBranch>;
|
2641
|
-
createBranch: (variables: CreateBranchVariables) => Promise<
|
2861
|
+
createBranch: (variables: CreateBranchVariables) => Promise<CreateBranchResponse>;
|
2642
2862
|
deleteBranch: (variables: DeleteBranchVariables) => Promise<undefined>;
|
2643
2863
|
updateBranchMetadata: (variables: UpdateBranchMetadataVariables) => Promise<undefined>;
|
2644
2864
|
getBranchMetadata: (variables: GetBranchMetadataVariables) => Promise<BranchMetadata>;
|
@@ -2648,7 +2868,7 @@ declare const operationsByTag: {
|
|
2648
2868
|
getBranchStats: (variables: GetBranchStatsVariables) => Promise<GetBranchStatsResponse>;
|
2649
2869
|
};
|
2650
2870
|
table: {
|
2651
|
-
createTable: (variables: CreateTableVariables) => Promise<
|
2871
|
+
createTable: (variables: CreateTableVariables) => Promise<CreateTableResponse>;
|
2652
2872
|
deleteTable: (variables: DeleteTableVariables) => Promise<undefined>;
|
2653
2873
|
updateTable: (variables: UpdateTableVariables) => Promise<undefined>;
|
2654
2874
|
getTableSchema: (variables: GetTableSchemaVariables) => Promise<GetTableSchemaResponse>;
|
@@ -2660,14 +2880,15 @@ declare const operationsByTag: {
|
|
2660
2880
|
updateColumn: (variables: UpdateColumnVariables) => Promise<MigrationIdResponse>;
|
2661
2881
|
};
|
2662
2882
|
records: {
|
2663
|
-
insertRecord: (variables: InsertRecordVariables) => Promise<
|
2883
|
+
insertRecord: (variables: InsertRecordVariables) => Promise<RecordUpdateResponse>;
|
2664
2884
|
insertRecordWithID: (variables: InsertRecordWithIDVariables) => Promise<RecordUpdateResponse>;
|
2665
2885
|
updateRecordWithID: (variables: UpdateRecordWithIDVariables) => Promise<RecordUpdateResponse>;
|
2666
2886
|
upsertRecordWithID: (variables: UpsertRecordWithIDVariables) => Promise<RecordUpdateResponse>;
|
2667
|
-
deleteRecord: (variables: DeleteRecordVariables) => Promise<
|
2887
|
+
deleteRecord: (variables: DeleteRecordVariables) => Promise<XataRecord$1>;
|
2668
2888
|
getRecord: (variables: GetRecordVariables) => Promise<XataRecord$1>;
|
2669
|
-
bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<
|
2889
|
+
bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertResponse>;
|
2670
2890
|
queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
2891
|
+
searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
|
2671
2892
|
searchBranch: (variables: SearchBranchVariables) => Promise<SearchResponse>;
|
2672
2893
|
};
|
2673
2894
|
};
|
@@ -2683,10 +2904,8 @@ interface XataApiClientOptions {
|
|
2683
2904
|
fetch?: FetchImpl;
|
2684
2905
|
apiKey?: string;
|
2685
2906
|
host?: HostProvider;
|
2907
|
+
trace?: TraceFunction;
|
2686
2908
|
}
|
2687
|
-
/**
|
2688
|
-
* @deprecated Use XataApiPlugin instead
|
2689
|
-
*/
|
2690
2909
|
declare class XataApiClient {
|
2691
2910
|
#private;
|
2692
2911
|
constructor(options?: XataApiClientOptions);
|
@@ -2719,6 +2938,7 @@ declare class WorkspaceApi {
|
|
2719
2938
|
updateWorkspaceMemberRole(workspaceId: WorkspaceID, userId: UserID, role: Role): Promise<void>;
|
2720
2939
|
removeWorkspaceMember(workspaceId: WorkspaceID, userId: UserID): Promise<void>;
|
2721
2940
|
inviteWorkspaceMember(workspaceId: WorkspaceID, email: string, role: Role): Promise<WorkspaceInvite>;
|
2941
|
+
updateWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID, role: Role): Promise<WorkspaceInvite>;
|
2722
2942
|
cancelWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID): Promise<void>;
|
2723
2943
|
resendWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID): Promise<void>;
|
2724
2944
|
acceptWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteKey: InviteKey): Promise<void>;
|
@@ -2729,17 +2949,18 @@ declare class DatabaseApi {
|
|
2729
2949
|
getDatabaseList(workspace: WorkspaceID): Promise<ListDatabasesResponse>;
|
2730
2950
|
createDatabase(workspace: WorkspaceID, dbName: DBName, options?: CreateDatabaseRequestBody): Promise<CreateDatabaseResponse>;
|
2731
2951
|
deleteDatabase(workspace: WorkspaceID, dbName: DBName): Promise<void>;
|
2952
|
+
getDatabaseMetadata(workspace: WorkspaceID, dbName: DBName): Promise<DatabaseMetadata>;
|
2732
2953
|
getGitBranchesMapping(workspace: WorkspaceID, dbName: DBName): Promise<ListGitBranchesResponse>;
|
2733
2954
|
addGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, body: AddGitBranchesEntryRequestBody): Promise<AddGitBranchesEntryResponse>;
|
2734
2955
|
removeGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<void>;
|
2735
|
-
resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch
|
2956
|
+
resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch?: string, fallbackBranch?: string): Promise<ResolveBranchResponse>;
|
2736
2957
|
}
|
2737
2958
|
declare class BranchApi {
|
2738
2959
|
private extraProps;
|
2739
2960
|
constructor(extraProps: FetcherExtraProps);
|
2740
2961
|
getBranchList(workspace: WorkspaceID, dbName: DBName): Promise<ListBranchesResponse>;
|
2741
2962
|
getBranchDetails(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<DBBranch>;
|
2742
|
-
createBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, from?: string, options?: CreateBranchRequestBody): Promise<
|
2963
|
+
createBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, from?: string, options?: CreateBranchRequestBody): Promise<CreateBranchResponse>;
|
2743
2964
|
deleteBranch(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<void>;
|
2744
2965
|
updateBranchMetadata(workspace: WorkspaceID, database: DBName, branch: BranchName, metadata?: BranchMetadata): Promise<void>;
|
2745
2966
|
getBranchMetadata(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<BranchMetadata>;
|
@@ -2751,7 +2972,7 @@ declare class BranchApi {
|
|
2751
2972
|
declare class TableApi {
|
2752
2973
|
private extraProps;
|
2753
2974
|
constructor(extraProps: FetcherExtraProps);
|
2754
|
-
createTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<
|
2975
|
+
createTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<CreateTableResponse>;
|
2755
2976
|
deleteTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<void>;
|
2756
2977
|
updateTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, options: UpdateTableRequestBody): Promise<void>;
|
2757
2978
|
getTableSchema(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<GetTableSchemaResponse>;
|
@@ -2765,14 +2986,15 @@ declare class TableApi {
|
|
2765
2986
|
declare class RecordsApi {
|
2766
2987
|
private extraProps;
|
2767
2988
|
constructor(extraProps: FetcherExtraProps);
|
2768
|
-
insertRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, record: Record<string, any
|
2989
|
+
insertRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, record: Record<string, any>, options?: InsertRecordQueryParams): Promise<RecordUpdateResponse>;
|
2769
2990
|
insertRecordWithID(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, record: Record<string, any>, options?: InsertRecordWithIDQueryParams): Promise<RecordUpdateResponse>;
|
2770
2991
|
updateRecordWithID(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, record: Record<string, any>, options?: UpdateRecordWithIDQueryParams): Promise<RecordUpdateResponse>;
|
2771
2992
|
upsertRecordWithID(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, record: Record<string, any>, options?: UpsertRecordWithIDQueryParams): Promise<RecordUpdateResponse>;
|
2772
|
-
deleteRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID): Promise<
|
2773
|
-
getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?:
|
2774
|
-
bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[]): Promise<
|
2993
|
+
deleteRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: DeleteRecordQueryParams): Promise<RecordUpdateResponse>;
|
2994
|
+
getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: GetRecordQueryParams): Promise<XataRecord$1>;
|
2995
|
+
bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[], options?: BulkInsertTableRecordsQueryParams): Promise<BulkInsertResponse>;
|
2775
2996
|
queryTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: QueryTableRequestBody): Promise<QueryResponse>;
|
2997
|
+
searchTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: SearchTableRequestBody): Promise<SearchResponse>;
|
2776
2998
|
searchBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, query: SearchBranchRequestBody): Promise<SearchResponse>;
|
2777
2999
|
}
|
2778
3000
|
|
@@ -2786,28 +3008,29 @@ declare type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) ex
|
|
2786
3008
|
declare type If<Condition, Then, Else> = Condition extends true ? Then : Else;
|
2787
3009
|
declare type IsObject<T> = T extends Record<string, any> ? true : false;
|
2788
3010
|
declare type IsArray<T> = T extends Array<any> ? true : false;
|
2789
|
-
declare type NonEmptyArray<T> = T[] & {
|
2790
|
-
0: T;
|
2791
|
-
};
|
2792
3011
|
declare type RequiredBy<T, K extends keyof T> = T & {
|
2793
3012
|
[P in K]-?: NonNullable<T[P]>;
|
2794
3013
|
};
|
2795
3014
|
declare type GetArrayInnerType<T extends readonly any[]> = T[number];
|
2796
3015
|
declare type SingleOrArray<T> = T | T[];
|
2797
|
-
declare type
|
3016
|
+
declare type OmitBy<T, K extends keyof T> = T extends any ? Omit<T, K> : never;
|
3017
|
+
declare type Without<T, U> = {
|
3018
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
3019
|
+
};
|
3020
|
+
declare type ExclusiveOr<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
|
2798
3021
|
|
2799
3022
|
declare type SelectableColumn<O, RecursivePath extends any[] = []> = '*' | 'id' | DataProps<O> | NestedColumns<O, RecursivePath>;
|
2800
|
-
declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord & UnionToIntersection<Values<{
|
2801
|
-
[K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord
|
3023
|
+
declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord<O> & UnionToIntersection<Values<{
|
3024
|
+
[K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord<O>;
|
2802
3025
|
}>>;
|
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<
|
2805
|
-
} : never
|
3026
|
+
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> ? {
|
3027
|
+
V: ValueAtColumn<Item, V>;
|
3028
|
+
} : never : O[K] : never> : never : never;
|
2806
3029
|
declare type MAX_RECURSION = 5;
|
2807
3030
|
declare type NestedColumns<O, RecursivePath extends any[]> = RecursivePath['length'] extends MAX_RECURSION ? never : If<IsObject<O>, Values<{
|
2808
|
-
[K in DataProps<O>]:
|
2809
|
-
If<IsObject<
|
2810
|
-
K
|
3031
|
+
[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
|
3032
|
+
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
|
3033
|
+
K>> : never;
|
2811
3034
|
}>, never>;
|
2812
3035
|
declare type DataProps<O> = Exclude<StringKeys<O>, StringKeys<XataRecord>>;
|
2813
3036
|
declare type NestedValueAtColumn<O, Key extends SelectableColumn<O>> = Key extends `${infer N}.${infer M}` ? N extends DataProps<O> ? {
|
@@ -2834,27 +3057,37 @@ interface BaseData {
|
|
2834
3057
|
/**
|
2835
3058
|
* Represents a persisted record from the database.
|
2836
3059
|
*/
|
2837
|
-
interface XataRecord extends Identifiable {
|
3060
|
+
interface XataRecord<OriginalRecord extends XataRecord<any> = XataRecord<any>> extends Identifiable {
|
2838
3061
|
/**
|
2839
|
-
*
|
3062
|
+
* Get metadata of this record.
|
2840
3063
|
*/
|
2841
|
-
|
2842
|
-
/**
|
2843
|
-
* Number that is increased every time the record is updated.
|
2844
|
-
*/
|
2845
|
-
version: number;
|
2846
|
-
};
|
3064
|
+
getMetadata(): XataRecordMetadata;
|
2847
3065
|
/**
|
2848
3066
|
* Retrieves a refreshed copy of the current record from the database.
|
3067
|
+
* @param columns The columns to retrieve. If not specified, all first level properties are retrieved.
|
3068
|
+
* @returns The persisted record with the selected columns.
|
2849
3069
|
*/
|
2850
|
-
read(): Promise<Readonly<SelectedPick<
|
3070
|
+
read<K extends SelectableColumn<OriginalRecord>>(columns: K[]): Promise<Readonly<SelectedPick<OriginalRecord, typeof columns>> | null>;
|
3071
|
+
/**
|
3072
|
+
* Retrieves a refreshed copy of the current record from the database.
|
3073
|
+
* @returns The persisted record with all first level properties.
|
3074
|
+
*/
|
3075
|
+
read(): Promise<Readonly<SelectedPick<OriginalRecord, ['*']>> | null>;
|
2851
3076
|
/**
|
2852
3077
|
* Performs a partial update of the current record. On success a new object is
|
2853
3078
|
* returned and the current object is not mutated.
|
2854
|
-
* @param
|
2855
|
-
* @
|
3079
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
3080
|
+
* @param columns The columns to retrieve. If not specified, all first level properties are retrieved.
|
3081
|
+
* @returns The persisted record with the selected columns.
|
2856
3082
|
*/
|
2857
|
-
update(partialUpdate: Partial<EditableData<Omit<
|
3083
|
+
update<K extends SelectableColumn<OriginalRecord>>(partialUpdate: Partial<EditableData<Omit<OriginalRecord, keyof XataRecord>>>, columns: K[]): Promise<Readonly<SelectedPick<OriginalRecord, typeof columns>>>;
|
3084
|
+
/**
|
3085
|
+
* Performs a partial update of the current record. On success a new object is
|
3086
|
+
* returned and the current object is not mutated.
|
3087
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
3088
|
+
* @returns The persisted record with all first level properties.
|
3089
|
+
*/
|
3090
|
+
update(partialUpdate: Partial<EditableData<Omit<OriginalRecord, keyof XataRecord>>>): Promise<Readonly<SelectedPick<OriginalRecord, ['*']>>>;
|
2858
3091
|
/**
|
2859
3092
|
* Performs a deletion of the current record in the database.
|
2860
3093
|
*
|
@@ -2866,23 +3099,36 @@ declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update
|
|
2866
3099
|
/**
|
2867
3100
|
* Retrieves a refreshed copy of the current record from the database.
|
2868
3101
|
*/
|
2869
|
-
read(): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
|
3102
|
+
read<K extends SelectableColumn<Record>>(columns?: K[]): Promise<Readonly<SelectedPick<Record, typeof columns extends SelectableColumn<Record>[] ? typeof columns : ['*']>> | null>;
|
2870
3103
|
/**
|
2871
3104
|
* Performs a partial update of the current record. On success a new object is
|
2872
3105
|
* returned and the current object is not mutated.
|
2873
|
-
* @param
|
3106
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
2874
3107
|
* @returns A new record containing the latest values for all the columns of the current record.
|
2875
3108
|
*/
|
2876
|
-
update(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord
|
3109
|
+
update<K extends SelectableColumn<Record>>(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>, columns?: K[]): Promise<Readonly<SelectedPick<Record, typeof columns extends SelectableColumn<Record>[] ? typeof columns : ['*']>>>;
|
3110
|
+
/**
|
3111
|
+
* Performs a deletion of the current record in the database.
|
3112
|
+
*
|
3113
|
+
* @throws If the record was already deleted or if an error happened while performing the deletion.
|
3114
|
+
*/
|
3115
|
+
delete(): Promise<void>;
|
3116
|
+
};
|
3117
|
+
declare type XataRecordMetadata = {
|
3118
|
+
/**
|
3119
|
+
* Number that is increased every time the record is updated.
|
3120
|
+
*/
|
3121
|
+
version: number;
|
3122
|
+
warnings?: string[];
|
2877
3123
|
};
|
2878
3124
|
declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
|
2879
3125
|
declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
|
2880
3126
|
declare type EditableData<O extends BaseData> = {
|
2881
3127
|
[K in keyof O]: O[K] extends XataRecord ? {
|
2882
3128
|
id: string;
|
2883
|
-
} : NonNullable<O[K]> extends XataRecord ? {
|
3129
|
+
} | string : NonNullable<O[K]> extends XataRecord ? {
|
2884
3130
|
id: string;
|
2885
|
-
} | null | undefined : O[K];
|
3131
|
+
} | string | null | undefined : O[K];
|
2886
3132
|
};
|
2887
3133
|
|
2888
3134
|
/**
|
@@ -2958,8 +3204,8 @@ declare type ValueTypeFilters<T> = T | T extends string ? StringTypeFilter : T e
|
|
2958
3204
|
],
|
2959
3205
|
}
|
2960
3206
|
*/
|
2961
|
-
declare type AggregatorFilter<
|
2962
|
-
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<
|
3207
|
+
declare type AggregatorFilter<T> = {
|
3208
|
+
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<T>>;
|
2963
3209
|
};
|
2964
3210
|
/**
|
2965
3211
|
* Existance filter
|
@@ -2974,10 +3220,88 @@ declare type BaseApiFilter<Record> = PropertyAccessFilter<Record> | AggregatorFi
|
|
2974
3220
|
* Injects the Api filters on nested properties
|
2975
3221
|
* Example: { filter: { settings: { plan: { $any: ['free', 'trial'] } } } }
|
2976
3222
|
*/
|
2977
|
-
declare type NestedApiFilter<T> =
|
3223
|
+
declare type NestedApiFilter<T> = {
|
2978
3224
|
[key in keyof T]?: T[key] extends Record<string, any> ? SingleOrArray<Filter<T[key]>> : PropertyFilter<T[key]>;
|
2979
|
-
}
|
2980
|
-
declare type Filter<
|
3225
|
+
};
|
3226
|
+
declare type Filter<T> = T extends Record<string, any> ? T extends Date ? PropertyFilter<T> : BaseApiFilter<T> | NestedApiFilter<T> : PropertyFilter<T>;
|
3227
|
+
|
3228
|
+
declare type DateBooster = {
|
3229
|
+
origin?: string;
|
3230
|
+
scale: string;
|
3231
|
+
decay: number;
|
3232
|
+
};
|
3233
|
+
declare type NumericBooster = {
|
3234
|
+
factor: number;
|
3235
|
+
};
|
3236
|
+
declare type ValueBooster<T extends string | number | boolean> = {
|
3237
|
+
value: T;
|
3238
|
+
factor: number;
|
3239
|
+
};
|
3240
|
+
declare type Boosters<O extends XataRecord> = Values<{
|
3241
|
+
[K in SelectableColumn<O>]: NonNullable<ValueAtColumn<O, K>> extends Date ? {
|
3242
|
+
dateBooster: {
|
3243
|
+
column: K;
|
3244
|
+
} & DateBooster;
|
3245
|
+
} : NonNullable<ValueAtColumn<O, K>> extends number ? ExclusiveOr<{
|
3246
|
+
numericBooster?: {
|
3247
|
+
column: K;
|
3248
|
+
} & NumericBooster;
|
3249
|
+
}, {
|
3250
|
+
valueBooster?: {
|
3251
|
+
column: K;
|
3252
|
+
} & ValueBooster<number>;
|
3253
|
+
}> : NonNullable<ValueAtColumn<O, K>> extends string | boolean ? {
|
3254
|
+
valueBooster: {
|
3255
|
+
column: K;
|
3256
|
+
} & ValueBooster<NonNullable<ValueAtColumn<O, K>>>;
|
3257
|
+
} : never;
|
3258
|
+
}>;
|
3259
|
+
|
3260
|
+
declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
|
3261
|
+
fuzziness?: FuzzinessExpression;
|
3262
|
+
prefix?: PrefixExpression;
|
3263
|
+
highlight?: HighlightExpression;
|
3264
|
+
tables?: Array<Tables | Values<{
|
3265
|
+
[Model in GetArrayInnerType<NonNullable<Tables[]>>]: {
|
3266
|
+
table: Model;
|
3267
|
+
filter?: Filter<SelectedPick<Schemas[Model] & XataRecord, ['*']>>;
|
3268
|
+
boosters?: Boosters<Schemas[Model] & XataRecord>[];
|
3269
|
+
};
|
3270
|
+
}>>;
|
3271
|
+
};
|
3272
|
+
declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
|
3273
|
+
all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
|
3274
|
+
[Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]: {
|
3275
|
+
table: Model;
|
3276
|
+
record: Awaited<SearchXataRecord<SelectedPick<Schemas[Model] & XataRecord, ['*']>>>;
|
3277
|
+
};
|
3278
|
+
}>[]>;
|
3279
|
+
byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
|
3280
|
+
[Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]?: Awaited<SearchXataRecord<SelectedPick<Schemas[Model] & XataRecord, ['*']>>[]>;
|
3281
|
+
}>;
|
3282
|
+
};
|
3283
|
+
declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
3284
|
+
#private;
|
3285
|
+
private db;
|
3286
|
+
constructor(db: SchemaPluginResult<Schemas>, schemaTables?: Schemas.Table[]);
|
3287
|
+
build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
|
3288
|
+
}
|
3289
|
+
declare type SearchXataRecord<Record extends XataRecord> = Omit<Record, 'getMetadata'> & {
|
3290
|
+
getMetadata: () => XataRecordMetadata & SearchExtraProperties;
|
3291
|
+
};
|
3292
|
+
declare type SearchExtraProperties = {
|
3293
|
+
table: string;
|
3294
|
+
highlight?: {
|
3295
|
+
[key: string]: string[] | {
|
3296
|
+
[key: string]: any;
|
3297
|
+
};
|
3298
|
+
};
|
3299
|
+
score?: number;
|
3300
|
+
};
|
3301
|
+
declare type ReturnTable<Table, Tables> = Table extends Tables ? Table : never;
|
3302
|
+
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 {
|
3303
|
+
table: infer Table;
|
3304
|
+
} ? ReturnTable<Table, Tables> : never;
|
2981
3305
|
|
2982
3306
|
declare type SortDirection = 'asc' | 'desc';
|
2983
3307
|
declare type SortFilterExtended<T extends XataRecord> = {
|
@@ -2989,13 +3313,21 @@ declare type SortFilterBase<T extends XataRecord> = {
|
|
2989
3313
|
[Key in StringKeys<T>]: SortDirection;
|
2990
3314
|
};
|
2991
3315
|
|
2992
|
-
declare type
|
2993
|
-
|
2994
|
-
|
3316
|
+
declare type BaseOptions<T extends XataRecord> = {
|
3317
|
+
columns?: SelectableColumn<T>[];
|
3318
|
+
cache?: number;
|
3319
|
+
};
|
3320
|
+
declare type CursorQueryOptions = {
|
3321
|
+
pagination?: CursorNavigationOptions & OffsetNavigationOptions;
|
3322
|
+
filter?: never;
|
3323
|
+
sort?: never;
|
3324
|
+
};
|
3325
|
+
declare type OffsetQueryOptions<T extends XataRecord> = {
|
3326
|
+
pagination?: OffsetNavigationOptions;
|
2995
3327
|
filter?: FilterExpression;
|
2996
3328
|
sort?: SortFilter<T> | SortFilter<T>[];
|
2997
|
-
cache?: number;
|
2998
3329
|
};
|
3330
|
+
declare type QueryOptions<T extends XataRecord> = BaseOptions<T> & (CursorQueryOptions | OffsetQueryOptions<T>);
|
2999
3331
|
/**
|
3000
3332
|
* Query objects contain the information of all filters, sorting, etc. to be included in the database query.
|
3001
3333
|
*
|
@@ -3005,8 +3337,8 @@ declare type QueryOptions<T extends XataRecord> = {
|
|
3005
3337
|
declare class Query<Record extends XataRecord, Result extends XataRecord = Record> implements Paginable<Record, Result> {
|
3006
3338
|
#private;
|
3007
3339
|
readonly meta: PaginationQueryMeta;
|
3008
|
-
readonly records: Result
|
3009
|
-
constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>,
|
3340
|
+
readonly records: RecordArray<Result>;
|
3341
|
+
constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, rawParent?: Partial<QueryOptions<Record>>);
|
3010
3342
|
getQueryOptions(): QueryOptions<Record>;
|
3011
3343
|
key(): string;
|
3012
3344
|
/**
|
@@ -3038,73 +3370,183 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
3038
3370
|
*
|
3039
3371
|
* ```
|
3040
3372
|
* query.filter("columnName", columnValue)
|
3041
|
-
* query.filter(
|
3042
|
-
*
|
3043
|
-
*
|
3373
|
+
* query.filter("columnName", operator(columnValue)) // Use gt, gte, lt, lte, startsWith,...
|
3374
|
+
* ```
|
3375
|
+
*
|
3376
|
+
* @param column The name of the column to filter.
|
3377
|
+
* @param value The value to filter.
|
3378
|
+
* @returns A new Query object.
|
3379
|
+
*/
|
3380
|
+
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<NonNullable<ValueAtColumn<Record, F>>>): Query<Record, Result>;
|
3381
|
+
/**
|
3382
|
+
* Builds a new query object adding one or more constraints. Examples:
|
3383
|
+
*
|
3384
|
+
* ```
|
3385
|
+
* query.filter({ "columnName": columnValue })
|
3044
3386
|
* query.filter({
|
3045
3387
|
* "columnName": operator(columnValue) // Use gt, gte, lt, lte, startsWith,...
|
3046
3388
|
* })
|
3047
3389
|
* ```
|
3048
3390
|
*
|
3391
|
+
* @param filters A filter object
|
3049
3392
|
* @returns A new Query object.
|
3050
3393
|
*/
|
3051
3394
|
filter(filters: Filter<Record>): Query<Record, Result>;
|
3052
|
-
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
|
3053
3395
|
/**
|
3054
3396
|
* Builds a new query with a new sort option.
|
3055
3397
|
* @param column The column name.
|
3056
3398
|
* @param direction The direction. Either ascending or descending.
|
3057
3399
|
* @returns A new Query object.
|
3058
3400
|
*/
|
3059
|
-
sort<F extends SelectableColumn<Record>>(column: F, direction
|
3401
|
+
sort<F extends SelectableColumn<Record>>(column: F, direction?: SortDirection): Query<Record, Result>;
|
3060
3402
|
/**
|
3061
3403
|
* Builds a new query specifying the set of columns to be returned in the query response.
|
3062
3404
|
* @param columns Array of column names to be returned by the query.
|
3063
3405
|
* @returns A new Query object.
|
3064
3406
|
*/
|
3065
|
-
select<K extends SelectableColumn<Record>>(columns:
|
3407
|
+
select<K extends SelectableColumn<Record>>(columns: K[]): Query<Record, SelectedPick<Record, K[]>>;
|
3408
|
+
/**
|
3409
|
+
* Get paginated results
|
3410
|
+
*
|
3411
|
+
* @returns A page of results
|
3412
|
+
*/
|
3066
3413
|
getPaginated(): Promise<Page<Record, Result>>;
|
3067
|
-
|
3414
|
+
/**
|
3415
|
+
* Get paginated results
|
3416
|
+
*
|
3417
|
+
* @param options Pagination options
|
3418
|
+
* @returns A page of results
|
3419
|
+
*/
|
3420
|
+
getPaginated(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
|
3421
|
+
/**
|
3422
|
+
* Get paginated results
|
3423
|
+
*
|
3424
|
+
* @param options Pagination options
|
3425
|
+
* @returns A page of results
|
3426
|
+
*/
|
3068
3427
|
getPaginated<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<Page<Record, SelectedPick<Record, typeof options['columns']>>>;
|
3428
|
+
/**
|
3429
|
+
* Get results in an iterator
|
3430
|
+
*
|
3431
|
+
* @async
|
3432
|
+
* @returns Async interable of results
|
3433
|
+
*/
|
3069
3434
|
[Symbol.asyncIterator](): AsyncIterableIterator<Result>;
|
3070
|
-
|
3071
|
-
|
3072
|
-
|
3435
|
+
/**
|
3436
|
+
* Build an iterator of results
|
3437
|
+
*
|
3438
|
+
* @returns Async generator of results array
|
3439
|
+
*/
|
3440
|
+
getIterator(): AsyncGenerator<Result[]>;
|
3441
|
+
/**
|
3442
|
+
* Build an iterator of results
|
3443
|
+
*
|
3444
|
+
* @param options Pagination options with batchSize
|
3445
|
+
* @returns Async generator of results array
|
3446
|
+
*/
|
3447
|
+
getIterator(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
|
3448
|
+
batchSize?: number;
|
3449
|
+
}): AsyncGenerator<Result[]>;
|
3450
|
+
/**
|
3451
|
+
* Build an iterator of results
|
3452
|
+
*
|
3453
|
+
* @param options Pagination options with batchSize
|
3454
|
+
* @returns Async generator of results array
|
3455
|
+
*/
|
3456
|
+
getIterator<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
|
3457
|
+
batchSize?: number;
|
3458
|
+
}>(options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
|
3459
|
+
/**
|
3460
|
+
* Performs the query in the database and returns a set of results.
|
3461
|
+
* @returns An array of records from the database.
|
3462
|
+
*/
|
3463
|
+
getMany(): Promise<RecordArray<Result>>;
|
3464
|
+
/**
|
3465
|
+
* Performs the query in the database and returns a set of results.
|
3466
|
+
* @param options Additional options to be used when performing the query.
|
3467
|
+
* @returns An array of records from the database.
|
3468
|
+
*/
|
3469
|
+
getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<RecordArray<SelectedPick<Record, typeof options['columns']>>>;
|
3073
3470
|
/**
|
3074
3471
|
* Performs the query in the database and returns a set of results.
|
3075
3472
|
* @param options Additional options to be used when performing the query.
|
3076
3473
|
* @returns An array of records from the database.
|
3077
3474
|
*/
|
3078
|
-
getMany(): Promise<Result
|
3079
|
-
|
3080
|
-
|
3475
|
+
getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<RecordArray<Result>>;
|
3476
|
+
/**
|
3477
|
+
* Performs the query in the database and returns all the results.
|
3478
|
+
* Warning: If there are a large number of results, this method can have performance implications.
|
3479
|
+
* @returns An array of records from the database.
|
3480
|
+
*/
|
3481
|
+
getAll(): Promise<Result[]>;
|
3482
|
+
/**
|
3483
|
+
* Performs the query in the database and returns all the results.
|
3484
|
+
* Warning: If there are a large number of results, this method can have performance implications.
|
3485
|
+
* @param options Additional options to be used when performing the query.
|
3486
|
+
* @returns An array of records from the database.
|
3487
|
+
*/
|
3488
|
+
getAll<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
|
3489
|
+
batchSize?: number;
|
3490
|
+
}>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
|
3081
3491
|
/**
|
3082
3492
|
* Performs the query in the database and returns all the results.
|
3083
3493
|
* Warning: If there are a large number of results, this method can have performance implications.
|
3084
3494
|
* @param options Additional options to be used when performing the query.
|
3085
3495
|
* @returns An array of records from the database.
|
3086
3496
|
*/
|
3087
|
-
getAll(
|
3088
|
-
|
3089
|
-
|
3497
|
+
getAll(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
|
3498
|
+
batchSize?: number;
|
3499
|
+
}): Promise<Result[]>;
|
3090
3500
|
/**
|
3091
3501
|
* Performs the query in the database and returns the first result.
|
3092
|
-
* @param options Additional options to be used when performing the query.
|
3093
3502
|
* @returns The first record that matches the query, or null if no record matched the query.
|
3094
3503
|
*/
|
3095
3504
|
getFirst(): Promise<Result | null>;
|
3096
|
-
|
3097
|
-
|
3505
|
+
/**
|
3506
|
+
* Performs the query in the database and returns the first result.
|
3507
|
+
* @param options Additional options to be used when performing the query.
|
3508
|
+
* @returns The first record that matches the query, or null if no record matched the query.
|
3509
|
+
*/
|
3510
|
+
getFirst<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
|
3511
|
+
/**
|
3512
|
+
* Performs the query in the database and returns the first result.
|
3513
|
+
* @param options Additional options to be used when performing the query.
|
3514
|
+
* @returns The first record that matches the query, or null if no record matched the query.
|
3515
|
+
*/
|
3516
|
+
getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
|
3098
3517
|
/**
|
3099
3518
|
* Builds a new query object adding a cache TTL in milliseconds.
|
3100
3519
|
* @param ttl The cache TTL in milliseconds.
|
3101
3520
|
* @returns A new Query object.
|
3102
3521
|
*/
|
3103
3522
|
cache(ttl: number): Query<Record, Result>;
|
3523
|
+
/**
|
3524
|
+
* Retrieve next page of records
|
3525
|
+
*
|
3526
|
+
* @returns A new page object.
|
3527
|
+
*/
|
3104
3528
|
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3529
|
+
/**
|
3530
|
+
* Retrieve previous page of records
|
3531
|
+
*
|
3532
|
+
* @returns A new page object
|
3533
|
+
*/
|
3105
3534
|
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3535
|
+
/**
|
3536
|
+
* Retrieve first page of records
|
3537
|
+
*
|
3538
|
+
* @returns A new page object
|
3539
|
+
*/
|
3106
3540
|
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3541
|
+
/**
|
3542
|
+
* Retrieve last page of records
|
3543
|
+
*
|
3544
|
+
* @returns A new page object
|
3545
|
+
*/
|
3107
3546
|
lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3547
|
+
/**
|
3548
|
+
* @returns Boolean indicating if there is a next page
|
3549
|
+
*/
|
3108
3550
|
hasNextPage(): boolean;
|
3109
3551
|
}
|
3110
3552
|
|
@@ -3116,7 +3558,7 @@ declare type PaginationQueryMeta = {
|
|
3116
3558
|
};
|
3117
3559
|
interface Paginable<Record extends XataRecord, Result extends XataRecord = Record> {
|
3118
3560
|
meta: PaginationQueryMeta;
|
3119
|
-
records: Result
|
3561
|
+
records: RecordArray<Result>;
|
3120
3562
|
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3121
3563
|
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3122
3564
|
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
@@ -3136,7 +3578,7 @@ declare class Page<Record extends XataRecord, Result extends XataRecord = Record
|
|
3136
3578
|
/**
|
3137
3579
|
* The set of results for this page.
|
3138
3580
|
*/
|
3139
|
-
readonly records: Result
|
3581
|
+
readonly records: RecordArray<Result>;
|
3140
3582
|
constructor(query: Query<Record, Result>, meta: PaginationQueryMeta, records?: Result[]);
|
3141
3583
|
/**
|
3142
3584
|
* Retrieves the next page of results.
|
@@ -3184,44 +3626,154 @@ declare type OffsetNavigationOptions = {
|
|
3184
3626
|
size?: number;
|
3185
3627
|
offset?: number;
|
3186
3628
|
};
|
3187
|
-
declare type PaginationOptions = CursorNavigationOptions & OffsetNavigationOptions;
|
3188
3629
|
declare const PAGINATION_MAX_SIZE = 200;
|
3189
|
-
declare const PAGINATION_DEFAULT_SIZE =
|
3630
|
+
declare const PAGINATION_DEFAULT_SIZE = 20;
|
3190
3631
|
declare const PAGINATION_MAX_OFFSET = 800;
|
3191
3632
|
declare const PAGINATION_DEFAULT_OFFSET = 0;
|
3633
|
+
declare function isCursorPaginationOptions(options: Record<string, unknown> | undefined | null): options is CursorNavigationOptions;
|
3634
|
+
declare class RecordArray<Result extends XataRecord> extends Array<Result> {
|
3635
|
+
#private;
|
3636
|
+
constructor(page: Paginable<any, Result>, overrideRecords?: Result[]);
|
3637
|
+
static parseConstructorParams(...args: any[]): any[];
|
3638
|
+
toArray(): Result[];
|
3639
|
+
map<U>(callbackfn: (value: Result, index: number, array: Result[]) => U, thisArg?: any): U[];
|
3640
|
+
/**
|
3641
|
+
* Retrieve next page of records
|
3642
|
+
*
|
3643
|
+
* @returns A new array of objects
|
3644
|
+
*/
|
3645
|
+
nextPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3646
|
+
/**
|
3647
|
+
* Retrieve previous page of records
|
3648
|
+
*
|
3649
|
+
* @returns A new array of objects
|
3650
|
+
*/
|
3651
|
+
previousPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3652
|
+
/**
|
3653
|
+
* Retrieve first page of records
|
3654
|
+
*
|
3655
|
+
* @returns A new array of objects
|
3656
|
+
*/
|
3657
|
+
firstPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3658
|
+
/**
|
3659
|
+
* Retrieve last page of records
|
3660
|
+
*
|
3661
|
+
* @returns A new array of objects
|
3662
|
+
*/
|
3663
|
+
lastPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3664
|
+
/**
|
3665
|
+
* @returns Boolean indicating if there is a next page
|
3666
|
+
*/
|
3667
|
+
hasNextPage(): boolean;
|
3668
|
+
}
|
3192
3669
|
|
3193
|
-
declare type TableLink = string[];
|
3194
|
-
declare type LinkDictionary = Dictionary<TableLink[]>;
|
3195
3670
|
/**
|
3196
3671
|
* Common interface for performing operations on a table.
|
3197
3672
|
*/
|
3198
3673
|
declare abstract class Repository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, Readonly<SelectedPick<Record, ['*']>>> {
|
3199
|
-
abstract create(object: EditableData<Data> & Partial<Identifiable
|
3674
|
+
abstract create<K extends SelectableColumn<Record>>(object: Omit<EditableData<Data>, 'id'> & Partial<Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
3675
|
+
abstract create(object: Omit<EditableData<Data>, 'id'> & Partial<Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3676
|
+
/**
|
3677
|
+
* Creates a single record in the table with a unique id.
|
3678
|
+
* @param id The unique id.
|
3679
|
+
* @param object Object containing the column names with their values to be stored in the table.
|
3680
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3681
|
+
* @returns The full persisted record.
|
3682
|
+
*/
|
3683
|
+
abstract create<K extends SelectableColumn<Record>>(id: string, object: Omit<EditableData<Data>, 'id'>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
3200
3684
|
/**
|
3201
3685
|
* Creates a single record in the table with a unique id.
|
3202
3686
|
* @param id The unique id.
|
3203
3687
|
* @param object Object containing the column names with their values to be stored in the table.
|
3204
3688
|
* @returns The full persisted record.
|
3205
3689
|
*/
|
3206
|
-
abstract create(id: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3690
|
+
abstract create(id: string, object: Omit<EditableData<Data>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3207
3691
|
/**
|
3208
3692
|
* Creates multiple records in the table.
|
3209
3693
|
* @param objects Array of objects with the column names and the values to be stored in the table.
|
3210
|
-
* @
|
3694
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3695
|
+
* @returns Array of the persisted records in order.
|
3696
|
+
*/
|
3697
|
+
abstract create<K extends SelectableColumn<Record>>(objects: Array<Omit<EditableData<Data>, 'id'> & Partial<Identifiable>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
|
3698
|
+
/**
|
3699
|
+
* Creates multiple records in the table.
|
3700
|
+
* @param objects Array of objects with the column names and the values to be stored in the table.
|
3701
|
+
* @returns Array of the persisted records in order.
|
3702
|
+
*/
|
3703
|
+
abstract create(objects: Array<Omit<EditableData<Data>, 'id'> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
|
3704
|
+
/**
|
3705
|
+
* Queries a single record from the table given its unique id.
|
3706
|
+
* @param id The unique id.
|
3707
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3708
|
+
* @returns The persisted record for the given id or null if the record could not be found.
|
3211
3709
|
*/
|
3212
|
-
abstract
|
3710
|
+
abstract read<K extends SelectableColumn<Record>>(id: string, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns> | null>>;
|
3213
3711
|
/**
|
3214
3712
|
* Queries a single record from the table given its unique id.
|
3215
3713
|
* @param id The unique id.
|
3216
3714
|
* @returns The persisted record for the given id or null if the record could not be found.
|
3217
3715
|
*/
|
3218
3716
|
abstract read(id: string): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
|
3717
|
+
/**
|
3718
|
+
* Queries multiple records from the table given their unique id.
|
3719
|
+
* @param ids The unique ids array.
|
3720
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3721
|
+
* @returns The persisted records for the given ids in order (if a record could not be found null is returned).
|
3722
|
+
*/
|
3723
|
+
abstract read<K extends SelectableColumn<Record>>(ids: string[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
|
3724
|
+
/**
|
3725
|
+
* Queries multiple records from the table given their unique id.
|
3726
|
+
* @param ids The unique ids array.
|
3727
|
+
* @returns The persisted records for the given ids in order (if a record could not be found null is returned).
|
3728
|
+
*/
|
3729
|
+
abstract read(ids: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
|
3730
|
+
/**
|
3731
|
+
* Queries a single record from the table by the id in the object.
|
3732
|
+
* @param object Object containing the id of the record.
|
3733
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3734
|
+
* @returns The persisted record for the given id or null if the record could not be found.
|
3735
|
+
*/
|
3736
|
+
abstract read<K extends SelectableColumn<Record>>(object: Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns> | null>>;
|
3737
|
+
/**
|
3738
|
+
* Queries a single record from the table by the id in the object.
|
3739
|
+
* @param object Object containing the id of the record.
|
3740
|
+
* @returns The persisted record for the given id or null if the record could not be found.
|
3741
|
+
*/
|
3742
|
+
abstract read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
|
3743
|
+
/**
|
3744
|
+
* Queries multiple records from the table by the ids in the objects.
|
3745
|
+
* @param objects Array of objects containing the ids of the records.
|
3746
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3747
|
+
* @returns The persisted records for the given ids in order (if a record could not be found null is returned).
|
3748
|
+
*/
|
3749
|
+
abstract read<K extends SelectableColumn<Record>>(objects: Identifiable[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
|
3750
|
+
/**
|
3751
|
+
* Queries multiple records from the table by the ids in the objects.
|
3752
|
+
* @param objects Array of objects containing the ids of the records.
|
3753
|
+
* @returns The persisted records for the given ids in order (if a record could not be found null is returned).
|
3754
|
+
*/
|
3755
|
+
abstract read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
|
3756
|
+
/**
|
3757
|
+
* Partially update a single record.
|
3758
|
+
* @param object An object with its id and the columns to be updated.
|
3759
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3760
|
+
* @returns The full persisted record.
|
3761
|
+
*/
|
3762
|
+
abstract update<K extends SelectableColumn<Record>>(object: Partial<EditableData<Data>> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
3219
3763
|
/**
|
3220
3764
|
* Partially update a single record.
|
3221
3765
|
* @param object An object with its id and the columns to be updated.
|
3222
3766
|
* @returns The full persisted record.
|
3223
3767
|
*/
|
3224
3768
|
abstract update(object: Partial<EditableData<Data>> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3769
|
+
/**
|
3770
|
+
* Partially update a single record given its unique id.
|
3771
|
+
* @param id The unique id.
|
3772
|
+
* @param object The column names and their values that have to be updated.
|
3773
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3774
|
+
* @returns The full persisted record.
|
3775
|
+
*/
|
3776
|
+
abstract update<K extends SelectableColumn<Record>>(id: string, object: Partial<EditableData<Data>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
3225
3777
|
/**
|
3226
3778
|
* Partially update a single record given its unique id.
|
3227
3779
|
* @param id The unique id.
|
@@ -3232,9 +3784,24 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
3232
3784
|
/**
|
3233
3785
|
* Partially updates multiple records.
|
3234
3786
|
* @param objects An array of objects with their ids and columns to be updated.
|
3235
|
-
* @
|
3787
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3788
|
+
* @returns Array of the persisted records in order.
|
3789
|
+
*/
|
3790
|
+
abstract update<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Data>> & Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
|
3791
|
+
/**
|
3792
|
+
* Partially updates multiple records.
|
3793
|
+
* @param objects An array of objects with their ids and columns to be updated.
|
3794
|
+
* @returns Array of the persisted records in order.
|
3236
3795
|
*/
|
3237
3796
|
abstract update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
|
3797
|
+
/**
|
3798
|
+
* Creates or updates a single record. If a record exists with the given id,
|
3799
|
+
* it will be update, otherwise a new record will be created.
|
3800
|
+
* @param object Object containing the column names with their values to be persisted in the table.
|
3801
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3802
|
+
* @returns The full persisted record.
|
3803
|
+
*/
|
3804
|
+
abstract createOrUpdate<K extends SelectableColumn<Record>>(object: EditableData<Data> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
3238
3805
|
/**
|
3239
3806
|
* Creates or updates a single record. If a record exists with the given id,
|
3240
3807
|
* it will be update, otherwise a new record will be created.
|
@@ -3242,6 +3809,15 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
3242
3809
|
* @returns The full persisted record.
|
3243
3810
|
*/
|
3244
3811
|
abstract createOrUpdate(object: EditableData<Data> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3812
|
+
/**
|
3813
|
+
* Creates or updates a single record. If a record exists with the given id,
|
3814
|
+
* it will be update, otherwise a new record will be created.
|
3815
|
+
* @param id A unique id.
|
3816
|
+
* @param object The column names and the values to be persisted.
|
3817
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3818
|
+
* @returns The full persisted record.
|
3819
|
+
*/
|
3820
|
+
abstract createOrUpdate<K extends SelectableColumn<Record>>(id: string, object: Omit<EditableData<Data>, 'id'>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
3245
3821
|
/**
|
3246
3822
|
* Creates or updates a single record. If a record exists with the given id,
|
3247
3823
|
* it will be update, otherwise a new record will be created.
|
@@ -3249,7 +3825,15 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
3249
3825
|
* @param object The column names and the values to be persisted.
|
3250
3826
|
* @returns The full persisted record.
|
3251
3827
|
*/
|
3252
|
-
abstract createOrUpdate(id: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3828
|
+
abstract createOrUpdate(id: string, object: Omit<EditableData<Data>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3829
|
+
/**
|
3830
|
+
* Creates or updates a single record. If a record exists with the given id,
|
3831
|
+
* it will be update, otherwise a new record will be created.
|
3832
|
+
* @param objects Array of objects with the column names and the values to be stored in the table.
|
3833
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3834
|
+
* @returns Array of the persisted records.
|
3835
|
+
*/
|
3836
|
+
abstract createOrUpdate<K extends SelectableColumn<Record>>(objects: Array<EditableData<Data> & Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
|
3253
3837
|
/**
|
3254
3838
|
* Creates or updates a single record. If a record exists with the given id,
|
3255
3839
|
* it will be update, otherwise a new record will be created.
|
@@ -3288,36 +3872,116 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
3288
3872
|
* @returns The found records.
|
3289
3873
|
*/
|
3290
3874
|
abstract search(query: string, options?: {
|
3291
|
-
fuzziness?:
|
3292
|
-
|
3875
|
+
fuzziness?: FuzzinessExpression;
|
3876
|
+
prefix?: PrefixExpression;
|
3877
|
+
highlight?: HighlightExpression;
|
3878
|
+
filter?: Filter<Record>;
|
3879
|
+
boosters?: Boosters<Record>[];
|
3880
|
+
}): Promise<SearchXataRecord<SelectedPick<Record, ['*']>>[]>;
|
3293
3881
|
abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
3294
3882
|
}
|
3295
3883
|
declare class RestRepository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, SelectedPick<Record, ['*']>> implements Repository<Data, Record> {
|
3296
3884
|
#private;
|
3297
|
-
db: SchemaPluginResult<any>;
|
3298
3885
|
constructor(options: {
|
3299
3886
|
table: string;
|
3300
|
-
links?: LinkDictionary;
|
3301
3887
|
db: SchemaPluginResult<any>;
|
3302
3888
|
pluginOptions: XataPluginOptions;
|
3889
|
+
schemaTables?: Table[];
|
3303
3890
|
});
|
3304
|
-
create(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']
|
3305
|
-
create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']
|
3306
|
-
create(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']
|
3307
|
-
|
3891
|
+
create(object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3892
|
+
create(recordId: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3893
|
+
create(objects: EditableData<Data>[]): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
|
3894
|
+
create<K extends SelectableColumn<Record>>(object: EditableData<Data>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
3895
|
+
create<K extends SelectableColumn<Record>>(recordId: string, object: EditableData<Data>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
3896
|
+
create<K extends SelectableColumn<Record>>(objects: EditableData<Data>[], columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
|
3897
|
+
read(recordId: string): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
|
3898
|
+
read(recordIds: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3899
|
+
read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
|
3900
|
+
read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3901
|
+
read<K extends SelectableColumn<Record>>(recordId: string, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
|
3902
|
+
read<K extends SelectableColumn<Record>>(recordIds: string[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>>>>;
|
3903
|
+
read<K extends SelectableColumn<Record>>(object: Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
|
3904
|
+
read<K extends SelectableColumn<Record>>(objects: Identifiable[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>>>>;
|
3308
3905
|
update(object: Partial<EditableData<Data>> & Identifiable): Promise<SelectedPick<Record, ['*']>>;
|
3309
3906
|
update(recordId: string, object: Partial<EditableData<Data>>): Promise<SelectedPick<Record, ['*']>>;
|
3310
3907
|
update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<SelectedPick<Record, ['*']>[]>;
|
3908
|
+
update<K extends SelectableColumn<Record>>(object: Partial<EditableData<Data>> & Identifiable, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
|
3909
|
+
update<K extends SelectableColumn<Record>>(recordId: string, object: Partial<EditableData<Data>>, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
|
3910
|
+
update<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Data>> & Identifiable>, columns: K[]): Promise<SelectedPick<Record, typeof columns>[]>;
|
3311
3911
|
createOrUpdate(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
|
3312
3912
|
createOrUpdate(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
|
3313
3913
|
createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
|
3914
|
+
createOrUpdate<K extends SelectableColumn<Record>>(object: EditableData<Data>, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
|
3915
|
+
createOrUpdate<K extends SelectableColumn<Record>>(recordId: string, object: EditableData<Data>, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
|
3916
|
+
createOrUpdate<K extends SelectableColumn<Record>>(objects: EditableData<Data>[], columns: K[]): Promise<SelectedPick<Record, typeof columns>[]>;
|
3314
3917
|
delete(a: string | Identifiable | Array<string | Identifiable>): Promise<void>;
|
3315
3918
|
search(query: string, options?: {
|
3316
|
-
fuzziness?:
|
3317
|
-
|
3919
|
+
fuzziness?: FuzzinessExpression;
|
3920
|
+
prefix?: PrefixExpression;
|
3921
|
+
highlight?: HighlightExpression;
|
3922
|
+
filter?: Filter<Record>;
|
3923
|
+
boosters?: Boosters<Record>[];
|
3924
|
+
}): Promise<any>;
|
3318
3925
|
query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
3319
3926
|
}
|
3320
3927
|
|
3928
|
+
declare type BaseSchema = {
|
3929
|
+
name: string;
|
3930
|
+
columns: readonly ({
|
3931
|
+
name: string;
|
3932
|
+
type: Column['type'];
|
3933
|
+
} | {
|
3934
|
+
name: string;
|
3935
|
+
type: 'link';
|
3936
|
+
link: {
|
3937
|
+
table: string;
|
3938
|
+
};
|
3939
|
+
} | {
|
3940
|
+
name: string;
|
3941
|
+
type: 'object';
|
3942
|
+
columns: {
|
3943
|
+
name: string;
|
3944
|
+
type: string;
|
3945
|
+
}[];
|
3946
|
+
})[];
|
3947
|
+
};
|
3948
|
+
declare type SchemaInference<T extends readonly BaseSchema[]> = T extends never[] ? Record<string, Record<string, any>> : T extends readonly unknown[] ? T[number] extends {
|
3949
|
+
name: string;
|
3950
|
+
columns: readonly unknown[];
|
3951
|
+
} ? {
|
3952
|
+
[K in T[number]['name']]: TableType<T[number], K>;
|
3953
|
+
} : never : never;
|
3954
|
+
declare type TableType<Tables, TableName> = Tables & {
|
3955
|
+
name: TableName;
|
3956
|
+
} extends infer Table ? Table extends {
|
3957
|
+
name: string;
|
3958
|
+
columns: infer Columns;
|
3959
|
+
} ? Columns extends readonly unknown[] ? Columns[number] extends {
|
3960
|
+
name: string;
|
3961
|
+
type: string;
|
3962
|
+
} ? Identifiable & {
|
3963
|
+
[K in Columns[number]['name']]?: PropertyType<Tables, Columns[number], K>;
|
3964
|
+
} : never : never : never : never;
|
3965
|
+
declare type PropertyType<Tables, Properties, PropertyName> = Properties & {
|
3966
|
+
name: PropertyName;
|
3967
|
+
} extends infer Property ? Property extends {
|
3968
|
+
name: string;
|
3969
|
+
type: infer Type;
|
3970
|
+
link?: {
|
3971
|
+
table: infer LinkedTable;
|
3972
|
+
};
|
3973
|
+
columns?: infer ObjectColumns;
|
3974
|
+
} ? (Type extends 'string' | 'text' | 'email' ? string : Type extends 'int' | 'float' ? number : Type extends 'bool' ? boolean : Type extends 'datetime' ? Date : Type extends 'multiple' ? string[] : Type extends 'object' ? ObjectColumns extends readonly unknown[] ? ObjectColumns[number] extends {
|
3975
|
+
name: string;
|
3976
|
+
type: string;
|
3977
|
+
} ? {
|
3978
|
+
[K in ObjectColumns[number]['name']]?: PropertyType<Tables, ObjectColumns[number], K>;
|
3979
|
+
} : never : never : Type extends 'link' ? TableType<Tables, LinkedTable> & XataRecord : never) | null : never : never;
|
3980
|
+
|
3981
|
+
/**
|
3982
|
+
* Operator to restrict results to only values that are greater than the given value.
|
3983
|
+
*/
|
3984
|
+
declare const greaterThan: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
3321
3985
|
/**
|
3322
3986
|
* Operator to restrict results to only values that are greater than the given value.
|
3323
3987
|
*/
|
@@ -3325,15 +3989,35 @@ declare const gt: <T extends ComparableType>(value: T) => ComparableTypeFilter<T
|
|
3325
3989
|
/**
|
3326
3990
|
* Operator to restrict results to only values that are greater than or equal to the given value.
|
3327
3991
|
*/
|
3328
|
-
declare const
|
3992
|
+
declare const greaterThanEquals: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
3993
|
+
/**
|
3994
|
+
* Operator to restrict results to only values that are greater than or equal to the given value.
|
3995
|
+
*/
|
3996
|
+
declare const greaterEquals: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
3329
3997
|
/**
|
3330
3998
|
* Operator to restrict results to only values that are greater than or equal to the given value.
|
3331
3999
|
*/
|
3332
4000
|
declare const gte: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
4001
|
+
/**
|
4002
|
+
* Operator to restrict results to only values that are greater than or equal to the given value.
|
4003
|
+
*/
|
4004
|
+
declare const ge: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
4005
|
+
/**
|
4006
|
+
* Operator to restrict results to only values that are lower than the given value.
|
4007
|
+
*/
|
4008
|
+
declare const lessThan: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
3333
4009
|
/**
|
3334
4010
|
* Operator to restrict results to only values that are lower than the given value.
|
3335
4011
|
*/
|
3336
4012
|
declare const lt: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
4013
|
+
/**
|
4014
|
+
* Operator to restrict results to only values that are lower than or equal to the given value.
|
4015
|
+
*/
|
4016
|
+
declare const lessThanEquals: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
4017
|
+
/**
|
4018
|
+
* Operator to restrict results to only values that are lower than or equal to the given value.
|
4019
|
+
*/
|
4020
|
+
declare const lessEquals: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
3337
4021
|
/**
|
3338
4022
|
* Operator to restrict results to only values that are lower than or equal to the given value.
|
3339
4023
|
*/
|
@@ -3366,6 +4050,10 @@ declare const pattern: (value: string) => StringTypeFilter;
|
|
3366
4050
|
* Operator to restrict results to only values that are equal to the given value.
|
3367
4051
|
*/
|
3368
4052
|
declare const is: <T>(value: T) => PropertyFilter<T>;
|
4053
|
+
/**
|
4054
|
+
* Operator to restrict results to only values that are equal to the given value.
|
4055
|
+
*/
|
4056
|
+
declare const equals: <T>(value: T) => PropertyFilter<T>;
|
3369
4057
|
/**
|
3370
4058
|
* Operator to restrict results to only values that are not equal to the given value.
|
3371
4059
|
*/
|
@@ -3393,7 +4081,6 @@ declare const includesAny: <T>(value: T) => ArrayFilter<T>;
|
|
3393
4081
|
|
3394
4082
|
declare type SchemaDefinition = {
|
3395
4083
|
table: string;
|
3396
|
-
links?: LinkDictionary;
|
3397
4084
|
};
|
3398
4085
|
declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
|
3399
4086
|
[Key in keyof Schemas]: Repository<Schemas[Key]>;
|
@@ -3402,40 +4089,10 @@ declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
|
|
3402
4089
|
};
|
3403
4090
|
declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
3404
4091
|
#private;
|
3405
|
-
|
3406
|
-
private tableNames?;
|
3407
|
-
constructor(links?: LinkDictionary | undefined, tableNames?: string[] | undefined);
|
4092
|
+
constructor(schemaTables?: Schemas.Table[]);
|
3408
4093
|
build(pluginOptions: XataPluginOptions): SchemaPluginResult<Schemas>;
|
3409
4094
|
}
|
3410
4095
|
|
3411
|
-
declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
|
3412
|
-
fuzziness?: number;
|
3413
|
-
tables?: Tables[];
|
3414
|
-
};
|
3415
|
-
declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
|
3416
|
-
all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
|
3417
|
-
[Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]: {
|
3418
|
-
table: Model;
|
3419
|
-
record: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
|
3420
|
-
};
|
3421
|
-
}>[]>;
|
3422
|
-
byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
|
3423
|
-
[Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
|
3424
|
-
}>;
|
3425
|
-
};
|
3426
|
-
declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
3427
|
-
#private;
|
3428
|
-
private db;
|
3429
|
-
private links;
|
3430
|
-
constructor(db: SchemaPluginResult<Schemas>, links: LinkDictionary);
|
3431
|
-
build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
|
3432
|
-
}
|
3433
|
-
declare type SearchXataRecord = XataRecord & {
|
3434
|
-
xata: {
|
3435
|
-
table: string;
|
3436
|
-
};
|
3437
|
-
};
|
3438
|
-
|
3439
4096
|
declare type BranchStrategyValue = string | undefined | null;
|
3440
4097
|
declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
|
3441
4098
|
declare type BranchStrategy = BranchStrategyValue | BranchStrategyBuilder;
|
@@ -3447,20 +4104,35 @@ declare type BaseClientOptions = {
|
|
3447
4104
|
databaseURL?: string;
|
3448
4105
|
branch?: BranchStrategyOption;
|
3449
4106
|
cache?: CacheImpl;
|
4107
|
+
trace?: TraceFunction;
|
3450
4108
|
};
|
3451
4109
|
declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
|
3452
4110
|
interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
|
3453
|
-
new <
|
3454
|
-
db: Awaited<ReturnType<SchemaPlugin<
|
3455
|
-
search: Awaited<ReturnType<SearchPlugin<
|
4111
|
+
new <T extends readonly BaseSchema[]>(options?: Partial<BaseClientOptions>, schemaTables?: T): Omit<{
|
4112
|
+
db: Awaited<ReturnType<SchemaPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
|
4113
|
+
search: Awaited<ReturnType<SearchPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
|
3456
4114
|
}, keyof Plugins> & {
|
3457
4115
|
[Key in StringKeys<NonNullable<Plugins>>]: Awaited<ReturnType<NonNullable<Plugins>[Key]['build']>>;
|
4116
|
+
} & {
|
4117
|
+
getConfig(): Promise<{
|
4118
|
+
databaseURL: string;
|
4119
|
+
branch: string;
|
4120
|
+
}>;
|
3458
4121
|
};
|
3459
4122
|
}
|
3460
4123
|
declare const BaseClient_base: ClientConstructor<{}>;
|
3461
|
-
declare class BaseClient extends BaseClient_base<
|
4124
|
+
declare class BaseClient extends BaseClient_base<[]> {
|
3462
4125
|
}
|
3463
4126
|
|
4127
|
+
declare class Serializer {
|
4128
|
+
classes: Record<string, any>;
|
4129
|
+
add(clazz: any): void;
|
4130
|
+
toJSON<T>(data: T): string;
|
4131
|
+
fromJSON<T>(json: string): T;
|
4132
|
+
}
|
4133
|
+
declare const serialize: <T>(data: T) => string;
|
4134
|
+
declare const deserialize: <T>(json: string) => T;
|
4135
|
+
|
3464
4136
|
declare type BranchResolutionOptions = {
|
3465
4137
|
databaseURL?: string;
|
3466
4138
|
apiKey?: string;
|
@@ -3472,9 +4144,89 @@ declare function getDatabaseURL(): string | undefined;
|
|
3472
4144
|
|
3473
4145
|
declare function getAPIKey(): string | undefined;
|
3474
4146
|
|
4147
|
+
interface Body {
|
4148
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
4149
|
+
blob(): Promise<Blob>;
|
4150
|
+
formData(): Promise<FormData>;
|
4151
|
+
json(): Promise<any>;
|
4152
|
+
text(): Promise<string>;
|
4153
|
+
}
|
4154
|
+
interface Blob {
|
4155
|
+
readonly size: number;
|
4156
|
+
readonly type: string;
|
4157
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
4158
|
+
slice(start?: number, end?: number, contentType?: string): Blob;
|
4159
|
+
text(): Promise<string>;
|
4160
|
+
}
|
4161
|
+
/** Provides information about files and allows JavaScript in a web page to access their content. */
|
4162
|
+
interface File extends Blob {
|
4163
|
+
readonly lastModified: number;
|
4164
|
+
readonly name: string;
|
4165
|
+
readonly webkitRelativePath: string;
|
4166
|
+
}
|
4167
|
+
declare type FormDataEntryValue = File | string;
|
4168
|
+
/** Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data". */
|
4169
|
+
interface FormData {
|
4170
|
+
append(name: string, value: string | Blob, fileName?: string): void;
|
4171
|
+
delete(name: string): void;
|
4172
|
+
get(name: string): FormDataEntryValue | null;
|
4173
|
+
getAll(name: string): FormDataEntryValue[];
|
4174
|
+
has(name: string): boolean;
|
4175
|
+
set(name: string, value: string | Blob, fileName?: string): void;
|
4176
|
+
forEach(callbackfn: (value: FormDataEntryValue, key: string, parent: FormData) => void, thisArg?: any): void;
|
4177
|
+
}
|
4178
|
+
/** This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence. */
|
4179
|
+
interface Headers {
|
4180
|
+
append(name: string, value: string): void;
|
4181
|
+
delete(name: string): void;
|
4182
|
+
get(name: string): string | null;
|
4183
|
+
has(name: string): boolean;
|
4184
|
+
set(name: string, value: string): void;
|
4185
|
+
forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void;
|
4186
|
+
}
|
4187
|
+
interface Request extends Body {
|
4188
|
+
/** Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching. */
|
4189
|
+
readonly cache: 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload';
|
4190
|
+
/** Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. */
|
4191
|
+
readonly credentials: 'include' | 'omit' | 'same-origin';
|
4192
|
+
/** Returns the kind of resource requested by request, e.g., "document" or "script". */
|
4193
|
+
readonly destination: '' | 'audio' | 'audioworklet' | 'document' | 'embed' | 'font' | 'frame' | 'iframe' | 'image' | 'manifest' | 'object' | 'paintworklet' | 'report' | 'script' | 'sharedworker' | 'style' | 'track' | 'video' | 'worker' | 'xslt';
|
4194
|
+
/** Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header. */
|
4195
|
+
readonly headers: Headers;
|
4196
|
+
/** Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI] */
|
4197
|
+
readonly integrity: string;
|
4198
|
+
/** Returns a boolean indicating whether or not request can outlive the global in which it was created. */
|
4199
|
+
readonly keepalive: boolean;
|
4200
|
+
/** Returns request's HTTP method, which is "GET" by default. */
|
4201
|
+
readonly method: string;
|
4202
|
+
/** Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs. */
|
4203
|
+
readonly mode: 'cors' | 'navigate' | 'no-cors' | 'same-origin';
|
4204
|
+
/** Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default. */
|
4205
|
+
readonly redirect: 'error' | 'follow' | 'manual';
|
4206
|
+
/** Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and "about:client" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made. */
|
4207
|
+
readonly referrer: string;
|
4208
|
+
/** Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer. */
|
4209
|
+
readonly referrerPolicy: '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
4210
|
+
/** Returns the URL of request as a string. */
|
4211
|
+
readonly url: string;
|
4212
|
+
clone(): Request;
|
4213
|
+
}
|
4214
|
+
|
4215
|
+
declare type XataWorkerContext<XataClient> = {
|
4216
|
+
xata: XataClient;
|
4217
|
+
request: Request;
|
4218
|
+
env: Record<string, string | undefined>;
|
4219
|
+
};
|
4220
|
+
declare type RemoveFirst<T> = T extends [any, ...infer U] ? U : never;
|
4221
|
+
declare type WorkerRunnerConfig = {
|
4222
|
+
workspace: string;
|
4223
|
+
worker: string;
|
4224
|
+
};
|
4225
|
+
declare function buildWorkerRunner<XataClient>(config: WorkerRunnerConfig): <WorkerFunction extends (ctx: XataWorkerContext<XataClient>, ...args: any[]) => any>(name: string, _worker: WorkerFunction) => (...args: RemoveFirst<Parameters<WorkerFunction>>) => Promise<Awaited<ReturnType<WorkerFunction>>>;
|
4226
|
+
|
3475
4227
|
declare class XataError extends Error {
|
3476
4228
|
readonly status: number;
|
3477
4229
|
constructor(message: string, status: number);
|
3478
4230
|
}
|
3479
4231
|
|
3480
|
-
export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddGitBranchesEntryError, AddGitBranchesEntryPathParams, AddGitBranchesEntryRequestBody, AddGitBranchesEntryResponse, AddGitBranchesEntryVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams,
|
4232
|
+
export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddGitBranchesEntryError, AddGitBranchesEntryPathParams, AddGitBranchesEntryRequestBody, AddGitBranchesEntryResponse, AddGitBranchesEntryVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BaseSchema, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsQueryParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsVariables, CacheImpl, CancelWorkspaceMemberInviteError, CancelWorkspaceMemberInvitePathParams, CancelWorkspaceMemberInviteVariables, ClientConstructor, CreateBranchError, CreateBranchPathParams, CreateBranchQueryParams, CreateBranchRequestBody, CreateBranchResponse, CreateBranchVariables, CreateDatabaseError, CreateDatabasePathParams, CreateDatabaseRequestBody, CreateDatabaseResponse, CreateDatabaseVariables, CreateTableError, CreateTablePathParams, CreateTableResponse, CreateTableVariables, CreateUserAPIKeyError, CreateUserAPIKeyPathParams, CreateUserAPIKeyResponse, CreateUserAPIKeyVariables, CreateWorkspaceError, CreateWorkspaceVariables, CursorNavigationOptions, DeleteBranchError, DeleteBranchPathParams, DeleteBranchVariables, DeleteColumnError, DeleteColumnPathParams, DeleteColumnVariables, DeleteDatabaseError, DeleteDatabasePathParams, DeleteDatabaseVariables, DeleteRecordError, DeleteRecordPathParams, DeleteRecordQueryParams, 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, GetDatabaseMetadataError, GetDatabaseMetadataPathParams, GetDatabaseMetadataVariables, GetGitBranchesMappingError, GetGitBranchesMappingPathParams, GetGitBranchesMappingVariables, GetRecordError, GetRecordPathParams, GetRecordQueryParams, 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, InsertRecordQueryParams, InsertRecordVariables, InsertRecordWithIDError, InsertRecordWithIDPathParams, InsertRecordWithIDQueryParams, InsertRecordWithIDVariables, InviteWorkspaceMemberError, InviteWorkspaceMemberPathParams, InviteWorkspaceMemberRequestBody, InviteWorkspaceMemberVariables, Link, OffsetNavigationOptions, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Paginable, PaginationQueryMeta, Query, QueryTableError, QueryTablePathParams, QueryTableRequestBody, QueryTableVariables, RecordArray, RemoveGitBranchesEntryError, RemoveGitBranchesEntryPathParams, RemoveGitBranchesEntryQueryParams, RemoveGitBranchesEntryVariables, RemoveWorkspaceMemberError, RemoveWorkspaceMemberPathParams, RemoveWorkspaceMemberVariables, Repository, ResendWorkspaceMemberInviteError, ResendWorkspaceMemberInvitePathParams, ResendWorkspaceMemberInviteVariables, ResolveBranchError, ResolveBranchPathParams, ResolveBranchQueryParams, ResolveBranchResponse, ResolveBranchVariables, responses as Responses, RestRepository, SchemaDefinition, SchemaInference, SchemaPlugin, SchemaPluginResult, schemas as Schemas, SearchBranchError, SearchBranchPathParams, SearchBranchRequestBody, SearchBranchVariables, SearchOptions, SearchPlugin, SearchPluginResult, SearchTableError, SearchTablePathParams, SearchTableRequestBody, SearchTableVariables, SearchXataRecord, SelectableColumn, SelectedPick, Serializer, SetTableSchemaError, SetTableSchemaPathParams, SetTableSchemaRequestBody, SetTableSchemaVariables, SimpleCache, SimpleCacheOptions, UpdateBranchMetadataError, UpdateBranchMetadataPathParams, UpdateBranchMetadataVariables, UpdateColumnError, UpdateColumnPathParams, UpdateColumnRequestBody, UpdateColumnVariables, UpdateRecordWithIDError, UpdateRecordWithIDPathParams, UpdateRecordWithIDQueryParams, UpdateRecordWithIDVariables, UpdateTableError, UpdateTablePathParams, UpdateTableRequestBody, UpdateTableVariables, UpdateUserError, UpdateUserVariables, UpdateWorkspaceError, UpdateWorkspaceMemberInviteError, UpdateWorkspaceMemberInvitePathParams, UpdateWorkspaceMemberInviteRequestBody, UpdateWorkspaceMemberInviteVariables, UpdateWorkspaceMemberRoleError, UpdateWorkspaceMemberRolePathParams, UpdateWorkspaceMemberRoleRequestBody, UpdateWorkspaceMemberRoleVariables, UpdateWorkspacePathParams, UpdateWorkspaceVariables, UpsertRecordWithIDError, UpsertRecordWithIDPathParams, UpsertRecordWithIDQueryParams, UpsertRecordWithIDVariables, ValueAtColumn, XataApiClient, XataApiClientOptions, XataApiPlugin, XataError, XataPlugin, XataPluginOptions, XataRecord, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
|