@xata.io/client 0.0.0-alpha.vfb85b8b → 0.0.0-alpha.vfee45b2

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