@xata.io/client 0.18.6 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -60,6 +60,9 @@ function isString(value) {
60
60
  function isStringArray(value) {
61
61
  return isDefined(value) && Array.isArray(value) && value.every(isString);
62
62
  }
63
+ function isNumber(value) {
64
+ return isDefined(value) && typeof value === "number";
65
+ }
63
66
  function toBase64(value) {
64
67
  try {
65
68
  return btoa(value);
@@ -68,6 +71,17 @@ function toBase64(value) {
68
71
  return buf.from(value).toString("base64");
69
72
  }
70
73
  }
74
+ function deepMerge(a, b) {
75
+ const result = { ...a };
76
+ for (const [key, value] of Object.entries(b)) {
77
+ if (isObject(value) && isObject(result[key])) {
78
+ result[key] = deepMerge(result[key], value);
79
+ } else {
80
+ result[key] = value;
81
+ }
82
+ }
83
+ return result;
84
+ }
71
85
 
72
86
  function getEnvironment() {
73
87
  try {
@@ -172,7 +186,7 @@ function getFetchImplementation(userFetch) {
172
186
  return fetchImpl;
173
187
  }
174
188
 
175
- const VERSION = "0.18.6";
189
+ const VERSION = "0.19.0";
176
190
 
177
191
  class ErrorWithCause extends Error {
178
192
  constructor(message, options) {
@@ -229,15 +243,18 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
229
243
  return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
230
244
  };
231
245
  function buildBaseUrl({
246
+ endpoint,
232
247
  path,
233
248
  workspacesApiUrl,
234
249
  apiUrl,
235
- pathParams
250
+ pathParams = {}
236
251
  }) {
237
- if (pathParams?.workspace === void 0 || !path.startsWith("/db"))
238
- return `${apiUrl}${path}`;
239
- const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
240
- return url.replace("{workspaceId}", String(pathParams.workspace));
252
+ if (endpoint === "dataPlane") {
253
+ const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
254
+ const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
255
+ return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
256
+ }
257
+ return `${apiUrl}${path}`;
241
258
  }
242
259
  function hostHeader(url) {
243
260
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
@@ -253,6 +270,7 @@ async function fetch$1({
253
270
  queryParams,
254
271
  fetchImpl,
255
272
  apiKey,
273
+ endpoint,
256
274
  apiUrl,
257
275
  workspacesApiUrl,
258
276
  trace,
@@ -263,7 +281,7 @@ async function fetch$1({
263
281
  return trace(
264
282
  `${method.toUpperCase()} ${path}`,
265
283
  async ({ setAttributes }) => {
266
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
284
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
267
285
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
268
286
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
269
287
  setAttributes({
@@ -318,415 +336,359 @@ function parseUrl(url) {
318
336
  }
319
337
  }
320
338
 
321
- const getUser = (variables, signal) => fetch$1({ url: "/user", method: "get", ...variables, signal });
322
- const updateUser = (variables, signal) => fetch$1({
323
- url: "/user",
324
- method: "put",
325
- ...variables,
326
- signal
327
- });
328
- const deleteUser = (variables, signal) => fetch$1({ url: "/user", method: "delete", ...variables, signal });
329
- const getUserAPIKeys = (variables, signal) => fetch$1({
330
- url: "/user/keys",
339
+ const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
340
+
341
+ const getDatabaseList = (variables, signal) => dataPlaneFetch({
342
+ url: "/dbs",
331
343
  method: "get",
332
344
  ...variables,
333
345
  signal
334
346
  });
335
- const createUserAPIKey = (variables, signal) => fetch$1({
336
- url: "/user/keys/{keyName}",
337
- method: "post",
347
+ const getBranchList = (variables, signal) => dataPlaneFetch({
348
+ url: "/dbs/{dbName}",
349
+ method: "get",
338
350
  ...variables,
339
351
  signal
340
352
  });
341
- const deleteUserAPIKey = (variables, signal) => fetch$1({
342
- url: "/user/keys/{keyName}",
353
+ const createDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
354
+ const deleteDatabase = (variables, signal) => dataPlaneFetch({
355
+ url: "/dbs/{dbName}",
343
356
  method: "delete",
344
357
  ...variables,
345
358
  signal
346
359
  });
347
- const createWorkspace = (variables, signal) => fetch$1({
348
- url: "/workspaces",
349
- method: "post",
350
- ...variables,
351
- signal
352
- });
353
- const getWorkspacesList = (variables, signal) => fetch$1({
354
- url: "/workspaces",
355
- method: "get",
356
- ...variables,
357
- signal
358
- });
359
- const getWorkspace = (variables, signal) => fetch$1({
360
- url: "/workspaces/{workspaceId}",
360
+ const getDatabaseMetadata = (variables, signal) => dataPlaneFetch({
361
+ url: "/dbs/{dbName}/metadata",
361
362
  method: "get",
362
363
  ...variables,
363
364
  signal
364
365
  });
365
- const updateWorkspace = (variables, signal) => fetch$1({
366
- url: "/workspaces/{workspaceId}",
367
- method: "put",
368
- ...variables,
369
- signal
370
- });
371
- const deleteWorkspace = (variables, signal) => fetch$1({
372
- url: "/workspaces/{workspaceId}",
373
- method: "delete",
374
- ...variables,
375
- signal
376
- });
377
- const getWorkspaceMembersList = (variables, signal) => fetch$1({
378
- url: "/workspaces/{workspaceId}/members",
366
+ const updateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
367
+ const getBranchDetails = (variables, signal) => dataPlaneFetch({
368
+ url: "/db/{dbBranchName}",
379
369
  method: "get",
380
370
  ...variables,
381
371
  signal
382
372
  });
383
- const updateWorkspaceMemberRole = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
384
- const removeWorkspaceMember = (variables, signal) => fetch$1({
385
- url: "/workspaces/{workspaceId}/members/{userId}",
373
+ const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
374
+ const deleteBranch = (variables, signal) => dataPlaneFetch({
375
+ url: "/db/{dbBranchName}",
386
376
  method: "delete",
387
377
  ...variables,
388
378
  signal
389
379
  });
390
- const inviteWorkspaceMember = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
391
- const updateWorkspaceMemberInvite = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
392
- const cancelWorkspaceMemberInvite = (variables, signal) => fetch$1({
393
- url: "/workspaces/{workspaceId}/invites/{inviteId}",
394
- method: "delete",
380
+ const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
381
+ url: "/db/{dbBranchName}/metadata",
382
+ method: "put",
395
383
  ...variables,
396
384
  signal
397
385
  });
398
- const resendWorkspaceMemberInvite = (variables, signal) => fetch$1({
399
- url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
400
- method: "post",
386
+ const getBranchMetadata = (variables, signal) => dataPlaneFetch({
387
+ url: "/db/{dbBranchName}/metadata",
388
+ method: "get",
401
389
  ...variables,
402
390
  signal
403
391
  });
404
- const acceptWorkspaceMemberInvite = (variables, signal) => fetch$1({
405
- url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
406
- method: "post",
392
+ const getBranchStats = (variables, signal) => dataPlaneFetch({
393
+ url: "/db/{dbBranchName}/stats",
394
+ method: "get",
407
395
  ...variables,
408
396
  signal
409
397
  });
410
- const getDatabaseList = (variables, signal) => fetch$1({
411
- url: "/dbs",
398
+ const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
399
+ const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
400
+ const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
401
+ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
402
+ const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
403
+ const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
404
+ const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
405
+ const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
406
+ const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
407
+ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
408
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
412
409
  method: "get",
413
410
  ...variables,
414
411
  signal
415
412
  });
416
- const getBranchList = (variables, signal) => fetch$1({
417
- url: "/dbs/{dbName}",
418
- method: "get",
413
+ const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
414
+ const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
415
+ const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
416
+ const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
417
+ const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
418
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
419
+ method: "post",
419
420
  ...variables,
420
421
  signal
421
422
  });
422
- const createDatabase = (variables, signal) => fetch$1({
423
- url: "/dbs/{dbName}",
423
+ const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
424
+ const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
425
+ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
426
+ const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
427
+ const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
428
+ const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
429
+ const createTable = (variables, signal) => dataPlaneFetch({
430
+ url: "/db/{dbBranchName}/tables/{tableName}",
424
431
  method: "put",
425
432
  ...variables,
426
433
  signal
427
434
  });
428
- const deleteDatabase = (variables, signal) => fetch$1({
429
- url: "/dbs/{dbName}",
435
+ const deleteTable = (variables, signal) => dataPlaneFetch({
436
+ url: "/db/{dbBranchName}/tables/{tableName}",
430
437
  method: "delete",
431
438
  ...variables,
432
439
  signal
433
440
  });
434
- const getDatabaseMetadata = (variables, signal) => fetch$1({
435
- url: "/dbs/{dbName}/metadata",
441
+ const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
442
+ const getTableSchema = (variables, signal) => dataPlaneFetch({
443
+ url: "/db/{dbBranchName}/tables/{tableName}/schema",
436
444
  method: "get",
437
445
  ...variables,
438
446
  signal
439
447
  });
440
- const updateDatabaseMetadata = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
441
- const getGitBranchesMapping = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
442
- const addGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
443
- const removeGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
444
- const resolveBranch = (variables, signal) => fetch$1({
445
- url: "/dbs/{dbName}/resolveBranch",
448
+ const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
449
+ const getTableColumns = (variables, signal) => dataPlaneFetch({
450
+ url: "/db/{dbBranchName}/tables/{tableName}/columns",
446
451
  method: "get",
447
452
  ...variables,
448
453
  signal
449
454
  });
450
- const queryMigrationRequests = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
451
- const createMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
452
- const getMigrationRequest = (variables, signal) => fetch$1({
453
- url: "/dbs/{dbName}/migrations/{mrNumber}",
455
+ const addTableColumn = (variables, signal) => dataPlaneFetch(
456
+ { url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
457
+ );
458
+ const getColumn = (variables, signal) => dataPlaneFetch({
459
+ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
454
460
  method: "get",
455
461
  ...variables,
456
462
  signal
457
463
  });
458
- const updateMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
459
- const listMigrationRequestsCommits = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
460
- const compareMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
461
- const getMigrationRequestIsMerged = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
462
- const mergeMigrationRequest = (variables, signal) => fetch$1({
463
- url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
464
- method: "post",
464
+ const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
465
+ const deleteColumn = (variables, signal) => dataPlaneFetch({
466
+ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
467
+ method: "delete",
465
468
  ...variables,
466
469
  signal
467
470
  });
468
- const getBranchDetails = (variables, signal) => fetch$1({
469
- url: "/db/{dbBranchName}",
471
+ const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
472
+ const getRecord = (variables, signal) => dataPlaneFetch({
473
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
470
474
  method: "get",
471
475
  ...variables,
472
476
  signal
473
477
  });
474
- const createBranch = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
475
- const deleteBranch = (variables, signal) => fetch$1({
476
- url: "/db/{dbBranchName}",
477
- method: "delete",
478
- ...variables,
479
- signal
480
- });
481
- const updateBranchMetadata = (variables, signal) => fetch$1({
482
- url: "/db/{dbBranchName}/metadata",
483
- method: "put",
478
+ const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
479
+ const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
480
+ const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
481
+ const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
482
+ const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
483
+ const queryTable = (variables, signal) => dataPlaneFetch({
484
+ url: "/db/{dbBranchName}/tables/{tableName}/query",
485
+ method: "post",
484
486
  ...variables,
485
487
  signal
486
488
  });
487
- const getBranchMetadata = (variables, signal) => fetch$1({
488
- url: "/db/{dbBranchName}/metadata",
489
- method: "get",
489
+ const searchBranch = (variables, signal) => dataPlaneFetch({
490
+ url: "/db/{dbBranchName}/search",
491
+ method: "post",
490
492
  ...variables,
491
493
  signal
492
494
  });
493
- const getBranchMigrationHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
494
- const executeBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
495
- const getBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
496
- const compareBranchWithUserSchema = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
497
- const compareBranchSchemas = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
498
- const updateBranchSchema = (variables, signal) => fetch$1({
499
- url: "/db/{dbBranchName}/schema/update",
495
+ const searchTable = (variables, signal) => dataPlaneFetch({
496
+ url: "/db/{dbBranchName}/tables/{tableName}/search",
500
497
  method: "post",
501
498
  ...variables,
502
499
  signal
503
500
  });
504
- const previewBranchSchemaEdit = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
505
- const applyBranchSchemaEdit = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
506
- const getBranchSchemaHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
507
- const getBranchStats = (variables, signal) => fetch$1({
508
- url: "/db/{dbBranchName}/stats",
501
+ const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
502
+ const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
503
+ const operationsByTag$2 = {
504
+ database: { getDatabaseList, createDatabase, deleteDatabase, getDatabaseMetadata, updateDatabaseMetadata },
505
+ branch: {
506
+ getBranchList,
507
+ getBranchDetails,
508
+ createBranch,
509
+ deleteBranch,
510
+ updateBranchMetadata,
511
+ getBranchMetadata,
512
+ getBranchStats,
513
+ getGitBranchesMapping,
514
+ addGitBranchesEntry,
515
+ removeGitBranchesEntry,
516
+ resolveBranch
517
+ },
518
+ migrations: {
519
+ getBranchMigrationHistory,
520
+ getBranchMigrationPlan,
521
+ executeBranchMigrationPlan,
522
+ getBranchSchemaHistory,
523
+ compareBranchWithUserSchema,
524
+ compareBranchSchemas,
525
+ updateBranchSchema,
526
+ previewBranchSchemaEdit,
527
+ applyBranchSchemaEdit
528
+ },
529
+ migrationRequests: {
530
+ queryMigrationRequests,
531
+ createMigrationRequest,
532
+ getMigrationRequest,
533
+ updateMigrationRequest,
534
+ listMigrationRequestsCommits,
535
+ compareMigrationRequest,
536
+ getMigrationRequestIsMerged,
537
+ mergeMigrationRequest
538
+ },
539
+ table: {
540
+ createTable,
541
+ deleteTable,
542
+ updateTable,
543
+ getTableSchema,
544
+ setTableSchema,
545
+ getTableColumns,
546
+ addTableColumn,
547
+ getColumn,
548
+ updateColumn,
549
+ deleteColumn
550
+ },
551
+ records: {
552
+ insertRecord,
553
+ getRecord,
554
+ insertRecordWithID,
555
+ updateRecordWithID,
556
+ upsertRecordWithID,
557
+ deleteRecord,
558
+ bulkInsertTableRecords
559
+ },
560
+ searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
561
+ };
562
+
563
+ const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
564
+
565
+ const getUser = (variables, signal) => controlPlaneFetch({
566
+ url: "/user",
509
567
  method: "get",
510
568
  ...variables,
511
569
  signal
512
570
  });
513
- const createTable = (variables, signal) => fetch$1({
514
- url: "/db/{dbBranchName}/tables/{tableName}",
571
+ const updateUser = (variables, signal) => controlPlaneFetch({
572
+ url: "/user",
515
573
  method: "put",
516
574
  ...variables,
517
575
  signal
518
576
  });
519
- const deleteTable = (variables, signal) => fetch$1({
520
- url: "/db/{dbBranchName}/tables/{tableName}",
577
+ const deleteUser = (variables, signal) => controlPlaneFetch({
578
+ url: "/user",
521
579
  method: "delete",
522
580
  ...variables,
523
581
  signal
524
582
  });
525
- const updateTable = (variables, signal) => fetch$1({
526
- url: "/db/{dbBranchName}/tables/{tableName}",
527
- method: "patch",
528
- ...variables,
529
- signal
530
- });
531
- const getTableSchema = (variables, signal) => fetch$1({
532
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
533
- method: "get",
534
- ...variables,
535
- signal
536
- });
537
- const setTableSchema = (variables, signal) => fetch$1({
538
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
539
- method: "put",
540
- ...variables,
541
- signal
542
- });
543
- const getTableColumns = (variables, signal) => fetch$1({
544
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
583
+ const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
584
+ url: "/user/keys",
545
585
  method: "get",
546
586
  ...variables,
547
587
  signal
548
588
  });
549
- const addTableColumn = (variables, signal) => fetch$1({
550
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
589
+ const createUserAPIKey = (variables, signal) => controlPlaneFetch({
590
+ url: "/user/keys/{keyName}",
551
591
  method: "post",
552
592
  ...variables,
553
593
  signal
554
594
  });
555
- const getColumn = (variables, signal) => fetch$1({
556
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
557
- method: "get",
558
- ...variables,
559
- signal
560
- });
561
- const deleteColumn = (variables, signal) => fetch$1({
562
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
563
- method: "delete",
564
- ...variables,
565
- signal
566
- });
567
- const updateColumn = (variables, signal) => fetch$1({
568
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
569
- method: "patch",
570
- ...variables,
571
- signal
572
- });
573
- const insertRecord = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
574
- const insertRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
575
- const updateRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
576
- const upsertRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
577
- const deleteRecord = (variables, signal) => fetch$1({
578
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
595
+ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
596
+ url: "/user/keys/{keyName}",
579
597
  method: "delete",
580
598
  ...variables,
581
599
  signal
582
600
  });
583
- const getRecord = (variables, signal) => fetch$1({
584
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
601
+ const getWorkspacesList = (variables, signal) => controlPlaneFetch({
602
+ url: "/workspaces",
585
603
  method: "get",
586
604
  ...variables,
587
605
  signal
588
606
  });
589
- const bulkInsertTableRecords = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
590
- const queryTable = (variables, signal) => fetch$1({
591
- url: "/db/{dbBranchName}/tables/{tableName}/query",
607
+ const createWorkspace = (variables, signal) => controlPlaneFetch({
608
+ url: "/workspaces",
592
609
  method: "post",
593
610
  ...variables,
594
611
  signal
595
612
  });
596
- const searchTable = (variables, signal) => fetch$1({
597
- url: "/db/{dbBranchName}/tables/{tableName}/search",
598
- method: "post",
613
+ const getWorkspace = (variables, signal) => controlPlaneFetch({
614
+ url: "/workspaces/{workspaceId}",
615
+ method: "get",
599
616
  ...variables,
600
617
  signal
601
618
  });
602
- const searchBranch = (variables, signal) => fetch$1({
603
- url: "/db/{dbBranchName}/search",
604
- method: "post",
619
+ const updateWorkspace = (variables, signal) => controlPlaneFetch({
620
+ url: "/workspaces/{workspaceId}",
621
+ method: "put",
605
622
  ...variables,
606
623
  signal
607
624
  });
608
- const summarizeTable = (variables, signal) => fetch$1({
609
- url: "/db/{dbBranchName}/tables/{tableName}/summarize",
610
- method: "post",
625
+ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
626
+ url: "/workspaces/{workspaceId}",
627
+ method: "delete",
611
628
  ...variables,
612
629
  signal
613
630
  });
614
- const aggregateTable = (variables, signal) => fetch$1({
615
- url: "/db/{dbBranchName}/tables/{tableName}/aggregate",
616
- method: "post",
631
+ const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
632
+ const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
633
+ const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
634
+ url: "/workspaces/{workspaceId}/members/{userId}",
635
+ method: "delete",
617
636
  ...variables,
618
637
  signal
619
638
  });
620
- const cPGetDatabaseList = (variables, signal) => fetch$1({
621
- url: "/workspaces/{workspaceId}/dbs",
622
- method: "get",
639
+ const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
640
+ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
641
+ const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
642
+ const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
643
+ const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
644
+ const cPGetDatabaseList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs", method: "get", ...variables, signal });
645
+ const cPCreateDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
646
+ const cPDeleteDatabase = (variables, signal) => controlPlaneFetch({
647
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
648
+ method: "delete",
623
649
  ...variables,
624
650
  signal
625
651
  });
626
- const cPCreateDatabase = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
627
- const cPDeleteDatabase = (variables, signal) => fetch$1({
628
- url: "/workspaces/{workspaceId}/dbs/{dbName}",
629
- method: "delete",
652
+ const cPGetCPDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
653
+ const cPUpdateCPDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
654
+ const listRegions = (variables, signal) => controlPlaneFetch({
655
+ url: "/workspaces/{workspaceId}/regions",
656
+ method: "get",
630
657
  ...variables,
631
658
  signal
632
659
  });
633
- const cPGetCPDatabaseMetadata = (variables, signal) => fetch$1(
634
- { url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "get", ...variables, signal }
635
- );
636
- const cPUpdateCPDatabaseMetadata = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
637
- const operationsByTag = {
638
- users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
660
+ const operationsByTag$1 = {
661
+ users: { getUser, updateUser, deleteUser },
662
+ authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
639
663
  workspaces: {
640
- createWorkspace,
641
664
  getWorkspacesList,
665
+ createWorkspace,
642
666
  getWorkspace,
643
667
  updateWorkspace,
644
668
  deleteWorkspace,
645
669
  getWorkspaceMembersList,
646
670
  updateWorkspaceMemberRole,
647
- removeWorkspaceMember,
671
+ removeWorkspaceMember
672
+ },
673
+ invites: {
648
674
  inviteWorkspaceMember,
649
675
  updateWorkspaceMemberInvite,
650
676
  cancelWorkspaceMemberInvite,
651
- resendWorkspaceMemberInvite,
652
- acceptWorkspaceMemberInvite
653
- },
654
- database: {
655
- getDatabaseList,
656
- createDatabase,
657
- deleteDatabase,
658
- getDatabaseMetadata,
659
- updateDatabaseMetadata,
660
- getGitBranchesMapping,
661
- addGitBranchesEntry,
662
- removeGitBranchesEntry,
663
- resolveBranch
664
- },
665
- branch: {
666
- getBranchList,
667
- getBranchDetails,
668
- createBranch,
669
- deleteBranch,
670
- updateBranchMetadata,
671
- getBranchMetadata,
672
- getBranchStats
673
- },
674
- migrationRequests: {
675
- queryMigrationRequests,
676
- createMigrationRequest,
677
- getMigrationRequest,
678
- updateMigrationRequest,
679
- listMigrationRequestsCommits,
680
- compareMigrationRequest,
681
- getMigrationRequestIsMerged,
682
- mergeMigrationRequest
683
- },
684
- branchSchema: {
685
- getBranchMigrationHistory,
686
- executeBranchMigrationPlan,
687
- getBranchMigrationPlan,
688
- compareBranchWithUserSchema,
689
- compareBranchSchemas,
690
- updateBranchSchema,
691
- previewBranchSchemaEdit,
692
- applyBranchSchemaEdit,
693
- getBranchSchemaHistory
694
- },
695
- table: {
696
- createTable,
697
- deleteTable,
698
- updateTable,
699
- getTableSchema,
700
- setTableSchema,
701
- getTableColumns,
702
- addTableColumn,
703
- getColumn,
704
- deleteColumn,
705
- updateColumn
706
- },
707
- records: {
708
- insertRecord,
709
- insertRecordWithID,
710
- updateRecordWithID,
711
- upsertRecordWithID,
712
- deleteRecord,
713
- getRecord,
714
- bulkInsertTableRecords,
715
- queryTable,
716
- searchTable,
717
- searchBranch,
718
- summarizeTable,
719
- aggregateTable
677
+ acceptWorkspaceMemberInvite,
678
+ resendWorkspaceMemberInvite
720
679
  },
721
680
  databases: {
722
681
  cPGetDatabaseList,
723
682
  cPCreateDatabase,
724
683
  cPDeleteDatabase,
725
684
  cPGetCPDatabaseMetadata,
726
- cPUpdateCPDatabaseMetadata
685
+ cPUpdateCPDatabaseMetadata,
686
+ listRegions
727
687
  }
728
688
  };
729
689
 
690
+ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
691
+
730
692
  function getHostUrl(provider, type) {
731
693
  if (isHostProviderAlias(provider)) {
732
694
  return providers[provider][type];
@@ -738,11 +700,11 @@ function getHostUrl(provider, type) {
738
700
  const providers = {
739
701
  production: {
740
702
  main: "https://api.xata.io",
741
- workspaces: "https://{workspaceId}.xata.sh"
703
+ workspaces: "https://{workspaceId}.{region}.xata.sh"
742
704
  },
743
705
  staging: {
744
706
  main: "https://staging.xatabase.co",
745
- workspaces: "https://{workspaceId}.staging.xatabase.co"
707
+ workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
746
708
  }
747
709
  };
748
710
  function isHostProviderAlias(alias) {
@@ -758,7 +720,17 @@ function parseProviderString(provider = "production") {
758
720
  const [main, workspaces] = provider.split(",");
759
721
  if (!main || !workspaces)
760
722
  return null;
761
- return { main, workspaces };
723
+ return { main, workspaces };
724
+ }
725
+ function parseWorkspacesUrlParts(url) {
726
+ if (!isString(url))
727
+ return null;
728
+ const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
729
+ const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
730
+ const match = url.match(regex) || url.match(regexStaging);
731
+ if (!match)
732
+ return null;
733
+ return { workspace: match[1], region: match[2] ?? "eu-west-1" };
762
734
  }
763
735
 
764
736
  var __accessCheck$7 = (obj, member, msg) => {
@@ -803,21 +775,41 @@ class XataApiClient {
803
775
  __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
804
776
  return __privateGet$7(this, _namespaces).user;
805
777
  }
778
+ get authentication() {
779
+ if (!__privateGet$7(this, _namespaces).authentication)
780
+ __privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
781
+ return __privateGet$7(this, _namespaces).authentication;
782
+ }
806
783
  get workspaces() {
807
784
  if (!__privateGet$7(this, _namespaces).workspaces)
808
785
  __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
809
786
  return __privateGet$7(this, _namespaces).workspaces;
810
787
  }
811
- get databases() {
812
- if (!__privateGet$7(this, _namespaces).databases)
813
- __privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
814
- return __privateGet$7(this, _namespaces).databases;
788
+ get invites() {
789
+ if (!__privateGet$7(this, _namespaces).invites)
790
+ __privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
791
+ return __privateGet$7(this, _namespaces).invites;
792
+ }
793
+ get database() {
794
+ if (!__privateGet$7(this, _namespaces).database)
795
+ __privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
796
+ return __privateGet$7(this, _namespaces).database;
815
797
  }
816
798
  get branches() {
817
799
  if (!__privateGet$7(this, _namespaces).branches)
818
800
  __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
819
801
  return __privateGet$7(this, _namespaces).branches;
820
802
  }
803
+ get migrations() {
804
+ if (!__privateGet$7(this, _namespaces).migrations)
805
+ __privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
806
+ return __privateGet$7(this, _namespaces).migrations;
807
+ }
808
+ get migrationRequests() {
809
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
810
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
811
+ return __privateGet$7(this, _namespaces).migrationRequests;
812
+ }
821
813
  get tables() {
822
814
  if (!__privateGet$7(this, _namespaces).tables)
823
815
  __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
@@ -828,15 +820,10 @@ class XataApiClient {
828
820
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
829
821
  return __privateGet$7(this, _namespaces).records;
830
822
  }
831
- get migrationRequests() {
832
- if (!__privateGet$7(this, _namespaces).migrationRequests)
833
- __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
834
- return __privateGet$7(this, _namespaces).migrationRequests;
835
- }
836
- get branchSchema() {
837
- if (!__privateGet$7(this, _namespaces).branchSchema)
838
- __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
839
- return __privateGet$7(this, _namespaces).branchSchema;
823
+ get searchAndFilter() {
824
+ if (!__privateGet$7(this, _namespaces).searchAndFilter)
825
+ __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
826
+ return __privateGet$7(this, _namespaces).searchAndFilter;
840
827
  }
841
828
  }
842
829
  _extraProps = new WeakMap();
@@ -848,24 +835,29 @@ class UserApi {
848
835
  getUser() {
849
836
  return operationsByTag.users.getUser({ ...this.extraProps });
850
837
  }
851
- updateUser(user) {
838
+ updateUser({ user }) {
852
839
  return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
853
840
  }
854
841
  deleteUser() {
855
842
  return operationsByTag.users.deleteUser({ ...this.extraProps });
856
843
  }
844
+ }
845
+ class AuthenticationApi {
846
+ constructor(extraProps) {
847
+ this.extraProps = extraProps;
848
+ }
857
849
  getUserAPIKeys() {
858
- return operationsByTag.users.getUserAPIKeys({ ...this.extraProps });
850
+ return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
859
851
  }
860
- createUserAPIKey(keyName) {
861
- return operationsByTag.users.createUserAPIKey({
862
- pathParams: { keyName },
852
+ createUserAPIKey({ name }) {
853
+ return operationsByTag.authentication.createUserAPIKey({
854
+ pathParams: { keyName: name },
863
855
  ...this.extraProps
864
856
  });
865
857
  }
866
- deleteUserAPIKey(keyName) {
867
- return operationsByTag.users.deleteUserAPIKey({
868
- pathParams: { keyName },
858
+ deleteUserAPIKey({ name }) {
859
+ return operationsByTag.authentication.deleteUserAPIKey({
860
+ pathParams: { keyName: name },
869
861
  ...this.extraProps
870
862
  });
871
863
  }
@@ -874,196 +866,248 @@ class WorkspaceApi {
874
866
  constructor(extraProps) {
875
867
  this.extraProps = extraProps;
876
868
  }
877
- createWorkspace(workspaceMeta) {
869
+ getWorkspacesList() {
870
+ return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
871
+ }
872
+ createWorkspace({ data }) {
878
873
  return operationsByTag.workspaces.createWorkspace({
879
- body: workspaceMeta,
874
+ body: data,
880
875
  ...this.extraProps
881
876
  });
882
877
  }
883
- getWorkspacesList() {
884
- return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
885
- }
886
- getWorkspace(workspaceId) {
878
+ getWorkspace({ workspace }) {
887
879
  return operationsByTag.workspaces.getWorkspace({
888
- pathParams: { workspaceId },
880
+ pathParams: { workspaceId: workspace },
889
881
  ...this.extraProps
890
882
  });
891
883
  }
892
- updateWorkspace(workspaceId, workspaceMeta) {
884
+ updateWorkspace({
885
+ workspace,
886
+ update
887
+ }) {
893
888
  return operationsByTag.workspaces.updateWorkspace({
894
- pathParams: { workspaceId },
895
- body: workspaceMeta,
889
+ pathParams: { workspaceId: workspace },
890
+ body: update,
896
891
  ...this.extraProps
897
892
  });
898
893
  }
899
- deleteWorkspace(workspaceId) {
894
+ deleteWorkspace({ workspace }) {
900
895
  return operationsByTag.workspaces.deleteWorkspace({
901
- pathParams: { workspaceId },
896
+ pathParams: { workspaceId: workspace },
902
897
  ...this.extraProps
903
898
  });
904
899
  }
905
- getWorkspaceMembersList(workspaceId) {
900
+ getWorkspaceMembersList({ workspace }) {
906
901
  return operationsByTag.workspaces.getWorkspaceMembersList({
907
- pathParams: { workspaceId },
902
+ pathParams: { workspaceId: workspace },
908
903
  ...this.extraProps
909
904
  });
910
905
  }
911
- updateWorkspaceMemberRole(workspaceId, userId, role) {
906
+ updateWorkspaceMemberRole({
907
+ workspace,
908
+ user,
909
+ role
910
+ }) {
912
911
  return operationsByTag.workspaces.updateWorkspaceMemberRole({
913
- pathParams: { workspaceId, userId },
912
+ pathParams: { workspaceId: workspace, userId: user },
914
913
  body: { role },
915
914
  ...this.extraProps
916
915
  });
917
916
  }
918
- removeWorkspaceMember(workspaceId, userId) {
917
+ removeWorkspaceMember({
918
+ workspace,
919
+ user
920
+ }) {
919
921
  return operationsByTag.workspaces.removeWorkspaceMember({
920
- pathParams: { workspaceId, userId },
922
+ pathParams: { workspaceId: workspace, userId: user },
921
923
  ...this.extraProps
922
924
  });
923
925
  }
924
- inviteWorkspaceMember(workspaceId, email, role) {
925
- return operationsByTag.workspaces.inviteWorkspaceMember({
926
- pathParams: { workspaceId },
926
+ }
927
+ class InvitesApi {
928
+ constructor(extraProps) {
929
+ this.extraProps = extraProps;
930
+ }
931
+ inviteWorkspaceMember({
932
+ workspace,
933
+ email,
934
+ role
935
+ }) {
936
+ return operationsByTag.invites.inviteWorkspaceMember({
937
+ pathParams: { workspaceId: workspace },
927
938
  body: { email, role },
928
939
  ...this.extraProps
929
940
  });
930
941
  }
931
- updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
932
- return operationsByTag.workspaces.updateWorkspaceMemberInvite({
933
- pathParams: { workspaceId, inviteId },
942
+ updateWorkspaceMemberInvite({
943
+ workspace,
944
+ invite,
945
+ role
946
+ }) {
947
+ return operationsByTag.invites.updateWorkspaceMemberInvite({
948
+ pathParams: { workspaceId: workspace, inviteId: invite },
934
949
  body: { role },
935
950
  ...this.extraProps
936
951
  });
937
952
  }
938
- cancelWorkspaceMemberInvite(workspaceId, inviteId) {
939
- return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
940
- pathParams: { workspaceId, inviteId },
953
+ cancelWorkspaceMemberInvite({
954
+ workspace,
955
+ invite
956
+ }) {
957
+ return operationsByTag.invites.cancelWorkspaceMemberInvite({
958
+ pathParams: { workspaceId: workspace, inviteId: invite },
941
959
  ...this.extraProps
942
960
  });
943
961
  }
944
- resendWorkspaceMemberInvite(workspaceId, inviteId) {
945
- return operationsByTag.workspaces.resendWorkspaceMemberInvite({
946
- pathParams: { workspaceId, inviteId },
962
+ acceptWorkspaceMemberInvite({
963
+ workspace,
964
+ key
965
+ }) {
966
+ return operationsByTag.invites.acceptWorkspaceMemberInvite({
967
+ pathParams: { workspaceId: workspace, inviteKey: key },
947
968
  ...this.extraProps
948
969
  });
949
970
  }
950
- acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
951
- return operationsByTag.workspaces.acceptWorkspaceMemberInvite({
952
- pathParams: { workspaceId, inviteKey },
971
+ resendWorkspaceMemberInvite({
972
+ workspace,
973
+ invite
974
+ }) {
975
+ return operationsByTag.invites.resendWorkspaceMemberInvite({
976
+ pathParams: { workspaceId: workspace, inviteId: invite },
953
977
  ...this.extraProps
954
978
  });
955
979
  }
956
980
  }
957
- class DatabaseApi {
981
+ class BranchApi {
958
982
  constructor(extraProps) {
959
983
  this.extraProps = extraProps;
960
984
  }
961
- getDatabaseList(workspace) {
962
- return operationsByTag.database.getDatabaseList({
963
- pathParams: { workspace },
964
- ...this.extraProps
965
- });
966
- }
967
- createDatabase(workspace, dbName, options = {}) {
968
- return operationsByTag.database.createDatabase({
969
- pathParams: { workspace, dbName },
970
- body: options,
971
- ...this.extraProps
972
- });
973
- }
974
- deleteDatabase(workspace, dbName) {
975
- return operationsByTag.database.deleteDatabase({
976
- pathParams: { workspace, dbName },
977
- ...this.extraProps
978
- });
979
- }
980
- getDatabaseMetadata(workspace, dbName) {
981
- return operationsByTag.database.getDatabaseMetadata({
982
- pathParams: { workspace, dbName },
983
- ...this.extraProps
984
- });
985
- }
986
- updateDatabaseMetadata(workspace, dbName, options = {}) {
987
- return operationsByTag.database.updateDatabaseMetadata({
988
- pathParams: { workspace, dbName },
989
- body: options,
990
- ...this.extraProps
991
- });
992
- }
993
- getGitBranchesMapping(workspace, dbName) {
994
- return operationsByTag.database.getGitBranchesMapping({
995
- pathParams: { workspace, dbName },
985
+ getBranchList({
986
+ workspace,
987
+ region,
988
+ database
989
+ }) {
990
+ return operationsByTag.branch.getBranchList({
991
+ pathParams: { workspace, region, dbName: database },
996
992
  ...this.extraProps
997
993
  });
998
994
  }
999
- addGitBranchesEntry(workspace, dbName, body) {
1000
- return operationsByTag.database.addGitBranchesEntry({
1001
- pathParams: { workspace, dbName },
1002
- body,
995
+ getBranchDetails({
996
+ workspace,
997
+ region,
998
+ database,
999
+ branch
1000
+ }) {
1001
+ return operationsByTag.branch.getBranchDetails({
1002
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1003
1003
  ...this.extraProps
1004
1004
  });
1005
1005
  }
1006
- removeGitBranchesEntry(workspace, dbName, gitBranch) {
1007
- return operationsByTag.database.removeGitBranchesEntry({
1008
- pathParams: { workspace, dbName },
1009
- queryParams: { gitBranch },
1006
+ createBranch({
1007
+ workspace,
1008
+ region,
1009
+ database,
1010
+ branch,
1011
+ from,
1012
+ metadata
1013
+ }) {
1014
+ return operationsByTag.branch.createBranch({
1015
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1016
+ body: { from, metadata },
1010
1017
  ...this.extraProps
1011
1018
  });
1012
1019
  }
1013
- resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
1014
- return operationsByTag.database.resolveBranch({
1015
- pathParams: { workspace, dbName },
1016
- queryParams: { gitBranch, fallbackBranch },
1020
+ deleteBranch({
1021
+ workspace,
1022
+ region,
1023
+ database,
1024
+ branch
1025
+ }) {
1026
+ return operationsByTag.branch.deleteBranch({
1027
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1017
1028
  ...this.extraProps
1018
1029
  });
1019
1030
  }
1020
- }
1021
- class BranchApi {
1022
- constructor(extraProps) {
1023
- this.extraProps = extraProps;
1024
- }
1025
- getBranchList(workspace, dbName) {
1026
- return operationsByTag.branch.getBranchList({
1027
- pathParams: { workspace, dbName },
1031
+ updateBranchMetadata({
1032
+ workspace,
1033
+ region,
1034
+ database,
1035
+ branch,
1036
+ metadata
1037
+ }) {
1038
+ return operationsByTag.branch.updateBranchMetadata({
1039
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1040
+ body: metadata,
1028
1041
  ...this.extraProps
1029
1042
  });
1030
1043
  }
1031
- getBranchDetails(workspace, database, branch) {
1032
- return operationsByTag.branch.getBranchDetails({
1033
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1044
+ getBranchMetadata({
1045
+ workspace,
1046
+ region,
1047
+ database,
1048
+ branch
1049
+ }) {
1050
+ return operationsByTag.branch.getBranchMetadata({
1051
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1034
1052
  ...this.extraProps
1035
1053
  });
1036
1054
  }
1037
- createBranch(workspace, database, branch, from, options = {}) {
1038
- return operationsByTag.branch.createBranch({
1039
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1040
- queryParams: isString(from) ? { from } : void 0,
1041
- body: options,
1055
+ getBranchStats({
1056
+ workspace,
1057
+ region,
1058
+ database,
1059
+ branch
1060
+ }) {
1061
+ return operationsByTag.branch.getBranchStats({
1062
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1042
1063
  ...this.extraProps
1043
1064
  });
1044
1065
  }
1045
- deleteBranch(workspace, database, branch) {
1046
- return operationsByTag.branch.deleteBranch({
1047
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1066
+ getGitBranchesMapping({
1067
+ workspace,
1068
+ region,
1069
+ database
1070
+ }) {
1071
+ return operationsByTag.branch.getGitBranchesMapping({
1072
+ pathParams: { workspace, region, dbName: database },
1048
1073
  ...this.extraProps
1049
1074
  });
1050
1075
  }
1051
- updateBranchMetadata(workspace, database, branch, metadata = {}) {
1052
- return operationsByTag.branch.updateBranchMetadata({
1053
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1054
- body: metadata,
1076
+ addGitBranchesEntry({
1077
+ workspace,
1078
+ region,
1079
+ database,
1080
+ gitBranch,
1081
+ xataBranch
1082
+ }) {
1083
+ return operationsByTag.branch.addGitBranchesEntry({
1084
+ pathParams: { workspace, region, dbName: database },
1085
+ body: { gitBranch, xataBranch },
1055
1086
  ...this.extraProps
1056
1087
  });
1057
1088
  }
1058
- getBranchMetadata(workspace, database, branch) {
1059
- return operationsByTag.branch.getBranchMetadata({
1060
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1089
+ removeGitBranchesEntry({
1090
+ workspace,
1091
+ region,
1092
+ database,
1093
+ gitBranch
1094
+ }) {
1095
+ return operationsByTag.branch.removeGitBranchesEntry({
1096
+ pathParams: { workspace, region, dbName: database },
1097
+ queryParams: { gitBranch },
1061
1098
  ...this.extraProps
1062
1099
  });
1063
1100
  }
1064
- getBranchStats(workspace, database, branch) {
1065
- return operationsByTag.branch.getBranchStats({
1066
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1101
+ resolveBranch({
1102
+ workspace,
1103
+ region,
1104
+ database,
1105
+ gitBranch,
1106
+ fallbackBranch
1107
+ }) {
1108
+ return operationsByTag.branch.resolveBranch({
1109
+ pathParams: { workspace, region, dbName: database },
1110
+ queryParams: { gitBranch, fallbackBranch },
1067
1111
  ...this.extraProps
1068
1112
  });
1069
1113
  }
@@ -1072,67 +1116,134 @@ class TableApi {
1072
1116
  constructor(extraProps) {
1073
1117
  this.extraProps = extraProps;
1074
1118
  }
1075
- createTable(workspace, database, branch, tableName) {
1119
+ createTable({
1120
+ workspace,
1121
+ region,
1122
+ database,
1123
+ branch,
1124
+ table
1125
+ }) {
1076
1126
  return operationsByTag.table.createTable({
1077
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1127
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1078
1128
  ...this.extraProps
1079
1129
  });
1080
1130
  }
1081
- deleteTable(workspace, database, branch, tableName) {
1131
+ deleteTable({
1132
+ workspace,
1133
+ region,
1134
+ database,
1135
+ branch,
1136
+ table
1137
+ }) {
1082
1138
  return operationsByTag.table.deleteTable({
1083
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1139
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1084
1140
  ...this.extraProps
1085
1141
  });
1086
1142
  }
1087
- updateTable(workspace, database, branch, tableName, options) {
1143
+ updateTable({
1144
+ workspace,
1145
+ region,
1146
+ database,
1147
+ branch,
1148
+ table,
1149
+ update
1150
+ }) {
1088
1151
  return operationsByTag.table.updateTable({
1089
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1090
- body: options,
1152
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1153
+ body: update,
1091
1154
  ...this.extraProps
1092
1155
  });
1093
1156
  }
1094
- getTableSchema(workspace, database, branch, tableName) {
1157
+ getTableSchema({
1158
+ workspace,
1159
+ region,
1160
+ database,
1161
+ branch,
1162
+ table
1163
+ }) {
1095
1164
  return operationsByTag.table.getTableSchema({
1096
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1165
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1097
1166
  ...this.extraProps
1098
1167
  });
1099
1168
  }
1100
- setTableSchema(workspace, database, branch, tableName, options) {
1169
+ setTableSchema({
1170
+ workspace,
1171
+ region,
1172
+ database,
1173
+ branch,
1174
+ table,
1175
+ schema
1176
+ }) {
1101
1177
  return operationsByTag.table.setTableSchema({
1102
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1103
- body: options,
1178
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1179
+ body: schema,
1104
1180
  ...this.extraProps
1105
1181
  });
1106
1182
  }
1107
- getTableColumns(workspace, database, branch, tableName) {
1183
+ getTableColumns({
1184
+ workspace,
1185
+ region,
1186
+ database,
1187
+ branch,
1188
+ table
1189
+ }) {
1108
1190
  return operationsByTag.table.getTableColumns({
1109
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1191
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1110
1192
  ...this.extraProps
1111
1193
  });
1112
1194
  }
1113
- addTableColumn(workspace, database, branch, tableName, column) {
1195
+ addTableColumn({
1196
+ workspace,
1197
+ region,
1198
+ database,
1199
+ branch,
1200
+ table,
1201
+ column
1202
+ }) {
1114
1203
  return operationsByTag.table.addTableColumn({
1115
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1204
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1116
1205
  body: column,
1117
1206
  ...this.extraProps
1118
1207
  });
1119
1208
  }
1120
- getColumn(workspace, database, branch, tableName, columnName) {
1209
+ getColumn({
1210
+ workspace,
1211
+ region,
1212
+ database,
1213
+ branch,
1214
+ table,
1215
+ column
1216
+ }) {
1121
1217
  return operationsByTag.table.getColumn({
1122
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1218
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1123
1219
  ...this.extraProps
1124
1220
  });
1125
1221
  }
1126
- deleteColumn(workspace, database, branch, tableName, columnName) {
1127
- return operationsByTag.table.deleteColumn({
1128
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1222
+ updateColumn({
1223
+ workspace,
1224
+ region,
1225
+ database,
1226
+ branch,
1227
+ table,
1228
+ column,
1229
+ update
1230
+ }) {
1231
+ return operationsByTag.table.updateColumn({
1232
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1233
+ body: update,
1129
1234
  ...this.extraProps
1130
1235
  });
1131
1236
  }
1132
- updateColumn(workspace, database, branch, tableName, columnName, options) {
1133
- return operationsByTag.table.updateColumn({
1134
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1135
- body: options,
1237
+ deleteColumn({
1238
+ workspace,
1239
+ region,
1240
+ database,
1241
+ branch,
1242
+ table,
1243
+ column
1244
+ }) {
1245
+ return operationsByTag.table.deleteColumn({
1246
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1136
1247
  ...this.extraProps
1137
1248
  });
1138
1249
  }
@@ -1141,92 +1252,213 @@ class RecordsApi {
1141
1252
  constructor(extraProps) {
1142
1253
  this.extraProps = extraProps;
1143
1254
  }
1144
- insertRecord(workspace, database, branch, tableName, record, options = {}) {
1255
+ insertRecord({
1256
+ workspace,
1257
+ region,
1258
+ database,
1259
+ branch,
1260
+ table,
1261
+ record,
1262
+ columns
1263
+ }) {
1145
1264
  return operationsByTag.records.insertRecord({
1146
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1147
- queryParams: options,
1265
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1266
+ queryParams: { columns },
1148
1267
  body: record,
1149
1268
  ...this.extraProps
1150
1269
  });
1151
1270
  }
1152
- insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1271
+ getRecord({
1272
+ workspace,
1273
+ region,
1274
+ database,
1275
+ branch,
1276
+ table,
1277
+ id,
1278
+ columns
1279
+ }) {
1280
+ return operationsByTag.records.getRecord({
1281
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1282
+ queryParams: { columns },
1283
+ ...this.extraProps
1284
+ });
1285
+ }
1286
+ insertRecordWithID({
1287
+ workspace,
1288
+ region,
1289
+ database,
1290
+ branch,
1291
+ table,
1292
+ id,
1293
+ record,
1294
+ columns,
1295
+ createOnly,
1296
+ ifVersion
1297
+ }) {
1153
1298
  return operationsByTag.records.insertRecordWithID({
1154
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1155
- queryParams: options,
1299
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1300
+ queryParams: { columns, createOnly, ifVersion },
1156
1301
  body: record,
1157
1302
  ...this.extraProps
1158
1303
  });
1159
1304
  }
1160
- updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1305
+ updateRecordWithID({
1306
+ workspace,
1307
+ region,
1308
+ database,
1309
+ branch,
1310
+ table,
1311
+ id,
1312
+ record,
1313
+ columns,
1314
+ ifVersion
1315
+ }) {
1161
1316
  return operationsByTag.records.updateRecordWithID({
1162
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1163
- queryParams: options,
1317
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1318
+ queryParams: { columns, ifVersion },
1164
1319
  body: record,
1165
1320
  ...this.extraProps
1166
1321
  });
1167
1322
  }
1168
- upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1323
+ upsertRecordWithID({
1324
+ workspace,
1325
+ region,
1326
+ database,
1327
+ branch,
1328
+ table,
1329
+ id,
1330
+ record,
1331
+ columns,
1332
+ ifVersion
1333
+ }) {
1169
1334
  return operationsByTag.records.upsertRecordWithID({
1170
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1171
- queryParams: options,
1335
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1336
+ queryParams: { columns, ifVersion },
1172
1337
  body: record,
1173
1338
  ...this.extraProps
1174
1339
  });
1175
1340
  }
1176
- deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
1341
+ deleteRecord({
1342
+ workspace,
1343
+ region,
1344
+ database,
1345
+ branch,
1346
+ table,
1347
+ id,
1348
+ columns
1349
+ }) {
1177
1350
  return operationsByTag.records.deleteRecord({
1178
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1179
- queryParams: options,
1180
- ...this.extraProps
1181
- });
1182
- }
1183
- getRecord(workspace, database, branch, tableName, recordId, options = {}) {
1184
- return operationsByTag.records.getRecord({
1185
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1186
- queryParams: options,
1351
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1352
+ queryParams: { columns },
1187
1353
  ...this.extraProps
1188
1354
  });
1189
1355
  }
1190
- bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
1356
+ bulkInsertTableRecords({
1357
+ workspace,
1358
+ region,
1359
+ database,
1360
+ branch,
1361
+ table,
1362
+ records,
1363
+ columns
1364
+ }) {
1191
1365
  return operationsByTag.records.bulkInsertTableRecords({
1192
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1193
- queryParams: options,
1366
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1367
+ queryParams: { columns },
1194
1368
  body: { records },
1195
1369
  ...this.extraProps
1196
1370
  });
1197
1371
  }
1198
- queryTable(workspace, database, branch, tableName, query) {
1199
- return operationsByTag.records.queryTable({
1200
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1201
- body: query,
1372
+ }
1373
+ class SearchAndFilterApi {
1374
+ constructor(extraProps) {
1375
+ this.extraProps = extraProps;
1376
+ }
1377
+ queryTable({
1378
+ workspace,
1379
+ region,
1380
+ database,
1381
+ branch,
1382
+ table,
1383
+ filter,
1384
+ sort,
1385
+ page,
1386
+ columns
1387
+ }) {
1388
+ return operationsByTag.searchAndFilter.queryTable({
1389
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1390
+ body: { filter, sort, page, columns },
1202
1391
  ...this.extraProps
1203
1392
  });
1204
1393
  }
1205
- searchTable(workspace, database, branch, tableName, query) {
1206
- return operationsByTag.records.searchTable({
1207
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1208
- body: query,
1394
+ searchTable({
1395
+ workspace,
1396
+ region,
1397
+ database,
1398
+ branch,
1399
+ table,
1400
+ query,
1401
+ fuzziness,
1402
+ target,
1403
+ prefix,
1404
+ filter,
1405
+ highlight,
1406
+ boosters
1407
+ }) {
1408
+ return operationsByTag.searchAndFilter.searchTable({
1409
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1410
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
1209
1411
  ...this.extraProps
1210
1412
  });
1211
1413
  }
1212
- searchBranch(workspace, database, branch, query) {
1213
- return operationsByTag.records.searchBranch({
1214
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1215
- body: query,
1414
+ searchBranch({
1415
+ workspace,
1416
+ region,
1417
+ database,
1418
+ branch,
1419
+ tables,
1420
+ query,
1421
+ fuzziness,
1422
+ prefix,
1423
+ highlight
1424
+ }) {
1425
+ return operationsByTag.searchAndFilter.searchBranch({
1426
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1427
+ body: { tables, query, fuzziness, prefix, highlight },
1216
1428
  ...this.extraProps
1217
1429
  });
1218
1430
  }
1219
- summarizeTable(workspace, database, branch, tableName, query) {
1220
- return operationsByTag.records.summarizeTable({
1221
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1222
- body: query,
1431
+ summarizeTable({
1432
+ workspace,
1433
+ region,
1434
+ database,
1435
+ branch,
1436
+ table,
1437
+ filter,
1438
+ columns,
1439
+ summaries,
1440
+ sort,
1441
+ summariesFilter,
1442
+ page
1443
+ }) {
1444
+ return operationsByTag.searchAndFilter.summarizeTable({
1445
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1446
+ body: { filter, columns, summaries, sort, summariesFilter, page },
1223
1447
  ...this.extraProps
1224
1448
  });
1225
1449
  }
1226
- aggregateTable(workspace, database, branch, tableName, query) {
1227
- return operationsByTag.records.aggregateTable({
1228
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1229
- body: query,
1450
+ aggregateTable({
1451
+ workspace,
1452
+ region,
1453
+ database,
1454
+ branch,
1455
+ table,
1456
+ filter,
1457
+ aggs
1458
+ }) {
1459
+ return operationsByTag.searchAndFilter.aggregateTable({
1460
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1461
+ body: { filter, aggs },
1230
1462
  ...this.extraProps
1231
1463
  });
1232
1464
  }
@@ -1235,123 +1467,281 @@ class MigrationRequestsApi {
1235
1467
  constructor(extraProps) {
1236
1468
  this.extraProps = extraProps;
1237
1469
  }
1238
- queryMigrationRequests(workspace, database, options = {}) {
1470
+ queryMigrationRequests({
1471
+ workspace,
1472
+ region,
1473
+ database,
1474
+ filter,
1475
+ sort,
1476
+ page,
1477
+ columns
1478
+ }) {
1239
1479
  return operationsByTag.migrationRequests.queryMigrationRequests({
1240
- pathParams: { workspace, dbName: database },
1241
- body: options,
1480
+ pathParams: { workspace, region, dbName: database },
1481
+ body: { filter, sort, page, columns },
1242
1482
  ...this.extraProps
1243
1483
  });
1244
1484
  }
1245
- createMigrationRequest(workspace, database, options) {
1485
+ createMigrationRequest({
1486
+ workspace,
1487
+ region,
1488
+ database,
1489
+ migration
1490
+ }) {
1246
1491
  return operationsByTag.migrationRequests.createMigrationRequest({
1247
- pathParams: { workspace, dbName: database },
1248
- body: options,
1492
+ pathParams: { workspace, region, dbName: database },
1493
+ body: migration,
1249
1494
  ...this.extraProps
1250
1495
  });
1251
1496
  }
1252
- getMigrationRequest(workspace, database, migrationRequest) {
1497
+ getMigrationRequest({
1498
+ workspace,
1499
+ region,
1500
+ database,
1501
+ migrationRequest
1502
+ }) {
1253
1503
  return operationsByTag.migrationRequests.getMigrationRequest({
1254
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1504
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1255
1505
  ...this.extraProps
1256
1506
  });
1257
1507
  }
1258
- updateMigrationRequest(workspace, database, migrationRequest, options) {
1508
+ updateMigrationRequest({
1509
+ workspace,
1510
+ region,
1511
+ database,
1512
+ migrationRequest,
1513
+ update
1514
+ }) {
1259
1515
  return operationsByTag.migrationRequests.updateMigrationRequest({
1260
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1261
- body: options,
1516
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1517
+ body: update,
1262
1518
  ...this.extraProps
1263
1519
  });
1264
1520
  }
1265
- listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1521
+ listMigrationRequestsCommits({
1522
+ workspace,
1523
+ region,
1524
+ database,
1525
+ migrationRequest,
1526
+ page
1527
+ }) {
1266
1528
  return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1267
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1268
- body: options,
1529
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1530
+ body: { page },
1269
1531
  ...this.extraProps
1270
1532
  });
1271
1533
  }
1272
- compareMigrationRequest(workspace, database, migrationRequest) {
1534
+ compareMigrationRequest({
1535
+ workspace,
1536
+ region,
1537
+ database,
1538
+ migrationRequest
1539
+ }) {
1273
1540
  return operationsByTag.migrationRequests.compareMigrationRequest({
1274
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1541
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1275
1542
  ...this.extraProps
1276
1543
  });
1277
1544
  }
1278
- getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1545
+ getMigrationRequestIsMerged({
1546
+ workspace,
1547
+ region,
1548
+ database,
1549
+ migrationRequest
1550
+ }) {
1279
1551
  return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1280
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1552
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1281
1553
  ...this.extraProps
1282
1554
  });
1283
1555
  }
1284
- mergeMigrationRequest(workspace, database, migrationRequest) {
1556
+ mergeMigrationRequest({
1557
+ workspace,
1558
+ region,
1559
+ database,
1560
+ migrationRequest
1561
+ }) {
1285
1562
  return operationsByTag.migrationRequests.mergeMigrationRequest({
1286
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1563
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1287
1564
  ...this.extraProps
1288
1565
  });
1289
1566
  }
1290
1567
  }
1291
- class BranchSchemaApi {
1568
+ class MigrationsApi {
1292
1569
  constructor(extraProps) {
1293
1570
  this.extraProps = extraProps;
1294
1571
  }
1295
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
1296
- return operationsByTag.branchSchema.getBranchMigrationHistory({
1297
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1298
- body: options,
1572
+ getBranchMigrationHistory({
1573
+ workspace,
1574
+ region,
1575
+ database,
1576
+ branch,
1577
+ limit,
1578
+ startFrom
1579
+ }) {
1580
+ return operationsByTag.migrations.getBranchMigrationHistory({
1581
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1582
+ body: { limit, startFrom },
1299
1583
  ...this.extraProps
1300
1584
  });
1301
1585
  }
1302
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1303
- return operationsByTag.branchSchema.executeBranchMigrationPlan({
1304
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1305
- body: migrationPlan,
1586
+ getBranchMigrationPlan({
1587
+ workspace,
1588
+ region,
1589
+ database,
1590
+ branch,
1591
+ schema
1592
+ }) {
1593
+ return operationsByTag.migrations.getBranchMigrationPlan({
1594
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1595
+ body: schema,
1306
1596
  ...this.extraProps
1307
1597
  });
1308
1598
  }
1309
- getBranchMigrationPlan(workspace, database, branch, schema) {
1310
- return operationsByTag.branchSchema.getBranchMigrationPlan({
1311
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1312
- body: schema,
1599
+ executeBranchMigrationPlan({
1600
+ workspace,
1601
+ region,
1602
+ database,
1603
+ branch,
1604
+ plan
1605
+ }) {
1606
+ return operationsByTag.migrations.executeBranchMigrationPlan({
1607
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1608
+ body: plan,
1609
+ ...this.extraProps
1610
+ });
1611
+ }
1612
+ getBranchSchemaHistory({
1613
+ workspace,
1614
+ region,
1615
+ database,
1616
+ branch,
1617
+ page
1618
+ }) {
1619
+ return operationsByTag.migrations.getBranchSchemaHistory({
1620
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1621
+ body: { page },
1313
1622
  ...this.extraProps
1314
1623
  });
1315
1624
  }
1316
- compareBranchWithUserSchema(workspace, database, branch, schema) {
1317
- return operationsByTag.branchSchema.compareBranchWithUserSchema({
1318
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1625
+ compareBranchWithUserSchema({
1626
+ workspace,
1627
+ region,
1628
+ database,
1629
+ branch,
1630
+ schema
1631
+ }) {
1632
+ return operationsByTag.migrations.compareBranchWithUserSchema({
1633
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1319
1634
  body: { schema },
1320
1635
  ...this.extraProps
1321
1636
  });
1322
1637
  }
1323
- compareBranchSchemas(workspace, database, branch, branchName, schema) {
1324
- return operationsByTag.branchSchema.compareBranchSchemas({
1325
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1638
+ compareBranchSchemas({
1639
+ workspace,
1640
+ region,
1641
+ database,
1642
+ branch,
1643
+ compare,
1644
+ schema
1645
+ }) {
1646
+ return operationsByTag.migrations.compareBranchSchemas({
1647
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
1326
1648
  body: { schema },
1327
1649
  ...this.extraProps
1328
1650
  });
1329
1651
  }
1330
- updateBranchSchema(workspace, database, branch, migration) {
1331
- return operationsByTag.branchSchema.updateBranchSchema({
1332
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1652
+ updateBranchSchema({
1653
+ workspace,
1654
+ region,
1655
+ database,
1656
+ branch,
1657
+ migration
1658
+ }) {
1659
+ return operationsByTag.migrations.updateBranchSchema({
1660
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1333
1661
  body: migration,
1334
1662
  ...this.extraProps
1335
1663
  });
1336
1664
  }
1337
- previewBranchSchemaEdit(workspace, database, branch, migration) {
1338
- return operationsByTag.branchSchema.previewBranchSchemaEdit({
1339
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1340
- body: migration,
1665
+ previewBranchSchemaEdit({
1666
+ workspace,
1667
+ region,
1668
+ database,
1669
+ branch,
1670
+ data
1671
+ }) {
1672
+ return operationsByTag.migrations.previewBranchSchemaEdit({
1673
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1674
+ body: data,
1341
1675
  ...this.extraProps
1342
1676
  });
1343
1677
  }
1344
- applyBranchSchemaEdit(workspace, database, branch, edits) {
1345
- return operationsByTag.branchSchema.applyBranchSchemaEdit({
1346
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1678
+ applyBranchSchemaEdit({
1679
+ workspace,
1680
+ region,
1681
+ database,
1682
+ branch,
1683
+ edits
1684
+ }) {
1685
+ return operationsByTag.migrations.applyBranchSchemaEdit({
1686
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1347
1687
  body: { edits },
1348
1688
  ...this.extraProps
1349
1689
  });
1350
1690
  }
1351
- getBranchSchemaHistory(workspace, database, branch, options = {}) {
1352
- return operationsByTag.branchSchema.getBranchSchemaHistory({
1353
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1354
- body: options,
1691
+ }
1692
+ class DatabaseApi {
1693
+ constructor(extraProps) {
1694
+ this.extraProps = extraProps;
1695
+ }
1696
+ getDatabaseList({ workspace }) {
1697
+ return operationsByTag.databases.cPGetDatabaseList({
1698
+ pathParams: { workspaceId: workspace },
1699
+ ...this.extraProps
1700
+ });
1701
+ }
1702
+ createDatabase({
1703
+ workspace,
1704
+ database,
1705
+ data
1706
+ }) {
1707
+ return operationsByTag.databases.cPCreateDatabase({
1708
+ pathParams: { workspaceId: workspace, dbName: database },
1709
+ body: data,
1710
+ ...this.extraProps
1711
+ });
1712
+ }
1713
+ deleteDatabase({
1714
+ workspace,
1715
+ database
1716
+ }) {
1717
+ return operationsByTag.databases.cPDeleteDatabase({
1718
+ pathParams: { workspaceId: workspace, dbName: database },
1719
+ ...this.extraProps
1720
+ });
1721
+ }
1722
+ getDatabaseMetadata({
1723
+ workspace,
1724
+ database
1725
+ }) {
1726
+ return operationsByTag.databases.cPGetCPDatabaseMetadata({
1727
+ pathParams: { workspaceId: workspace, dbName: database },
1728
+ ...this.extraProps
1729
+ });
1730
+ }
1731
+ updateDatabaseMetadata({
1732
+ workspace,
1733
+ database,
1734
+ metadata
1735
+ }) {
1736
+ return operationsByTag.databases.cPUpdateCPDatabaseMetadata({
1737
+ pathParams: { workspaceId: workspace, dbName: database },
1738
+ body: metadata,
1739
+ ...this.extraProps
1740
+ });
1741
+ }
1742
+ listRegions({ workspace }) {
1743
+ return operationsByTag.databases.listRegions({
1744
+ pathParams: { workspaceId: workspace },
1355
1745
  ...this.extraProps
1356
1746
  });
1357
1747
  }
@@ -1682,7 +2072,7 @@ cleanFilterConstraint_fn = function(column, value) {
1682
2072
  };
1683
2073
  function cleanParent(data, parent) {
1684
2074
  if (isCursorPaginationOptions(data.pagination)) {
1685
- return { ...parent, sorting: void 0, filter: void 0 };
2075
+ return { ...parent, sort: void 0, filter: void 0 };
1686
2076
  }
1687
2077
  return parent;
1688
2078
  }
@@ -1784,8 +2174,9 @@ class RestRepository extends Query {
1784
2174
  });
1785
2175
  });
1786
2176
  }
1787
- async create(a, b, c) {
2177
+ async create(a, b, c, d) {
1788
2178
  return __privateGet$4(this, _trace).call(this, "create", async () => {
2179
+ const ifVersion = parseIfVersion(b, c, d);
1789
2180
  if (Array.isArray(a)) {
1790
2181
  if (a.length === 0)
1791
2182
  return [];
@@ -1796,13 +2187,13 @@ class RestRepository extends Query {
1796
2187
  if (a === "")
1797
2188
  throw new Error("The id can't be empty");
1798
2189
  const columns = isStringArray(c) ? c : void 0;
1799
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
2190
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
1800
2191
  }
1801
2192
  if (isObject(a) && isString(a.id)) {
1802
2193
  if (a.id === "")
1803
2194
  throw new Error("The id can't be empty");
1804
2195
  const columns = isStringArray(b) ? b : void 0;
1805
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2196
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
1806
2197
  }
1807
2198
  if (isObject(a)) {
1808
2199
  const columns = isStringArray(b) ? b : void 0;
@@ -1833,6 +2224,7 @@ class RestRepository extends Query {
1833
2224
  pathParams: {
1834
2225
  workspace: "{workspaceId}",
1835
2226
  dbBranchName: "{dbBranch}",
2227
+ region: "{region}",
1836
2228
  tableName: __privateGet$4(this, _table),
1837
2229
  recordId: id
1838
2230
  },
@@ -1870,8 +2262,9 @@ class RestRepository extends Query {
1870
2262
  return result;
1871
2263
  });
1872
2264
  }
1873
- async update(a, b, c) {
2265
+ async update(a, b, c, d) {
1874
2266
  return __privateGet$4(this, _trace).call(this, "update", async () => {
2267
+ const ifVersion = parseIfVersion(b, c, d);
1875
2268
  if (Array.isArray(a)) {
1876
2269
  if (a.length === 0)
1877
2270
  return [];
@@ -1883,18 +2276,18 @@ class RestRepository extends Query {
1883
2276
  }
1884
2277
  if (isString(a) && isObject(b)) {
1885
2278
  const columns = isStringArray(c) ? c : void 0;
1886
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
2279
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1887
2280
  }
1888
2281
  if (isObject(a) && isString(a.id)) {
1889
2282
  const columns = isStringArray(b) ? b : void 0;
1890
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2283
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
1891
2284
  }
1892
2285
  throw new Error("Invalid arguments for update method");
1893
2286
  });
1894
2287
  }
1895
- async updateOrThrow(a, b, c) {
2288
+ async updateOrThrow(a, b, c, d) {
1896
2289
  return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1897
- const result = await this.update(a, b, c);
2290
+ const result = await this.update(a, b, c, d);
1898
2291
  if (Array.isArray(result)) {
1899
2292
  const missingIds = compact(
1900
2293
  a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
@@ -1911,8 +2304,9 @@ class RestRepository extends Query {
1911
2304
  return result;
1912
2305
  });
1913
2306
  }
1914
- async createOrUpdate(a, b, c) {
2307
+ async createOrUpdate(a, b, c, d) {
1915
2308
  return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
2309
+ const ifVersion = parseIfVersion(b, c, d);
1916
2310
  if (Array.isArray(a)) {
1917
2311
  if (a.length === 0)
1918
2312
  return [];
@@ -1924,15 +2318,35 @@ class RestRepository extends Query {
1924
2318
  }
1925
2319
  if (isString(a) && isObject(b)) {
1926
2320
  const columns = isStringArray(c) ? c : void 0;
1927
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
2321
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1928
2322
  }
1929
2323
  if (isObject(a) && isString(a.id)) {
1930
2324
  const columns = isStringArray(c) ? c : void 0;
1931
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2325
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
1932
2326
  }
1933
2327
  throw new Error("Invalid arguments for createOrUpdate method");
1934
2328
  });
1935
2329
  }
2330
+ async createOrReplace(a, b, c, d) {
2331
+ return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
2332
+ const ifVersion = parseIfVersion(b, c, d);
2333
+ if (Array.isArray(a)) {
2334
+ if (a.length === 0)
2335
+ return [];
2336
+ const columns = isStringArray(b) ? b : ["*"];
2337
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
2338
+ }
2339
+ if (isString(a) && isObject(b)) {
2340
+ const columns = isStringArray(c) ? c : void 0;
2341
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
2342
+ }
2343
+ if (isObject(a) && isString(a.id)) {
2344
+ const columns = isStringArray(c) ? c : void 0;
2345
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
2346
+ }
2347
+ throw new Error("Invalid arguments for createOrReplace method");
2348
+ });
2349
+ }
1936
2350
  async delete(a, b) {
1937
2351
  return __privateGet$4(this, _trace).call(this, "delete", async () => {
1938
2352
  if (Array.isArray(a)) {
@@ -1974,7 +2388,12 @@ class RestRepository extends Query {
1974
2388
  return __privateGet$4(this, _trace).call(this, "search", async () => {
1975
2389
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1976
2390
  const { records } = await searchTable({
1977
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2391
+ pathParams: {
2392
+ workspace: "{workspaceId}",
2393
+ dbBranchName: "{dbBranch}",
2394
+ region: "{region}",
2395
+ tableName: __privateGet$4(this, _table)
2396
+ },
1978
2397
  body: {
1979
2398
  query,
1980
2399
  fuzziness: options.fuzziness,
@@ -1993,7 +2412,12 @@ class RestRepository extends Query {
1993
2412
  return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
1994
2413
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1995
2414
  const result = await aggregateTable({
1996
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2415
+ pathParams: {
2416
+ workspace: "{workspaceId}",
2417
+ dbBranchName: "{dbBranch}",
2418
+ region: "{region}",
2419
+ tableName: __privateGet$4(this, _table)
2420
+ },
1997
2421
  body: { aggs, filter },
1998
2422
  ...fetchProps
1999
2423
  });
@@ -2008,7 +2432,12 @@ class RestRepository extends Query {
2008
2432
  const data = query.getQueryOptions();
2009
2433
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2010
2434
  const { meta, records: objects } = await queryTable({
2011
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2435
+ pathParams: {
2436
+ workspace: "{workspaceId}",
2437
+ dbBranchName: "{dbBranch}",
2438
+ region: "{region}",
2439
+ tableName: __privateGet$4(this, _table)
2440
+ },
2012
2441
  body: {
2013
2442
  filter: cleanFilter(data.filter),
2014
2443
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
@@ -2030,11 +2459,17 @@ class RestRepository extends Query {
2030
2459
  const data = query.getQueryOptions();
2031
2460
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2032
2461
  const result = await summarizeTable({
2033
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2462
+ pathParams: {
2463
+ workspace: "{workspaceId}",
2464
+ dbBranchName: "{dbBranch}",
2465
+ region: "{region}",
2466
+ tableName: __privateGet$4(this, _table)
2467
+ },
2034
2468
  body: {
2035
2469
  filter: cleanFilter(data.filter),
2036
2470
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2037
2471
  columns: data.columns,
2472
+ page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
2038
2473
  summaries,
2039
2474
  summariesFilter
2040
2475
  },
@@ -2058,6 +2493,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
2058
2493
  pathParams: {
2059
2494
  workspace: "{workspaceId}",
2060
2495
  dbBranchName: "{dbBranch}",
2496
+ region: "{region}",
2061
2497
  tableName: __privateGet$4(this, _table)
2062
2498
  },
2063
2499
  queryParams: { columns },
@@ -2068,18 +2504,19 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
2068
2504
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2069
2505
  };
2070
2506
  _insertRecordWithId = new WeakSet();
2071
- insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
2507
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
2072
2508
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2073
2509
  const record = transformObjectLinks(object);
2074
2510
  const response = await insertRecordWithID({
2075
2511
  pathParams: {
2076
2512
  workspace: "{workspaceId}",
2077
2513
  dbBranchName: "{dbBranch}",
2514
+ region: "{region}",
2078
2515
  tableName: __privateGet$4(this, _table),
2079
2516
  recordId
2080
2517
  },
2081
2518
  body: record,
2082
- queryParams: { createOnly: true, columns },
2519
+ queryParams: { createOnly, columns, ifVersion },
2083
2520
  ...fetchProps
2084
2521
  });
2085
2522
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
@@ -2090,7 +2527,12 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
2090
2527
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2091
2528
  const records = objects.map((object) => transformObjectLinks(object));
2092
2529
  const response = await bulkInsertTableRecords({
2093
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2530
+ pathParams: {
2531
+ workspace: "{workspaceId}",
2532
+ dbBranchName: "{dbBranch}",
2533
+ region: "{region}",
2534
+ tableName: __privateGet$4(this, _table)
2535
+ },
2094
2536
  queryParams: { columns },
2095
2537
  body: { records },
2096
2538
  ...fetchProps
@@ -2102,13 +2544,19 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
2102
2544
  return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
2103
2545
  };
2104
2546
  _updateRecordWithID = new WeakSet();
2105
- updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2547
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
2106
2548
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2107
2549
  const record = transformObjectLinks(object);
2108
2550
  try {
2109
2551
  const response = await updateRecordWithID({
2110
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2111
- queryParams: { columns },
2552
+ pathParams: {
2553
+ workspace: "{workspaceId}",
2554
+ dbBranchName: "{dbBranch}",
2555
+ region: "{region}",
2556
+ tableName: __privateGet$4(this, _table),
2557
+ recordId
2558
+ },
2559
+ queryParams: { columns, ifVersion },
2112
2560
  body: record,
2113
2561
  ...fetchProps
2114
2562
  });
@@ -2122,11 +2570,17 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2122
2570
  }
2123
2571
  };
2124
2572
  _upsertRecordWithID = new WeakSet();
2125
- upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2573
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
2126
2574
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2127
2575
  const response = await upsertRecordWithID({
2128
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2129
- queryParams: { columns },
2576
+ pathParams: {
2577
+ workspace: "{workspaceId}",
2578
+ dbBranchName: "{dbBranch}",
2579
+ region: "{region}",
2580
+ tableName: __privateGet$4(this, _table),
2581
+ recordId
2582
+ },
2583
+ queryParams: { columns, ifVersion },
2130
2584
  body: object,
2131
2585
  ...fetchProps
2132
2586
  });
@@ -2138,7 +2592,13 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
2138
2592
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2139
2593
  try {
2140
2594
  const response = await deleteRecord({
2141
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2595
+ pathParams: {
2596
+ workspace: "{workspaceId}",
2597
+ dbBranchName: "{dbBranch}",
2598
+ region: "{region}",
2599
+ tableName: __privateGet$4(this, _table),
2600
+ recordId
2601
+ },
2142
2602
  queryParams: { columns },
2143
2603
  ...fetchProps
2144
2604
  });
@@ -2173,7 +2633,7 @@ getSchemaTables_fn$1 = async function() {
2173
2633
  return __privateGet$4(this, _schemaTables$2);
2174
2634
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2175
2635
  const { schema } = await getBranchDetails({
2176
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2636
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2177
2637
  ...fetchProps
2178
2638
  });
2179
2639
  __privateSet$4(this, _schemaTables$2, schema.tables);
@@ -2239,8 +2699,15 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2239
2699
  result.read = function(columns2) {
2240
2700
  return db[table].read(result["id"], columns2);
2241
2701
  };
2242
- result.update = function(data, columns2) {
2243
- return db[table].update(result["id"], data, columns2);
2702
+ result.update = function(data, b, c) {
2703
+ const columns2 = isStringArray(b) ? b : ["*"];
2704
+ const ifVersion = parseIfVersion(b, c);
2705
+ return db[table].update(result["id"], data, columns2, { ifVersion });
2706
+ };
2707
+ result.replace = function(data, b, c) {
2708
+ const columns2 = isStringArray(b) ? b : ["*"];
2709
+ const ifVersion = parseIfVersion(b, c);
2710
+ return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
2244
2711
  };
2245
2712
  result.delete = function() {
2246
2713
  return db[table].delete(result["id"]);
@@ -2273,6 +2740,14 @@ function isValidColumn(columns, column) {
2273
2740
  }
2274
2741
  return columns.includes(column.name);
2275
2742
  }
2743
+ function parseIfVersion(...args) {
2744
+ for (const arg of args) {
2745
+ if (isObject(arg) && isNumber(arg.ifVersion)) {
2746
+ return arg.ifVersion;
2747
+ }
2748
+ }
2749
+ return void 0;
2750
+ }
2276
2751
 
2277
2752
  var __accessCheck$3 = (obj, member, msg) => {
2278
2753
  if (!member.has(obj))
@@ -2460,7 +2935,7 @@ search_fn = async function(query, options, getFetchProps) {
2460
2935
  const fetchProps = await getFetchProps();
2461
2936
  const { tables, fuzziness, highlight, prefix } = options ?? {};
2462
2937
  const { records } = await searchBranch({
2463
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2938
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2464
2939
  body: { tables, query, fuzziness, prefix, highlight },
2465
2940
  ...fetchProps
2466
2941
  });
@@ -2472,7 +2947,7 @@ getSchemaTables_fn = async function(getFetchProps) {
2472
2947
  return __privateGet$1(this, _schemaTables);
2473
2948
  const fetchProps = await getFetchProps();
2474
2949
  const { schema } = await getBranchDetails({
2475
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2950
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2476
2951
  ...fetchProps
2477
2952
  });
2478
2953
  __privateSet$1(this, _schemaTables, schema.tables);
@@ -2510,14 +2985,17 @@ async function resolveXataBranch(gitBranch, options) {
2510
2985
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2511
2986
  );
2512
2987
  const [protocol, , host, , dbName] = databaseURL.split("/");
2513
- const [workspace] = host.split(".");
2988
+ const urlParts = parseWorkspacesUrlParts(host);
2989
+ if (!urlParts)
2990
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
2991
+ const { workspace, region } = urlParts;
2514
2992
  const { fallbackBranch } = getEnvironment();
2515
2993
  const { branch } = await resolveBranch({
2516
2994
  apiKey,
2517
2995
  apiUrl: databaseURL,
2518
2996
  fetchImpl: getFetchImplementation(options?.fetchImpl),
2519
2997
  workspacesApiUrl: `${protocol}//${host}`,
2520
- pathParams: { dbName, workspace },
2998
+ pathParams: { dbName, workspace, region },
2521
2999
  queryParams: { gitBranch, fallbackBranch },
2522
3000
  trace: defaultTrace
2523
3001
  });
@@ -2535,15 +3013,17 @@ async function getDatabaseBranch(branch, options) {
2535
3013
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2536
3014
  );
2537
3015
  const [protocol, , host, , database] = databaseURL.split("/");
2538
- const [workspace] = host.split(".");
2539
- const dbBranchName = `${database}:${branch}`;
3016
+ const urlParts = parseWorkspacesUrlParts(host);
3017
+ if (!urlParts)
3018
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3019
+ const { workspace, region } = urlParts;
2540
3020
  try {
2541
3021
  return await getBranchDetails({
2542
3022
  apiKey,
2543
3023
  apiUrl: databaseURL,
2544
3024
  fetchImpl: getFetchImplementation(options?.fetchImpl),
2545
3025
  workspacesApiUrl: `${protocol}//${host}`,
2546
- pathParams: { dbBranchName, workspace },
3026
+ pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
2547
3027
  trace: defaultTrace
2548
3028
  });
2549
3029
  } catch (err) {
@@ -2635,14 +3115,7 @@ const buildClient = (plugins) => {
2635
3115
  throw new Error("Option databaseURL is required");
2636
3116
  }
2637
3117
  return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID() };
2638
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
2639
- fetch,
2640
- apiKey,
2641
- databaseURL,
2642
- branch,
2643
- trace,
2644
- clientID
2645
- }) {
3118
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
2646
3119
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2647
3120
  if (!branchValue)
2648
3121
  throw new Error("Unable to resolve branch value");
@@ -2875,12 +3348,14 @@ exports.lessEquals = lessEquals;
2875
3348
  exports.lessThan = lessThan;
2876
3349
  exports.lessThanEquals = lessThanEquals;
2877
3350
  exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
3351
+ exports.listRegions = listRegions;
2878
3352
  exports.lt = lt;
2879
3353
  exports.lte = lte;
2880
3354
  exports.mergeMigrationRequest = mergeMigrationRequest;
2881
3355
  exports.notExists = notExists;
2882
3356
  exports.operationsByTag = operationsByTag;
2883
3357
  exports.parseProviderString = parseProviderString;
3358
+ exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
2884
3359
  exports.pattern = pattern;
2885
3360
  exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
2886
3361
  exports.queryMigrationRequests = queryMigrationRequests;