@xata.io/client 0.18.6 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -38,6 +38,9 @@ function isString(value) {
38
38
  function isStringArray(value) {
39
39
  return isDefined(value) && Array.isArray(value) && value.every(isString);
40
40
  }
41
+ function isNumber(value) {
42
+ return isDefined(value) && typeof value === "number";
43
+ }
41
44
  function toBase64(value) {
42
45
  try {
43
46
  return btoa(value);
@@ -46,6 +49,17 @@ function toBase64(value) {
46
49
  return buf.from(value).toString("base64");
47
50
  }
48
51
  }
52
+ function deepMerge(a, b) {
53
+ const result = { ...a };
54
+ for (const [key, value] of Object.entries(b)) {
55
+ if (isObject(value) && isObject(result[key])) {
56
+ result[key] = deepMerge(result[key], value);
57
+ } else {
58
+ result[key] = value;
59
+ }
60
+ }
61
+ return result;
62
+ }
49
63
 
50
64
  function getEnvironment() {
51
65
  try {
@@ -150,7 +164,7 @@ function getFetchImplementation(userFetch) {
150
164
  return fetchImpl;
151
165
  }
152
166
 
153
- const VERSION = "0.18.6";
167
+ const VERSION = "0.19.1";
154
168
 
155
169
  class ErrorWithCause extends Error {
156
170
  constructor(message, options) {
@@ -207,15 +221,18 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
207
221
  return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
208
222
  };
209
223
  function buildBaseUrl({
224
+ endpoint,
210
225
  path,
211
226
  workspacesApiUrl,
212
227
  apiUrl,
213
- pathParams
228
+ pathParams = {}
214
229
  }) {
215
- if (pathParams?.workspace === void 0 || !path.startsWith("/db"))
216
- return `${apiUrl}${path}`;
217
- const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
218
- return url.replace("{workspaceId}", String(pathParams.workspace));
230
+ if (endpoint === "dataPlane") {
231
+ const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
232
+ const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
233
+ return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
234
+ }
235
+ return `${apiUrl}${path}`;
219
236
  }
220
237
  function hostHeader(url) {
221
238
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
@@ -231,6 +248,7 @@ async function fetch$1({
231
248
  queryParams,
232
249
  fetchImpl,
233
250
  apiKey,
251
+ endpoint,
234
252
  apiUrl,
235
253
  workspacesApiUrl,
236
254
  trace,
@@ -241,7 +259,7 @@ async function fetch$1({
241
259
  return trace(
242
260
  `${method.toUpperCase()} ${path}`,
243
261
  async ({ setAttributes }) => {
244
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
262
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
245
263
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
246
264
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
247
265
  setAttributes({
@@ -296,415 +314,355 @@ function parseUrl(url) {
296
314
  }
297
315
  }
298
316
 
299
- const getUser = (variables, signal) => fetch$1({ url: "/user", method: "get", ...variables, signal });
300
- const updateUser = (variables, signal) => fetch$1({
301
- url: "/user",
302
- method: "put",
303
- ...variables,
304
- signal
305
- });
306
- const deleteUser = (variables, signal) => fetch$1({ url: "/user", method: "delete", ...variables, signal });
307
- const getUserAPIKeys = (variables, signal) => fetch$1({
308
- url: "/user/keys",
317
+ const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
318
+
319
+ const dEPRECATEDgetDatabaseList = (variables, signal) => dataPlaneFetch({ url: "/dbs", method: "get", ...variables, signal });
320
+ const getBranchList = (variables, signal) => dataPlaneFetch({
321
+ url: "/dbs/{dbName}",
309
322
  method: "get",
310
323
  ...variables,
311
324
  signal
312
325
  });
313
- const createUserAPIKey = (variables, signal) => fetch$1({
314
- url: "/user/keys/{keyName}",
315
- method: "post",
326
+ const dEPRECATEDcreateDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
327
+ const dEPRECATEDdeleteDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "delete", ...variables, signal });
328
+ const dEPRECATEDgetDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "get", ...variables, signal });
329
+ const dEPRECATEDupdateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
330
+ const getBranchDetails = (variables, signal) => dataPlaneFetch({
331
+ url: "/db/{dbBranchName}",
332
+ method: "get",
316
333
  ...variables,
317
334
  signal
318
335
  });
319
- const deleteUserAPIKey = (variables, signal) => fetch$1({
320
- url: "/user/keys/{keyName}",
336
+ const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
337
+ const deleteBranch = (variables, signal) => dataPlaneFetch({
338
+ url: "/db/{dbBranchName}",
321
339
  method: "delete",
322
340
  ...variables,
323
341
  signal
324
342
  });
325
- const createWorkspace = (variables, signal) => fetch$1({
326
- url: "/workspaces",
327
- method: "post",
343
+ const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
344
+ url: "/db/{dbBranchName}/metadata",
345
+ method: "put",
328
346
  ...variables,
329
347
  signal
330
348
  });
331
- const getWorkspacesList = (variables, signal) => fetch$1({
332
- url: "/workspaces",
349
+ const getBranchMetadata = (variables, signal) => dataPlaneFetch({
350
+ url: "/db/{dbBranchName}/metadata",
333
351
  method: "get",
334
352
  ...variables,
335
353
  signal
336
354
  });
337
- const getWorkspace = (variables, signal) => fetch$1({
338
- url: "/workspaces/{workspaceId}",
355
+ const getBranchStats = (variables, signal) => dataPlaneFetch({
356
+ url: "/db/{dbBranchName}/stats",
339
357
  method: "get",
340
358
  ...variables,
341
359
  signal
342
360
  });
343
- const updateWorkspace = (variables, signal) => fetch$1({
344
- url: "/workspaces/{workspaceId}",
345
- method: "put",
346
- ...variables,
347
- signal
348
- });
349
- const deleteWorkspace = (variables, signal) => fetch$1({
350
- url: "/workspaces/{workspaceId}",
351
- method: "delete",
352
- ...variables,
353
- signal
354
- });
355
- const getWorkspaceMembersList = (variables, signal) => fetch$1({
356
- url: "/workspaces/{workspaceId}/members",
361
+ const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
362
+ const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
363
+ const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
364
+ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
365
+ const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
366
+ const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
367
+ const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
368
+ const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
369
+ const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
370
+ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
371
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
357
372
  method: "get",
358
373
  ...variables,
359
374
  signal
360
375
  });
361
- const updateWorkspaceMemberRole = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
362
- const removeWorkspaceMember = (variables, signal) => fetch$1({
363
- url: "/workspaces/{workspaceId}/members/{userId}",
364
- method: "delete",
365
- ...variables,
366
- signal
367
- });
368
- const inviteWorkspaceMember = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
369
- const updateWorkspaceMemberInvite = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
370
- const cancelWorkspaceMemberInvite = (variables, signal) => fetch$1({
371
- url: "/workspaces/{workspaceId}/invites/{inviteId}",
372
- method: "delete",
373
- ...variables,
374
- signal
375
- });
376
- const resendWorkspaceMemberInvite = (variables, signal) => fetch$1({
377
- url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
378
- method: "post",
379
- ...variables,
380
- signal
381
- });
382
- const acceptWorkspaceMemberInvite = (variables, signal) => fetch$1({
383
- url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
376
+ const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
377
+ const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
378
+ const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
379
+ const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
380
+ const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
381
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
384
382
  method: "post",
385
383
  ...variables,
386
384
  signal
387
385
  });
388
- const getDatabaseList = (variables, signal) => fetch$1({
389
- url: "/dbs",
390
- method: "get",
391
- ...variables,
392
- signal
393
- });
394
- const getBranchList = (variables, signal) => fetch$1({
395
- url: "/dbs/{dbName}",
396
- method: "get",
397
- ...variables,
398
- signal
399
- });
400
- const createDatabase = (variables, signal) => fetch$1({
401
- url: "/dbs/{dbName}",
386
+ const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
387
+ const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
388
+ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
389
+ const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
390
+ const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
391
+ const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
392
+ const createTable = (variables, signal) => dataPlaneFetch({
393
+ url: "/db/{dbBranchName}/tables/{tableName}",
402
394
  method: "put",
403
395
  ...variables,
404
396
  signal
405
397
  });
406
- const deleteDatabase = (variables, signal) => fetch$1({
407
- url: "/dbs/{dbName}",
398
+ const deleteTable = (variables, signal) => dataPlaneFetch({
399
+ url: "/db/{dbBranchName}/tables/{tableName}",
408
400
  method: "delete",
409
401
  ...variables,
410
402
  signal
411
403
  });
412
- const getDatabaseMetadata = (variables, signal) => fetch$1({
413
- url: "/dbs/{dbName}/metadata",
404
+ const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
405
+ const getTableSchema = (variables, signal) => dataPlaneFetch({
406
+ url: "/db/{dbBranchName}/tables/{tableName}/schema",
414
407
  method: "get",
415
408
  ...variables,
416
409
  signal
417
410
  });
418
- const updateDatabaseMetadata = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
419
- const getGitBranchesMapping = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
420
- const addGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
421
- const removeGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
422
- const resolveBranch = (variables, signal) => fetch$1({
423
- url: "/dbs/{dbName}/resolveBranch",
411
+ const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
412
+ const getTableColumns = (variables, signal) => dataPlaneFetch({
413
+ url: "/db/{dbBranchName}/tables/{tableName}/columns",
424
414
  method: "get",
425
415
  ...variables,
426
416
  signal
427
417
  });
428
- const queryMigrationRequests = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
429
- const createMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
430
- const getMigrationRequest = (variables, signal) => fetch$1({
431
- url: "/dbs/{dbName}/migrations/{mrNumber}",
418
+ const addTableColumn = (variables, signal) => dataPlaneFetch(
419
+ { url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
420
+ );
421
+ const getColumn = (variables, signal) => dataPlaneFetch({
422
+ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
432
423
  method: "get",
433
424
  ...variables,
434
425
  signal
435
426
  });
436
- const updateMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
437
- const listMigrationRequestsCommits = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
438
- const compareMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
439
- const getMigrationRequestIsMerged = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
440
- const mergeMigrationRequest = (variables, signal) => fetch$1({
441
- url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
442
- method: "post",
427
+ const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
428
+ const deleteColumn = (variables, signal) => dataPlaneFetch({
429
+ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
430
+ method: "delete",
443
431
  ...variables,
444
432
  signal
445
433
  });
446
- const getBranchDetails = (variables, signal) => fetch$1({
447
- url: "/db/{dbBranchName}",
434
+ const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
435
+ const getRecord = (variables, signal) => dataPlaneFetch({
436
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
448
437
  method: "get",
449
438
  ...variables,
450
439
  signal
451
440
  });
452
- const createBranch = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
453
- const deleteBranch = (variables, signal) => fetch$1({
454
- url: "/db/{dbBranchName}",
455
- method: "delete",
456
- ...variables,
457
- signal
458
- });
459
- const updateBranchMetadata = (variables, signal) => fetch$1({
460
- url: "/db/{dbBranchName}/metadata",
461
- method: "put",
441
+ const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
442
+ const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
443
+ const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
444
+ const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
445
+ const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
446
+ const queryTable = (variables, signal) => dataPlaneFetch({
447
+ url: "/db/{dbBranchName}/tables/{tableName}/query",
448
+ method: "post",
462
449
  ...variables,
463
450
  signal
464
451
  });
465
- const getBranchMetadata = (variables, signal) => fetch$1({
466
- url: "/db/{dbBranchName}/metadata",
467
- method: "get",
452
+ const searchBranch = (variables, signal) => dataPlaneFetch({
453
+ url: "/db/{dbBranchName}/search",
454
+ method: "post",
468
455
  ...variables,
469
456
  signal
470
457
  });
471
- const getBranchMigrationHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
472
- const executeBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
473
- const getBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
474
- const compareBranchWithUserSchema = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
475
- const compareBranchSchemas = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
476
- const updateBranchSchema = (variables, signal) => fetch$1({
477
- url: "/db/{dbBranchName}/schema/update",
458
+ const searchTable = (variables, signal) => dataPlaneFetch({
459
+ url: "/db/{dbBranchName}/tables/{tableName}/search",
478
460
  method: "post",
479
461
  ...variables,
480
462
  signal
481
463
  });
482
- const previewBranchSchemaEdit = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
483
- const applyBranchSchemaEdit = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
484
- const getBranchSchemaHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
485
- const getBranchStats = (variables, signal) => fetch$1({
486
- url: "/db/{dbBranchName}/stats",
464
+ const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
465
+ const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
466
+ const operationsByTag$2 = {
467
+ database: {
468
+ dEPRECATEDgetDatabaseList,
469
+ dEPRECATEDcreateDatabase,
470
+ dEPRECATEDdeleteDatabase,
471
+ dEPRECATEDgetDatabaseMetadata,
472
+ dEPRECATEDupdateDatabaseMetadata
473
+ },
474
+ branch: {
475
+ getBranchList,
476
+ getBranchDetails,
477
+ createBranch,
478
+ deleteBranch,
479
+ updateBranchMetadata,
480
+ getBranchMetadata,
481
+ getBranchStats,
482
+ getGitBranchesMapping,
483
+ addGitBranchesEntry,
484
+ removeGitBranchesEntry,
485
+ resolveBranch
486
+ },
487
+ migrations: {
488
+ getBranchMigrationHistory,
489
+ getBranchMigrationPlan,
490
+ executeBranchMigrationPlan,
491
+ getBranchSchemaHistory,
492
+ compareBranchWithUserSchema,
493
+ compareBranchSchemas,
494
+ updateBranchSchema,
495
+ previewBranchSchemaEdit,
496
+ applyBranchSchemaEdit
497
+ },
498
+ migrationRequests: {
499
+ queryMigrationRequests,
500
+ createMigrationRequest,
501
+ getMigrationRequest,
502
+ updateMigrationRequest,
503
+ listMigrationRequestsCommits,
504
+ compareMigrationRequest,
505
+ getMigrationRequestIsMerged,
506
+ mergeMigrationRequest
507
+ },
508
+ table: {
509
+ createTable,
510
+ deleteTable,
511
+ updateTable,
512
+ getTableSchema,
513
+ setTableSchema,
514
+ getTableColumns,
515
+ addTableColumn,
516
+ getColumn,
517
+ updateColumn,
518
+ deleteColumn
519
+ },
520
+ records: {
521
+ insertRecord,
522
+ getRecord,
523
+ insertRecordWithID,
524
+ updateRecordWithID,
525
+ upsertRecordWithID,
526
+ deleteRecord,
527
+ bulkInsertTableRecords
528
+ },
529
+ searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
530
+ };
531
+
532
+ const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
533
+
534
+ const getUser = (variables, signal) => controlPlaneFetch({
535
+ url: "/user",
487
536
  method: "get",
488
537
  ...variables,
489
538
  signal
490
539
  });
491
- const createTable = (variables, signal) => fetch$1({
492
- url: "/db/{dbBranchName}/tables/{tableName}",
540
+ const updateUser = (variables, signal) => controlPlaneFetch({
541
+ url: "/user",
493
542
  method: "put",
494
543
  ...variables,
495
544
  signal
496
545
  });
497
- const deleteTable = (variables, signal) => fetch$1({
498
- url: "/db/{dbBranchName}/tables/{tableName}",
546
+ const deleteUser = (variables, signal) => controlPlaneFetch({
547
+ url: "/user",
499
548
  method: "delete",
500
549
  ...variables,
501
550
  signal
502
551
  });
503
- const updateTable = (variables, signal) => fetch$1({
504
- url: "/db/{dbBranchName}/tables/{tableName}",
505
- method: "patch",
506
- ...variables,
507
- signal
508
- });
509
- const getTableSchema = (variables, signal) => fetch$1({
510
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
511
- method: "get",
512
- ...variables,
513
- signal
514
- });
515
- const setTableSchema = (variables, signal) => fetch$1({
516
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
517
- method: "put",
518
- ...variables,
519
- signal
520
- });
521
- const getTableColumns = (variables, signal) => fetch$1({
522
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
552
+ const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
553
+ url: "/user/keys",
523
554
  method: "get",
524
555
  ...variables,
525
556
  signal
526
557
  });
527
- const addTableColumn = (variables, signal) => fetch$1({
528
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
558
+ const createUserAPIKey = (variables, signal) => controlPlaneFetch({
559
+ url: "/user/keys/{keyName}",
529
560
  method: "post",
530
561
  ...variables,
531
562
  signal
532
563
  });
533
- const getColumn = (variables, signal) => fetch$1({
534
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
535
- method: "get",
536
- ...variables,
537
- signal
538
- });
539
- const deleteColumn = (variables, signal) => fetch$1({
540
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
541
- method: "delete",
542
- ...variables,
543
- signal
544
- });
545
- const updateColumn = (variables, signal) => fetch$1({
546
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
547
- method: "patch",
548
- ...variables,
549
- signal
550
- });
551
- const insertRecord = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
552
- const insertRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
553
- const updateRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
554
- const upsertRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
555
- const deleteRecord = (variables, signal) => fetch$1({
556
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
564
+ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
565
+ url: "/user/keys/{keyName}",
557
566
  method: "delete",
558
567
  ...variables,
559
568
  signal
560
569
  });
561
- const getRecord = (variables, signal) => fetch$1({
562
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
570
+ const getWorkspacesList = (variables, signal) => controlPlaneFetch({
571
+ url: "/workspaces",
563
572
  method: "get",
564
573
  ...variables,
565
574
  signal
566
575
  });
567
- const bulkInsertTableRecords = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
568
- const queryTable = (variables, signal) => fetch$1({
569
- url: "/db/{dbBranchName}/tables/{tableName}/query",
576
+ const createWorkspace = (variables, signal) => controlPlaneFetch({
577
+ url: "/workspaces",
570
578
  method: "post",
571
579
  ...variables,
572
580
  signal
573
581
  });
574
- const searchTable = (variables, signal) => fetch$1({
575
- url: "/db/{dbBranchName}/tables/{tableName}/search",
576
- method: "post",
582
+ const getWorkspace = (variables, signal) => controlPlaneFetch({
583
+ url: "/workspaces/{workspaceId}",
584
+ method: "get",
577
585
  ...variables,
578
586
  signal
579
587
  });
580
- const searchBranch = (variables, signal) => fetch$1({
581
- url: "/db/{dbBranchName}/search",
582
- method: "post",
588
+ const updateWorkspace = (variables, signal) => controlPlaneFetch({
589
+ url: "/workspaces/{workspaceId}",
590
+ method: "put",
583
591
  ...variables,
584
592
  signal
585
593
  });
586
- const summarizeTable = (variables, signal) => fetch$1({
587
- url: "/db/{dbBranchName}/tables/{tableName}/summarize",
588
- method: "post",
594
+ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
595
+ url: "/workspaces/{workspaceId}",
596
+ method: "delete",
589
597
  ...variables,
590
598
  signal
591
599
  });
592
- const aggregateTable = (variables, signal) => fetch$1({
593
- url: "/db/{dbBranchName}/tables/{tableName}/aggregate",
594
- method: "post",
600
+ const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
601
+ const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
602
+ const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
603
+ url: "/workspaces/{workspaceId}/members/{userId}",
604
+ method: "delete",
595
605
  ...variables,
596
606
  signal
597
607
  });
598
- const cPGetDatabaseList = (variables, signal) => fetch$1({
608
+ const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
609
+ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
610
+ const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
611
+ const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
612
+ const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
613
+ const getDatabaseList = (variables, signal) => controlPlaneFetch({
599
614
  url: "/workspaces/{workspaceId}/dbs",
600
615
  method: "get",
601
616
  ...variables,
602
617
  signal
603
618
  });
604
- const cPCreateDatabase = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
605
- const cPDeleteDatabase = (variables, signal) => fetch$1({
619
+ const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
620
+ const deleteDatabase = (variables, signal) => controlPlaneFetch({
606
621
  url: "/workspaces/{workspaceId}/dbs/{dbName}",
607
622
  method: "delete",
608
623
  ...variables,
609
624
  signal
610
625
  });
611
- const cPGetCPDatabaseMetadata = (variables, signal) => fetch$1(
612
- { url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "get", ...variables, signal }
613
- );
614
- const cPUpdateCPDatabaseMetadata = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
615
- const operationsByTag = {
616
- users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
626
+ const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
627
+ const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
628
+ const listRegions = (variables, signal) => controlPlaneFetch({
629
+ url: "/workspaces/{workspaceId}/regions",
630
+ method: "get",
631
+ ...variables,
632
+ signal
633
+ });
634
+ const operationsByTag$1 = {
635
+ users: { getUser, updateUser, deleteUser },
636
+ authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
617
637
  workspaces: {
618
- createWorkspace,
619
638
  getWorkspacesList,
639
+ createWorkspace,
620
640
  getWorkspace,
621
641
  updateWorkspace,
622
642
  deleteWorkspace,
623
643
  getWorkspaceMembersList,
624
644
  updateWorkspaceMemberRole,
625
- removeWorkspaceMember,
645
+ removeWorkspaceMember
646
+ },
647
+ invites: {
626
648
  inviteWorkspaceMember,
627
649
  updateWorkspaceMemberInvite,
628
650
  cancelWorkspaceMemberInvite,
629
- resendWorkspaceMemberInvite,
630
- acceptWorkspaceMemberInvite
651
+ acceptWorkspaceMemberInvite,
652
+ resendWorkspaceMemberInvite
631
653
  },
632
- database: {
654
+ databases: {
633
655
  getDatabaseList,
634
656
  createDatabase,
635
657
  deleteDatabase,
636
658
  getDatabaseMetadata,
637
659
  updateDatabaseMetadata,
638
- getGitBranchesMapping,
639
- addGitBranchesEntry,
640
- removeGitBranchesEntry,
641
- resolveBranch
642
- },
643
- branch: {
644
- getBranchList,
645
- getBranchDetails,
646
- createBranch,
647
- deleteBranch,
648
- updateBranchMetadata,
649
- getBranchMetadata,
650
- getBranchStats
651
- },
652
- migrationRequests: {
653
- queryMigrationRequests,
654
- createMigrationRequest,
655
- getMigrationRequest,
656
- updateMigrationRequest,
657
- listMigrationRequestsCommits,
658
- compareMigrationRequest,
659
- getMigrationRequestIsMerged,
660
- mergeMigrationRequest
661
- },
662
- branchSchema: {
663
- getBranchMigrationHistory,
664
- executeBranchMigrationPlan,
665
- getBranchMigrationPlan,
666
- compareBranchWithUserSchema,
667
- compareBranchSchemas,
668
- updateBranchSchema,
669
- previewBranchSchemaEdit,
670
- applyBranchSchemaEdit,
671
- getBranchSchemaHistory
672
- },
673
- table: {
674
- createTable,
675
- deleteTable,
676
- updateTable,
677
- getTableSchema,
678
- setTableSchema,
679
- getTableColumns,
680
- addTableColumn,
681
- getColumn,
682
- deleteColumn,
683
- updateColumn
684
- },
685
- records: {
686
- insertRecord,
687
- insertRecordWithID,
688
- updateRecordWithID,
689
- upsertRecordWithID,
690
- deleteRecord,
691
- getRecord,
692
- bulkInsertTableRecords,
693
- queryTable,
694
- searchTable,
695
- searchBranch,
696
- summarizeTable,
697
- aggregateTable
698
- },
699
- databases: {
700
- cPGetDatabaseList,
701
- cPCreateDatabase,
702
- cPDeleteDatabase,
703
- cPGetCPDatabaseMetadata,
704
- cPUpdateCPDatabaseMetadata
660
+ listRegions
705
661
  }
706
662
  };
707
663
 
664
+ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
665
+
708
666
  function getHostUrl(provider, type) {
709
667
  if (isHostProviderAlias(provider)) {
710
668
  return providers[provider][type];
@@ -716,11 +674,11 @@ function getHostUrl(provider, type) {
716
674
  const providers = {
717
675
  production: {
718
676
  main: "https://api.xata.io",
719
- workspaces: "https://{workspaceId}.xata.sh"
677
+ workspaces: "https://{workspaceId}.{region}.xata.sh"
720
678
  },
721
679
  staging: {
722
680
  main: "https://staging.xatabase.co",
723
- workspaces: "https://{workspaceId}.staging.xatabase.co"
681
+ workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
724
682
  }
725
683
  };
726
684
  function isHostProviderAlias(alias) {
@@ -736,7 +694,17 @@ function parseProviderString(provider = "production") {
736
694
  const [main, workspaces] = provider.split(",");
737
695
  if (!main || !workspaces)
738
696
  return null;
739
- return { main, workspaces };
697
+ return { main, workspaces };
698
+ }
699
+ function parseWorkspacesUrlParts(url) {
700
+ if (!isString(url))
701
+ return null;
702
+ const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
703
+ const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
704
+ const match = url.match(regex) || url.match(regexStaging);
705
+ if (!match)
706
+ return null;
707
+ return { workspace: match[1], region: match[2] ?? "eu-west-1" };
740
708
  }
741
709
 
742
710
  var __accessCheck$7 = (obj, member, msg) => {
@@ -781,21 +749,41 @@ class XataApiClient {
781
749
  __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
782
750
  return __privateGet$7(this, _namespaces).user;
783
751
  }
752
+ get authentication() {
753
+ if (!__privateGet$7(this, _namespaces).authentication)
754
+ __privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
755
+ return __privateGet$7(this, _namespaces).authentication;
756
+ }
784
757
  get workspaces() {
785
758
  if (!__privateGet$7(this, _namespaces).workspaces)
786
759
  __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
787
760
  return __privateGet$7(this, _namespaces).workspaces;
788
761
  }
789
- get databases() {
790
- if (!__privateGet$7(this, _namespaces).databases)
791
- __privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
792
- return __privateGet$7(this, _namespaces).databases;
762
+ get invites() {
763
+ if (!__privateGet$7(this, _namespaces).invites)
764
+ __privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
765
+ return __privateGet$7(this, _namespaces).invites;
766
+ }
767
+ get database() {
768
+ if (!__privateGet$7(this, _namespaces).database)
769
+ __privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
770
+ return __privateGet$7(this, _namespaces).database;
793
771
  }
794
772
  get branches() {
795
773
  if (!__privateGet$7(this, _namespaces).branches)
796
774
  __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
797
775
  return __privateGet$7(this, _namespaces).branches;
798
776
  }
777
+ get migrations() {
778
+ if (!__privateGet$7(this, _namespaces).migrations)
779
+ __privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
780
+ return __privateGet$7(this, _namespaces).migrations;
781
+ }
782
+ get migrationRequests() {
783
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
784
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
785
+ return __privateGet$7(this, _namespaces).migrationRequests;
786
+ }
799
787
  get tables() {
800
788
  if (!__privateGet$7(this, _namespaces).tables)
801
789
  __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
@@ -806,15 +794,10 @@ class XataApiClient {
806
794
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
807
795
  return __privateGet$7(this, _namespaces).records;
808
796
  }
809
- get migrationRequests() {
810
- if (!__privateGet$7(this, _namespaces).migrationRequests)
811
- __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
812
- return __privateGet$7(this, _namespaces).migrationRequests;
813
- }
814
- get branchSchema() {
815
- if (!__privateGet$7(this, _namespaces).branchSchema)
816
- __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
817
- return __privateGet$7(this, _namespaces).branchSchema;
797
+ get searchAndFilter() {
798
+ if (!__privateGet$7(this, _namespaces).searchAndFilter)
799
+ __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
800
+ return __privateGet$7(this, _namespaces).searchAndFilter;
818
801
  }
819
802
  }
820
803
  _extraProps = new WeakMap();
@@ -826,24 +809,29 @@ class UserApi {
826
809
  getUser() {
827
810
  return operationsByTag.users.getUser({ ...this.extraProps });
828
811
  }
829
- updateUser(user) {
812
+ updateUser({ user }) {
830
813
  return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
831
814
  }
832
815
  deleteUser() {
833
816
  return operationsByTag.users.deleteUser({ ...this.extraProps });
834
817
  }
818
+ }
819
+ class AuthenticationApi {
820
+ constructor(extraProps) {
821
+ this.extraProps = extraProps;
822
+ }
835
823
  getUserAPIKeys() {
836
- return operationsByTag.users.getUserAPIKeys({ ...this.extraProps });
824
+ return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
837
825
  }
838
- createUserAPIKey(keyName) {
839
- return operationsByTag.users.createUserAPIKey({
840
- pathParams: { keyName },
826
+ createUserAPIKey({ name }) {
827
+ return operationsByTag.authentication.createUserAPIKey({
828
+ pathParams: { keyName: name },
841
829
  ...this.extraProps
842
830
  });
843
831
  }
844
- deleteUserAPIKey(keyName) {
845
- return operationsByTag.users.deleteUserAPIKey({
846
- pathParams: { keyName },
832
+ deleteUserAPIKey({ name }) {
833
+ return operationsByTag.authentication.deleteUserAPIKey({
834
+ pathParams: { keyName: name },
847
835
  ...this.extraProps
848
836
  });
849
837
  }
@@ -852,196 +840,248 @@ class WorkspaceApi {
852
840
  constructor(extraProps) {
853
841
  this.extraProps = extraProps;
854
842
  }
855
- createWorkspace(workspaceMeta) {
843
+ getWorkspacesList() {
844
+ return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
845
+ }
846
+ createWorkspace({ data }) {
856
847
  return operationsByTag.workspaces.createWorkspace({
857
- body: workspaceMeta,
848
+ body: data,
858
849
  ...this.extraProps
859
850
  });
860
851
  }
861
- getWorkspacesList() {
862
- return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
863
- }
864
- getWorkspace(workspaceId) {
852
+ getWorkspace({ workspace }) {
865
853
  return operationsByTag.workspaces.getWorkspace({
866
- pathParams: { workspaceId },
854
+ pathParams: { workspaceId: workspace },
867
855
  ...this.extraProps
868
856
  });
869
857
  }
870
- updateWorkspace(workspaceId, workspaceMeta) {
858
+ updateWorkspace({
859
+ workspace,
860
+ update
861
+ }) {
871
862
  return operationsByTag.workspaces.updateWorkspace({
872
- pathParams: { workspaceId },
873
- body: workspaceMeta,
863
+ pathParams: { workspaceId: workspace },
864
+ body: update,
874
865
  ...this.extraProps
875
866
  });
876
867
  }
877
- deleteWorkspace(workspaceId) {
868
+ deleteWorkspace({ workspace }) {
878
869
  return operationsByTag.workspaces.deleteWorkspace({
879
- pathParams: { workspaceId },
870
+ pathParams: { workspaceId: workspace },
880
871
  ...this.extraProps
881
872
  });
882
873
  }
883
- getWorkspaceMembersList(workspaceId) {
874
+ getWorkspaceMembersList({ workspace }) {
884
875
  return operationsByTag.workspaces.getWorkspaceMembersList({
885
- pathParams: { workspaceId },
876
+ pathParams: { workspaceId: workspace },
886
877
  ...this.extraProps
887
878
  });
888
879
  }
889
- updateWorkspaceMemberRole(workspaceId, userId, role) {
880
+ updateWorkspaceMemberRole({
881
+ workspace,
882
+ user,
883
+ role
884
+ }) {
890
885
  return operationsByTag.workspaces.updateWorkspaceMemberRole({
891
- pathParams: { workspaceId, userId },
886
+ pathParams: { workspaceId: workspace, userId: user },
892
887
  body: { role },
893
888
  ...this.extraProps
894
889
  });
895
890
  }
896
- removeWorkspaceMember(workspaceId, userId) {
891
+ removeWorkspaceMember({
892
+ workspace,
893
+ user
894
+ }) {
897
895
  return operationsByTag.workspaces.removeWorkspaceMember({
898
- pathParams: { workspaceId, userId },
896
+ pathParams: { workspaceId: workspace, userId: user },
899
897
  ...this.extraProps
900
898
  });
901
899
  }
902
- inviteWorkspaceMember(workspaceId, email, role) {
903
- return operationsByTag.workspaces.inviteWorkspaceMember({
904
- pathParams: { workspaceId },
900
+ }
901
+ class InvitesApi {
902
+ constructor(extraProps) {
903
+ this.extraProps = extraProps;
904
+ }
905
+ inviteWorkspaceMember({
906
+ workspace,
907
+ email,
908
+ role
909
+ }) {
910
+ return operationsByTag.invites.inviteWorkspaceMember({
911
+ pathParams: { workspaceId: workspace },
905
912
  body: { email, role },
906
913
  ...this.extraProps
907
914
  });
908
915
  }
909
- updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
910
- return operationsByTag.workspaces.updateWorkspaceMemberInvite({
911
- pathParams: { workspaceId, inviteId },
916
+ updateWorkspaceMemberInvite({
917
+ workspace,
918
+ invite,
919
+ role
920
+ }) {
921
+ return operationsByTag.invites.updateWorkspaceMemberInvite({
922
+ pathParams: { workspaceId: workspace, inviteId: invite },
912
923
  body: { role },
913
924
  ...this.extraProps
914
925
  });
915
926
  }
916
- cancelWorkspaceMemberInvite(workspaceId, inviteId) {
917
- return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
918
- pathParams: { workspaceId, inviteId },
927
+ cancelWorkspaceMemberInvite({
928
+ workspace,
929
+ invite
930
+ }) {
931
+ return operationsByTag.invites.cancelWorkspaceMemberInvite({
932
+ pathParams: { workspaceId: workspace, inviteId: invite },
919
933
  ...this.extraProps
920
934
  });
921
935
  }
922
- resendWorkspaceMemberInvite(workspaceId, inviteId) {
923
- return operationsByTag.workspaces.resendWorkspaceMemberInvite({
924
- pathParams: { workspaceId, inviteId },
936
+ acceptWorkspaceMemberInvite({
937
+ workspace,
938
+ key
939
+ }) {
940
+ return operationsByTag.invites.acceptWorkspaceMemberInvite({
941
+ pathParams: { workspaceId: workspace, inviteKey: key },
925
942
  ...this.extraProps
926
943
  });
927
944
  }
928
- acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
929
- return operationsByTag.workspaces.acceptWorkspaceMemberInvite({
930
- pathParams: { workspaceId, inviteKey },
945
+ resendWorkspaceMemberInvite({
946
+ workspace,
947
+ invite
948
+ }) {
949
+ return operationsByTag.invites.resendWorkspaceMemberInvite({
950
+ pathParams: { workspaceId: workspace, inviteId: invite },
931
951
  ...this.extraProps
932
952
  });
933
953
  }
934
954
  }
935
- class DatabaseApi {
955
+ class BranchApi {
936
956
  constructor(extraProps) {
937
957
  this.extraProps = extraProps;
938
958
  }
939
- getDatabaseList(workspace) {
940
- return operationsByTag.database.getDatabaseList({
941
- pathParams: { workspace },
942
- ...this.extraProps
943
- });
944
- }
945
- createDatabase(workspace, dbName, options = {}) {
946
- return operationsByTag.database.createDatabase({
947
- pathParams: { workspace, dbName },
948
- body: options,
949
- ...this.extraProps
950
- });
951
- }
952
- deleteDatabase(workspace, dbName) {
953
- return operationsByTag.database.deleteDatabase({
954
- pathParams: { workspace, dbName },
955
- ...this.extraProps
956
- });
957
- }
958
- getDatabaseMetadata(workspace, dbName) {
959
- return operationsByTag.database.getDatabaseMetadata({
960
- pathParams: { workspace, dbName },
961
- ...this.extraProps
962
- });
963
- }
964
- updateDatabaseMetadata(workspace, dbName, options = {}) {
965
- return operationsByTag.database.updateDatabaseMetadata({
966
- pathParams: { workspace, dbName },
967
- body: options,
968
- ...this.extraProps
969
- });
970
- }
971
- getGitBranchesMapping(workspace, dbName) {
972
- return operationsByTag.database.getGitBranchesMapping({
973
- pathParams: { workspace, dbName },
959
+ getBranchList({
960
+ workspace,
961
+ region,
962
+ database
963
+ }) {
964
+ return operationsByTag.branch.getBranchList({
965
+ pathParams: { workspace, region, dbName: database },
974
966
  ...this.extraProps
975
967
  });
976
968
  }
977
- addGitBranchesEntry(workspace, dbName, body) {
978
- return operationsByTag.database.addGitBranchesEntry({
979
- pathParams: { workspace, dbName },
980
- body,
969
+ getBranchDetails({
970
+ workspace,
971
+ region,
972
+ database,
973
+ branch
974
+ }) {
975
+ return operationsByTag.branch.getBranchDetails({
976
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
981
977
  ...this.extraProps
982
978
  });
983
979
  }
984
- removeGitBranchesEntry(workspace, dbName, gitBranch) {
985
- return operationsByTag.database.removeGitBranchesEntry({
986
- pathParams: { workspace, dbName },
987
- queryParams: { gitBranch },
980
+ createBranch({
981
+ workspace,
982
+ region,
983
+ database,
984
+ branch,
985
+ from,
986
+ metadata
987
+ }) {
988
+ return operationsByTag.branch.createBranch({
989
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
990
+ body: { from, metadata },
988
991
  ...this.extraProps
989
992
  });
990
993
  }
991
- resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
992
- return operationsByTag.database.resolveBranch({
993
- pathParams: { workspace, dbName },
994
- queryParams: { gitBranch, fallbackBranch },
994
+ deleteBranch({
995
+ workspace,
996
+ region,
997
+ database,
998
+ branch
999
+ }) {
1000
+ return operationsByTag.branch.deleteBranch({
1001
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
995
1002
  ...this.extraProps
996
1003
  });
997
1004
  }
998
- }
999
- class BranchApi {
1000
- constructor(extraProps) {
1001
- this.extraProps = extraProps;
1002
- }
1003
- getBranchList(workspace, dbName) {
1004
- return operationsByTag.branch.getBranchList({
1005
- pathParams: { workspace, dbName },
1005
+ updateBranchMetadata({
1006
+ workspace,
1007
+ region,
1008
+ database,
1009
+ branch,
1010
+ metadata
1011
+ }) {
1012
+ return operationsByTag.branch.updateBranchMetadata({
1013
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1014
+ body: metadata,
1006
1015
  ...this.extraProps
1007
1016
  });
1008
1017
  }
1009
- getBranchDetails(workspace, database, branch) {
1010
- return operationsByTag.branch.getBranchDetails({
1011
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1018
+ getBranchMetadata({
1019
+ workspace,
1020
+ region,
1021
+ database,
1022
+ branch
1023
+ }) {
1024
+ return operationsByTag.branch.getBranchMetadata({
1025
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1012
1026
  ...this.extraProps
1013
1027
  });
1014
1028
  }
1015
- createBranch(workspace, database, branch, from, options = {}) {
1016
- return operationsByTag.branch.createBranch({
1017
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1018
- queryParams: isString(from) ? { from } : void 0,
1019
- body: options,
1029
+ getBranchStats({
1030
+ workspace,
1031
+ region,
1032
+ database,
1033
+ branch
1034
+ }) {
1035
+ return operationsByTag.branch.getBranchStats({
1036
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1020
1037
  ...this.extraProps
1021
1038
  });
1022
1039
  }
1023
- deleteBranch(workspace, database, branch) {
1024
- return operationsByTag.branch.deleteBranch({
1025
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1040
+ getGitBranchesMapping({
1041
+ workspace,
1042
+ region,
1043
+ database
1044
+ }) {
1045
+ return operationsByTag.branch.getGitBranchesMapping({
1046
+ pathParams: { workspace, region, dbName: database },
1026
1047
  ...this.extraProps
1027
1048
  });
1028
1049
  }
1029
- updateBranchMetadata(workspace, database, branch, metadata = {}) {
1030
- return operationsByTag.branch.updateBranchMetadata({
1031
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1032
- body: metadata,
1050
+ addGitBranchesEntry({
1051
+ workspace,
1052
+ region,
1053
+ database,
1054
+ gitBranch,
1055
+ xataBranch
1056
+ }) {
1057
+ return operationsByTag.branch.addGitBranchesEntry({
1058
+ pathParams: { workspace, region, dbName: database },
1059
+ body: { gitBranch, xataBranch },
1033
1060
  ...this.extraProps
1034
1061
  });
1035
1062
  }
1036
- getBranchMetadata(workspace, database, branch) {
1037
- return operationsByTag.branch.getBranchMetadata({
1038
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1063
+ removeGitBranchesEntry({
1064
+ workspace,
1065
+ region,
1066
+ database,
1067
+ gitBranch
1068
+ }) {
1069
+ return operationsByTag.branch.removeGitBranchesEntry({
1070
+ pathParams: { workspace, region, dbName: database },
1071
+ queryParams: { gitBranch },
1039
1072
  ...this.extraProps
1040
1073
  });
1041
1074
  }
1042
- getBranchStats(workspace, database, branch) {
1043
- return operationsByTag.branch.getBranchStats({
1044
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1075
+ resolveBranch({
1076
+ workspace,
1077
+ region,
1078
+ database,
1079
+ gitBranch,
1080
+ fallbackBranch
1081
+ }) {
1082
+ return operationsByTag.branch.resolveBranch({
1083
+ pathParams: { workspace, region, dbName: database },
1084
+ queryParams: { gitBranch, fallbackBranch },
1045
1085
  ...this.extraProps
1046
1086
  });
1047
1087
  }
@@ -1050,67 +1090,134 @@ class TableApi {
1050
1090
  constructor(extraProps) {
1051
1091
  this.extraProps = extraProps;
1052
1092
  }
1053
- createTable(workspace, database, branch, tableName) {
1093
+ createTable({
1094
+ workspace,
1095
+ region,
1096
+ database,
1097
+ branch,
1098
+ table
1099
+ }) {
1054
1100
  return operationsByTag.table.createTable({
1055
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1101
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1056
1102
  ...this.extraProps
1057
1103
  });
1058
1104
  }
1059
- deleteTable(workspace, database, branch, tableName) {
1105
+ deleteTable({
1106
+ workspace,
1107
+ region,
1108
+ database,
1109
+ branch,
1110
+ table
1111
+ }) {
1060
1112
  return operationsByTag.table.deleteTable({
1061
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1113
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1062
1114
  ...this.extraProps
1063
1115
  });
1064
1116
  }
1065
- updateTable(workspace, database, branch, tableName, options) {
1117
+ updateTable({
1118
+ workspace,
1119
+ region,
1120
+ database,
1121
+ branch,
1122
+ table,
1123
+ update
1124
+ }) {
1066
1125
  return operationsByTag.table.updateTable({
1067
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1068
- body: options,
1126
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1127
+ body: update,
1069
1128
  ...this.extraProps
1070
1129
  });
1071
1130
  }
1072
- getTableSchema(workspace, database, branch, tableName) {
1131
+ getTableSchema({
1132
+ workspace,
1133
+ region,
1134
+ database,
1135
+ branch,
1136
+ table
1137
+ }) {
1073
1138
  return operationsByTag.table.getTableSchema({
1074
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1139
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1075
1140
  ...this.extraProps
1076
1141
  });
1077
1142
  }
1078
- setTableSchema(workspace, database, branch, tableName, options) {
1143
+ setTableSchema({
1144
+ workspace,
1145
+ region,
1146
+ database,
1147
+ branch,
1148
+ table,
1149
+ schema
1150
+ }) {
1079
1151
  return operationsByTag.table.setTableSchema({
1080
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1081
- body: options,
1152
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1153
+ body: schema,
1082
1154
  ...this.extraProps
1083
1155
  });
1084
1156
  }
1085
- getTableColumns(workspace, database, branch, tableName) {
1157
+ getTableColumns({
1158
+ workspace,
1159
+ region,
1160
+ database,
1161
+ branch,
1162
+ table
1163
+ }) {
1086
1164
  return operationsByTag.table.getTableColumns({
1087
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1165
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1088
1166
  ...this.extraProps
1089
1167
  });
1090
1168
  }
1091
- addTableColumn(workspace, database, branch, tableName, column) {
1169
+ addTableColumn({
1170
+ workspace,
1171
+ region,
1172
+ database,
1173
+ branch,
1174
+ table,
1175
+ column
1176
+ }) {
1092
1177
  return operationsByTag.table.addTableColumn({
1093
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1178
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1094
1179
  body: column,
1095
1180
  ...this.extraProps
1096
1181
  });
1097
1182
  }
1098
- getColumn(workspace, database, branch, tableName, columnName) {
1183
+ getColumn({
1184
+ workspace,
1185
+ region,
1186
+ database,
1187
+ branch,
1188
+ table,
1189
+ column
1190
+ }) {
1099
1191
  return operationsByTag.table.getColumn({
1100
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1192
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1101
1193
  ...this.extraProps
1102
1194
  });
1103
1195
  }
1104
- deleteColumn(workspace, database, branch, tableName, columnName) {
1105
- return operationsByTag.table.deleteColumn({
1106
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1196
+ updateColumn({
1197
+ workspace,
1198
+ region,
1199
+ database,
1200
+ branch,
1201
+ table,
1202
+ column,
1203
+ update
1204
+ }) {
1205
+ return operationsByTag.table.updateColumn({
1206
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1207
+ body: update,
1107
1208
  ...this.extraProps
1108
1209
  });
1109
1210
  }
1110
- updateColumn(workspace, database, branch, tableName, columnName, options) {
1111
- return operationsByTag.table.updateColumn({
1112
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1113
- body: options,
1211
+ deleteColumn({
1212
+ workspace,
1213
+ region,
1214
+ database,
1215
+ branch,
1216
+ table,
1217
+ column
1218
+ }) {
1219
+ return operationsByTag.table.deleteColumn({
1220
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1114
1221
  ...this.extraProps
1115
1222
  });
1116
1223
  }
@@ -1119,92 +1226,213 @@ class RecordsApi {
1119
1226
  constructor(extraProps) {
1120
1227
  this.extraProps = extraProps;
1121
1228
  }
1122
- insertRecord(workspace, database, branch, tableName, record, options = {}) {
1229
+ insertRecord({
1230
+ workspace,
1231
+ region,
1232
+ database,
1233
+ branch,
1234
+ table,
1235
+ record,
1236
+ columns
1237
+ }) {
1123
1238
  return operationsByTag.records.insertRecord({
1124
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1125
- queryParams: options,
1239
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1240
+ queryParams: { columns },
1126
1241
  body: record,
1127
1242
  ...this.extraProps
1128
1243
  });
1129
1244
  }
1130
- insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1245
+ getRecord({
1246
+ workspace,
1247
+ region,
1248
+ database,
1249
+ branch,
1250
+ table,
1251
+ id,
1252
+ columns
1253
+ }) {
1254
+ return operationsByTag.records.getRecord({
1255
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1256
+ queryParams: { columns },
1257
+ ...this.extraProps
1258
+ });
1259
+ }
1260
+ insertRecordWithID({
1261
+ workspace,
1262
+ region,
1263
+ database,
1264
+ branch,
1265
+ table,
1266
+ id,
1267
+ record,
1268
+ columns,
1269
+ createOnly,
1270
+ ifVersion
1271
+ }) {
1131
1272
  return operationsByTag.records.insertRecordWithID({
1132
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1133
- queryParams: options,
1273
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1274
+ queryParams: { columns, createOnly, ifVersion },
1134
1275
  body: record,
1135
1276
  ...this.extraProps
1136
1277
  });
1137
1278
  }
1138
- updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1279
+ updateRecordWithID({
1280
+ workspace,
1281
+ region,
1282
+ database,
1283
+ branch,
1284
+ table,
1285
+ id,
1286
+ record,
1287
+ columns,
1288
+ ifVersion
1289
+ }) {
1139
1290
  return operationsByTag.records.updateRecordWithID({
1140
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1141
- queryParams: options,
1291
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1292
+ queryParams: { columns, ifVersion },
1142
1293
  body: record,
1143
1294
  ...this.extraProps
1144
1295
  });
1145
1296
  }
1146
- upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1297
+ upsertRecordWithID({
1298
+ workspace,
1299
+ region,
1300
+ database,
1301
+ branch,
1302
+ table,
1303
+ id,
1304
+ record,
1305
+ columns,
1306
+ ifVersion
1307
+ }) {
1147
1308
  return operationsByTag.records.upsertRecordWithID({
1148
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1149
- queryParams: options,
1309
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1310
+ queryParams: { columns, ifVersion },
1150
1311
  body: record,
1151
1312
  ...this.extraProps
1152
1313
  });
1153
1314
  }
1154
- deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
1315
+ deleteRecord({
1316
+ workspace,
1317
+ region,
1318
+ database,
1319
+ branch,
1320
+ table,
1321
+ id,
1322
+ columns
1323
+ }) {
1155
1324
  return operationsByTag.records.deleteRecord({
1156
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1157
- queryParams: options,
1158
- ...this.extraProps
1159
- });
1160
- }
1161
- getRecord(workspace, database, branch, tableName, recordId, options = {}) {
1162
- return operationsByTag.records.getRecord({
1163
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1164
- queryParams: options,
1325
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1326
+ queryParams: { columns },
1165
1327
  ...this.extraProps
1166
1328
  });
1167
1329
  }
1168
- bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
1330
+ bulkInsertTableRecords({
1331
+ workspace,
1332
+ region,
1333
+ database,
1334
+ branch,
1335
+ table,
1336
+ records,
1337
+ columns
1338
+ }) {
1169
1339
  return operationsByTag.records.bulkInsertTableRecords({
1170
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1171
- queryParams: options,
1340
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1341
+ queryParams: { columns },
1172
1342
  body: { records },
1173
1343
  ...this.extraProps
1174
1344
  });
1175
1345
  }
1176
- queryTable(workspace, database, branch, tableName, query) {
1177
- return operationsByTag.records.queryTable({
1178
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1179
- body: query,
1346
+ }
1347
+ class SearchAndFilterApi {
1348
+ constructor(extraProps) {
1349
+ this.extraProps = extraProps;
1350
+ }
1351
+ queryTable({
1352
+ workspace,
1353
+ region,
1354
+ database,
1355
+ branch,
1356
+ table,
1357
+ filter,
1358
+ sort,
1359
+ page,
1360
+ columns
1361
+ }) {
1362
+ return operationsByTag.searchAndFilter.queryTable({
1363
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1364
+ body: { filter, sort, page, columns },
1180
1365
  ...this.extraProps
1181
1366
  });
1182
1367
  }
1183
- searchTable(workspace, database, branch, tableName, query) {
1184
- return operationsByTag.records.searchTable({
1185
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1186
- body: query,
1368
+ searchTable({
1369
+ workspace,
1370
+ region,
1371
+ database,
1372
+ branch,
1373
+ table,
1374
+ query,
1375
+ fuzziness,
1376
+ target,
1377
+ prefix,
1378
+ filter,
1379
+ highlight,
1380
+ boosters
1381
+ }) {
1382
+ return operationsByTag.searchAndFilter.searchTable({
1383
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1384
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
1187
1385
  ...this.extraProps
1188
1386
  });
1189
1387
  }
1190
- searchBranch(workspace, database, branch, query) {
1191
- return operationsByTag.records.searchBranch({
1192
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1193
- body: query,
1388
+ searchBranch({
1389
+ workspace,
1390
+ region,
1391
+ database,
1392
+ branch,
1393
+ tables,
1394
+ query,
1395
+ fuzziness,
1396
+ prefix,
1397
+ highlight
1398
+ }) {
1399
+ return operationsByTag.searchAndFilter.searchBranch({
1400
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1401
+ body: { tables, query, fuzziness, prefix, highlight },
1194
1402
  ...this.extraProps
1195
1403
  });
1196
1404
  }
1197
- summarizeTable(workspace, database, branch, tableName, query) {
1198
- return operationsByTag.records.summarizeTable({
1199
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1200
- body: query,
1405
+ summarizeTable({
1406
+ workspace,
1407
+ region,
1408
+ database,
1409
+ branch,
1410
+ table,
1411
+ filter,
1412
+ columns,
1413
+ summaries,
1414
+ sort,
1415
+ summariesFilter,
1416
+ page
1417
+ }) {
1418
+ return operationsByTag.searchAndFilter.summarizeTable({
1419
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1420
+ body: { filter, columns, summaries, sort, summariesFilter, page },
1201
1421
  ...this.extraProps
1202
1422
  });
1203
1423
  }
1204
- aggregateTable(workspace, database, branch, tableName, query) {
1205
- return operationsByTag.records.aggregateTable({
1206
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1207
- body: query,
1424
+ aggregateTable({
1425
+ workspace,
1426
+ region,
1427
+ database,
1428
+ branch,
1429
+ table,
1430
+ filter,
1431
+ aggs
1432
+ }) {
1433
+ return operationsByTag.searchAndFilter.aggregateTable({
1434
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1435
+ body: { filter, aggs },
1208
1436
  ...this.extraProps
1209
1437
  });
1210
1438
  }
@@ -1213,123 +1441,281 @@ class MigrationRequestsApi {
1213
1441
  constructor(extraProps) {
1214
1442
  this.extraProps = extraProps;
1215
1443
  }
1216
- queryMigrationRequests(workspace, database, options = {}) {
1444
+ queryMigrationRequests({
1445
+ workspace,
1446
+ region,
1447
+ database,
1448
+ filter,
1449
+ sort,
1450
+ page,
1451
+ columns
1452
+ }) {
1217
1453
  return operationsByTag.migrationRequests.queryMigrationRequests({
1218
- pathParams: { workspace, dbName: database },
1219
- body: options,
1454
+ pathParams: { workspace, region, dbName: database },
1455
+ body: { filter, sort, page, columns },
1220
1456
  ...this.extraProps
1221
1457
  });
1222
1458
  }
1223
- createMigrationRequest(workspace, database, options) {
1459
+ createMigrationRequest({
1460
+ workspace,
1461
+ region,
1462
+ database,
1463
+ migration
1464
+ }) {
1224
1465
  return operationsByTag.migrationRequests.createMigrationRequest({
1225
- pathParams: { workspace, dbName: database },
1226
- body: options,
1466
+ pathParams: { workspace, region, dbName: database },
1467
+ body: migration,
1227
1468
  ...this.extraProps
1228
1469
  });
1229
1470
  }
1230
- getMigrationRequest(workspace, database, migrationRequest) {
1471
+ getMigrationRequest({
1472
+ workspace,
1473
+ region,
1474
+ database,
1475
+ migrationRequest
1476
+ }) {
1231
1477
  return operationsByTag.migrationRequests.getMigrationRequest({
1232
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1478
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1233
1479
  ...this.extraProps
1234
1480
  });
1235
1481
  }
1236
- updateMigrationRequest(workspace, database, migrationRequest, options) {
1482
+ updateMigrationRequest({
1483
+ workspace,
1484
+ region,
1485
+ database,
1486
+ migrationRequest,
1487
+ update
1488
+ }) {
1237
1489
  return operationsByTag.migrationRequests.updateMigrationRequest({
1238
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1239
- body: options,
1490
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1491
+ body: update,
1240
1492
  ...this.extraProps
1241
1493
  });
1242
1494
  }
1243
- listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1495
+ listMigrationRequestsCommits({
1496
+ workspace,
1497
+ region,
1498
+ database,
1499
+ migrationRequest,
1500
+ page
1501
+ }) {
1244
1502
  return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1245
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1246
- body: options,
1503
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1504
+ body: { page },
1247
1505
  ...this.extraProps
1248
1506
  });
1249
1507
  }
1250
- compareMigrationRequest(workspace, database, migrationRequest) {
1508
+ compareMigrationRequest({
1509
+ workspace,
1510
+ region,
1511
+ database,
1512
+ migrationRequest
1513
+ }) {
1251
1514
  return operationsByTag.migrationRequests.compareMigrationRequest({
1252
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1515
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1253
1516
  ...this.extraProps
1254
1517
  });
1255
1518
  }
1256
- getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1519
+ getMigrationRequestIsMerged({
1520
+ workspace,
1521
+ region,
1522
+ database,
1523
+ migrationRequest
1524
+ }) {
1257
1525
  return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1258
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1526
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1259
1527
  ...this.extraProps
1260
1528
  });
1261
1529
  }
1262
- mergeMigrationRequest(workspace, database, migrationRequest) {
1530
+ mergeMigrationRequest({
1531
+ workspace,
1532
+ region,
1533
+ database,
1534
+ migrationRequest
1535
+ }) {
1263
1536
  return operationsByTag.migrationRequests.mergeMigrationRequest({
1264
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1537
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1265
1538
  ...this.extraProps
1266
1539
  });
1267
1540
  }
1268
1541
  }
1269
- class BranchSchemaApi {
1542
+ class MigrationsApi {
1270
1543
  constructor(extraProps) {
1271
1544
  this.extraProps = extraProps;
1272
1545
  }
1273
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
1274
- return operationsByTag.branchSchema.getBranchMigrationHistory({
1275
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1276
- body: options,
1546
+ getBranchMigrationHistory({
1547
+ workspace,
1548
+ region,
1549
+ database,
1550
+ branch,
1551
+ limit,
1552
+ startFrom
1553
+ }) {
1554
+ return operationsByTag.migrations.getBranchMigrationHistory({
1555
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1556
+ body: { limit, startFrom },
1277
1557
  ...this.extraProps
1278
1558
  });
1279
1559
  }
1280
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1281
- return operationsByTag.branchSchema.executeBranchMigrationPlan({
1282
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1283
- body: migrationPlan,
1560
+ getBranchMigrationPlan({
1561
+ workspace,
1562
+ region,
1563
+ database,
1564
+ branch,
1565
+ schema
1566
+ }) {
1567
+ return operationsByTag.migrations.getBranchMigrationPlan({
1568
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1569
+ body: schema,
1284
1570
  ...this.extraProps
1285
1571
  });
1286
1572
  }
1287
- getBranchMigrationPlan(workspace, database, branch, schema) {
1288
- return operationsByTag.branchSchema.getBranchMigrationPlan({
1289
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1290
- body: schema,
1573
+ executeBranchMigrationPlan({
1574
+ workspace,
1575
+ region,
1576
+ database,
1577
+ branch,
1578
+ plan
1579
+ }) {
1580
+ return operationsByTag.migrations.executeBranchMigrationPlan({
1581
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1582
+ body: plan,
1583
+ ...this.extraProps
1584
+ });
1585
+ }
1586
+ getBranchSchemaHistory({
1587
+ workspace,
1588
+ region,
1589
+ database,
1590
+ branch,
1591
+ page
1592
+ }) {
1593
+ return operationsByTag.migrations.getBranchSchemaHistory({
1594
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1595
+ body: { page },
1291
1596
  ...this.extraProps
1292
1597
  });
1293
1598
  }
1294
- compareBranchWithUserSchema(workspace, database, branch, schema) {
1295
- return operationsByTag.branchSchema.compareBranchWithUserSchema({
1296
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1599
+ compareBranchWithUserSchema({
1600
+ workspace,
1601
+ region,
1602
+ database,
1603
+ branch,
1604
+ schema
1605
+ }) {
1606
+ return operationsByTag.migrations.compareBranchWithUserSchema({
1607
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1297
1608
  body: { schema },
1298
1609
  ...this.extraProps
1299
1610
  });
1300
1611
  }
1301
- compareBranchSchemas(workspace, database, branch, branchName, schema) {
1302
- return operationsByTag.branchSchema.compareBranchSchemas({
1303
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1612
+ compareBranchSchemas({
1613
+ workspace,
1614
+ region,
1615
+ database,
1616
+ branch,
1617
+ compare,
1618
+ schema
1619
+ }) {
1620
+ return operationsByTag.migrations.compareBranchSchemas({
1621
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
1304
1622
  body: { schema },
1305
1623
  ...this.extraProps
1306
1624
  });
1307
1625
  }
1308
- updateBranchSchema(workspace, database, branch, migration) {
1309
- return operationsByTag.branchSchema.updateBranchSchema({
1310
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1626
+ updateBranchSchema({
1627
+ workspace,
1628
+ region,
1629
+ database,
1630
+ branch,
1631
+ migration
1632
+ }) {
1633
+ return operationsByTag.migrations.updateBranchSchema({
1634
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1311
1635
  body: migration,
1312
1636
  ...this.extraProps
1313
1637
  });
1314
1638
  }
1315
- previewBranchSchemaEdit(workspace, database, branch, migration) {
1316
- return operationsByTag.branchSchema.previewBranchSchemaEdit({
1317
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1318
- body: migration,
1639
+ previewBranchSchemaEdit({
1640
+ workspace,
1641
+ region,
1642
+ database,
1643
+ branch,
1644
+ data
1645
+ }) {
1646
+ return operationsByTag.migrations.previewBranchSchemaEdit({
1647
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1648
+ body: data,
1319
1649
  ...this.extraProps
1320
1650
  });
1321
1651
  }
1322
- applyBranchSchemaEdit(workspace, database, branch, edits) {
1323
- return operationsByTag.branchSchema.applyBranchSchemaEdit({
1324
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1652
+ applyBranchSchemaEdit({
1653
+ workspace,
1654
+ region,
1655
+ database,
1656
+ branch,
1657
+ edits
1658
+ }) {
1659
+ return operationsByTag.migrations.applyBranchSchemaEdit({
1660
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1325
1661
  body: { edits },
1326
1662
  ...this.extraProps
1327
1663
  });
1328
1664
  }
1329
- getBranchSchemaHistory(workspace, database, branch, options = {}) {
1330
- return operationsByTag.branchSchema.getBranchSchemaHistory({
1331
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1332
- body: options,
1665
+ }
1666
+ class DatabaseApi {
1667
+ constructor(extraProps) {
1668
+ this.extraProps = extraProps;
1669
+ }
1670
+ getDatabaseList({ workspace }) {
1671
+ return operationsByTag.databases.getDatabaseList({
1672
+ pathParams: { workspaceId: workspace },
1673
+ ...this.extraProps
1674
+ });
1675
+ }
1676
+ createDatabase({
1677
+ workspace,
1678
+ database,
1679
+ data
1680
+ }) {
1681
+ return operationsByTag.databases.createDatabase({
1682
+ pathParams: { workspaceId: workspace, dbName: database },
1683
+ body: data,
1684
+ ...this.extraProps
1685
+ });
1686
+ }
1687
+ deleteDatabase({
1688
+ workspace,
1689
+ database
1690
+ }) {
1691
+ return operationsByTag.databases.deleteDatabase({
1692
+ pathParams: { workspaceId: workspace, dbName: database },
1693
+ ...this.extraProps
1694
+ });
1695
+ }
1696
+ getDatabaseMetadata({
1697
+ workspace,
1698
+ database
1699
+ }) {
1700
+ return operationsByTag.databases.getDatabaseMetadata({
1701
+ pathParams: { workspaceId: workspace, dbName: database },
1702
+ ...this.extraProps
1703
+ });
1704
+ }
1705
+ updateDatabaseMetadata({
1706
+ workspace,
1707
+ database,
1708
+ metadata
1709
+ }) {
1710
+ return operationsByTag.databases.updateDatabaseMetadata({
1711
+ pathParams: { workspaceId: workspace, dbName: database },
1712
+ body: metadata,
1713
+ ...this.extraProps
1714
+ });
1715
+ }
1716
+ listRegions({ workspace }) {
1717
+ return operationsByTag.databases.listRegions({
1718
+ pathParams: { workspaceId: workspace },
1333
1719
  ...this.extraProps
1334
1720
  });
1335
1721
  }
@@ -1660,7 +2046,7 @@ cleanFilterConstraint_fn = function(column, value) {
1660
2046
  };
1661
2047
  function cleanParent(data, parent) {
1662
2048
  if (isCursorPaginationOptions(data.pagination)) {
1663
- return { ...parent, sorting: void 0, filter: void 0 };
2049
+ return { ...parent, sort: void 0, filter: void 0 };
1664
2050
  }
1665
2051
  return parent;
1666
2052
  }
@@ -1762,8 +2148,9 @@ class RestRepository extends Query {
1762
2148
  });
1763
2149
  });
1764
2150
  }
1765
- async create(a, b, c) {
2151
+ async create(a, b, c, d) {
1766
2152
  return __privateGet$4(this, _trace).call(this, "create", async () => {
2153
+ const ifVersion = parseIfVersion(b, c, d);
1767
2154
  if (Array.isArray(a)) {
1768
2155
  if (a.length === 0)
1769
2156
  return [];
@@ -1774,13 +2161,13 @@ class RestRepository extends Query {
1774
2161
  if (a === "")
1775
2162
  throw new Error("The id can't be empty");
1776
2163
  const columns = isStringArray(c) ? c : void 0;
1777
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
2164
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
1778
2165
  }
1779
2166
  if (isObject(a) && isString(a.id)) {
1780
2167
  if (a.id === "")
1781
2168
  throw new Error("The id can't be empty");
1782
2169
  const columns = isStringArray(b) ? b : void 0;
1783
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2170
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
1784
2171
  }
1785
2172
  if (isObject(a)) {
1786
2173
  const columns = isStringArray(b) ? b : void 0;
@@ -1811,6 +2198,7 @@ class RestRepository extends Query {
1811
2198
  pathParams: {
1812
2199
  workspace: "{workspaceId}",
1813
2200
  dbBranchName: "{dbBranch}",
2201
+ region: "{region}",
1814
2202
  tableName: __privateGet$4(this, _table),
1815
2203
  recordId: id
1816
2204
  },
@@ -1848,8 +2236,9 @@ class RestRepository extends Query {
1848
2236
  return result;
1849
2237
  });
1850
2238
  }
1851
- async update(a, b, c) {
2239
+ async update(a, b, c, d) {
1852
2240
  return __privateGet$4(this, _trace).call(this, "update", async () => {
2241
+ const ifVersion = parseIfVersion(b, c, d);
1853
2242
  if (Array.isArray(a)) {
1854
2243
  if (a.length === 0)
1855
2244
  return [];
@@ -1861,18 +2250,18 @@ class RestRepository extends Query {
1861
2250
  }
1862
2251
  if (isString(a) && isObject(b)) {
1863
2252
  const columns = isStringArray(c) ? c : void 0;
1864
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
2253
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1865
2254
  }
1866
2255
  if (isObject(a) && isString(a.id)) {
1867
2256
  const columns = isStringArray(b) ? b : void 0;
1868
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2257
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
1869
2258
  }
1870
2259
  throw new Error("Invalid arguments for update method");
1871
2260
  });
1872
2261
  }
1873
- async updateOrThrow(a, b, c) {
2262
+ async updateOrThrow(a, b, c, d) {
1874
2263
  return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1875
- const result = await this.update(a, b, c);
2264
+ const result = await this.update(a, b, c, d);
1876
2265
  if (Array.isArray(result)) {
1877
2266
  const missingIds = compact(
1878
2267
  a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
@@ -1889,8 +2278,9 @@ class RestRepository extends Query {
1889
2278
  return result;
1890
2279
  });
1891
2280
  }
1892
- async createOrUpdate(a, b, c) {
2281
+ async createOrUpdate(a, b, c, d) {
1893
2282
  return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
2283
+ const ifVersion = parseIfVersion(b, c, d);
1894
2284
  if (Array.isArray(a)) {
1895
2285
  if (a.length === 0)
1896
2286
  return [];
@@ -1902,15 +2292,35 @@ class RestRepository extends Query {
1902
2292
  }
1903
2293
  if (isString(a) && isObject(b)) {
1904
2294
  const columns = isStringArray(c) ? c : void 0;
1905
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
2295
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1906
2296
  }
1907
2297
  if (isObject(a) && isString(a.id)) {
1908
2298
  const columns = isStringArray(c) ? c : void 0;
1909
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2299
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
1910
2300
  }
1911
2301
  throw new Error("Invalid arguments for createOrUpdate method");
1912
2302
  });
1913
2303
  }
2304
+ async createOrReplace(a, b, c, d) {
2305
+ return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
2306
+ const ifVersion = parseIfVersion(b, c, d);
2307
+ if (Array.isArray(a)) {
2308
+ if (a.length === 0)
2309
+ return [];
2310
+ const columns = isStringArray(b) ? b : ["*"];
2311
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
2312
+ }
2313
+ if (isString(a) && isObject(b)) {
2314
+ const columns = isStringArray(c) ? c : void 0;
2315
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
2316
+ }
2317
+ if (isObject(a) && isString(a.id)) {
2318
+ const columns = isStringArray(c) ? c : void 0;
2319
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
2320
+ }
2321
+ throw new Error("Invalid arguments for createOrReplace method");
2322
+ });
2323
+ }
1914
2324
  async delete(a, b) {
1915
2325
  return __privateGet$4(this, _trace).call(this, "delete", async () => {
1916
2326
  if (Array.isArray(a)) {
@@ -1952,7 +2362,12 @@ class RestRepository extends Query {
1952
2362
  return __privateGet$4(this, _trace).call(this, "search", async () => {
1953
2363
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1954
2364
  const { records } = await searchTable({
1955
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2365
+ pathParams: {
2366
+ workspace: "{workspaceId}",
2367
+ dbBranchName: "{dbBranch}",
2368
+ region: "{region}",
2369
+ tableName: __privateGet$4(this, _table)
2370
+ },
1956
2371
  body: {
1957
2372
  query,
1958
2373
  fuzziness: options.fuzziness,
@@ -1971,7 +2386,12 @@ class RestRepository extends Query {
1971
2386
  return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
1972
2387
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1973
2388
  const result = await aggregateTable({
1974
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2389
+ pathParams: {
2390
+ workspace: "{workspaceId}",
2391
+ dbBranchName: "{dbBranch}",
2392
+ region: "{region}",
2393
+ tableName: __privateGet$4(this, _table)
2394
+ },
1975
2395
  body: { aggs, filter },
1976
2396
  ...fetchProps
1977
2397
  });
@@ -1986,7 +2406,12 @@ class RestRepository extends Query {
1986
2406
  const data = query.getQueryOptions();
1987
2407
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1988
2408
  const { meta, records: objects } = await queryTable({
1989
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2409
+ pathParams: {
2410
+ workspace: "{workspaceId}",
2411
+ dbBranchName: "{dbBranch}",
2412
+ region: "{region}",
2413
+ tableName: __privateGet$4(this, _table)
2414
+ },
1990
2415
  body: {
1991
2416
  filter: cleanFilter(data.filter),
1992
2417
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
@@ -2008,11 +2433,17 @@ class RestRepository extends Query {
2008
2433
  const data = query.getQueryOptions();
2009
2434
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2010
2435
  const result = await summarizeTable({
2011
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2436
+ pathParams: {
2437
+ workspace: "{workspaceId}",
2438
+ dbBranchName: "{dbBranch}",
2439
+ region: "{region}",
2440
+ tableName: __privateGet$4(this, _table)
2441
+ },
2012
2442
  body: {
2013
2443
  filter: cleanFilter(data.filter),
2014
2444
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2015
2445
  columns: data.columns,
2446
+ page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
2016
2447
  summaries,
2017
2448
  summariesFilter
2018
2449
  },
@@ -2036,6 +2467,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
2036
2467
  pathParams: {
2037
2468
  workspace: "{workspaceId}",
2038
2469
  dbBranchName: "{dbBranch}",
2470
+ region: "{region}",
2039
2471
  tableName: __privateGet$4(this, _table)
2040
2472
  },
2041
2473
  queryParams: { columns },
@@ -2046,18 +2478,19 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
2046
2478
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2047
2479
  };
2048
2480
  _insertRecordWithId = new WeakSet();
2049
- insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
2481
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
2050
2482
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2051
2483
  const record = transformObjectLinks(object);
2052
2484
  const response = await insertRecordWithID({
2053
2485
  pathParams: {
2054
2486
  workspace: "{workspaceId}",
2055
2487
  dbBranchName: "{dbBranch}",
2488
+ region: "{region}",
2056
2489
  tableName: __privateGet$4(this, _table),
2057
2490
  recordId
2058
2491
  },
2059
2492
  body: record,
2060
- queryParams: { createOnly: true, columns },
2493
+ queryParams: { createOnly, columns, ifVersion },
2061
2494
  ...fetchProps
2062
2495
  });
2063
2496
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
@@ -2068,7 +2501,12 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
2068
2501
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2069
2502
  const records = objects.map((object) => transformObjectLinks(object));
2070
2503
  const response = await bulkInsertTableRecords({
2071
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2504
+ pathParams: {
2505
+ workspace: "{workspaceId}",
2506
+ dbBranchName: "{dbBranch}",
2507
+ region: "{region}",
2508
+ tableName: __privateGet$4(this, _table)
2509
+ },
2072
2510
  queryParams: { columns },
2073
2511
  body: { records },
2074
2512
  ...fetchProps
@@ -2080,13 +2518,19 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
2080
2518
  return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
2081
2519
  };
2082
2520
  _updateRecordWithID = new WeakSet();
2083
- updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2521
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
2084
2522
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2085
2523
  const record = transformObjectLinks(object);
2086
2524
  try {
2087
2525
  const response = await updateRecordWithID({
2088
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2089
- queryParams: { columns },
2526
+ pathParams: {
2527
+ workspace: "{workspaceId}",
2528
+ dbBranchName: "{dbBranch}",
2529
+ region: "{region}",
2530
+ tableName: __privateGet$4(this, _table),
2531
+ recordId
2532
+ },
2533
+ queryParams: { columns, ifVersion },
2090
2534
  body: record,
2091
2535
  ...fetchProps
2092
2536
  });
@@ -2100,11 +2544,17 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2100
2544
  }
2101
2545
  };
2102
2546
  _upsertRecordWithID = new WeakSet();
2103
- upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2547
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
2104
2548
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2105
2549
  const response = await upsertRecordWithID({
2106
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2107
- queryParams: { columns },
2550
+ pathParams: {
2551
+ workspace: "{workspaceId}",
2552
+ dbBranchName: "{dbBranch}",
2553
+ region: "{region}",
2554
+ tableName: __privateGet$4(this, _table),
2555
+ recordId
2556
+ },
2557
+ queryParams: { columns, ifVersion },
2108
2558
  body: object,
2109
2559
  ...fetchProps
2110
2560
  });
@@ -2116,7 +2566,13 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
2116
2566
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2117
2567
  try {
2118
2568
  const response = await deleteRecord({
2119
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2569
+ pathParams: {
2570
+ workspace: "{workspaceId}",
2571
+ dbBranchName: "{dbBranch}",
2572
+ region: "{region}",
2573
+ tableName: __privateGet$4(this, _table),
2574
+ recordId
2575
+ },
2120
2576
  queryParams: { columns },
2121
2577
  ...fetchProps
2122
2578
  });
@@ -2151,7 +2607,7 @@ getSchemaTables_fn$1 = async function() {
2151
2607
  return __privateGet$4(this, _schemaTables$2);
2152
2608
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2153
2609
  const { schema } = await getBranchDetails({
2154
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2610
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2155
2611
  ...fetchProps
2156
2612
  });
2157
2613
  __privateSet$4(this, _schemaTables$2, schema.tables);
@@ -2217,8 +2673,15 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2217
2673
  result.read = function(columns2) {
2218
2674
  return db[table].read(result["id"], columns2);
2219
2675
  };
2220
- result.update = function(data, columns2) {
2221
- return db[table].update(result["id"], data, columns2);
2676
+ result.update = function(data, b, c) {
2677
+ const columns2 = isStringArray(b) ? b : ["*"];
2678
+ const ifVersion = parseIfVersion(b, c);
2679
+ return db[table].update(result["id"], data, columns2, { ifVersion });
2680
+ };
2681
+ result.replace = function(data, b, c) {
2682
+ const columns2 = isStringArray(b) ? b : ["*"];
2683
+ const ifVersion = parseIfVersion(b, c);
2684
+ return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
2222
2685
  };
2223
2686
  result.delete = function() {
2224
2687
  return db[table].delete(result["id"]);
@@ -2226,7 +2689,7 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2226
2689
  result.getMetadata = function() {
2227
2690
  return xata;
2228
2691
  };
2229
- for (const prop of ["read", "update", "delete", "getMetadata"]) {
2692
+ for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
2230
2693
  Object.defineProperty(result, prop, { enumerable: false });
2231
2694
  }
2232
2695
  Object.freeze(result);
@@ -2251,6 +2714,14 @@ function isValidColumn(columns, column) {
2251
2714
  }
2252
2715
  return columns.includes(column.name);
2253
2716
  }
2717
+ function parseIfVersion(...args) {
2718
+ for (const arg of args) {
2719
+ if (isObject(arg) && isNumber(arg.ifVersion)) {
2720
+ return arg.ifVersion;
2721
+ }
2722
+ }
2723
+ return void 0;
2724
+ }
2254
2725
 
2255
2726
  var __accessCheck$3 = (obj, member, msg) => {
2256
2727
  if (!member.has(obj))
@@ -2438,7 +2909,7 @@ search_fn = async function(query, options, getFetchProps) {
2438
2909
  const fetchProps = await getFetchProps();
2439
2910
  const { tables, fuzziness, highlight, prefix } = options ?? {};
2440
2911
  const { records } = await searchBranch({
2441
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2912
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2442
2913
  body: { tables, query, fuzziness, prefix, highlight },
2443
2914
  ...fetchProps
2444
2915
  });
@@ -2450,7 +2921,7 @@ getSchemaTables_fn = async function(getFetchProps) {
2450
2921
  return __privateGet$1(this, _schemaTables);
2451
2922
  const fetchProps = await getFetchProps();
2452
2923
  const { schema } = await getBranchDetails({
2453
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2924
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2454
2925
  ...fetchProps
2455
2926
  });
2456
2927
  __privateSet$1(this, _schemaTables, schema.tables);
@@ -2488,14 +2959,17 @@ async function resolveXataBranch(gitBranch, options) {
2488
2959
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2489
2960
  );
2490
2961
  const [protocol, , host, , dbName] = databaseURL.split("/");
2491
- const [workspace] = host.split(".");
2962
+ const urlParts = parseWorkspacesUrlParts(host);
2963
+ if (!urlParts)
2964
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
2965
+ const { workspace, region } = urlParts;
2492
2966
  const { fallbackBranch } = getEnvironment();
2493
2967
  const { branch } = await resolveBranch({
2494
2968
  apiKey,
2495
2969
  apiUrl: databaseURL,
2496
2970
  fetchImpl: getFetchImplementation(options?.fetchImpl),
2497
2971
  workspacesApiUrl: `${protocol}//${host}`,
2498
- pathParams: { dbName, workspace },
2972
+ pathParams: { dbName, workspace, region },
2499
2973
  queryParams: { gitBranch, fallbackBranch },
2500
2974
  trace: defaultTrace
2501
2975
  });
@@ -2513,15 +2987,17 @@ async function getDatabaseBranch(branch, options) {
2513
2987
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2514
2988
  );
2515
2989
  const [protocol, , host, , database] = databaseURL.split("/");
2516
- const [workspace] = host.split(".");
2517
- const dbBranchName = `${database}:${branch}`;
2990
+ const urlParts = parseWorkspacesUrlParts(host);
2991
+ if (!urlParts)
2992
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
2993
+ const { workspace, region } = urlParts;
2518
2994
  try {
2519
2995
  return await getBranchDetails({
2520
2996
  apiKey,
2521
2997
  apiUrl: databaseURL,
2522
2998
  fetchImpl: getFetchImplementation(options?.fetchImpl),
2523
2999
  workspacesApiUrl: `${protocol}//${host}`,
2524
- pathParams: { dbBranchName, workspace },
3000
+ pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
2525
3001
  trace: defaultTrace
2526
3002
  });
2527
3003
  } catch (err) {
@@ -2613,14 +3089,7 @@ const buildClient = (plugins) => {
2613
3089
  throw new Error("Option databaseURL is required");
2614
3090
  }
2615
3091
  return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID() };
2616
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
2617
- fetch,
2618
- apiKey,
2619
- databaseURL,
2620
- branch,
2621
- trace,
2622
- clientID
2623
- }) {
3092
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
2624
3093
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2625
3094
  if (!branchValue)
2626
3095
  throw new Error("Unable to resolve branch value");
@@ -2746,5 +3215,5 @@ class XataError extends Error {
2746
3215
  }
2747
3216
  }
2748
3217
 
2749
- export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, buildClient, buildWorkerRunner, bulkInsertTableRecords, cPCreateDatabase, cPDeleteDatabase, cPGetCPDatabaseMetadata, cPGetDatabaseList, cPUpdateCPDatabaseMetadata, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, pattern, previewBranchSchemaEdit, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
3218
+ export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, dEPRECATEDcreateDatabase, dEPRECATEDdeleteDatabase, dEPRECATEDgetDatabaseList, dEPRECATEDgetDatabaseMetadata, dEPRECATEDupdateDatabaseMetadata, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
2750
3219
  //# sourceMappingURL=index.mjs.map