@xata.io/client 0.18.6 → 0.19.1

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