@xata.io/client 0.0.0-alpha.vf71bb14 → 0.0.0-alpha.vf95371f

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