@xata.io/client 0.0.0-alpha.vf231460 → 0.0.0-alpha.vf28813b
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 +176 -0
- package/README.md +271 -1
- package/Usage.md +428 -0
- package/dist/index.cjs +774 -330
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1097 -245
- package/dist/index.mjs +747 -331
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -4
- package/tsconfig.json +1 -0
package/dist/index.d.ts
CHANGED
@@ -6,6 +6,9 @@ declare type FetchImpl = (url: string, init?: {
|
|
6
6
|
ok: boolean;
|
7
7
|
status: number;
|
8
8
|
json(): Promise<any>;
|
9
|
+
headers?: {
|
10
|
+
get(name: string): string | null;
|
11
|
+
};
|
9
12
|
}>;
|
10
13
|
declare type WorkspaceApiUrlBuilder = (path: string, pathParams: Record<string, string>) => string;
|
11
14
|
declare type FetcherExtraProps = {
|
@@ -19,11 +22,36 @@ declare type ErrorWrapper<TError> = TError | {
|
|
19
22
|
payload: string;
|
20
23
|
};
|
21
24
|
|
25
|
+
interface CacheImpl {
|
26
|
+
defaultQueryTTL: number;
|
27
|
+
getAll(): Promise<Record<string, unknown>>;
|
28
|
+
get: <T>(key: string) => Promise<T | null>;
|
29
|
+
set: <T>(key: string, value: T) => Promise<void>;
|
30
|
+
delete: (key: string) => Promise<void>;
|
31
|
+
clear: () => Promise<void>;
|
32
|
+
}
|
33
|
+
interface SimpleCacheOptions {
|
34
|
+
max?: number;
|
35
|
+
defaultQueryTTL?: number;
|
36
|
+
}
|
37
|
+
declare class SimpleCache implements CacheImpl {
|
38
|
+
#private;
|
39
|
+
capacity: number;
|
40
|
+
defaultQueryTTL: number;
|
41
|
+
constructor(options?: SimpleCacheOptions);
|
42
|
+
getAll(): Promise<Record<string, unknown>>;
|
43
|
+
get<T>(key: string): Promise<T | null>;
|
44
|
+
set<T>(key: string, value: T): Promise<void>;
|
45
|
+
delete(key: string): Promise<void>;
|
46
|
+
clear(): Promise<void>;
|
47
|
+
}
|
48
|
+
|
22
49
|
declare abstract class XataPlugin {
|
23
50
|
abstract build(options: XataPluginOptions): unknown | Promise<unknown>;
|
24
51
|
}
|
25
52
|
declare type XataPluginOptions = {
|
26
53
|
getFetchProps: () => Promise<FetcherExtraProps>;
|
54
|
+
cache: CacheImpl;
|
27
55
|
};
|
28
56
|
|
29
57
|
/**
|
@@ -94,22 +122,32 @@ declare type WorkspaceMembers = {
|
|
94
122
|
* @pattern ^ik_[a-zA-Z0-9]+
|
95
123
|
*/
|
96
124
|
declare type InviteKey = string;
|
125
|
+
/**
|
126
|
+
* Metadata of databases
|
127
|
+
*/
|
128
|
+
declare type DatabaseMetadata = {
|
129
|
+
name: string;
|
130
|
+
displayName: string;
|
131
|
+
createdAt: DateTime;
|
132
|
+
numberOfBranches: number;
|
133
|
+
ui?: {
|
134
|
+
color?: string;
|
135
|
+
};
|
136
|
+
};
|
97
137
|
declare type ListDatabasesResponse = {
|
98
|
-
databases?:
|
99
|
-
name: string;
|
100
|
-
displayName: string;
|
101
|
-
createdAt: DateTime;
|
102
|
-
numberOfBranches: number;
|
103
|
-
ui?: {
|
104
|
-
color?: string;
|
105
|
-
};
|
106
|
-
}[];
|
138
|
+
databases?: DatabaseMetadata[];
|
107
139
|
};
|
108
140
|
declare type ListBranchesResponse = {
|
109
141
|
databaseName: string;
|
110
142
|
displayName: string;
|
111
143
|
branches: Branch[];
|
112
144
|
};
|
145
|
+
declare type ListGitBranchesResponse = {
|
146
|
+
mapping: {
|
147
|
+
gitBranch: string;
|
148
|
+
xataBranch: string;
|
149
|
+
}[];
|
150
|
+
};
|
113
151
|
declare type Branch = {
|
114
152
|
name: string;
|
115
153
|
createdAt: DateTime;
|
@@ -158,7 +196,7 @@ declare type Table = {
|
|
158
196
|
*/
|
159
197
|
declare type Column = {
|
160
198
|
name: string;
|
161
|
-
type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object';
|
199
|
+
type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object' | 'datetime';
|
162
200
|
link?: {
|
163
201
|
table: string;
|
164
202
|
};
|
@@ -234,6 +272,21 @@ declare type SortExpression = string[] | {
|
|
234
272
|
[key: string]: SortOrder;
|
235
273
|
}[];
|
236
274
|
declare type SortOrder = 'asc' | 'desc';
|
275
|
+
/**
|
276
|
+
* Maximum [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) for the search terms. The Levenshtein
|
277
|
+
* distance is the number of one charcter changes needed to make two strings equal. The default is 1, meaning that single
|
278
|
+
* character typos per word are tollerated by search. You can set it to 0 to remove the typo tollerance or set it to 2
|
279
|
+
* to allow two typos in a word.
|
280
|
+
*
|
281
|
+
* @default 1
|
282
|
+
* @maximum 2
|
283
|
+
* @minimum 0
|
284
|
+
*/
|
285
|
+
declare type FuzzinessExpression = number;
|
286
|
+
/**
|
287
|
+
* 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.
|
288
|
+
*/
|
289
|
+
declare type PrefixExpression = 'phrase' | 'disabled';
|
237
290
|
/**
|
238
291
|
* @minProperties 1
|
239
292
|
*/
|
@@ -247,6 +300,48 @@ declare type FilterExpression = {
|
|
247
300
|
} & {
|
248
301
|
[key: string]: FilterColumn;
|
249
302
|
};
|
303
|
+
declare type HighlightExpression = {
|
304
|
+
enabled?: boolean;
|
305
|
+
encodeHTML?: boolean;
|
306
|
+
};
|
307
|
+
/**
|
308
|
+
* Booster Expression
|
309
|
+
*
|
310
|
+
* @x-go-type xata.BoosterExpression
|
311
|
+
*/
|
312
|
+
declare type BoosterExpression = {
|
313
|
+
valueBooster?: ValueBooster$1;
|
314
|
+
} | {
|
315
|
+
numericBooster?: NumericBooster$1;
|
316
|
+
} | {
|
317
|
+
dateBooster?: DateBooster$1;
|
318
|
+
};
|
319
|
+
/**
|
320
|
+
* Boost records with a particular value for a column.
|
321
|
+
*/
|
322
|
+
declare type ValueBooster$1 = {
|
323
|
+
column: string;
|
324
|
+
value: string | number | boolean;
|
325
|
+
factor: number;
|
326
|
+
};
|
327
|
+
/**
|
328
|
+
* Boost records based on the value of a numeric column.
|
329
|
+
*/
|
330
|
+
declare type NumericBooster$1 = {
|
331
|
+
column: string;
|
332
|
+
factor: number;
|
333
|
+
};
|
334
|
+
/**
|
335
|
+
* Boost records based on the value of a datetime column. It is configured via "origin", "scale", and "decay". The further away from the "origin",
|
336
|
+
* 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
|
337
|
+
* 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.
|
338
|
+
*/
|
339
|
+
declare type DateBooster$1 = {
|
340
|
+
column: string;
|
341
|
+
origin?: string;
|
342
|
+
scale: string;
|
343
|
+
decay: number;
|
344
|
+
};
|
250
345
|
declare type FilterList = FilterExpression | FilterExpression[];
|
251
346
|
declare type FilterColumn = FilterColumnIncludes | FilterPredicate | FilterList;
|
252
347
|
/**
|
@@ -303,7 +398,24 @@ declare type PageConfig = {
|
|
303
398
|
size?: number;
|
304
399
|
offset?: number;
|
305
400
|
};
|
306
|
-
declare type
|
401
|
+
declare type ColumnsProjection = string[];
|
402
|
+
/**
|
403
|
+
* Xata Table Record Metadata
|
404
|
+
*/
|
405
|
+
declare type RecordMeta = {
|
406
|
+
id: RecordID;
|
407
|
+
xata: {
|
408
|
+
version: number;
|
409
|
+
table?: string;
|
410
|
+
highlight?: {
|
411
|
+
[key: string]: string[] | {
|
412
|
+
[key: string]: any;
|
413
|
+
};
|
414
|
+
};
|
415
|
+
score?: number;
|
416
|
+
warnings?: string[];
|
417
|
+
};
|
418
|
+
};
|
307
419
|
/**
|
308
420
|
* @pattern [a-zA-Z0-9_-~:]+
|
309
421
|
*/
|
@@ -325,16 +437,9 @@ declare type RecordsMetadata = {
|
|
325
437
|
};
|
326
438
|
};
|
327
439
|
/**
|
328
|
-
* Xata Table Record
|
440
|
+
* Xata Table Record Metadata
|
329
441
|
*/
|
330
|
-
declare type XataRecord$1 = {
|
331
|
-
id: RecordID;
|
332
|
-
xata: {
|
333
|
-
version: number;
|
334
|
-
table?: string;
|
335
|
-
warnings?: string[];
|
336
|
-
};
|
337
|
-
} & {
|
442
|
+
declare type XataRecord$1 = RecordMeta & {
|
338
443
|
[key: string]: any;
|
339
444
|
};
|
340
445
|
|
@@ -352,8 +457,10 @@ type schemas_InviteID = InviteID;
|
|
352
457
|
type schemas_WorkspaceInvite = WorkspaceInvite;
|
353
458
|
type schemas_WorkspaceMembers = WorkspaceMembers;
|
354
459
|
type schemas_InviteKey = InviteKey;
|
460
|
+
type schemas_DatabaseMetadata = DatabaseMetadata;
|
355
461
|
type schemas_ListDatabasesResponse = ListDatabasesResponse;
|
356
462
|
type schemas_ListBranchesResponse = ListBranchesResponse;
|
463
|
+
type schemas_ListGitBranchesResponse = ListGitBranchesResponse;
|
357
464
|
type schemas_Branch = Branch;
|
358
465
|
type schemas_BranchMetadata = BranchMetadata;
|
359
466
|
type schemas_DBBranch = DBBranch;
|
@@ -374,7 +481,11 @@ type schemas_TableMigration = TableMigration;
|
|
374
481
|
type schemas_ColumnMigration = ColumnMigration;
|
375
482
|
type schemas_SortExpression = SortExpression;
|
376
483
|
type schemas_SortOrder = SortOrder;
|
484
|
+
type schemas_FuzzinessExpression = FuzzinessExpression;
|
485
|
+
type schemas_PrefixExpression = PrefixExpression;
|
377
486
|
type schemas_FilterExpression = FilterExpression;
|
487
|
+
type schemas_HighlightExpression = HighlightExpression;
|
488
|
+
type schemas_BoosterExpression = BoosterExpression;
|
378
489
|
type schemas_FilterList = FilterList;
|
379
490
|
type schemas_FilterColumn = FilterColumn;
|
380
491
|
type schemas_FilterColumnIncludes = FilterColumnIncludes;
|
@@ -384,7 +495,8 @@ type schemas_FilterPredicateRangeOp = FilterPredicateRangeOp;
|
|
384
495
|
type schemas_FilterRangeValue = FilterRangeValue;
|
385
496
|
type schemas_FilterValue = FilterValue;
|
386
497
|
type schemas_PageConfig = PageConfig;
|
387
|
-
type
|
498
|
+
type schemas_ColumnsProjection = ColumnsProjection;
|
499
|
+
type schemas_RecordMeta = RecordMeta;
|
388
500
|
type schemas_RecordID = RecordID;
|
389
501
|
type schemas_TableRename = TableRename;
|
390
502
|
type schemas_RecordsMetadata = RecordsMetadata;
|
@@ -404,8 +516,10 @@ declare namespace schemas {
|
|
404
516
|
schemas_WorkspaceInvite as WorkspaceInvite,
|
405
517
|
schemas_WorkspaceMembers as WorkspaceMembers,
|
406
518
|
schemas_InviteKey as InviteKey,
|
519
|
+
schemas_DatabaseMetadata as DatabaseMetadata,
|
407
520
|
schemas_ListDatabasesResponse as ListDatabasesResponse,
|
408
521
|
schemas_ListBranchesResponse as ListBranchesResponse,
|
522
|
+
schemas_ListGitBranchesResponse as ListGitBranchesResponse,
|
409
523
|
schemas_Branch as Branch,
|
410
524
|
schemas_BranchMetadata as BranchMetadata,
|
411
525
|
schemas_DBBranch as DBBranch,
|
@@ -426,7 +540,14 @@ declare namespace schemas {
|
|
426
540
|
schemas_ColumnMigration as ColumnMigration,
|
427
541
|
schemas_SortExpression as SortExpression,
|
428
542
|
schemas_SortOrder as SortOrder,
|
543
|
+
schemas_FuzzinessExpression as FuzzinessExpression,
|
544
|
+
schemas_PrefixExpression as PrefixExpression,
|
429
545
|
schemas_FilterExpression as FilterExpression,
|
546
|
+
schemas_HighlightExpression as HighlightExpression,
|
547
|
+
schemas_BoosterExpression as BoosterExpression,
|
548
|
+
ValueBooster$1 as ValueBooster,
|
549
|
+
NumericBooster$1 as NumericBooster,
|
550
|
+
DateBooster$1 as DateBooster,
|
430
551
|
schemas_FilterList as FilterList,
|
431
552
|
schemas_FilterColumn as FilterColumn,
|
432
553
|
schemas_FilterColumnIncludes as FilterColumnIncludes,
|
@@ -436,7 +557,8 @@ declare namespace schemas {
|
|
436
557
|
schemas_FilterRangeValue as FilterRangeValue,
|
437
558
|
schemas_FilterValue as FilterValue,
|
438
559
|
schemas_PageConfig as PageConfig,
|
439
|
-
|
560
|
+
schemas_ColumnsProjection as ColumnsProjection,
|
561
|
+
schemas_RecordMeta as RecordMeta,
|
440
562
|
schemas_RecordID as RecordID,
|
441
563
|
schemas_TableRename as TableRename,
|
442
564
|
schemas_RecordsMetadata as RecordsMetadata,
|
@@ -471,11 +593,17 @@ declare type BulkError = {
|
|
471
593
|
status?: number;
|
472
594
|
}[];
|
473
595
|
};
|
596
|
+
declare type BulkInsertResponse = {
|
597
|
+
recordIDs: string[];
|
598
|
+
} | {
|
599
|
+
records: XataRecord$1[];
|
600
|
+
};
|
474
601
|
declare type BranchMigrationPlan = {
|
475
602
|
version: number;
|
476
603
|
migration: BranchMigration;
|
477
604
|
};
|
478
|
-
declare type
|
605
|
+
declare type RecordResponse = XataRecord$1;
|
606
|
+
declare type RecordUpdateResponse = XataRecord$1 | {
|
479
607
|
id: string;
|
480
608
|
xata: {
|
481
609
|
version: number;
|
@@ -499,7 +627,9 @@ type responses_SimpleError = SimpleError;
|
|
499
627
|
type responses_BadRequestError = BadRequestError;
|
500
628
|
type responses_AuthError = AuthError;
|
501
629
|
type responses_BulkError = BulkError;
|
630
|
+
type responses_BulkInsertResponse = BulkInsertResponse;
|
502
631
|
type responses_BranchMigrationPlan = BranchMigrationPlan;
|
632
|
+
type responses_RecordResponse = RecordResponse;
|
503
633
|
type responses_RecordUpdateResponse = RecordUpdateResponse;
|
504
634
|
type responses_QueryResponse = QueryResponse;
|
505
635
|
type responses_SearchResponse = SearchResponse;
|
@@ -510,7 +640,9 @@ declare namespace responses {
|
|
510
640
|
responses_BadRequestError as BadRequestError,
|
511
641
|
responses_AuthError as AuthError,
|
512
642
|
responses_BulkError as BulkError,
|
643
|
+
responses_BulkInsertResponse as BulkInsertResponse,
|
513
644
|
responses_BranchMigrationPlan as BranchMigrationPlan,
|
645
|
+
responses_RecordResponse as RecordResponse,
|
514
646
|
responses_RecordUpdateResponse as RecordUpdateResponse,
|
515
647
|
responses_QueryResponse as QueryResponse,
|
516
648
|
responses_SearchResponse as SearchResponse,
|
@@ -816,6 +948,9 @@ declare type InviteWorkspaceMemberError = ErrorWrapper<{
|
|
816
948
|
} | {
|
817
949
|
status: 404;
|
818
950
|
payload: SimpleError;
|
951
|
+
} | {
|
952
|
+
status: 409;
|
953
|
+
payload: SimpleError;
|
819
954
|
}>;
|
820
955
|
declare type InviteWorkspaceMemberRequestBody = {
|
821
956
|
email: string;
|
@@ -829,6 +964,34 @@ declare type InviteWorkspaceMemberVariables = {
|
|
829
964
|
* Invite some user to join the workspace with the given role
|
830
965
|
*/
|
831
966
|
declare const inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<WorkspaceInvite>;
|
967
|
+
declare type UpdateWorkspaceMemberInvitePathParams = {
|
968
|
+
workspaceId: WorkspaceID;
|
969
|
+
inviteId: InviteID;
|
970
|
+
};
|
971
|
+
declare type UpdateWorkspaceMemberInviteError = ErrorWrapper<{
|
972
|
+
status: 400;
|
973
|
+
payload: BadRequestError;
|
974
|
+
} | {
|
975
|
+
status: 401;
|
976
|
+
payload: AuthError;
|
977
|
+
} | {
|
978
|
+
status: 404;
|
979
|
+
payload: SimpleError;
|
980
|
+
} | {
|
981
|
+
status: 422;
|
982
|
+
payload: SimpleError;
|
983
|
+
}>;
|
984
|
+
declare type UpdateWorkspaceMemberInviteRequestBody = {
|
985
|
+
role: Role;
|
986
|
+
};
|
987
|
+
declare type UpdateWorkspaceMemberInviteVariables = {
|
988
|
+
body: UpdateWorkspaceMemberInviteRequestBody;
|
989
|
+
pathParams: UpdateWorkspaceMemberInvitePathParams;
|
990
|
+
} & FetcherExtraProps;
|
991
|
+
/**
|
992
|
+
* 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.
|
993
|
+
*/
|
994
|
+
declare const updateWorkspaceMemberInvite: (variables: UpdateWorkspaceMemberInviteVariables) => Promise<WorkspaceInvite>;
|
832
995
|
declare type CancelWorkspaceMemberInvitePathParams = {
|
833
996
|
workspaceId: WorkspaceID;
|
834
997
|
inviteId: InviteID;
|
@@ -982,6 +1145,184 @@ declare type DeleteDatabaseVariables = {
|
|
982
1145
|
* Delete a database and all of its branches and tables permanently.
|
983
1146
|
*/
|
984
1147
|
declare const deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
|
1148
|
+
declare type GetDatabaseMetadataPathParams = {
|
1149
|
+
dbName: DBName;
|
1150
|
+
workspace: string;
|
1151
|
+
};
|
1152
|
+
declare type GetDatabaseMetadataError = ErrorWrapper<{
|
1153
|
+
status: 400;
|
1154
|
+
payload: BadRequestError;
|
1155
|
+
} | {
|
1156
|
+
status: 401;
|
1157
|
+
payload: AuthError;
|
1158
|
+
} | {
|
1159
|
+
status: 404;
|
1160
|
+
payload: SimpleError;
|
1161
|
+
}>;
|
1162
|
+
declare type GetDatabaseMetadataVariables = {
|
1163
|
+
pathParams: GetDatabaseMetadataPathParams;
|
1164
|
+
} & FetcherExtraProps;
|
1165
|
+
/**
|
1166
|
+
* Retrieve metadata of the given database
|
1167
|
+
*/
|
1168
|
+
declare const getDatabaseMetadata: (variables: GetDatabaseMetadataVariables) => Promise<DatabaseMetadata>;
|
1169
|
+
declare type GetGitBranchesMappingPathParams = {
|
1170
|
+
dbName: DBName;
|
1171
|
+
workspace: string;
|
1172
|
+
};
|
1173
|
+
declare type GetGitBranchesMappingError = ErrorWrapper<{
|
1174
|
+
status: 400;
|
1175
|
+
payload: BadRequestError;
|
1176
|
+
} | {
|
1177
|
+
status: 401;
|
1178
|
+
payload: AuthError;
|
1179
|
+
}>;
|
1180
|
+
declare type GetGitBranchesMappingVariables = {
|
1181
|
+
pathParams: GetGitBranchesMappingPathParams;
|
1182
|
+
} & FetcherExtraProps;
|
1183
|
+
/**
|
1184
|
+
* Lists all the git branches in the mapping, and their associated Xata branches.
|
1185
|
+
*
|
1186
|
+
* Example response:
|
1187
|
+
*
|
1188
|
+
* ```json
|
1189
|
+
* {
|
1190
|
+
* "mappings": [
|
1191
|
+
* {
|
1192
|
+
* "gitBranch": "main",
|
1193
|
+
* "xataBranch": "main"
|
1194
|
+
* },
|
1195
|
+
* {
|
1196
|
+
* "gitBranch": "gitBranch1",
|
1197
|
+
* "xataBranch": "xataBranch1"
|
1198
|
+
* }
|
1199
|
+
* {
|
1200
|
+
* "gitBranch": "xataBranch2",
|
1201
|
+
* "xataBranch": "xataBranch2"
|
1202
|
+
* }
|
1203
|
+
* ]
|
1204
|
+
* }
|
1205
|
+
* ```
|
1206
|
+
*/
|
1207
|
+
declare const getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
|
1208
|
+
declare type AddGitBranchesEntryPathParams = {
|
1209
|
+
dbName: DBName;
|
1210
|
+
workspace: string;
|
1211
|
+
};
|
1212
|
+
declare type AddGitBranchesEntryError = ErrorWrapper<{
|
1213
|
+
status: 400;
|
1214
|
+
payload: BadRequestError;
|
1215
|
+
} | {
|
1216
|
+
status: 401;
|
1217
|
+
payload: AuthError;
|
1218
|
+
}>;
|
1219
|
+
declare type AddGitBranchesEntryResponse = {
|
1220
|
+
warning?: string;
|
1221
|
+
};
|
1222
|
+
declare type AddGitBranchesEntryRequestBody = {
|
1223
|
+
gitBranch: string;
|
1224
|
+
xataBranch: BranchName;
|
1225
|
+
};
|
1226
|
+
declare type AddGitBranchesEntryVariables = {
|
1227
|
+
body: AddGitBranchesEntryRequestBody;
|
1228
|
+
pathParams: AddGitBranchesEntryPathParams;
|
1229
|
+
} & FetcherExtraProps;
|
1230
|
+
/**
|
1231
|
+
* Adds an entry to the mapping of git branches to Xata branches. The git branch and the Xata branch must be present in the body of the request. If the Xata branch doesn't exist, a 400 error is returned.
|
1232
|
+
*
|
1233
|
+
* If the git branch is already present in the mapping, the old entry is overwritten, and a warning message is included in the response. If the git branch is added and didn't exist before, the response code is 204. If the git branch existed and it was overwritten, the response code is 201.
|
1234
|
+
*
|
1235
|
+
* Example request:
|
1236
|
+
*
|
1237
|
+
* ```json
|
1238
|
+
* // POST https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches
|
1239
|
+
* {
|
1240
|
+
* "gitBranch": "fix/bug123",
|
1241
|
+
* "xataBranch": "fix_bug"
|
1242
|
+
* }
|
1243
|
+
* ```
|
1244
|
+
*/
|
1245
|
+
declare const addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
|
1246
|
+
declare type RemoveGitBranchesEntryPathParams = {
|
1247
|
+
dbName: DBName;
|
1248
|
+
workspace: string;
|
1249
|
+
};
|
1250
|
+
declare type RemoveGitBranchesEntryQueryParams = {
|
1251
|
+
gitBranch: string;
|
1252
|
+
};
|
1253
|
+
declare type RemoveGitBranchesEntryError = ErrorWrapper<{
|
1254
|
+
status: 400;
|
1255
|
+
payload: BadRequestError;
|
1256
|
+
} | {
|
1257
|
+
status: 401;
|
1258
|
+
payload: AuthError;
|
1259
|
+
}>;
|
1260
|
+
declare type RemoveGitBranchesEntryVariables = {
|
1261
|
+
pathParams: RemoveGitBranchesEntryPathParams;
|
1262
|
+
queryParams: RemoveGitBranchesEntryQueryParams;
|
1263
|
+
} & FetcherExtraProps;
|
1264
|
+
/**
|
1265
|
+
* Removes an entry from the mapping of git branches to Xata branches. The name of the git branch must be passed as a query parameter. If the git branch is not found, the endpoint returns a 404 status code.
|
1266
|
+
*
|
1267
|
+
* Example request:
|
1268
|
+
*
|
1269
|
+
* ```json
|
1270
|
+
* // DELETE https://tutorial-ng7s8c.xata.sh/dbs/demo/gitBranches?gitBranch=fix%2Fbug123
|
1271
|
+
* ```
|
1272
|
+
*/
|
1273
|
+
declare const removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
|
1274
|
+
declare type ResolveBranchPathParams = {
|
1275
|
+
dbName: DBName;
|
1276
|
+
workspace: string;
|
1277
|
+
};
|
1278
|
+
declare type ResolveBranchQueryParams = {
|
1279
|
+
gitBranch?: string;
|
1280
|
+
fallbackBranch?: string;
|
1281
|
+
};
|
1282
|
+
declare type ResolveBranchError = ErrorWrapper<{
|
1283
|
+
status: 400;
|
1284
|
+
payload: BadRequestError;
|
1285
|
+
} | {
|
1286
|
+
status: 401;
|
1287
|
+
payload: AuthError;
|
1288
|
+
}>;
|
1289
|
+
declare type ResolveBranchResponse = {
|
1290
|
+
branch: string;
|
1291
|
+
reason: {
|
1292
|
+
code: 'FOUND_IN_MAPPING' | 'BRANCH_EXISTS' | 'FALLBACK_BRANCH' | 'DEFAULT_BRANCH';
|
1293
|
+
message: string;
|
1294
|
+
};
|
1295
|
+
};
|
1296
|
+
declare type ResolveBranchVariables = {
|
1297
|
+
pathParams: ResolveBranchPathParams;
|
1298
|
+
queryParams?: ResolveBranchQueryParams;
|
1299
|
+
} & FetcherExtraProps;
|
1300
|
+
/**
|
1301
|
+
* In order to resolve the database branch, the following algorithm is used:
|
1302
|
+
* * 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
|
1303
|
+
* * else, if a Xata branch with the exact same name as `gitBranch` exists, return it
|
1304
|
+
* * else, if `fallbackBranch` is provided and a branch with that name exists, return it
|
1305
|
+
* * else, return the default branch of the DB (`main` or the first branch)
|
1306
|
+
*
|
1307
|
+
* Example call:
|
1308
|
+
*
|
1309
|
+
* ```json
|
1310
|
+
* // GET https://tutorial-ng7s8c.xata.sh/dbs/demo/dbs/demo/resolveBranch?gitBranch=test&fallbackBranch=tsg
|
1311
|
+
* ```
|
1312
|
+
*
|
1313
|
+
* Example response:
|
1314
|
+
*
|
1315
|
+
* ```json
|
1316
|
+
* {
|
1317
|
+
* "branch": "main",
|
1318
|
+
* "reason": {
|
1319
|
+
* "code": "DEFAULT_BRANCH",
|
1320
|
+
* "message": "Default branch for this database (main)"
|
1321
|
+
* }
|
1322
|
+
* }
|
1323
|
+
* ```
|
1324
|
+
*/
|
1325
|
+
declare const resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
|
985
1326
|
declare type GetBranchDetailsPathParams = {
|
986
1327
|
dbBranchName: DBBranchName;
|
987
1328
|
workspace: string;
|
@@ -1017,6 +1358,10 @@ declare type CreateBranchError = ErrorWrapper<{
|
|
1017
1358
|
status: 404;
|
1018
1359
|
payload: SimpleError;
|
1019
1360
|
}>;
|
1361
|
+
declare type CreateBranchResponse = {
|
1362
|
+
databaseName: string;
|
1363
|
+
branchName: string;
|
1364
|
+
};
|
1020
1365
|
declare type CreateBranchRequestBody = {
|
1021
1366
|
from?: string;
|
1022
1367
|
metadata?: BranchMetadata;
|
@@ -1026,7 +1371,7 @@ declare type CreateBranchVariables = {
|
|
1026
1371
|
pathParams: CreateBranchPathParams;
|
1027
1372
|
queryParams?: CreateBranchQueryParams;
|
1028
1373
|
} & FetcherExtraProps;
|
1029
|
-
declare const createBranch: (variables: CreateBranchVariables) => Promise<
|
1374
|
+
declare const createBranch: (variables: CreateBranchVariables) => Promise<CreateBranchResponse>;
|
1030
1375
|
declare type DeleteBranchPathParams = {
|
1031
1376
|
dbBranchName: DBBranchName;
|
1032
1377
|
workspace: string;
|
@@ -1213,13 +1558,17 @@ declare type CreateTableError = ErrorWrapper<{
|
|
1213
1558
|
status: 422;
|
1214
1559
|
payload: SimpleError;
|
1215
1560
|
}>;
|
1561
|
+
declare type CreateTableResponse = {
|
1562
|
+
branchName: string;
|
1563
|
+
tableName: string;
|
1564
|
+
};
|
1216
1565
|
declare type CreateTableVariables = {
|
1217
1566
|
pathParams: CreateTablePathParams;
|
1218
1567
|
} & FetcherExtraProps;
|
1219
1568
|
/**
|
1220
1569
|
* Creates a new table with the given name. Returns 422 if a table with the same name already exists.
|
1221
1570
|
*/
|
1222
|
-
declare const createTable: (variables: CreateTableVariables) => Promise<
|
1571
|
+
declare const createTable: (variables: CreateTableVariables) => Promise<CreateTableResponse>;
|
1223
1572
|
declare type DeleteTablePathParams = {
|
1224
1573
|
dbBranchName: DBBranchName;
|
1225
1574
|
tableName: TableName;
|
@@ -1266,8 +1615,9 @@ declare type UpdateTableVariables = {
|
|
1266
1615
|
*
|
1267
1616
|
* In the example below, we rename a table from “users” to “people”:
|
1268
1617
|
*
|
1269
|
-
* ```
|
1270
|
-
* PATCH /db/test:main/tables/users
|
1618
|
+
* ```json
|
1619
|
+
* // PATCH /db/test:main/tables/users
|
1620
|
+
*
|
1271
1621
|
* {
|
1272
1622
|
* "name": "people"
|
1273
1623
|
* }
|
@@ -1451,6 +1801,9 @@ declare type InsertRecordPathParams = {
|
|
1451
1801
|
tableName: TableName;
|
1452
1802
|
workspace: string;
|
1453
1803
|
};
|
1804
|
+
declare type InsertRecordQueryParams = {
|
1805
|
+
columns?: ColumnsProjection;
|
1806
|
+
};
|
1454
1807
|
declare type InsertRecordError = ErrorWrapper<{
|
1455
1808
|
status: 400;
|
1456
1809
|
payload: BadRequestError;
|
@@ -1461,20 +1814,15 @@ declare type InsertRecordError = ErrorWrapper<{
|
|
1461
1814
|
status: 404;
|
1462
1815
|
payload: SimpleError;
|
1463
1816
|
}>;
|
1464
|
-
declare type InsertRecordResponse = {
|
1465
|
-
id: string;
|
1466
|
-
xata: {
|
1467
|
-
version: number;
|
1468
|
-
};
|
1469
|
-
};
|
1470
1817
|
declare type InsertRecordVariables = {
|
1471
1818
|
body?: Record<string, any>;
|
1472
1819
|
pathParams: InsertRecordPathParams;
|
1820
|
+
queryParams?: InsertRecordQueryParams;
|
1473
1821
|
} & FetcherExtraProps;
|
1474
1822
|
/**
|
1475
1823
|
* Insert a new Record into the Table
|
1476
1824
|
*/
|
1477
|
-
declare const insertRecord: (variables: InsertRecordVariables) => Promise<
|
1825
|
+
declare const insertRecord: (variables: InsertRecordVariables) => Promise<RecordUpdateResponse>;
|
1478
1826
|
declare type InsertRecordWithIDPathParams = {
|
1479
1827
|
dbBranchName: DBBranchName;
|
1480
1828
|
tableName: TableName;
|
@@ -1482,6 +1830,7 @@ declare type InsertRecordWithIDPathParams = {
|
|
1482
1830
|
workspace: string;
|
1483
1831
|
};
|
1484
1832
|
declare type InsertRecordWithIDQueryParams = {
|
1833
|
+
columns?: ColumnsProjection;
|
1485
1834
|
createOnly?: boolean;
|
1486
1835
|
ifVersion?: number;
|
1487
1836
|
};
|
@@ -1514,6 +1863,7 @@ declare type UpdateRecordWithIDPathParams = {
|
|
1514
1863
|
workspace: string;
|
1515
1864
|
};
|
1516
1865
|
declare type UpdateRecordWithIDQueryParams = {
|
1866
|
+
columns?: ColumnsProjection;
|
1517
1867
|
ifVersion?: number;
|
1518
1868
|
};
|
1519
1869
|
declare type UpdateRecordWithIDError = ErrorWrapper<{
|
@@ -1542,6 +1892,7 @@ declare type UpsertRecordWithIDPathParams = {
|
|
1542
1892
|
workspace: string;
|
1543
1893
|
};
|
1544
1894
|
declare type UpsertRecordWithIDQueryParams = {
|
1895
|
+
columns?: ColumnsProjection;
|
1545
1896
|
ifVersion?: number;
|
1546
1897
|
};
|
1547
1898
|
declare type UpsertRecordWithIDError = ErrorWrapper<{
|
@@ -1569,6 +1920,9 @@ declare type DeleteRecordPathParams = {
|
|
1569
1920
|
recordId: RecordID;
|
1570
1921
|
workspace: string;
|
1571
1922
|
};
|
1923
|
+
declare type DeleteRecordQueryParams = {
|
1924
|
+
columns?: ColumnsProjection;
|
1925
|
+
};
|
1572
1926
|
declare type DeleteRecordError = ErrorWrapper<{
|
1573
1927
|
status: 400;
|
1574
1928
|
payload: BadRequestError;
|
@@ -1581,14 +1935,18 @@ declare type DeleteRecordError = ErrorWrapper<{
|
|
1581
1935
|
}>;
|
1582
1936
|
declare type DeleteRecordVariables = {
|
1583
1937
|
pathParams: DeleteRecordPathParams;
|
1938
|
+
queryParams?: DeleteRecordQueryParams;
|
1584
1939
|
} & FetcherExtraProps;
|
1585
|
-
declare const deleteRecord: (variables: DeleteRecordVariables) => Promise<
|
1940
|
+
declare const deleteRecord: (variables: DeleteRecordVariables) => Promise<XataRecord$1>;
|
1586
1941
|
declare type GetRecordPathParams = {
|
1587
1942
|
dbBranchName: DBBranchName;
|
1588
1943
|
tableName: TableName;
|
1589
1944
|
recordId: RecordID;
|
1590
1945
|
workspace: string;
|
1591
1946
|
};
|
1947
|
+
declare type GetRecordQueryParams = {
|
1948
|
+
columns?: ColumnsProjection;
|
1949
|
+
};
|
1592
1950
|
declare type GetRecordError = ErrorWrapper<{
|
1593
1951
|
status: 400;
|
1594
1952
|
payload: BadRequestError;
|
@@ -1599,12 +1957,9 @@ declare type GetRecordError = ErrorWrapper<{
|
|
1599
1957
|
status: 404;
|
1600
1958
|
payload: SimpleError;
|
1601
1959
|
}>;
|
1602
|
-
declare type GetRecordRequestBody = {
|
1603
|
-
columns?: ColumnsFilter;
|
1604
|
-
};
|
1605
1960
|
declare type GetRecordVariables = {
|
1606
|
-
body?: GetRecordRequestBody;
|
1607
1961
|
pathParams: GetRecordPathParams;
|
1962
|
+
queryParams?: GetRecordQueryParams;
|
1608
1963
|
} & FetcherExtraProps;
|
1609
1964
|
/**
|
1610
1965
|
* Retrieve record by ID
|
@@ -1615,6 +1970,9 @@ declare type BulkInsertTableRecordsPathParams = {
|
|
1615
1970
|
tableName: TableName;
|
1616
1971
|
workspace: string;
|
1617
1972
|
};
|
1973
|
+
declare type BulkInsertTableRecordsQueryParams = {
|
1974
|
+
columns?: ColumnsProjection;
|
1975
|
+
};
|
1618
1976
|
declare type BulkInsertTableRecordsError = ErrorWrapper<{
|
1619
1977
|
status: 400;
|
1620
1978
|
payload: BulkError;
|
@@ -1624,21 +1982,22 @@ declare type BulkInsertTableRecordsError = ErrorWrapper<{
|
|
1624
1982
|
} | {
|
1625
1983
|
status: 404;
|
1626
1984
|
payload: SimpleError;
|
1985
|
+
} | {
|
1986
|
+
status: 422;
|
1987
|
+
payload: SimpleError;
|
1627
1988
|
}>;
|
1628
|
-
declare type BulkInsertTableRecordsResponse = {
|
1629
|
-
recordIDs: string[];
|
1630
|
-
};
|
1631
1989
|
declare type BulkInsertTableRecordsRequestBody = {
|
1632
1990
|
records: Record<string, any>[];
|
1633
1991
|
};
|
1634
1992
|
declare type BulkInsertTableRecordsVariables = {
|
1635
1993
|
body: BulkInsertTableRecordsRequestBody;
|
1636
1994
|
pathParams: BulkInsertTableRecordsPathParams;
|
1995
|
+
queryParams?: BulkInsertTableRecordsQueryParams;
|
1637
1996
|
} & FetcherExtraProps;
|
1638
1997
|
/**
|
1639
1998
|
* Bulk insert records
|
1640
1999
|
*/
|
1641
|
-
declare const bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<
|
2000
|
+
declare const bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertResponse>;
|
1642
2001
|
declare type QueryTablePathParams = {
|
1643
2002
|
dbBranchName: DBBranchName;
|
1644
2003
|
tableName: TableName;
|
@@ -1658,7 +2017,7 @@ declare type QueryTableRequestBody = {
|
|
1658
2017
|
filter?: FilterExpression;
|
1659
2018
|
sort?: SortExpression;
|
1660
2019
|
page?: PageConfig;
|
1661
|
-
columns?:
|
2020
|
+
columns?: ColumnsProjection;
|
1662
2021
|
};
|
1663
2022
|
declare type QueryTableVariables = {
|
1664
2023
|
body?: QueryTableRequestBody;
|
@@ -1675,7 +2034,7 @@ declare type QueryTableVariables = {
|
|
1675
2034
|
* {
|
1676
2035
|
* "columns": [...],
|
1677
2036
|
* "filter": {
|
1678
|
-
* "$all": [...]
|
2037
|
+
* "$all": [...],
|
1679
2038
|
* "$any": [...]
|
1680
2039
|
* ...
|
1681
2040
|
* },
|
@@ -1721,7 +2080,11 @@ declare type QueryTableVariables = {
|
|
1721
2080
|
* "link": {
|
1722
2081
|
* "table": "users"
|
1723
2082
|
* }
|
1724
|
-
* }
|
2083
|
+
* },
|
2084
|
+
* {
|
2085
|
+
* "name": "foundedDate",
|
2086
|
+
* "type": "datetime"
|
2087
|
+
* },
|
1725
2088
|
* ]
|
1726
2089
|
* },
|
1727
2090
|
* {
|
@@ -1809,7 +2172,7 @@ declare type QueryTableVariables = {
|
|
1809
2172
|
* {
|
1810
2173
|
* "name": "Kilian",
|
1811
2174
|
* "address": {
|
1812
|
-
* "street": "New street"
|
2175
|
+
* "street": "New street"
|
1813
2176
|
* }
|
1814
2177
|
* }
|
1815
2178
|
* ```
|
@@ -1818,10 +2181,7 @@ declare type QueryTableVariables = {
|
|
1818
2181
|
*
|
1819
2182
|
* ```json
|
1820
2183
|
* {
|
1821
|
-
* "columns": [
|
1822
|
-
* "*",
|
1823
|
-
* "team.name"
|
1824
|
-
* ]
|
2184
|
+
* "columns": ["*", "team.name"]
|
1825
2185
|
* }
|
1826
2186
|
* ```
|
1827
2187
|
*
|
@@ -1839,7 +2199,7 @@ declare type QueryTableVariables = {
|
|
1839
2199
|
* "team": {
|
1840
2200
|
* "id": "XX",
|
1841
2201
|
* "xata": {
|
1842
|
-
* "version": 0
|
2202
|
+
* "version": 0
|
1843
2203
|
* },
|
1844
2204
|
* "name": "first team"
|
1845
2205
|
* }
|
@@ -1850,10 +2210,7 @@ declare type QueryTableVariables = {
|
|
1850
2210
|
*
|
1851
2211
|
* ```json
|
1852
2212
|
* {
|
1853
|
-
* "columns": [
|
1854
|
-
* "*",
|
1855
|
-
* "team.*"
|
1856
|
-
* ]
|
2213
|
+
* "columns": ["*", "team.*"]
|
1857
2214
|
* }
|
1858
2215
|
* ```
|
1859
2216
|
*
|
@@ -1871,10 +2228,11 @@ declare type QueryTableVariables = {
|
|
1871
2228
|
* "team": {
|
1872
2229
|
* "id": "XX",
|
1873
2230
|
* "xata": {
|
1874
|
-
* "version": 0
|
2231
|
+
* "version": 0
|
1875
2232
|
* },
|
1876
2233
|
* "name": "first team",
|
1877
|
-
* "code": "A1"
|
2234
|
+
* "code": "A1",
|
2235
|
+
* "foundedDate": "2020-03-04T10:43:54.32Z"
|
1878
2236
|
* }
|
1879
2237
|
* }
|
1880
2238
|
* ```
|
@@ -1889,7 +2247,7 @@ declare type QueryTableVariables = {
|
|
1889
2247
|
* `$none`, etc.
|
1890
2248
|
*
|
1891
2249
|
* All operators start with an `$` to differentiate them from column names
|
1892
|
-
* (which are not allowed to start with
|
2250
|
+
* (which are not allowed to start with a dollar sign).
|
1893
2251
|
*
|
1894
2252
|
* #### Exact matching and control operators
|
1895
2253
|
*
|
@@ -1920,7 +2278,7 @@ declare type QueryTableVariables = {
|
|
1920
2278
|
* ```json
|
1921
2279
|
* {
|
1922
2280
|
* "filter": {
|
1923
|
-
*
|
2281
|
+
* "name": "r2"
|
1924
2282
|
* }
|
1925
2283
|
* }
|
1926
2284
|
* ```
|
@@ -1942,7 +2300,7 @@ declare type QueryTableVariables = {
|
|
1942
2300
|
* ```json
|
1943
2301
|
* {
|
1944
2302
|
* "filter": {
|
1945
|
-
*
|
2303
|
+
* "settings.plan": "free"
|
1946
2304
|
* }
|
1947
2305
|
* }
|
1948
2306
|
* ```
|
@@ -1952,8 +2310,8 @@ declare type QueryTableVariables = {
|
|
1952
2310
|
* "filter": {
|
1953
2311
|
* "settings": {
|
1954
2312
|
* "plan": "free"
|
1955
|
-
* }
|
1956
|
-
* }
|
2313
|
+
* }
|
2314
|
+
* }
|
1957
2315
|
* }
|
1958
2316
|
* ```
|
1959
2317
|
*
|
@@ -1962,8 +2320,8 @@ declare type QueryTableVariables = {
|
|
1962
2320
|
* ```json
|
1963
2321
|
* {
|
1964
2322
|
* "filter": {
|
1965
|
-
* "settings.plan": {"$any": ["free", "paid"]}
|
1966
|
-
* }
|
2323
|
+
* "settings.plan": { "$any": ["free", "paid"] }
|
2324
|
+
* }
|
1967
2325
|
* }
|
1968
2326
|
* ```
|
1969
2327
|
*
|
@@ -1972,9 +2330,9 @@ declare type QueryTableVariables = {
|
|
1972
2330
|
* ```json
|
1973
2331
|
* {
|
1974
2332
|
* "filter": {
|
1975
|
-
*
|
1976
|
-
*
|
1977
|
-
* }
|
2333
|
+
* "settings.dark": true,
|
2334
|
+
* "settings.plan": "free"
|
2335
|
+
* }
|
1978
2336
|
* }
|
1979
2337
|
* ```
|
1980
2338
|
*
|
@@ -1985,11 +2343,11 @@ declare type QueryTableVariables = {
|
|
1985
2343
|
* ```json
|
1986
2344
|
* {
|
1987
2345
|
* "filter": {
|
1988
|
-
*
|
1989
|
-
*
|
1990
|
-
*
|
1991
|
-
*
|
1992
|
-
* }
|
2346
|
+
* "$any": {
|
2347
|
+
* "settings.dark": true,
|
2348
|
+
* "settings.plan": "free"
|
2349
|
+
* }
|
2350
|
+
* }
|
1993
2351
|
* }
|
1994
2352
|
* ```
|
1995
2353
|
*
|
@@ -2000,10 +2358,10 @@ declare type QueryTableVariables = {
|
|
2000
2358
|
* "filter": {
|
2001
2359
|
* "$any": [
|
2002
2360
|
* {
|
2003
|
-
* "name": "r1"
|
2361
|
+
* "name": "r1"
|
2004
2362
|
* },
|
2005
2363
|
* {
|
2006
|
-
* "name": "r2"
|
2364
|
+
* "name": "r2"
|
2007
2365
|
* }
|
2008
2366
|
* ]
|
2009
2367
|
* }
|
@@ -2015,7 +2373,7 @@ declare type QueryTableVariables = {
|
|
2015
2373
|
* ```json
|
2016
2374
|
* {
|
2017
2375
|
* "filter": {
|
2018
|
-
* "$exists": "settings"
|
2376
|
+
* "$exists": "settings"
|
2019
2377
|
* }
|
2020
2378
|
* }
|
2021
2379
|
* ```
|
@@ -2027,10 +2385,10 @@ declare type QueryTableVariables = {
|
|
2027
2385
|
* "filter": {
|
2028
2386
|
* "$all": [
|
2029
2387
|
* {
|
2030
|
-
* "$exists": "settings"
|
2388
|
+
* "$exists": "settings"
|
2031
2389
|
* },
|
2032
2390
|
* {
|
2033
|
-
* "$exists": "name"
|
2391
|
+
* "$exists": "name"
|
2034
2392
|
* }
|
2035
2393
|
* ]
|
2036
2394
|
* }
|
@@ -2042,7 +2400,7 @@ declare type QueryTableVariables = {
|
|
2042
2400
|
* ```json
|
2043
2401
|
* {
|
2044
2402
|
* "filter": {
|
2045
|
-
* "$notExists": "settings"
|
2403
|
+
* "$notExists": "settings"
|
2046
2404
|
* }
|
2047
2405
|
* }
|
2048
2406
|
* ```
|
@@ -2069,43 +2427,59 @@ declare type QueryTableVariables = {
|
|
2069
2427
|
* {
|
2070
2428
|
* "filter": {
|
2071
2429
|
* "<column_name>": {
|
2072
|
-
*
|
2430
|
+
* "$pattern": "v*alu?"
|
2073
2431
|
* }
|
2074
2432
|
* }
|
2075
2433
|
* }
|
2076
2434
|
* ```
|
2077
2435
|
*
|
2436
|
+
* The `$pattern` operator accepts two wildcard characters:
|
2437
|
+
* * `*` matches zero or more characters
|
2438
|
+
* * `?` matches exactly one character
|
2439
|
+
*
|
2440
|
+
* 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.
|
2441
|
+
*
|
2078
2442
|
* We could also have `$endsWith` and `$startsWith` operators:
|
2079
2443
|
*
|
2080
2444
|
* ```json
|
2081
2445
|
* {
|
2082
2446
|
* "filter": {
|
2083
2447
|
* "<column_name>": {
|
2084
|
-
*
|
2448
|
+
* "$endsWith": ".gz"
|
2085
2449
|
* },
|
2086
2450
|
* "<column_name>": {
|
2087
|
-
*
|
2451
|
+
* "$startsWith": "tmp-"
|
2088
2452
|
* }
|
2089
2453
|
* }
|
2090
2454
|
* }
|
2091
2455
|
* ```
|
2092
2456
|
*
|
2093
|
-
* #### Numeric ranges
|
2457
|
+
* #### Numeric or datetime ranges
|
2094
2458
|
*
|
2095
2459
|
* ```json
|
2096
2460
|
* {
|
2097
2461
|
* "filter": {
|
2098
|
-
*
|
2099
|
-
*
|
2100
|
-
*
|
2101
|
-
*
|
2462
|
+
* "<column_name>": {
|
2463
|
+
* "$ge": 0,
|
2464
|
+
* "$lt": 100
|
2465
|
+
* }
|
2466
|
+
* }
|
2467
|
+
* }
|
2468
|
+
* ```
|
2469
|
+
* Date ranges support the same operators, with the date using the format defined in
|
2470
|
+
* [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339):
|
2471
|
+
* ```json
|
2472
|
+
* {
|
2473
|
+
* "filter": {
|
2474
|
+
* "<column_name>": {
|
2475
|
+
* "$gt": "2019-10-12T07:20:50.52Z",
|
2476
|
+
* "$lt": "2021-10-12T07:20:50.52Z"
|
2477
|
+
* }
|
2102
2478
|
* }
|
2103
2479
|
* }
|
2104
2480
|
* ```
|
2105
|
-
*
|
2106
2481
|
* The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
|
2107
2482
|
*
|
2108
|
-
*
|
2109
2483
|
* #### Negations
|
2110
2484
|
*
|
2111
2485
|
* A general `$not` operator can inverse any operation.
|
@@ -2130,22 +2504,28 @@ declare type QueryTableVariables = {
|
|
2130
2504
|
* {
|
2131
2505
|
* "filter": {
|
2132
2506
|
* "$not": {
|
2133
|
-
* "$any": [
|
2134
|
-
*
|
2135
|
-
*
|
2136
|
-
*
|
2137
|
-
*
|
2138
|
-
*
|
2139
|
-
*
|
2140
|
-
*
|
2141
|
-
*
|
2142
|
-
*
|
2143
|
-
*
|
2144
|
-
*
|
2145
|
-
*
|
2146
|
-
*
|
2147
|
-
*
|
2148
|
-
*
|
2507
|
+
* "$any": [
|
2508
|
+
* {
|
2509
|
+
* "<column_name1>": "value1"
|
2510
|
+
* },
|
2511
|
+
* {
|
2512
|
+
* "$all": [
|
2513
|
+
* {
|
2514
|
+
* "<column_name2>": "value2"
|
2515
|
+
* },
|
2516
|
+
* {
|
2517
|
+
* "<column_name3>": "value3"
|
2518
|
+
* }
|
2519
|
+
* ]
|
2520
|
+
* }
|
2521
|
+
* ]
|
2522
|
+
* }
|
2523
|
+
* }
|
2524
|
+
* }
|
2525
|
+
* ```
|
2526
|
+
*
|
2527
|
+
* The `$not: { $any: {}}` can be shorted using the `$none` operator:
|
2528
|
+
*
|
2149
2529
|
* ```json
|
2150
2530
|
* {
|
2151
2531
|
* "filter": {
|
@@ -2193,8 +2573,8 @@ declare type QueryTableVariables = {
|
|
2193
2573
|
* "<array name>": {
|
2194
2574
|
* "$includes": {
|
2195
2575
|
* "$all": [
|
2196
|
-
* {"$contains": "label"},
|
2197
|
-
* {"$not": {"$endsWith": "-debug"}}
|
2576
|
+
* { "$contains": "label" },
|
2577
|
+
* { "$not": { "$endsWith": "-debug" } }
|
2198
2578
|
* ]
|
2199
2579
|
* }
|
2200
2580
|
* }
|
@@ -2214,9 +2594,7 @@ declare type QueryTableVariables = {
|
|
2214
2594
|
* {
|
2215
2595
|
* "filter": {
|
2216
2596
|
* "settings.labels": {
|
2217
|
-
* "$includesAll": [
|
2218
|
-
* {"$contains": "label"},
|
2219
|
-
* ]
|
2597
|
+
* "$includesAll": [{ "$contains": "label" }]
|
2220
2598
|
* }
|
2221
2599
|
* }
|
2222
2600
|
* }
|
@@ -2264,7 +2642,6 @@ declare type QueryTableVariables = {
|
|
2264
2642
|
* }
|
2265
2643
|
* ```
|
2266
2644
|
*
|
2267
|
-
*
|
2268
2645
|
* ### Pagination
|
2269
2646
|
*
|
2270
2647
|
* We offer cursor pagination and offset pagination. The offset pagination is limited
|
@@ -2330,8 +2707,8 @@ declare type QueryTableVariables = {
|
|
2330
2707
|
* can be queried by update `page.after` to the returned cursor while keeping the
|
2331
2708
|
* `page.before` cursor from the first range query.
|
2332
2709
|
*
|
2333
|
-
* The `filter` , `columns`,
|
2334
|
-
* encoded with the cursor.
|
2710
|
+
* The `filter` , `columns`, `sort` , and `page.size` configuration will be
|
2711
|
+
* encoded with the cursor. The pagination request will be invalid if
|
2335
2712
|
* `filter` or `sort` is set. The columns returned and page size can be changed
|
2336
2713
|
* anytime by passing the `columns` or `page.size` settings to the next query.
|
2337
2714
|
*
|
@@ -2368,6 +2745,41 @@ declare type QueryTableVariables = {
|
|
2368
2745
|
* ```
|
2369
2746
|
*/
|
2370
2747
|
declare const queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
2748
|
+
declare type SearchTablePathParams = {
|
2749
|
+
dbBranchName: DBBranchName;
|
2750
|
+
tableName: TableName;
|
2751
|
+
workspace: string;
|
2752
|
+
};
|
2753
|
+
declare type SearchTableError = ErrorWrapper<{
|
2754
|
+
status: 400;
|
2755
|
+
payload: BadRequestError;
|
2756
|
+
} | {
|
2757
|
+
status: 401;
|
2758
|
+
payload: AuthError;
|
2759
|
+
} | {
|
2760
|
+
status: 404;
|
2761
|
+
payload: SimpleError;
|
2762
|
+
}>;
|
2763
|
+
declare type SearchTableRequestBody = {
|
2764
|
+
query: string;
|
2765
|
+
fuzziness?: FuzzinessExpression;
|
2766
|
+
prefix?: PrefixExpression;
|
2767
|
+
filter?: FilterExpression;
|
2768
|
+
highlight?: HighlightExpression;
|
2769
|
+
boosters?: BoosterExpression[];
|
2770
|
+
};
|
2771
|
+
declare type SearchTableVariables = {
|
2772
|
+
body: SearchTableRequestBody;
|
2773
|
+
pathParams: SearchTablePathParams;
|
2774
|
+
} & FetcherExtraProps;
|
2775
|
+
/**
|
2776
|
+
* Run a free text search operation in a particular table.
|
2777
|
+
*
|
2778
|
+
* 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:
|
2779
|
+
* * filters `$contains`, `$startsWith`, `$endsWith` don't work on columns of type `text`
|
2780
|
+
* * filtering on columns of type `multiple` is currently unsupported
|
2781
|
+
*/
|
2782
|
+
declare const searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
|
2371
2783
|
declare type SearchBranchPathParams = {
|
2372
2784
|
dbBranchName: DBBranchName;
|
2373
2785
|
workspace: string;
|
@@ -2383,9 +2795,14 @@ declare type SearchBranchError = ErrorWrapper<{
|
|
2383
2795
|
payload: SimpleError;
|
2384
2796
|
}>;
|
2385
2797
|
declare type SearchBranchRequestBody = {
|
2386
|
-
tables?: string
|
2798
|
+
tables?: (string | {
|
2799
|
+
table: string;
|
2800
|
+
filter?: FilterExpression;
|
2801
|
+
boosters?: BoosterExpression[];
|
2802
|
+
})[];
|
2387
2803
|
query: string;
|
2388
|
-
fuzziness?:
|
2804
|
+
fuzziness?: FuzzinessExpression;
|
2805
|
+
highlight?: HighlightExpression;
|
2389
2806
|
};
|
2390
2807
|
declare type SearchBranchVariables = {
|
2391
2808
|
body: SearchBranchRequestBody;
|
@@ -2414,6 +2831,7 @@ declare const operationsByTag: {
|
|
2414
2831
|
updateWorkspaceMemberRole: (variables: UpdateWorkspaceMemberRoleVariables) => Promise<undefined>;
|
2415
2832
|
removeWorkspaceMember: (variables: RemoveWorkspaceMemberVariables) => Promise<undefined>;
|
2416
2833
|
inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<WorkspaceInvite>;
|
2834
|
+
updateWorkspaceMemberInvite: (variables: UpdateWorkspaceMemberInviteVariables) => Promise<WorkspaceInvite>;
|
2417
2835
|
cancelWorkspaceMemberInvite: (variables: CancelWorkspaceMemberInviteVariables) => Promise<undefined>;
|
2418
2836
|
resendWorkspaceMemberInvite: (variables: ResendWorkspaceMemberInviteVariables) => Promise<undefined>;
|
2419
2837
|
acceptWorkspaceMemberInvite: (variables: AcceptWorkspaceMemberInviteVariables) => Promise<undefined>;
|
@@ -2422,11 +2840,16 @@ declare const operationsByTag: {
|
|
2422
2840
|
getDatabaseList: (variables: GetDatabaseListVariables) => Promise<ListDatabasesResponse>;
|
2423
2841
|
createDatabase: (variables: CreateDatabaseVariables) => Promise<CreateDatabaseResponse>;
|
2424
2842
|
deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
|
2843
|
+
getGitBranchesMapping: (variables: GetGitBranchesMappingVariables) => Promise<ListGitBranchesResponse>;
|
2844
|
+
addGitBranchesEntry: (variables: AddGitBranchesEntryVariables) => Promise<AddGitBranchesEntryResponse>;
|
2845
|
+
removeGitBranchesEntry: (variables: RemoveGitBranchesEntryVariables) => Promise<undefined>;
|
2846
|
+
resolveBranch: (variables: ResolveBranchVariables) => Promise<ResolveBranchResponse>;
|
2425
2847
|
};
|
2426
2848
|
branch: {
|
2427
2849
|
getBranchList: (variables: GetBranchListVariables) => Promise<ListBranchesResponse>;
|
2850
|
+
getDatabaseMetadata: (variables: GetDatabaseMetadataVariables) => Promise<DatabaseMetadata>;
|
2428
2851
|
getBranchDetails: (variables: GetBranchDetailsVariables) => Promise<DBBranch>;
|
2429
|
-
createBranch: (variables: CreateBranchVariables) => Promise<
|
2852
|
+
createBranch: (variables: CreateBranchVariables) => Promise<CreateBranchResponse>;
|
2430
2853
|
deleteBranch: (variables: DeleteBranchVariables) => Promise<undefined>;
|
2431
2854
|
updateBranchMetadata: (variables: UpdateBranchMetadataVariables) => Promise<undefined>;
|
2432
2855
|
getBranchMetadata: (variables: GetBranchMetadataVariables) => Promise<BranchMetadata>;
|
@@ -2436,7 +2859,7 @@ declare const operationsByTag: {
|
|
2436
2859
|
getBranchStats: (variables: GetBranchStatsVariables) => Promise<GetBranchStatsResponse>;
|
2437
2860
|
};
|
2438
2861
|
table: {
|
2439
|
-
createTable: (variables: CreateTableVariables) => Promise<
|
2862
|
+
createTable: (variables: CreateTableVariables) => Promise<CreateTableResponse>;
|
2440
2863
|
deleteTable: (variables: DeleteTableVariables) => Promise<undefined>;
|
2441
2864
|
updateTable: (variables: UpdateTableVariables) => Promise<undefined>;
|
2442
2865
|
getTableSchema: (variables: GetTableSchemaVariables) => Promise<GetTableSchemaResponse>;
|
@@ -2448,14 +2871,15 @@ declare const operationsByTag: {
|
|
2448
2871
|
updateColumn: (variables: UpdateColumnVariables) => Promise<MigrationIdResponse>;
|
2449
2872
|
};
|
2450
2873
|
records: {
|
2451
|
-
insertRecord: (variables: InsertRecordVariables) => Promise<
|
2874
|
+
insertRecord: (variables: InsertRecordVariables) => Promise<RecordUpdateResponse>;
|
2452
2875
|
insertRecordWithID: (variables: InsertRecordWithIDVariables) => Promise<RecordUpdateResponse>;
|
2453
2876
|
updateRecordWithID: (variables: UpdateRecordWithIDVariables) => Promise<RecordUpdateResponse>;
|
2454
2877
|
upsertRecordWithID: (variables: UpsertRecordWithIDVariables) => Promise<RecordUpdateResponse>;
|
2455
|
-
deleteRecord: (variables: DeleteRecordVariables) => Promise<
|
2878
|
+
deleteRecord: (variables: DeleteRecordVariables) => Promise<XataRecord$1>;
|
2456
2879
|
getRecord: (variables: GetRecordVariables) => Promise<XataRecord$1>;
|
2457
|
-
bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<
|
2880
|
+
bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertResponse>;
|
2458
2881
|
queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
2882
|
+
searchTable: (variables: SearchTableVariables) => Promise<SearchResponse>;
|
2459
2883
|
searchBranch: (variables: SearchBranchVariables) => Promise<SearchResponse>;
|
2460
2884
|
};
|
2461
2885
|
};
|
@@ -2472,6 +2896,9 @@ interface XataApiClientOptions {
|
|
2472
2896
|
apiKey?: string;
|
2473
2897
|
host?: HostProvider;
|
2474
2898
|
}
|
2899
|
+
/**
|
2900
|
+
* @deprecated Use XataApiPlugin instead
|
2901
|
+
*/
|
2475
2902
|
declare class XataApiClient {
|
2476
2903
|
#private;
|
2477
2904
|
constructor(options?: XataApiClientOptions);
|
@@ -2504,6 +2931,7 @@ declare class WorkspaceApi {
|
|
2504
2931
|
updateWorkspaceMemberRole(workspaceId: WorkspaceID, userId: UserID, role: Role): Promise<void>;
|
2505
2932
|
removeWorkspaceMember(workspaceId: WorkspaceID, userId: UserID): Promise<void>;
|
2506
2933
|
inviteWorkspaceMember(workspaceId: WorkspaceID, email: string, role: Role): Promise<WorkspaceInvite>;
|
2934
|
+
updateWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID, role: Role): Promise<WorkspaceInvite>;
|
2507
2935
|
cancelWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID): Promise<void>;
|
2508
2936
|
resendWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID): Promise<void>;
|
2509
2937
|
acceptWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteKey: InviteKey): Promise<void>;
|
@@ -2514,13 +2942,17 @@ declare class DatabaseApi {
|
|
2514
2942
|
getDatabaseList(workspace: WorkspaceID): Promise<ListDatabasesResponse>;
|
2515
2943
|
createDatabase(workspace: WorkspaceID, dbName: DBName, options?: CreateDatabaseRequestBody): Promise<CreateDatabaseResponse>;
|
2516
2944
|
deleteDatabase(workspace: WorkspaceID, dbName: DBName): Promise<void>;
|
2945
|
+
getGitBranchesMapping(workspace: WorkspaceID, dbName: DBName): Promise<ListGitBranchesResponse>;
|
2946
|
+
addGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, body: AddGitBranchesEntryRequestBody): Promise<AddGitBranchesEntryResponse>;
|
2947
|
+
removeGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<void>;
|
2948
|
+
resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch?: string, fallbackBranch?: string): Promise<ResolveBranchResponse>;
|
2517
2949
|
}
|
2518
2950
|
declare class BranchApi {
|
2519
2951
|
private extraProps;
|
2520
2952
|
constructor(extraProps: FetcherExtraProps);
|
2521
2953
|
getBranchList(workspace: WorkspaceID, dbName: DBName): Promise<ListBranchesResponse>;
|
2522
2954
|
getBranchDetails(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<DBBranch>;
|
2523
|
-
createBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, from?: string, options?: CreateBranchRequestBody): Promise<
|
2955
|
+
createBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, from?: string, options?: CreateBranchRequestBody): Promise<CreateBranchResponse>;
|
2524
2956
|
deleteBranch(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<void>;
|
2525
2957
|
updateBranchMetadata(workspace: WorkspaceID, database: DBName, branch: BranchName, metadata?: BranchMetadata): Promise<void>;
|
2526
2958
|
getBranchMetadata(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<BranchMetadata>;
|
@@ -2532,7 +2964,7 @@ declare class BranchApi {
|
|
2532
2964
|
declare class TableApi {
|
2533
2965
|
private extraProps;
|
2534
2966
|
constructor(extraProps: FetcherExtraProps);
|
2535
|
-
createTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<
|
2967
|
+
createTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<CreateTableResponse>;
|
2536
2968
|
deleteTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<void>;
|
2537
2969
|
updateTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, options: UpdateTableRequestBody): Promise<void>;
|
2538
2970
|
getTableSchema(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<GetTableSchemaResponse>;
|
@@ -2546,14 +2978,15 @@ declare class TableApi {
|
|
2546
2978
|
declare class RecordsApi {
|
2547
2979
|
private extraProps;
|
2548
2980
|
constructor(extraProps: FetcherExtraProps);
|
2549
|
-
insertRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, record: Record<string, any
|
2981
|
+
insertRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, record: Record<string, any>, options?: InsertRecordQueryParams): Promise<RecordUpdateResponse>;
|
2550
2982
|
insertRecordWithID(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, record: Record<string, any>, options?: InsertRecordWithIDQueryParams): Promise<RecordUpdateResponse>;
|
2551
2983
|
updateRecordWithID(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, record: Record<string, any>, options?: UpdateRecordWithIDQueryParams): Promise<RecordUpdateResponse>;
|
2552
2984
|
upsertRecordWithID(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, record: Record<string, any>, options?: UpsertRecordWithIDQueryParams): Promise<RecordUpdateResponse>;
|
2553
|
-
deleteRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID): Promise<
|
2554
|
-
getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?:
|
2555
|
-
bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[]): Promise<
|
2985
|
+
deleteRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: DeleteRecordQueryParams): Promise<RecordUpdateResponse>;
|
2986
|
+
getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: GetRecordQueryParams): Promise<XataRecord$1>;
|
2987
|
+
bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[], options?: BulkInsertTableRecordsQueryParams): Promise<BulkInsertResponse>;
|
2556
2988
|
queryTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: QueryTableRequestBody): Promise<QueryResponse>;
|
2989
|
+
searchTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: SearchTableRequestBody): Promise<SearchResponse>;
|
2557
2990
|
searchBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, query: SearchBranchRequestBody): Promise<SearchResponse>;
|
2558
2991
|
}
|
2559
2992
|
|
@@ -2567,28 +3000,29 @@ declare type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) ex
|
|
2567
3000
|
declare type If<Condition, Then, Else> = Condition extends true ? Then : Else;
|
2568
3001
|
declare type IsObject<T> = T extends Record<string, any> ? true : false;
|
2569
3002
|
declare type IsArray<T> = T extends Array<any> ? true : false;
|
2570
|
-
declare type NonEmptyArray<T> = T[] & {
|
2571
|
-
0: T;
|
2572
|
-
};
|
2573
3003
|
declare type RequiredBy<T, K extends keyof T> = T & {
|
2574
3004
|
[P in K]-?: NonNullable<T[P]>;
|
2575
3005
|
};
|
2576
3006
|
declare type GetArrayInnerType<T extends readonly any[]> = T[number];
|
2577
3007
|
declare type SingleOrArray<T> = T | T[];
|
2578
|
-
declare type
|
3008
|
+
declare type OmitBy<T, K extends keyof T> = T extends any ? Omit<T, K> : never;
|
3009
|
+
declare type Without<T, U> = {
|
3010
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
3011
|
+
};
|
3012
|
+
declare type ExclusiveOr<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
|
2579
3013
|
|
2580
3014
|
declare type SelectableColumn<O, RecursivePath extends any[] = []> = '*' | 'id' | DataProps<O> | NestedColumns<O, RecursivePath>;
|
2581
|
-
declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord & UnionToIntersection<Values<{
|
2582
|
-
[K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord
|
3015
|
+
declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord<O> & UnionToIntersection<Values<{
|
3016
|
+
[K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord<O>;
|
2583
3017
|
}>>;
|
2584
|
-
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
|
2585
|
-
V: ValueAtColumn<
|
2586
|
-
} : never
|
3018
|
+
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> ? {
|
3019
|
+
V: ValueAtColumn<Item, V>;
|
3020
|
+
} : never : O[K] : never> : never : never;
|
2587
3021
|
declare type MAX_RECURSION = 5;
|
2588
3022
|
declare type NestedColumns<O, RecursivePath extends any[]> = RecursivePath['length'] extends MAX_RECURSION ? never : If<IsObject<O>, Values<{
|
2589
|
-
[K in DataProps<O>]:
|
2590
|
-
If<IsObject<
|
2591
|
-
K
|
3023
|
+
[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
|
3024
|
+
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
|
3025
|
+
K>> : never;
|
2592
3026
|
}>, never>;
|
2593
3027
|
declare type DataProps<O> = Exclude<StringKeys<O>, StringKeys<XataRecord>>;
|
2594
3028
|
declare type NestedValueAtColumn<O, Key extends SelectableColumn<O>> = Key extends `${infer N}.${infer M}` ? N extends DataProps<O> ? {
|
@@ -2615,27 +3049,37 @@ interface BaseData {
|
|
2615
3049
|
/**
|
2616
3050
|
* Represents a persisted record from the database.
|
2617
3051
|
*/
|
2618
|
-
interface XataRecord extends Identifiable {
|
3052
|
+
interface XataRecord<OriginalRecord extends XataRecord<any> = XataRecord<any>> extends Identifiable {
|
2619
3053
|
/**
|
2620
|
-
*
|
3054
|
+
* Get metadata of this record.
|
2621
3055
|
*/
|
2622
|
-
|
2623
|
-
/**
|
2624
|
-
* Number that is increased every time the record is updated.
|
2625
|
-
*/
|
2626
|
-
version: number;
|
2627
|
-
};
|
3056
|
+
getMetadata(): XataRecordMetadata;
|
2628
3057
|
/**
|
2629
3058
|
* Retrieves a refreshed copy of the current record from the database.
|
3059
|
+
* @param columns The columns to retrieve. If not specified, all first level properties are retrieved.
|
3060
|
+
* @returns The persisted record with the selected columns.
|
2630
3061
|
*/
|
2631
|
-
read(): Promise<Readonly<SelectedPick<
|
3062
|
+
read<K extends SelectableColumn<OriginalRecord>>(columns: K[]): Promise<Readonly<SelectedPick<OriginalRecord, typeof columns>> | null>;
|
3063
|
+
/**
|
3064
|
+
* Retrieves a refreshed copy of the current record from the database.
|
3065
|
+
* @returns The persisted record with all first level properties.
|
3066
|
+
*/
|
3067
|
+
read(): Promise<Readonly<SelectedPick<OriginalRecord, ['*']>> | null>;
|
2632
3068
|
/**
|
2633
3069
|
* Performs a partial update of the current record. On success a new object is
|
2634
3070
|
* returned and the current object is not mutated.
|
2635
|
-
* @param
|
2636
|
-
* @
|
3071
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
3072
|
+
* @param columns The columns to retrieve. If not specified, all first level properties are retrieved.
|
3073
|
+
* @returns The persisted record with the selected columns.
|
3074
|
+
*/
|
3075
|
+
update<K extends SelectableColumn<OriginalRecord>>(partialUpdate: Partial<EditableData<Omit<OriginalRecord, keyof XataRecord>>>, columns: K[]): Promise<Readonly<SelectedPick<OriginalRecord, typeof columns>>>;
|
3076
|
+
/**
|
3077
|
+
* Performs a partial update of the current record. On success a new object is
|
3078
|
+
* returned and the current object is not mutated.
|
3079
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
3080
|
+
* @returns The persisted record with all first level properties.
|
2637
3081
|
*/
|
2638
|
-
update(partialUpdate: Partial<EditableData<Omit<
|
3082
|
+
update(partialUpdate: Partial<EditableData<Omit<OriginalRecord, keyof XataRecord>>>): Promise<Readonly<SelectedPick<OriginalRecord, ['*']>>>;
|
2639
3083
|
/**
|
2640
3084
|
* Performs a deletion of the current record in the database.
|
2641
3085
|
*
|
@@ -2647,23 +3091,36 @@ declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update
|
|
2647
3091
|
/**
|
2648
3092
|
* Retrieves a refreshed copy of the current record from the database.
|
2649
3093
|
*/
|
2650
|
-
read(): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
|
3094
|
+
read<K extends SelectableColumn<Record>>(columns?: K[]): Promise<Readonly<SelectedPick<Record, typeof columns extends SelectableColumn<Record>[] ? typeof columns : ['*']>> | null>;
|
2651
3095
|
/**
|
2652
3096
|
* Performs a partial update of the current record. On success a new object is
|
2653
3097
|
* returned and the current object is not mutated.
|
2654
|
-
* @param
|
3098
|
+
* @param partialUpdate The columns and their values that have to be updated.
|
2655
3099
|
* @returns A new record containing the latest values for all the columns of the current record.
|
2656
3100
|
*/
|
2657
|
-
update(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord
|
3101
|
+
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 : ['*']>>>;
|
3102
|
+
/**
|
3103
|
+
* Performs a deletion of the current record in the database.
|
3104
|
+
*
|
3105
|
+
* @throws If the record was already deleted or if an error happened while performing the deletion.
|
3106
|
+
*/
|
3107
|
+
delete(): Promise<void>;
|
3108
|
+
};
|
3109
|
+
declare type XataRecordMetadata = {
|
3110
|
+
/**
|
3111
|
+
* Number that is increased every time the record is updated.
|
3112
|
+
*/
|
3113
|
+
version: number;
|
3114
|
+
warnings?: string[];
|
2658
3115
|
};
|
2659
3116
|
declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
|
2660
3117
|
declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
|
2661
3118
|
declare type EditableData<O extends BaseData> = {
|
2662
3119
|
[K in keyof O]: O[K] extends XataRecord ? {
|
2663
3120
|
id: string;
|
2664
|
-
} : NonNullable<O[K]> extends XataRecord ? {
|
3121
|
+
} | string : NonNullable<O[K]> extends XataRecord ? {
|
2665
3122
|
id: string;
|
2666
|
-
} | null | undefined : O[K];
|
3123
|
+
} | string | null | undefined : O[K];
|
2667
3124
|
};
|
2668
3125
|
|
2669
3126
|
/**
|
@@ -2739,8 +3196,8 @@ declare type ValueTypeFilters<T> = T | T extends string ? StringTypeFilter : T e
|
|
2739
3196
|
],
|
2740
3197
|
}
|
2741
3198
|
*/
|
2742
|
-
declare type AggregatorFilter<
|
2743
|
-
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<
|
3199
|
+
declare type AggregatorFilter<T> = {
|
3200
|
+
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<T>>;
|
2744
3201
|
};
|
2745
3202
|
/**
|
2746
3203
|
* Existance filter
|
@@ -2755,10 +3212,88 @@ declare type BaseApiFilter<Record> = PropertyAccessFilter<Record> | AggregatorFi
|
|
2755
3212
|
* Injects the Api filters on nested properties
|
2756
3213
|
* Example: { filter: { settings: { plan: { $any: ['free', 'trial'] } } } }
|
2757
3214
|
*/
|
2758
|
-
declare type NestedApiFilter<T> =
|
3215
|
+
declare type NestedApiFilter<T> = {
|
2759
3216
|
[key in keyof T]?: T[key] extends Record<string, any> ? SingleOrArray<Filter<T[key]>> : PropertyFilter<T[key]>;
|
2760
|
-
}
|
2761
|
-
declare type Filter<
|
3217
|
+
};
|
3218
|
+
declare type Filter<T> = T extends Record<string, any> ? BaseApiFilter<T> | NestedApiFilter<T> : PropertyFilter<T>;
|
3219
|
+
|
3220
|
+
declare type DateBooster = {
|
3221
|
+
origin?: string;
|
3222
|
+
scale: string;
|
3223
|
+
decay: number;
|
3224
|
+
};
|
3225
|
+
declare type NumericBooster = {
|
3226
|
+
factor: number;
|
3227
|
+
};
|
3228
|
+
declare type ValueBooster<T extends string | number | boolean> = {
|
3229
|
+
value: T;
|
3230
|
+
factor: number;
|
3231
|
+
};
|
3232
|
+
declare type Boosters<O extends XataRecord> = Values<{
|
3233
|
+
[K in SelectableColumn<O>]: NonNullable<ValueAtColumn<O, K>> extends Date ? {
|
3234
|
+
dateBooster: {
|
3235
|
+
column: K;
|
3236
|
+
} & DateBooster;
|
3237
|
+
} : NonNullable<ValueAtColumn<O, K>> extends number ? ExclusiveOr<{
|
3238
|
+
numericBooster?: {
|
3239
|
+
column: K;
|
3240
|
+
} & NumericBooster;
|
3241
|
+
}, {
|
3242
|
+
valueBooster?: {
|
3243
|
+
column: K;
|
3244
|
+
} & ValueBooster<number>;
|
3245
|
+
}> : NonNullable<ValueAtColumn<O, K>> extends string | boolean ? {
|
3246
|
+
valueBooster: {
|
3247
|
+
column: K;
|
3248
|
+
} & ValueBooster<NonNullable<ValueAtColumn<O, K>>>;
|
3249
|
+
} : never;
|
3250
|
+
}>;
|
3251
|
+
|
3252
|
+
declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
|
3253
|
+
fuzziness?: FuzzinessExpression;
|
3254
|
+
prefix?: PrefixExpression;
|
3255
|
+
highlight?: HighlightExpression;
|
3256
|
+
tables?: Array<Tables | Values<{
|
3257
|
+
[Model in GetArrayInnerType<NonNullable<Tables[]>>]: {
|
3258
|
+
table: Model;
|
3259
|
+
filter?: Filter<SelectedPick<Schemas[Model] & XataRecord, ['*']>>;
|
3260
|
+
boosters?: Boosters<Schemas[Model] & XataRecord>[];
|
3261
|
+
};
|
3262
|
+
}>>;
|
3263
|
+
};
|
3264
|
+
declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
|
3265
|
+
all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
|
3266
|
+
[Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]: {
|
3267
|
+
table: Model;
|
3268
|
+
record: Awaited<SearchXataRecord<SelectedPick<Schemas[Model] & XataRecord, ['*']>>>;
|
3269
|
+
};
|
3270
|
+
}>[]>;
|
3271
|
+
byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
|
3272
|
+
[Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]?: Awaited<SearchXataRecord<SelectedPick<Schemas[Model] & XataRecord, ['*']>>[]>;
|
3273
|
+
}>;
|
3274
|
+
};
|
3275
|
+
declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
3276
|
+
#private;
|
3277
|
+
private db;
|
3278
|
+
constructor(db: SchemaPluginResult<Schemas>, schemaTables?: Schemas.Table[]);
|
3279
|
+
build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
|
3280
|
+
}
|
3281
|
+
declare type SearchXataRecord<Record extends XataRecord> = Omit<Record, 'getMetadata'> & {
|
3282
|
+
getMetadata: () => XataRecordMetadata & SearchExtraProperties;
|
3283
|
+
};
|
3284
|
+
declare type SearchExtraProperties = {
|
3285
|
+
table: string;
|
3286
|
+
highlight?: {
|
3287
|
+
[key: string]: string[] | {
|
3288
|
+
[key: string]: any;
|
3289
|
+
};
|
3290
|
+
};
|
3291
|
+
score?: number;
|
3292
|
+
};
|
3293
|
+
declare type ReturnTable<Table, Tables> = Table extends Tables ? Table : never;
|
3294
|
+
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 {
|
3295
|
+
table: infer Table;
|
3296
|
+
} ? ReturnTable<Table, Tables> : never;
|
2762
3297
|
|
2763
3298
|
declare type SortDirection = 'asc' | 'desc';
|
2764
3299
|
declare type SortFilterExtended<T extends XataRecord> = {
|
@@ -2770,12 +3305,21 @@ declare type SortFilterBase<T extends XataRecord> = {
|
|
2770
3305
|
[Key in StringKeys<T>]: SortDirection;
|
2771
3306
|
};
|
2772
3307
|
|
2773
|
-
declare type
|
2774
|
-
|
2775
|
-
|
3308
|
+
declare type BaseOptions<T extends XataRecord> = {
|
3309
|
+
columns?: SelectableColumn<T>[];
|
3310
|
+
cache?: number;
|
3311
|
+
};
|
3312
|
+
declare type CursorQueryOptions = {
|
3313
|
+
pagination?: CursorNavigationOptions & OffsetNavigationOptions;
|
3314
|
+
filter?: never;
|
3315
|
+
sort?: never;
|
3316
|
+
};
|
3317
|
+
declare type OffsetQueryOptions<T extends XataRecord> = {
|
3318
|
+
pagination?: OffsetNavigationOptions;
|
2776
3319
|
filter?: FilterExpression;
|
2777
3320
|
sort?: SortFilter<T> | SortFilter<T>[];
|
2778
3321
|
};
|
3322
|
+
declare type QueryOptions<T extends XataRecord> = BaseOptions<T> & (CursorQueryOptions | OffsetQueryOptions<T>);
|
2779
3323
|
/**
|
2780
3324
|
* Query objects contain the information of all filters, sorting, etc. to be included in the database query.
|
2781
3325
|
*
|
@@ -2785,9 +3329,10 @@ declare type QueryOptions<T extends XataRecord> = {
|
|
2785
3329
|
declare class Query<Record extends XataRecord, Result extends XataRecord = Record> implements Paginable<Record, Result> {
|
2786
3330
|
#private;
|
2787
3331
|
readonly meta: PaginationQueryMeta;
|
2788
|
-
readonly records: Result
|
2789
|
-
constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>,
|
3332
|
+
readonly records: RecordArray<Result>;
|
3333
|
+
constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, rawParent?: Partial<QueryOptions<Record>>);
|
2790
3334
|
getQueryOptions(): QueryOptions<Record>;
|
3335
|
+
key(): string;
|
2791
3336
|
/**
|
2792
3337
|
* Builds a new query object representing a logical OR between the given subqueries.
|
2793
3338
|
* @param queries An array of subqueries.
|
@@ -2817,18 +3362,28 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
2817
3362
|
*
|
2818
3363
|
* ```
|
2819
3364
|
* query.filter("columnName", columnValue)
|
2820
|
-
* query.filter(
|
2821
|
-
*
|
2822
|
-
*
|
3365
|
+
* query.filter("columnName", operator(columnValue)) // Use gt, gte, lt, lte, startsWith,...
|
3366
|
+
* ```
|
3367
|
+
*
|
3368
|
+
* @param column The name of the column to filter.
|
3369
|
+
* @param value The value to filter.
|
3370
|
+
* @returns A new Query object.
|
3371
|
+
*/
|
3372
|
+
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
|
3373
|
+
/**
|
3374
|
+
* Builds a new query object adding one or more constraints. Examples:
|
3375
|
+
*
|
3376
|
+
* ```
|
3377
|
+
* query.filter({ "columnName": columnValue })
|
2823
3378
|
* query.filter({
|
2824
3379
|
* "columnName": operator(columnValue) // Use gt, gte, lt, lte, startsWith,...
|
2825
3380
|
* })
|
2826
3381
|
* ```
|
2827
3382
|
*
|
3383
|
+
* @param filters A filter object
|
2828
3384
|
* @returns A new Query object.
|
2829
3385
|
*/
|
2830
3386
|
filter(filters: Filter<Record>): Query<Record, Result>;
|
2831
|
-
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
|
2832
3387
|
/**
|
2833
3388
|
* Builds a new query with a new sort option.
|
2834
3389
|
* @param column The column name.
|
@@ -2841,43 +3396,149 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
|
|
2841
3396
|
* @param columns Array of column names to be returned by the query.
|
2842
3397
|
* @returns A new Query object.
|
2843
3398
|
*/
|
2844
|
-
select<K extends SelectableColumn<Record>>(columns:
|
3399
|
+
select<K extends SelectableColumn<Record>>(columns: K[]): Query<Record, SelectedPick<Record, K[]>>;
|
3400
|
+
/**
|
3401
|
+
* Get paginated results
|
3402
|
+
*
|
3403
|
+
* @returns A page of results
|
3404
|
+
*/
|
2845
3405
|
getPaginated(): Promise<Page<Record, Result>>;
|
2846
|
-
|
3406
|
+
/**
|
3407
|
+
* Get paginated results
|
3408
|
+
*
|
3409
|
+
* @param options Pagination options
|
3410
|
+
* @returns A page of results
|
3411
|
+
*/
|
3412
|
+
getPaginated(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
|
3413
|
+
/**
|
3414
|
+
* Get paginated results
|
3415
|
+
*
|
3416
|
+
* @param options Pagination options
|
3417
|
+
* @returns A page of results
|
3418
|
+
*/
|
2847
3419
|
getPaginated<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<Page<Record, SelectedPick<Record, typeof options['columns']>>>;
|
3420
|
+
/**
|
3421
|
+
* Get results in an iterator
|
3422
|
+
*
|
3423
|
+
* @async
|
3424
|
+
* @returns Async interable of results
|
3425
|
+
*/
|
2848
3426
|
[Symbol.asyncIterator](): AsyncIterableIterator<Result>;
|
2849
|
-
|
2850
|
-
|
2851
|
-
|
3427
|
+
/**
|
3428
|
+
* Build an iterator of results
|
3429
|
+
*
|
3430
|
+
* @returns Async generator of results array
|
3431
|
+
*/
|
3432
|
+
getIterator(): AsyncGenerator<Result[]>;
|
3433
|
+
/**
|
3434
|
+
* Build an iterator of results
|
3435
|
+
*
|
3436
|
+
* @param options Pagination options with batchSize
|
3437
|
+
* @returns Async generator of results array
|
3438
|
+
*/
|
3439
|
+
getIterator(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
|
3440
|
+
batchSize?: number;
|
3441
|
+
}): AsyncGenerator<Result[]>;
|
3442
|
+
/**
|
3443
|
+
* Build an iterator of results
|
3444
|
+
*
|
3445
|
+
* @param options Pagination options with batchSize
|
3446
|
+
* @returns Async generator of results array
|
3447
|
+
*/
|
3448
|
+
getIterator<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
|
3449
|
+
batchSize?: number;
|
3450
|
+
}>(options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
|
3451
|
+
/**
|
3452
|
+
* Performs the query in the database and returns a set of results.
|
3453
|
+
* @returns An array of records from the database.
|
3454
|
+
*/
|
3455
|
+
getMany(): Promise<RecordArray<Result>>;
|
2852
3456
|
/**
|
2853
3457
|
* Performs the query in the database and returns a set of results.
|
2854
3458
|
* @param options Additional options to be used when performing the query.
|
2855
3459
|
* @returns An array of records from the database.
|
2856
3460
|
*/
|
2857
|
-
getMany(): Promise<
|
2858
|
-
|
2859
|
-
|
3461
|
+
getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<RecordArray<SelectedPick<Record, typeof options['columns']>>>;
|
3462
|
+
/**
|
3463
|
+
* Performs the query in the database and returns a set of results.
|
3464
|
+
* @param options Additional options to be used when performing the query.
|
3465
|
+
* @returns An array of records from the database.
|
3466
|
+
*/
|
3467
|
+
getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<RecordArray<Result>>;
|
3468
|
+
/**
|
3469
|
+
* Performs the query in the database and returns all the results.
|
3470
|
+
* Warning: If there are a large number of results, this method can have performance implications.
|
3471
|
+
* @returns An array of records from the database.
|
3472
|
+
*/
|
3473
|
+
getAll(): Promise<Result[]>;
|
2860
3474
|
/**
|
2861
3475
|
* Performs the query in the database and returns all the results.
|
2862
3476
|
* Warning: If there are a large number of results, this method can have performance implications.
|
2863
3477
|
* @param options Additional options to be used when performing the query.
|
2864
3478
|
* @returns An array of records from the database.
|
2865
3479
|
*/
|
2866
|
-
getAll
|
2867
|
-
|
2868
|
-
|
3480
|
+
getAll<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
|
3481
|
+
batchSize?: number;
|
3482
|
+
}>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
|
3483
|
+
/**
|
3484
|
+
* Performs the query in the database and returns all the results.
|
3485
|
+
* Warning: If there are a large number of results, this method can have performance implications.
|
3486
|
+
* @param options Additional options to be used when performing the query.
|
3487
|
+
* @returns An array of records from the database.
|
3488
|
+
*/
|
3489
|
+
getAll(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
|
3490
|
+
batchSize?: number;
|
3491
|
+
}): Promise<Result[]>;
|
3492
|
+
/**
|
3493
|
+
* Performs the query in the database and returns the first result.
|
3494
|
+
* @returns The first record that matches the query, or null if no record matched the query.
|
3495
|
+
*/
|
3496
|
+
getFirst(): Promise<Result | null>;
|
3497
|
+
/**
|
3498
|
+
* Performs the query in the database and returns the first result.
|
3499
|
+
* @param options Additional options to be used when performing the query.
|
3500
|
+
* @returns The first record that matches the query, or null if no record matched the query.
|
3501
|
+
*/
|
3502
|
+
getFirst<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
|
2869
3503
|
/**
|
2870
3504
|
* Performs the query in the database and returns the first result.
|
2871
3505
|
* @param options Additional options to be used when performing the query.
|
2872
3506
|
* @returns The first record that matches the query, or null if no record matched the query.
|
2873
3507
|
*/
|
2874
|
-
|
2875
|
-
|
2876
|
-
|
3508
|
+
getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
|
3509
|
+
/**
|
3510
|
+
* Builds a new query object adding a cache TTL in milliseconds.
|
3511
|
+
* @param ttl The cache TTL in milliseconds.
|
3512
|
+
* @returns A new Query object.
|
3513
|
+
*/
|
3514
|
+
cache(ttl: number): Query<Record, Result>;
|
3515
|
+
/**
|
3516
|
+
* Retrieve next page of records
|
3517
|
+
*
|
3518
|
+
* @returns A new page object.
|
3519
|
+
*/
|
2877
3520
|
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3521
|
+
/**
|
3522
|
+
* Retrieve previous page of records
|
3523
|
+
*
|
3524
|
+
* @returns A new page object
|
3525
|
+
*/
|
2878
3526
|
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3527
|
+
/**
|
3528
|
+
* Retrieve first page of records
|
3529
|
+
*
|
3530
|
+
* @returns A new page object
|
3531
|
+
*/
|
2879
3532
|
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3533
|
+
/**
|
3534
|
+
* Retrieve last page of records
|
3535
|
+
*
|
3536
|
+
* @returns A new page object
|
3537
|
+
*/
|
2880
3538
|
lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
3539
|
+
/**
|
3540
|
+
* @returns Boolean indicating if there is a next page
|
3541
|
+
*/
|
2881
3542
|
hasNextPage(): boolean;
|
2882
3543
|
}
|
2883
3544
|
|
@@ -2889,7 +3550,7 @@ declare type PaginationQueryMeta = {
|
|
2889
3550
|
};
|
2890
3551
|
interface Paginable<Record extends XataRecord, Result extends XataRecord = Record> {
|
2891
3552
|
meta: PaginationQueryMeta;
|
2892
|
-
records: Result
|
3553
|
+
records: RecordArray<Result>;
|
2893
3554
|
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2894
3555
|
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2895
3556
|
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
@@ -2909,7 +3570,7 @@ declare class Page<Record extends XataRecord, Result extends XataRecord = Record
|
|
2909
3570
|
/**
|
2910
3571
|
* The set of results for this page.
|
2911
3572
|
*/
|
2912
|
-
readonly records: Result
|
3573
|
+
readonly records: RecordArray<Result>;
|
2913
3574
|
constructor(query: Query<Record, Result>, meta: PaginationQueryMeta, records?: Result[]);
|
2914
3575
|
/**
|
2915
3576
|
* Retrieves the next page of results.
|
@@ -2957,44 +3618,154 @@ declare type OffsetNavigationOptions = {
|
|
2957
3618
|
size?: number;
|
2958
3619
|
offset?: number;
|
2959
3620
|
};
|
2960
|
-
declare type PaginationOptions = CursorNavigationOptions & OffsetNavigationOptions;
|
2961
3621
|
declare const PAGINATION_MAX_SIZE = 200;
|
2962
|
-
declare const PAGINATION_DEFAULT_SIZE =
|
3622
|
+
declare const PAGINATION_DEFAULT_SIZE = 20;
|
2963
3623
|
declare const PAGINATION_MAX_OFFSET = 800;
|
2964
3624
|
declare const PAGINATION_DEFAULT_OFFSET = 0;
|
3625
|
+
declare function isCursorPaginationOptions(options: Record<string, unknown> | undefined | null): options is CursorNavigationOptions;
|
3626
|
+
declare class RecordArray<Result extends XataRecord> extends Array<Result> {
|
3627
|
+
#private;
|
3628
|
+
constructor(page: Paginable<any, Result>, overrideRecords?: Result[]);
|
3629
|
+
static parseConstructorParams(...args: any[]): any[];
|
3630
|
+
toArray(): Result[];
|
3631
|
+
map<U>(callbackfn: (value: Result, index: number, array: Result[]) => U, thisArg?: any): U[];
|
3632
|
+
/**
|
3633
|
+
* Retrieve next page of records
|
3634
|
+
*
|
3635
|
+
* @returns A new array of objects
|
3636
|
+
*/
|
3637
|
+
nextPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3638
|
+
/**
|
3639
|
+
* Retrieve previous page of records
|
3640
|
+
*
|
3641
|
+
* @returns A new array of objects
|
3642
|
+
*/
|
3643
|
+
previousPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3644
|
+
/**
|
3645
|
+
* Retrieve first page of records
|
3646
|
+
*
|
3647
|
+
* @returns A new array of objects
|
3648
|
+
*/
|
3649
|
+
firstPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3650
|
+
/**
|
3651
|
+
* Retrieve last page of records
|
3652
|
+
*
|
3653
|
+
* @returns A new array of objects
|
3654
|
+
*/
|
3655
|
+
lastPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
|
3656
|
+
/**
|
3657
|
+
* @returns Boolean indicating if there is a next page
|
3658
|
+
*/
|
3659
|
+
hasNextPage(): boolean;
|
3660
|
+
}
|
2965
3661
|
|
2966
|
-
declare type TableLink = string[];
|
2967
|
-
declare type LinkDictionary = Dictionary<TableLink[]>;
|
2968
3662
|
/**
|
2969
3663
|
* Common interface for performing operations on a table.
|
2970
3664
|
*/
|
2971
3665
|
declare abstract class Repository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, Readonly<SelectedPick<Record, ['*']>>> {
|
2972
|
-
abstract create(object: EditableData<Data> & Partial<Identifiable
|
3666
|
+
abstract create<K extends SelectableColumn<Record>>(object: Omit<EditableData<Data>, 'id'> & Partial<Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
3667
|
+
abstract create(object: Omit<EditableData<Data>, 'id'> & Partial<Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3668
|
+
/**
|
3669
|
+
* Creates a single record in the table with a unique id.
|
3670
|
+
* @param id The unique id.
|
3671
|
+
* @param object Object containing the column names with their values to be stored in the table.
|
3672
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3673
|
+
* @returns The full persisted record.
|
3674
|
+
*/
|
3675
|
+
abstract create<K extends SelectableColumn<Record>>(id: string, object: Omit<EditableData<Data>, 'id'>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
2973
3676
|
/**
|
2974
3677
|
* Creates a single record in the table with a unique id.
|
2975
3678
|
* @param id The unique id.
|
2976
3679
|
* @param object Object containing the column names with their values to be stored in the table.
|
2977
3680
|
* @returns The full persisted record.
|
2978
3681
|
*/
|
2979
|
-
abstract create(id: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3682
|
+
abstract create(id: string, object: Omit<EditableData<Data>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
2980
3683
|
/**
|
2981
3684
|
* Creates multiple records in the table.
|
2982
3685
|
* @param objects Array of objects with the column names and the values to be stored in the table.
|
2983
|
-
* @
|
3686
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3687
|
+
* @returns Array of the persisted records in order.
|
3688
|
+
*/
|
3689
|
+
abstract create<K extends SelectableColumn<Record>>(objects: Array<Omit<EditableData<Data>, 'id'> & Partial<Identifiable>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
|
3690
|
+
/**
|
3691
|
+
* Creates multiple records in the table.
|
3692
|
+
* @param objects Array of objects with the column names and the values to be stored in the table.
|
3693
|
+
* @returns Array of the persisted records in order.
|
2984
3694
|
*/
|
2985
|
-
abstract create(objects: Array<EditableData<Data> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
|
3695
|
+
abstract create(objects: Array<Omit<EditableData<Data>, 'id'> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
|
3696
|
+
/**
|
3697
|
+
* Queries a single record from the table given its unique id.
|
3698
|
+
* @param id The unique id.
|
3699
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3700
|
+
* @returns The persisted record for the given id or null if the record could not be found.
|
3701
|
+
*/
|
3702
|
+
abstract read<K extends SelectableColumn<Record>>(id: string, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns> | null>>;
|
2986
3703
|
/**
|
2987
3704
|
* Queries a single record from the table given its unique id.
|
2988
3705
|
* @param id The unique id.
|
2989
3706
|
* @returns The persisted record for the given id or null if the record could not be found.
|
2990
3707
|
*/
|
2991
3708
|
abstract read(id: string): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
|
3709
|
+
/**
|
3710
|
+
* Queries multiple records from the table given their unique id.
|
3711
|
+
* @param ids The unique ids array.
|
3712
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3713
|
+
* @returns The persisted records for the given ids in order (if a record could not be found null is returned).
|
3714
|
+
*/
|
3715
|
+
abstract read<K extends SelectableColumn<Record>>(ids: string[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
|
3716
|
+
/**
|
3717
|
+
* Queries multiple records from the table given their unique id.
|
3718
|
+
* @param ids The unique ids array.
|
3719
|
+
* @returns The persisted records for the given ids in order (if a record could not be found null is returned).
|
3720
|
+
*/
|
3721
|
+
abstract read(ids: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
|
3722
|
+
/**
|
3723
|
+
* Queries a single record from the table by the id in the object.
|
3724
|
+
* @param object Object containing the id of the record.
|
3725
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3726
|
+
* @returns The persisted record for the given id or null if the record could not be found.
|
3727
|
+
*/
|
3728
|
+
abstract read<K extends SelectableColumn<Record>>(object: Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns> | null>>;
|
3729
|
+
/**
|
3730
|
+
* Queries a single record from the table by the id in the object.
|
3731
|
+
* @param object Object containing the id of the record.
|
3732
|
+
* @returns The persisted record for the given id or null if the record could not be found.
|
3733
|
+
*/
|
3734
|
+
abstract read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
|
3735
|
+
/**
|
3736
|
+
* Queries multiple records from the table by the ids in the objects.
|
3737
|
+
* @param objects Array of objects containing the ids of the records.
|
3738
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3739
|
+
* @returns The persisted records for the given ids in order (if a record could not be found null is returned).
|
3740
|
+
*/
|
3741
|
+
abstract read<K extends SelectableColumn<Record>>(objects: Identifiable[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
|
3742
|
+
/**
|
3743
|
+
* Queries multiple records from the table by the ids in the objects.
|
3744
|
+
* @param objects Array of objects containing the ids of the records.
|
3745
|
+
* @returns The persisted records for the given ids in order (if a record could not be found null is returned).
|
3746
|
+
*/
|
3747
|
+
abstract read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
|
3748
|
+
/**
|
3749
|
+
* Partially update a single record.
|
3750
|
+
* @param object An object with its id and the columns to be updated.
|
3751
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3752
|
+
* @returns The full persisted record.
|
3753
|
+
*/
|
3754
|
+
abstract update<K extends SelectableColumn<Record>>(object: Partial<EditableData<Data>> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
2992
3755
|
/**
|
2993
3756
|
* Partially update a single record.
|
2994
3757
|
* @param object An object with its id and the columns to be updated.
|
2995
3758
|
* @returns The full persisted record.
|
2996
3759
|
*/
|
2997
3760
|
abstract update(object: Partial<EditableData<Data>> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3761
|
+
/**
|
3762
|
+
* Partially update a single record given its unique id.
|
3763
|
+
* @param id The unique id.
|
3764
|
+
* @param object The column names and their values that have to be updated.
|
3765
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3766
|
+
* @returns The full persisted record.
|
3767
|
+
*/
|
3768
|
+
abstract update<K extends SelectableColumn<Record>>(id: string, object: Partial<EditableData<Data>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
2998
3769
|
/**
|
2999
3770
|
* Partially update a single record given its unique id.
|
3000
3771
|
* @param id The unique id.
|
@@ -3005,9 +3776,24 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
3005
3776
|
/**
|
3006
3777
|
* Partially updates multiple records.
|
3007
3778
|
* @param objects An array of objects with their ids and columns to be updated.
|
3008
|
-
* @
|
3779
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3780
|
+
* @returns Array of the persisted records in order.
|
3781
|
+
*/
|
3782
|
+
abstract update<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Data>> & Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
|
3783
|
+
/**
|
3784
|
+
* Partially updates multiple records.
|
3785
|
+
* @param objects An array of objects with their ids and columns to be updated.
|
3786
|
+
* @returns Array of the persisted records in order.
|
3009
3787
|
*/
|
3010
3788
|
abstract update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
|
3789
|
+
/**
|
3790
|
+
* Creates or updates a single record. If a record exists with the given id,
|
3791
|
+
* it will be update, otherwise a new record will be created.
|
3792
|
+
* @param object Object containing the column names with their values to be persisted in the table.
|
3793
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3794
|
+
* @returns The full persisted record.
|
3795
|
+
*/
|
3796
|
+
abstract createOrUpdate<K extends SelectableColumn<Record>>(object: EditableData<Data> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
3011
3797
|
/**
|
3012
3798
|
* Creates or updates a single record. If a record exists with the given id,
|
3013
3799
|
* it will be update, otherwise a new record will be created.
|
@@ -3015,6 +3801,15 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
3015
3801
|
* @returns The full persisted record.
|
3016
3802
|
*/
|
3017
3803
|
abstract createOrUpdate(object: EditableData<Data> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3804
|
+
/**
|
3805
|
+
* Creates or updates a single record. If a record exists with the given id,
|
3806
|
+
* it will be update, otherwise a new record will be created.
|
3807
|
+
* @param id A unique id.
|
3808
|
+
* @param object The column names and the values to be persisted.
|
3809
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3810
|
+
* @returns The full persisted record.
|
3811
|
+
*/
|
3812
|
+
abstract createOrUpdate<K extends SelectableColumn<Record>>(id: string, object: Omit<EditableData<Data>, 'id'>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
3018
3813
|
/**
|
3019
3814
|
* Creates or updates a single record. If a record exists with the given id,
|
3020
3815
|
* it will be update, otherwise a new record will be created.
|
@@ -3022,7 +3817,15 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
3022
3817
|
* @param object The column names and the values to be persisted.
|
3023
3818
|
* @returns The full persisted record.
|
3024
3819
|
*/
|
3025
|
-
abstract createOrUpdate(id: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3820
|
+
abstract createOrUpdate(id: string, object: Omit<EditableData<Data>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3821
|
+
/**
|
3822
|
+
* Creates or updates a single record. If a record exists with the given id,
|
3823
|
+
* it will be update, otherwise a new record will be created.
|
3824
|
+
* @param objects Array of objects with the column names and the values to be stored in the table.
|
3825
|
+
* @param columns Array of columns to be returned. If not specified, first level columns will be returned.
|
3826
|
+
* @returns Array of the persisted records.
|
3827
|
+
*/
|
3828
|
+
abstract createOrUpdate<K extends SelectableColumn<Record>>(objects: Array<EditableData<Data> & Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
|
3026
3829
|
/**
|
3027
3830
|
* Creates or updates a single record. If a record exists with the given id,
|
3028
3831
|
* it will be update, otherwise a new record will be created.
|
@@ -3061,8 +3864,12 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
3061
3864
|
* @returns The found records.
|
3062
3865
|
*/
|
3063
3866
|
abstract search(query: string, options?: {
|
3064
|
-
fuzziness?:
|
3065
|
-
|
3867
|
+
fuzziness?: FuzzinessExpression;
|
3868
|
+
prefix?: PrefixExpression;
|
3869
|
+
highlight?: HighlightExpression;
|
3870
|
+
filter?: Filter<Record>;
|
3871
|
+
boosters?: Boosters<Record>[];
|
3872
|
+
}): Promise<SearchXataRecord<SelectedPick<Record, ['*']>>[]>;
|
3066
3873
|
abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
3067
3874
|
}
|
3068
3875
|
declare class RestRepository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, SelectedPick<Record, ['*']>> implements Repository<Data, Record> {
|
@@ -3070,27 +3877,100 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
|
|
3070
3877
|
db: SchemaPluginResult<any>;
|
3071
3878
|
constructor(options: {
|
3072
3879
|
table: string;
|
3073
|
-
links?: LinkDictionary;
|
3074
|
-
getFetchProps: () => Promise<FetcherExtraProps>;
|
3075
3880
|
db: SchemaPluginResult<any>;
|
3881
|
+
pluginOptions: XataPluginOptions;
|
3882
|
+
schemaTables?: Table[];
|
3076
3883
|
});
|
3077
|
-
create(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']
|
3078
|
-
create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']
|
3079
|
-
create(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']
|
3080
|
-
|
3884
|
+
create(object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3885
|
+
create(recordId: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
3886
|
+
create(objects: EditableData<Data>[]): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
|
3887
|
+
create<K extends SelectableColumn<Record>>(object: EditableData<Data>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
3888
|
+
create<K extends SelectableColumn<Record>>(recordId: string, object: EditableData<Data>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
|
3889
|
+
create<K extends SelectableColumn<Record>>(objects: EditableData<Data>[], columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
|
3890
|
+
read(recordId: string): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
|
3891
|
+
read(recordIds: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3892
|
+
read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
|
3893
|
+
read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
|
3894
|
+
read<K extends SelectableColumn<Record>>(recordId: string, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
|
3895
|
+
read<K extends SelectableColumn<Record>>(recordIds: string[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>>>>;
|
3896
|
+
read<K extends SelectableColumn<Record>>(object: Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
|
3897
|
+
read<K extends SelectableColumn<Record>>(objects: Identifiable[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>>>>;
|
3081
3898
|
update(object: Partial<EditableData<Data>> & Identifiable): Promise<SelectedPick<Record, ['*']>>;
|
3082
3899
|
update(recordId: string, object: Partial<EditableData<Data>>): Promise<SelectedPick<Record, ['*']>>;
|
3083
3900
|
update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<SelectedPick<Record, ['*']>[]>;
|
3901
|
+
update<K extends SelectableColumn<Record>>(object: Partial<EditableData<Data>> & Identifiable, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
|
3902
|
+
update<K extends SelectableColumn<Record>>(recordId: string, object: Partial<EditableData<Data>>, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
|
3903
|
+
update<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Data>> & Identifiable>, columns: K[]): Promise<SelectedPick<Record, typeof columns>[]>;
|
3084
3904
|
createOrUpdate(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
|
3085
3905
|
createOrUpdate(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
|
3086
3906
|
createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
|
3087
|
-
|
3907
|
+
createOrUpdate<K extends SelectableColumn<Record>>(object: EditableData<Data>, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
|
3908
|
+
createOrUpdate<K extends SelectableColumn<Record>>(recordId: string, object: EditableData<Data>, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
|
3909
|
+
createOrUpdate<K extends SelectableColumn<Record>>(objects: EditableData<Data>[], columns: K[]): Promise<SelectedPick<Record, typeof columns>[]>;
|
3910
|
+
delete(a: string | Identifiable | Array<string | Identifiable>): Promise<void>;
|
3088
3911
|
search(query: string, options?: {
|
3089
|
-
fuzziness?:
|
3090
|
-
|
3912
|
+
fuzziness?: FuzzinessExpression;
|
3913
|
+
prefix?: PrefixExpression;
|
3914
|
+
highlight?: HighlightExpression;
|
3915
|
+
filter?: Filter<Record>;
|
3916
|
+
boosters?: Boosters<Record>[];
|
3917
|
+
}): Promise<any>;
|
3091
3918
|
query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
3092
3919
|
}
|
3093
3920
|
|
3921
|
+
declare type BaseSchema = {
|
3922
|
+
name: string;
|
3923
|
+
columns: readonly ({
|
3924
|
+
name: string;
|
3925
|
+
type: Column['type'];
|
3926
|
+
} | {
|
3927
|
+
name: string;
|
3928
|
+
type: 'link';
|
3929
|
+
link: {
|
3930
|
+
table: string;
|
3931
|
+
};
|
3932
|
+
} | {
|
3933
|
+
name: string;
|
3934
|
+
type: 'object';
|
3935
|
+
columns: {
|
3936
|
+
name: string;
|
3937
|
+
type: string;
|
3938
|
+
}[];
|
3939
|
+
})[];
|
3940
|
+
};
|
3941
|
+
declare type SchemaInference<T extends readonly BaseSchema[]> = T extends never[] ? Record<string, Record<string, any>> : T extends readonly unknown[] ? T[number] extends {
|
3942
|
+
name: string;
|
3943
|
+
columns: readonly unknown[];
|
3944
|
+
} ? {
|
3945
|
+
[K in T[number]['name']]: TableType<T[number], K>;
|
3946
|
+
} : never : never;
|
3947
|
+
declare type TableType<Tables, TableName> = Tables & {
|
3948
|
+
name: TableName;
|
3949
|
+
} extends infer Table ? Table extends {
|
3950
|
+
name: string;
|
3951
|
+
columns: infer Columns;
|
3952
|
+
} ? Columns extends readonly unknown[] ? Columns[number] extends {
|
3953
|
+
name: string;
|
3954
|
+
type: string;
|
3955
|
+
} ? Identifiable & {
|
3956
|
+
[K in Columns[number]['name']]?: PropertyType<Tables, Columns[number], K>;
|
3957
|
+
} : never : never : never : never;
|
3958
|
+
declare type PropertyType<Tables, Properties, PropertyName> = Properties & {
|
3959
|
+
name: PropertyName;
|
3960
|
+
} extends infer Property ? Property extends {
|
3961
|
+
name: string;
|
3962
|
+
type: infer Type;
|
3963
|
+
link?: {
|
3964
|
+
table: infer LinkedTable;
|
3965
|
+
};
|
3966
|
+
columns?: infer ObjectColumns;
|
3967
|
+
} ? (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 {
|
3968
|
+
name: string;
|
3969
|
+
type: string;
|
3970
|
+
} ? {
|
3971
|
+
[K in ObjectColumns[number]['name']]?: PropertyType<Tables, ObjectColumns[number], K>;
|
3972
|
+
} : never : never : Type extends 'link' ? TableType<Tables, LinkedTable> & XataRecord : never) | null : never : never;
|
3973
|
+
|
3094
3974
|
/**
|
3095
3975
|
* Operator to restrict results to only values that are greater than the given value.
|
3096
3976
|
*/
|
@@ -3166,46 +4046,17 @@ declare const includesAny: <T>(value: T) => ArrayFilter<T>;
|
|
3166
4046
|
|
3167
4047
|
declare type SchemaDefinition = {
|
3168
4048
|
table: string;
|
3169
|
-
links?: LinkDictionary;
|
3170
4049
|
};
|
3171
4050
|
declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
|
3172
4051
|
[Key in keyof Schemas]: Repository<Schemas[Key]>;
|
4052
|
+
} & {
|
4053
|
+
[key: string]: Repository<XataRecord$1>;
|
3173
4054
|
};
|
3174
4055
|
declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
3175
4056
|
#private;
|
3176
|
-
|
3177
|
-
|
3178
|
-
constructor(links?: LinkDictionary | undefined, tableNames?: string[] | undefined);
|
3179
|
-
build(options: XataPluginOptions): SchemaPluginResult<Schemas>;
|
3180
|
-
}
|
3181
|
-
|
3182
|
-
declare type SearchOptions<Schemas extends Record<string, BaseData>, Tables extends StringKeys<Schemas>> = {
|
3183
|
-
fuzziness?: number;
|
3184
|
-
tables?: Tables[];
|
3185
|
-
};
|
3186
|
-
declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
|
3187
|
-
all: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<Values<{
|
3188
|
-
[Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]: {
|
3189
|
-
table: Model;
|
3190
|
-
record: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>>;
|
3191
|
-
};
|
3192
|
-
}>[]>;
|
3193
|
-
byTable: <Tables extends StringKeys<Schemas>>(query: string, options?: SearchOptions<Schemas, Tables>) => Promise<{
|
3194
|
-
[Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]?: Awaited<SelectedPick<Schemas[Model] & SearchXataRecord, ['*']>[]>;
|
3195
|
-
}>;
|
3196
|
-
};
|
3197
|
-
declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
3198
|
-
#private;
|
3199
|
-
private db;
|
3200
|
-
private links;
|
3201
|
-
constructor(db: SchemaPluginResult<Schemas>, links: LinkDictionary);
|
3202
|
-
build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
|
4057
|
+
constructor(schemaTables?: Schemas.Table[]);
|
4058
|
+
build(pluginOptions: XataPluginOptions): SchemaPluginResult<Schemas>;
|
3203
4059
|
}
|
3204
|
-
declare type SearchXataRecord = XataRecord & {
|
3205
|
-
xata: {
|
3206
|
-
table: string;
|
3207
|
-
};
|
3208
|
-
};
|
3209
4060
|
|
3210
4061
|
declare type BranchStrategyValue = string | undefined | null;
|
3211
4062
|
declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
|
@@ -3217,18 +4068,19 @@ declare type BaseClientOptions = {
|
|
3217
4068
|
apiKey?: string;
|
3218
4069
|
databaseURL?: string;
|
3219
4070
|
branch?: BranchStrategyOption;
|
4071
|
+
cache?: CacheImpl;
|
3220
4072
|
};
|
3221
4073
|
declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
|
3222
4074
|
interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
|
3223
|
-
new <
|
3224
|
-
db: Awaited<ReturnType<SchemaPlugin<
|
3225
|
-
search: Awaited<ReturnType<SearchPlugin<
|
4075
|
+
new <T extends readonly BaseSchema[]>(options?: Partial<BaseClientOptions>, schemaTables?: T): Omit<{
|
4076
|
+
db: Awaited<ReturnType<SchemaPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
|
4077
|
+
search: Awaited<ReturnType<SearchPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
|
3226
4078
|
}, keyof Plugins> & {
|
3227
4079
|
[Key in StringKeys<NonNullable<Plugins>>]: Awaited<ReturnType<NonNullable<Plugins>[Key]['build']>>;
|
3228
4080
|
};
|
3229
4081
|
}
|
3230
4082
|
declare const BaseClient_base: ClientConstructor<{}>;
|
3231
|
-
declare class BaseClient extends BaseClient_base<
|
4083
|
+
declare class BaseClient extends BaseClient_base<[]> {
|
3232
4084
|
}
|
3233
4085
|
|
3234
4086
|
declare type BranchResolutionOptions = {
|
@@ -3236,7 +4088,7 @@ declare type BranchResolutionOptions = {
|
|
3236
4088
|
apiKey?: string;
|
3237
4089
|
fetchImpl?: FetchImpl;
|
3238
4090
|
};
|
3239
|
-
declare function getCurrentBranchName(options?: BranchResolutionOptions): Promise<string
|
4091
|
+
declare function getCurrentBranchName(options?: BranchResolutionOptions): Promise<string>;
|
3240
4092
|
declare function getCurrentBranchDetails(options?: BranchResolutionOptions): Promise<DBBranch | null>;
|
3241
4093
|
declare function getDatabaseURL(): string | undefined;
|
3242
4094
|
|
@@ -3247,4 +4099,4 @@ declare class XataError extends Error {
|
|
3247
4099
|
constructor(message: string, status: number);
|
3248
4100
|
}
|
3249
4101
|
|
3250
|
-
export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams,
|
4102
|
+
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, 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, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
|