@xata.io/client 0.2.2 → 0.3.0

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 (44) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/api/client.d.ts +95 -0
  3. package/dist/api/client.js +235 -0
  4. package/dist/api/components.d.ts +1440 -0
  5. package/dist/api/components.js +1001 -0
  6. package/dist/api/fetcher.d.ts +25 -0
  7. package/dist/api/fetcher.js +78 -0
  8. package/dist/api/index.d.ts +7 -0
  9. package/dist/api/index.js +21 -0
  10. package/dist/api/parameters.d.ts +16 -0
  11. package/dist/api/parameters.js +2 -0
  12. package/dist/api/providers.d.ts +8 -0
  13. package/dist/api/providers.js +29 -0
  14. package/dist/api/responses.d.ts +44 -0
  15. package/dist/api/responses.js +2 -0
  16. package/dist/api/schemas.d.ts +311 -0
  17. package/dist/api/schemas.js +2 -0
  18. package/dist/index.d.ts +2 -133
  19. package/dist/index.js +16 -368
  20. package/dist/schema/filters.d.ts +20 -0
  21. package/dist/schema/filters.js +24 -0
  22. package/dist/schema/index.d.ts +5 -0
  23. package/dist/schema/index.js +25 -0
  24. package/dist/schema/operators.d.ts +72 -0
  25. package/dist/schema/operators.js +91 -0
  26. package/dist/schema/pagination.d.ts +79 -0
  27. package/dist/schema/pagination.js +90 -0
  28. package/dist/schema/query.d.ts +114 -0
  29. package/dist/schema/query.js +227 -0
  30. package/dist/schema/record.d.ts +36 -0
  31. package/dist/schema/record.js +2 -0
  32. package/dist/schema/repository.d.ts +109 -0
  33. package/dist/schema/repository.js +273 -0
  34. package/dist/schema/selection.d.ts +13 -0
  35. package/dist/schema/selection.js +2 -0
  36. package/dist/util/lang.d.ts +2 -0
  37. package/dist/util/lang.js +10 -0
  38. package/dist/util/types.d.ts +3 -0
  39. package/dist/util/types.js +2 -0
  40. package/package.json +3 -3
  41. package/dist/index.test.d.ts +0 -1
  42. package/dist/index.test.js +0 -304
  43. package/src/index.test.ts +0 -392
  44. package/src/index.ts +0 -506
@@ -0,0 +1,1001 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchBranch = exports.queryTable = exports.bulkInsertTableRecords = exports.getRecord = exports.deleteRecord = exports.upsertRecordWithID = exports.updateRecordWithID = exports.insertRecordWithID = exports.insertRecord = exports.updateColumn = exports.deleteColumn = exports.getColumn = exports.addTableColumn = exports.getTableColumns = exports.setTableSchema = exports.getTableSchema = exports.updateTable = exports.deleteTable = exports.createTable = exports.getBranchStats = exports.getBranchMigrationPlan = exports.executeBranchMigrationPlan = exports.getBranchMigrationHistory = exports.getBranchMetadata = exports.updateBranchMetadata = exports.deleteBranch = exports.createBranch = exports.getBranchDetails = exports.deleteDatabase = exports.createDatabase = exports.getBranchList = exports.getDatabaseList = exports.acceptWorkspaceMemberInvite = exports.resendWorkspaceMemberInvite = exports.cancelWorkspaceMemberInvite = exports.inviteWorkspaceMember = exports.removeWorkspaceMember = exports.updateWorkspaceMemberRole = exports.getWorkspaceMembersList = exports.deleteWorkspace = exports.updateWorkspace = exports.getWorkspace = exports.getWorkspacesList = exports.createWorkspace = exports.deleteUserAPIKey = exports.createUserAPIKey = exports.getUserAPIKeys = exports.deleteUser = exports.updateUser = exports.getUser = void 0;
4
+ exports.operationsByTag = void 0;
5
+ /**
6
+ * Generated by @openapi-codegen
7
+ *
8
+ * @version 1.0
9
+ */
10
+ const fetcher_1 = require("./fetcher");
11
+ /**
12
+ * Return details of the user making the request
13
+ */
14
+ const getUser = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/user', method: 'get' }, variables));
15
+ exports.getUser = getUser;
16
+ /**
17
+ * Update user info
18
+ */
19
+ const updateUser = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/user', method: 'put' }, variables));
20
+ exports.updateUser = updateUser;
21
+ /**
22
+ * Delete the user making the request
23
+ */
24
+ const deleteUser = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/user', method: 'delete' }, variables));
25
+ exports.deleteUser = deleteUser;
26
+ /**
27
+ * Retrieve a list of existing user API keys
28
+ */
29
+ const getUserAPIKeys = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/user/keys', method: 'get' }, variables));
30
+ exports.getUserAPIKeys = getUserAPIKeys;
31
+ /**
32
+ * Create and return new API key
33
+ */
34
+ const createUserAPIKey = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/user/keys/{keyName}', method: 'post' }, variables));
35
+ exports.createUserAPIKey = createUserAPIKey;
36
+ /**
37
+ * Delete an existing API key
38
+ */
39
+ const deleteUserAPIKey = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/user/keys/{keyName}', method: 'delete' }, variables));
40
+ exports.deleteUserAPIKey = deleteUserAPIKey;
41
+ /**
42
+ * Creates a new workspace with the user requesting it as its single owner.
43
+ */
44
+ const createWorkspace = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces', method: 'post' }, variables));
45
+ exports.createWorkspace = createWorkspace;
46
+ /**
47
+ * Retrieve the list of workspaces the user belongs to
48
+ */
49
+ const getWorkspacesList = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces', method: 'get' }, variables));
50
+ exports.getWorkspacesList = getWorkspacesList;
51
+ /**
52
+ * Retrieve workspace info from a workspace ID
53
+ */
54
+ const getWorkspace = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}', method: 'get' }, variables));
55
+ exports.getWorkspace = getWorkspace;
56
+ /**
57
+ * Update workspace info
58
+ */
59
+ const updateWorkspace = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}', method: 'put' }, variables));
60
+ exports.updateWorkspace = updateWorkspace;
61
+ /**
62
+ * Delete the workspace with the provided ID
63
+ */
64
+ const deleteWorkspace = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}', method: 'delete' }, variables));
65
+ exports.deleteWorkspace = deleteWorkspace;
66
+ /**
67
+ * Retrieve the list of members of the given workspace
68
+ */
69
+ const getWorkspaceMembersList = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/members', method: 'get' }, variables));
70
+ exports.getWorkspaceMembersList = getWorkspaceMembersList;
71
+ /**
72
+ * 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.
73
+ */
74
+ const updateWorkspaceMemberRole = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/members/{userId}', method: 'put' }, variables));
75
+ exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
76
+ /**
77
+ * Remove the member from the workspace
78
+ */
79
+ const removeWorkspaceMember = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/members/{userId}', method: 'delete' }, variables));
80
+ exports.removeWorkspaceMember = removeWorkspaceMember;
81
+ /**
82
+ * Invite some user to join the workspace with the given role
83
+ */
84
+ const inviteWorkspaceMember = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/invites', method: 'post' }, variables));
85
+ exports.inviteWorkspaceMember = inviteWorkspaceMember;
86
+ /**
87
+ * This operation provides a way to cancel invites by deleting them. Already accepted invites cannot be deleted.
88
+ */
89
+ const cancelWorkspaceMemberInvite = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/invites/{inviteId}', method: 'delete' }, variables));
90
+ exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
91
+ /**
92
+ * This operation provides a way to resend an Invite notification. Invite notifications can only be sent for Invites not yet accepted.
93
+ */
94
+ const resendWorkspaceMemberInvite = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/invites/{inviteId}/resend', method: 'post' }, variables));
95
+ exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
96
+ /**
97
+ * Accept the invitation to join a workspace. If the operation succeeds the user will be a member of the workspace
98
+ */
99
+ const acceptWorkspaceMemberInvite = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/invites/{inviteKey}/accept', method: 'post' }, variables));
100
+ exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
101
+ /**
102
+ * List all databases available in your Workspace.
103
+ */
104
+ const getDatabaseList = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/dbs', method: 'get' }, variables));
105
+ exports.getDatabaseList = getDatabaseList;
106
+ /**
107
+ * List all available Branches
108
+ */
109
+ const getBranchList = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/dbs/{dbName}', method: 'get' }, variables));
110
+ exports.getBranchList = getBranchList;
111
+ /**
112
+ * Create Database with identifier name
113
+ */
114
+ const createDatabase = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/dbs/{dbName}', method: 'put' }, variables));
115
+ exports.createDatabase = createDatabase;
116
+ /**
117
+ * Delete a database and all of its branches and tables permanently.
118
+ */
119
+ const deleteDatabase = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/dbs/{dbName}', method: 'delete' }, variables));
120
+ exports.deleteDatabase = deleteDatabase;
121
+ const getBranchDetails = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}', method: 'get' }, variables));
122
+ exports.getBranchDetails = getBranchDetails;
123
+ const createBranch = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}', method: 'put' }, variables));
124
+ exports.createBranch = createBranch;
125
+ /**
126
+ * Delete the branch in the database and all its resources
127
+ */
128
+ const deleteBranch = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}', method: 'delete' }, variables));
129
+ exports.deleteBranch = deleteBranch;
130
+ /**
131
+ * Update the branch metadata
132
+ */
133
+ const updateBranchMetadata = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/metadata', method: 'put' }, variables));
134
+ exports.updateBranchMetadata = updateBranchMetadata;
135
+ const getBranchMetadata = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/metadata', method: 'get' }, variables));
136
+ exports.getBranchMetadata = getBranchMetadata;
137
+ const getBranchMigrationHistory = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/migrations', method: 'get' }, variables));
138
+ exports.getBranchMigrationHistory = getBranchMigrationHistory;
139
+ /**
140
+ * Apply a migration plan to the branch
141
+ */
142
+ const executeBranchMigrationPlan = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/migrations/execute', method: 'post' }, variables));
143
+ exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
144
+ /**
145
+ * Compute a migration plan from a target schema the branch should be migrated too.
146
+ */
147
+ const getBranchMigrationPlan = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/migrations/plan', method: 'post' }, variables));
148
+ exports.getBranchMigrationPlan = getBranchMigrationPlan;
149
+ /**
150
+ * Get branch usage metrics.
151
+ */
152
+ const getBranchStats = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/stats', method: 'get' }, variables));
153
+ exports.getBranchStats = getBranchStats;
154
+ /**
155
+ * Creates a new table with the given name. Returns 422 if a table with the same name already exists.
156
+ */
157
+ const createTable = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}', method: 'put' }, variables));
158
+ exports.createTable = createTable;
159
+ /**
160
+ * Deletes the table with the given name.
161
+ */
162
+ const deleteTable = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}', method: 'delete' }, variables));
163
+ exports.deleteTable = deleteTable;
164
+ /**
165
+ * Update table. Currently there is only one update operation supported: renaming the table by providing a new name.
166
+ *
167
+ * In the example below, we rename a table from “users” to “people”:
168
+ *
169
+ * ```jsx
170
+ * PATCH /db/test:main/tables/users
171
+ * {
172
+ * "name": "people"
173
+ * }
174
+ * ```
175
+ */
176
+ const updateTable = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}', method: 'patch' }, variables));
177
+ exports.updateTable = updateTable;
178
+ const getTableSchema = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/schema', method: 'get' }, variables));
179
+ exports.getTableSchema = getTableSchema;
180
+ const setTableSchema = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/schema', method: 'put' }, variables));
181
+ exports.setTableSchema = setTableSchema;
182
+ /**
183
+ * Retrieves the list of table columns and their definition. This endpoint returns the column list with object columns being reported with their
184
+ * full dot-separated path (flattened).
185
+ */
186
+ const getTableColumns = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/columns', method: 'get' }, variables));
187
+ exports.getTableColumns = getTableColumns;
188
+ /**
189
+ * 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
190
+ * contain the full path separated by dots. If the parent objects do not exists, they will be automatically created. For example,
191
+ * passing `"name": "address.city"` will auto-create the `address` object if it doesn't exist.
192
+ */
193
+ const addTableColumn = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/columns', method: 'post' }, variables));
194
+ exports.addTableColumn = addTableColumn;
195
+ /**
196
+ * Get the definition of a single column. To refer to sub-objects, the column name can contain dots. For example `address.country`.
197
+ */
198
+ const getColumn = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/columns/{columnName}', method: 'get' }, variables));
199
+ exports.getColumn = getColumn;
200
+ /**
201
+ * Deletes the specified column. To refer to sub-objects, the column name can contain dots. For example `address.country`.
202
+ */
203
+ const deleteColumn = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/columns/{columnName}', method: 'delete' }, variables));
204
+ exports.deleteColumn = deleteColumn;
205
+ /**
206
+ * 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`.
207
+ */
208
+ const updateColumn = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/columns/{columnName}', method: 'patch' }, variables));
209
+ exports.updateColumn = updateColumn;
210
+ /**
211
+ * Insert a new Record into the Table
212
+ */
213
+ const insertRecord = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/data', method: 'post' }, variables));
214
+ exports.insertRecord = insertRecord;
215
+ /**
216
+ * 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.
217
+ */
218
+ const insertRecordWithID = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/data/{recordId}', method: 'put' }, variables));
219
+ exports.insertRecordWithID = insertRecordWithID;
220
+ const updateRecordWithID = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/data/{recordId}', method: 'patch' }, variables));
221
+ exports.updateRecordWithID = updateRecordWithID;
222
+ const upsertRecordWithID = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/data/{recordId}', method: 'post' }, variables));
223
+ exports.upsertRecordWithID = upsertRecordWithID;
224
+ const deleteRecord = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/data/{recordId}', method: 'delete' }, variables));
225
+ exports.deleteRecord = deleteRecord;
226
+ /**
227
+ * Retrieve record by ID
228
+ */
229
+ const getRecord = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/data/{recordId}', method: 'get' }, variables));
230
+ exports.getRecord = getRecord;
231
+ /**
232
+ * Bulk insert records
233
+ */
234
+ const bulkInsertTableRecords = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/bulk', method: 'post' }, variables));
235
+ exports.bulkInsertTableRecords = bulkInsertTableRecords;
236
+ /**
237
+ * The Query Table API can be used to retrieve all records in a table.
238
+ * The API support filtering, sorting, selecting a subset of columns, and pagination.
239
+ *
240
+ * The overall structure of the request looks like this:
241
+ *
242
+ * ```json
243
+ * // POST /db/<dbname>:<branch>/tables/<table>/query
244
+ * {
245
+ * "columns": [...],
246
+ * "filter": {
247
+ * "$all": [...]
248
+ * "$any": [...]
249
+ * ...
250
+ * },
251
+ * "sort": {
252
+ * "multiple": [...]
253
+ * ...
254
+ * },
255
+ * "page": {
256
+ * ...
257
+ * }
258
+ * }
259
+ * ```
260
+ *
261
+ * ### Column selection
262
+ *
263
+ * If the `columns` array is not specified, all columns are included. For link
264
+ * fields, only the ID column of the linked records is included in the response.
265
+ *
266
+ * If the `columns` array is specified, only the selected columns are included.
267
+ * The `*` wildcard can be used to select all columns of the given array
268
+ *
269
+ * For objects and link fields, if the column name of the object is specified, we
270
+ * include all of its sub-keys. If only some sub-keys are specified (via dotted
271
+ * notation, e.g. `"settings.plan"` ), then only those sub-keys from the object
272
+ * are included.
273
+ *
274
+ * By the way of example, assuming two tables like this:
275
+ *
276
+ * ```json {"truncate": true}
277
+ * {
278
+ * "formatVersion": "1.0",
279
+ * "tables": [
280
+ * {
281
+ * "name": "teams",
282
+ * "columns": [
283
+ * {
284
+ * "name": "name",
285
+ * "type": "string"
286
+ * },
287
+ * {
288
+ * "name": "owner",
289
+ * "type": "link",
290
+ * "link": {
291
+ * "table": "users"
292
+ * }
293
+ * }
294
+ * ]
295
+ * },
296
+ * {
297
+ * "name": "users",
298
+ * "columns": [
299
+ * {
300
+ * "name": "email",
301
+ * "type": "email"
302
+ * },
303
+ * {
304
+ * "name": "full_name",
305
+ * "type": "string"
306
+ * },
307
+ * {
308
+ * "name": "address",
309
+ * "type": "object",
310
+ * "columns": [
311
+ * {
312
+ * "name": "street",
313
+ * "type": "string"
314
+ * },
315
+ * {
316
+ * "name": "number",
317
+ * "type": "int"
318
+ * },
319
+ * {
320
+ * "name": "zipcode",
321
+ * "type": "int"
322
+ * }
323
+ * ]
324
+ * },
325
+ * {
326
+ * "name": "team",
327
+ * "type": "link",
328
+ * "link": {
329
+ * "table": "teams"
330
+ * }
331
+ * }
332
+ * ]
333
+ * }
334
+ * ]
335
+ * }
336
+ * ```
337
+ *
338
+ * A query like this:
339
+ *
340
+ * ```json
341
+ * POST /db/<dbname>:<branch>/tables/<table>/query
342
+ * {
343
+ * "columns": [
344
+ * "name",
345
+ * "address.*"
346
+ * ]
347
+ * }
348
+ * ```
349
+ *
350
+ * returns objects like:
351
+ *
352
+ * ```json
353
+ * {
354
+ * "name": "Kilian",
355
+ * "address": {
356
+ * "street": "New street",
357
+ * "number": 41,
358
+ * "zipcode": 10407
359
+ * }
360
+ * }
361
+ * ```
362
+ *
363
+ * while a query like this:
364
+ *
365
+ * ```json
366
+ * POST /db/<dbname>:<branch>/tables/<table>/query
367
+ * {
368
+ * "columns": [
369
+ * "name",
370
+ * "address.street"
371
+ * ]
372
+ * }
373
+ * ```
374
+ *
375
+ * returns objects like:
376
+ *
377
+ * ```json
378
+ * {
379
+ * "name": "Kilian",
380
+ * "address": {
381
+ * "street": "New street",
382
+ * }
383
+ * }
384
+ * ```
385
+ *
386
+ * If you want to return all columns from the main table and selected columns from the linked table, you can do it like this:
387
+ *
388
+ * ```json
389
+ * {
390
+ * "columns": [
391
+ * "*",
392
+ * "team.name"
393
+ * ]
394
+ * }
395
+ * ```
396
+ *
397
+ * The `"*"` in the above means all columns, including columns of objects. This returns data like:
398
+ *
399
+ * ```json
400
+ * {
401
+ * "name": "Kilian",
402
+ * "email": "kilian@gmail.com",
403
+ * "address": {
404
+ * "street": "New street",
405
+ * "number": 41,
406
+ * "zipcode": 10407
407
+ * },
408
+ * "team": {
409
+ * "id": "XX",
410
+ * "xata": {
411
+ * "version": 0,
412
+ * },
413
+ * "name": "first team"
414
+ * }
415
+ * }
416
+ * ```
417
+ *
418
+ * If you want all columns of the linked table, you can do:
419
+ *
420
+ * ```json
421
+ * {
422
+ * "columns": [
423
+ * "*",
424
+ * "team.*"
425
+ * ]
426
+ * }
427
+ * ```
428
+ *
429
+ * This returns, for example:
430
+ *
431
+ * ```json
432
+ * {
433
+ * "name": "Kilian",
434
+ * "email": "kilian@gmail.com",
435
+ * "address": {
436
+ * "street": "New street",
437
+ * "number": 41,
438
+ * "zipcode": 10407
439
+ * },
440
+ * "team": {
441
+ * "id": "XX",
442
+ * "xata": {
443
+ * "version": 0,
444
+ * },
445
+ * "name": "first team",
446
+ * "code": "A1"
447
+ * }
448
+ * }
449
+ * ```
450
+ *
451
+ * ### Filtering
452
+ *
453
+ * There are two types of operators:
454
+ *
455
+ * - Operators that work on a single column: `$is`, `$contains`, `$pattern`,
456
+ * `$includes`, `$gt`, etc.
457
+ * - Control operators that combine multiple conditions: `$any`, `$all`, `$not` ,
458
+ * `$none`, etc.
459
+ *
460
+ * All operators start with an `$` to differentiate them from column names
461
+ * (which are not allowed to start with an underscore).
462
+ *
463
+ * #### Exact matching and control operators
464
+ *
465
+ * Filter by one column:
466
+ *
467
+ * ```json
468
+ * {
469
+ * "filter": {
470
+ * "<column_name>": "value"
471
+ * }
472
+ * }
473
+ * ```
474
+ *
475
+ * This is equivalent to using the `$is` operator:
476
+ *
477
+ * ```json
478
+ * {
479
+ * "filter": {
480
+ * "<column_name>": {
481
+ * "$is": "value"
482
+ * }
483
+ * }
484
+ * }
485
+ * ```
486
+ *
487
+ * For example:
488
+ *
489
+ * ```json
490
+ * {
491
+ * "filter": {
492
+ * "name": "r2",
493
+ * }
494
+ * }
495
+ * ```
496
+ *
497
+ * Or:
498
+ *
499
+ * ```json
500
+ * {
501
+ * "filter": {
502
+ * "name": {
503
+ * "$is": "r2"
504
+ * }
505
+ * }
506
+ * }
507
+ * ```
508
+ *
509
+ * For objects, both dots and nested versions work:
510
+ *
511
+ * ```json
512
+ * {
513
+ * "filter": {
514
+ * "settings.plan": "free",
515
+ * }
516
+ * }
517
+ * ```
518
+ *
519
+ * ```json
520
+ * {
521
+ * "filter": {
522
+ * "settings": {
523
+ * "plan": "free"
524
+ * },
525
+ * },
526
+ * }
527
+ * ```
528
+ *
529
+ * If you want to OR together multiple values, you can use an array of values:
530
+ *
531
+ * ```json
532
+ * {
533
+ * "filter": {
534
+ * "settings.plan": ["free", "paid"]
535
+ * },
536
+ * }
537
+ * ```
538
+ *
539
+ * Same query with `$is` operator:
540
+ *
541
+ * ```json
542
+ * {
543
+ * "filter": {
544
+ * "settings.plan": { "$is": ["free", "paid"]}
545
+ * },
546
+ * }
547
+ * ```
548
+ *
549
+ * Specifying multiple columns, ANDs them together:
550
+ *
551
+ * ```json
552
+ * {
553
+ * "filter": {
554
+ * "settings.dark": true,
555
+ * "settings.plan": "free",
556
+ * },
557
+ * }
558
+ * ```
559
+ *
560
+ * To be more explicit about it, you can use `$all` or `$any`:
561
+ *
562
+ * ```json
563
+ * {
564
+ * "filter": {
565
+ * "$any": {
566
+ * "settings.dark": true,
567
+ * "settings.plan": "free",
568
+ * }
569
+ * },
570
+ * }
571
+ * ```
572
+ *
573
+ * `$all` and `$any` can also receive an array of objects, which allows for repeating columns:
574
+ *
575
+ * ```json
576
+ * {
577
+ * "filter": {
578
+ * "$any": [
579
+ * {
580
+ * "name": "r1",
581
+ * },
582
+ * {
583
+ * "name": "r2",
584
+ * },
585
+ * ],
586
+ * }
587
+ * ```
588
+ *
589
+ * You can check for a value being not-null with `$exists`:
590
+ *
591
+ * ```json
592
+ * {
593
+ * "filter": {
594
+ * "$exists": "settings",
595
+ * },
596
+ * }
597
+ * ```
598
+ *
599
+ * This can be combined with `$all` or `$any` :
600
+ *
601
+ * ```json
602
+ * {
603
+ * "filter": {
604
+ * "$all": [
605
+ * {
606
+ * "$exists": "settings",
607
+ * },
608
+ * {
609
+ * "$exists": "name",
610
+ * },
611
+ * ],
612
+ * }
613
+ * }
614
+ * ```
615
+ *
616
+ * We can also make the negation version, `$notExists` :
617
+ *
618
+ * ```json
619
+ * {
620
+ * "filter": {
621
+ * "$notExists": "settings",
622
+ * },
623
+ * }
624
+ * ```
625
+ *
626
+ * #### Partial match
627
+ *
628
+ * `$contains` is the simplest operator for partial matching. We should generally
629
+ * discourage overusing `$contains` because it typically can't make use of
630
+ * indices.
631
+ *
632
+ * ```json
633
+ * {
634
+ * "filter": {
635
+ * "<column_name>": {
636
+ * "$contains": "value"
637
+ * }
638
+ * }
639
+ * }
640
+ * ```
641
+ *
642
+ * Wildcards are supported via the `$pattern` operator:
643
+ *
644
+ * ```json
645
+ * {
646
+ * "filter": {
647
+ * "<column_name>": {
648
+ * "$pattern": "v*alue*"
649
+ * }
650
+ * }
651
+ * }
652
+ * ```
653
+ *
654
+ * We could also have `$endsWith` and `$startsWith` operators:
655
+ *
656
+ * ```json
657
+ * {
658
+ * "filter": {
659
+ * "<column_name>": {
660
+ * "$endsWith": ".gz"
661
+ * },
662
+ * "<column_name>": {
663
+ * "$startsWith": "tmp-"
664
+ * }
665
+ * }
666
+ * }
667
+ * ```
668
+ *
669
+ * #### Numeric/date ranges
670
+ *
671
+ * ```json
672
+ * {
673
+ * "filter": {
674
+ * "<column_name>": {
675
+ * "$ge": 0,
676
+ * "$lt": 100
677
+ * }
678
+ * }
679
+ * }
680
+ * ```
681
+ *
682
+ * The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
683
+ *
684
+ * Date ranges would support the same operators, with the date as string in RFC 3339:
685
+ *
686
+ * ```json
687
+ * {
688
+ * "filter": {
689
+ * "<column_name>": {
690
+ * "$gt": "2019-10-12T07:20:50.52Z",
691
+ * "$lt": "2021-10-12T07:20:50.52Z"
692
+ * }
693
+ * }
694
+ * }
695
+ * ```
696
+ *
697
+ * #### Negations
698
+ *
699
+ * A general `$not` operator can inverse any operation.
700
+ *
701
+ * ```json
702
+ * {
703
+ * "filter": {
704
+ * "$not": {
705
+ * "<column_name1>": "value1",
706
+ * "<column_name2>": "value1"
707
+ * }
708
+ * }
709
+ * }
710
+ * ```
711
+ *
712
+ * Note: in the above the two condition are AND together, so this does (NOT ( ...
713
+ * AND ...))
714
+ *
715
+ * Or more complex:
716
+ *
717
+ * ```json
718
+ * {
719
+ * "filter": {
720
+ * "$not": {
721
+ * "$any": [{
722
+ * "<column_name1>": "value1"
723
+ * }, {
724
+ * "$all": [{
725
+ * "<column_name2>": "value2"
726
+ * }, {
727
+ * "<column_name3>": "value3"
728
+ * }]
729
+ * }]
730
+ * }
731
+ * }
732
+ * }
733
+ * ```
734
+ *
735
+ * The `$not: { $any: {}}` can be shorted using the `$none` operator:
736
+ *
737
+ * ```json
738
+ * {
739
+ * "filter": {
740
+ * "$none": {
741
+ * "<column_name1>": "value1",
742
+ * "<column_name2>": "value1"
743
+ * }
744
+ * }
745
+ * }
746
+ * ```
747
+ *
748
+ * In addition, we can add specific operators like `$isNot` to simplify expressions:
749
+ *
750
+ * ```json
751
+ * {
752
+ * "filter": {
753
+ * "<column_name>": {
754
+ * "$isNot": "2019-10-12T07:20:50.52Z"
755
+ * }
756
+ * }
757
+ * }
758
+ * ```
759
+ *
760
+ * #### Working with arrays
761
+ *
762
+ * To test that an array contains a value, use `$includes`.
763
+ *
764
+ * ```json
765
+ * {
766
+ * "filter": {
767
+ * "<array_name>": {
768
+ * "$includes": "value"
769
+ * }
770
+ * }
771
+ * }
772
+ * ```
773
+ *
774
+ * The `$includes` operator accepts a custom predicate that will check if any
775
+ * array values matches the predicate. For example a complex predicate can include
776
+ * the `$all` , `$contains` and `$endsWith` operators:
777
+ *
778
+ * ```json
779
+ * {
780
+ * "filter": {
781
+ * "<array name>": {
782
+ * "$includes": {
783
+ * "$all": [
784
+ * {"$contains": "label"},
785
+ * {"$not": {"$endsWith": "-debug"}}
786
+ * ]
787
+ * }
788
+ * }
789
+ * }
790
+ * }
791
+ * ```
792
+ *
793
+ * The `$includes` all operator succeeds if any column in the array matches the
794
+ * predicate. The `$includesAll` operator succeeds if all array items match the
795
+ * predicate. The `$includesNone` operator succeeds if no array item matches the
796
+ * predicate. The `$includes` operator is a synonym for the `$includesAny`
797
+ * operator.
798
+ *
799
+ * ### Sorting
800
+ *
801
+ * Sorting by one element:
802
+ *
803
+ * ```json
804
+ * POST /db/demo:main/tables/table/query
805
+ * {
806
+ * "sort": {
807
+ * "index": "asc"
808
+ * }
809
+ * }
810
+ * ```
811
+ *
812
+ * or descendently:
813
+ *
814
+ * ```json
815
+ * POST /db/demo:main/tables/table/query
816
+ * {
817
+ * "sort": {
818
+ * "index": "desc"
819
+ * }
820
+ * }
821
+ * ```
822
+ *
823
+ * Sorting by multiple fields:
824
+ *
825
+ * ```json
826
+ * POST /db/demo:main/tables/table/query
827
+ * {
828
+ * "sort": [
829
+ * {
830
+ * "index": "desc"
831
+ * },
832
+ * {
833
+ * "createdAt": "desc"
834
+ * }
835
+ * ]
836
+ * }
837
+ * ```
838
+ *
839
+ *
840
+ * ### Pagination
841
+ *
842
+ * We offer cursor pagination and offset pagination. The offset pagination is limited
843
+ * in the amount of data it can retrieve, so we recommend the cursor pagination if you have more than 1000 records.
844
+ *
845
+ * Example of size + offset pagination:
846
+ *
847
+ * ```json
848
+ * POST /db/demo:main/tables/table/query
849
+ * {
850
+ * "page": {
851
+ * "size": 100,
852
+ * "offset": 200
853
+ * }
854
+ * }
855
+ * ```
856
+ *
857
+ * 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.
858
+ * 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.
859
+ *
860
+ * Example of cursor pagination:
861
+ *
862
+ * ```json
863
+ * POST /db/demo:main/tables/table/query
864
+ * {
865
+ * "page": {
866
+ * "after":"fMoxCsIwFIDh3WP8c4amDai5hO5SJCRNfaVSeC9b6d1FD"
867
+ * }
868
+ * }
869
+ * ```
870
+ *
871
+ * 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:
872
+ *
873
+ * ```json
874
+ * {
875
+ * "meta": {
876
+ * "page": {
877
+ * "cursor": "fMoxCsIwFIDh3WP8c4amDai5hO5SJCRNfaVSeC9b6d1FD",
878
+ * "more": true
879
+ * }
880
+ * },
881
+ * "records": [...]
882
+ * }
883
+ * ```
884
+ *
885
+ * The `page` object might contain the follow keys, in addition to `size` and `offset` that were introduced before:
886
+ *
887
+ * - `after`: Return the next page 'after' the current cursor
888
+ * - `before`: Return the previous page 'before' the current cursor.
889
+ * - `first`: Return the first page in the table from a cursor.
890
+ * - `last`: Return the last N records in the table from a cursor, where N is the `page.size` parameter.
891
+ *
892
+ * The request will fail if an invalid cursor value is given to `page.before`,
893
+ * `page.after`, `page.first` , or `page.last`. No other cursor setting can be
894
+ * used if `page.first` or `page.last` is set in a query.
895
+ *
896
+ * If both `page.before` and `page.after` parameters are present we treat the
897
+ * request as a range query. The range query will return all entries after
898
+ * `page.after`, but before `page.before`, up to `page.size` or the maximum
899
+ * page size. This query requires both cursors to use the same filters and sort
900
+ * settings, plus we require `page.after < page.before`. The range query returns
901
+ * a new cursor. If the range encompass multiple pages the next page in the range
902
+ * can be queried by update `page.after` to the returned cursor while keeping the
903
+ * `page.before` cursor from the first range query.
904
+ *
905
+ * The `filter` , `columns`, `sort` , and `page.size` configuration will be
906
+ * encoded with the cursor. The pagination request will be invalid if
907
+ * `filter` or `sort` is set. The columns returned and page size can be changed
908
+ * anytime by passing the `columns` or `page.size` settings to the next query.
909
+ *
910
+ * **Special cursors:**
911
+ *
912
+ * - `page.after=end`: Result points past the last entry. The list of records
913
+ * returned is empty, but `page.meta.cursor` will include a cursor that can be
914
+ * used to "tail" the table from the end waiting for new data to be inserted.
915
+ * - `page.before=end`: This cursor returns the last page.
916
+ * - `page.first=<cursor>`: Go to first page. This is equivalent to querying the
917
+ * first page without a cursor but `filter` and `sort` . Yet the `page.first`
918
+ * cursor can be convenient at times as user code does not need to remember the
919
+ * filter, sort, columns or page size configuration. All these information are
920
+ * read from the cursor.
921
+ * - `page.last=<cursor>`: Go to the end of the table. This is equivalent to querying the
922
+ * last page with `page.before=end`, `filter`, and `sort` . Yet the
923
+ * `page.last` cursor can be more convenient at times as user code does not
924
+ * need to remember the filter, sort, columns or page size configuration. All
925
+ * these information are read from the cursor.
926
+ *
927
+ * When using special cursors like `page.after="end"` or `page.before="end"`, we
928
+ * still allow `filter` and `sort` to be set.
929
+ *
930
+ * Example of getting the last page:
931
+ *
932
+ * ```json
933
+ * POST /db/demo:main/tables/table/query
934
+ * {
935
+ * "page": {
936
+ * "size": 10,
937
+ * "before": "end"
938
+ * }
939
+ * }
940
+ * ```
941
+ */
942
+ const queryTable = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/query', method: 'post' }, variables));
943
+ exports.queryTable = queryTable;
944
+ /**
945
+ * Run a free text search operation across the database branch.
946
+ */
947
+ const searchBranch = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/search', method: 'post' }, variables));
948
+ exports.searchBranch = searchBranch;
949
+ exports.operationsByTag = {
950
+ users: { getUser: exports.getUser, updateUser: exports.updateUser, deleteUser: exports.deleteUser, getUserAPIKeys: exports.getUserAPIKeys, createUserAPIKey: exports.createUserAPIKey, deleteUserAPIKey: exports.deleteUserAPIKey },
951
+ workspaces: {
952
+ createWorkspace: exports.createWorkspace,
953
+ getWorkspacesList: exports.getWorkspacesList,
954
+ getWorkspace: exports.getWorkspace,
955
+ updateWorkspace: exports.updateWorkspace,
956
+ deleteWorkspace: exports.deleteWorkspace,
957
+ getWorkspaceMembersList: exports.getWorkspaceMembersList,
958
+ updateWorkspaceMemberRole: exports.updateWorkspaceMemberRole,
959
+ removeWorkspaceMember: exports.removeWorkspaceMember,
960
+ inviteWorkspaceMember: exports.inviteWorkspaceMember,
961
+ cancelWorkspaceMemberInvite: exports.cancelWorkspaceMemberInvite,
962
+ resendWorkspaceMemberInvite: exports.resendWorkspaceMemberInvite,
963
+ acceptWorkspaceMemberInvite: exports.acceptWorkspaceMemberInvite
964
+ },
965
+ database: { getDatabaseList: exports.getDatabaseList, createDatabase: exports.createDatabase, deleteDatabase: exports.deleteDatabase },
966
+ branch: {
967
+ getBranchList: exports.getBranchList,
968
+ getBranchDetails: exports.getBranchDetails,
969
+ createBranch: exports.createBranch,
970
+ deleteBranch: exports.deleteBranch,
971
+ updateBranchMetadata: exports.updateBranchMetadata,
972
+ getBranchMetadata: exports.getBranchMetadata,
973
+ getBranchMigrationHistory: exports.getBranchMigrationHistory,
974
+ executeBranchMigrationPlan: exports.executeBranchMigrationPlan,
975
+ getBranchMigrationPlan: exports.getBranchMigrationPlan,
976
+ getBranchStats: exports.getBranchStats
977
+ },
978
+ table: {
979
+ createTable: exports.createTable,
980
+ deleteTable: exports.deleteTable,
981
+ updateTable: exports.updateTable,
982
+ getTableSchema: exports.getTableSchema,
983
+ setTableSchema: exports.setTableSchema,
984
+ getTableColumns: exports.getTableColumns,
985
+ addTableColumn: exports.addTableColumn,
986
+ getColumn: exports.getColumn,
987
+ deleteColumn: exports.deleteColumn,
988
+ updateColumn: exports.updateColumn
989
+ },
990
+ records: {
991
+ insertRecord: exports.insertRecord,
992
+ insertRecordWithID: exports.insertRecordWithID,
993
+ updateRecordWithID: exports.updateRecordWithID,
994
+ upsertRecordWithID: exports.upsertRecordWithID,
995
+ deleteRecord: exports.deleteRecord,
996
+ getRecord: exports.getRecord,
997
+ bulkInsertTableRecords: exports.bulkInsertTableRecords,
998
+ queryTable: exports.queryTable,
999
+ searchBranch: exports.searchBranch
1000
+ }
1001
+ };