@xata.io/client 0.0.0-alpha.vf683143 → 0.0.0-alpha.vf6a5dcf

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.0.0-alpha.vf683143";
189
+ const VERSION = "0.0.0-alpha.vf6a5dcf";
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)
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,14 +270,18 @@ async function fetch$1({
253
270
  queryParams,
254
271
  fetchImpl,
255
272
  apiKey,
273
+ endpoint,
256
274
  apiUrl,
257
275
  workspacesApiUrl,
258
- trace
276
+ trace,
277
+ signal,
278
+ clientID,
279
+ sessionID
259
280
  }) {
260
281
  return trace(
261
282
  `${method.toUpperCase()} ${path}`,
262
283
  async ({ setAttributes }) => {
263
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
284
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
264
285
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
265
286
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
266
287
  setAttributes({
@@ -273,10 +294,13 @@ async function fetch$1({
273
294
  headers: {
274
295
  "Content-Type": "application/json",
275
296
  "User-Agent": `Xata client-ts/${VERSION}`,
297
+ "X-Xata-Client-ID": clientID ?? "",
298
+ "X-Xata-Session-ID": sessionID ?? "",
276
299
  ...headers,
277
300
  ...hostHeader(fullUrl),
278
301
  Authorization: `Bearer ${apiKey}`
279
- }
302
+ },
303
+ signal
280
304
  });
281
305
  if (response.status === 204) {
282
306
  return {};
@@ -312,278 +336,163 @@ function parseUrl(url) {
312
336
  }
313
337
  }
314
338
 
315
- const getUser = (variables) => fetch$1({ url: "/user", method: "get", ...variables });
316
- const updateUser = (variables) => fetch$1({ url: "/user", method: "put", ...variables });
317
- const deleteUser = (variables) => fetch$1({ url: "/user", method: "delete", ...variables });
318
- const getUserAPIKeys = (variables) => fetch$1({
319
- url: "/user/keys",
320
- method: "get",
321
- ...variables
322
- });
323
- const createUserAPIKey = (variables) => fetch$1({
324
- url: "/user/keys/{keyName}",
325
- method: "post",
326
- ...variables
327
- });
328
- const deleteUserAPIKey = (variables) => fetch$1({
329
- url: "/user/keys/{keyName}",
330
- method: "delete",
331
- ...variables
332
- });
333
- const createWorkspace = (variables) => fetch$1({
334
- url: "/workspaces",
335
- method: "post",
336
- ...variables
337
- });
338
- const getWorkspacesList = (variables) => fetch$1({
339
- url: "/workspaces",
340
- method: "get",
341
- ...variables
342
- });
343
- const getWorkspace = (variables) => fetch$1({
344
- url: "/workspaces/{workspaceId}",
345
- method: "get",
346
- ...variables
347
- });
348
- const updateWorkspace = (variables) => fetch$1({
349
- url: "/workspaces/{workspaceId}",
350
- method: "put",
351
- ...variables
352
- });
353
- const deleteWorkspace = (variables) => fetch$1({
354
- url: "/workspaces/{workspaceId}",
355
- method: "delete",
356
- ...variables
357
- });
358
- const getWorkspaceMembersList = (variables) => fetch$1({
359
- url: "/workspaces/{workspaceId}/members",
360
- method: "get",
361
- ...variables
362
- });
363
- const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
364
- const removeWorkspaceMember = (variables) => fetch$1({
365
- url: "/workspaces/{workspaceId}/members/{userId}",
366
- method: "delete",
367
- ...variables
368
- });
369
- const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
370
- const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
371
- const cancelWorkspaceMemberInvite = (variables) => fetch$1({
372
- url: "/workspaces/{workspaceId}/invites/{inviteId}",
373
- method: "delete",
374
- ...variables
375
- });
376
- const resendWorkspaceMemberInvite = (variables) => fetch$1({
377
- url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
378
- method: "post",
379
- ...variables
380
- });
381
- const acceptWorkspaceMemberInvite = (variables) => fetch$1({
382
- url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
383
- method: "post",
384
- ...variables
385
- });
386
- const getDatabaseList = (variables) => fetch$1({
387
- url: "/dbs",
388
- method: "get",
389
- ...variables
390
- });
391
- const getBranchList = (variables) => fetch$1({
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({
392
343
  url: "/dbs/{dbName}",
393
344
  method: "get",
394
- ...variables
345
+ ...variables,
346
+ signal
395
347
  });
396
- const createDatabase = (variables) => fetch$1({
397
- url: "/dbs/{dbName}",
398
- method: "put",
399
- ...variables
400
- });
401
- const deleteDatabase = (variables) => fetch$1({
402
- url: "/dbs/{dbName}",
403
- method: "delete",
404
- ...variables
405
- });
406
- const getDatabaseMetadata = (variables) => fetch$1({
407
- url: "/dbs/{dbName}/metadata",
408
- method: "get",
409
- ...variables
410
- });
411
- const updateDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
412
- const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
413
- const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
414
- const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
415
- const resolveBranch = (variables) => fetch$1({
416
- url: "/dbs/{dbName}/resolveBranch",
417
- method: "get",
418
- ...variables
419
- });
420
- const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
421
- const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
422
- const getMigrationRequest = (variables) => fetch$1({
423
- url: "/dbs/{dbName}/migrations/{mrNumber}",
424
- method: "get",
425
- ...variables
426
- });
427
- const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
428
- const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
429
- const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
430
- const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
431
- const mergeMigrationRequest = (variables) => fetch$1({
432
- url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
433
- method: "post",
434
- ...variables
435
- });
436
- const getBranchDetails = (variables) => fetch$1({
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({
437
353
  url: "/db/{dbBranchName}",
438
354
  method: "get",
439
- ...variables
355
+ ...variables,
356
+ signal
440
357
  });
441
- const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
442
- const deleteBranch = (variables) => fetch$1({
358
+ const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
359
+ const deleteBranch = (variables, signal) => dataPlaneFetch({
443
360
  url: "/db/{dbBranchName}",
444
361
  method: "delete",
445
- ...variables
362
+ ...variables,
363
+ signal
446
364
  });
447
- const updateBranchMetadata = (variables) => fetch$1({
365
+ const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
448
366
  url: "/db/{dbBranchName}/metadata",
449
367
  method: "put",
450
- ...variables
368
+ ...variables,
369
+ signal
451
370
  });
452
- const getBranchMetadata = (variables) => fetch$1({
371
+ const getBranchMetadata = (variables, signal) => dataPlaneFetch({
453
372
  url: "/db/{dbBranchName}/metadata",
454
373
  method: "get",
455
- ...variables
456
- });
457
- const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
458
- const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
459
- const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
460
- const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
461
- const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
462
- const updateBranchSchema = (variables) => fetch$1({
463
- url: "/db/{dbBranchName}/schema/update",
464
- method: "post",
465
- ...variables
374
+ ...variables,
375
+ signal
466
376
  });
467
- const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
468
- const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
469
- const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
470
- const getBranchStats = (variables) => fetch$1({
377
+ const getBranchStats = (variables, signal) => dataPlaneFetch({
471
378
  url: "/db/{dbBranchName}/stats",
472
379
  method: "get",
473
- ...variables
380
+ ...variables,
381
+ signal
382
+ });
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 branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
391
+ const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
392
+ const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
393
+ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
394
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
395
+ method: "get",
396
+ ...variables,
397
+ signal
474
398
  });
475
- const createTable = (variables) => fetch$1({
399
+ const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
400
+ const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
401
+ const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
402
+ const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
403
+ const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
404
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
405
+ method: "post",
406
+ ...variables,
407
+ signal
408
+ });
409
+ const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
410
+ const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
411
+ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
412
+ const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
413
+ const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
414
+ const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
415
+ const createTable = (variables, signal) => dataPlaneFetch({
476
416
  url: "/db/{dbBranchName}/tables/{tableName}",
477
417
  method: "put",
478
- ...variables
418
+ ...variables,
419
+ signal
479
420
  });
480
- const deleteTable = (variables) => fetch$1({
421
+ const deleteTable = (variables, signal) => dataPlaneFetch({
481
422
  url: "/db/{dbBranchName}/tables/{tableName}",
482
423
  method: "delete",
483
- ...variables
424
+ ...variables,
425
+ signal
484
426
  });
485
- const updateTable = (variables) => fetch$1({
486
- url: "/db/{dbBranchName}/tables/{tableName}",
487
- method: "patch",
488
- ...variables
489
- });
490
- const getTableSchema = (variables) => fetch$1({
427
+ const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
428
+ const getTableSchema = (variables, signal) => dataPlaneFetch({
491
429
  url: "/db/{dbBranchName}/tables/{tableName}/schema",
492
430
  method: "get",
493
- ...variables
431
+ ...variables,
432
+ signal
494
433
  });
495
- const setTableSchema = (variables) => fetch$1({
496
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
497
- method: "put",
498
- ...variables
499
- });
500
- const getTableColumns = (variables) => fetch$1({
434
+ const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
435
+ const getTableColumns = (variables, signal) => dataPlaneFetch({
501
436
  url: "/db/{dbBranchName}/tables/{tableName}/columns",
502
437
  method: "get",
503
- ...variables
504
- });
505
- const addTableColumn = (variables) => fetch$1({
506
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
507
- method: "post",
508
- ...variables
438
+ ...variables,
439
+ signal
509
440
  });
510
- const getColumn = (variables) => fetch$1({
441
+ const addTableColumn = (variables, signal) => dataPlaneFetch(
442
+ { url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
443
+ );
444
+ const getColumn = (variables, signal) => dataPlaneFetch({
511
445
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
512
446
  method: "get",
513
- ...variables
447
+ ...variables,
448
+ signal
514
449
  });
515
- const deleteColumn = (variables) => fetch$1({
450
+ const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
451
+ const deleteColumn = (variables, signal) => dataPlaneFetch({
516
452
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
517
453
  method: "delete",
518
- ...variables
519
- });
520
- const updateColumn = (variables) => fetch$1({
521
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
522
- method: "patch",
523
- ...variables
454
+ ...variables,
455
+ signal
524
456
  });
525
- const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
526
- const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
527
- const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
528
- const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
529
- const deleteRecord = (variables) => fetch$1({
530
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
531
- method: "delete",
532
- ...variables
533
- });
534
- const getRecord = (variables) => fetch$1({
457
+ const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
458
+ const getRecord = (variables, signal) => dataPlaneFetch({
535
459
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
536
460
  method: "get",
537
- ...variables
461
+ ...variables,
462
+ signal
538
463
  });
539
- const bulkInsertTableRecords = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables });
540
- const queryTable = (variables) => fetch$1({
464
+ const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
465
+ const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
466
+ const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
467
+ const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
468
+ const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
469
+ const queryTable = (variables, signal) => dataPlaneFetch({
541
470
  url: "/db/{dbBranchName}/tables/{tableName}/query",
542
471
  method: "post",
543
- ...variables
472
+ ...variables,
473
+ signal
544
474
  });
545
- const searchTable = (variables) => fetch$1({
546
- url: "/db/{dbBranchName}/tables/{tableName}/search",
547
- method: "post",
548
- ...variables
549
- });
550
- const searchBranch = (variables) => fetch$1({
475
+ const searchBranch = (variables, signal) => dataPlaneFetch({
551
476
  url: "/db/{dbBranchName}/search",
552
477
  method: "post",
553
- ...variables
478
+ ...variables,
479
+ signal
554
480
  });
555
- const summarizeTable = (variables) => fetch$1({
556
- url: "/db/{dbBranchName}/tables/{tableName}/summarize",
481
+ const searchTable = (variables, signal) => dataPlaneFetch({
482
+ url: "/db/{dbBranchName}/tables/{tableName}/search",
557
483
  method: "post",
558
- ...variables
484
+ ...variables,
485
+ signal
559
486
  });
560
- const operationsByTag = {
561
- users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
562
- workspaces: {
563
- createWorkspace,
564
- getWorkspacesList,
565
- getWorkspace,
566
- updateWorkspace,
567
- deleteWorkspace,
568
- getWorkspaceMembersList,
569
- updateWorkspaceMemberRole,
570
- removeWorkspaceMember,
571
- inviteWorkspaceMember,
572
- updateWorkspaceMemberInvite,
573
- cancelWorkspaceMemberInvite,
574
- resendWorkspaceMemberInvite,
575
- acceptWorkspaceMemberInvite
576
- },
487
+ const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
488
+ const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
489
+ const operationsByTag$2 = {
577
490
  database: {
578
- getDatabaseList,
579
- createDatabase,
580
- deleteDatabase,
581
- getDatabaseMetadata,
582
- updateDatabaseMetadata,
583
- getGitBranchesMapping,
584
- addGitBranchesEntry,
585
- removeGitBranchesEntry,
586
- resolveBranch
491
+ dEPRECATEDgetDatabaseList,
492
+ dEPRECATEDcreateDatabase,
493
+ dEPRECATEDdeleteDatabase,
494
+ dEPRECATEDgetDatabaseMetadata,
495
+ dEPRECATEDupdateDatabaseMetadata
587
496
  },
588
497
  branch: {
589
498
  getBranchList,
@@ -592,10 +501,35 @@ const operationsByTag = {
592
501
  deleteBranch,
593
502
  updateBranchMetadata,
594
503
  getBranchMetadata,
595
- getBranchStats
504
+ getBranchStats,
505
+ getGitBranchesMapping,
506
+ addGitBranchesEntry,
507
+ removeGitBranchesEntry,
508
+ resolveBranch
509
+ },
510
+ migrations: {
511
+ getBranchMigrationHistory,
512
+ getBranchMigrationPlan,
513
+ executeBranchMigrationPlan,
514
+ getBranchSchemaHistory,
515
+ compareBranchWithUserSchema,
516
+ compareBranchSchemas,
517
+ updateBranchSchema,
518
+ previewBranchSchemaEdit,
519
+ applyBranchSchemaEdit
520
+ },
521
+ records: {
522
+ branchTransaction,
523
+ insertRecord,
524
+ getRecord,
525
+ insertRecordWithID,
526
+ updateRecordWithID,
527
+ upsertRecordWithID,
528
+ deleteRecord,
529
+ bulkInsertTableRecords
596
530
  },
597
531
  migrationRequests: {
598
- listMigrationRequests,
532
+ queryMigrationRequests,
599
533
  createMigrationRequest,
600
534
  getMigrationRequest,
601
535
  updateMigrationRequest,
@@ -604,17 +538,6 @@ const operationsByTag = {
604
538
  getMigrationRequestIsMerged,
605
539
  mergeMigrationRequest
606
540
  },
607
- branchSchema: {
608
- getBranchMigrationHistory,
609
- executeBranchMigrationPlan,
610
- getBranchMigrationPlan,
611
- compareBranchWithUserSchema,
612
- compareBranchSchemas,
613
- updateBranchSchema,
614
- previewBranchSchemaEdit,
615
- applyBranchSchemaEdit,
616
- getBranchSchemaHistory
617
- },
618
541
  table: {
619
542
  createTable,
620
543
  deleteTable,
@@ -624,24 +547,146 @@ const operationsByTag = {
624
547
  getTableColumns,
625
548
  addTableColumn,
626
549
  getColumn,
627
- deleteColumn,
628
- updateColumn
550
+ updateColumn,
551
+ deleteColumn
629
552
  },
630
- records: {
631
- insertRecord,
632
- insertRecordWithID,
633
- updateRecordWithID,
634
- upsertRecordWithID,
635
- deleteRecord,
636
- getRecord,
637
- bulkInsertTableRecords,
638
- queryTable,
639
- searchTable,
640
- searchBranch,
641
- summarizeTable
553
+ searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
554
+ };
555
+
556
+ const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
557
+
558
+ const getUser = (variables, signal) => controlPlaneFetch({
559
+ url: "/user",
560
+ method: "get",
561
+ ...variables,
562
+ signal
563
+ });
564
+ const updateUser = (variables, signal) => controlPlaneFetch({
565
+ url: "/user",
566
+ method: "put",
567
+ ...variables,
568
+ signal
569
+ });
570
+ const deleteUser = (variables, signal) => controlPlaneFetch({
571
+ url: "/user",
572
+ method: "delete",
573
+ ...variables,
574
+ signal
575
+ });
576
+ const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
577
+ url: "/user/keys",
578
+ method: "get",
579
+ ...variables,
580
+ signal
581
+ });
582
+ const createUserAPIKey = (variables, signal) => controlPlaneFetch({
583
+ url: "/user/keys/{keyName}",
584
+ method: "post",
585
+ ...variables,
586
+ signal
587
+ });
588
+ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
589
+ url: "/user/keys/{keyName}",
590
+ method: "delete",
591
+ ...variables,
592
+ signal
593
+ });
594
+ const getWorkspacesList = (variables, signal) => controlPlaneFetch({
595
+ url: "/workspaces",
596
+ method: "get",
597
+ ...variables,
598
+ signal
599
+ });
600
+ const createWorkspace = (variables, signal) => controlPlaneFetch({
601
+ url: "/workspaces",
602
+ method: "post",
603
+ ...variables,
604
+ signal
605
+ });
606
+ const getWorkspace = (variables, signal) => controlPlaneFetch({
607
+ url: "/workspaces/{workspaceId}",
608
+ method: "get",
609
+ ...variables,
610
+ signal
611
+ });
612
+ const updateWorkspace = (variables, signal) => controlPlaneFetch({
613
+ url: "/workspaces/{workspaceId}",
614
+ method: "put",
615
+ ...variables,
616
+ signal
617
+ });
618
+ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
619
+ url: "/workspaces/{workspaceId}",
620
+ method: "delete",
621
+ ...variables,
622
+ signal
623
+ });
624
+ const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
625
+ const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
626
+ const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
627
+ url: "/workspaces/{workspaceId}/members/{userId}",
628
+ method: "delete",
629
+ ...variables,
630
+ signal
631
+ });
632
+ const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
633
+ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
634
+ const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
635
+ const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
636
+ const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
637
+ const getDatabaseList = (variables, signal) => controlPlaneFetch({
638
+ url: "/workspaces/{workspaceId}/dbs",
639
+ method: "get",
640
+ ...variables,
641
+ signal
642
+ });
643
+ const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
644
+ const deleteDatabase = (variables, signal) => controlPlaneFetch({
645
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
646
+ method: "delete",
647
+ ...variables,
648
+ signal
649
+ });
650
+ const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
651
+ const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
652
+ const listRegions = (variables, signal) => controlPlaneFetch({
653
+ url: "/workspaces/{workspaceId}/regions",
654
+ method: "get",
655
+ ...variables,
656
+ signal
657
+ });
658
+ const operationsByTag$1 = {
659
+ users: { getUser, updateUser, deleteUser },
660
+ authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
661
+ workspaces: {
662
+ getWorkspacesList,
663
+ createWorkspace,
664
+ getWorkspace,
665
+ updateWorkspace,
666
+ deleteWorkspace,
667
+ getWorkspaceMembersList,
668
+ updateWorkspaceMemberRole,
669
+ removeWorkspaceMember
670
+ },
671
+ invites: {
672
+ inviteWorkspaceMember,
673
+ updateWorkspaceMemberInvite,
674
+ cancelWorkspaceMemberInvite,
675
+ acceptWorkspaceMemberInvite,
676
+ resendWorkspaceMemberInvite
677
+ },
678
+ databases: {
679
+ getDatabaseList,
680
+ createDatabase,
681
+ deleteDatabase,
682
+ getDatabaseMetadata,
683
+ updateDatabaseMetadata,
684
+ listRegions
642
685
  }
643
686
  };
644
687
 
688
+ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
689
+
645
690
  function getHostUrl(provider, type) {
646
691
  if (isHostProviderAlias(provider)) {
647
692
  return providers[provider][type];
@@ -653,11 +698,11 @@ function getHostUrl(provider, type) {
653
698
  const providers = {
654
699
  production: {
655
700
  main: "https://api.xata.io",
656
- workspaces: "https://{workspaceId}.xata.sh"
701
+ workspaces: "https://{workspaceId}.{region}.xata.sh"
657
702
  },
658
703
  staging: {
659
704
  main: "https://staging.xatabase.co",
660
- workspaces: "https://{workspaceId}.staging.xatabase.co"
705
+ workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
661
706
  }
662
707
  };
663
708
  function isHostProviderAlias(alias) {
@@ -666,6 +711,25 @@ function isHostProviderAlias(alias) {
666
711
  function isHostProviderBuilder(builder) {
667
712
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
668
713
  }
714
+ function parseProviderString(provider = "production") {
715
+ if (isHostProviderAlias(provider)) {
716
+ return provider;
717
+ }
718
+ const [main, workspaces] = provider.split(",");
719
+ if (!main || !workspaces)
720
+ return null;
721
+ return { main, workspaces };
722
+ }
723
+ function parseWorkspacesUrlParts(url) {
724
+ if (!isString(url))
725
+ return null;
726
+ const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
727
+ const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
728
+ const match = url.match(regex) || url.match(regexStaging);
729
+ if (!match)
730
+ return null;
731
+ return { workspace: match[1], region: match[2] ?? "eu-west-1" };
732
+ }
669
733
 
670
734
  var __accessCheck$7 = (obj, member, msg) => {
671
735
  if (!member.has(obj))
@@ -709,21 +773,41 @@ class XataApiClient {
709
773
  __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
710
774
  return __privateGet$7(this, _namespaces).user;
711
775
  }
776
+ get authentication() {
777
+ if (!__privateGet$7(this, _namespaces).authentication)
778
+ __privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
779
+ return __privateGet$7(this, _namespaces).authentication;
780
+ }
712
781
  get workspaces() {
713
782
  if (!__privateGet$7(this, _namespaces).workspaces)
714
783
  __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
715
784
  return __privateGet$7(this, _namespaces).workspaces;
716
785
  }
717
- get databases() {
718
- if (!__privateGet$7(this, _namespaces).databases)
719
- __privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
720
- return __privateGet$7(this, _namespaces).databases;
786
+ get invites() {
787
+ if (!__privateGet$7(this, _namespaces).invites)
788
+ __privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
789
+ return __privateGet$7(this, _namespaces).invites;
790
+ }
791
+ get database() {
792
+ if (!__privateGet$7(this, _namespaces).database)
793
+ __privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
794
+ return __privateGet$7(this, _namespaces).database;
721
795
  }
722
796
  get branches() {
723
797
  if (!__privateGet$7(this, _namespaces).branches)
724
798
  __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
725
799
  return __privateGet$7(this, _namespaces).branches;
726
800
  }
801
+ get migrations() {
802
+ if (!__privateGet$7(this, _namespaces).migrations)
803
+ __privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
804
+ return __privateGet$7(this, _namespaces).migrations;
805
+ }
806
+ get migrationRequests() {
807
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
808
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
809
+ return __privateGet$7(this, _namespaces).migrationRequests;
810
+ }
727
811
  get tables() {
728
812
  if (!__privateGet$7(this, _namespaces).tables)
729
813
  __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
@@ -734,15 +818,10 @@ class XataApiClient {
734
818
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
735
819
  return __privateGet$7(this, _namespaces).records;
736
820
  }
737
- get migrationRequests() {
738
- if (!__privateGet$7(this, _namespaces).migrationRequests)
739
- __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
740
- return __privateGet$7(this, _namespaces).migrationRequests;
741
- }
742
- get branchSchema() {
743
- if (!__privateGet$7(this, _namespaces).branchSchema)
744
- __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
745
- return __privateGet$7(this, _namespaces).branchSchema;
821
+ get searchAndFilter() {
822
+ if (!__privateGet$7(this, _namespaces).searchAndFilter)
823
+ __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
824
+ return __privateGet$7(this, _namespaces).searchAndFilter;
746
825
  }
747
826
  }
748
827
  _extraProps = new WeakMap();
@@ -754,24 +833,29 @@ class UserApi {
754
833
  getUser() {
755
834
  return operationsByTag.users.getUser({ ...this.extraProps });
756
835
  }
757
- updateUser(user) {
836
+ updateUser({ user }) {
758
837
  return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
759
838
  }
760
839
  deleteUser() {
761
840
  return operationsByTag.users.deleteUser({ ...this.extraProps });
762
841
  }
842
+ }
843
+ class AuthenticationApi {
844
+ constructor(extraProps) {
845
+ this.extraProps = extraProps;
846
+ }
763
847
  getUserAPIKeys() {
764
- return operationsByTag.users.getUserAPIKeys({ ...this.extraProps });
848
+ return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
765
849
  }
766
- createUserAPIKey(keyName) {
767
- return operationsByTag.users.createUserAPIKey({
768
- pathParams: { keyName },
850
+ createUserAPIKey({ name }) {
851
+ return operationsByTag.authentication.createUserAPIKey({
852
+ pathParams: { keyName: name },
769
853
  ...this.extraProps
770
854
  });
771
855
  }
772
- deleteUserAPIKey(keyName) {
773
- return operationsByTag.users.deleteUserAPIKey({
774
- pathParams: { keyName },
856
+ deleteUserAPIKey({ name }) {
857
+ return operationsByTag.authentication.deleteUserAPIKey({
858
+ pathParams: { keyName: name },
775
859
  ...this.extraProps
776
860
  });
777
861
  }
@@ -780,196 +864,248 @@ class WorkspaceApi {
780
864
  constructor(extraProps) {
781
865
  this.extraProps = extraProps;
782
866
  }
783
- createWorkspace(workspaceMeta) {
867
+ getWorkspacesList() {
868
+ return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
869
+ }
870
+ createWorkspace({ data }) {
784
871
  return operationsByTag.workspaces.createWorkspace({
785
- body: workspaceMeta,
872
+ body: data,
786
873
  ...this.extraProps
787
874
  });
788
875
  }
789
- getWorkspacesList() {
790
- return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
791
- }
792
- getWorkspace(workspaceId) {
876
+ getWorkspace({ workspace }) {
793
877
  return operationsByTag.workspaces.getWorkspace({
794
- pathParams: { workspaceId },
878
+ pathParams: { workspaceId: workspace },
795
879
  ...this.extraProps
796
880
  });
797
881
  }
798
- updateWorkspace(workspaceId, workspaceMeta) {
882
+ updateWorkspace({
883
+ workspace,
884
+ update
885
+ }) {
799
886
  return operationsByTag.workspaces.updateWorkspace({
800
- pathParams: { workspaceId },
801
- body: workspaceMeta,
887
+ pathParams: { workspaceId: workspace },
888
+ body: update,
802
889
  ...this.extraProps
803
890
  });
804
891
  }
805
- deleteWorkspace(workspaceId) {
892
+ deleteWorkspace({ workspace }) {
806
893
  return operationsByTag.workspaces.deleteWorkspace({
807
- pathParams: { workspaceId },
894
+ pathParams: { workspaceId: workspace },
808
895
  ...this.extraProps
809
896
  });
810
897
  }
811
- getWorkspaceMembersList(workspaceId) {
898
+ getWorkspaceMembersList({ workspace }) {
812
899
  return operationsByTag.workspaces.getWorkspaceMembersList({
813
- pathParams: { workspaceId },
900
+ pathParams: { workspaceId: workspace },
814
901
  ...this.extraProps
815
902
  });
816
903
  }
817
- updateWorkspaceMemberRole(workspaceId, userId, role) {
904
+ updateWorkspaceMemberRole({
905
+ workspace,
906
+ user,
907
+ role
908
+ }) {
818
909
  return operationsByTag.workspaces.updateWorkspaceMemberRole({
819
- pathParams: { workspaceId, userId },
910
+ pathParams: { workspaceId: workspace, userId: user },
820
911
  body: { role },
821
912
  ...this.extraProps
822
913
  });
823
914
  }
824
- removeWorkspaceMember(workspaceId, userId) {
915
+ removeWorkspaceMember({
916
+ workspace,
917
+ user
918
+ }) {
825
919
  return operationsByTag.workspaces.removeWorkspaceMember({
826
- pathParams: { workspaceId, userId },
920
+ pathParams: { workspaceId: workspace, userId: user },
827
921
  ...this.extraProps
828
922
  });
829
923
  }
830
- inviteWorkspaceMember(workspaceId, email, role) {
831
- return operationsByTag.workspaces.inviteWorkspaceMember({
832
- pathParams: { workspaceId },
924
+ }
925
+ class InvitesApi {
926
+ constructor(extraProps) {
927
+ this.extraProps = extraProps;
928
+ }
929
+ inviteWorkspaceMember({
930
+ workspace,
931
+ email,
932
+ role
933
+ }) {
934
+ return operationsByTag.invites.inviteWorkspaceMember({
935
+ pathParams: { workspaceId: workspace },
833
936
  body: { email, role },
834
937
  ...this.extraProps
835
938
  });
836
939
  }
837
- updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
838
- return operationsByTag.workspaces.updateWorkspaceMemberInvite({
839
- pathParams: { workspaceId, inviteId },
940
+ updateWorkspaceMemberInvite({
941
+ workspace,
942
+ invite,
943
+ role
944
+ }) {
945
+ return operationsByTag.invites.updateWorkspaceMemberInvite({
946
+ pathParams: { workspaceId: workspace, inviteId: invite },
840
947
  body: { role },
841
948
  ...this.extraProps
842
949
  });
843
950
  }
844
- cancelWorkspaceMemberInvite(workspaceId, inviteId) {
845
- return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
846
- pathParams: { workspaceId, inviteId },
951
+ cancelWorkspaceMemberInvite({
952
+ workspace,
953
+ invite
954
+ }) {
955
+ return operationsByTag.invites.cancelWorkspaceMemberInvite({
956
+ pathParams: { workspaceId: workspace, inviteId: invite },
847
957
  ...this.extraProps
848
958
  });
849
959
  }
850
- resendWorkspaceMemberInvite(workspaceId, inviteId) {
851
- return operationsByTag.workspaces.resendWorkspaceMemberInvite({
852
- pathParams: { workspaceId, inviteId },
960
+ acceptWorkspaceMemberInvite({
961
+ workspace,
962
+ key
963
+ }) {
964
+ return operationsByTag.invites.acceptWorkspaceMemberInvite({
965
+ pathParams: { workspaceId: workspace, inviteKey: key },
853
966
  ...this.extraProps
854
967
  });
855
968
  }
856
- acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
857
- return operationsByTag.workspaces.acceptWorkspaceMemberInvite({
858
- pathParams: { workspaceId, inviteKey },
969
+ resendWorkspaceMemberInvite({
970
+ workspace,
971
+ invite
972
+ }) {
973
+ return operationsByTag.invites.resendWorkspaceMemberInvite({
974
+ pathParams: { workspaceId: workspace, inviteId: invite },
859
975
  ...this.extraProps
860
976
  });
861
977
  }
862
978
  }
863
- class DatabaseApi {
979
+ class BranchApi {
864
980
  constructor(extraProps) {
865
981
  this.extraProps = extraProps;
866
982
  }
867
- getDatabaseList(workspace) {
868
- return operationsByTag.database.getDatabaseList({
869
- pathParams: { workspace },
870
- ...this.extraProps
871
- });
872
- }
873
- createDatabase(workspace, dbName, options = {}) {
874
- return operationsByTag.database.createDatabase({
875
- pathParams: { workspace, dbName },
876
- body: options,
877
- ...this.extraProps
878
- });
879
- }
880
- deleteDatabase(workspace, dbName) {
881
- return operationsByTag.database.deleteDatabase({
882
- pathParams: { workspace, dbName },
883
- ...this.extraProps
884
- });
885
- }
886
- getDatabaseMetadata(workspace, dbName) {
887
- return operationsByTag.database.getDatabaseMetadata({
888
- pathParams: { workspace, dbName },
889
- ...this.extraProps
890
- });
891
- }
892
- updateDatabaseMetadata(workspace, dbName, options = {}) {
893
- return operationsByTag.database.updateDatabaseMetadata({
894
- pathParams: { workspace, dbName },
895
- body: options,
896
- ...this.extraProps
897
- });
898
- }
899
- getGitBranchesMapping(workspace, dbName) {
900
- return operationsByTag.database.getGitBranchesMapping({
901
- pathParams: { workspace, dbName },
983
+ getBranchList({
984
+ workspace,
985
+ region,
986
+ database
987
+ }) {
988
+ return operationsByTag.branch.getBranchList({
989
+ pathParams: { workspace, region, dbName: database },
902
990
  ...this.extraProps
903
991
  });
904
992
  }
905
- addGitBranchesEntry(workspace, dbName, body) {
906
- return operationsByTag.database.addGitBranchesEntry({
907
- pathParams: { workspace, dbName },
908
- body,
993
+ getBranchDetails({
994
+ workspace,
995
+ region,
996
+ database,
997
+ branch
998
+ }) {
999
+ return operationsByTag.branch.getBranchDetails({
1000
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
909
1001
  ...this.extraProps
910
1002
  });
911
1003
  }
912
- removeGitBranchesEntry(workspace, dbName, gitBranch) {
913
- return operationsByTag.database.removeGitBranchesEntry({
914
- pathParams: { workspace, dbName },
915
- queryParams: { gitBranch },
1004
+ createBranch({
1005
+ workspace,
1006
+ region,
1007
+ database,
1008
+ branch,
1009
+ from,
1010
+ metadata
1011
+ }) {
1012
+ return operationsByTag.branch.createBranch({
1013
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1014
+ body: { from, metadata },
916
1015
  ...this.extraProps
917
1016
  });
918
1017
  }
919
- resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
920
- return operationsByTag.database.resolveBranch({
921
- pathParams: { workspace, dbName },
922
- queryParams: { gitBranch, fallbackBranch },
1018
+ deleteBranch({
1019
+ workspace,
1020
+ region,
1021
+ database,
1022
+ branch
1023
+ }) {
1024
+ return operationsByTag.branch.deleteBranch({
1025
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
923
1026
  ...this.extraProps
924
1027
  });
925
1028
  }
926
- }
927
- class BranchApi {
928
- constructor(extraProps) {
929
- this.extraProps = extraProps;
930
- }
931
- getBranchList(workspace, dbName) {
932
- return operationsByTag.branch.getBranchList({
933
- pathParams: { workspace, dbName },
1029
+ updateBranchMetadata({
1030
+ workspace,
1031
+ region,
1032
+ database,
1033
+ branch,
1034
+ metadata
1035
+ }) {
1036
+ return operationsByTag.branch.updateBranchMetadata({
1037
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1038
+ body: metadata,
934
1039
  ...this.extraProps
935
1040
  });
936
1041
  }
937
- getBranchDetails(workspace, database, branch) {
938
- return operationsByTag.branch.getBranchDetails({
939
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1042
+ getBranchMetadata({
1043
+ workspace,
1044
+ region,
1045
+ database,
1046
+ branch
1047
+ }) {
1048
+ return operationsByTag.branch.getBranchMetadata({
1049
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
940
1050
  ...this.extraProps
941
1051
  });
942
1052
  }
943
- createBranch(workspace, database, branch, from, options = {}) {
944
- return operationsByTag.branch.createBranch({
945
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
946
- queryParams: isString(from) ? { from } : void 0,
947
- body: options,
1053
+ getBranchStats({
1054
+ workspace,
1055
+ region,
1056
+ database,
1057
+ branch
1058
+ }) {
1059
+ return operationsByTag.branch.getBranchStats({
1060
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
948
1061
  ...this.extraProps
949
1062
  });
950
1063
  }
951
- deleteBranch(workspace, database, branch) {
952
- return operationsByTag.branch.deleteBranch({
953
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1064
+ getGitBranchesMapping({
1065
+ workspace,
1066
+ region,
1067
+ database
1068
+ }) {
1069
+ return operationsByTag.branch.getGitBranchesMapping({
1070
+ pathParams: { workspace, region, dbName: database },
954
1071
  ...this.extraProps
955
1072
  });
956
1073
  }
957
- updateBranchMetadata(workspace, database, branch, metadata = {}) {
958
- return operationsByTag.branch.updateBranchMetadata({
959
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
960
- body: metadata,
1074
+ addGitBranchesEntry({
1075
+ workspace,
1076
+ region,
1077
+ database,
1078
+ gitBranch,
1079
+ xataBranch
1080
+ }) {
1081
+ return operationsByTag.branch.addGitBranchesEntry({
1082
+ pathParams: { workspace, region, dbName: database },
1083
+ body: { gitBranch, xataBranch },
961
1084
  ...this.extraProps
962
1085
  });
963
1086
  }
964
- getBranchMetadata(workspace, database, branch) {
965
- return operationsByTag.branch.getBranchMetadata({
966
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1087
+ removeGitBranchesEntry({
1088
+ workspace,
1089
+ region,
1090
+ database,
1091
+ gitBranch
1092
+ }) {
1093
+ return operationsByTag.branch.removeGitBranchesEntry({
1094
+ pathParams: { workspace, region, dbName: database },
1095
+ queryParams: { gitBranch },
967
1096
  ...this.extraProps
968
1097
  });
969
1098
  }
970
- getBranchStats(workspace, database, branch) {
971
- return operationsByTag.branch.getBranchStats({
972
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1099
+ resolveBranch({
1100
+ workspace,
1101
+ region,
1102
+ database,
1103
+ gitBranch,
1104
+ fallbackBranch
1105
+ }) {
1106
+ return operationsByTag.branch.resolveBranch({
1107
+ pathParams: { workspace, region, dbName: database },
1108
+ queryParams: { gitBranch, fallbackBranch },
973
1109
  ...this.extraProps
974
1110
  });
975
1111
  }
@@ -978,67 +1114,134 @@ class TableApi {
978
1114
  constructor(extraProps) {
979
1115
  this.extraProps = extraProps;
980
1116
  }
981
- createTable(workspace, database, branch, tableName) {
1117
+ createTable({
1118
+ workspace,
1119
+ region,
1120
+ database,
1121
+ branch,
1122
+ table
1123
+ }) {
982
1124
  return operationsByTag.table.createTable({
983
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1125
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
984
1126
  ...this.extraProps
985
1127
  });
986
1128
  }
987
- deleteTable(workspace, database, branch, tableName) {
1129
+ deleteTable({
1130
+ workspace,
1131
+ region,
1132
+ database,
1133
+ branch,
1134
+ table
1135
+ }) {
988
1136
  return operationsByTag.table.deleteTable({
989
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1137
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
990
1138
  ...this.extraProps
991
1139
  });
992
1140
  }
993
- updateTable(workspace, database, branch, tableName, options) {
1141
+ updateTable({
1142
+ workspace,
1143
+ region,
1144
+ database,
1145
+ branch,
1146
+ table,
1147
+ update
1148
+ }) {
994
1149
  return operationsByTag.table.updateTable({
995
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
996
- body: options,
1150
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1151
+ body: update,
997
1152
  ...this.extraProps
998
1153
  });
999
1154
  }
1000
- getTableSchema(workspace, database, branch, tableName) {
1155
+ getTableSchema({
1156
+ workspace,
1157
+ region,
1158
+ database,
1159
+ branch,
1160
+ table
1161
+ }) {
1001
1162
  return operationsByTag.table.getTableSchema({
1002
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1163
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1003
1164
  ...this.extraProps
1004
1165
  });
1005
1166
  }
1006
- setTableSchema(workspace, database, branch, tableName, options) {
1167
+ setTableSchema({
1168
+ workspace,
1169
+ region,
1170
+ database,
1171
+ branch,
1172
+ table,
1173
+ schema
1174
+ }) {
1007
1175
  return operationsByTag.table.setTableSchema({
1008
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1009
- body: options,
1176
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1177
+ body: schema,
1010
1178
  ...this.extraProps
1011
1179
  });
1012
1180
  }
1013
- getTableColumns(workspace, database, branch, tableName) {
1181
+ getTableColumns({
1182
+ workspace,
1183
+ region,
1184
+ database,
1185
+ branch,
1186
+ table
1187
+ }) {
1014
1188
  return operationsByTag.table.getTableColumns({
1015
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1189
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1016
1190
  ...this.extraProps
1017
1191
  });
1018
1192
  }
1019
- addTableColumn(workspace, database, branch, tableName, column) {
1193
+ addTableColumn({
1194
+ workspace,
1195
+ region,
1196
+ database,
1197
+ branch,
1198
+ table,
1199
+ column
1200
+ }) {
1020
1201
  return operationsByTag.table.addTableColumn({
1021
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1202
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1022
1203
  body: column,
1023
1204
  ...this.extraProps
1024
1205
  });
1025
1206
  }
1026
- getColumn(workspace, database, branch, tableName, columnName) {
1207
+ getColumn({
1208
+ workspace,
1209
+ region,
1210
+ database,
1211
+ branch,
1212
+ table,
1213
+ column
1214
+ }) {
1027
1215
  return operationsByTag.table.getColumn({
1028
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1216
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1029
1217
  ...this.extraProps
1030
1218
  });
1031
1219
  }
1032
- deleteColumn(workspace, database, branch, tableName, columnName) {
1033
- return operationsByTag.table.deleteColumn({
1034
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1220
+ updateColumn({
1221
+ workspace,
1222
+ region,
1223
+ database,
1224
+ branch,
1225
+ table,
1226
+ column,
1227
+ update
1228
+ }) {
1229
+ return operationsByTag.table.updateColumn({
1230
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1231
+ body: update,
1035
1232
  ...this.extraProps
1036
1233
  });
1037
1234
  }
1038
- updateColumn(workspace, database, branch, tableName, columnName, options) {
1039
- return operationsByTag.table.updateColumn({
1040
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1041
- body: options,
1235
+ deleteColumn({
1236
+ workspace,
1237
+ region,
1238
+ database,
1239
+ branch,
1240
+ table,
1241
+ column
1242
+ }) {
1243
+ return operationsByTag.table.deleteColumn({
1244
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1042
1245
  ...this.extraProps
1043
1246
  });
1044
1247
  }
@@ -1047,85 +1250,213 @@ class RecordsApi {
1047
1250
  constructor(extraProps) {
1048
1251
  this.extraProps = extraProps;
1049
1252
  }
1050
- insertRecord(workspace, database, branch, tableName, record, options = {}) {
1253
+ insertRecord({
1254
+ workspace,
1255
+ region,
1256
+ database,
1257
+ branch,
1258
+ table,
1259
+ record,
1260
+ columns
1261
+ }) {
1051
1262
  return operationsByTag.records.insertRecord({
1052
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1053
- queryParams: options,
1263
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1264
+ queryParams: { columns },
1054
1265
  body: record,
1055
1266
  ...this.extraProps
1056
1267
  });
1057
1268
  }
1058
- insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1269
+ getRecord({
1270
+ workspace,
1271
+ region,
1272
+ database,
1273
+ branch,
1274
+ table,
1275
+ id,
1276
+ columns
1277
+ }) {
1278
+ return operationsByTag.records.getRecord({
1279
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1280
+ queryParams: { columns },
1281
+ ...this.extraProps
1282
+ });
1283
+ }
1284
+ insertRecordWithID({
1285
+ workspace,
1286
+ region,
1287
+ database,
1288
+ branch,
1289
+ table,
1290
+ id,
1291
+ record,
1292
+ columns,
1293
+ createOnly,
1294
+ ifVersion
1295
+ }) {
1059
1296
  return operationsByTag.records.insertRecordWithID({
1060
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1061
- queryParams: options,
1297
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1298
+ queryParams: { columns, createOnly, ifVersion },
1062
1299
  body: record,
1063
1300
  ...this.extraProps
1064
1301
  });
1065
1302
  }
1066
- updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1303
+ updateRecordWithID({
1304
+ workspace,
1305
+ region,
1306
+ database,
1307
+ branch,
1308
+ table,
1309
+ id,
1310
+ record,
1311
+ columns,
1312
+ ifVersion
1313
+ }) {
1067
1314
  return operationsByTag.records.updateRecordWithID({
1068
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1069
- queryParams: options,
1315
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1316
+ queryParams: { columns, ifVersion },
1070
1317
  body: record,
1071
1318
  ...this.extraProps
1072
1319
  });
1073
1320
  }
1074
- upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1321
+ upsertRecordWithID({
1322
+ workspace,
1323
+ region,
1324
+ database,
1325
+ branch,
1326
+ table,
1327
+ id,
1328
+ record,
1329
+ columns,
1330
+ ifVersion
1331
+ }) {
1075
1332
  return operationsByTag.records.upsertRecordWithID({
1076
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1077
- queryParams: options,
1333
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1334
+ queryParams: { columns, ifVersion },
1078
1335
  body: record,
1079
1336
  ...this.extraProps
1080
1337
  });
1081
1338
  }
1082
- deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
1339
+ deleteRecord({
1340
+ workspace,
1341
+ region,
1342
+ database,
1343
+ branch,
1344
+ table,
1345
+ id,
1346
+ columns
1347
+ }) {
1083
1348
  return operationsByTag.records.deleteRecord({
1084
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1085
- queryParams: options,
1086
- ...this.extraProps
1087
- });
1088
- }
1089
- getRecord(workspace, database, branch, tableName, recordId, options = {}) {
1090
- return operationsByTag.records.getRecord({
1091
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1092
- queryParams: options,
1349
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1350
+ queryParams: { columns },
1093
1351
  ...this.extraProps
1094
1352
  });
1095
1353
  }
1096
- bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
1354
+ bulkInsertTableRecords({
1355
+ workspace,
1356
+ region,
1357
+ database,
1358
+ branch,
1359
+ table,
1360
+ records,
1361
+ columns
1362
+ }) {
1097
1363
  return operationsByTag.records.bulkInsertTableRecords({
1098
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1099
- queryParams: options,
1364
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1365
+ queryParams: { columns },
1100
1366
  body: { records },
1101
1367
  ...this.extraProps
1102
1368
  });
1103
1369
  }
1104
- queryTable(workspace, database, branch, tableName, query) {
1105
- return operationsByTag.records.queryTable({
1106
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1107
- body: query,
1108
- ...this.extraProps
1109
- });
1110
- }
1111
- searchTable(workspace, database, branch, tableName, query) {
1112
- return operationsByTag.records.searchTable({
1113
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1114
- body: query,
1115
- ...this.extraProps
1116
- });
1117
- }
1118
- searchBranch(workspace, database, branch, query) {
1119
- return operationsByTag.records.searchBranch({
1120
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1121
- body: query,
1122
- ...this.extraProps
1123
- });
1370
+ }
1371
+ class SearchAndFilterApi {
1372
+ constructor(extraProps) {
1373
+ this.extraProps = extraProps;
1124
1374
  }
1125
- summarizeTable(workspace, database, branch, tableName, query) {
1126
- return operationsByTag.records.summarizeTable({
1127
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1128
- body: query,
1375
+ queryTable({
1376
+ workspace,
1377
+ region,
1378
+ database,
1379
+ branch,
1380
+ table,
1381
+ filter,
1382
+ sort,
1383
+ page,
1384
+ columns
1385
+ }) {
1386
+ return operationsByTag.searchAndFilter.queryTable({
1387
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1388
+ body: { filter, sort, page, columns },
1389
+ ...this.extraProps
1390
+ });
1391
+ }
1392
+ searchTable({
1393
+ workspace,
1394
+ region,
1395
+ database,
1396
+ branch,
1397
+ table,
1398
+ query,
1399
+ fuzziness,
1400
+ target,
1401
+ prefix,
1402
+ filter,
1403
+ highlight,
1404
+ boosters
1405
+ }) {
1406
+ return operationsByTag.searchAndFilter.searchTable({
1407
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1408
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
1409
+ ...this.extraProps
1410
+ });
1411
+ }
1412
+ searchBranch({
1413
+ workspace,
1414
+ region,
1415
+ database,
1416
+ branch,
1417
+ tables,
1418
+ query,
1419
+ fuzziness,
1420
+ prefix,
1421
+ highlight
1422
+ }) {
1423
+ return operationsByTag.searchAndFilter.searchBranch({
1424
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1425
+ body: { tables, query, fuzziness, prefix, highlight },
1426
+ ...this.extraProps
1427
+ });
1428
+ }
1429
+ summarizeTable({
1430
+ workspace,
1431
+ region,
1432
+ database,
1433
+ branch,
1434
+ table,
1435
+ filter,
1436
+ columns,
1437
+ summaries,
1438
+ sort,
1439
+ summariesFilter,
1440
+ page
1441
+ }) {
1442
+ return operationsByTag.searchAndFilter.summarizeTable({
1443
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1444
+ body: { filter, columns, summaries, sort, summariesFilter, page },
1445
+ ...this.extraProps
1446
+ });
1447
+ }
1448
+ aggregateTable({
1449
+ workspace,
1450
+ region,
1451
+ database,
1452
+ branch,
1453
+ table,
1454
+ filter,
1455
+ aggs
1456
+ }) {
1457
+ return operationsByTag.searchAndFilter.aggregateTable({
1458
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1459
+ body: { filter, aggs },
1129
1460
  ...this.extraProps
1130
1461
  });
1131
1462
  }
@@ -1134,123 +1465,281 @@ class MigrationRequestsApi {
1134
1465
  constructor(extraProps) {
1135
1466
  this.extraProps = extraProps;
1136
1467
  }
1137
- listMigrationRequests(workspace, database, options = {}) {
1138
- return operationsByTag.migrationRequests.listMigrationRequests({
1139
- pathParams: { workspace, dbName: database },
1140
- body: options,
1141
- ...this.extraProps
1142
- });
1143
- }
1144
- createMigrationRequest(workspace, database, options) {
1468
+ queryMigrationRequests({
1469
+ workspace,
1470
+ region,
1471
+ database,
1472
+ filter,
1473
+ sort,
1474
+ page,
1475
+ columns
1476
+ }) {
1477
+ return operationsByTag.migrationRequests.queryMigrationRequests({
1478
+ pathParams: { workspace, region, dbName: database },
1479
+ body: { filter, sort, page, columns },
1480
+ ...this.extraProps
1481
+ });
1482
+ }
1483
+ createMigrationRequest({
1484
+ workspace,
1485
+ region,
1486
+ database,
1487
+ migration
1488
+ }) {
1145
1489
  return operationsByTag.migrationRequests.createMigrationRequest({
1146
- pathParams: { workspace, dbName: database },
1147
- body: options,
1490
+ pathParams: { workspace, region, dbName: database },
1491
+ body: migration,
1148
1492
  ...this.extraProps
1149
1493
  });
1150
1494
  }
1151
- getMigrationRequest(workspace, database, migrationRequest) {
1495
+ getMigrationRequest({
1496
+ workspace,
1497
+ region,
1498
+ database,
1499
+ migrationRequest
1500
+ }) {
1152
1501
  return operationsByTag.migrationRequests.getMigrationRequest({
1153
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1502
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1154
1503
  ...this.extraProps
1155
1504
  });
1156
1505
  }
1157
- updateMigrationRequest(workspace, database, migrationRequest, options) {
1506
+ updateMigrationRequest({
1507
+ workspace,
1508
+ region,
1509
+ database,
1510
+ migrationRequest,
1511
+ update
1512
+ }) {
1158
1513
  return operationsByTag.migrationRequests.updateMigrationRequest({
1159
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1160
- body: options,
1514
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1515
+ body: update,
1161
1516
  ...this.extraProps
1162
1517
  });
1163
1518
  }
1164
- listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1519
+ listMigrationRequestsCommits({
1520
+ workspace,
1521
+ region,
1522
+ database,
1523
+ migrationRequest,
1524
+ page
1525
+ }) {
1165
1526
  return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1166
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1167
- body: options,
1527
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1528
+ body: { page },
1168
1529
  ...this.extraProps
1169
1530
  });
1170
1531
  }
1171
- compareMigrationRequest(workspace, database, migrationRequest) {
1532
+ compareMigrationRequest({
1533
+ workspace,
1534
+ region,
1535
+ database,
1536
+ migrationRequest
1537
+ }) {
1172
1538
  return operationsByTag.migrationRequests.compareMigrationRequest({
1173
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1539
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1174
1540
  ...this.extraProps
1175
1541
  });
1176
1542
  }
1177
- getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1543
+ getMigrationRequestIsMerged({
1544
+ workspace,
1545
+ region,
1546
+ database,
1547
+ migrationRequest
1548
+ }) {
1178
1549
  return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1179
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1550
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1180
1551
  ...this.extraProps
1181
1552
  });
1182
1553
  }
1183
- mergeMigrationRequest(workspace, database, migrationRequest) {
1554
+ mergeMigrationRequest({
1555
+ workspace,
1556
+ region,
1557
+ database,
1558
+ migrationRequest
1559
+ }) {
1184
1560
  return operationsByTag.migrationRequests.mergeMigrationRequest({
1185
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1561
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1186
1562
  ...this.extraProps
1187
1563
  });
1188
1564
  }
1189
1565
  }
1190
- class BranchSchemaApi {
1566
+ class MigrationsApi {
1191
1567
  constructor(extraProps) {
1192
1568
  this.extraProps = extraProps;
1193
1569
  }
1194
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
1195
- return operationsByTag.branchSchema.getBranchMigrationHistory({
1196
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1197
- body: options,
1570
+ getBranchMigrationHistory({
1571
+ workspace,
1572
+ region,
1573
+ database,
1574
+ branch,
1575
+ limit,
1576
+ startFrom
1577
+ }) {
1578
+ return operationsByTag.migrations.getBranchMigrationHistory({
1579
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1580
+ body: { limit, startFrom },
1581
+ ...this.extraProps
1582
+ });
1583
+ }
1584
+ getBranchMigrationPlan({
1585
+ workspace,
1586
+ region,
1587
+ database,
1588
+ branch,
1589
+ schema
1590
+ }) {
1591
+ return operationsByTag.migrations.getBranchMigrationPlan({
1592
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1593
+ body: schema,
1198
1594
  ...this.extraProps
1199
1595
  });
1200
1596
  }
1201
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1202
- return operationsByTag.branchSchema.executeBranchMigrationPlan({
1203
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1204
- body: migrationPlan,
1597
+ executeBranchMigrationPlan({
1598
+ workspace,
1599
+ region,
1600
+ database,
1601
+ branch,
1602
+ plan
1603
+ }) {
1604
+ return operationsByTag.migrations.executeBranchMigrationPlan({
1605
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1606
+ body: plan,
1205
1607
  ...this.extraProps
1206
1608
  });
1207
1609
  }
1208
- getBranchMigrationPlan(workspace, database, branch, schema) {
1209
- return operationsByTag.branchSchema.getBranchMigrationPlan({
1210
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1211
- body: schema,
1610
+ getBranchSchemaHistory({
1611
+ workspace,
1612
+ region,
1613
+ database,
1614
+ branch,
1615
+ page
1616
+ }) {
1617
+ return operationsByTag.migrations.getBranchSchemaHistory({
1618
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1619
+ body: { page },
1212
1620
  ...this.extraProps
1213
1621
  });
1214
1622
  }
1215
- compareBranchWithUserSchema(workspace, database, branch, schema) {
1216
- return operationsByTag.branchSchema.compareBranchWithUserSchema({
1217
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1623
+ compareBranchWithUserSchema({
1624
+ workspace,
1625
+ region,
1626
+ database,
1627
+ branch,
1628
+ schema
1629
+ }) {
1630
+ return operationsByTag.migrations.compareBranchWithUserSchema({
1631
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1218
1632
  body: { schema },
1219
1633
  ...this.extraProps
1220
1634
  });
1221
1635
  }
1222
- compareBranchSchemas(workspace, database, branch, branchName, schema) {
1223
- return operationsByTag.branchSchema.compareBranchSchemas({
1224
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1636
+ compareBranchSchemas({
1637
+ workspace,
1638
+ region,
1639
+ database,
1640
+ branch,
1641
+ compare,
1642
+ schema
1643
+ }) {
1644
+ return operationsByTag.migrations.compareBranchSchemas({
1645
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
1225
1646
  body: { schema },
1226
1647
  ...this.extraProps
1227
1648
  });
1228
1649
  }
1229
- updateBranchSchema(workspace, database, branch, migration) {
1230
- return operationsByTag.branchSchema.updateBranchSchema({
1231
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1650
+ updateBranchSchema({
1651
+ workspace,
1652
+ region,
1653
+ database,
1654
+ branch,
1655
+ migration
1656
+ }) {
1657
+ return operationsByTag.migrations.updateBranchSchema({
1658
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1232
1659
  body: migration,
1233
1660
  ...this.extraProps
1234
1661
  });
1235
1662
  }
1236
- previewBranchSchemaEdit(workspace, database, branch, migration) {
1237
- return operationsByTag.branchSchema.previewBranchSchemaEdit({
1238
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1239
- body: migration,
1663
+ previewBranchSchemaEdit({
1664
+ workspace,
1665
+ region,
1666
+ database,
1667
+ branch,
1668
+ data
1669
+ }) {
1670
+ return operationsByTag.migrations.previewBranchSchemaEdit({
1671
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1672
+ body: data,
1240
1673
  ...this.extraProps
1241
1674
  });
1242
1675
  }
1243
- applyBranchSchemaEdit(workspace, database, branch, edits) {
1244
- return operationsByTag.branchSchema.applyBranchSchemaEdit({
1245
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1676
+ applyBranchSchemaEdit({
1677
+ workspace,
1678
+ region,
1679
+ database,
1680
+ branch,
1681
+ edits
1682
+ }) {
1683
+ return operationsByTag.migrations.applyBranchSchemaEdit({
1684
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1246
1685
  body: { edits },
1247
1686
  ...this.extraProps
1248
1687
  });
1249
1688
  }
1250
- getBranchSchemaHistory(workspace, database, branch, options = {}) {
1251
- return operationsByTag.branchSchema.getBranchSchemaHistory({
1252
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1253
- body: options,
1689
+ }
1690
+ class DatabaseApi {
1691
+ constructor(extraProps) {
1692
+ this.extraProps = extraProps;
1693
+ }
1694
+ getDatabaseList({ workspace }) {
1695
+ return operationsByTag.databases.getDatabaseList({
1696
+ pathParams: { workspaceId: workspace },
1697
+ ...this.extraProps
1698
+ });
1699
+ }
1700
+ createDatabase({
1701
+ workspace,
1702
+ database,
1703
+ data
1704
+ }) {
1705
+ return operationsByTag.databases.createDatabase({
1706
+ pathParams: { workspaceId: workspace, dbName: database },
1707
+ body: data,
1708
+ ...this.extraProps
1709
+ });
1710
+ }
1711
+ deleteDatabase({
1712
+ workspace,
1713
+ database
1714
+ }) {
1715
+ return operationsByTag.databases.deleteDatabase({
1716
+ pathParams: { workspaceId: workspace, dbName: database },
1717
+ ...this.extraProps
1718
+ });
1719
+ }
1720
+ getDatabaseMetadata({
1721
+ workspace,
1722
+ database
1723
+ }) {
1724
+ return operationsByTag.databases.getDatabaseMetadata({
1725
+ pathParams: { workspaceId: workspace, dbName: database },
1726
+ ...this.extraProps
1727
+ });
1728
+ }
1729
+ updateDatabaseMetadata({
1730
+ workspace,
1731
+ database,
1732
+ metadata
1733
+ }) {
1734
+ return operationsByTag.databases.updateDatabaseMetadata({
1735
+ pathParams: { workspaceId: workspace, dbName: database },
1736
+ body: metadata,
1737
+ ...this.extraProps
1738
+ });
1739
+ }
1740
+ listRegions({ workspace }) {
1741
+ return operationsByTag.databases.listRegions({
1742
+ pathParams: { workspaceId: workspace },
1254
1743
  ...this.extraProps
1255
1744
  });
1256
1745
  }
@@ -1266,6 +1755,20 @@ class XataApiPlugin {
1266
1755
  class XataPlugin {
1267
1756
  }
1268
1757
 
1758
+ function generateUUID() {
1759
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
1760
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
1761
+ return v.toString(16);
1762
+ });
1763
+ }
1764
+
1765
+ function cleanFilter(filter) {
1766
+ if (!filter)
1767
+ return void 0;
1768
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
1769
+ return values.length > 0 ? filter : void 0;
1770
+ }
1771
+
1269
1772
  var __accessCheck$6 = (obj, member, msg) => {
1270
1773
  if (!member.has(obj))
1271
1774
  throw TypeError("Cannot " + msg);
@@ -1379,9 +1882,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
1379
1882
  setter ? setter.call(obj, value) : member.set(obj, value);
1380
1883
  return value;
1381
1884
  };
1382
- var _table$1, _repository, _data;
1885
+ var __privateMethod$3 = (obj, member, method) => {
1886
+ __accessCheck$5(obj, member, "access private method");
1887
+ return method;
1888
+ };
1889
+ var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
1383
1890
  const _Query = class {
1384
1891
  constructor(repository, table, data, rawParent) {
1892
+ __privateAdd$5(this, _cleanFilterConstraint);
1385
1893
  __privateAdd$5(this, _table$1, void 0);
1386
1894
  __privateAdd$5(this, _repository, void 0);
1387
1895
  __privateAdd$5(this, _data, { filter: {} });
@@ -1400,7 +1908,7 @@ const _Query = class {
1400
1908
  __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
1401
1909
  __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
1402
1910
  __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
1403
- __privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
1911
+ __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
1404
1912
  __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
1405
1913
  __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
1406
1914
  this.any = this.any.bind(this);
@@ -1438,22 +1946,17 @@ const _Query = class {
1438
1946
  }
1439
1947
  filter(a, b) {
1440
1948
  if (arguments.length === 1) {
1441
- const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({ [column]: constraint }));
1949
+ const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
1950
+ [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
1951
+ }));
1442
1952
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1443
1953
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1444
1954
  } else {
1445
- const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.defaultFilter(a, b) }] : void 0;
1955
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
1446
1956
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1447
1957
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1448
1958
  }
1449
1959
  }
1450
- defaultFilter(column, value) {
1451
- const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
1452
- if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
1453
- return { $includes: value };
1454
- }
1455
- return value;
1456
- }
1457
1960
  sort(column, direction = "asc") {
1458
1961
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1459
1962
  const sort = [...originalSort, { column, direction }];
@@ -1521,6 +2024,16 @@ const _Query = class {
1521
2024
  throw new Error("No results found.");
1522
2025
  return records[0];
1523
2026
  }
2027
+ async summarize(params = {}) {
2028
+ const { summaries, summariesFilter, ...options } = params;
2029
+ const query = new _Query(
2030
+ __privateGet$5(this, _repository),
2031
+ __privateGet$5(this, _table$1),
2032
+ options,
2033
+ __privateGet$5(this, _data)
2034
+ );
2035
+ return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
2036
+ }
1524
2037
  cache(ttl) {
1525
2038
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1526
2039
  }
@@ -1544,9 +2057,20 @@ let Query = _Query;
1544
2057
  _table$1 = new WeakMap();
1545
2058
  _repository = new WeakMap();
1546
2059
  _data = new WeakMap();
2060
+ _cleanFilterConstraint = new WeakSet();
2061
+ cleanFilterConstraint_fn = function(column, value) {
2062
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
2063
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
2064
+ return { $includes: value };
2065
+ }
2066
+ if (columnType === "link" && isObject(value) && isString(value.id)) {
2067
+ return value.id;
2068
+ }
2069
+ return value;
2070
+ };
1547
2071
  function cleanParent(data, parent) {
1548
2072
  if (isCursorPaginationOptions(data.pagination)) {
1549
- return { ...parent, sorting: void 0, filter: void 0 };
2073
+ return { ...parent, sort: void 0, filter: void 0 };
1550
2074
  }
1551
2075
  return parent;
1552
2076
  }
@@ -1631,10 +2155,13 @@ class RestRepository extends Query {
1631
2155
  __privateAdd$4(this, _schemaTables$2, void 0);
1632
2156
  __privateAdd$4(this, _trace, void 0);
1633
2157
  __privateSet$4(this, _table, options.table);
1634
- __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1635
2158
  __privateSet$4(this, _db, options.db);
1636
2159
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1637
2160
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
2161
+ __privateSet$4(this, _getFetchProps, async () => {
2162
+ const props = await options.pluginOptions.getFetchProps();
2163
+ return { ...props, sessionID: generateUUID() };
2164
+ });
1638
2165
  const trace = options.pluginOptions.trace ?? defaultTrace;
1639
2166
  __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
1640
2167
  return trace(name, fn, {
@@ -1645,8 +2172,9 @@ class RestRepository extends Query {
1645
2172
  });
1646
2173
  });
1647
2174
  }
1648
- async create(a, b, c) {
2175
+ async create(a, b, c, d) {
1649
2176
  return __privateGet$4(this, _trace).call(this, "create", async () => {
2177
+ const ifVersion = parseIfVersion(b, c, d);
1650
2178
  if (Array.isArray(a)) {
1651
2179
  if (a.length === 0)
1652
2180
  return [];
@@ -1657,13 +2185,13 @@ class RestRepository extends Query {
1657
2185
  if (a === "")
1658
2186
  throw new Error("The id can't be empty");
1659
2187
  const columns = isStringArray(c) ? c : void 0;
1660
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
2188
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
1661
2189
  }
1662
2190
  if (isObject(a) && isString(a.id)) {
1663
2191
  if (a.id === "")
1664
2192
  throw new Error("The id can't be empty");
1665
2193
  const columns = isStringArray(b) ? b : void 0;
1666
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2194
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
1667
2195
  }
1668
2196
  if (isObject(a)) {
1669
2197
  const columns = isStringArray(b) ? b : void 0;
@@ -1694,6 +2222,7 @@ class RestRepository extends Query {
1694
2222
  pathParams: {
1695
2223
  workspace: "{workspaceId}",
1696
2224
  dbBranchName: "{dbBranch}",
2225
+ region: "{region}",
1697
2226
  tableName: __privateGet$4(this, _table),
1698
2227
  recordId: id
1699
2228
  },
@@ -1701,7 +2230,7 @@ class RestRepository extends Query {
1701
2230
  ...fetchProps
1702
2231
  });
1703
2232
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1704
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2233
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1705
2234
  } catch (e) {
1706
2235
  if (isObject(e) && e.status === 404) {
1707
2236
  return null;
@@ -1731,8 +2260,9 @@ class RestRepository extends Query {
1731
2260
  return result;
1732
2261
  });
1733
2262
  }
1734
- async update(a, b, c) {
2263
+ async update(a, b, c, d) {
1735
2264
  return __privateGet$4(this, _trace).call(this, "update", async () => {
2265
+ const ifVersion = parseIfVersion(b, c, d);
1736
2266
  if (Array.isArray(a)) {
1737
2267
  if (a.length === 0)
1738
2268
  return [];
@@ -1744,18 +2274,18 @@ class RestRepository extends Query {
1744
2274
  }
1745
2275
  if (isString(a) && isObject(b)) {
1746
2276
  const columns = isStringArray(c) ? c : void 0;
1747
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
2277
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1748
2278
  }
1749
2279
  if (isObject(a) && isString(a.id)) {
1750
2280
  const columns = isStringArray(b) ? b : void 0;
1751
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2281
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
1752
2282
  }
1753
2283
  throw new Error("Invalid arguments for update method");
1754
2284
  });
1755
2285
  }
1756
- async updateOrThrow(a, b, c) {
2286
+ async updateOrThrow(a, b, c, d) {
1757
2287
  return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1758
- const result = await this.update(a, b, c);
2288
+ const result = await this.update(a, b, c, d);
1759
2289
  if (Array.isArray(result)) {
1760
2290
  const missingIds = compact(
1761
2291
  a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
@@ -1772,8 +2302,9 @@ class RestRepository extends Query {
1772
2302
  return result;
1773
2303
  });
1774
2304
  }
1775
- async createOrUpdate(a, b, c) {
2305
+ async createOrUpdate(a, b, c, d) {
1776
2306
  return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
2307
+ const ifVersion = parseIfVersion(b, c, d);
1777
2308
  if (Array.isArray(a)) {
1778
2309
  if (a.length === 0)
1779
2310
  return [];
@@ -1785,15 +2316,35 @@ class RestRepository extends Query {
1785
2316
  }
1786
2317
  if (isString(a) && isObject(b)) {
1787
2318
  const columns = isStringArray(c) ? c : void 0;
1788
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
2319
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1789
2320
  }
1790
2321
  if (isObject(a) && isString(a.id)) {
1791
2322
  const columns = isStringArray(c) ? c : void 0;
1792
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2323
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
1793
2324
  }
1794
2325
  throw new Error("Invalid arguments for createOrUpdate method");
1795
2326
  });
1796
2327
  }
2328
+ async createOrReplace(a, b, c, d) {
2329
+ return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
2330
+ const ifVersion = parseIfVersion(b, c, d);
2331
+ if (Array.isArray(a)) {
2332
+ if (a.length === 0)
2333
+ return [];
2334
+ const columns = isStringArray(b) ? b : ["*"];
2335
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
2336
+ }
2337
+ if (isString(a) && isObject(b)) {
2338
+ const columns = isStringArray(c) ? c : void 0;
2339
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
2340
+ }
2341
+ if (isObject(a) && isString(a.id)) {
2342
+ const columns = isStringArray(c) ? c : void 0;
2343
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
2344
+ }
2345
+ throw new Error("Invalid arguments for createOrReplace method");
2346
+ });
2347
+ }
1797
2348
  async delete(a, b) {
1798
2349
  return __privateGet$4(this, _trace).call(this, "delete", async () => {
1799
2350
  if (Array.isArray(a)) {
@@ -1835,7 +2386,12 @@ class RestRepository extends Query {
1835
2386
  return __privateGet$4(this, _trace).call(this, "search", async () => {
1836
2387
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1837
2388
  const { records } = await searchTable({
1838
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2389
+ pathParams: {
2390
+ workspace: "{workspaceId}",
2391
+ dbBranchName: "{dbBranch}",
2392
+ region: "{region}",
2393
+ tableName: __privateGet$4(this, _table)
2394
+ },
1839
2395
  body: {
1840
2396
  query,
1841
2397
  fuzziness: options.fuzziness,
@@ -1847,7 +2403,23 @@ class RestRepository extends Query {
1847
2403
  ...fetchProps
1848
2404
  });
1849
2405
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1850
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
2406
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
2407
+ });
2408
+ }
2409
+ async aggregate(aggs, filter) {
2410
+ return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
2411
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2412
+ const result = await aggregateTable({
2413
+ pathParams: {
2414
+ workspace: "{workspaceId}",
2415
+ dbBranchName: "{dbBranch}",
2416
+ region: "{region}",
2417
+ tableName: __privateGet$4(this, _table)
2418
+ },
2419
+ body: { aggs, filter },
2420
+ ...fetchProps
2421
+ });
2422
+ return result;
1851
2423
  });
1852
2424
  }
1853
2425
  async query(query) {
@@ -1856,24 +2428,54 @@ class RestRepository extends Query {
1856
2428
  if (cacheQuery)
1857
2429
  return new Page(query, cacheQuery.meta, cacheQuery.records);
1858
2430
  const data = query.getQueryOptions();
1859
- const body = {
1860
- filter: cleanFilter(data.filter),
1861
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1862
- page: data.pagination,
1863
- columns: data.columns
1864
- };
1865
2431
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1866
2432
  const { meta, records: objects } = await queryTable({
1867
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1868
- body,
2433
+ pathParams: {
2434
+ workspace: "{workspaceId}",
2435
+ dbBranchName: "{dbBranch}",
2436
+ region: "{region}",
2437
+ tableName: __privateGet$4(this, _table)
2438
+ },
2439
+ body: {
2440
+ filter: cleanFilter(data.filter),
2441
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2442
+ page: data.pagination,
2443
+ columns: data.columns ?? ["*"]
2444
+ },
1869
2445
  ...fetchProps
1870
2446
  });
1871
2447
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1872
- const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
2448
+ const records = objects.map(
2449
+ (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
2450
+ );
1873
2451
  await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1874
2452
  return new Page(query, meta, records);
1875
2453
  });
1876
2454
  }
2455
+ async summarizeTable(query, summaries, summariesFilter) {
2456
+ return __privateGet$4(this, _trace).call(this, "summarize", async () => {
2457
+ const data = query.getQueryOptions();
2458
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2459
+ const result = await summarizeTable({
2460
+ pathParams: {
2461
+ workspace: "{workspaceId}",
2462
+ dbBranchName: "{dbBranch}",
2463
+ region: "{region}",
2464
+ tableName: __privateGet$4(this, _table)
2465
+ },
2466
+ body: {
2467
+ filter: cleanFilter(data.filter),
2468
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2469
+ columns: data.columns,
2470
+ page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
2471
+ summaries,
2472
+ summariesFilter
2473
+ },
2474
+ ...fetchProps
2475
+ });
2476
+ return result;
2477
+ });
2478
+ }
1877
2479
  }
1878
2480
  _table = new WeakMap();
1879
2481
  _getFetchProps = new WeakMap();
@@ -1889,6 +2491,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1889
2491
  pathParams: {
1890
2492
  workspace: "{workspaceId}",
1891
2493
  dbBranchName: "{dbBranch}",
2494
+ region: "{region}",
1892
2495
  tableName: __privateGet$4(this, _table)
1893
2496
  },
1894
2497
  queryParams: { columns },
@@ -1896,32 +2499,38 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1896
2499
  ...fetchProps
1897
2500
  });
1898
2501
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1899
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2502
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1900
2503
  };
1901
2504
  _insertRecordWithId = new WeakSet();
1902
- insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
2505
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
1903
2506
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1904
2507
  const record = transformObjectLinks(object);
1905
2508
  const response = await insertRecordWithID({
1906
2509
  pathParams: {
1907
2510
  workspace: "{workspaceId}",
1908
2511
  dbBranchName: "{dbBranch}",
2512
+ region: "{region}",
1909
2513
  tableName: __privateGet$4(this, _table),
1910
2514
  recordId
1911
2515
  },
1912
2516
  body: record,
1913
- queryParams: { createOnly: true, columns },
2517
+ queryParams: { createOnly, columns, ifVersion },
1914
2518
  ...fetchProps
1915
2519
  });
1916
2520
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1917
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2521
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1918
2522
  };
1919
2523
  _bulkInsertTableRecords = new WeakSet();
1920
2524
  bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1921
2525
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1922
2526
  const records = objects.map((object) => transformObjectLinks(object));
1923
2527
  const response = await bulkInsertTableRecords({
1924
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2528
+ pathParams: {
2529
+ workspace: "{workspaceId}",
2530
+ dbBranchName: "{dbBranch}",
2531
+ region: "{region}",
2532
+ tableName: __privateGet$4(this, _table)
2533
+ },
1925
2534
  queryParams: { columns },
1926
2535
  body: { records },
1927
2536
  ...fetchProps
@@ -1930,21 +2539,27 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1930
2539
  throw new Error("Request included columns but server didn't include them");
1931
2540
  }
1932
2541
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1933
- return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
2542
+ return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
1934
2543
  };
1935
2544
  _updateRecordWithID = new WeakSet();
1936
- updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2545
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
1937
2546
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1938
2547
  const record = transformObjectLinks(object);
1939
2548
  try {
1940
2549
  const response = await updateRecordWithID({
1941
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1942
- queryParams: { columns },
2550
+ pathParams: {
2551
+ workspace: "{workspaceId}",
2552
+ dbBranchName: "{dbBranch}",
2553
+ region: "{region}",
2554
+ tableName: __privateGet$4(this, _table),
2555
+ recordId
2556
+ },
2557
+ queryParams: { columns, ifVersion },
1943
2558
  body: record,
1944
2559
  ...fetchProps
1945
2560
  });
1946
2561
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1947
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2562
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1948
2563
  } catch (e) {
1949
2564
  if (isObject(e) && e.status === 404) {
1950
2565
  return null;
@@ -1953,28 +2568,40 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1953
2568
  }
1954
2569
  };
1955
2570
  _upsertRecordWithID = new WeakSet();
1956
- upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2571
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
1957
2572
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1958
2573
  const response = await upsertRecordWithID({
1959
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1960
- queryParams: { columns },
2574
+ pathParams: {
2575
+ workspace: "{workspaceId}",
2576
+ dbBranchName: "{dbBranch}",
2577
+ region: "{region}",
2578
+ tableName: __privateGet$4(this, _table),
2579
+ recordId
2580
+ },
2581
+ queryParams: { columns, ifVersion },
1961
2582
  body: object,
1962
2583
  ...fetchProps
1963
2584
  });
1964
2585
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1965
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2586
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1966
2587
  };
1967
2588
  _deleteRecord = new WeakSet();
1968
2589
  deleteRecord_fn = async function(recordId, columns = ["*"]) {
1969
2590
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1970
2591
  try {
1971
2592
  const response = await deleteRecord({
1972
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2593
+ pathParams: {
2594
+ workspace: "{workspaceId}",
2595
+ dbBranchName: "{dbBranch}",
2596
+ region: "{region}",
2597
+ tableName: __privateGet$4(this, _table),
2598
+ recordId
2599
+ },
1973
2600
  queryParams: { columns },
1974
2601
  ...fetchProps
1975
2602
  });
1976
2603
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1977
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2604
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1978
2605
  } catch (e) {
1979
2606
  if (isObject(e) && e.status === 404) {
1980
2607
  return null;
@@ -2004,7 +2631,7 @@ getSchemaTables_fn$1 = async function() {
2004
2631
  return __privateGet$4(this, _schemaTables$2);
2005
2632
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2006
2633
  const { schema } = await getBranchDetails({
2007
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2634
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2008
2635
  ...fetchProps
2009
2636
  });
2010
2637
  __privateSet$4(this, _schemaTables$2, schema.tables);
@@ -2017,7 +2644,7 @@ const transformObjectLinks = (object) => {
2017
2644
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
2018
2645
  }, {});
2019
2646
  };
2020
- const initObject = (db, schemaTables, table, object) => {
2647
+ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2021
2648
  const result = {};
2022
2649
  const { xata, ...rest } = object ?? {};
2023
2650
  Object.assign(result, rest);
@@ -2025,6 +2652,8 @@ const initObject = (db, schemaTables, table, object) => {
2025
2652
  if (!columns)
2026
2653
  console.error(`Table ${table} not found in schema`);
2027
2654
  for (const column of columns ?? []) {
2655
+ if (!isValidColumn(selectedColumns, column))
2656
+ continue;
2028
2657
  const value = result[column.name];
2029
2658
  switch (column.type) {
2030
2659
  case "datetime": {
@@ -2041,7 +2670,17 @@ const initObject = (db, schemaTables, table, object) => {
2041
2670
  if (!linkTable) {
2042
2671
  console.error(`Failed to parse link for field ${column.name}`);
2043
2672
  } else if (isObject(value)) {
2044
- result[column.name] = initObject(db, schemaTables, linkTable, value);
2673
+ const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
2674
+ if (item === column.name) {
2675
+ return [...acc, "*"];
2676
+ }
2677
+ if (item.startsWith(`${column.name}.`)) {
2678
+ const [, ...path] = item.split(".");
2679
+ return [...acc, path.join(".")];
2680
+ }
2681
+ return acc;
2682
+ }, []);
2683
+ result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2045
2684
  } else {
2046
2685
  result[column.name] = null;
2047
2686
  }
@@ -2058,8 +2697,15 @@ const initObject = (db, schemaTables, table, object) => {
2058
2697
  result.read = function(columns2) {
2059
2698
  return db[table].read(result["id"], columns2);
2060
2699
  };
2061
- result.update = function(data, columns2) {
2062
- return db[table].update(result["id"], data, columns2);
2700
+ result.update = function(data, b, c) {
2701
+ const columns2 = isStringArray(b) ? b : ["*"];
2702
+ const ifVersion = parseIfVersion(b, c);
2703
+ return db[table].update(result["id"], data, columns2, { ifVersion });
2704
+ };
2705
+ result.replace = function(data, b, c) {
2706
+ const columns2 = isStringArray(b) ? b : ["*"];
2707
+ const ifVersion = parseIfVersion(b, c);
2708
+ return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
2063
2709
  };
2064
2710
  result.delete = function() {
2065
2711
  return db[table].delete(result["id"]);
@@ -2067,7 +2713,7 @@ const initObject = (db, schemaTables, table, object) => {
2067
2713
  result.getMetadata = function() {
2068
2714
  return xata;
2069
2715
  };
2070
- for (const prop of ["read", "update", "delete", "getMetadata"]) {
2716
+ for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
2071
2717
  Object.defineProperty(result, prop, { enumerable: false });
2072
2718
  }
2073
2719
  Object.freeze(result);
@@ -2083,11 +2729,22 @@ function extractId(value) {
2083
2729
  return value.id;
2084
2730
  return void 0;
2085
2731
  }
2086
- function cleanFilter(filter) {
2087
- if (!filter)
2088
- return void 0;
2089
- const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2090
- return values.length > 0 ? filter : void 0;
2732
+ function isValidColumn(columns, column) {
2733
+ if (columns.includes("*"))
2734
+ return true;
2735
+ if (column.type === "link") {
2736
+ const linkColumns = columns.filter((item) => item.startsWith(column.name));
2737
+ return linkColumns.length > 0;
2738
+ }
2739
+ return columns.includes(column.name);
2740
+ }
2741
+ function parseIfVersion(...args) {
2742
+ for (const arg of args) {
2743
+ if (isObject(arg) && isNumber(arg.ifVersion)) {
2744
+ return arg.ifVersion;
2745
+ }
2746
+ }
2747
+ return void 0;
2091
2748
  }
2092
2749
 
2093
2750
  var __accessCheck$3 = (obj, member, msg) => {
@@ -2254,7 +2911,7 @@ class SearchPlugin extends XataPlugin {
2254
2911
  const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
2255
2912
  return records.map((record) => {
2256
2913
  const { table = "orphan" } = record.xata;
2257
- return { table, record: initObject(this.db, schemaTables, table, record) };
2914
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
2258
2915
  });
2259
2916
  },
2260
2917
  byTable: async (query, options = {}) => {
@@ -2263,7 +2920,7 @@ class SearchPlugin extends XataPlugin {
2263
2920
  return records.reduce((acc, record) => {
2264
2921
  const { table = "orphan" } = record.xata;
2265
2922
  const items = acc[table] ?? [];
2266
- const item = initObject(this.db, schemaTables, table, record);
2923
+ const item = initObject(this.db, schemaTables, table, record, ["*"]);
2267
2924
  return { ...acc, [table]: [...items, item] };
2268
2925
  }, {});
2269
2926
  }
@@ -2276,7 +2933,7 @@ search_fn = async function(query, options, getFetchProps) {
2276
2933
  const fetchProps = await getFetchProps();
2277
2934
  const { tables, fuzziness, highlight, prefix } = options ?? {};
2278
2935
  const { records } = await searchBranch({
2279
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2936
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2280
2937
  body: { tables, query, fuzziness, prefix, highlight },
2281
2938
  ...fetchProps
2282
2939
  });
@@ -2288,7 +2945,7 @@ getSchemaTables_fn = async function(getFetchProps) {
2288
2945
  return __privateGet$1(this, _schemaTables);
2289
2946
  const fetchProps = await getFetchProps();
2290
2947
  const { schema } = await getBranchDetails({
2291
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2948
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2292
2949
  ...fetchProps
2293
2950
  });
2294
2951
  __privateSet$1(this, _schemaTables, schema.tables);
@@ -2326,14 +2983,17 @@ async function resolveXataBranch(gitBranch, options) {
2326
2983
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2327
2984
  );
2328
2985
  const [protocol, , host, , dbName] = databaseURL.split("/");
2329
- const [workspace] = host.split(".");
2986
+ const urlParts = parseWorkspacesUrlParts(host);
2987
+ if (!urlParts)
2988
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
2989
+ const { workspace, region } = urlParts;
2330
2990
  const { fallbackBranch } = getEnvironment();
2331
2991
  const { branch } = await resolveBranch({
2332
2992
  apiKey,
2333
2993
  apiUrl: databaseURL,
2334
2994
  fetchImpl: getFetchImplementation(options?.fetchImpl),
2335
2995
  workspacesApiUrl: `${protocol}//${host}`,
2336
- pathParams: { dbName, workspace },
2996
+ pathParams: { dbName, workspace, region },
2337
2997
  queryParams: { gitBranch, fallbackBranch },
2338
2998
  trace: defaultTrace
2339
2999
  });
@@ -2351,15 +3011,17 @@ async function getDatabaseBranch(branch, options) {
2351
3011
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2352
3012
  );
2353
3013
  const [protocol, , host, , database] = databaseURL.split("/");
2354
- const [workspace] = host.split(".");
2355
- const dbBranchName = `${database}:${branch}`;
3014
+ const urlParts = parseWorkspacesUrlParts(host);
3015
+ if (!urlParts)
3016
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3017
+ const { workspace, region } = urlParts;
2356
3018
  try {
2357
3019
  return await getBranchDetails({
2358
3020
  apiKey,
2359
3021
  apiUrl: databaseURL,
2360
3022
  fetchImpl: getFetchImplementation(options?.fetchImpl),
2361
3023
  workspacesApiUrl: `${protocol}//${host}`,
2362
- pathParams: { dbBranchName, workspace },
3024
+ pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
2363
3025
  trace: defaultTrace
2364
3026
  });
2365
3027
  } catch (err) {
@@ -2450,8 +3112,8 @@ const buildClient = (plugins) => {
2450
3112
  if (!databaseURL) {
2451
3113
  throw new Error("Option databaseURL is required");
2452
3114
  }
2453
- return { fetch, databaseURL, apiKey, branch, cache, trace };
2454
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
3115
+ return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID() };
3116
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
2455
3117
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2456
3118
  if (!branchValue)
2457
3119
  throw new Error("Unable to resolve branch value");
@@ -2464,7 +3126,8 @@ const buildClient = (plugins) => {
2464
3126
  const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
2465
3127
  return databaseURL + newPath;
2466
3128
  },
2467
- trace
3129
+ trace,
3130
+ clientID
2468
3131
  };
2469
3132
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2470
3133
  if (__privateGet(this, _branch))
@@ -2598,7 +3261,9 @@ exports.XataPlugin = XataPlugin;
2598
3261
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
2599
3262
  exports.addGitBranchesEntry = addGitBranchesEntry;
2600
3263
  exports.addTableColumn = addTableColumn;
3264
+ exports.aggregateTable = aggregateTable;
2601
3265
  exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
3266
+ exports.branchTransaction = branchTransaction;
2602
3267
  exports.buildClient = buildClient;
2603
3268
  exports.buildWorkerRunner = buildWorkerRunner;
2604
3269
  exports.bulkInsertTableRecords = bulkInsertTableRecords;
@@ -2613,6 +3278,11 @@ exports.createMigrationRequest = createMigrationRequest;
2613
3278
  exports.createTable = createTable;
2614
3279
  exports.createUserAPIKey = createUserAPIKey;
2615
3280
  exports.createWorkspace = createWorkspace;
3281
+ exports.dEPRECATEDcreateDatabase = dEPRECATEDcreateDatabase;
3282
+ exports.dEPRECATEDdeleteDatabase = dEPRECATEDdeleteDatabase;
3283
+ exports.dEPRECATEDgetDatabaseList = dEPRECATEDgetDatabaseList;
3284
+ exports.dEPRECATEDgetDatabaseMetadata = dEPRECATEDgetDatabaseMetadata;
3285
+ exports.dEPRECATEDupdateDatabaseMetadata = dEPRECATEDupdateDatabaseMetadata;
2616
3286
  exports.deleteBranch = deleteBranch;
2617
3287
  exports.deleteColumn = deleteColumn;
2618
3288
  exports.deleteDatabase = deleteDatabase;
@@ -2642,6 +3312,7 @@ exports.getDatabaseList = getDatabaseList;
2642
3312
  exports.getDatabaseMetadata = getDatabaseMetadata;
2643
3313
  exports.getDatabaseURL = getDatabaseURL;
2644
3314
  exports.getGitBranchesMapping = getGitBranchesMapping;
3315
+ exports.getHostUrl = getHostUrl;
2645
3316
  exports.getMigrationRequest = getMigrationRequest;
2646
3317
  exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
2647
3318
  exports.getRecord = getRecord;
@@ -2666,6 +3337,8 @@ exports.insertRecordWithID = insertRecordWithID;
2666
3337
  exports.inviteWorkspaceMember = inviteWorkspaceMember;
2667
3338
  exports.is = is;
2668
3339
  exports.isCursorPaginationOptions = isCursorPaginationOptions;
3340
+ exports.isHostProviderAlias = isHostProviderAlias;
3341
+ exports.isHostProviderBuilder = isHostProviderBuilder;
2669
3342
  exports.isIdentifiable = isIdentifiable;
2670
3343
  exports.isNot = isNot;
2671
3344
  exports.isXataRecord = isXataRecord;
@@ -2673,15 +3346,18 @@ exports.le = le;
2673
3346
  exports.lessEquals = lessEquals;
2674
3347
  exports.lessThan = lessThan;
2675
3348
  exports.lessThanEquals = lessThanEquals;
2676
- exports.listMigrationRequests = listMigrationRequests;
2677
3349
  exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
3350
+ exports.listRegions = listRegions;
2678
3351
  exports.lt = lt;
2679
3352
  exports.lte = lte;
2680
3353
  exports.mergeMigrationRequest = mergeMigrationRequest;
2681
3354
  exports.notExists = notExists;
2682
3355
  exports.operationsByTag = operationsByTag;
3356
+ exports.parseProviderString = parseProviderString;
3357
+ exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
2683
3358
  exports.pattern = pattern;
2684
3359
  exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
3360
+ exports.queryMigrationRequests = queryMigrationRequests;
2685
3361
  exports.queryTable = queryTable;
2686
3362
  exports.removeGitBranchesEntry = removeGitBranchesEntry;
2687
3363
  exports.removeWorkspaceMember = removeWorkspaceMember;