@xata.io/client 0.8.2 → 0.8.3
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/CHANGELOG.md +6 -0
- package/dist/index.cjs +1762 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2731 -7
- package/dist/index.mjs +1667 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +9 -5
- package/rollup.config.js +33 -0
- package/tsconfig.json +2 -2
- package/dist/api/client.d.ts +0 -95
- package/dist/api/client.js +0 -251
- package/dist/api/components.d.ts +0 -1437
- package/dist/api/components.js +0 -998
- package/dist/api/fetcher.d.ts +0 -40
- package/dist/api/fetcher.js +0 -79
- package/dist/api/index.d.ts +0 -13
- package/dist/api/index.js +0 -40
- package/dist/api/parameters.d.ts +0 -16
- package/dist/api/parameters.js +0 -2
- package/dist/api/providers.d.ts +0 -8
- package/dist/api/providers.js +0 -30
- package/dist/api/responses.d.ts +0 -50
- package/dist/api/responses.js +0 -2
- package/dist/api/schemas.d.ts +0 -311
- package/dist/api/schemas.js +0 -2
- package/dist/client.d.ts +0 -27
- package/dist/client.js +0 -131
- package/dist/index.js +0 -30
- package/dist/plugins.d.ts +0 -7
- package/dist/plugins.js +0 -6
- package/dist/schema/filters.d.ts +0 -96
- package/dist/schema/filters.js +0 -2
- package/dist/schema/filters.spec.d.ts +0 -1
- package/dist/schema/filters.spec.js +0 -177
- package/dist/schema/index.d.ts +0 -24
- package/dist/schema/index.js +0 -60
- package/dist/schema/operators.d.ts +0 -74
- package/dist/schema/operators.js +0 -93
- package/dist/schema/pagination.d.ts +0 -83
- package/dist/schema/pagination.js +0 -93
- package/dist/schema/query.d.ts +0 -118
- package/dist/schema/query.js +0 -242
- package/dist/schema/record.d.ts +0 -66
- package/dist/schema/record.js +0 -13
- package/dist/schema/repository.d.ts +0 -135
- package/dist/schema/repository.js +0 -283
- package/dist/schema/selection.d.ts +0 -25
- package/dist/schema/selection.js +0 -2
- package/dist/schema/selection.spec.d.ts +0 -1
- package/dist/schema/selection.spec.js +0 -204
- package/dist/schema/sorting.d.ts +0 -22
- package/dist/schema/sorting.js +0 -35
- package/dist/schema/sorting.spec.d.ts +0 -1
- package/dist/schema/sorting.spec.js +0 -11
- package/dist/search/index.d.ts +0 -34
- package/dist/search/index.js +0 -55
- package/dist/util/branches.d.ts +0 -5
- package/dist/util/branches.js +0 -7
- package/dist/util/config.d.ts +0 -11
- package/dist/util/config.js +0 -121
- package/dist/util/environment.d.ts +0 -5
- package/dist/util/environment.js +0 -68
- package/dist/util/fetch.d.ts +0 -2
- package/dist/util/fetch.js +0 -13
- package/dist/util/lang.d.ts +0 -5
- package/dist/util/lang.js +0 -22
- package/dist/util/types.d.ts +0 -25
- package/dist/util/types.js +0 -2
package/dist/index.d.ts
CHANGED
@@ -1,10 +1,2734 @@
|
|
1
|
-
|
1
|
+
declare type FetchImpl = (url: string, init?: {
|
2
|
+
body?: string;
|
3
|
+
headers?: Record<string, string>;
|
4
|
+
method?: string;
|
5
|
+
}) => Promise<{
|
6
|
+
ok: boolean;
|
7
|
+
status: number;
|
8
|
+
json(): Promise<any>;
|
9
|
+
}>;
|
10
|
+
declare type WorkspaceApiUrlBuilder = (path: string, pathParams: Record<string, string>) => string;
|
11
|
+
declare type FetcherExtraProps = {
|
12
|
+
apiUrl: string;
|
13
|
+
workspacesApiUrl: string | WorkspaceApiUrlBuilder;
|
14
|
+
fetchImpl: FetchImpl;
|
15
|
+
apiKey: string;
|
16
|
+
};
|
17
|
+
|
18
|
+
declare abstract class XataPlugin {
|
19
|
+
abstract build(options: XataPluginOptions): unknown | Promise<unknown>;
|
20
|
+
}
|
21
|
+
declare type XataPluginOptions = {
|
22
|
+
getFetchProps: () => Promise<FetcherExtraProps>;
|
23
|
+
};
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Generated by @openapi-codegen
|
27
|
+
*
|
28
|
+
* @version 1.0
|
29
|
+
*/
|
30
|
+
declare type User = {
|
31
|
+
email: string;
|
32
|
+
fullname: string;
|
33
|
+
image: string;
|
34
|
+
};
|
35
|
+
/**
|
36
|
+
* @pattern [a-zA-Z0-9_-~:]+
|
37
|
+
*/
|
38
|
+
declare type UserID = string;
|
39
|
+
declare type UserWithID = User & {
|
40
|
+
id: UserID;
|
41
|
+
};
|
42
|
+
/**
|
43
|
+
* @format date-time
|
44
|
+
* @x-go-type string
|
45
|
+
*/
|
46
|
+
declare type DateTime = string;
|
47
|
+
/**
|
48
|
+
* @pattern [a-zA-Z0-9_\-~]*
|
49
|
+
*/
|
50
|
+
declare type APIKeyName = string;
|
51
|
+
/**
|
52
|
+
* @pattern ^([a-zA-Z0-9][a-zA-Z0-9_\-~]+-)?[a-zA-Z0-9]{6}
|
53
|
+
* @x-go-type auth.WorkspaceID
|
54
|
+
*/
|
55
|
+
declare type WorkspaceID = string;
|
56
|
+
/**
|
57
|
+
* @x-go-type auth.Role
|
58
|
+
*/
|
59
|
+
declare type Role = 'owner' | 'maintainer';
|
60
|
+
declare type WorkspaceMeta = {
|
61
|
+
name: string;
|
62
|
+
slug: string;
|
63
|
+
};
|
64
|
+
declare type Workspace = WorkspaceMeta & {
|
65
|
+
id: WorkspaceID;
|
66
|
+
memberCount: number;
|
67
|
+
plan: 'free';
|
68
|
+
};
|
69
|
+
declare type WorkspaceMember = {
|
70
|
+
userId: UserID;
|
71
|
+
fullname: string;
|
72
|
+
email: string;
|
73
|
+
role: Role;
|
74
|
+
};
|
75
|
+
/**
|
76
|
+
* @pattern [a-zA-Z0-9]+
|
77
|
+
*/
|
78
|
+
declare type InviteID = string;
|
79
|
+
declare type WorkspaceInvite = {
|
80
|
+
inviteId: InviteID;
|
81
|
+
email: string;
|
82
|
+
expires: string;
|
83
|
+
role: Role;
|
84
|
+
};
|
85
|
+
declare type WorkspaceMembers = {
|
86
|
+
members: WorkspaceMember[];
|
87
|
+
invites: WorkspaceInvite[];
|
88
|
+
};
|
89
|
+
/**
|
90
|
+
* @pattern ^ik_[a-zA-Z0-9]+
|
91
|
+
*/
|
92
|
+
declare type InviteKey = string;
|
93
|
+
declare type ListDatabasesResponse = {
|
94
|
+
databases?: {
|
95
|
+
name: string;
|
96
|
+
displayName: string;
|
97
|
+
createdAt: DateTime;
|
98
|
+
numberOfBranches: number;
|
99
|
+
ui?: {
|
100
|
+
color?: string;
|
101
|
+
};
|
102
|
+
}[];
|
103
|
+
};
|
104
|
+
declare type ListBranchesResponse = {
|
105
|
+
databaseName: string;
|
106
|
+
displayName: string;
|
107
|
+
branches: Branch[];
|
108
|
+
};
|
109
|
+
declare type Branch = {
|
110
|
+
name: string;
|
111
|
+
createdAt: DateTime;
|
112
|
+
};
|
113
|
+
/**
|
114
|
+
* @example {"repository":"github.com/my/repository","branch":"feature-login","stage":"testing","labels":["epic-100"]}
|
115
|
+
* @x-go-type xata.BranchMetadata
|
116
|
+
*/
|
117
|
+
declare type BranchMetadata = {
|
118
|
+
repository?: string;
|
119
|
+
branch?: BranchName;
|
120
|
+
stage?: string;
|
121
|
+
labels?: string[];
|
122
|
+
};
|
123
|
+
declare type DBBranch = {
|
124
|
+
databaseName: DBName;
|
125
|
+
branchName: BranchName;
|
126
|
+
createdAt: DateTime;
|
127
|
+
id: string;
|
128
|
+
version: number;
|
129
|
+
lastMigrationID: string;
|
130
|
+
metadata?: BranchMetadata;
|
131
|
+
startedFrom?: StartedFromMetadata;
|
132
|
+
schema: Schema;
|
133
|
+
};
|
134
|
+
declare type StartedFromMetadata = {
|
135
|
+
branchName: BranchName;
|
136
|
+
dbBranchID: string;
|
137
|
+
migrationID: string;
|
138
|
+
};
|
139
|
+
/**
|
140
|
+
* @x-go-type xata.Schema
|
141
|
+
*/
|
142
|
+
declare type Schema = {
|
143
|
+
tables: Table[];
|
144
|
+
tablesOrder?: string[];
|
145
|
+
};
|
146
|
+
declare type Table = {
|
147
|
+
id?: string;
|
148
|
+
name: TableName;
|
149
|
+
columns: Column[];
|
150
|
+
revLinks?: RevLink[];
|
151
|
+
};
|
152
|
+
/**
|
153
|
+
* @x-go-type xata.Column
|
154
|
+
*/
|
155
|
+
declare type Column = {
|
156
|
+
name: string;
|
157
|
+
type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object';
|
158
|
+
link?: {
|
159
|
+
table: string;
|
160
|
+
};
|
161
|
+
columns?: Column[];
|
162
|
+
};
|
163
|
+
declare type RevLink = {
|
164
|
+
linkID: string;
|
165
|
+
table: string;
|
166
|
+
};
|
167
|
+
/**
|
168
|
+
* @pattern [a-zA-Z0-9_\-~]+
|
169
|
+
*/
|
170
|
+
declare type BranchName = string;
|
171
|
+
/**
|
172
|
+
* @pattern [a-zA-Z0-9_\-~]+
|
173
|
+
*/
|
174
|
+
declare type DBName = string;
|
175
|
+
/**
|
176
|
+
* The DBBranchName matches the pattern `{db_name}:{branch_name}`.
|
177
|
+
*
|
178
|
+
* @pattern [a-zA-Z0-9_\-~]+:[a-zA-Z0-9_\-~]+
|
179
|
+
*/
|
180
|
+
declare type DBBranchName = string;
|
181
|
+
/**
|
182
|
+
* @pattern [a-zA-Z0-9_\-~]+
|
183
|
+
*/
|
184
|
+
declare type TableName = string;
|
185
|
+
/**
|
186
|
+
* @pattern [a-zA-Z0-9_\-~\.]+
|
187
|
+
*/
|
188
|
+
declare type ColumnName = string;
|
189
|
+
declare type MetricsDatapoint = {
|
190
|
+
timestamp: string;
|
191
|
+
value: number;
|
192
|
+
};
|
193
|
+
declare type MetricsLatency = {
|
194
|
+
p50?: MetricsDatapoint[];
|
195
|
+
p90?: MetricsDatapoint[];
|
196
|
+
};
|
197
|
+
declare type BranchMigration = {
|
198
|
+
id?: string;
|
199
|
+
parentID?: string;
|
200
|
+
status: string;
|
201
|
+
title?: string;
|
202
|
+
lastGitRevision?: string;
|
203
|
+
localChanges: boolean;
|
204
|
+
createdAt?: DateTime;
|
205
|
+
newTables?: {
|
206
|
+
[key: string]: Table;
|
207
|
+
};
|
208
|
+
removedTables?: string[];
|
209
|
+
tableMigrations?: {
|
210
|
+
[key: string]: TableMigration;
|
211
|
+
};
|
212
|
+
newTableOrder: string[];
|
213
|
+
renamedTables?: TableRename[];
|
214
|
+
};
|
215
|
+
declare type TableMigration = {
|
216
|
+
newColumns?: {
|
217
|
+
[key: string]: Column;
|
218
|
+
};
|
219
|
+
removedColumns?: string[];
|
220
|
+
modifiedColumns?: ColumnMigration[];
|
221
|
+
newColumnOrder: string[];
|
222
|
+
};
|
223
|
+
declare type ColumnMigration = {
|
224
|
+
old: Column;
|
225
|
+
['new']: Column;
|
226
|
+
};
|
227
|
+
declare type SortExpression = string[] | {
|
228
|
+
[key: string]: SortOrder;
|
229
|
+
} | {
|
230
|
+
[key: string]: SortOrder;
|
231
|
+
}[];
|
232
|
+
declare type SortOrder = 'asc' | 'desc';
|
233
|
+
/**
|
234
|
+
* @minProperties 1
|
235
|
+
*/
|
236
|
+
declare type FilterExpression = {
|
237
|
+
$exists?: string;
|
238
|
+
$existsNot?: string;
|
239
|
+
$any?: FilterList;
|
240
|
+
$all?: FilterList;
|
241
|
+
$none?: FilterList;
|
242
|
+
$not?: FilterList;
|
243
|
+
} & {
|
244
|
+
[key: string]: FilterColumn;
|
245
|
+
};
|
246
|
+
declare type FilterList = FilterExpression | FilterExpression[];
|
247
|
+
declare type FilterColumn = FilterColumnIncludes | FilterPredicate | FilterList;
|
248
|
+
/**
|
249
|
+
* @maxProperties 1
|
250
|
+
* @minProperties 1
|
251
|
+
*/
|
252
|
+
declare type FilterColumnIncludes = {
|
253
|
+
$includes?: FilterPredicate;
|
254
|
+
$includesAny?: FilterPredicate;
|
255
|
+
$includesAll?: FilterPredicate;
|
256
|
+
$includesNone?: FilterPredicate;
|
257
|
+
};
|
258
|
+
declare type FilterPredicate = FilterValue | FilterPredicate[] | FilterPredicateOp | FilterPredicateRangeOp;
|
259
|
+
/**
|
260
|
+
* @maxProperties 1
|
261
|
+
* @minProperties 1
|
262
|
+
*/
|
263
|
+
declare type FilterPredicateOp = {
|
264
|
+
$any?: FilterPredicate[];
|
265
|
+
$all?: FilterPredicate[];
|
266
|
+
$none?: FilterPredicate | FilterPredicate[];
|
267
|
+
$not?: FilterPredicate | FilterPredicate[];
|
268
|
+
$is?: FilterValue | FilterValue[];
|
269
|
+
$isNot?: FilterValue | FilterValue[];
|
270
|
+
$lt?: FilterRangeValue;
|
271
|
+
$le?: FilterRangeValue;
|
272
|
+
$gt?: FilterRangeValue;
|
273
|
+
$ge?: FilterRangeValue;
|
274
|
+
$contains?: string;
|
275
|
+
$startsWith?: string;
|
276
|
+
$endsWith?: string;
|
277
|
+
$pattern?: string;
|
278
|
+
};
|
279
|
+
/**
|
280
|
+
* @maxProperties 2
|
281
|
+
* @minProperties 2
|
282
|
+
*/
|
283
|
+
declare type FilterPredicateRangeOp = {
|
284
|
+
$lt?: FilterRangeValue;
|
285
|
+
$le?: FilterRangeValue;
|
286
|
+
$gt?: FilterRangeValue;
|
287
|
+
$ge?: FilterRangeValue;
|
288
|
+
};
|
289
|
+
declare type FilterRangeValue = number | string;
|
290
|
+
declare type FilterValue = number | string | boolean;
|
291
|
+
/**
|
292
|
+
* Pagination settings.
|
293
|
+
*/
|
294
|
+
declare type PageConfig = {
|
295
|
+
after?: string;
|
296
|
+
before?: string;
|
297
|
+
first?: string;
|
298
|
+
last?: string;
|
299
|
+
size?: number;
|
300
|
+
offset?: number;
|
301
|
+
};
|
302
|
+
declare type ColumnsFilter = string[];
|
303
|
+
/**
|
304
|
+
* @pattern [a-zA-Z0-9_-~:]+
|
305
|
+
*/
|
306
|
+
declare type RecordID = string;
|
307
|
+
/**
|
308
|
+
* @example {"newName":"newName","oldName":"oldName"}
|
309
|
+
*/
|
310
|
+
declare type TableRename = {
|
311
|
+
newName: string;
|
312
|
+
oldName: string;
|
313
|
+
};
|
314
|
+
/**
|
315
|
+
* Records metadata
|
316
|
+
*/
|
317
|
+
declare type RecordsMetadata = {
|
318
|
+
page: {
|
319
|
+
cursor: string;
|
320
|
+
more: boolean;
|
321
|
+
};
|
322
|
+
};
|
323
|
+
/**
|
324
|
+
* Xata Table Record
|
325
|
+
*/
|
326
|
+
declare type XataRecord$1 = {
|
327
|
+
id: RecordID;
|
328
|
+
xata: {
|
329
|
+
version: number;
|
330
|
+
table?: string;
|
331
|
+
warnings?: string[];
|
332
|
+
};
|
333
|
+
} & {
|
334
|
+
[key: string]: any;
|
335
|
+
};
|
336
|
+
|
337
|
+
type schemas_User = User;
|
338
|
+
type schemas_UserID = UserID;
|
339
|
+
type schemas_UserWithID = UserWithID;
|
340
|
+
type schemas_DateTime = DateTime;
|
341
|
+
type schemas_APIKeyName = APIKeyName;
|
342
|
+
type schemas_WorkspaceID = WorkspaceID;
|
343
|
+
type schemas_Role = Role;
|
344
|
+
type schemas_WorkspaceMeta = WorkspaceMeta;
|
345
|
+
type schemas_Workspace = Workspace;
|
346
|
+
type schemas_WorkspaceMember = WorkspaceMember;
|
347
|
+
type schemas_InviteID = InviteID;
|
348
|
+
type schemas_WorkspaceInvite = WorkspaceInvite;
|
349
|
+
type schemas_WorkspaceMembers = WorkspaceMembers;
|
350
|
+
type schemas_InviteKey = InviteKey;
|
351
|
+
type schemas_ListDatabasesResponse = ListDatabasesResponse;
|
352
|
+
type schemas_ListBranchesResponse = ListBranchesResponse;
|
353
|
+
type schemas_Branch = Branch;
|
354
|
+
type schemas_BranchMetadata = BranchMetadata;
|
355
|
+
type schemas_DBBranch = DBBranch;
|
356
|
+
type schemas_StartedFromMetadata = StartedFromMetadata;
|
357
|
+
type schemas_Schema = Schema;
|
358
|
+
type schemas_Table = Table;
|
359
|
+
type schemas_Column = Column;
|
360
|
+
type schemas_RevLink = RevLink;
|
361
|
+
type schemas_BranchName = BranchName;
|
362
|
+
type schemas_DBName = DBName;
|
363
|
+
type schemas_DBBranchName = DBBranchName;
|
364
|
+
type schemas_TableName = TableName;
|
365
|
+
type schemas_ColumnName = ColumnName;
|
366
|
+
type schemas_MetricsDatapoint = MetricsDatapoint;
|
367
|
+
type schemas_MetricsLatency = MetricsLatency;
|
368
|
+
type schemas_BranchMigration = BranchMigration;
|
369
|
+
type schemas_TableMigration = TableMigration;
|
370
|
+
type schemas_ColumnMigration = ColumnMigration;
|
371
|
+
type schemas_SortExpression = SortExpression;
|
372
|
+
type schemas_SortOrder = SortOrder;
|
373
|
+
type schemas_FilterExpression = FilterExpression;
|
374
|
+
type schemas_FilterList = FilterList;
|
375
|
+
type schemas_FilterColumn = FilterColumn;
|
376
|
+
type schemas_FilterColumnIncludes = FilterColumnIncludes;
|
377
|
+
type schemas_FilterPredicate = FilterPredicate;
|
378
|
+
type schemas_FilterPredicateOp = FilterPredicateOp;
|
379
|
+
type schemas_FilterPredicateRangeOp = FilterPredicateRangeOp;
|
380
|
+
type schemas_FilterRangeValue = FilterRangeValue;
|
381
|
+
type schemas_FilterValue = FilterValue;
|
382
|
+
type schemas_PageConfig = PageConfig;
|
383
|
+
type schemas_ColumnsFilter = ColumnsFilter;
|
384
|
+
type schemas_RecordID = RecordID;
|
385
|
+
type schemas_TableRename = TableRename;
|
386
|
+
type schemas_RecordsMetadata = RecordsMetadata;
|
387
|
+
declare namespace schemas {
|
388
|
+
export {
|
389
|
+
schemas_User as User,
|
390
|
+
schemas_UserID as UserID,
|
391
|
+
schemas_UserWithID as UserWithID,
|
392
|
+
schemas_DateTime as DateTime,
|
393
|
+
schemas_APIKeyName as APIKeyName,
|
394
|
+
schemas_WorkspaceID as WorkspaceID,
|
395
|
+
schemas_Role as Role,
|
396
|
+
schemas_WorkspaceMeta as WorkspaceMeta,
|
397
|
+
schemas_Workspace as Workspace,
|
398
|
+
schemas_WorkspaceMember as WorkspaceMember,
|
399
|
+
schemas_InviteID as InviteID,
|
400
|
+
schemas_WorkspaceInvite as WorkspaceInvite,
|
401
|
+
schemas_WorkspaceMembers as WorkspaceMembers,
|
402
|
+
schemas_InviteKey as InviteKey,
|
403
|
+
schemas_ListDatabasesResponse as ListDatabasesResponse,
|
404
|
+
schemas_ListBranchesResponse as ListBranchesResponse,
|
405
|
+
schemas_Branch as Branch,
|
406
|
+
schemas_BranchMetadata as BranchMetadata,
|
407
|
+
schemas_DBBranch as DBBranch,
|
408
|
+
schemas_StartedFromMetadata as StartedFromMetadata,
|
409
|
+
schemas_Schema as Schema,
|
410
|
+
schemas_Table as Table,
|
411
|
+
schemas_Column as Column,
|
412
|
+
schemas_RevLink as RevLink,
|
413
|
+
schemas_BranchName as BranchName,
|
414
|
+
schemas_DBName as DBName,
|
415
|
+
schemas_DBBranchName as DBBranchName,
|
416
|
+
schemas_TableName as TableName,
|
417
|
+
schemas_ColumnName as ColumnName,
|
418
|
+
schemas_MetricsDatapoint as MetricsDatapoint,
|
419
|
+
schemas_MetricsLatency as MetricsLatency,
|
420
|
+
schemas_BranchMigration as BranchMigration,
|
421
|
+
schemas_TableMigration as TableMigration,
|
422
|
+
schemas_ColumnMigration as ColumnMigration,
|
423
|
+
schemas_SortExpression as SortExpression,
|
424
|
+
schemas_SortOrder as SortOrder,
|
425
|
+
schemas_FilterExpression as FilterExpression,
|
426
|
+
schemas_FilterList as FilterList,
|
427
|
+
schemas_FilterColumn as FilterColumn,
|
428
|
+
schemas_FilterColumnIncludes as FilterColumnIncludes,
|
429
|
+
schemas_FilterPredicate as FilterPredicate,
|
430
|
+
schemas_FilterPredicateOp as FilterPredicateOp,
|
431
|
+
schemas_FilterPredicateRangeOp as FilterPredicateRangeOp,
|
432
|
+
schemas_FilterRangeValue as FilterRangeValue,
|
433
|
+
schemas_FilterValue as FilterValue,
|
434
|
+
schemas_PageConfig as PageConfig,
|
435
|
+
schemas_ColumnsFilter as ColumnsFilter,
|
436
|
+
schemas_RecordID as RecordID,
|
437
|
+
schemas_TableRename as TableRename,
|
438
|
+
schemas_RecordsMetadata as RecordsMetadata,
|
439
|
+
XataRecord$1 as XataRecord,
|
440
|
+
};
|
441
|
+
}
|
442
|
+
|
443
|
+
/**
|
444
|
+
* Generated by @openapi-codegen
|
445
|
+
*
|
446
|
+
* @version 1.0
|
447
|
+
*/
|
448
|
+
|
449
|
+
declare type SimpleError = {
|
450
|
+
id?: string;
|
451
|
+
message: string;
|
452
|
+
};
|
453
|
+
declare type BadRequestError = {
|
454
|
+
id?: string;
|
455
|
+
message: string;
|
456
|
+
};
|
457
|
+
/**
|
458
|
+
* @example {"message":"invalid API key"}
|
459
|
+
*/
|
460
|
+
declare type AuthError = {
|
461
|
+
id?: string;
|
462
|
+
message: string;
|
463
|
+
};
|
464
|
+
declare type BulkError = {
|
465
|
+
errors: {
|
466
|
+
message?: string;
|
467
|
+
status?: number;
|
468
|
+
}[];
|
469
|
+
};
|
470
|
+
declare type BranchMigrationPlan = {
|
471
|
+
version: number;
|
472
|
+
migration: BranchMigration;
|
473
|
+
};
|
474
|
+
declare type RecordUpdateResponse = {
|
475
|
+
id: string;
|
476
|
+
xata: {
|
477
|
+
version: number;
|
478
|
+
};
|
479
|
+
};
|
480
|
+
declare type QueryResponse = {
|
481
|
+
records: XataRecord$1[];
|
482
|
+
meta: RecordsMetadata;
|
483
|
+
};
|
484
|
+
declare type SearchResponse = {
|
485
|
+
records: XataRecord$1[];
|
486
|
+
};
|
487
|
+
/**
|
488
|
+
* @example {"migrationID":"mig_c7m19ilcefoebpqj12p0"}
|
489
|
+
*/
|
490
|
+
declare type MigrationIdResponse = {
|
491
|
+
migrationID: string;
|
492
|
+
};
|
493
|
+
|
494
|
+
type responses_SimpleError = SimpleError;
|
495
|
+
type responses_BadRequestError = BadRequestError;
|
496
|
+
type responses_AuthError = AuthError;
|
497
|
+
type responses_BulkError = BulkError;
|
498
|
+
type responses_BranchMigrationPlan = BranchMigrationPlan;
|
499
|
+
type responses_RecordUpdateResponse = RecordUpdateResponse;
|
500
|
+
type responses_QueryResponse = QueryResponse;
|
501
|
+
type responses_SearchResponse = SearchResponse;
|
502
|
+
type responses_MigrationIdResponse = MigrationIdResponse;
|
503
|
+
declare namespace responses {
|
504
|
+
export {
|
505
|
+
responses_SimpleError as SimpleError,
|
506
|
+
responses_BadRequestError as BadRequestError,
|
507
|
+
responses_AuthError as AuthError,
|
508
|
+
responses_BulkError as BulkError,
|
509
|
+
responses_BranchMigrationPlan as BranchMigrationPlan,
|
510
|
+
responses_RecordUpdateResponse as RecordUpdateResponse,
|
511
|
+
responses_QueryResponse as QueryResponse,
|
512
|
+
responses_SearchResponse as SearchResponse,
|
513
|
+
responses_MigrationIdResponse as MigrationIdResponse,
|
514
|
+
};
|
515
|
+
}
|
516
|
+
|
517
|
+
/**
|
518
|
+
* Generated by @openapi-codegen
|
519
|
+
*
|
520
|
+
* @version 1.0
|
521
|
+
*/
|
522
|
+
|
523
|
+
declare type GetUserVariables = FetcherExtraProps;
|
524
|
+
/**
|
525
|
+
* Return details of the user making the request
|
526
|
+
*/
|
527
|
+
declare const getUser: (variables: GetUserVariables) => Promise<UserWithID>;
|
528
|
+
declare type UpdateUserVariables = {
|
529
|
+
body: User;
|
530
|
+
} & FetcherExtraProps;
|
531
|
+
/**
|
532
|
+
* Update user info
|
533
|
+
*/
|
534
|
+
declare const updateUser: (variables: UpdateUserVariables) => Promise<UserWithID>;
|
535
|
+
declare type DeleteUserVariables = FetcherExtraProps;
|
536
|
+
/**
|
537
|
+
* Delete the user making the request
|
538
|
+
*/
|
539
|
+
declare const deleteUser: (variables: DeleteUserVariables) => Promise<undefined>;
|
540
|
+
declare type GetUserAPIKeysResponse = {
|
541
|
+
keys: {
|
542
|
+
name: string;
|
543
|
+
createdAt: DateTime;
|
544
|
+
}[];
|
545
|
+
};
|
546
|
+
declare type GetUserAPIKeysVariables = FetcherExtraProps;
|
547
|
+
/**
|
548
|
+
* Retrieve a list of existing user API keys
|
549
|
+
*/
|
550
|
+
declare const getUserAPIKeys: (variables: GetUserAPIKeysVariables) => Promise<GetUserAPIKeysResponse>;
|
551
|
+
declare type CreateUserAPIKeyPathParams = {
|
552
|
+
keyName: APIKeyName;
|
553
|
+
};
|
554
|
+
declare type CreateUserAPIKeyResponse = {
|
555
|
+
name: string;
|
556
|
+
key: string;
|
557
|
+
createdAt: DateTime;
|
558
|
+
};
|
559
|
+
declare type CreateUserAPIKeyVariables = {
|
560
|
+
pathParams: CreateUserAPIKeyPathParams;
|
561
|
+
} & FetcherExtraProps;
|
562
|
+
/**
|
563
|
+
* Create and return new API key
|
564
|
+
*/
|
565
|
+
declare const createUserAPIKey: (variables: CreateUserAPIKeyVariables) => Promise<CreateUserAPIKeyResponse>;
|
566
|
+
declare type DeleteUserAPIKeyPathParams = {
|
567
|
+
keyName: APIKeyName;
|
568
|
+
};
|
569
|
+
declare type DeleteUserAPIKeyVariables = {
|
570
|
+
pathParams: DeleteUserAPIKeyPathParams;
|
571
|
+
} & FetcherExtraProps;
|
572
|
+
/**
|
573
|
+
* Delete an existing API key
|
574
|
+
*/
|
575
|
+
declare const deleteUserAPIKey: (variables: DeleteUserAPIKeyVariables) => Promise<undefined>;
|
576
|
+
declare type CreateWorkspaceVariables = {
|
577
|
+
body: WorkspaceMeta;
|
578
|
+
} & FetcherExtraProps;
|
579
|
+
/**
|
580
|
+
* Creates a new workspace with the user requesting it as its single owner.
|
581
|
+
*/
|
582
|
+
declare const createWorkspace: (variables: CreateWorkspaceVariables) => Promise<Workspace>;
|
583
|
+
declare type GetWorkspacesListResponse = {
|
584
|
+
workspaces: {
|
585
|
+
id: WorkspaceID;
|
586
|
+
name: string;
|
587
|
+
slug: string;
|
588
|
+
role: Role;
|
589
|
+
}[];
|
590
|
+
};
|
591
|
+
declare type GetWorkspacesListVariables = FetcherExtraProps;
|
592
|
+
/**
|
593
|
+
* Retrieve the list of workspaces the user belongs to
|
594
|
+
*/
|
595
|
+
declare const getWorkspacesList: (variables: GetWorkspacesListVariables) => Promise<GetWorkspacesListResponse>;
|
596
|
+
declare type GetWorkspacePathParams = {
|
597
|
+
workspaceId: WorkspaceID;
|
598
|
+
};
|
599
|
+
declare type GetWorkspaceVariables = {
|
600
|
+
pathParams: GetWorkspacePathParams;
|
601
|
+
} & FetcherExtraProps;
|
602
|
+
/**
|
603
|
+
* Retrieve workspace info from a workspace ID
|
604
|
+
*/
|
605
|
+
declare const getWorkspace: (variables: GetWorkspaceVariables) => Promise<Workspace>;
|
606
|
+
declare type UpdateWorkspacePathParams = {
|
607
|
+
workspaceId: WorkspaceID;
|
608
|
+
};
|
609
|
+
declare type UpdateWorkspaceVariables = {
|
610
|
+
body: WorkspaceMeta;
|
611
|
+
pathParams: UpdateWorkspacePathParams;
|
612
|
+
} & FetcherExtraProps;
|
613
|
+
/**
|
614
|
+
* Update workspace info
|
615
|
+
*/
|
616
|
+
declare const updateWorkspace: (variables: UpdateWorkspaceVariables) => Promise<Workspace>;
|
617
|
+
declare type DeleteWorkspacePathParams = {
|
618
|
+
workspaceId: WorkspaceID;
|
619
|
+
};
|
620
|
+
declare type DeleteWorkspaceVariables = {
|
621
|
+
pathParams: DeleteWorkspacePathParams;
|
622
|
+
} & FetcherExtraProps;
|
623
|
+
/**
|
624
|
+
* Delete the workspace with the provided ID
|
625
|
+
*/
|
626
|
+
declare const deleteWorkspace: (variables: DeleteWorkspaceVariables) => Promise<undefined>;
|
627
|
+
declare type GetWorkspaceMembersListPathParams = {
|
628
|
+
workspaceId: WorkspaceID;
|
629
|
+
};
|
630
|
+
declare type GetWorkspaceMembersListVariables = {
|
631
|
+
pathParams: GetWorkspaceMembersListPathParams;
|
632
|
+
} & FetcherExtraProps;
|
633
|
+
/**
|
634
|
+
* Retrieve the list of members of the given workspace
|
635
|
+
*/
|
636
|
+
declare const getWorkspaceMembersList: (variables: GetWorkspaceMembersListVariables) => Promise<WorkspaceMembers>;
|
637
|
+
declare type UpdateWorkspaceMemberRolePathParams = {
|
638
|
+
workspaceId: WorkspaceID;
|
639
|
+
userId: UserID;
|
640
|
+
};
|
641
|
+
declare type UpdateWorkspaceMemberRoleRequestBody = {
|
642
|
+
role: Role;
|
643
|
+
};
|
644
|
+
declare type UpdateWorkspaceMemberRoleVariables = {
|
645
|
+
body: UpdateWorkspaceMemberRoleRequestBody;
|
646
|
+
pathParams: UpdateWorkspaceMemberRolePathParams;
|
647
|
+
} & FetcherExtraProps;
|
648
|
+
/**
|
649
|
+
* Update a workspace member role. Workspaces must always have at least one owner, so this operation will fail if trying to remove owner role from the last owner in the workspace.
|
650
|
+
*/
|
651
|
+
declare const updateWorkspaceMemberRole: (variables: UpdateWorkspaceMemberRoleVariables) => Promise<undefined>;
|
652
|
+
declare type RemoveWorkspaceMemberPathParams = {
|
653
|
+
workspaceId: WorkspaceID;
|
654
|
+
userId: UserID;
|
655
|
+
};
|
656
|
+
declare type RemoveWorkspaceMemberVariables = {
|
657
|
+
pathParams: RemoveWorkspaceMemberPathParams;
|
658
|
+
} & FetcherExtraProps;
|
659
|
+
/**
|
660
|
+
* Remove the member from the workspace
|
661
|
+
*/
|
662
|
+
declare const removeWorkspaceMember: (variables: RemoveWorkspaceMemberVariables) => Promise<undefined>;
|
663
|
+
declare type InviteWorkspaceMemberPathParams = {
|
664
|
+
workspaceId: WorkspaceID;
|
665
|
+
};
|
666
|
+
declare type InviteWorkspaceMemberRequestBody = {
|
667
|
+
email: string;
|
668
|
+
role: Role;
|
669
|
+
};
|
670
|
+
declare type InviteWorkspaceMemberVariables = {
|
671
|
+
body: InviteWorkspaceMemberRequestBody;
|
672
|
+
pathParams: InviteWorkspaceMemberPathParams;
|
673
|
+
} & FetcherExtraProps;
|
674
|
+
/**
|
675
|
+
* Invite some user to join the workspace with the given role
|
676
|
+
*/
|
677
|
+
declare const inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<WorkspaceInvite>;
|
678
|
+
declare type CancelWorkspaceMemberInvitePathParams = {
|
679
|
+
workspaceId: WorkspaceID;
|
680
|
+
inviteId: InviteID;
|
681
|
+
};
|
682
|
+
declare type CancelWorkspaceMemberInviteVariables = {
|
683
|
+
pathParams: CancelWorkspaceMemberInvitePathParams;
|
684
|
+
} & FetcherExtraProps;
|
685
|
+
/**
|
686
|
+
* This operation provides a way to cancel invites by deleting them. Already accepted invites cannot be deleted.
|
687
|
+
*/
|
688
|
+
declare const cancelWorkspaceMemberInvite: (variables: CancelWorkspaceMemberInviteVariables) => Promise<undefined>;
|
689
|
+
declare type ResendWorkspaceMemberInvitePathParams = {
|
690
|
+
workspaceId: WorkspaceID;
|
691
|
+
inviteId: InviteID;
|
692
|
+
};
|
693
|
+
declare type ResendWorkspaceMemberInviteVariables = {
|
694
|
+
pathParams: ResendWorkspaceMemberInvitePathParams;
|
695
|
+
} & FetcherExtraProps;
|
696
|
+
/**
|
697
|
+
* This operation provides a way to resend an Invite notification. Invite notifications can only be sent for Invites not yet accepted.
|
698
|
+
*/
|
699
|
+
declare const resendWorkspaceMemberInvite: (variables: ResendWorkspaceMemberInviteVariables) => Promise<undefined>;
|
700
|
+
declare type AcceptWorkspaceMemberInvitePathParams = {
|
701
|
+
workspaceId: WorkspaceID;
|
702
|
+
inviteKey: InviteKey;
|
703
|
+
};
|
704
|
+
declare type AcceptWorkspaceMemberInviteVariables = {
|
705
|
+
pathParams: AcceptWorkspaceMemberInvitePathParams;
|
706
|
+
} & FetcherExtraProps;
|
707
|
+
/**
|
708
|
+
* Accept the invitation to join a workspace. If the operation succeeds the user will be a member of the workspace
|
709
|
+
*/
|
710
|
+
declare const acceptWorkspaceMemberInvite: (variables: AcceptWorkspaceMemberInviteVariables) => Promise<undefined>;
|
711
|
+
declare type GetDatabaseListPathParams = {
|
712
|
+
workspace: string;
|
713
|
+
};
|
714
|
+
declare type GetDatabaseListVariables = {
|
715
|
+
pathParams: GetDatabaseListPathParams;
|
716
|
+
} & FetcherExtraProps;
|
717
|
+
/**
|
718
|
+
* List all databases available in your Workspace.
|
719
|
+
*/
|
720
|
+
declare const getDatabaseList: (variables: GetDatabaseListVariables) => Promise<ListDatabasesResponse>;
|
721
|
+
declare type GetBranchListPathParams = {
|
722
|
+
dbName: DBName;
|
723
|
+
workspace: string;
|
724
|
+
};
|
725
|
+
declare type GetBranchListVariables = {
|
726
|
+
pathParams: GetBranchListPathParams;
|
727
|
+
} & FetcherExtraProps;
|
728
|
+
/**
|
729
|
+
* List all available Branches
|
730
|
+
*/
|
731
|
+
declare const getBranchList: (variables: GetBranchListVariables) => Promise<ListBranchesResponse>;
|
732
|
+
declare type CreateDatabasePathParams = {
|
733
|
+
dbName: DBName;
|
734
|
+
workspace: string;
|
735
|
+
};
|
736
|
+
declare type CreateDatabaseResponse = {
|
737
|
+
databaseName: string;
|
738
|
+
branchName?: string;
|
739
|
+
};
|
740
|
+
declare type CreateDatabaseRequestBody = {
|
741
|
+
displayName?: string;
|
742
|
+
branchName?: string;
|
743
|
+
ui?: {
|
744
|
+
color?: string;
|
745
|
+
};
|
746
|
+
metadata?: BranchMetadata;
|
747
|
+
};
|
748
|
+
declare type CreateDatabaseVariables = {
|
749
|
+
body?: CreateDatabaseRequestBody;
|
750
|
+
pathParams: CreateDatabasePathParams;
|
751
|
+
} & FetcherExtraProps;
|
752
|
+
/**
|
753
|
+
* Create Database with identifier name
|
754
|
+
*/
|
755
|
+
declare const createDatabase: (variables: CreateDatabaseVariables) => Promise<CreateDatabaseResponse>;
|
756
|
+
declare type DeleteDatabasePathParams = {
|
757
|
+
dbName: DBName;
|
758
|
+
workspace: string;
|
759
|
+
};
|
760
|
+
declare type DeleteDatabaseVariables = {
|
761
|
+
pathParams: DeleteDatabasePathParams;
|
762
|
+
} & FetcherExtraProps;
|
763
|
+
/**
|
764
|
+
* Delete a database and all of its branches and tables permanently.
|
765
|
+
*/
|
766
|
+
declare const deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
|
767
|
+
declare type GetBranchDetailsPathParams = {
|
768
|
+
dbBranchName: DBBranchName;
|
769
|
+
workspace: string;
|
770
|
+
};
|
771
|
+
declare type GetBranchDetailsVariables = {
|
772
|
+
pathParams: GetBranchDetailsPathParams;
|
773
|
+
} & FetcherExtraProps;
|
774
|
+
declare const getBranchDetails: (variables: GetBranchDetailsVariables) => Promise<DBBranch>;
|
775
|
+
declare type CreateBranchPathParams = {
|
776
|
+
dbBranchName: DBBranchName;
|
777
|
+
workspace: string;
|
778
|
+
};
|
779
|
+
declare type CreateBranchQueryParams = {
|
780
|
+
from?: string;
|
781
|
+
};
|
782
|
+
declare type CreateBranchRequestBody = {
|
783
|
+
from?: string;
|
784
|
+
metadata?: BranchMetadata;
|
785
|
+
};
|
786
|
+
declare type CreateBranchVariables = {
|
787
|
+
body?: CreateBranchRequestBody;
|
788
|
+
pathParams: CreateBranchPathParams;
|
789
|
+
queryParams?: CreateBranchQueryParams;
|
790
|
+
} & FetcherExtraProps;
|
791
|
+
declare const createBranch: (variables: CreateBranchVariables) => Promise<undefined>;
|
792
|
+
declare type DeleteBranchPathParams = {
|
793
|
+
dbBranchName: DBBranchName;
|
794
|
+
workspace: string;
|
795
|
+
};
|
796
|
+
declare type DeleteBranchVariables = {
|
797
|
+
pathParams: DeleteBranchPathParams;
|
798
|
+
} & FetcherExtraProps;
|
799
|
+
/**
|
800
|
+
* Delete the branch in the database and all its resources
|
801
|
+
*/
|
802
|
+
declare const deleteBranch: (variables: DeleteBranchVariables) => Promise<undefined>;
|
803
|
+
declare type UpdateBranchMetadataPathParams = {
|
804
|
+
dbBranchName: DBBranchName;
|
805
|
+
workspace: string;
|
806
|
+
};
|
807
|
+
declare type UpdateBranchMetadataVariables = {
|
808
|
+
body?: BranchMetadata;
|
809
|
+
pathParams: UpdateBranchMetadataPathParams;
|
810
|
+
} & FetcherExtraProps;
|
811
|
+
/**
|
812
|
+
* Update the branch metadata
|
813
|
+
*/
|
814
|
+
declare const updateBranchMetadata: (variables: UpdateBranchMetadataVariables) => Promise<undefined>;
|
815
|
+
declare type GetBranchMetadataPathParams = {
|
816
|
+
dbBranchName: DBBranchName;
|
817
|
+
workspace: string;
|
818
|
+
};
|
819
|
+
declare type GetBranchMetadataVariables = {
|
820
|
+
pathParams: GetBranchMetadataPathParams;
|
821
|
+
} & FetcherExtraProps;
|
822
|
+
declare const getBranchMetadata: (variables: GetBranchMetadataVariables) => Promise<BranchMetadata>;
|
823
|
+
declare type GetBranchMigrationHistoryPathParams = {
|
824
|
+
dbBranchName: DBBranchName;
|
825
|
+
workspace: string;
|
826
|
+
};
|
827
|
+
declare type GetBranchMigrationHistoryResponse = {
|
828
|
+
startedFrom?: StartedFromMetadata;
|
829
|
+
migrations?: BranchMigration[];
|
830
|
+
};
|
831
|
+
declare type GetBranchMigrationHistoryRequestBody = {
|
832
|
+
limit?: number;
|
833
|
+
startFrom?: string;
|
834
|
+
};
|
835
|
+
declare type GetBranchMigrationHistoryVariables = {
|
836
|
+
body?: GetBranchMigrationHistoryRequestBody;
|
837
|
+
pathParams: GetBranchMigrationHistoryPathParams;
|
838
|
+
} & FetcherExtraProps;
|
839
|
+
declare const getBranchMigrationHistory: (variables: GetBranchMigrationHistoryVariables) => Promise<GetBranchMigrationHistoryResponse>;
|
840
|
+
declare type ExecuteBranchMigrationPlanPathParams = {
|
841
|
+
dbBranchName: DBBranchName;
|
842
|
+
workspace: string;
|
843
|
+
};
|
844
|
+
declare type ExecuteBranchMigrationPlanRequestBody = {
|
845
|
+
version: number;
|
846
|
+
migration: BranchMigration;
|
847
|
+
};
|
848
|
+
declare type ExecuteBranchMigrationPlanVariables = {
|
849
|
+
body: ExecuteBranchMigrationPlanRequestBody;
|
850
|
+
pathParams: ExecuteBranchMigrationPlanPathParams;
|
851
|
+
} & FetcherExtraProps;
|
852
|
+
/**
|
853
|
+
* Apply a migration plan to the branch
|
854
|
+
*/
|
855
|
+
declare const executeBranchMigrationPlan: (variables: ExecuteBranchMigrationPlanVariables) => Promise<undefined>;
|
856
|
+
declare type GetBranchMigrationPlanPathParams = {
|
857
|
+
dbBranchName: DBBranchName;
|
858
|
+
workspace: string;
|
859
|
+
};
|
860
|
+
declare type GetBranchMigrationPlanVariables = {
|
861
|
+
body: Schema;
|
862
|
+
pathParams: GetBranchMigrationPlanPathParams;
|
863
|
+
} & FetcherExtraProps;
|
864
|
+
/**
|
865
|
+
* Compute a migration plan from a target schema the branch should be migrated too.
|
866
|
+
*/
|
867
|
+
declare const getBranchMigrationPlan: (variables: GetBranchMigrationPlanVariables) => Promise<BranchMigrationPlan>;
|
868
|
+
declare type GetBranchStatsPathParams = {
|
869
|
+
dbBranchName: DBBranchName;
|
870
|
+
workspace: string;
|
871
|
+
};
|
872
|
+
declare type GetBranchStatsResponse = {
|
873
|
+
timestamp: string;
|
874
|
+
interval: string;
|
875
|
+
resolution: string;
|
876
|
+
numberOfRecords?: MetricsDatapoint[];
|
877
|
+
writesOverTime?: MetricsDatapoint[];
|
878
|
+
readsOverTime?: MetricsDatapoint[];
|
879
|
+
readLatency?: MetricsLatency;
|
880
|
+
writeLatency?: MetricsLatency;
|
881
|
+
warning?: string;
|
882
|
+
};
|
883
|
+
declare type GetBranchStatsVariables = {
|
884
|
+
pathParams: GetBranchStatsPathParams;
|
885
|
+
} & FetcherExtraProps;
|
886
|
+
/**
|
887
|
+
* Get branch usage metrics.
|
888
|
+
*/
|
889
|
+
declare const getBranchStats: (variables: GetBranchStatsVariables) => Promise<GetBranchStatsResponse>;
|
890
|
+
declare type CreateTablePathParams = {
|
891
|
+
dbBranchName: DBBranchName;
|
892
|
+
tableName: TableName;
|
893
|
+
workspace: string;
|
894
|
+
};
|
895
|
+
declare type CreateTableVariables = {
|
896
|
+
pathParams: CreateTablePathParams;
|
897
|
+
} & FetcherExtraProps;
|
898
|
+
/**
|
899
|
+
* Creates a new table with the given name. Returns 422 if a table with the same name already exists.
|
900
|
+
*/
|
901
|
+
declare const createTable: (variables: CreateTableVariables) => Promise<undefined>;
|
902
|
+
declare type DeleteTablePathParams = {
|
903
|
+
dbBranchName: DBBranchName;
|
904
|
+
tableName: TableName;
|
905
|
+
workspace: string;
|
906
|
+
};
|
907
|
+
declare type DeleteTableVariables = {
|
908
|
+
pathParams: DeleteTablePathParams;
|
909
|
+
} & FetcherExtraProps;
|
910
|
+
/**
|
911
|
+
* Deletes the table with the given name.
|
912
|
+
*/
|
913
|
+
declare const deleteTable: (variables: DeleteTableVariables) => Promise<undefined>;
|
914
|
+
declare type UpdateTablePathParams = {
|
915
|
+
dbBranchName: DBBranchName;
|
916
|
+
tableName: TableName;
|
917
|
+
workspace: string;
|
918
|
+
};
|
919
|
+
declare type UpdateTableRequestBody = {
|
920
|
+
name: string;
|
921
|
+
};
|
922
|
+
declare type UpdateTableVariables = {
|
923
|
+
body: UpdateTableRequestBody;
|
924
|
+
pathParams: UpdateTablePathParams;
|
925
|
+
} & FetcherExtraProps;
|
926
|
+
/**
|
927
|
+
* Update table. Currently there is only one update operation supported: renaming the table by providing a new name.
|
928
|
+
*
|
929
|
+
* In the example below, we rename a table from “users” to “people”:
|
930
|
+
*
|
931
|
+
* ```jsx
|
932
|
+
* PATCH /db/test:main/tables/users
|
933
|
+
* {
|
934
|
+
* "name": "people"
|
935
|
+
* }
|
936
|
+
* ```
|
937
|
+
*/
|
938
|
+
declare const updateTable: (variables: UpdateTableVariables) => Promise<undefined>;
|
939
|
+
declare type GetTableSchemaPathParams = {
|
940
|
+
dbBranchName: DBBranchName;
|
941
|
+
tableName: TableName;
|
942
|
+
workspace: string;
|
943
|
+
};
|
944
|
+
declare type GetTableSchemaResponse = {
|
945
|
+
columns: Column[];
|
946
|
+
};
|
947
|
+
declare type GetTableSchemaVariables = {
|
948
|
+
pathParams: GetTableSchemaPathParams;
|
949
|
+
} & FetcherExtraProps;
|
950
|
+
declare const getTableSchema: (variables: GetTableSchemaVariables) => Promise<GetTableSchemaResponse>;
|
951
|
+
declare type SetTableSchemaPathParams = {
|
952
|
+
dbBranchName: DBBranchName;
|
953
|
+
tableName: TableName;
|
954
|
+
workspace: string;
|
955
|
+
};
|
956
|
+
declare type SetTableSchemaRequestBody = {
|
957
|
+
columns: Column[];
|
958
|
+
};
|
959
|
+
declare type SetTableSchemaVariables = {
|
960
|
+
body: SetTableSchemaRequestBody;
|
961
|
+
pathParams: SetTableSchemaPathParams;
|
962
|
+
} & FetcherExtraProps;
|
963
|
+
declare const setTableSchema: (variables: SetTableSchemaVariables) => Promise<undefined>;
|
964
|
+
declare type GetTableColumnsPathParams = {
|
965
|
+
dbBranchName: DBBranchName;
|
966
|
+
tableName: TableName;
|
967
|
+
workspace: string;
|
968
|
+
};
|
969
|
+
declare type GetTableColumnsResponse = {
|
970
|
+
columns: Column[];
|
971
|
+
};
|
972
|
+
declare type GetTableColumnsVariables = {
|
973
|
+
pathParams: GetTableColumnsPathParams;
|
974
|
+
} & FetcherExtraProps;
|
975
|
+
/**
|
976
|
+
* Retrieves the list of table columns and their definition. This endpoint returns the column list with object columns being reported with their
|
977
|
+
* full dot-separated path (flattened).
|
978
|
+
*/
|
979
|
+
declare const getTableColumns: (variables: GetTableColumnsVariables) => Promise<GetTableColumnsResponse>;
|
980
|
+
declare type AddTableColumnPathParams = {
|
981
|
+
dbBranchName: DBBranchName;
|
982
|
+
tableName: TableName;
|
983
|
+
workspace: string;
|
984
|
+
};
|
985
|
+
declare type AddTableColumnVariables = {
|
986
|
+
body: Column;
|
987
|
+
pathParams: AddTableColumnPathParams;
|
988
|
+
} & FetcherExtraProps;
|
989
|
+
/**
|
990
|
+
* Adds a new column to the table. The body of the request should contain the column definition. In the column definition, the 'name' field should
|
991
|
+
* contain the full path separated by dots. If the parent objects do not exists, they will be automatically created. For example,
|
992
|
+
* passing `"name": "address.city"` will auto-create the `address` object if it doesn't exist.
|
993
|
+
*/
|
994
|
+
declare const addTableColumn: (variables: AddTableColumnVariables) => Promise<MigrationIdResponse>;
|
995
|
+
declare type GetColumnPathParams = {
|
996
|
+
dbBranchName: DBBranchName;
|
997
|
+
tableName: TableName;
|
998
|
+
columnName: ColumnName;
|
999
|
+
workspace: string;
|
1000
|
+
};
|
1001
|
+
declare type GetColumnVariables = {
|
1002
|
+
pathParams: GetColumnPathParams;
|
1003
|
+
} & FetcherExtraProps;
|
1004
|
+
/**
|
1005
|
+
* Get the definition of a single column. To refer to sub-objects, the column name can contain dots. For example `address.country`.
|
1006
|
+
*/
|
1007
|
+
declare const getColumn: (variables: GetColumnVariables) => Promise<Column>;
|
1008
|
+
declare type DeleteColumnPathParams = {
|
1009
|
+
dbBranchName: DBBranchName;
|
1010
|
+
tableName: TableName;
|
1011
|
+
columnName: ColumnName;
|
1012
|
+
workspace: string;
|
1013
|
+
};
|
1014
|
+
declare type DeleteColumnVariables = {
|
1015
|
+
pathParams: DeleteColumnPathParams;
|
1016
|
+
} & FetcherExtraProps;
|
1017
|
+
/**
|
1018
|
+
* Deletes the specified column. To refer to sub-objects, the column name can contain dots. For example `address.country`.
|
1019
|
+
*/
|
1020
|
+
declare const deleteColumn: (variables: DeleteColumnVariables) => Promise<MigrationIdResponse>;
|
1021
|
+
declare type UpdateColumnPathParams = {
|
1022
|
+
dbBranchName: DBBranchName;
|
1023
|
+
tableName: TableName;
|
1024
|
+
columnName: ColumnName;
|
1025
|
+
workspace: string;
|
1026
|
+
};
|
1027
|
+
declare type UpdateColumnRequestBody = {
|
1028
|
+
name: string;
|
1029
|
+
};
|
1030
|
+
declare type UpdateColumnVariables = {
|
1031
|
+
body: UpdateColumnRequestBody;
|
1032
|
+
pathParams: UpdateColumnPathParams;
|
1033
|
+
} & FetcherExtraProps;
|
1034
|
+
/**
|
1035
|
+
* Update column with partial data. Can be used for renaming the column by providing a new "name" field. To refer to sub-objects, the column name can contain dots. For example `address.country`.
|
1036
|
+
*/
|
1037
|
+
declare const updateColumn: (variables: UpdateColumnVariables) => Promise<MigrationIdResponse>;
|
1038
|
+
declare type InsertRecordPathParams = {
|
1039
|
+
dbBranchName: DBBranchName;
|
1040
|
+
tableName: TableName;
|
1041
|
+
workspace: string;
|
1042
|
+
};
|
1043
|
+
declare type InsertRecordResponse = {
|
1044
|
+
id: string;
|
1045
|
+
xata: {
|
1046
|
+
version: number;
|
1047
|
+
};
|
1048
|
+
};
|
1049
|
+
declare type InsertRecordVariables = {
|
1050
|
+
body?: Record<string, any>;
|
1051
|
+
pathParams: InsertRecordPathParams;
|
1052
|
+
} & FetcherExtraProps;
|
1053
|
+
/**
|
1054
|
+
* Insert a new Record into the Table
|
1055
|
+
*/
|
1056
|
+
declare const insertRecord: (variables: InsertRecordVariables) => Promise<InsertRecordResponse>;
|
1057
|
+
declare type InsertRecordWithIDPathParams = {
|
1058
|
+
dbBranchName: DBBranchName;
|
1059
|
+
tableName: TableName;
|
1060
|
+
recordId: RecordID;
|
1061
|
+
workspace: string;
|
1062
|
+
};
|
1063
|
+
declare type InsertRecordWithIDQueryParams = {
|
1064
|
+
createOnly?: boolean;
|
1065
|
+
ifVersion?: number;
|
1066
|
+
};
|
1067
|
+
declare type InsertRecordWithIDVariables = {
|
1068
|
+
body?: Record<string, any>;
|
1069
|
+
pathParams: InsertRecordWithIDPathParams;
|
1070
|
+
queryParams?: InsertRecordWithIDQueryParams;
|
1071
|
+
} & FetcherExtraProps;
|
1072
|
+
/**
|
1073
|
+
* By default, IDs are auto-generated when data is insterted into Xata. Sending a request to this endpoint allows us to insert a record with a pre-existing ID, bypassing the default automatic ID generation.
|
1074
|
+
*/
|
1075
|
+
declare const insertRecordWithID: (variables: InsertRecordWithIDVariables) => Promise<RecordUpdateResponse>;
|
1076
|
+
declare type UpdateRecordWithIDPathParams = {
|
1077
|
+
dbBranchName: DBBranchName;
|
1078
|
+
tableName: TableName;
|
1079
|
+
recordId: RecordID;
|
1080
|
+
workspace: string;
|
1081
|
+
};
|
1082
|
+
declare type UpdateRecordWithIDQueryParams = {
|
1083
|
+
ifVersion?: number;
|
1084
|
+
};
|
1085
|
+
declare type UpdateRecordWithIDVariables = {
|
1086
|
+
body?: Record<string, any>;
|
1087
|
+
pathParams: UpdateRecordWithIDPathParams;
|
1088
|
+
queryParams?: UpdateRecordWithIDQueryParams;
|
1089
|
+
} & FetcherExtraProps;
|
1090
|
+
declare const updateRecordWithID: (variables: UpdateRecordWithIDVariables) => Promise<RecordUpdateResponse>;
|
1091
|
+
declare type UpsertRecordWithIDPathParams = {
|
1092
|
+
dbBranchName: DBBranchName;
|
1093
|
+
tableName: TableName;
|
1094
|
+
recordId: RecordID;
|
1095
|
+
workspace: string;
|
1096
|
+
};
|
1097
|
+
declare type UpsertRecordWithIDQueryParams = {
|
1098
|
+
ifVersion?: number;
|
1099
|
+
};
|
1100
|
+
declare type UpsertRecordWithIDVariables = {
|
1101
|
+
body?: Record<string, any>;
|
1102
|
+
pathParams: UpsertRecordWithIDPathParams;
|
1103
|
+
queryParams?: UpsertRecordWithIDQueryParams;
|
1104
|
+
} & FetcherExtraProps;
|
1105
|
+
declare const upsertRecordWithID: (variables: UpsertRecordWithIDVariables) => Promise<RecordUpdateResponse>;
|
1106
|
+
declare type DeleteRecordPathParams = {
|
1107
|
+
dbBranchName: DBBranchName;
|
1108
|
+
tableName: TableName;
|
1109
|
+
recordId: RecordID;
|
1110
|
+
workspace: string;
|
1111
|
+
};
|
1112
|
+
declare type DeleteRecordVariables = {
|
1113
|
+
pathParams: DeleteRecordPathParams;
|
1114
|
+
} & FetcherExtraProps;
|
1115
|
+
declare const deleteRecord: (variables: DeleteRecordVariables) => Promise<undefined>;
|
1116
|
+
declare type GetRecordPathParams = {
|
1117
|
+
dbBranchName: DBBranchName;
|
1118
|
+
tableName: TableName;
|
1119
|
+
recordId: RecordID;
|
1120
|
+
workspace: string;
|
1121
|
+
};
|
1122
|
+
declare type GetRecordRequestBody = {
|
1123
|
+
columns?: ColumnsFilter;
|
1124
|
+
};
|
1125
|
+
declare type GetRecordVariables = {
|
1126
|
+
body?: GetRecordRequestBody;
|
1127
|
+
pathParams: GetRecordPathParams;
|
1128
|
+
} & FetcherExtraProps;
|
1129
|
+
/**
|
1130
|
+
* Retrieve record by ID
|
1131
|
+
*/
|
1132
|
+
declare const getRecord: (variables: GetRecordVariables) => Promise<XataRecord$1>;
|
1133
|
+
declare type BulkInsertTableRecordsPathParams = {
|
1134
|
+
dbBranchName: DBBranchName;
|
1135
|
+
tableName: TableName;
|
1136
|
+
workspace: string;
|
1137
|
+
};
|
1138
|
+
declare type BulkInsertTableRecordsResponse = {
|
1139
|
+
recordIDs: string[];
|
1140
|
+
};
|
1141
|
+
declare type BulkInsertTableRecordsRequestBody = {
|
1142
|
+
records: Record<string, any>[];
|
1143
|
+
};
|
1144
|
+
declare type BulkInsertTableRecordsVariables = {
|
1145
|
+
body: BulkInsertTableRecordsRequestBody;
|
1146
|
+
pathParams: BulkInsertTableRecordsPathParams;
|
1147
|
+
} & FetcherExtraProps;
|
1148
|
+
/**
|
1149
|
+
* Bulk insert records
|
1150
|
+
*/
|
1151
|
+
declare const bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
|
1152
|
+
declare type QueryTablePathParams = {
|
1153
|
+
dbBranchName: DBBranchName;
|
1154
|
+
tableName: TableName;
|
1155
|
+
workspace: string;
|
1156
|
+
};
|
1157
|
+
declare type QueryTableRequestBody = {
|
1158
|
+
filter?: FilterExpression;
|
1159
|
+
sort?: SortExpression;
|
1160
|
+
page?: PageConfig;
|
1161
|
+
columns?: ColumnsFilter;
|
1162
|
+
};
|
1163
|
+
declare type QueryTableVariables = {
|
1164
|
+
body?: QueryTableRequestBody;
|
1165
|
+
pathParams: QueryTablePathParams;
|
1166
|
+
} & FetcherExtraProps;
|
1167
|
+
/**
|
1168
|
+
* The Query Table API can be used to retrieve all records in a table.
|
1169
|
+
* The API support filtering, sorting, selecting a subset of columns, and pagination.
|
1170
|
+
*
|
1171
|
+
* The overall structure of the request looks like this:
|
1172
|
+
*
|
1173
|
+
* ```json
|
1174
|
+
* // POST /db/<dbname>:<branch>/tables/<table>/query
|
1175
|
+
* {
|
1176
|
+
* "columns": [...],
|
1177
|
+
* "filter": {
|
1178
|
+
* "$all": [...]
|
1179
|
+
* "$any": [...]
|
1180
|
+
* ...
|
1181
|
+
* },
|
1182
|
+
* "sort": {
|
1183
|
+
* "multiple": [...]
|
1184
|
+
* ...
|
1185
|
+
* },
|
1186
|
+
* "page": {
|
1187
|
+
* ...
|
1188
|
+
* }
|
1189
|
+
* }
|
1190
|
+
* ```
|
1191
|
+
*
|
1192
|
+
* ### Column selection
|
1193
|
+
*
|
1194
|
+
* If the `columns` array is not specified, all columns are included. For link
|
1195
|
+
* fields, only the ID column of the linked records is included in the response.
|
1196
|
+
*
|
1197
|
+
* If the `columns` array is specified, only the selected columns are included.
|
1198
|
+
* The `*` wildcard can be used to select all columns of the given array
|
1199
|
+
*
|
1200
|
+
* For objects and link fields, if the column name of the object is specified, we
|
1201
|
+
* include all of its sub-keys. If only some sub-keys are specified (via dotted
|
1202
|
+
* notation, e.g. `"settings.plan"` ), then only those sub-keys from the object
|
1203
|
+
* are included.
|
1204
|
+
*
|
1205
|
+
* By the way of example, assuming two tables like this:
|
1206
|
+
*
|
1207
|
+
* ```json {"truncate": true}
|
1208
|
+
* {
|
1209
|
+
* "formatVersion": "1.0",
|
1210
|
+
* "tables": [
|
1211
|
+
* {
|
1212
|
+
* "name": "teams",
|
1213
|
+
* "columns": [
|
1214
|
+
* {
|
1215
|
+
* "name": "name",
|
1216
|
+
* "type": "string"
|
1217
|
+
* },
|
1218
|
+
* {
|
1219
|
+
* "name": "owner",
|
1220
|
+
* "type": "link",
|
1221
|
+
* "link": {
|
1222
|
+
* "table": "users"
|
1223
|
+
* }
|
1224
|
+
* }
|
1225
|
+
* ]
|
1226
|
+
* },
|
1227
|
+
* {
|
1228
|
+
* "name": "users",
|
1229
|
+
* "columns": [
|
1230
|
+
* {
|
1231
|
+
* "name": "email",
|
1232
|
+
* "type": "email"
|
1233
|
+
* },
|
1234
|
+
* {
|
1235
|
+
* "name": "full_name",
|
1236
|
+
* "type": "string"
|
1237
|
+
* },
|
1238
|
+
* {
|
1239
|
+
* "name": "address",
|
1240
|
+
* "type": "object",
|
1241
|
+
* "columns": [
|
1242
|
+
* {
|
1243
|
+
* "name": "street",
|
1244
|
+
* "type": "string"
|
1245
|
+
* },
|
1246
|
+
* {
|
1247
|
+
* "name": "number",
|
1248
|
+
* "type": "int"
|
1249
|
+
* },
|
1250
|
+
* {
|
1251
|
+
* "name": "zipcode",
|
1252
|
+
* "type": "int"
|
1253
|
+
* }
|
1254
|
+
* ]
|
1255
|
+
* },
|
1256
|
+
* {
|
1257
|
+
* "name": "team",
|
1258
|
+
* "type": "link",
|
1259
|
+
* "link": {
|
1260
|
+
* "table": "teams"
|
1261
|
+
* }
|
1262
|
+
* }
|
1263
|
+
* ]
|
1264
|
+
* }
|
1265
|
+
* ]
|
1266
|
+
* }
|
1267
|
+
* ```
|
1268
|
+
*
|
1269
|
+
* A query like this:
|
1270
|
+
*
|
1271
|
+
* ```json
|
1272
|
+
* POST /db/<dbname>:<branch>/tables/<table>/query
|
1273
|
+
* {
|
1274
|
+
* "columns": [
|
1275
|
+
* "name",
|
1276
|
+
* "address.*"
|
1277
|
+
* ]
|
1278
|
+
* }
|
1279
|
+
* ```
|
1280
|
+
*
|
1281
|
+
* returns objects like:
|
1282
|
+
*
|
1283
|
+
* ```json
|
1284
|
+
* {
|
1285
|
+
* "name": "Kilian",
|
1286
|
+
* "address": {
|
1287
|
+
* "street": "New street",
|
1288
|
+
* "number": 41,
|
1289
|
+
* "zipcode": 10407
|
1290
|
+
* }
|
1291
|
+
* }
|
1292
|
+
* ```
|
1293
|
+
*
|
1294
|
+
* while a query like this:
|
1295
|
+
*
|
1296
|
+
* ```json
|
1297
|
+
* POST /db/<dbname>:<branch>/tables/<table>/query
|
1298
|
+
* {
|
1299
|
+
* "columns": [
|
1300
|
+
* "name",
|
1301
|
+
* "address.street"
|
1302
|
+
* ]
|
1303
|
+
* }
|
1304
|
+
* ```
|
1305
|
+
*
|
1306
|
+
* returns objects like:
|
1307
|
+
*
|
1308
|
+
* ```json
|
1309
|
+
* {
|
1310
|
+
* "name": "Kilian",
|
1311
|
+
* "address": {
|
1312
|
+
* "street": "New street",
|
1313
|
+
* }
|
1314
|
+
* }
|
1315
|
+
* ```
|
1316
|
+
*
|
1317
|
+
* If you want to return all columns from the main table and selected columns from the linked table, you can do it like this:
|
1318
|
+
*
|
1319
|
+
* ```json
|
1320
|
+
* {
|
1321
|
+
* "columns": [
|
1322
|
+
* "*",
|
1323
|
+
* "team.name"
|
1324
|
+
* ]
|
1325
|
+
* }
|
1326
|
+
* ```
|
1327
|
+
*
|
1328
|
+
* The `"*"` in the above means all columns, including columns of objects. This returns data like:
|
1329
|
+
*
|
1330
|
+
* ```json
|
1331
|
+
* {
|
1332
|
+
* "name": "Kilian",
|
1333
|
+
* "email": "kilian@gmail.com",
|
1334
|
+
* "address": {
|
1335
|
+
* "street": "New street",
|
1336
|
+
* "number": 41,
|
1337
|
+
* "zipcode": 10407
|
1338
|
+
* },
|
1339
|
+
* "team": {
|
1340
|
+
* "id": "XX",
|
1341
|
+
* "xata": {
|
1342
|
+
* "version": 0,
|
1343
|
+
* },
|
1344
|
+
* "name": "first team"
|
1345
|
+
* }
|
1346
|
+
* }
|
1347
|
+
* ```
|
1348
|
+
*
|
1349
|
+
* If you want all columns of the linked table, you can do:
|
1350
|
+
*
|
1351
|
+
* ```json
|
1352
|
+
* {
|
1353
|
+
* "columns": [
|
1354
|
+
* "*",
|
1355
|
+
* "team.*"
|
1356
|
+
* ]
|
1357
|
+
* }
|
1358
|
+
* ```
|
1359
|
+
*
|
1360
|
+
* This returns, for example:
|
1361
|
+
*
|
1362
|
+
* ```json
|
1363
|
+
* {
|
1364
|
+
* "name": "Kilian",
|
1365
|
+
* "email": "kilian@gmail.com",
|
1366
|
+
* "address": {
|
1367
|
+
* "street": "New street",
|
1368
|
+
* "number": 41,
|
1369
|
+
* "zipcode": 10407
|
1370
|
+
* },
|
1371
|
+
* "team": {
|
1372
|
+
* "id": "XX",
|
1373
|
+
* "xata": {
|
1374
|
+
* "version": 0,
|
1375
|
+
* },
|
1376
|
+
* "name": "first team",
|
1377
|
+
* "code": "A1"
|
1378
|
+
* }
|
1379
|
+
* }
|
1380
|
+
* ```
|
1381
|
+
*
|
1382
|
+
* ### Filtering
|
1383
|
+
*
|
1384
|
+
* There are two types of operators:
|
1385
|
+
*
|
1386
|
+
* - Operators that work on a single column: `$is`, `$contains`, `$pattern`,
|
1387
|
+
* `$includes`, `$gt`, etc.
|
1388
|
+
* - Control operators that combine multiple conditions: `$any`, `$all`, `$not` ,
|
1389
|
+
* `$none`, etc.
|
1390
|
+
*
|
1391
|
+
* All operators start with an `$` to differentiate them from column names
|
1392
|
+
* (which are not allowed to start with an dollar sign).
|
1393
|
+
*
|
1394
|
+
* #### Exact matching and control operators
|
1395
|
+
*
|
1396
|
+
* Filter by one column:
|
1397
|
+
*
|
1398
|
+
* ```json
|
1399
|
+
* {
|
1400
|
+
* "filter": {
|
1401
|
+
* "<column_name>": "value"
|
1402
|
+
* }
|
1403
|
+
* }
|
1404
|
+
* ```
|
1405
|
+
*
|
1406
|
+
* This is equivalent to using the `$is` operator:
|
1407
|
+
*
|
1408
|
+
* ```json
|
1409
|
+
* {
|
1410
|
+
* "filter": {
|
1411
|
+
* "<column_name>": {
|
1412
|
+
* "$is": "value"
|
1413
|
+
* }
|
1414
|
+
* }
|
1415
|
+
* }
|
1416
|
+
* ```
|
1417
|
+
*
|
1418
|
+
* For example:
|
1419
|
+
*
|
1420
|
+
* ```json
|
1421
|
+
* {
|
1422
|
+
* "filter": {
|
1423
|
+
* "name": "r2",
|
1424
|
+
* }
|
1425
|
+
* }
|
1426
|
+
* ```
|
1427
|
+
*
|
1428
|
+
* Or:
|
1429
|
+
*
|
1430
|
+
* ```json
|
1431
|
+
* {
|
1432
|
+
* "filter": {
|
1433
|
+
* "name": {
|
1434
|
+
* "$is": "r2"
|
1435
|
+
* }
|
1436
|
+
* }
|
1437
|
+
* }
|
1438
|
+
* ```
|
1439
|
+
*
|
1440
|
+
* For objects, both dots and nested versions work:
|
1441
|
+
*
|
1442
|
+
* ```json
|
1443
|
+
* {
|
1444
|
+
* "filter": {
|
1445
|
+
* "settings.plan": "free",
|
1446
|
+
* }
|
1447
|
+
* }
|
1448
|
+
* ```
|
1449
|
+
*
|
1450
|
+
* ```json
|
1451
|
+
* {
|
1452
|
+
* "filter": {
|
1453
|
+
* "settings": {
|
1454
|
+
* "plan": "free"
|
1455
|
+
* },
|
1456
|
+
* },
|
1457
|
+
* }
|
1458
|
+
* ```
|
1459
|
+
*
|
1460
|
+
* If you want to OR together multiple values, you can use the `$any` operator with an array of values:
|
1461
|
+
*
|
1462
|
+
* ```json
|
1463
|
+
* {
|
1464
|
+
* "filter": {
|
1465
|
+
* "settings.plan": {"$any": ["free", "paid"]}
|
1466
|
+
* },
|
1467
|
+
* }
|
1468
|
+
* ```
|
1469
|
+
*
|
1470
|
+
* If you specify multiple columns in the same filter, they are logically AND'ed together:
|
1471
|
+
*
|
1472
|
+
* ```json
|
1473
|
+
* {
|
1474
|
+
* "filter": {
|
1475
|
+
* "settings.dark": true,
|
1476
|
+
* "settings.plan": "free",
|
1477
|
+
* },
|
1478
|
+
* }
|
1479
|
+
* ```
|
1480
|
+
*
|
1481
|
+
* The above matches if both conditions are met.
|
1482
|
+
*
|
1483
|
+
* To be more explicit about it, you can use `$all` or `$any`:
|
1484
|
+
*
|
1485
|
+
* ```json
|
1486
|
+
* {
|
1487
|
+
* "filter": {
|
1488
|
+
* "$any": {
|
1489
|
+
* "settings.dark": true,
|
1490
|
+
* "settings.plan": "free"
|
1491
|
+
* }
|
1492
|
+
* },
|
1493
|
+
* }
|
1494
|
+
* ```
|
1495
|
+
*
|
1496
|
+
* The `$all` and `$any` operators can also receive an array of objects, which allows for repeating column names:
|
1497
|
+
*
|
1498
|
+
* ```json
|
1499
|
+
* {
|
1500
|
+
* "filter": {
|
1501
|
+
* "$any": [
|
1502
|
+
* {
|
1503
|
+
* "name": "r1",
|
1504
|
+
* },
|
1505
|
+
* {
|
1506
|
+
* "name": "r2",
|
1507
|
+
* }
|
1508
|
+
* ]
|
1509
|
+
* }
|
1510
|
+
* }
|
1511
|
+
* ```
|
1512
|
+
*
|
1513
|
+
* You can check for a value being not-null with `$exists`:
|
1514
|
+
*
|
1515
|
+
* ```json
|
1516
|
+
* {
|
1517
|
+
* "filter": {
|
1518
|
+
* "$exists": "settings",
|
1519
|
+
* }
|
1520
|
+
* }
|
1521
|
+
* ```
|
1522
|
+
*
|
1523
|
+
* This can be combined with `$all` or `$any` :
|
1524
|
+
*
|
1525
|
+
* ```json
|
1526
|
+
* {
|
1527
|
+
* "filter": {
|
1528
|
+
* "$all": [
|
1529
|
+
* {
|
1530
|
+
* "$exists": "settings",
|
1531
|
+
* },
|
1532
|
+
* {
|
1533
|
+
* "$exists": "name",
|
1534
|
+
* }
|
1535
|
+
* ]
|
1536
|
+
* }
|
1537
|
+
* }
|
1538
|
+
* ```
|
1539
|
+
*
|
1540
|
+
* Or you can use the inverse operator `$notExists`:
|
1541
|
+
*
|
1542
|
+
* ```json
|
1543
|
+
* {
|
1544
|
+
* "filter": {
|
1545
|
+
* "$notExists": "settings",
|
1546
|
+
* }
|
1547
|
+
* }
|
1548
|
+
* ```
|
1549
|
+
*
|
1550
|
+
* #### Partial match
|
1551
|
+
*
|
1552
|
+
* `$contains` is the simplest operator for partial matching. We should generally
|
1553
|
+
* discourage overusing `$contains` because it typically can't make use of
|
1554
|
+
* indices.
|
1555
|
+
*
|
1556
|
+
* ```json
|
1557
|
+
* {
|
1558
|
+
* "filter": {
|
1559
|
+
* "<column_name>": {
|
1560
|
+
* "$contains": "value"
|
1561
|
+
* }
|
1562
|
+
* }
|
1563
|
+
* }
|
1564
|
+
* ```
|
1565
|
+
*
|
1566
|
+
* Wildcards are supported via the `$pattern` operator:
|
1567
|
+
*
|
1568
|
+
* ```json
|
1569
|
+
* {
|
1570
|
+
* "filter": {
|
1571
|
+
* "<column_name>": {
|
1572
|
+
* "$pattern": "v*alue*"
|
1573
|
+
* }
|
1574
|
+
* }
|
1575
|
+
* }
|
1576
|
+
* ```
|
1577
|
+
*
|
1578
|
+
* We could also have `$endsWith` and `$startsWith` operators:
|
1579
|
+
*
|
1580
|
+
* ```json
|
1581
|
+
* {
|
1582
|
+
* "filter": {
|
1583
|
+
* "<column_name>": {
|
1584
|
+
* "$endsWith": ".gz"
|
1585
|
+
* },
|
1586
|
+
* "<column_name>": {
|
1587
|
+
* "$startsWith": "tmp-"
|
1588
|
+
* }
|
1589
|
+
* }
|
1590
|
+
* }
|
1591
|
+
* ```
|
1592
|
+
*
|
1593
|
+
* #### Numeric ranges
|
1594
|
+
*
|
1595
|
+
* ```json
|
1596
|
+
* {
|
1597
|
+
* "filter": {
|
1598
|
+
* "<column_name>": {
|
1599
|
+
* "$ge": 0,
|
1600
|
+
* "$lt": 100
|
1601
|
+
* }
|
1602
|
+
* }
|
1603
|
+
* }
|
1604
|
+
* ```
|
1605
|
+
*
|
1606
|
+
* The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
|
1607
|
+
*
|
1608
|
+
*
|
1609
|
+
* #### Negations
|
1610
|
+
*
|
1611
|
+
* A general `$not` operator can inverse any operation.
|
1612
|
+
*
|
1613
|
+
* ```json
|
1614
|
+
* {
|
1615
|
+
* "filter": {
|
1616
|
+
* "$not": {
|
1617
|
+
* "<column_name1>": "value1",
|
1618
|
+
* "<column_name2>": "value1"
|
1619
|
+
* }
|
1620
|
+
* }
|
1621
|
+
* }
|
1622
|
+
* ```
|
1623
|
+
*
|
1624
|
+
* Note: in the above the two condition are AND together, so this does (NOT ( ...
|
1625
|
+
* AND ...))
|
1626
|
+
*
|
1627
|
+
* Or more complex:
|
1628
|
+
*
|
1629
|
+
* ```json
|
1630
|
+
* {
|
1631
|
+
* "filter": {
|
1632
|
+
* "$not": {
|
1633
|
+
* "$any": [{
|
1634
|
+
* "<column_name1>": "value1"
|
1635
|
+
* }, {
|
1636
|
+
* "$all": [{
|
1637
|
+
* "<column_name2>": "value2"
|
1638
|
+
* }, {
|
1639
|
+
* "<column_name3>": "value3"
|
1640
|
+
* }]
|
1641
|
+
* }]
|
1642
|
+
* }
|
1643
|
+
* }
|
1644
|
+
* }
|
1645
|
+
* ```
|
1646
|
+
*
|
1647
|
+
* The `$not: { $any: {}}` can be shorted using the `$none` operator:
|
1648
|
+
*
|
1649
|
+
* ```json
|
1650
|
+
* {
|
1651
|
+
* "filter": {
|
1652
|
+
* "$none": {
|
1653
|
+
* "<column_name1>": "value1",
|
1654
|
+
* "<column_name2>": "value1"
|
1655
|
+
* }
|
1656
|
+
* }
|
1657
|
+
* }
|
1658
|
+
* ```
|
1659
|
+
*
|
1660
|
+
* In addition, you can use operators like `$isNot` or `$notExists` to simplify expressions:
|
1661
|
+
*
|
1662
|
+
* ```json
|
1663
|
+
* {
|
1664
|
+
* "filter": {
|
1665
|
+
* "<column_name>": {
|
1666
|
+
* "$isNot": "2019-10-12T07:20:50.52Z"
|
1667
|
+
* }
|
1668
|
+
* }
|
1669
|
+
* }
|
1670
|
+
* ```
|
1671
|
+
*
|
1672
|
+
* #### Working with arrays
|
1673
|
+
*
|
1674
|
+
* To test that an array contains a value, use `$includes`.
|
1675
|
+
*
|
1676
|
+
* ```json
|
1677
|
+
* {
|
1678
|
+
* "filter": {
|
1679
|
+
* "<array_name>": {
|
1680
|
+
* "$includes": "value"
|
1681
|
+
* }
|
1682
|
+
* }
|
1683
|
+
* }
|
1684
|
+
* ```
|
1685
|
+
*
|
1686
|
+
* The `$includes` operator accepts a custom predicate that will check if any
|
1687
|
+
* array values matches the predicate. For example a complex predicate can include
|
1688
|
+
* the `$all` , `$contains` and `$endsWith` operators:
|
1689
|
+
*
|
1690
|
+
* ```json
|
1691
|
+
* {
|
1692
|
+
* "filter": {
|
1693
|
+
* "<array name>": {
|
1694
|
+
* "$includes": {
|
1695
|
+
* "$all": [
|
1696
|
+
* {"$contains": "label"},
|
1697
|
+
* {"$not": {"$endsWith": "-debug"}}
|
1698
|
+
* ]
|
1699
|
+
* }
|
1700
|
+
* }
|
1701
|
+
* }
|
1702
|
+
* }
|
1703
|
+
* ```
|
1704
|
+
*
|
1705
|
+
* The `$includes` all operator succeeds if any column in the array matches the
|
1706
|
+
* predicate. The `$includesAll` operator succeeds if all array items match the
|
1707
|
+
* predicate. The `$includesNone` operator succeeds if no array item matches the
|
1708
|
+
* predicate. The `$includes` operator is a synonym for the `$includesAny`
|
1709
|
+
* operator.
|
1710
|
+
*
|
1711
|
+
* Here is an example of using the `$includesAll` operator:
|
1712
|
+
*
|
1713
|
+
* ```json
|
1714
|
+
* {
|
1715
|
+
* "filter": {
|
1716
|
+
* "settings.labels": {
|
1717
|
+
* "$includesAll": [
|
1718
|
+
* {"$contains": "label"},
|
1719
|
+
* ]
|
1720
|
+
* }
|
1721
|
+
* }
|
1722
|
+
* }
|
1723
|
+
* ```
|
1724
|
+
*
|
1725
|
+
* The above matches if all label values contain the string "labels".
|
1726
|
+
*
|
1727
|
+
* ### Sorting
|
1728
|
+
*
|
1729
|
+
* Sorting by one element:
|
1730
|
+
*
|
1731
|
+
* ```json
|
1732
|
+
* POST /db/demo:main/tables/table/query
|
1733
|
+
* {
|
1734
|
+
* "sort": {
|
1735
|
+
* "index": "asc"
|
1736
|
+
* }
|
1737
|
+
* }
|
1738
|
+
* ```
|
1739
|
+
*
|
1740
|
+
* or descendently:
|
1741
|
+
*
|
1742
|
+
* ```json
|
1743
|
+
* POST /db/demo:main/tables/table/query
|
1744
|
+
* {
|
1745
|
+
* "sort": {
|
1746
|
+
* "index": "desc"
|
1747
|
+
* }
|
1748
|
+
* }
|
1749
|
+
* ```
|
1750
|
+
*
|
1751
|
+
* Sorting by multiple fields:
|
1752
|
+
*
|
1753
|
+
* ```json
|
1754
|
+
* POST /db/demo:main/tables/table/query
|
1755
|
+
* {
|
1756
|
+
* "sort": [
|
1757
|
+
* {
|
1758
|
+
* "index": "desc"
|
1759
|
+
* },
|
1760
|
+
* {
|
1761
|
+
* "createdAt": "desc"
|
1762
|
+
* }
|
1763
|
+
* ]
|
1764
|
+
* }
|
1765
|
+
* ```
|
1766
|
+
*
|
1767
|
+
*
|
1768
|
+
* ### Pagination
|
1769
|
+
*
|
1770
|
+
* We offer cursor pagination and offset pagination. The offset pagination is limited
|
1771
|
+
* in the amount of data it can retrieve, so we recommend the cursor pagination if you have more than 1000 records.
|
1772
|
+
*
|
1773
|
+
* Example of size + offset pagination:
|
1774
|
+
*
|
1775
|
+
* ```json
|
1776
|
+
* POST /db/demo:main/tables/table/query
|
1777
|
+
* {
|
1778
|
+
* "page": {
|
1779
|
+
* "size": 100,
|
1780
|
+
* "offset": 200
|
1781
|
+
* }
|
1782
|
+
* }
|
1783
|
+
* ```
|
1784
|
+
*
|
1785
|
+
* The `page.size` parameter represents the maximum number of records returned by this query. It has a default value of 20 and a maximum value of 200.
|
1786
|
+
* The `page.offset` parameter represents the number of matching records to skip. It has a default value of 0 and a maximum value of 800.
|
1787
|
+
*
|
1788
|
+
* Example of cursor pagination:
|
1789
|
+
*
|
1790
|
+
* ```json
|
1791
|
+
* POST /db/demo:main/tables/table/query
|
1792
|
+
* {
|
1793
|
+
* "page": {
|
1794
|
+
* "after":"fMoxCsIwFIDh3WP8c4amDai5hO5SJCRNfaVSeC9b6d1FD"
|
1795
|
+
* }
|
1796
|
+
* }
|
1797
|
+
* ```
|
1798
|
+
*
|
1799
|
+
* In the above example, the value of the `page.after` parameter is the cursor returned by the previous query. A sample response is shown below:
|
1800
|
+
*
|
1801
|
+
* ```json
|
1802
|
+
* {
|
1803
|
+
* "meta": {
|
1804
|
+
* "page": {
|
1805
|
+
* "cursor": "fMoxCsIwFIDh3WP8c4amDai5hO5SJCRNfaVSeC9b6d1FD",
|
1806
|
+
* "more": true
|
1807
|
+
* }
|
1808
|
+
* },
|
1809
|
+
* "records": [...]
|
1810
|
+
* }
|
1811
|
+
* ```
|
1812
|
+
*
|
1813
|
+
* The `page` object might contain the follow keys, in addition to `size` and `offset` that were introduced before:
|
1814
|
+
*
|
1815
|
+
* - `after`: Return the next page 'after' the current cursor
|
1816
|
+
* - `before`: Return the previous page 'before' the current cursor.
|
1817
|
+
* - `first`: Return the first page in the table from a cursor.
|
1818
|
+
* - `last`: Return the last N records in the table from a cursor, where N is the `page.size` parameter.
|
1819
|
+
*
|
1820
|
+
* The request will fail if an invalid cursor value is given to `page.before`,
|
1821
|
+
* `page.after`, `page.first` , or `page.last`. No other cursor setting can be
|
1822
|
+
* used if `page.first` or `page.last` is set in a query.
|
1823
|
+
*
|
1824
|
+
* If both `page.before` and `page.after` parameters are present we treat the
|
1825
|
+
* request as a range query. The range query will return all entries after
|
1826
|
+
* `page.after`, but before `page.before`, up to `page.size` or the maximum
|
1827
|
+
* page size. This query requires both cursors to use the same filters and sort
|
1828
|
+
* settings, plus we require `page.after < page.before`. The range query returns
|
1829
|
+
* a new cursor. If the range encompass multiple pages the next page in the range
|
1830
|
+
* can be queried by update `page.after` to the returned cursor while keeping the
|
1831
|
+
* `page.before` cursor from the first range query.
|
1832
|
+
*
|
1833
|
+
* The `filter` , `columns`, `sort` , and `page.size` configuration will be
|
1834
|
+
* encoded with the cursor. The pagination request will be invalid if
|
1835
|
+
* `filter` or `sort` is set. The columns returned and page size can be changed
|
1836
|
+
* anytime by passing the `columns` or `page.size` settings to the next query.
|
1837
|
+
*
|
1838
|
+
* **Special cursors:**
|
1839
|
+
*
|
1840
|
+
* - `page.after=end`: Result points past the last entry. The list of records
|
1841
|
+
* returned is empty, but `page.meta.cursor` will include a cursor that can be
|
1842
|
+
* used to "tail" the table from the end waiting for new data to be inserted.
|
1843
|
+
* - `page.before=end`: This cursor returns the last page.
|
1844
|
+
* - `page.first=<cursor>`: Go to first page. This is equivalent to querying the
|
1845
|
+
* first page without a cursor but `filter` and `sort` . Yet the `page.first`
|
1846
|
+
* cursor can be convenient at times as user code does not need to remember the
|
1847
|
+
* filter, sort, columns or page size configuration. All these information are
|
1848
|
+
* read from the cursor.
|
1849
|
+
* - `page.last=<cursor>`: Go to the end of the table. This is equivalent to querying the
|
1850
|
+
* last page with `page.before=end`, `filter`, and `sort` . Yet the
|
1851
|
+
* `page.last` cursor can be more convenient at times as user code does not
|
1852
|
+
* need to remember the filter, sort, columns or page size configuration. All
|
1853
|
+
* these information are read from the cursor.
|
1854
|
+
*
|
1855
|
+
* When using special cursors like `page.after="end"` or `page.before="end"`, we
|
1856
|
+
* still allow `filter` and `sort` to be set.
|
1857
|
+
*
|
1858
|
+
* Example of getting the last page:
|
1859
|
+
*
|
1860
|
+
* ```json
|
1861
|
+
* POST /db/demo:main/tables/table/query
|
1862
|
+
* {
|
1863
|
+
* "page": {
|
1864
|
+
* "size": 10,
|
1865
|
+
* "before": "end"
|
1866
|
+
* }
|
1867
|
+
* }
|
1868
|
+
* ```
|
1869
|
+
*/
|
1870
|
+
declare const queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
1871
|
+
declare type SearchBranchPathParams = {
|
1872
|
+
dbBranchName: DBBranchName;
|
1873
|
+
workspace: string;
|
1874
|
+
};
|
1875
|
+
declare type SearchBranchRequestBody = {
|
1876
|
+
tables?: string[];
|
1877
|
+
query: string;
|
1878
|
+
fuzziness?: number;
|
1879
|
+
};
|
1880
|
+
declare type SearchBranchVariables = {
|
1881
|
+
body: SearchBranchRequestBody;
|
1882
|
+
pathParams: SearchBranchPathParams;
|
1883
|
+
} & FetcherExtraProps;
|
1884
|
+
/**
|
1885
|
+
* Run a free text search operation across the database branch.
|
1886
|
+
*/
|
1887
|
+
declare const searchBranch: (variables: SearchBranchVariables) => Promise<SearchResponse>;
|
1888
|
+
declare const operationsByTag: {
|
1889
|
+
users: {
|
1890
|
+
getUser: (variables: GetUserVariables) => Promise<UserWithID>;
|
1891
|
+
updateUser: (variables: UpdateUserVariables) => Promise<UserWithID>;
|
1892
|
+
deleteUser: (variables: DeleteUserVariables) => Promise<undefined>;
|
1893
|
+
getUserAPIKeys: (variables: GetUserAPIKeysVariables) => Promise<GetUserAPIKeysResponse>;
|
1894
|
+
createUserAPIKey: (variables: CreateUserAPIKeyVariables) => Promise<CreateUserAPIKeyResponse>;
|
1895
|
+
deleteUserAPIKey: (variables: DeleteUserAPIKeyVariables) => Promise<undefined>;
|
1896
|
+
};
|
1897
|
+
workspaces: {
|
1898
|
+
createWorkspace: (variables: CreateWorkspaceVariables) => Promise<Workspace>;
|
1899
|
+
getWorkspacesList: (variables: GetWorkspacesListVariables) => Promise<GetWorkspacesListResponse>;
|
1900
|
+
getWorkspace: (variables: GetWorkspaceVariables) => Promise<Workspace>;
|
1901
|
+
updateWorkspace: (variables: UpdateWorkspaceVariables) => Promise<Workspace>;
|
1902
|
+
deleteWorkspace: (variables: DeleteWorkspaceVariables) => Promise<undefined>;
|
1903
|
+
getWorkspaceMembersList: (variables: GetWorkspaceMembersListVariables) => Promise<WorkspaceMembers>;
|
1904
|
+
updateWorkspaceMemberRole: (variables: UpdateWorkspaceMemberRoleVariables) => Promise<undefined>;
|
1905
|
+
removeWorkspaceMember: (variables: RemoveWorkspaceMemberVariables) => Promise<undefined>;
|
1906
|
+
inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<WorkspaceInvite>;
|
1907
|
+
cancelWorkspaceMemberInvite: (variables: CancelWorkspaceMemberInviteVariables) => Promise<undefined>;
|
1908
|
+
resendWorkspaceMemberInvite: (variables: ResendWorkspaceMemberInviteVariables) => Promise<undefined>;
|
1909
|
+
acceptWorkspaceMemberInvite: (variables: AcceptWorkspaceMemberInviteVariables) => Promise<undefined>;
|
1910
|
+
};
|
1911
|
+
database: {
|
1912
|
+
getDatabaseList: (variables: GetDatabaseListVariables) => Promise<ListDatabasesResponse>;
|
1913
|
+
createDatabase: (variables: CreateDatabaseVariables) => Promise<CreateDatabaseResponse>;
|
1914
|
+
deleteDatabase: (variables: DeleteDatabaseVariables) => Promise<undefined>;
|
1915
|
+
};
|
1916
|
+
branch: {
|
1917
|
+
getBranchList: (variables: GetBranchListVariables) => Promise<ListBranchesResponse>;
|
1918
|
+
getBranchDetails: (variables: GetBranchDetailsVariables) => Promise<DBBranch>;
|
1919
|
+
createBranch: (variables: CreateBranchVariables) => Promise<undefined>;
|
1920
|
+
deleteBranch: (variables: DeleteBranchVariables) => Promise<undefined>;
|
1921
|
+
updateBranchMetadata: (variables: UpdateBranchMetadataVariables) => Promise<undefined>;
|
1922
|
+
getBranchMetadata: (variables: GetBranchMetadataVariables) => Promise<BranchMetadata>;
|
1923
|
+
getBranchMigrationHistory: (variables: GetBranchMigrationHistoryVariables) => Promise<GetBranchMigrationHistoryResponse>;
|
1924
|
+
executeBranchMigrationPlan: (variables: ExecuteBranchMigrationPlanVariables) => Promise<undefined>;
|
1925
|
+
getBranchMigrationPlan: (variables: GetBranchMigrationPlanVariables) => Promise<BranchMigrationPlan>;
|
1926
|
+
getBranchStats: (variables: GetBranchStatsVariables) => Promise<GetBranchStatsResponse>;
|
1927
|
+
};
|
1928
|
+
table: {
|
1929
|
+
createTable: (variables: CreateTableVariables) => Promise<undefined>;
|
1930
|
+
deleteTable: (variables: DeleteTableVariables) => Promise<undefined>;
|
1931
|
+
updateTable: (variables: UpdateTableVariables) => Promise<undefined>;
|
1932
|
+
getTableSchema: (variables: GetTableSchemaVariables) => Promise<GetTableSchemaResponse>;
|
1933
|
+
setTableSchema: (variables: SetTableSchemaVariables) => Promise<undefined>;
|
1934
|
+
getTableColumns: (variables: GetTableColumnsVariables) => Promise<GetTableColumnsResponse>;
|
1935
|
+
addTableColumn: (variables: AddTableColumnVariables) => Promise<MigrationIdResponse>;
|
1936
|
+
getColumn: (variables: GetColumnVariables) => Promise<Column>;
|
1937
|
+
deleteColumn: (variables: DeleteColumnVariables) => Promise<MigrationIdResponse>;
|
1938
|
+
updateColumn: (variables: UpdateColumnVariables) => Promise<MigrationIdResponse>;
|
1939
|
+
};
|
1940
|
+
records: {
|
1941
|
+
insertRecord: (variables: InsertRecordVariables) => Promise<InsertRecordResponse>;
|
1942
|
+
insertRecordWithID: (variables: InsertRecordWithIDVariables) => Promise<RecordUpdateResponse>;
|
1943
|
+
updateRecordWithID: (variables: UpdateRecordWithIDVariables) => Promise<RecordUpdateResponse>;
|
1944
|
+
upsertRecordWithID: (variables: UpsertRecordWithIDVariables) => Promise<RecordUpdateResponse>;
|
1945
|
+
deleteRecord: (variables: DeleteRecordVariables) => Promise<undefined>;
|
1946
|
+
getRecord: (variables: GetRecordVariables) => Promise<XataRecord$1>;
|
1947
|
+
bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
|
1948
|
+
queryTable: (variables: QueryTableVariables) => Promise<QueryResponse>;
|
1949
|
+
searchBranch: (variables: SearchBranchVariables) => Promise<SearchResponse>;
|
1950
|
+
};
|
1951
|
+
};
|
1952
|
+
|
1953
|
+
declare type HostAliases = 'production' | 'staging';
|
1954
|
+
declare type ProviderBuilder = {
|
1955
|
+
main: string;
|
1956
|
+
workspaces: string;
|
1957
|
+
};
|
1958
|
+
declare type HostProvider = HostAliases | ProviderBuilder;
|
1959
|
+
|
1960
|
+
interface XataApiClientOptions {
|
1961
|
+
fetch?: FetchImpl;
|
1962
|
+
apiKey?: string;
|
1963
|
+
host?: HostProvider;
|
1964
|
+
}
|
1965
|
+
declare class XataApiClient {
|
1966
|
+
#private;
|
1967
|
+
constructor(options: XataApiClientOptions);
|
1968
|
+
get user(): UserApi;
|
1969
|
+
get workspaces(): WorkspaceApi;
|
1970
|
+
get databases(): DatabaseApi;
|
1971
|
+
get branches(): BranchApi;
|
1972
|
+
get tables(): TableApi;
|
1973
|
+
get records(): RecordsApi;
|
1974
|
+
}
|
1975
|
+
declare class UserApi {
|
1976
|
+
private extraProps;
|
1977
|
+
constructor(extraProps: FetcherExtraProps);
|
1978
|
+
getUser(): Promise<UserWithID>;
|
1979
|
+
updateUser(user: User): Promise<UserWithID>;
|
1980
|
+
deleteUser(): Promise<void>;
|
1981
|
+
getUserAPIKeys(): Promise<GetUserAPIKeysResponse>;
|
1982
|
+
createUserAPIKey(keyName: APIKeyName): Promise<CreateUserAPIKeyResponse>;
|
1983
|
+
deleteUserAPIKey(keyName: APIKeyName): Promise<void>;
|
1984
|
+
}
|
1985
|
+
declare class WorkspaceApi {
|
1986
|
+
private extraProps;
|
1987
|
+
constructor(extraProps: FetcherExtraProps);
|
1988
|
+
createWorkspace(workspaceMeta: WorkspaceMeta): Promise<Workspace>;
|
1989
|
+
getWorkspacesList(): Promise<GetWorkspacesListResponse>;
|
1990
|
+
getWorkspace(workspaceId: WorkspaceID): Promise<Workspace>;
|
1991
|
+
updateWorkspace(workspaceId: WorkspaceID, workspaceMeta: WorkspaceMeta): Promise<Workspace>;
|
1992
|
+
deleteWorkspace(workspaceId: WorkspaceID): Promise<void>;
|
1993
|
+
getWorkspaceMembersList(workspaceId: WorkspaceID): Promise<WorkspaceMembers>;
|
1994
|
+
updateWorkspaceMemberRole(workspaceId: WorkspaceID, userId: UserID, role: Role): Promise<void>;
|
1995
|
+
removeWorkspaceMember(workspaceId: WorkspaceID, userId: UserID): Promise<void>;
|
1996
|
+
inviteWorkspaceMember(workspaceId: WorkspaceID, email: string, role: Role): Promise<WorkspaceInvite>;
|
1997
|
+
cancelWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID): Promise<void>;
|
1998
|
+
resendWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteId: InviteID): Promise<void>;
|
1999
|
+
acceptWorkspaceMemberInvite(workspaceId: WorkspaceID, inviteKey: InviteKey): Promise<void>;
|
2000
|
+
}
|
2001
|
+
declare class DatabaseApi {
|
2002
|
+
private extraProps;
|
2003
|
+
constructor(extraProps: FetcherExtraProps);
|
2004
|
+
getDatabaseList(workspace: WorkspaceID): Promise<ListDatabasesResponse>;
|
2005
|
+
createDatabase(workspace: WorkspaceID, dbName: DBName, options?: CreateDatabaseRequestBody): Promise<CreateDatabaseResponse>;
|
2006
|
+
deleteDatabase(workspace: WorkspaceID, dbName: DBName): Promise<void>;
|
2007
|
+
}
|
2008
|
+
declare class BranchApi {
|
2009
|
+
private extraProps;
|
2010
|
+
constructor(extraProps: FetcherExtraProps);
|
2011
|
+
getBranchList(workspace: WorkspaceID, dbName: DBName): Promise<ListBranchesResponse>;
|
2012
|
+
getBranchDetails(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<DBBranch>;
|
2013
|
+
createBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, from?: string, options?: CreateBranchRequestBody): Promise<void>;
|
2014
|
+
deleteBranch(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<void>;
|
2015
|
+
updateBranchMetadata(workspace: WorkspaceID, database: DBName, branch: BranchName, metadata?: BranchMetadata): Promise<void>;
|
2016
|
+
getBranchMetadata(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<BranchMetadata>;
|
2017
|
+
getBranchMigrationHistory(workspace: WorkspaceID, database: DBName, branch: BranchName, options?: GetBranchMigrationHistoryRequestBody): Promise<GetBranchMigrationHistoryResponse>;
|
2018
|
+
executeBranchMigrationPlan(workspace: WorkspaceID, database: DBName, branch: BranchName, migrationPlan: ExecuteBranchMigrationPlanRequestBody): Promise<void>;
|
2019
|
+
getBranchMigrationPlan(workspace: WorkspaceID, database: DBName, branch: BranchName, schema: Schema): Promise<BranchMigrationPlan>;
|
2020
|
+
getBranchStats(workspace: WorkspaceID, database: DBName, branch: BranchName): Promise<GetBranchStatsResponse>;
|
2021
|
+
}
|
2022
|
+
declare class TableApi {
|
2023
|
+
private extraProps;
|
2024
|
+
constructor(extraProps: FetcherExtraProps);
|
2025
|
+
createTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<void>;
|
2026
|
+
deleteTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<void>;
|
2027
|
+
updateTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, options: UpdateTableRequestBody): Promise<void>;
|
2028
|
+
getTableSchema(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<GetTableSchemaResponse>;
|
2029
|
+
setTableSchema(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, options: SetTableSchemaRequestBody): Promise<void>;
|
2030
|
+
getTableColumns(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName): Promise<GetTableColumnsResponse>;
|
2031
|
+
addTableColumn(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, column: Column): Promise<MigrationIdResponse>;
|
2032
|
+
getColumn(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, columnName: ColumnName): Promise<Column>;
|
2033
|
+
deleteColumn(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, columnName: ColumnName): Promise<MigrationIdResponse>;
|
2034
|
+
updateColumn(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, columnName: ColumnName, options: UpdateColumnRequestBody): Promise<MigrationIdResponse>;
|
2035
|
+
}
|
2036
|
+
declare class RecordsApi {
|
2037
|
+
private extraProps;
|
2038
|
+
constructor(extraProps: FetcherExtraProps);
|
2039
|
+
insertRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, record: Record<string, any>): Promise<InsertRecordResponse>;
|
2040
|
+
insertRecordWithID(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, record: Record<string, any>, options?: InsertRecordWithIDQueryParams): Promise<RecordUpdateResponse>;
|
2041
|
+
updateRecordWithID(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, record: Record<string, any>, options?: UpdateRecordWithIDQueryParams): Promise<RecordUpdateResponse>;
|
2042
|
+
upsertRecordWithID(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, record: Record<string, any>, options?: UpsertRecordWithIDQueryParams): Promise<RecordUpdateResponse>;
|
2043
|
+
deleteRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID): Promise<void>;
|
2044
|
+
getRecord(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, recordId: RecordID, options?: GetRecordRequestBody): Promise<XataRecord$1>;
|
2045
|
+
bulkInsertTableRecords(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, records: Record<string, any>[]): Promise<BulkInsertTableRecordsResponse>;
|
2046
|
+
queryTable(workspace: WorkspaceID, database: DBName, branch: BranchName, tableName: TableName, query: QueryTableRequestBody): Promise<QueryResponse>;
|
2047
|
+
searchBranch(workspace: WorkspaceID, database: DBName, branch: BranchName, query: SearchBranchRequestBody): Promise<SearchResponse>;
|
2048
|
+
}
|
2049
|
+
|
2050
|
+
declare class XataApiPlugin implements XataPlugin {
|
2051
|
+
build(options: XataPluginOptions): Promise<XataApiClient>;
|
2052
|
+
}
|
2053
|
+
|
2054
|
+
declare type StringKeys<O> = Extract<keyof O, string>;
|
2055
|
+
declare type Values<O> = O[StringKeys<O>];
|
2056
|
+
declare type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) extends (x: infer R) => any ? R : never;
|
2057
|
+
declare type If<Condition, Then, Else> = Condition extends true ? Then : Else;
|
2058
|
+
declare type IsObject<T> = T extends Record<string, any> ? true : false;
|
2059
|
+
declare type IsArray<T> = T extends Array<any> ? true : false;
|
2060
|
+
declare type NonEmptyArray<T> = T[] & {
|
2061
|
+
0: T;
|
2062
|
+
};
|
2063
|
+
declare type RequiredBy<T, K extends keyof T> = T & {
|
2064
|
+
[P in K]-?: NonNullable<T[P]>;
|
2065
|
+
};
|
2066
|
+
declare type SingleOrArray<T> = T | T[];
|
2067
|
+
declare type Dictionary<T> = Record<string, T>;
|
2068
|
+
|
2069
|
+
declare type SelectableColumn<O, RecursivePath extends any[] = []> = '*' | 'id' | DataProps<O> | NestedColumns<O, RecursivePath>;
|
2070
|
+
declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord & UnionToIntersection<Values<{
|
2071
|
+
[K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord;
|
2072
|
+
}>>;
|
2073
|
+
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 XataRecord ? (V extends SelectableColumn<O[K]> ? {
|
2074
|
+
V: ValueAtColumn<O[K], V>;
|
2075
|
+
} : never) : O[K]> : never : never;
|
2076
|
+
declare type MAX_RECURSION = 5;
|
2077
|
+
declare type NestedColumns<O, RecursivePath extends any[]> = RecursivePath['length'] extends MAX_RECURSION ? never : If<IsObject<O>, Values<{
|
2078
|
+
[K in DataProps<O>]: If<IsArray<NonNullable<O[K]>>, K, // If the property is an array, we stop recursion. We don't support object arrays yet
|
2079
|
+
If<IsObject<NonNullable<O[K]>>, NonNullable<O[K]> extends XataRecord ? SelectableColumn<NonNullable<O[K]>, [...RecursivePath, O[K]]> extends string ? K | `${K}.${SelectableColumn<NonNullable<O[K]>, [...RecursivePath, O[K]]>}` : never : `${K}.${StringKeys<NonNullable<O[K]>> | '*'}`, // This allows usage of objects that are not links
|
2080
|
+
K>>;
|
2081
|
+
}>, never>;
|
2082
|
+
declare type DataProps<O> = Exclude<StringKeys<O>, StringKeys<XataRecord>>;
|
2083
|
+
declare type NestedValueAtColumn<O, Key extends SelectableColumn<O>> = Key extends `${infer N}.${infer M}` ? N extends DataProps<O> ? {
|
2084
|
+
[K in N]: M extends SelectableColumn<NonNullable<O[K]>> ? NonNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], NestedValueAtColumn<NonNullable<O[K]>, M> & XataRecord> : ForwardNullable<O[K], NestedValueAtColumn<NonNullable<O[K]>, M>> : unknown;
|
2085
|
+
} : unknown : Key extends DataProps<O> ? {
|
2086
|
+
[K in Key]: NonNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], SelectedPick<NonNullable<O[K]>, ['*']>> : O[K];
|
2087
|
+
} : Key extends '*' ? {
|
2088
|
+
[K in StringKeys<O>]: NonNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], Link<NonNullable<O[K]>>> : O[K];
|
2089
|
+
} : unknown;
|
2090
|
+
declare type ForwardNullable<T, R> = T extends NonNullable<T> ? R : R | null;
|
2091
|
+
|
2092
|
+
/**
|
2093
|
+
* Represents an identifiable record from the database.
|
2094
|
+
*/
|
2095
|
+
interface Identifiable {
|
2096
|
+
/**
|
2097
|
+
* Unique id of this record.
|
2098
|
+
*/
|
2099
|
+
id: string;
|
2100
|
+
}
|
2101
|
+
interface BaseData {
|
2102
|
+
[key: string]: any;
|
2103
|
+
}
|
2104
|
+
/**
|
2105
|
+
* Represents a persisted record from the database.
|
2106
|
+
*/
|
2107
|
+
interface XataRecord extends Identifiable {
|
2108
|
+
/**
|
2109
|
+
* Metadata of this record.
|
2110
|
+
*/
|
2111
|
+
xata: {
|
2112
|
+
/**
|
2113
|
+
* Number that is increased every time the record is updated.
|
2114
|
+
*/
|
2115
|
+
version: number;
|
2116
|
+
};
|
2117
|
+
/**
|
2118
|
+
* Retrieves a refreshed copy of the current record from the database.
|
2119
|
+
*/
|
2120
|
+
read(): Promise<Readonly<SelectedPick<this, ['*']>> | null>;
|
2121
|
+
/**
|
2122
|
+
* Performs a partial update of the current record. On success a new object is
|
2123
|
+
* returned and the current object is not mutated.
|
2124
|
+
* @param data The columns and their values that have to be updated.
|
2125
|
+
* @returns A new record containing the latest values for all the columns of the current record.
|
2126
|
+
*/
|
2127
|
+
update(partialUpdate: Partial<EditableData<Omit<this, keyof XataRecord>>>): Promise<Readonly<SelectedPick<this, ['*']>>>;
|
2128
|
+
/**
|
2129
|
+
* Performs a deletion of the current record in the database.
|
2130
|
+
*
|
2131
|
+
* @throws If the record was already deleted or if an error happened while performing the deletion.
|
2132
|
+
*/
|
2133
|
+
delete(): Promise<void>;
|
2134
|
+
}
|
2135
|
+
declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update'> & {
|
2136
|
+
/**
|
2137
|
+
* Retrieves a refreshed copy of the current record from the database.
|
2138
|
+
*/
|
2139
|
+
read(): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
|
2140
|
+
/**
|
2141
|
+
* Performs a partial update of the current record. On success a new object is
|
2142
|
+
* returned and the current object is not mutated.
|
2143
|
+
* @param data The columns and their values that have to be updated.
|
2144
|
+
* @returns A new record containing the latest values for all the columns of the current record.
|
2145
|
+
*/
|
2146
|
+
update(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
2147
|
+
};
|
2148
|
+
declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
|
2149
|
+
declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
|
2150
|
+
declare type EditableData<O extends BaseData> = {
|
2151
|
+
[K in keyof O]: O[K] extends XataRecord ? {
|
2152
|
+
id: string;
|
2153
|
+
} : NonNullable<O[K]> extends XataRecord ? {
|
2154
|
+
id: string;
|
2155
|
+
} | null | undefined : O[K];
|
2156
|
+
};
|
2157
|
+
|
2158
|
+
/**
|
2159
|
+
* PropertyMatchFilter
|
2160
|
+
* Example:
|
2161
|
+
{
|
2162
|
+
"filter": {
|
2163
|
+
"name": "value",
|
2164
|
+
"name": {
|
2165
|
+
"$is": "value",
|
2166
|
+
"$any": [ "value1", "value2" ],
|
2167
|
+
},
|
2168
|
+
"settings.plan": {"$any": ["free", "paid"]},
|
2169
|
+
"settings.plan": "free",
|
2170
|
+
"settings": {
|
2171
|
+
"plan": "free"
|
2172
|
+
},
|
2173
|
+
}
|
2174
|
+
}
|
2175
|
+
*/
|
2176
|
+
declare type PropertyAccessFilter<Record> = {
|
2177
|
+
[key in SelectableColumn<Record>]?: NestedApiFilter<ValueAtColumn<Record, key>> | PropertyFilter<ValueAtColumn<Record, key>>;
|
2178
|
+
};
|
2179
|
+
declare type PropertyFilter<T> = T | {
|
2180
|
+
$is: T;
|
2181
|
+
} | {
|
2182
|
+
$isNot: T;
|
2183
|
+
} | {
|
2184
|
+
$any: T[];
|
2185
|
+
} | {
|
2186
|
+
$none: T[];
|
2187
|
+
} | ValueTypeFilters<T>;
|
2188
|
+
declare type IncludesFilter<T> = PropertyFilter<T> | {
|
2189
|
+
[key in '$all' | '$none' | '$any']?: IncludesFilter<T> | Array<IncludesFilter<T> | {
|
2190
|
+
$not: IncludesFilter<T>;
|
2191
|
+
}>;
|
2192
|
+
};
|
2193
|
+
declare type StringTypeFilter = {
|
2194
|
+
[key in '$contains' | '$pattern' | '$startsWith' | '$endsWith']?: string;
|
2195
|
+
};
|
2196
|
+
declare type ComparableType = number | Date;
|
2197
|
+
declare type ComparableTypeFilter<T extends ComparableType> = {
|
2198
|
+
[key in '$gt' | '$lt' | '$ge' | '$le']?: T;
|
2199
|
+
};
|
2200
|
+
declare type ArrayFilter<T> = {
|
2201
|
+
[key in '$includes']?: SingleOrArray<PropertyFilter<T> | ValueTypeFilters<T>> | IncludesFilter<T>;
|
2202
|
+
} | {
|
2203
|
+
[key in '$includesAll' | '$includesNone' | '$includesAny']?: T | Array<PropertyFilter<T> | {
|
2204
|
+
$not: PropertyFilter<T>;
|
2205
|
+
}>;
|
2206
|
+
};
|
2207
|
+
declare type ValueTypeFilters<T> = T | T extends string ? StringTypeFilter : T extends number ? ComparableTypeFilter<number> : T extends Date ? ComparableTypeFilter<Date> : T extends Array<infer T> ? ArrayFilter<T> : never;
|
2208
|
+
/**
|
2209
|
+
* AggregatorFilter
|
2210
|
+
* Example:
|
2211
|
+
{
|
2212
|
+
"filter": {
|
2213
|
+
"$any": {
|
2214
|
+
"settings.dark": true,
|
2215
|
+
"settings.plan": "free"
|
2216
|
+
}
|
2217
|
+
},
|
2218
|
+
}
|
2219
|
+
{
|
2220
|
+
"filter": {
|
2221
|
+
"$any": [
|
2222
|
+
{
|
2223
|
+
"name": "r1",
|
2224
|
+
},
|
2225
|
+
{
|
2226
|
+
"name": "r2",
|
2227
|
+
},
|
2228
|
+
],
|
2229
|
+
}
|
2230
|
+
*/
|
2231
|
+
declare type AggregatorFilter<Record> = {
|
2232
|
+
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<Record>>;
|
2233
|
+
};
|
2234
|
+
/**
|
2235
|
+
* Existance filter
|
2236
|
+
* Example: { filter: { $exists: "settings" } }
|
2237
|
+
*/
|
2238
|
+
declare type ExistanceFilter<Record> = {
|
2239
|
+
[key in '$exists' | '$notExists']?: SelectableColumn<Record>;
|
2240
|
+
};
|
2241
|
+
declare type BaseApiFilter<Record> = PropertyAccessFilter<Record> | AggregatorFilter<Record> | ExistanceFilter<Record>;
|
2242
|
+
/**
|
2243
|
+
* Nested filter
|
2244
|
+
* Injects the Api filters on nested properties
|
2245
|
+
* Example: { filter: { settings: { plan: { $any: ['free', 'trial'] } } } }
|
2246
|
+
*/
|
2247
|
+
declare type NestedApiFilter<T> = T extends Record<string, any> ? {
|
2248
|
+
[key in keyof T]?: T[key] extends Record<string, any> ? SingleOrArray<Filter<T[key]>> : PropertyFilter<T[key]>;
|
2249
|
+
} : PropertyFilter<T>;
|
2250
|
+
declare type Filter<Record> = BaseApiFilter<Record> | NestedApiFilter<Record>;
|
2251
|
+
|
2252
|
+
declare type SortDirection = 'asc' | 'desc';
|
2253
|
+
declare type SortFilterExtended<T extends XataRecord> = {
|
2254
|
+
column: SelectableColumn<T>;
|
2255
|
+
direction?: SortDirection;
|
2256
|
+
};
|
2257
|
+
declare type SortFilter<T extends XataRecord> = SelectableColumn<T> | SortFilterExtended<T> | SortFilterBase<T>;
|
2258
|
+
declare type SortFilterBase<T extends XataRecord> = {
|
2259
|
+
[Key in StringKeys<T>]: SortDirection;
|
2260
|
+
};
|
2261
|
+
|
2262
|
+
declare type QueryOptions<T extends XataRecord> = {
|
2263
|
+
page?: PaginationOptions;
|
2264
|
+
columns?: NonEmptyArray<SelectableColumn<T>>;
|
2265
|
+
filter?: FilterExpression;
|
2266
|
+
sort?: SortFilter<T> | SortFilter<T>[];
|
2267
|
+
};
|
2268
|
+
/**
|
2269
|
+
* Query objects contain the information of all filters, sorting, etc. to be included in the database query.
|
2270
|
+
*
|
2271
|
+
* Query objects are immutable. Any method that adds more constraints or options to the query will return
|
2272
|
+
* a new Query object containing the both the previous and the new constraints and options.
|
2273
|
+
*/
|
2274
|
+
declare class Query<Record extends XataRecord, Result extends XataRecord = Record> implements Paginable<Record, Result> {
|
2275
|
+
#private;
|
2276
|
+
readonly meta: PaginationQueryMeta;
|
2277
|
+
readonly records: Result[];
|
2278
|
+
constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, parent?: Partial<QueryOptions<Record>>);
|
2279
|
+
getQueryOptions(): QueryOptions<Record>;
|
2280
|
+
/**
|
2281
|
+
* Builds a new query object representing a logical OR between the given subqueries.
|
2282
|
+
* @param queries An array of subqueries.
|
2283
|
+
* @returns A new Query object.
|
2284
|
+
*/
|
2285
|
+
any(...queries: Query<Record, any>[]): Query<Record, Result>;
|
2286
|
+
/**
|
2287
|
+
* Builds a new query object representing a logical AND between the given subqueries.
|
2288
|
+
* @param queries An array of subqueries.
|
2289
|
+
* @returns A new Query object.
|
2290
|
+
*/
|
2291
|
+
all(...queries: Query<Record, any>[]): Query<Record, Result>;
|
2292
|
+
/**
|
2293
|
+
* Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
|
2294
|
+
* @param queries An array of subqueries.
|
2295
|
+
* @returns A new Query object.
|
2296
|
+
*/
|
2297
|
+
not(...queries: Query<Record, any>[]): Query<Record, Result>;
|
2298
|
+
/**
|
2299
|
+
* Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
|
2300
|
+
* @param queries An array of subqueries.
|
2301
|
+
* @returns A new Query object.
|
2302
|
+
*/
|
2303
|
+
none(...queries: Query<Record, any>[]): Query<Record, Result>;
|
2304
|
+
/**
|
2305
|
+
* Builds a new query object adding one or more constraints. Examples:
|
2306
|
+
*
|
2307
|
+
* ```
|
2308
|
+
* query.filter("columnName", columnValue)
|
2309
|
+
* query.filter({
|
2310
|
+
* "columnName": columnValue
|
2311
|
+
* })
|
2312
|
+
* query.filter({
|
2313
|
+
* "columnName": operator(columnValue) // Use gt, gte, lt, lte, startsWith,...
|
2314
|
+
* })
|
2315
|
+
* ```
|
2316
|
+
*
|
2317
|
+
* @returns A new Query object.
|
2318
|
+
*/
|
2319
|
+
filter(filters: Filter<Record>): Query<Record, Result>;
|
2320
|
+
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
|
2321
|
+
/**
|
2322
|
+
* Builds a new query with a new sort option.
|
2323
|
+
* @param column The column name.
|
2324
|
+
* @param direction The direction. Either ascending or descending.
|
2325
|
+
* @returns A new Query object.
|
2326
|
+
*/
|
2327
|
+
sort<F extends SelectableColumn<Record>>(column: F, direction: SortDirection): Query<Record, Result>;
|
2328
|
+
/**
|
2329
|
+
* Builds a new query specifying the set of columns to be returned in the query response.
|
2330
|
+
* @param columns Array of column names to be returned by the query.
|
2331
|
+
* @returns A new Query object.
|
2332
|
+
*/
|
2333
|
+
select<K extends SelectableColumn<Record>>(columns: NonEmptyArray<K>): Query<Record, SelectedPick<Record, NonEmptyArray<K>>>;
|
2334
|
+
getPaginated(): Promise<Page<Record, Result>>;
|
2335
|
+
getPaginated(options: Omit<QueryOptions<Record>, 'columns'>): Promise<Page<Record, Result>>;
|
2336
|
+
getPaginated<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<Page<Record, SelectedPick<Record, typeof options['columns']>>>;
|
2337
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<Result>;
|
2338
|
+
getIterator(chunk: number): AsyncGenerator<Result[]>;
|
2339
|
+
getIterator(chunk: number, options: Omit<QueryOptions<Record>, 'columns' | 'page'>): AsyncGenerator<Result[]>;
|
2340
|
+
getIterator<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(chunk: number, options: Options): AsyncGenerator<SelectedPick<Record, typeof options['columns']>[]>;
|
2341
|
+
/**
|
2342
|
+
* Performs the query in the database and returns a set of results.
|
2343
|
+
* @param options Additional options to be used when performing the query.
|
2344
|
+
* @returns An array of records from the database.
|
2345
|
+
*/
|
2346
|
+
getMany(): Promise<Result[]>;
|
2347
|
+
getMany(options: Omit<QueryOptions<Record>, 'columns'>): Promise<Result[]>;
|
2348
|
+
getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
|
2349
|
+
/**
|
2350
|
+
* Performs the query in the database and returns all the results.
|
2351
|
+
* Warning: If there are a large number of results, this method can have performance implications.
|
2352
|
+
* @param options Additional options to be used when performing the query.
|
2353
|
+
* @returns An array of records from the database.
|
2354
|
+
*/
|
2355
|
+
getAll(chunk?: number): Promise<Result[]>;
|
2356
|
+
getAll(chunk: number | undefined, options: Omit<QueryOptions<Record>, 'columns' | 'page'>): Promise<Result[]>;
|
2357
|
+
getAll<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(chunk: number | undefined, options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
|
2358
|
+
/**
|
2359
|
+
* Performs the query in the database and returns the first result.
|
2360
|
+
* @param options Additional options to be used when performing the query.
|
2361
|
+
* @returns The first record that matches the query, or null if no record matched the query.
|
2362
|
+
*/
|
2363
|
+
getOne(): Promise<Result | null>;
|
2364
|
+
getOne(options: Omit<QueryOptions<Record>, 'columns' | 'page'>): Promise<Result | null>;
|
2365
|
+
getOne<Options extends RequiredBy<Omit<QueryOptions<Record>, 'page'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
|
2366
|
+
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2367
|
+
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2368
|
+
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2369
|
+
lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2370
|
+
hasNextPage(): boolean;
|
2371
|
+
}
|
2372
|
+
|
2373
|
+
declare type PaginationQueryMeta = {
|
2374
|
+
page: {
|
2375
|
+
cursor: string;
|
2376
|
+
more: boolean;
|
2377
|
+
};
|
2378
|
+
};
|
2379
|
+
interface Paginable<Record extends XataRecord, Result extends XataRecord = Record> {
|
2380
|
+
meta: PaginationQueryMeta;
|
2381
|
+
records: Result[];
|
2382
|
+
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2383
|
+
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2384
|
+
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2385
|
+
lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2386
|
+
hasNextPage(): boolean;
|
2387
|
+
}
|
2388
|
+
/**
|
2389
|
+
* A Page contains a set of results from a query plus metadata about the retrieved
|
2390
|
+
* set of values such as the cursor, required to retrieve additional records.
|
2391
|
+
*/
|
2392
|
+
declare class Page<Record extends XataRecord, Result extends XataRecord = Record> implements Paginable<Record, Result> {
|
2393
|
+
#private;
|
2394
|
+
/**
|
2395
|
+
* Page metadata, required to retrieve additional records.
|
2396
|
+
*/
|
2397
|
+
readonly meta: PaginationQueryMeta;
|
2398
|
+
/**
|
2399
|
+
* The set of results for this page.
|
2400
|
+
*/
|
2401
|
+
readonly records: Result[];
|
2402
|
+
constructor(query: Query<Record, Result>, meta: PaginationQueryMeta, records?: Result[]);
|
2403
|
+
/**
|
2404
|
+
* Retrieves the next page of results.
|
2405
|
+
* @param size Maximum number of results to be retrieved.
|
2406
|
+
* @param offset Number of results to skip when retrieving the results.
|
2407
|
+
* @returns The next page or results.
|
2408
|
+
*/
|
2409
|
+
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2410
|
+
/**
|
2411
|
+
* Retrieves the previous page of results.
|
2412
|
+
* @param size Maximum number of results to be retrieved.
|
2413
|
+
* @param offset Number of results to skip when retrieving the results.
|
2414
|
+
* @returns The previous page or results.
|
2415
|
+
*/
|
2416
|
+
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2417
|
+
/**
|
2418
|
+
* Retrieves the first page of results.
|
2419
|
+
* @param size Maximum number of results to be retrieved.
|
2420
|
+
* @param offset Number of results to skip when retrieving the results.
|
2421
|
+
* @returns The first page or results.
|
2422
|
+
*/
|
2423
|
+
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2424
|
+
/**
|
2425
|
+
* Retrieves the last page of results.
|
2426
|
+
* @param size Maximum number of results to be retrieved.
|
2427
|
+
* @param offset Number of results to skip when retrieving the results.
|
2428
|
+
* @returns The last page or results.
|
2429
|
+
*/
|
2430
|
+
lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
2431
|
+
/**
|
2432
|
+
* Shortcut method to check if there will be additional results if the next page of results is retrieved.
|
2433
|
+
* @returns Whether or not there will be additional results in the next page of results.
|
2434
|
+
*/
|
2435
|
+
hasNextPage(): boolean;
|
2436
|
+
}
|
2437
|
+
declare type CursorNavigationOptions = {
|
2438
|
+
first?: string;
|
2439
|
+
} | {
|
2440
|
+
last?: string;
|
2441
|
+
} | {
|
2442
|
+
after?: string;
|
2443
|
+
before?: string;
|
2444
|
+
};
|
2445
|
+
declare type OffsetNavigationOptions = {
|
2446
|
+
size?: number;
|
2447
|
+
offset?: number;
|
2448
|
+
};
|
2449
|
+
declare type PaginationOptions = CursorNavigationOptions & OffsetNavigationOptions;
|
2450
|
+
declare const PAGINATION_MAX_SIZE = 200;
|
2451
|
+
declare const PAGINATION_DEFAULT_SIZE = 200;
|
2452
|
+
declare const PAGINATION_MAX_OFFSET = 800;
|
2453
|
+
declare const PAGINATION_DEFAULT_OFFSET = 0;
|
2454
|
+
|
2455
|
+
declare type TableLink = string[];
|
2456
|
+
declare type LinkDictionary = Dictionary<TableLink[]>;
|
2457
|
+
/**
|
2458
|
+
* Common interface for performing operations on a table.
|
2459
|
+
*/
|
2460
|
+
declare abstract class Repository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, Readonly<SelectedPick<Record, ['*']>>> {
|
2461
|
+
abstract create(object: EditableData<Data> & Partial<Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
2462
|
+
/**
|
2463
|
+
* Creates a single record in the table with a unique id.
|
2464
|
+
* @param id The unique id.
|
2465
|
+
* @param object Object containing the column names with their values to be stored in the table.
|
2466
|
+
* @returns The full persisted record.
|
2467
|
+
*/
|
2468
|
+
abstract create(id: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
2469
|
+
/**
|
2470
|
+
* Creates multiple records in the table.
|
2471
|
+
* @param objects Array of objects with the column names and the values to be stored in the table.
|
2472
|
+
* @returns Array of the persisted records.
|
2473
|
+
*/
|
2474
|
+
abstract create(objects: Array<EditableData<Data> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
|
2475
|
+
/**
|
2476
|
+
* Queries a single record from the table given its unique id.
|
2477
|
+
* @param id The unique id.
|
2478
|
+
* @returns The persisted record for the given id or null if the record could not be found.
|
2479
|
+
*/
|
2480
|
+
abstract read(id: string): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
|
2481
|
+
/**
|
2482
|
+
* Partially update a single record.
|
2483
|
+
* @param object An object with its id and the columns to be updated.
|
2484
|
+
* @returns The full persisted record.
|
2485
|
+
*/
|
2486
|
+
abstract update(object: Partial<EditableData<Data>> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
2487
|
+
/**
|
2488
|
+
* Partially update a single record given its unique id.
|
2489
|
+
* @param id The unique id.
|
2490
|
+
* @param object The column names and their values that have to be updated.
|
2491
|
+
* @returns The full persisted record.
|
2492
|
+
*/
|
2493
|
+
abstract update(id: string, object: Partial<EditableData<Data>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
2494
|
+
/**
|
2495
|
+
* Partially updates multiple records.
|
2496
|
+
* @param objects An array of objects with their ids and columns to be updated.
|
2497
|
+
* @returns Array of the persisted records.
|
2498
|
+
*/
|
2499
|
+
abstract update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
|
2500
|
+
/**
|
2501
|
+
* Creates or updates a single record. If a record exists with the given id,
|
2502
|
+
* it will be update, otherwise a new record will be created.
|
2503
|
+
* @param object Object containing the column names with their values to be persisted in the table.
|
2504
|
+
* @returns The full persisted record.
|
2505
|
+
*/
|
2506
|
+
abstract createOrUpdate(object: EditableData<Data> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
2507
|
+
/**
|
2508
|
+
* Creates or updates a single record. If a record exists with the given id,
|
2509
|
+
* it will be update, otherwise a new record will be created.
|
2510
|
+
* @param id A unique id.
|
2511
|
+
* @param object The column names and the values to be persisted.
|
2512
|
+
* @returns The full persisted record.
|
2513
|
+
*/
|
2514
|
+
abstract createOrUpdate(id: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
2515
|
+
/**
|
2516
|
+
* Creates or updates a single record. If a record exists with the given id,
|
2517
|
+
* it will be update, otherwise a new record will be created.
|
2518
|
+
* @param objects Array of objects with the column names and the values to be stored in the table.
|
2519
|
+
* @returns Array of the persisted records.
|
2520
|
+
*/
|
2521
|
+
abstract createOrUpdate(objects: Array<EditableData<Data> & Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
|
2522
|
+
/**
|
2523
|
+
* Deletes a record given its unique id.
|
2524
|
+
* @param id The unique id.
|
2525
|
+
* @throws If the record could not be found or there was an error while performing the deletion.
|
2526
|
+
*/
|
2527
|
+
abstract delete(id: string): Promise<void>;
|
2528
|
+
/**
|
2529
|
+
* Deletes a record given its unique id.
|
2530
|
+
* @param id An object with a unique id.
|
2531
|
+
* @throws If the record could not be found or there was an error while performing the deletion.
|
2532
|
+
*/
|
2533
|
+
abstract delete(id: Identifiable): Promise<void>;
|
2534
|
+
/**
|
2535
|
+
* Deletes a record given a list of unique ids.
|
2536
|
+
* @param ids The array of unique ids.
|
2537
|
+
* @throws If the record could not be found or there was an error while performing the deletion.
|
2538
|
+
*/
|
2539
|
+
abstract delete(ids: string[]): Promise<void>;
|
2540
|
+
/**
|
2541
|
+
* Deletes a record given a list of unique ids.
|
2542
|
+
* @param ids An array of objects with unique ids.
|
2543
|
+
* @throws If the record could not be found or there was an error while performing the deletion.
|
2544
|
+
*/
|
2545
|
+
abstract delete(ids: Identifiable[]): Promise<void>;
|
2546
|
+
/**
|
2547
|
+
* Search for records in the table.
|
2548
|
+
* @param query The query to search for.
|
2549
|
+
* @param options The options to search with (like: fuzziness)
|
2550
|
+
* @returns The found records.
|
2551
|
+
*/
|
2552
|
+
abstract search(query: string, options?: {
|
2553
|
+
fuzziness?: number;
|
2554
|
+
}): Promise<SelectedPick<Record, ['*']>[]>;
|
2555
|
+
abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
2556
|
+
}
|
2557
|
+
declare class RestRepository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, SelectedPick<Record, ['*']>> implements Repository<Data, Record> {
|
2558
|
+
#private;
|
2559
|
+
db: SchemaPluginResult<any>;
|
2560
|
+
constructor(options: {
|
2561
|
+
table: string;
|
2562
|
+
links?: LinkDictionary;
|
2563
|
+
getFetchProps: () => Promise<FetcherExtraProps>;
|
2564
|
+
db: SchemaPluginResult<any>;
|
2565
|
+
});
|
2566
|
+
create(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
|
2567
|
+
create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
|
2568
|
+
create(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
|
2569
|
+
read(recordId: string): Promise<SelectedPick<Record, ['*']> | null>;
|
2570
|
+
update(object: Partial<EditableData<Data>> & Identifiable): Promise<SelectedPick<Record, ['*']>>;
|
2571
|
+
update(recordId: string, object: Partial<EditableData<Data>>): Promise<SelectedPick<Record, ['*']>>;
|
2572
|
+
update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<SelectedPick<Record, ['*']>[]>;
|
2573
|
+
createOrUpdate(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
|
2574
|
+
createOrUpdate(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
|
2575
|
+
createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
|
2576
|
+
delete(recordId: string | Identifiable | Array<string | Identifiable>): Promise<void>;
|
2577
|
+
search(query: string, options?: {
|
2578
|
+
fuzziness?: number;
|
2579
|
+
}): Promise<SelectedPick<Record, ['*']>[]>;
|
2580
|
+
query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
|
2581
|
+
}
|
2582
|
+
|
2583
|
+
/**
|
2584
|
+
* Operator to restrict results to only values that are greater than the given value.
|
2585
|
+
*/
|
2586
|
+
declare const gt: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
2587
|
+
/**
|
2588
|
+
* Operator to restrict results to only values that are greater than or equal to the given value.
|
2589
|
+
*/
|
2590
|
+
declare const ge: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
2591
|
+
/**
|
2592
|
+
* Operator to restrict results to only values that are greater than or equal to the given value.
|
2593
|
+
*/
|
2594
|
+
declare const gte: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
2595
|
+
/**
|
2596
|
+
* Operator to restrict results to only values that are lower than the given value.
|
2597
|
+
*/
|
2598
|
+
declare const lt: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
2599
|
+
/**
|
2600
|
+
* Operator to restrict results to only values that are lower than or equal to the given value.
|
2601
|
+
*/
|
2602
|
+
declare const lte: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
2603
|
+
/**
|
2604
|
+
* Operator to restrict results to only values that are lower than or equal to the given value.
|
2605
|
+
*/
|
2606
|
+
declare const le: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
2607
|
+
/**
|
2608
|
+
* Operator to restrict results to only values that are not null.
|
2609
|
+
*/
|
2610
|
+
declare const exists: <T>(column: SelectableColumn<T, []>) => ExistanceFilter<T>;
|
2611
|
+
/**
|
2612
|
+
* Operator to restrict results to only values that are null.
|
2613
|
+
*/
|
2614
|
+
declare const notExists: <T>(column: SelectableColumn<T, []>) => ExistanceFilter<T>;
|
2615
|
+
/**
|
2616
|
+
* Operator to restrict results to only values that start with the given prefix.
|
2617
|
+
*/
|
2618
|
+
declare const startsWith: (value: string) => StringTypeFilter;
|
2619
|
+
/**
|
2620
|
+
* Operator to restrict results to only values that end with the given suffix.
|
2621
|
+
*/
|
2622
|
+
declare const endsWith: (value: string) => StringTypeFilter;
|
2623
|
+
/**
|
2624
|
+
* Operator to restrict results to only values that match the given pattern.
|
2625
|
+
*/
|
2626
|
+
declare const pattern: (value: string) => StringTypeFilter;
|
2627
|
+
/**
|
2628
|
+
* Operator to restrict results to only values that are equal to the given value.
|
2629
|
+
*/
|
2630
|
+
declare const is: <T>(value: T) => PropertyFilter<T>;
|
2631
|
+
/**
|
2632
|
+
* Operator to restrict results to only values that are not equal to the given value.
|
2633
|
+
*/
|
2634
|
+
declare const isNot: <T>(value: T) => PropertyFilter<T>;
|
2635
|
+
/**
|
2636
|
+
* Operator to restrict results to only values that contain the given value.
|
2637
|
+
*/
|
2638
|
+
declare const contains: (value: string) => StringTypeFilter;
|
2639
|
+
/**
|
2640
|
+
* Operator to restrict results if some array items match the predicate.
|
2641
|
+
*/
|
2642
|
+
declare const includes: <T>(value: T) => ArrayFilter<T>;
|
2643
|
+
/**
|
2644
|
+
* Operator to restrict results if all array items match the predicate.
|
2645
|
+
*/
|
2646
|
+
declare const includesAll: <T>(value: T) => ArrayFilter<T>;
|
2647
|
+
/**
|
2648
|
+
* Operator to restrict results if none array items match the predicate.
|
2649
|
+
*/
|
2650
|
+
declare const includesNone: <T>(value: T) => ArrayFilter<T>;
|
2651
|
+
/**
|
2652
|
+
* Operator to restrict results if some array items match the predicate.
|
2653
|
+
*/
|
2654
|
+
declare const includesAny: <T>(value: T) => ArrayFilter<T>;
|
2655
|
+
|
2656
|
+
declare type SchemaDefinition = {
|
2657
|
+
table: string;
|
2658
|
+
links?: LinkDictionary;
|
2659
|
+
};
|
2660
|
+
declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
|
2661
|
+
[Key in keyof Schemas]: Repository<Schemas[Key]>;
|
2662
|
+
};
|
2663
|
+
declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
2664
|
+
#private;
|
2665
|
+
private links?;
|
2666
|
+
constructor(links?: LinkDictionary | undefined);
|
2667
|
+
build(options: XataPluginOptions): SchemaPluginResult<Schemas>;
|
2668
|
+
}
|
2669
|
+
|
2670
|
+
declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
|
2671
|
+
#private;
|
2672
|
+
build({ getFetchProps }: XataPluginOptions): {
|
2673
|
+
all: <Tables extends Extract<keyof Schemas, string>>(query: string, options?: {
|
2674
|
+
fuzziness?: number | undefined;
|
2675
|
+
tables?: Tables[] | undefined;
|
2676
|
+
}) => Promise<Values<{ [Model in Tables]: {
|
2677
|
+
table: Model;
|
2678
|
+
record: Awaited<SelectedPick<Schemas[Model] & XataRecord & {
|
2679
|
+
xata: {
|
2680
|
+
table: string;
|
2681
|
+
};
|
2682
|
+
}, ["*"]>>;
|
2683
|
+
}; }>[]>;
|
2684
|
+
byTable: <Tables_1 extends Extract<keyof Schemas, string>>(query: string, options?: {
|
2685
|
+
fuzziness?: number | undefined;
|
2686
|
+
tables?: Tables_1[] | undefined;
|
2687
|
+
}) => Promise<{ [Model_1 in Tables_1]: SelectedPick<Schemas[Model_1] & XataRecord & {
|
2688
|
+
xata: {
|
2689
|
+
table: string;
|
2690
|
+
};
|
2691
|
+
}, ["*"]>[]; }>;
|
2692
|
+
};
|
2693
|
+
}
|
2694
|
+
|
2695
|
+
declare type BranchStrategyValue = string | undefined | null;
|
2696
|
+
declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
|
2697
|
+
declare type BranchStrategy = BranchStrategyValue | BranchStrategyBuilder;
|
2698
|
+
declare type BranchStrategyOption = NonNullable<BranchStrategy | BranchStrategy[]>;
|
2699
|
+
|
2700
|
+
declare type BaseClientOptions = {
|
2701
|
+
fetch?: FetchImpl;
|
2702
|
+
apiKey?: string;
|
2703
|
+
databaseURL?: string;
|
2704
|
+
branch?: BranchStrategyOption;
|
2705
|
+
};
|
2706
|
+
declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
|
2707
|
+
interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
|
2708
|
+
new <Schemas extends Record<string, BaseData>>(options?: Partial<BaseClientOptions>, links?: LinkDictionary): Omit<{
|
2709
|
+
db: Awaited<ReturnType<SchemaPlugin<Schemas>['build']>>;
|
2710
|
+
search: Awaited<ReturnType<SearchPlugin<Schemas>['build']>>;
|
2711
|
+
}, keyof Plugins> & {
|
2712
|
+
[Key in StringKeys<NonNullable<Plugins>>]: Awaited<ReturnType<NonNullable<Plugins>[Key]['build']>>;
|
2713
|
+
};
|
2714
|
+
}
|
2715
|
+
declare const BaseClient_base: ClientConstructor<{}>;
|
2716
|
+
declare class BaseClient extends BaseClient_base<Record<string, any>> {
|
2717
|
+
}
|
2718
|
+
|
2719
|
+
declare type BranchResolutionOptions = {
|
2720
|
+
databaseURL?: string;
|
2721
|
+
apiKey?: string;
|
2722
|
+
fetchImpl?: FetchImpl;
|
2723
|
+
};
|
2724
|
+
declare function getCurrentBranchName(options?: BranchResolutionOptions): Promise<string | undefined>;
|
2725
|
+
declare function getCurrentBranchDetails(options?: BranchResolutionOptions): Promise<DBBranch | null>;
|
2726
|
+
declare function getDatabaseURL(): string | undefined;
|
2727
|
+
declare function getAPIKey(): string | undefined;
|
2728
|
+
|
2729
|
+
declare class XataError extends Error {
|
2
2730
|
readonly status: number;
|
3
2731
|
constructor(message: string, status: number);
|
4
2732
|
}
|
5
|
-
|
6
|
-
export
|
7
|
-
export * from './client';
|
8
|
-
export * from './schema';
|
9
|
-
export * from './search';
|
10
|
-
export * from './util/config';
|
2733
|
+
|
2734
|
+
export { AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsResponse, BulkInsertTableRecordsVariables, CancelWorkspaceMemberInvitePathParams, CancelWorkspaceMemberInviteVariables, ClientConstructor, CreateBranchPathParams, CreateBranchQueryParams, CreateBranchRequestBody, CreateBranchVariables, CreateDatabasePathParams, CreateDatabaseRequestBody, CreateDatabaseResponse, CreateDatabaseVariables, CreateTablePathParams, CreateTableVariables, CreateUserAPIKeyPathParams, CreateUserAPIKeyResponse, CreateUserAPIKeyVariables, CreateWorkspaceVariables, CursorNavigationOptions, DeleteBranchPathParams, DeleteBranchVariables, DeleteColumnPathParams, DeleteColumnVariables, DeleteDatabasePathParams, DeleteDatabaseVariables, DeleteRecordPathParams, DeleteRecordVariables, DeleteTablePathParams, DeleteTableVariables, DeleteUserAPIKeyPathParams, DeleteUserAPIKeyVariables, DeleteUserVariables, DeleteWorkspacePathParams, DeleteWorkspaceVariables, EditableData, ExecuteBranchMigrationPlanPathParams, ExecuteBranchMigrationPlanRequestBody, ExecuteBranchMigrationPlanVariables, FetchImpl, FetcherExtraProps, GetBranchDetailsPathParams, GetBranchDetailsVariables, GetBranchListPathParams, GetBranchListVariables, GetBranchMetadataPathParams, GetBranchMetadataVariables, GetBranchMigrationHistoryPathParams, GetBranchMigrationHistoryRequestBody, GetBranchMigrationHistoryResponse, GetBranchMigrationHistoryVariables, GetBranchMigrationPlanPathParams, GetBranchMigrationPlanVariables, GetBranchStatsPathParams, GetBranchStatsResponse, GetBranchStatsVariables, GetColumnPathParams, GetColumnVariables, GetDatabaseListPathParams, GetDatabaseListVariables, GetRecordPathParams, GetRecordRequestBody, GetRecordVariables, GetTableColumnsPathParams, GetTableColumnsResponse, GetTableColumnsVariables, GetTableSchemaPathParams, GetTableSchemaResponse, GetTableSchemaVariables, GetUserAPIKeysResponse, GetUserAPIKeysVariables, GetUserVariables, GetWorkspaceMembersListPathParams, GetWorkspaceMembersListVariables, GetWorkspacePathParams, GetWorkspaceVariables, GetWorkspacesListResponse, GetWorkspacesListVariables, Identifiable, InsertRecordPathParams, InsertRecordResponse, InsertRecordVariables, InsertRecordWithIDPathParams, InsertRecordWithIDQueryParams, InsertRecordWithIDVariables, InviteWorkspaceMemberPathParams, InviteWorkspaceMemberRequestBody, InviteWorkspaceMemberVariables, LinkDictionary, OffsetNavigationOptions, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Paginable, PaginationOptions, PaginationQueryMeta, Query, QueryTablePathParams, QueryTableRequestBody, QueryTableVariables, RemoveWorkspaceMemberPathParams, RemoveWorkspaceMemberVariables, Repository, ResendWorkspaceMemberInvitePathParams, ResendWorkspaceMemberInviteVariables, responses as Responses, RestRepository, SchemaDefinition, SchemaPlugin, SchemaPluginResult, schemas as Schemas, SearchBranchPathParams, SearchBranchRequestBody, SearchBranchVariables, SearchPlugin, SelectableColumn, SelectedPick, SetTableSchemaPathParams, SetTableSchemaRequestBody, SetTableSchemaVariables, UpdateBranchMetadataPathParams, UpdateBranchMetadataVariables, UpdateColumnPathParams, UpdateColumnRequestBody, UpdateColumnVariables, UpdateRecordWithIDPathParams, UpdateRecordWithIDQueryParams, UpdateRecordWithIDVariables, UpdateTablePathParams, UpdateTableRequestBody, UpdateTableVariables, UpdateUserVariables, UpdateWorkspaceMemberRolePathParams, UpdateWorkspaceMemberRoleRequestBody, UpdateWorkspaceMemberRoleVariables, UpdateWorkspacePathParams, UpdateWorkspaceVariables, UpsertRecordWithIDPathParams, UpsertRecordWithIDQueryParams, UpsertRecordWithIDVariables, ValueAtColumn, XataApiClient, XataApiClientOptions, XataApiPlugin, XataError, XataPlugin, XataPluginOptions, XataRecord, acceptWorkspaceMemberInvite, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeWorkspaceMember, resendWorkspaceMemberInvite, searchBranch, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
|