@xata.io/client 0.0.0-alpha.vecd13ea → 0.0.0-alpha.vecdf10f

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