@xata.io/client 0.0.0-alpha.vf721f5c → 0.0.0-alpha.vf76843f

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
@@ -1,25 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopNamespace(e) {
6
- if (e && e.__esModule) return e;
7
- var n = Object.create(null);
8
- if (e) {
9
- Object.keys(e).forEach(function (k) {
10
- if (k !== 'default') {
11
- var d = Object.getOwnPropertyDescriptor(e, k);
12
- Object.defineProperty(n, k, d.get ? d : {
13
- enumerable: true,
14
- get: function () { return e[k]; }
15
- });
16
- }
17
- });
18
- }
19
- n["default"] = e;
20
- return Object.freeze(n);
21
- }
22
-
23
3
  const defaultTrace = async (_name, fn, _options) => {
24
4
  return await fn({
25
5
  setAttributes: () => {
@@ -60,6 +40,9 @@ function isString(value) {
60
40
  function isStringArray(value) {
61
41
  return isDefined(value) && Array.isArray(value) && value.every(isString);
62
42
  }
43
+ function isNumber(value) {
44
+ return isDefined(value) && typeof value === "number";
45
+ }
63
46
  function toBase64(value) {
64
47
  try {
65
48
  return btoa(value);
@@ -68,6 +51,24 @@ function toBase64(value) {
68
51
  return buf.from(value).toString("base64");
69
52
  }
70
53
  }
54
+ function deepMerge(a, b) {
55
+ const result = { ...a };
56
+ for (const [key, value] of Object.entries(b)) {
57
+ if (isObject(value) && isObject(result[key])) {
58
+ result[key] = deepMerge(result[key], value);
59
+ } else {
60
+ result[key] = value;
61
+ }
62
+ }
63
+ return result;
64
+ }
65
+ function chunk(array, chunkSize) {
66
+ const result = [];
67
+ for (let i = 0; i < array.length; i += chunkSize) {
68
+ result.push(array.slice(i, i + chunkSize));
69
+ }
70
+ return result;
71
+ }
71
72
 
72
73
  function getEnvironment() {
73
74
  try {
@@ -102,6 +103,25 @@ function getEnvironment() {
102
103
  fallbackBranch: getGlobalFallbackBranch()
103
104
  };
104
105
  }
106
+ function getEnableBrowserVariable() {
107
+ try {
108
+ if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
109
+ return process.env.XATA_ENABLE_BROWSER === "true";
110
+ }
111
+ } catch (err) {
112
+ }
113
+ try {
114
+ if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
115
+ return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
116
+ }
117
+ } catch (err) {
118
+ }
119
+ try {
120
+ return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
121
+ } catch (err) {
122
+ return void 0;
123
+ }
124
+ }
105
125
  function getGlobalApiKey() {
106
126
  try {
107
127
  return XATA_API_KEY;
@@ -139,7 +159,7 @@ async function getGitBranch() {
139
159
  if (typeof require === "function") {
140
160
  return require(nodeModule).execSync(fullCmd, execOptions).trim();
141
161
  }
142
- const { execSync } = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(nodeModule);
162
+ const { execSync } = await import(nodeModule);
143
163
  return execSync(fullCmd, execOptions).toString().trim();
144
164
  } catch (err) {
145
165
  }
@@ -172,7 +192,7 @@ function getFetchImplementation(userFetch) {
172
192
  return fetchImpl;
173
193
  }
174
194
 
175
- const VERSION = "0.0.0-alpha.vf721f5c";
195
+ const VERSION = "0.0.0-alpha.vf76843f";
176
196
 
177
197
  class ErrorWithCause extends Error {
178
198
  constructor(message, options) {
@@ -229,15 +249,18 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
229
249
  return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
230
250
  };
231
251
  function buildBaseUrl({
252
+ endpoint,
232
253
  path,
233
254
  workspacesApiUrl,
234
255
  apiUrl,
235
- pathParams
256
+ pathParams = {}
236
257
  }) {
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));
258
+ if (endpoint === "dataPlane") {
259
+ const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
260
+ const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
261
+ return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
262
+ }
263
+ return `${apiUrl}${path}`;
241
264
  }
242
265
  function hostHeader(url) {
243
266
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
@@ -253,14 +276,19 @@ async function fetch$1({
253
276
  queryParams,
254
277
  fetchImpl,
255
278
  apiKey,
279
+ endpoint,
256
280
  apiUrl,
257
281
  workspacesApiUrl,
258
- trace
282
+ trace,
283
+ signal,
284
+ clientID,
285
+ sessionID,
286
+ fetchOptions = {}
259
287
  }) {
260
288
  return trace(
261
289
  `${method.toUpperCase()} ${path}`,
262
290
  async ({ setAttributes }) => {
263
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
291
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
264
292
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
265
293
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
266
294
  setAttributes({
@@ -268,15 +296,19 @@ async function fetch$1({
268
296
  [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
269
297
  });
270
298
  const response = await fetchImpl(url, {
299
+ ...fetchOptions,
271
300
  method: method.toUpperCase(),
272
301
  body: body ? JSON.stringify(body) : void 0,
273
302
  headers: {
274
303
  "Content-Type": "application/json",
275
304
  "User-Agent": `Xata client-ts/${VERSION}`,
305
+ "X-Xata-Client-ID": clientID ?? "",
306
+ "X-Xata-Session-ID": sessionID ?? "",
276
307
  ...headers,
277
308
  ...hostHeader(fullUrl),
278
309
  Authorization: `Bearer ${apiKey}`
279
- }
310
+ },
311
+ signal
280
312
  });
281
313
  if (response.status === 204) {
282
314
  return {};
@@ -312,278 +344,163 @@ function parseUrl(url) {
312
344
  }
313
345
  }
314
346
 
315
- const getUser = (variables) => fetch$1({ url: "/user", method: "get", ...variables });
316
- const updateUser = (variables) => fetch$1({ url: "/user", method: "put", ...variables });
317
- const deleteUser = (variables) => fetch$1({ url: "/user", method: "delete", ...variables });
318
- const getUserAPIKeys = (variables) => fetch$1({
319
- url: "/user/keys",
320
- method: "get",
321
- ...variables
322
- });
323
- const createUserAPIKey = (variables) => fetch$1({
324
- url: "/user/keys/{keyName}",
325
- method: "post",
326
- ...variables
327
- });
328
- const deleteUserAPIKey = (variables) => fetch$1({
329
- url: "/user/keys/{keyName}",
330
- method: "delete",
331
- ...variables
332
- });
333
- const createWorkspace = (variables) => fetch$1({
334
- url: "/workspaces",
335
- method: "post",
336
- ...variables
337
- });
338
- const getWorkspacesList = (variables) => fetch$1({
339
- url: "/workspaces",
340
- method: "get",
341
- ...variables
342
- });
343
- const getWorkspace = (variables) => fetch$1({
344
- url: "/workspaces/{workspaceId}",
345
- method: "get",
346
- ...variables
347
- });
348
- const updateWorkspace = (variables) => fetch$1({
349
- url: "/workspaces/{workspaceId}",
350
- method: "put",
351
- ...variables
352
- });
353
- const deleteWorkspace = (variables) => fetch$1({
354
- url: "/workspaces/{workspaceId}",
355
- method: "delete",
356
- ...variables
357
- });
358
- const getWorkspaceMembersList = (variables) => fetch$1({
359
- url: "/workspaces/{workspaceId}/members",
360
- method: "get",
361
- ...variables
362
- });
363
- const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
364
- const removeWorkspaceMember = (variables) => fetch$1({
365
- url: "/workspaces/{workspaceId}/members/{userId}",
366
- method: "delete",
367
- ...variables
368
- });
369
- const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
370
- const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
371
- const cancelWorkspaceMemberInvite = (variables) => fetch$1({
372
- url: "/workspaces/{workspaceId}/invites/{inviteId}",
373
- method: "delete",
374
- ...variables
375
- });
376
- const resendWorkspaceMemberInvite = (variables) => fetch$1({
377
- url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
378
- method: "post",
379
- ...variables
380
- });
381
- const acceptWorkspaceMemberInvite = (variables) => fetch$1({
382
- url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
383
- method: "post",
384
- ...variables
385
- });
386
- const getDatabaseList = (variables) => fetch$1({
387
- url: "/dbs",
388
- method: "get",
389
- ...variables
390
- });
391
- const getBranchList = (variables) => fetch$1({
392
- url: "/dbs/{dbName}",
393
- method: "get",
394
- ...variables
395
- });
396
- const createDatabase = (variables) => fetch$1({
397
- url: "/dbs/{dbName}",
398
- method: "put",
399
- ...variables
400
- });
401
- const deleteDatabase = (variables) => fetch$1({
347
+ const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
348
+
349
+ const dEPRECATEDgetDatabaseList = (variables, signal) => dataPlaneFetch({ url: "/dbs", method: "get", ...variables, signal });
350
+ const getBranchList = (variables, signal) => dataPlaneFetch({
402
351
  url: "/dbs/{dbName}",
403
- method: "delete",
404
- ...variables
405
- });
406
- const getDatabaseMetadata = (variables) => fetch$1({
407
- url: "/dbs/{dbName}/metadata",
408
- method: "get",
409
- ...variables
410
- });
411
- const updateDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
412
- const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
413
- const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
414
- const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
415
- const resolveBranch = (variables) => fetch$1({
416
- url: "/dbs/{dbName}/resolveBranch",
417
- method: "get",
418
- ...variables
419
- });
420
- const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
421
- const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
422
- const getMigrationRequest = (variables) => fetch$1({
423
- url: "/dbs/{dbName}/migrations/{mrNumber}",
424
352
  method: "get",
425
- ...variables
353
+ ...variables,
354
+ signal
426
355
  });
427
- const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
428
- const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
429
- const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
430
- const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
431
- const mergeMigrationRequest = (variables) => fetch$1({
432
- url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
433
- method: "post",
434
- ...variables
435
- });
436
- const getBranchDetails = (variables) => fetch$1({
356
+ const dEPRECATEDcreateDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
357
+ const dEPRECATEDdeleteDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "delete", ...variables, signal });
358
+ const dEPRECATEDgetDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "get", ...variables, signal });
359
+ const dEPRECATEDupdateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
360
+ const getBranchDetails = (variables, signal) => dataPlaneFetch({
437
361
  url: "/db/{dbBranchName}",
438
362
  method: "get",
439
- ...variables
363
+ ...variables,
364
+ signal
440
365
  });
441
- const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
442
- const deleteBranch = (variables) => fetch$1({
366
+ const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
367
+ const deleteBranch = (variables, signal) => dataPlaneFetch({
443
368
  url: "/db/{dbBranchName}",
444
369
  method: "delete",
445
- ...variables
370
+ ...variables,
371
+ signal
446
372
  });
447
- const updateBranchMetadata = (variables) => fetch$1({
373
+ const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
448
374
  url: "/db/{dbBranchName}/metadata",
449
375
  method: "put",
450
- ...variables
376
+ ...variables,
377
+ signal
451
378
  });
452
- const getBranchMetadata = (variables) => fetch$1({
379
+ const getBranchMetadata = (variables, signal) => dataPlaneFetch({
453
380
  url: "/db/{dbBranchName}/metadata",
454
381
  method: "get",
455
- ...variables
382
+ ...variables,
383
+ signal
456
384
  });
457
- const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
458
- const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
459
- const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
460
- const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
461
- const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
462
- const updateBranchSchema = (variables) => fetch$1({
463
- url: "/db/{dbBranchName}/schema/update",
464
- method: "post",
465
- ...variables
466
- });
467
- const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
468
- const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
469
- const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
470
- const getBranchStats = (variables) => fetch$1({
385
+ const getBranchStats = (variables, signal) => dataPlaneFetch({
471
386
  url: "/db/{dbBranchName}/stats",
472
387
  method: "get",
473
- ...variables
388
+ ...variables,
389
+ signal
474
390
  });
475
- const createTable = (variables) => fetch$1({
391
+ const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
392
+ const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
393
+ const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
394
+ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
395
+ const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
396
+ const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
397
+ const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
398
+ const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
399
+ const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
400
+ const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
401
+ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
402
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
403
+ method: "get",
404
+ ...variables,
405
+ signal
406
+ });
407
+ const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
408
+ const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
409
+ const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
410
+ const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
411
+ const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
412
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
413
+ method: "post",
414
+ ...variables,
415
+ signal
416
+ });
417
+ const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
418
+ const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
419
+ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
420
+ const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
421
+ const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
422
+ const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
423
+ const createTable = (variables, signal) => dataPlaneFetch({
476
424
  url: "/db/{dbBranchName}/tables/{tableName}",
477
425
  method: "put",
478
- ...variables
426
+ ...variables,
427
+ signal
479
428
  });
480
- const deleteTable = (variables) => fetch$1({
429
+ const deleteTable = (variables, signal) => dataPlaneFetch({
481
430
  url: "/db/{dbBranchName}/tables/{tableName}",
482
431
  method: "delete",
483
- ...variables
432
+ ...variables,
433
+ signal
484
434
  });
485
- const updateTable = (variables) => fetch$1({
486
- url: "/db/{dbBranchName}/tables/{tableName}",
487
- method: "patch",
488
- ...variables
489
- });
490
- const getTableSchema = (variables) => fetch$1({
435
+ const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
436
+ const getTableSchema = (variables, signal) => dataPlaneFetch({
491
437
  url: "/db/{dbBranchName}/tables/{tableName}/schema",
492
438
  method: "get",
493
- ...variables
439
+ ...variables,
440
+ signal
494
441
  });
495
- const setTableSchema = (variables) => fetch$1({
496
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
497
- method: "put",
498
- ...variables
499
- });
500
- const getTableColumns = (variables) => fetch$1({
442
+ const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
443
+ const getTableColumns = (variables, signal) => dataPlaneFetch({
501
444
  url: "/db/{dbBranchName}/tables/{tableName}/columns",
502
445
  method: "get",
503
- ...variables
504
- });
505
- const addTableColumn = (variables) => fetch$1({
506
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
507
- method: "post",
508
- ...variables
446
+ ...variables,
447
+ signal
509
448
  });
510
- const getColumn = (variables) => fetch$1({
449
+ const addTableColumn = (variables, signal) => dataPlaneFetch(
450
+ { url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
451
+ );
452
+ const getColumn = (variables, signal) => dataPlaneFetch({
511
453
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
512
454
  method: "get",
513
- ...variables
455
+ ...variables,
456
+ signal
514
457
  });
515
- const deleteColumn = (variables) => fetch$1({
458
+ const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
459
+ const deleteColumn = (variables, signal) => dataPlaneFetch({
516
460
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
517
461
  method: "delete",
518
- ...variables
462
+ ...variables,
463
+ signal
519
464
  });
520
- const updateColumn = (variables) => fetch$1({
521
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
522
- method: "patch",
523
- ...variables
524
- });
525
- const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
526
- const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
527
- const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
528
- const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
529
- const deleteRecord = (variables) => fetch$1({
530
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
531
- method: "delete",
532
- ...variables
533
- });
534
- const getRecord = (variables) => fetch$1({
465
+ const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
466
+ const getRecord = (variables, signal) => dataPlaneFetch({
535
467
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
536
468
  method: "get",
537
- ...variables
469
+ ...variables,
470
+ signal
538
471
  });
539
- const bulkInsertTableRecords = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables });
540
- const queryTable = (variables) => fetch$1({
472
+ const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
473
+ const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
474
+ const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
475
+ const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
476
+ const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
477
+ const queryTable = (variables, signal) => dataPlaneFetch({
541
478
  url: "/db/{dbBranchName}/tables/{tableName}/query",
542
479
  method: "post",
543
- ...variables
480
+ ...variables,
481
+ signal
544
482
  });
545
- const searchTable = (variables) => fetch$1({
546
- url: "/db/{dbBranchName}/tables/{tableName}/search",
547
- method: "post",
548
- ...variables
549
- });
550
- const searchBranch = (variables) => fetch$1({
483
+ const searchBranch = (variables, signal) => dataPlaneFetch({
551
484
  url: "/db/{dbBranchName}/search",
552
485
  method: "post",
553
- ...variables
486
+ ...variables,
487
+ signal
554
488
  });
555
- const summarizeTable = (variables) => fetch$1({
556
- url: "/db/{dbBranchName}/tables/{tableName}/summarize",
489
+ const searchTable = (variables, signal) => dataPlaneFetch({
490
+ url: "/db/{dbBranchName}/tables/{tableName}/search",
557
491
  method: "post",
558
- ...variables
492
+ ...variables,
493
+ signal
559
494
  });
560
- const operationsByTag = {
561
- users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
562
- workspaces: {
563
- createWorkspace,
564
- getWorkspacesList,
565
- getWorkspace,
566
- updateWorkspace,
567
- deleteWorkspace,
568
- getWorkspaceMembersList,
569
- updateWorkspaceMemberRole,
570
- removeWorkspaceMember,
571
- inviteWorkspaceMember,
572
- updateWorkspaceMemberInvite,
573
- cancelWorkspaceMemberInvite,
574
- resendWorkspaceMemberInvite,
575
- acceptWorkspaceMemberInvite
576
- },
495
+ const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
496
+ const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
497
+ const operationsByTag$2 = {
577
498
  database: {
578
- getDatabaseList,
579
- createDatabase,
580
- deleteDatabase,
581
- getDatabaseMetadata,
582
- updateDatabaseMetadata,
583
- getGitBranchesMapping,
584
- addGitBranchesEntry,
585
- removeGitBranchesEntry,
586
- resolveBranch
499
+ dEPRECATEDgetDatabaseList,
500
+ dEPRECATEDcreateDatabase,
501
+ dEPRECATEDdeleteDatabase,
502
+ dEPRECATEDgetDatabaseMetadata,
503
+ dEPRECATEDupdateDatabaseMetadata
587
504
  },
588
505
  branch: {
589
506
  getBranchList,
@@ -592,10 +509,35 @@ const operationsByTag = {
592
509
  deleteBranch,
593
510
  updateBranchMetadata,
594
511
  getBranchMetadata,
595
- getBranchStats
512
+ getBranchStats,
513
+ getGitBranchesMapping,
514
+ addGitBranchesEntry,
515
+ removeGitBranchesEntry,
516
+ resolveBranch
517
+ },
518
+ migrations: {
519
+ getBranchMigrationHistory,
520
+ getBranchMigrationPlan,
521
+ executeBranchMigrationPlan,
522
+ getBranchSchemaHistory,
523
+ compareBranchWithUserSchema,
524
+ compareBranchSchemas,
525
+ updateBranchSchema,
526
+ previewBranchSchemaEdit,
527
+ applyBranchSchemaEdit
528
+ },
529
+ records: {
530
+ branchTransaction,
531
+ insertRecord,
532
+ getRecord,
533
+ insertRecordWithID,
534
+ updateRecordWithID,
535
+ upsertRecordWithID,
536
+ deleteRecord,
537
+ bulkInsertTableRecords
596
538
  },
597
539
  migrationRequests: {
598
- listMigrationRequests,
540
+ queryMigrationRequests,
599
541
  createMigrationRequest,
600
542
  getMigrationRequest,
601
543
  updateMigrationRequest,
@@ -604,17 +546,6 @@ const operationsByTag = {
604
546
  getMigrationRequestIsMerged,
605
547
  mergeMigrationRequest
606
548
  },
607
- branchSchema: {
608
- getBranchMigrationHistory,
609
- executeBranchMigrationPlan,
610
- getBranchMigrationPlan,
611
- compareBranchWithUserSchema,
612
- compareBranchSchemas,
613
- updateBranchSchema,
614
- previewBranchSchemaEdit,
615
- applyBranchSchemaEdit,
616
- getBranchSchemaHistory
617
- },
618
549
  table: {
619
550
  createTable,
620
551
  deleteTable,
@@ -624,24 +555,146 @@ const operationsByTag = {
624
555
  getTableColumns,
625
556
  addTableColumn,
626
557
  getColumn,
627
- deleteColumn,
628
- updateColumn
558
+ updateColumn,
559
+ deleteColumn
629
560
  },
630
- records: {
631
- insertRecord,
632
- insertRecordWithID,
633
- updateRecordWithID,
634
- upsertRecordWithID,
635
- deleteRecord,
636
- getRecord,
637
- bulkInsertTableRecords,
638
- queryTable,
639
- searchTable,
640
- searchBranch,
641
- summarizeTable
561
+ searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
562
+ };
563
+
564
+ const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
565
+
566
+ const getUser = (variables, signal) => controlPlaneFetch({
567
+ url: "/user",
568
+ method: "get",
569
+ ...variables,
570
+ signal
571
+ });
572
+ const updateUser = (variables, signal) => controlPlaneFetch({
573
+ url: "/user",
574
+ method: "put",
575
+ ...variables,
576
+ signal
577
+ });
578
+ const deleteUser = (variables, signal) => controlPlaneFetch({
579
+ url: "/user",
580
+ method: "delete",
581
+ ...variables,
582
+ signal
583
+ });
584
+ const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
585
+ url: "/user/keys",
586
+ method: "get",
587
+ ...variables,
588
+ signal
589
+ });
590
+ const createUserAPIKey = (variables, signal) => controlPlaneFetch({
591
+ url: "/user/keys/{keyName}",
592
+ method: "post",
593
+ ...variables,
594
+ signal
595
+ });
596
+ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
597
+ url: "/user/keys/{keyName}",
598
+ method: "delete",
599
+ ...variables,
600
+ signal
601
+ });
602
+ const getWorkspacesList = (variables, signal) => controlPlaneFetch({
603
+ url: "/workspaces",
604
+ method: "get",
605
+ ...variables,
606
+ signal
607
+ });
608
+ const createWorkspace = (variables, signal) => controlPlaneFetch({
609
+ url: "/workspaces",
610
+ method: "post",
611
+ ...variables,
612
+ signal
613
+ });
614
+ const getWorkspace = (variables, signal) => controlPlaneFetch({
615
+ url: "/workspaces/{workspaceId}",
616
+ method: "get",
617
+ ...variables,
618
+ signal
619
+ });
620
+ const updateWorkspace = (variables, signal) => controlPlaneFetch({
621
+ url: "/workspaces/{workspaceId}",
622
+ method: "put",
623
+ ...variables,
624
+ signal
625
+ });
626
+ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
627
+ url: "/workspaces/{workspaceId}",
628
+ method: "delete",
629
+ ...variables,
630
+ signal
631
+ });
632
+ const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
633
+ const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
634
+ const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
635
+ url: "/workspaces/{workspaceId}/members/{userId}",
636
+ method: "delete",
637
+ ...variables,
638
+ signal
639
+ });
640
+ const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
641
+ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
642
+ const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
643
+ const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
644
+ const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
645
+ const getDatabaseList = (variables, signal) => controlPlaneFetch({
646
+ url: "/workspaces/{workspaceId}/dbs",
647
+ method: "get",
648
+ ...variables,
649
+ signal
650
+ });
651
+ const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
652
+ const deleteDatabase = (variables, signal) => controlPlaneFetch({
653
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
654
+ method: "delete",
655
+ ...variables,
656
+ signal
657
+ });
658
+ const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
659
+ const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
660
+ const listRegions = (variables, signal) => controlPlaneFetch({
661
+ url: "/workspaces/{workspaceId}/regions",
662
+ method: "get",
663
+ ...variables,
664
+ signal
665
+ });
666
+ const operationsByTag$1 = {
667
+ users: { getUser, updateUser, deleteUser },
668
+ authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
669
+ workspaces: {
670
+ getWorkspacesList,
671
+ createWorkspace,
672
+ getWorkspace,
673
+ updateWorkspace,
674
+ deleteWorkspace,
675
+ getWorkspaceMembersList,
676
+ updateWorkspaceMemberRole,
677
+ removeWorkspaceMember
678
+ },
679
+ invites: {
680
+ inviteWorkspaceMember,
681
+ updateWorkspaceMemberInvite,
682
+ cancelWorkspaceMemberInvite,
683
+ acceptWorkspaceMemberInvite,
684
+ resendWorkspaceMemberInvite
685
+ },
686
+ databases: {
687
+ getDatabaseList,
688
+ createDatabase,
689
+ deleteDatabase,
690
+ getDatabaseMetadata,
691
+ updateDatabaseMetadata,
692
+ listRegions
642
693
  }
643
694
  };
644
695
 
696
+ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
697
+
645
698
  function getHostUrl(provider, type) {
646
699
  if (isHostProviderAlias(provider)) {
647
700
  return providers[provider][type];
@@ -653,11 +706,11 @@ function getHostUrl(provider, type) {
653
706
  const providers = {
654
707
  production: {
655
708
  main: "https://api.xata.io",
656
- workspaces: "https://{workspaceId}.xata.sh"
709
+ workspaces: "https://{workspaceId}.{region}.xata.sh"
657
710
  },
658
711
  staging: {
659
712
  main: "https://staging.xatabase.co",
660
- workspaces: "https://{workspaceId}.staging.xatabase.co"
713
+ workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
661
714
  }
662
715
  };
663
716
  function isHostProviderAlias(alias) {
@@ -666,6 +719,25 @@ function isHostProviderAlias(alias) {
666
719
  function isHostProviderBuilder(builder) {
667
720
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
668
721
  }
722
+ function parseProviderString(provider = "production") {
723
+ if (isHostProviderAlias(provider)) {
724
+ return provider;
725
+ }
726
+ const [main, workspaces] = provider.split(",");
727
+ if (!main || !workspaces)
728
+ return null;
729
+ return { main, workspaces };
730
+ }
731
+ function parseWorkspacesUrlParts(url) {
732
+ if (!isString(url))
733
+ return null;
734
+ const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
735
+ const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
736
+ const match = url.match(regex) || url.match(regexStaging);
737
+ if (!match)
738
+ return null;
739
+ return { workspace: match[1], region: match[2] ?? "eu-west-1" };
740
+ }
669
741
 
670
742
  var __accessCheck$7 = (obj, member, msg) => {
671
743
  if (!member.has(obj))
@@ -709,21 +781,41 @@ class XataApiClient {
709
781
  __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
710
782
  return __privateGet$7(this, _namespaces).user;
711
783
  }
784
+ get authentication() {
785
+ if (!__privateGet$7(this, _namespaces).authentication)
786
+ __privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
787
+ return __privateGet$7(this, _namespaces).authentication;
788
+ }
712
789
  get workspaces() {
713
790
  if (!__privateGet$7(this, _namespaces).workspaces)
714
791
  __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
715
792
  return __privateGet$7(this, _namespaces).workspaces;
716
793
  }
717
- get databases() {
718
- if (!__privateGet$7(this, _namespaces).databases)
719
- __privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
720
- return __privateGet$7(this, _namespaces).databases;
794
+ get invites() {
795
+ if (!__privateGet$7(this, _namespaces).invites)
796
+ __privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
797
+ return __privateGet$7(this, _namespaces).invites;
798
+ }
799
+ get database() {
800
+ if (!__privateGet$7(this, _namespaces).database)
801
+ __privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
802
+ return __privateGet$7(this, _namespaces).database;
721
803
  }
722
804
  get branches() {
723
805
  if (!__privateGet$7(this, _namespaces).branches)
724
806
  __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
725
807
  return __privateGet$7(this, _namespaces).branches;
726
808
  }
809
+ get migrations() {
810
+ if (!__privateGet$7(this, _namespaces).migrations)
811
+ __privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
812
+ return __privateGet$7(this, _namespaces).migrations;
813
+ }
814
+ get migrationRequests() {
815
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
816
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
817
+ return __privateGet$7(this, _namespaces).migrationRequests;
818
+ }
727
819
  get tables() {
728
820
  if (!__privateGet$7(this, _namespaces).tables)
729
821
  __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
@@ -734,15 +826,10 @@ class XataApiClient {
734
826
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
735
827
  return __privateGet$7(this, _namespaces).records;
736
828
  }
737
- get migrationRequests() {
738
- if (!__privateGet$7(this, _namespaces).migrationRequests)
739
- __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
740
- return __privateGet$7(this, _namespaces).migrationRequests;
741
- }
742
- get branchSchema() {
743
- if (!__privateGet$7(this, _namespaces).branchSchema)
744
- __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
745
- return __privateGet$7(this, _namespaces).branchSchema;
829
+ get searchAndFilter() {
830
+ if (!__privateGet$7(this, _namespaces).searchAndFilter)
831
+ __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
832
+ return __privateGet$7(this, _namespaces).searchAndFilter;
746
833
  }
747
834
  }
748
835
  _extraProps = new WeakMap();
@@ -754,24 +841,29 @@ class UserApi {
754
841
  getUser() {
755
842
  return operationsByTag.users.getUser({ ...this.extraProps });
756
843
  }
757
- updateUser(user) {
844
+ updateUser({ user }) {
758
845
  return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
759
846
  }
760
847
  deleteUser() {
761
848
  return operationsByTag.users.deleteUser({ ...this.extraProps });
762
849
  }
850
+ }
851
+ class AuthenticationApi {
852
+ constructor(extraProps) {
853
+ this.extraProps = extraProps;
854
+ }
763
855
  getUserAPIKeys() {
764
- return operationsByTag.users.getUserAPIKeys({ ...this.extraProps });
856
+ return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
765
857
  }
766
- createUserAPIKey(keyName) {
767
- return operationsByTag.users.createUserAPIKey({
768
- pathParams: { keyName },
858
+ createUserAPIKey({ name }) {
859
+ return operationsByTag.authentication.createUserAPIKey({
860
+ pathParams: { keyName: name },
769
861
  ...this.extraProps
770
862
  });
771
863
  }
772
- deleteUserAPIKey(keyName) {
773
- return operationsByTag.users.deleteUserAPIKey({
774
- pathParams: { keyName },
864
+ deleteUserAPIKey({ name }) {
865
+ return operationsByTag.authentication.deleteUserAPIKey({
866
+ pathParams: { keyName: name },
775
867
  ...this.extraProps
776
868
  });
777
869
  }
@@ -780,196 +872,248 @@ class WorkspaceApi {
780
872
  constructor(extraProps) {
781
873
  this.extraProps = extraProps;
782
874
  }
783
- createWorkspace(workspaceMeta) {
875
+ getWorkspacesList() {
876
+ return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
877
+ }
878
+ createWorkspace({ data }) {
784
879
  return operationsByTag.workspaces.createWorkspace({
785
- body: workspaceMeta,
880
+ body: data,
786
881
  ...this.extraProps
787
882
  });
788
883
  }
789
- getWorkspacesList() {
790
- return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
791
- }
792
- getWorkspace(workspaceId) {
884
+ getWorkspace({ workspace }) {
793
885
  return operationsByTag.workspaces.getWorkspace({
794
- pathParams: { workspaceId },
886
+ pathParams: { workspaceId: workspace },
795
887
  ...this.extraProps
796
888
  });
797
889
  }
798
- updateWorkspace(workspaceId, workspaceMeta) {
890
+ updateWorkspace({
891
+ workspace,
892
+ update
893
+ }) {
799
894
  return operationsByTag.workspaces.updateWorkspace({
800
- pathParams: { workspaceId },
801
- body: workspaceMeta,
895
+ pathParams: { workspaceId: workspace },
896
+ body: update,
802
897
  ...this.extraProps
803
898
  });
804
899
  }
805
- deleteWorkspace(workspaceId) {
900
+ deleteWorkspace({ workspace }) {
806
901
  return operationsByTag.workspaces.deleteWorkspace({
807
- pathParams: { workspaceId },
902
+ pathParams: { workspaceId: workspace },
808
903
  ...this.extraProps
809
904
  });
810
905
  }
811
- getWorkspaceMembersList(workspaceId) {
906
+ getWorkspaceMembersList({ workspace }) {
812
907
  return operationsByTag.workspaces.getWorkspaceMembersList({
813
- pathParams: { workspaceId },
908
+ pathParams: { workspaceId: workspace },
814
909
  ...this.extraProps
815
910
  });
816
911
  }
817
- updateWorkspaceMemberRole(workspaceId, userId, role) {
912
+ updateWorkspaceMemberRole({
913
+ workspace,
914
+ user,
915
+ role
916
+ }) {
818
917
  return operationsByTag.workspaces.updateWorkspaceMemberRole({
819
- pathParams: { workspaceId, userId },
918
+ pathParams: { workspaceId: workspace, userId: user },
820
919
  body: { role },
821
920
  ...this.extraProps
822
921
  });
823
922
  }
824
- removeWorkspaceMember(workspaceId, userId) {
923
+ removeWorkspaceMember({
924
+ workspace,
925
+ user
926
+ }) {
825
927
  return operationsByTag.workspaces.removeWorkspaceMember({
826
- pathParams: { workspaceId, userId },
928
+ pathParams: { workspaceId: workspace, userId: user },
827
929
  ...this.extraProps
828
930
  });
829
931
  }
830
- inviteWorkspaceMember(workspaceId, email, role) {
831
- return operationsByTag.workspaces.inviteWorkspaceMember({
832
- pathParams: { workspaceId },
932
+ }
933
+ class InvitesApi {
934
+ constructor(extraProps) {
935
+ this.extraProps = extraProps;
936
+ }
937
+ inviteWorkspaceMember({
938
+ workspace,
939
+ email,
940
+ role
941
+ }) {
942
+ return operationsByTag.invites.inviteWorkspaceMember({
943
+ pathParams: { workspaceId: workspace },
833
944
  body: { email, role },
834
945
  ...this.extraProps
835
946
  });
836
947
  }
837
- updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
838
- return operationsByTag.workspaces.updateWorkspaceMemberInvite({
839
- pathParams: { workspaceId, inviteId },
948
+ updateWorkspaceMemberInvite({
949
+ workspace,
950
+ invite,
951
+ role
952
+ }) {
953
+ return operationsByTag.invites.updateWorkspaceMemberInvite({
954
+ pathParams: { workspaceId: workspace, inviteId: invite },
840
955
  body: { role },
841
956
  ...this.extraProps
842
957
  });
843
958
  }
844
- cancelWorkspaceMemberInvite(workspaceId, inviteId) {
845
- return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
846
- pathParams: { workspaceId, inviteId },
959
+ cancelWorkspaceMemberInvite({
960
+ workspace,
961
+ invite
962
+ }) {
963
+ return operationsByTag.invites.cancelWorkspaceMemberInvite({
964
+ pathParams: { workspaceId: workspace, inviteId: invite },
847
965
  ...this.extraProps
848
966
  });
849
967
  }
850
- resendWorkspaceMemberInvite(workspaceId, inviteId) {
851
- return operationsByTag.workspaces.resendWorkspaceMemberInvite({
852
- pathParams: { workspaceId, inviteId },
968
+ acceptWorkspaceMemberInvite({
969
+ workspace,
970
+ key
971
+ }) {
972
+ return operationsByTag.invites.acceptWorkspaceMemberInvite({
973
+ pathParams: { workspaceId: workspace, inviteKey: key },
853
974
  ...this.extraProps
854
975
  });
855
976
  }
856
- acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
857
- return operationsByTag.workspaces.acceptWorkspaceMemberInvite({
858
- pathParams: { workspaceId, inviteKey },
977
+ resendWorkspaceMemberInvite({
978
+ workspace,
979
+ invite
980
+ }) {
981
+ return operationsByTag.invites.resendWorkspaceMemberInvite({
982
+ pathParams: { workspaceId: workspace, inviteId: invite },
859
983
  ...this.extraProps
860
984
  });
861
985
  }
862
986
  }
863
- class DatabaseApi {
987
+ class BranchApi {
864
988
  constructor(extraProps) {
865
989
  this.extraProps = extraProps;
866
990
  }
867
- getDatabaseList(workspace) {
868
- return operationsByTag.database.getDatabaseList({
869
- pathParams: { workspace },
870
- ...this.extraProps
871
- });
872
- }
873
- createDatabase(workspace, dbName, options = {}) {
874
- return operationsByTag.database.createDatabase({
875
- pathParams: { workspace, dbName },
876
- body: options,
877
- ...this.extraProps
878
- });
879
- }
880
- deleteDatabase(workspace, dbName) {
881
- return operationsByTag.database.deleteDatabase({
882
- pathParams: { workspace, dbName },
883
- ...this.extraProps
884
- });
885
- }
886
- getDatabaseMetadata(workspace, dbName) {
887
- return operationsByTag.database.getDatabaseMetadata({
888
- pathParams: { workspace, dbName },
889
- ...this.extraProps
890
- });
891
- }
892
- updateDatabaseMetadata(workspace, dbName, options = {}) {
893
- return operationsByTag.database.updateDatabaseMetadata({
894
- pathParams: { workspace, dbName },
895
- body: options,
991
+ getBranchList({
992
+ workspace,
993
+ region,
994
+ database
995
+ }) {
996
+ return operationsByTag.branch.getBranchList({
997
+ pathParams: { workspace, region, dbName: database },
896
998
  ...this.extraProps
897
999
  });
898
1000
  }
899
- getGitBranchesMapping(workspace, dbName) {
900
- return operationsByTag.database.getGitBranchesMapping({
901
- pathParams: { workspace, dbName },
1001
+ getBranchDetails({
1002
+ workspace,
1003
+ region,
1004
+ database,
1005
+ branch
1006
+ }) {
1007
+ return operationsByTag.branch.getBranchDetails({
1008
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
902
1009
  ...this.extraProps
903
1010
  });
904
1011
  }
905
- addGitBranchesEntry(workspace, dbName, body) {
906
- return operationsByTag.database.addGitBranchesEntry({
907
- pathParams: { workspace, dbName },
908
- body,
1012
+ createBranch({
1013
+ workspace,
1014
+ region,
1015
+ database,
1016
+ branch,
1017
+ from,
1018
+ metadata
1019
+ }) {
1020
+ return operationsByTag.branch.createBranch({
1021
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1022
+ body: { from, metadata },
909
1023
  ...this.extraProps
910
1024
  });
911
1025
  }
912
- removeGitBranchesEntry(workspace, dbName, gitBranch) {
913
- return operationsByTag.database.removeGitBranchesEntry({
914
- pathParams: { workspace, dbName },
915
- queryParams: { gitBranch },
1026
+ deleteBranch({
1027
+ workspace,
1028
+ region,
1029
+ database,
1030
+ branch
1031
+ }) {
1032
+ return operationsByTag.branch.deleteBranch({
1033
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
916
1034
  ...this.extraProps
917
1035
  });
918
1036
  }
919
- resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
920
- return operationsByTag.database.resolveBranch({
921
- pathParams: { workspace, dbName },
922
- queryParams: { gitBranch, fallbackBranch },
1037
+ updateBranchMetadata({
1038
+ workspace,
1039
+ region,
1040
+ database,
1041
+ branch,
1042
+ metadata
1043
+ }) {
1044
+ return operationsByTag.branch.updateBranchMetadata({
1045
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1046
+ body: metadata,
923
1047
  ...this.extraProps
924
1048
  });
925
1049
  }
926
- }
927
- class BranchApi {
928
- constructor(extraProps) {
929
- this.extraProps = extraProps;
930
- }
931
- getBranchList(workspace, dbName) {
932
- return operationsByTag.branch.getBranchList({
933
- pathParams: { workspace, dbName },
1050
+ getBranchMetadata({
1051
+ workspace,
1052
+ region,
1053
+ database,
1054
+ branch
1055
+ }) {
1056
+ return operationsByTag.branch.getBranchMetadata({
1057
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
934
1058
  ...this.extraProps
935
1059
  });
936
1060
  }
937
- getBranchDetails(workspace, database, branch) {
938
- return operationsByTag.branch.getBranchDetails({
939
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1061
+ getBranchStats({
1062
+ workspace,
1063
+ region,
1064
+ database,
1065
+ branch
1066
+ }) {
1067
+ return operationsByTag.branch.getBranchStats({
1068
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
940
1069
  ...this.extraProps
941
1070
  });
942
1071
  }
943
- createBranch(workspace, database, branch, from, options = {}) {
944
- return operationsByTag.branch.createBranch({
945
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
946
- queryParams: isString(from) ? { from } : void 0,
947
- body: options,
1072
+ getGitBranchesMapping({
1073
+ workspace,
1074
+ region,
1075
+ database
1076
+ }) {
1077
+ return operationsByTag.branch.getGitBranchesMapping({
1078
+ pathParams: { workspace, region, dbName: database },
948
1079
  ...this.extraProps
949
1080
  });
950
1081
  }
951
- deleteBranch(workspace, database, branch) {
952
- return operationsByTag.branch.deleteBranch({
953
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1082
+ addGitBranchesEntry({
1083
+ workspace,
1084
+ region,
1085
+ database,
1086
+ gitBranch,
1087
+ xataBranch
1088
+ }) {
1089
+ return operationsByTag.branch.addGitBranchesEntry({
1090
+ pathParams: { workspace, region, dbName: database },
1091
+ body: { gitBranch, xataBranch },
954
1092
  ...this.extraProps
955
1093
  });
956
1094
  }
957
- updateBranchMetadata(workspace, database, branch, metadata = {}) {
958
- return operationsByTag.branch.updateBranchMetadata({
959
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
960
- body: metadata,
961
- ...this.extraProps
962
- });
963
- }
964
- getBranchMetadata(workspace, database, branch) {
965
- return operationsByTag.branch.getBranchMetadata({
966
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1095
+ removeGitBranchesEntry({
1096
+ workspace,
1097
+ region,
1098
+ database,
1099
+ gitBranch
1100
+ }) {
1101
+ return operationsByTag.branch.removeGitBranchesEntry({
1102
+ pathParams: { workspace, region, dbName: database },
1103
+ queryParams: { gitBranch },
967
1104
  ...this.extraProps
968
1105
  });
969
1106
  }
970
- getBranchStats(workspace, database, branch) {
971
- return operationsByTag.branch.getBranchStats({
972
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1107
+ resolveBranch({
1108
+ workspace,
1109
+ region,
1110
+ database,
1111
+ gitBranch,
1112
+ fallbackBranch
1113
+ }) {
1114
+ return operationsByTag.branch.resolveBranch({
1115
+ pathParams: { workspace, region, dbName: database },
1116
+ queryParams: { gitBranch, fallbackBranch },
973
1117
  ...this.extraProps
974
1118
  });
975
1119
  }
@@ -978,67 +1122,134 @@ class TableApi {
978
1122
  constructor(extraProps) {
979
1123
  this.extraProps = extraProps;
980
1124
  }
981
- createTable(workspace, database, branch, tableName) {
1125
+ createTable({
1126
+ workspace,
1127
+ region,
1128
+ database,
1129
+ branch,
1130
+ table
1131
+ }) {
982
1132
  return operationsByTag.table.createTable({
983
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1133
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
984
1134
  ...this.extraProps
985
1135
  });
986
1136
  }
987
- deleteTable(workspace, database, branch, tableName) {
1137
+ deleteTable({
1138
+ workspace,
1139
+ region,
1140
+ database,
1141
+ branch,
1142
+ table
1143
+ }) {
988
1144
  return operationsByTag.table.deleteTable({
989
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1145
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
990
1146
  ...this.extraProps
991
1147
  });
992
1148
  }
993
- updateTable(workspace, database, branch, tableName, options) {
1149
+ updateTable({
1150
+ workspace,
1151
+ region,
1152
+ database,
1153
+ branch,
1154
+ table,
1155
+ update
1156
+ }) {
994
1157
  return operationsByTag.table.updateTable({
995
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
996
- body: options,
1158
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1159
+ body: update,
997
1160
  ...this.extraProps
998
1161
  });
999
1162
  }
1000
- getTableSchema(workspace, database, branch, tableName) {
1163
+ getTableSchema({
1164
+ workspace,
1165
+ region,
1166
+ database,
1167
+ branch,
1168
+ table
1169
+ }) {
1001
1170
  return operationsByTag.table.getTableSchema({
1002
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1171
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1003
1172
  ...this.extraProps
1004
1173
  });
1005
1174
  }
1006
- setTableSchema(workspace, database, branch, tableName, options) {
1175
+ setTableSchema({
1176
+ workspace,
1177
+ region,
1178
+ database,
1179
+ branch,
1180
+ table,
1181
+ schema
1182
+ }) {
1007
1183
  return operationsByTag.table.setTableSchema({
1008
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1009
- body: options,
1184
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1185
+ body: schema,
1010
1186
  ...this.extraProps
1011
1187
  });
1012
1188
  }
1013
- getTableColumns(workspace, database, branch, tableName) {
1189
+ getTableColumns({
1190
+ workspace,
1191
+ region,
1192
+ database,
1193
+ branch,
1194
+ table
1195
+ }) {
1014
1196
  return operationsByTag.table.getTableColumns({
1015
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1197
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1016
1198
  ...this.extraProps
1017
1199
  });
1018
1200
  }
1019
- addTableColumn(workspace, database, branch, tableName, column) {
1201
+ addTableColumn({
1202
+ workspace,
1203
+ region,
1204
+ database,
1205
+ branch,
1206
+ table,
1207
+ column
1208
+ }) {
1020
1209
  return operationsByTag.table.addTableColumn({
1021
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1210
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1022
1211
  body: column,
1023
1212
  ...this.extraProps
1024
1213
  });
1025
1214
  }
1026
- getColumn(workspace, database, branch, tableName, columnName) {
1215
+ getColumn({
1216
+ workspace,
1217
+ region,
1218
+ database,
1219
+ branch,
1220
+ table,
1221
+ column
1222
+ }) {
1027
1223
  return operationsByTag.table.getColumn({
1028
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1224
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1029
1225
  ...this.extraProps
1030
1226
  });
1031
1227
  }
1032
- deleteColumn(workspace, database, branch, tableName, columnName) {
1033
- return operationsByTag.table.deleteColumn({
1034
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1228
+ updateColumn({
1229
+ workspace,
1230
+ region,
1231
+ database,
1232
+ branch,
1233
+ table,
1234
+ column,
1235
+ update
1236
+ }) {
1237
+ return operationsByTag.table.updateColumn({
1238
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1239
+ body: update,
1035
1240
  ...this.extraProps
1036
1241
  });
1037
1242
  }
1038
- updateColumn(workspace, database, branch, tableName, columnName, options) {
1039
- return operationsByTag.table.updateColumn({
1040
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1041
- body: options,
1243
+ deleteColumn({
1244
+ workspace,
1245
+ region,
1246
+ database,
1247
+ branch,
1248
+ table,
1249
+ column
1250
+ }) {
1251
+ return operationsByTag.table.deleteColumn({
1252
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1042
1253
  ...this.extraProps
1043
1254
  });
1044
1255
  }
@@ -1047,85 +1258,228 @@ class RecordsApi {
1047
1258
  constructor(extraProps) {
1048
1259
  this.extraProps = extraProps;
1049
1260
  }
1050
- insertRecord(workspace, database, branch, tableName, record, options = {}) {
1261
+ insertRecord({
1262
+ workspace,
1263
+ region,
1264
+ database,
1265
+ branch,
1266
+ table,
1267
+ record,
1268
+ columns
1269
+ }) {
1051
1270
  return operationsByTag.records.insertRecord({
1052
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1053
- queryParams: options,
1271
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1272
+ queryParams: { columns },
1054
1273
  body: record,
1055
1274
  ...this.extraProps
1056
1275
  });
1057
1276
  }
1058
- insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1277
+ getRecord({
1278
+ workspace,
1279
+ region,
1280
+ database,
1281
+ branch,
1282
+ table,
1283
+ id,
1284
+ columns
1285
+ }) {
1286
+ return operationsByTag.records.getRecord({
1287
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1288
+ queryParams: { columns },
1289
+ ...this.extraProps
1290
+ });
1291
+ }
1292
+ insertRecordWithID({
1293
+ workspace,
1294
+ region,
1295
+ database,
1296
+ branch,
1297
+ table,
1298
+ id,
1299
+ record,
1300
+ columns,
1301
+ createOnly,
1302
+ ifVersion
1303
+ }) {
1059
1304
  return operationsByTag.records.insertRecordWithID({
1060
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1061
- queryParams: options,
1305
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1306
+ queryParams: { columns, createOnly, ifVersion },
1062
1307
  body: record,
1063
1308
  ...this.extraProps
1064
1309
  });
1065
1310
  }
1066
- updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1311
+ updateRecordWithID({
1312
+ workspace,
1313
+ region,
1314
+ database,
1315
+ branch,
1316
+ table,
1317
+ id,
1318
+ record,
1319
+ columns,
1320
+ ifVersion
1321
+ }) {
1067
1322
  return operationsByTag.records.updateRecordWithID({
1068
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1069
- queryParams: options,
1323
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1324
+ queryParams: { columns, ifVersion },
1070
1325
  body: record,
1071
1326
  ...this.extraProps
1072
1327
  });
1073
1328
  }
1074
- upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1329
+ upsertRecordWithID({
1330
+ workspace,
1331
+ region,
1332
+ database,
1333
+ branch,
1334
+ table,
1335
+ id,
1336
+ record,
1337
+ columns,
1338
+ ifVersion
1339
+ }) {
1075
1340
  return operationsByTag.records.upsertRecordWithID({
1076
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1077
- queryParams: options,
1341
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1342
+ queryParams: { columns, ifVersion },
1078
1343
  body: record,
1079
1344
  ...this.extraProps
1080
1345
  });
1081
1346
  }
1082
- deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
1347
+ deleteRecord({
1348
+ workspace,
1349
+ region,
1350
+ database,
1351
+ branch,
1352
+ table,
1353
+ id,
1354
+ columns
1355
+ }) {
1083
1356
  return operationsByTag.records.deleteRecord({
1084
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1085
- queryParams: options,
1086
- ...this.extraProps
1087
- });
1088
- }
1089
- getRecord(workspace, database, branch, tableName, recordId, options = {}) {
1090
- return operationsByTag.records.getRecord({
1091
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1092
- queryParams: options,
1357
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1358
+ queryParams: { columns },
1093
1359
  ...this.extraProps
1094
1360
  });
1095
1361
  }
1096
- bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
1362
+ bulkInsertTableRecords({
1363
+ workspace,
1364
+ region,
1365
+ database,
1366
+ branch,
1367
+ table,
1368
+ records,
1369
+ columns
1370
+ }) {
1097
1371
  return operationsByTag.records.bulkInsertTableRecords({
1098
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1099
- queryParams: options,
1372
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1373
+ queryParams: { columns },
1100
1374
  body: { records },
1101
1375
  ...this.extraProps
1102
1376
  });
1103
1377
  }
1104
- queryTable(workspace, database, branch, tableName, query) {
1105
- return operationsByTag.records.queryTable({
1106
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1107
- body: query,
1108
- ...this.extraProps
1109
- });
1110
- }
1111
- searchTable(workspace, database, branch, tableName, query) {
1112
- return operationsByTag.records.searchTable({
1113
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1114
- body: query,
1378
+ branchTransaction({
1379
+ workspace,
1380
+ region,
1381
+ database,
1382
+ branch,
1383
+ operations
1384
+ }) {
1385
+ return operationsByTag.records.branchTransaction({
1386
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1387
+ body: { operations },
1115
1388
  ...this.extraProps
1116
1389
  });
1117
1390
  }
1118
- searchBranch(workspace, database, branch, query) {
1119
- return operationsByTag.records.searchBranch({
1120
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1121
- body: query,
1122
- ...this.extraProps
1123
- });
1391
+ }
1392
+ class SearchAndFilterApi {
1393
+ constructor(extraProps) {
1394
+ this.extraProps = extraProps;
1124
1395
  }
1125
- summarizeTable(workspace, database, branch, tableName, query) {
1126
- return operationsByTag.records.summarizeTable({
1127
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1128
- body: query,
1396
+ queryTable({
1397
+ workspace,
1398
+ region,
1399
+ database,
1400
+ branch,
1401
+ table,
1402
+ filter,
1403
+ sort,
1404
+ page,
1405
+ columns,
1406
+ consistency
1407
+ }) {
1408
+ return operationsByTag.searchAndFilter.queryTable({
1409
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1410
+ body: { filter, sort, page, columns, consistency },
1411
+ ...this.extraProps
1412
+ });
1413
+ }
1414
+ searchTable({
1415
+ workspace,
1416
+ region,
1417
+ database,
1418
+ branch,
1419
+ table,
1420
+ query,
1421
+ fuzziness,
1422
+ target,
1423
+ prefix,
1424
+ filter,
1425
+ highlight,
1426
+ boosters
1427
+ }) {
1428
+ return operationsByTag.searchAndFilter.searchTable({
1429
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1430
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
1431
+ ...this.extraProps
1432
+ });
1433
+ }
1434
+ searchBranch({
1435
+ workspace,
1436
+ region,
1437
+ database,
1438
+ branch,
1439
+ tables,
1440
+ query,
1441
+ fuzziness,
1442
+ prefix,
1443
+ highlight
1444
+ }) {
1445
+ return operationsByTag.searchAndFilter.searchBranch({
1446
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1447
+ body: { tables, query, fuzziness, prefix, highlight },
1448
+ ...this.extraProps
1449
+ });
1450
+ }
1451
+ summarizeTable({
1452
+ workspace,
1453
+ region,
1454
+ database,
1455
+ branch,
1456
+ table,
1457
+ filter,
1458
+ columns,
1459
+ summaries,
1460
+ sort,
1461
+ summariesFilter,
1462
+ page,
1463
+ consistency
1464
+ }) {
1465
+ return operationsByTag.searchAndFilter.summarizeTable({
1466
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1467
+ body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
1468
+ ...this.extraProps
1469
+ });
1470
+ }
1471
+ aggregateTable({
1472
+ workspace,
1473
+ region,
1474
+ database,
1475
+ branch,
1476
+ table,
1477
+ filter,
1478
+ aggs
1479
+ }) {
1480
+ return operationsByTag.searchAndFilter.aggregateTable({
1481
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1482
+ body: { filter, aggs },
1129
1483
  ...this.extraProps
1130
1484
  });
1131
1485
  }
@@ -1134,123 +1488,281 @@ class MigrationRequestsApi {
1134
1488
  constructor(extraProps) {
1135
1489
  this.extraProps = extraProps;
1136
1490
  }
1137
- listMigrationRequests(workspace, database, options = {}) {
1138
- return operationsByTag.migrationRequests.listMigrationRequests({
1139
- pathParams: { workspace, dbName: database },
1140
- body: options,
1141
- ...this.extraProps
1142
- });
1143
- }
1144
- createMigrationRequest(workspace, database, options) {
1491
+ queryMigrationRequests({
1492
+ workspace,
1493
+ region,
1494
+ database,
1495
+ filter,
1496
+ sort,
1497
+ page,
1498
+ columns
1499
+ }) {
1500
+ return operationsByTag.migrationRequests.queryMigrationRequests({
1501
+ pathParams: { workspace, region, dbName: database },
1502
+ body: { filter, sort, page, columns },
1503
+ ...this.extraProps
1504
+ });
1505
+ }
1506
+ createMigrationRequest({
1507
+ workspace,
1508
+ region,
1509
+ database,
1510
+ migration
1511
+ }) {
1145
1512
  return operationsByTag.migrationRequests.createMigrationRequest({
1146
- pathParams: { workspace, dbName: database },
1147
- body: options,
1513
+ pathParams: { workspace, region, dbName: database },
1514
+ body: migration,
1148
1515
  ...this.extraProps
1149
1516
  });
1150
1517
  }
1151
- getMigrationRequest(workspace, database, migrationRequest) {
1518
+ getMigrationRequest({
1519
+ workspace,
1520
+ region,
1521
+ database,
1522
+ migrationRequest
1523
+ }) {
1152
1524
  return operationsByTag.migrationRequests.getMigrationRequest({
1153
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1525
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1154
1526
  ...this.extraProps
1155
1527
  });
1156
1528
  }
1157
- updateMigrationRequest(workspace, database, migrationRequest, options) {
1529
+ updateMigrationRequest({
1530
+ workspace,
1531
+ region,
1532
+ database,
1533
+ migrationRequest,
1534
+ update
1535
+ }) {
1158
1536
  return operationsByTag.migrationRequests.updateMigrationRequest({
1159
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1160
- body: options,
1537
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1538
+ body: update,
1161
1539
  ...this.extraProps
1162
1540
  });
1163
1541
  }
1164
- listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1542
+ listMigrationRequestsCommits({
1543
+ workspace,
1544
+ region,
1545
+ database,
1546
+ migrationRequest,
1547
+ page
1548
+ }) {
1165
1549
  return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1166
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1167
- body: options,
1550
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1551
+ body: { page },
1168
1552
  ...this.extraProps
1169
1553
  });
1170
1554
  }
1171
- compareMigrationRequest(workspace, database, migrationRequest) {
1555
+ compareMigrationRequest({
1556
+ workspace,
1557
+ region,
1558
+ database,
1559
+ migrationRequest
1560
+ }) {
1172
1561
  return operationsByTag.migrationRequests.compareMigrationRequest({
1173
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1562
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1174
1563
  ...this.extraProps
1175
1564
  });
1176
1565
  }
1177
- getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1566
+ getMigrationRequestIsMerged({
1567
+ workspace,
1568
+ region,
1569
+ database,
1570
+ migrationRequest
1571
+ }) {
1178
1572
  return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1179
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1573
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1180
1574
  ...this.extraProps
1181
1575
  });
1182
1576
  }
1183
- mergeMigrationRequest(workspace, database, migrationRequest) {
1577
+ mergeMigrationRequest({
1578
+ workspace,
1579
+ region,
1580
+ database,
1581
+ migrationRequest
1582
+ }) {
1184
1583
  return operationsByTag.migrationRequests.mergeMigrationRequest({
1185
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1584
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1186
1585
  ...this.extraProps
1187
1586
  });
1188
1587
  }
1189
1588
  }
1190
- class BranchSchemaApi {
1589
+ class MigrationsApi {
1191
1590
  constructor(extraProps) {
1192
1591
  this.extraProps = extraProps;
1193
1592
  }
1194
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
1195
- return operationsByTag.branchSchema.getBranchMigrationHistory({
1196
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1197
- body: options,
1593
+ getBranchMigrationHistory({
1594
+ workspace,
1595
+ region,
1596
+ database,
1597
+ branch,
1598
+ limit,
1599
+ startFrom
1600
+ }) {
1601
+ return operationsByTag.migrations.getBranchMigrationHistory({
1602
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1603
+ body: { limit, startFrom },
1604
+ ...this.extraProps
1605
+ });
1606
+ }
1607
+ getBranchMigrationPlan({
1608
+ workspace,
1609
+ region,
1610
+ database,
1611
+ branch,
1612
+ schema
1613
+ }) {
1614
+ return operationsByTag.migrations.getBranchMigrationPlan({
1615
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1616
+ body: schema,
1198
1617
  ...this.extraProps
1199
1618
  });
1200
1619
  }
1201
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1202
- return operationsByTag.branchSchema.executeBranchMigrationPlan({
1203
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1204
- body: migrationPlan,
1620
+ executeBranchMigrationPlan({
1621
+ workspace,
1622
+ region,
1623
+ database,
1624
+ branch,
1625
+ plan
1626
+ }) {
1627
+ return operationsByTag.migrations.executeBranchMigrationPlan({
1628
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1629
+ body: plan,
1205
1630
  ...this.extraProps
1206
1631
  });
1207
1632
  }
1208
- getBranchMigrationPlan(workspace, database, branch, schema) {
1209
- return operationsByTag.branchSchema.getBranchMigrationPlan({
1210
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1211
- body: schema,
1633
+ getBranchSchemaHistory({
1634
+ workspace,
1635
+ region,
1636
+ database,
1637
+ branch,
1638
+ page
1639
+ }) {
1640
+ return operationsByTag.migrations.getBranchSchemaHistory({
1641
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1642
+ body: { page },
1212
1643
  ...this.extraProps
1213
1644
  });
1214
1645
  }
1215
- compareBranchWithUserSchema(workspace, database, branch, schema) {
1216
- return operationsByTag.branchSchema.compareBranchWithUserSchema({
1217
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1646
+ compareBranchWithUserSchema({
1647
+ workspace,
1648
+ region,
1649
+ database,
1650
+ branch,
1651
+ schema
1652
+ }) {
1653
+ return operationsByTag.migrations.compareBranchWithUserSchema({
1654
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1218
1655
  body: { schema },
1219
1656
  ...this.extraProps
1220
1657
  });
1221
1658
  }
1222
- compareBranchSchemas(workspace, database, branch, branchName, schema) {
1223
- return operationsByTag.branchSchema.compareBranchSchemas({
1224
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1659
+ compareBranchSchemas({
1660
+ workspace,
1661
+ region,
1662
+ database,
1663
+ branch,
1664
+ compare,
1665
+ schema
1666
+ }) {
1667
+ return operationsByTag.migrations.compareBranchSchemas({
1668
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
1225
1669
  body: { schema },
1226
1670
  ...this.extraProps
1227
1671
  });
1228
1672
  }
1229
- updateBranchSchema(workspace, database, branch, migration) {
1230
- return operationsByTag.branchSchema.updateBranchSchema({
1231
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1673
+ updateBranchSchema({
1674
+ workspace,
1675
+ region,
1676
+ database,
1677
+ branch,
1678
+ migration
1679
+ }) {
1680
+ return operationsByTag.migrations.updateBranchSchema({
1681
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1232
1682
  body: migration,
1233
1683
  ...this.extraProps
1234
1684
  });
1235
1685
  }
1236
- previewBranchSchemaEdit(workspace, database, branch, migration) {
1237
- return operationsByTag.branchSchema.previewBranchSchemaEdit({
1238
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1239
- body: migration,
1686
+ previewBranchSchemaEdit({
1687
+ workspace,
1688
+ region,
1689
+ database,
1690
+ branch,
1691
+ data
1692
+ }) {
1693
+ return operationsByTag.migrations.previewBranchSchemaEdit({
1694
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1695
+ body: data,
1240
1696
  ...this.extraProps
1241
1697
  });
1242
1698
  }
1243
- applyBranchSchemaEdit(workspace, database, branch, edits) {
1244
- return operationsByTag.branchSchema.applyBranchSchemaEdit({
1245
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1699
+ applyBranchSchemaEdit({
1700
+ workspace,
1701
+ region,
1702
+ database,
1703
+ branch,
1704
+ edits
1705
+ }) {
1706
+ return operationsByTag.migrations.applyBranchSchemaEdit({
1707
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1246
1708
  body: { edits },
1247
1709
  ...this.extraProps
1248
1710
  });
1249
1711
  }
1250
- getBranchSchemaHistory(workspace, database, branch, options = {}) {
1251
- return operationsByTag.branchSchema.getBranchSchemaHistory({
1252
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1253
- body: options,
1712
+ }
1713
+ class DatabaseApi {
1714
+ constructor(extraProps) {
1715
+ this.extraProps = extraProps;
1716
+ }
1717
+ getDatabaseList({ workspace }) {
1718
+ return operationsByTag.databases.getDatabaseList({
1719
+ pathParams: { workspaceId: workspace },
1720
+ ...this.extraProps
1721
+ });
1722
+ }
1723
+ createDatabase({
1724
+ workspace,
1725
+ database,
1726
+ data
1727
+ }) {
1728
+ return operationsByTag.databases.createDatabase({
1729
+ pathParams: { workspaceId: workspace, dbName: database },
1730
+ body: data,
1731
+ ...this.extraProps
1732
+ });
1733
+ }
1734
+ deleteDatabase({
1735
+ workspace,
1736
+ database
1737
+ }) {
1738
+ return operationsByTag.databases.deleteDatabase({
1739
+ pathParams: { workspaceId: workspace, dbName: database },
1740
+ ...this.extraProps
1741
+ });
1742
+ }
1743
+ getDatabaseMetadata({
1744
+ workspace,
1745
+ database
1746
+ }) {
1747
+ return operationsByTag.databases.getDatabaseMetadata({
1748
+ pathParams: { workspaceId: workspace, dbName: database },
1749
+ ...this.extraProps
1750
+ });
1751
+ }
1752
+ updateDatabaseMetadata({
1753
+ workspace,
1754
+ database,
1755
+ metadata
1756
+ }) {
1757
+ return operationsByTag.databases.updateDatabaseMetadata({
1758
+ pathParams: { workspaceId: workspace, dbName: database },
1759
+ body: metadata,
1760
+ ...this.extraProps
1761
+ });
1762
+ }
1763
+ listRegions({ workspace }) {
1764
+ return operationsByTag.databases.listRegions({
1765
+ pathParams: { workspaceId: workspace },
1254
1766
  ...this.extraProps
1255
1767
  });
1256
1768
  }
@@ -1266,6 +1778,20 @@ class XataApiPlugin {
1266
1778
  class XataPlugin {
1267
1779
  }
1268
1780
 
1781
+ function generateUUID() {
1782
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
1783
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
1784
+ return v.toString(16);
1785
+ });
1786
+ }
1787
+
1788
+ function cleanFilter(filter) {
1789
+ if (!filter)
1790
+ return void 0;
1791
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
1792
+ return values.length > 0 ? filter : void 0;
1793
+ }
1794
+
1269
1795
  var __accessCheck$6 = (obj, member, msg) => {
1270
1796
  if (!member.has(obj))
1271
1797
  throw TypeError("Cannot " + msg);
@@ -1298,11 +1824,11 @@ class Page {
1298
1824
  async previousPage(size, offset) {
1299
1825
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
1300
1826
  }
1301
- async firstPage(size, offset) {
1302
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
1827
+ async startPage(size, offset) {
1828
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
1303
1829
  }
1304
- async lastPage(size, offset) {
1305
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
1830
+ async endPage(size, offset) {
1831
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
1306
1832
  }
1307
1833
  hasNextPage() {
1308
1834
  return this.meta.page.more;
@@ -1314,7 +1840,7 @@ const PAGINATION_DEFAULT_SIZE = 20;
1314
1840
  const PAGINATION_MAX_OFFSET = 800;
1315
1841
  const PAGINATION_DEFAULT_OFFSET = 0;
1316
1842
  function isCursorPaginationOptions(options) {
1317
- return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
1843
+ return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
1318
1844
  }
1319
1845
  const _RecordArray = class extends Array {
1320
1846
  constructor(...args) {
@@ -1346,12 +1872,12 @@ const _RecordArray = class extends Array {
1346
1872
  const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
1347
1873
  return new _RecordArray(newPage);
1348
1874
  }
1349
- async firstPage(size, offset) {
1350
- const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
1875
+ async startPage(size, offset) {
1876
+ const newPage = await __privateGet$6(this, _page).startPage(size, offset);
1351
1877
  return new _RecordArray(newPage);
1352
1878
  }
1353
- async lastPage(size, offset) {
1354
- const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
1879
+ async endPage(size, offset) {
1880
+ const newPage = await __privateGet$6(this, _page).endPage(size, offset);
1355
1881
  return new _RecordArray(newPage);
1356
1882
  }
1357
1883
  hasNextPage() {
@@ -1405,9 +1931,10 @@ const _Query = class {
1405
1931
  __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
1406
1932
  __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
1407
1933
  __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
1408
- __privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
1934
+ __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
1409
1935
  __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
1410
1936
  __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
1937
+ __privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
1411
1938
  this.any = this.any.bind(this);
1412
1939
  this.all = this.all.bind(this);
1413
1940
  this.not = this.not.bind(this);
@@ -1521,19 +2048,29 @@ const _Query = class {
1521
2048
  throw new Error("No results found.");
1522
2049
  return records[0];
1523
2050
  }
2051
+ async summarize(params = {}) {
2052
+ const { summaries, summariesFilter, ...options } = params;
2053
+ const query = new _Query(
2054
+ __privateGet$5(this, _repository),
2055
+ __privateGet$5(this, _table$1),
2056
+ options,
2057
+ __privateGet$5(this, _data)
2058
+ );
2059
+ return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
2060
+ }
1524
2061
  cache(ttl) {
1525
2062
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1526
2063
  }
1527
2064
  nextPage(size, offset) {
1528
- return this.firstPage(size, offset);
2065
+ return this.startPage(size, offset);
1529
2066
  }
1530
2067
  previousPage(size, offset) {
1531
- return this.firstPage(size, offset);
2068
+ return this.startPage(size, offset);
1532
2069
  }
1533
- firstPage(size, offset) {
2070
+ startPage(size, offset) {
1534
2071
  return this.getPaginated({ pagination: { size, offset } });
1535
2072
  }
1536
- lastPage(size, offset) {
2073
+ endPage(size, offset) {
1537
2074
  return this.getPaginated({ pagination: { size, offset, before: "end" } });
1538
2075
  }
1539
2076
  hasNextPage() {
@@ -1557,7 +2094,7 @@ cleanFilterConstraint_fn = function(column, value) {
1557
2094
  };
1558
2095
  function cleanParent(data, parent) {
1559
2096
  if (isCursorPaginationOptions(data.pagination)) {
1560
- return { ...parent, sorting: void 0, filter: void 0 };
2097
+ return { ...parent, sort: void 0, filter: void 0 };
1561
2098
  }
1562
2099
  return parent;
1563
2100
  }
@@ -1616,7 +2153,8 @@ var __privateMethod$2 = (obj, member, method) => {
1616
2153
  __accessCheck$4(obj, member, "access private method");
1617
2154
  return method;
1618
2155
  };
1619
- var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
2156
+ var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _insertRecords, insertRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _updateRecords, updateRecords_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _deleteRecords, deleteRecords_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
2157
+ const BULK_OPERATION_MAX_SIZE = 1e3;
1620
2158
  class Repository extends Query {
1621
2159
  }
1622
2160
  class RestRepository extends Query {
@@ -1628,10 +2166,12 @@ class RestRepository extends Query {
1628
2166
  );
1629
2167
  __privateAdd$4(this, _insertRecordWithoutId);
1630
2168
  __privateAdd$4(this, _insertRecordWithId);
1631
- __privateAdd$4(this, _bulkInsertTableRecords);
2169
+ __privateAdd$4(this, _insertRecords);
1632
2170
  __privateAdd$4(this, _updateRecordWithID);
2171
+ __privateAdd$4(this, _updateRecords);
1633
2172
  __privateAdd$4(this, _upsertRecordWithID);
1634
2173
  __privateAdd$4(this, _deleteRecord);
2174
+ __privateAdd$4(this, _deleteRecords);
1635
2175
  __privateAdd$4(this, _setCacheQuery);
1636
2176
  __privateAdd$4(this, _getCacheQuery);
1637
2177
  __privateAdd$4(this, _getSchemaTables$1);
@@ -1642,10 +2182,13 @@ class RestRepository extends Query {
1642
2182
  __privateAdd$4(this, _schemaTables$2, void 0);
1643
2183
  __privateAdd$4(this, _trace, void 0);
1644
2184
  __privateSet$4(this, _table, options.table);
1645
- __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1646
2185
  __privateSet$4(this, _db, options.db);
1647
2186
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1648
2187
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
2188
+ __privateSet$4(this, _getFetchProps, async () => {
2189
+ const props = await options.pluginOptions.getFetchProps();
2190
+ return { ...props, sessionID: generateUUID() };
2191
+ });
1649
2192
  const trace = options.pluginOptions.trace ?? defaultTrace;
1650
2193
  __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
1651
2194
  return trace(name, fn, {
@@ -1656,25 +2199,28 @@ class RestRepository extends Query {
1656
2199
  });
1657
2200
  });
1658
2201
  }
1659
- async create(a, b, c) {
2202
+ async create(a, b, c, d) {
1660
2203
  return __privateGet$4(this, _trace).call(this, "create", async () => {
2204
+ const ifVersion = parseIfVersion(b, c, d);
1661
2205
  if (Array.isArray(a)) {
1662
2206
  if (a.length === 0)
1663
2207
  return [];
1664
- const columns = isStringArray(b) ? b : void 0;
1665
- return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
2208
+ const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
2209
+ const columns = isStringArray(b) ? b : ["*"];
2210
+ const result = await this.read(ids, columns);
2211
+ return result;
1666
2212
  }
1667
2213
  if (isString(a) && isObject(b)) {
1668
2214
  if (a === "")
1669
2215
  throw new Error("The id can't be empty");
1670
2216
  const columns = isStringArray(c) ? c : void 0;
1671
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
2217
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
1672
2218
  }
1673
2219
  if (isObject(a) && isString(a.id)) {
1674
2220
  if (a.id === "")
1675
2221
  throw new Error("The id can't be empty");
1676
2222
  const columns = isStringArray(b) ? b : void 0;
1677
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2223
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
1678
2224
  }
1679
2225
  if (isObject(a)) {
1680
2226
  const columns = isStringArray(b) ? b : void 0;
@@ -1705,6 +2251,7 @@ class RestRepository extends Query {
1705
2251
  pathParams: {
1706
2252
  workspace: "{workspaceId}",
1707
2253
  dbBranchName: "{dbBranch}",
2254
+ region: "{region}",
1708
2255
  tableName: __privateGet$4(this, _table),
1709
2256
  recordId: id
1710
2257
  },
@@ -1742,31 +2289,36 @@ class RestRepository extends Query {
1742
2289
  return result;
1743
2290
  });
1744
2291
  }
1745
- async update(a, b, c) {
2292
+ async update(a, b, c, d) {
1746
2293
  return __privateGet$4(this, _trace).call(this, "update", async () => {
2294
+ const ifVersion = parseIfVersion(b, c, d);
1747
2295
  if (Array.isArray(a)) {
1748
2296
  if (a.length === 0)
1749
2297
  return [];
1750
- if (a.length > 100) {
1751
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1752
- }
2298
+ const existing = await this.read(a, ["id"]);
2299
+ const updates = a.filter((_item, index) => existing[index] !== null);
2300
+ await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
2301
+ ifVersion,
2302
+ upsert: false
2303
+ });
1753
2304
  const columns = isStringArray(b) ? b : ["*"];
1754
- return Promise.all(a.map((object) => this.update(object, columns)));
2305
+ const result = await this.read(a, columns);
2306
+ return result;
1755
2307
  }
1756
2308
  if (isString(a) && isObject(b)) {
1757
2309
  const columns = isStringArray(c) ? c : void 0;
1758
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
2310
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1759
2311
  }
1760
2312
  if (isObject(a) && isString(a.id)) {
1761
2313
  const columns = isStringArray(b) ? b : void 0;
1762
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2314
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
1763
2315
  }
1764
2316
  throw new Error("Invalid arguments for update method");
1765
2317
  });
1766
2318
  }
1767
- async updateOrThrow(a, b, c) {
2319
+ async updateOrThrow(a, b, c, d) {
1768
2320
  return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1769
- const result = await this.update(a, b, c);
2321
+ const result = await this.update(a, b, c, d);
1770
2322
  if (Array.isArray(result)) {
1771
2323
  const missingIds = compact(
1772
2324
  a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
@@ -1783,37 +2335,69 @@ class RestRepository extends Query {
1783
2335
  return result;
1784
2336
  });
1785
2337
  }
1786
- async createOrUpdate(a, b, c) {
2338
+ async createOrUpdate(a, b, c, d) {
1787
2339
  return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
2340
+ const ifVersion = parseIfVersion(b, c, d);
1788
2341
  if (Array.isArray(a)) {
1789
2342
  if (a.length === 0)
1790
2343
  return [];
1791
- if (a.length > 100) {
1792
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1793
- }
2344
+ await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
2345
+ ifVersion,
2346
+ upsert: true
2347
+ });
1794
2348
  const columns = isStringArray(b) ? b : ["*"];
1795
- return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
2349
+ const result = await this.read(a, columns);
2350
+ return result;
1796
2351
  }
1797
2352
  if (isString(a) && isObject(b)) {
1798
2353
  const columns = isStringArray(c) ? c : void 0;
1799
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
2354
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1800
2355
  }
1801
2356
  if (isObject(a) && isString(a.id)) {
1802
2357
  const columns = isStringArray(c) ? c : void 0;
1803
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2358
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
1804
2359
  }
1805
2360
  throw new Error("Invalid arguments for createOrUpdate method");
1806
2361
  });
1807
2362
  }
2363
+ async createOrReplace(a, b, c, d) {
2364
+ return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
2365
+ const ifVersion = parseIfVersion(b, c, d);
2366
+ if (Array.isArray(a)) {
2367
+ if (a.length === 0)
2368
+ return [];
2369
+ const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
2370
+ const columns = isStringArray(b) ? b : ["*"];
2371
+ const result = await this.read(ids, columns);
2372
+ return result;
2373
+ }
2374
+ if (isString(a) && isObject(b)) {
2375
+ const columns = isStringArray(c) ? c : void 0;
2376
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
2377
+ }
2378
+ if (isObject(a) && isString(a.id)) {
2379
+ const columns = isStringArray(c) ? c : void 0;
2380
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
2381
+ }
2382
+ throw new Error("Invalid arguments for createOrReplace method");
2383
+ });
2384
+ }
1808
2385
  async delete(a, b) {
1809
2386
  return __privateGet$4(this, _trace).call(this, "delete", async () => {
1810
2387
  if (Array.isArray(a)) {
1811
2388
  if (a.length === 0)
1812
2389
  return [];
1813
- if (a.length > 100) {
1814
- console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1815
- }
1816
- return Promise.all(a.map((id) => this.delete(id, b)));
2390
+ const ids = a.map((o) => {
2391
+ if (isString(o))
2392
+ return o;
2393
+ if (isString(o.id))
2394
+ return o.id;
2395
+ throw new Error("Invalid arguments for delete method");
2396
+ });
2397
+ const columns = isStringArray(b) ? b : ["*"];
2398
+ const result = await this.read(a, columns);
2399
+ await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
2400
+ return result;
1817
2401
  }
1818
2402
  if (isString(a)) {
1819
2403
  return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
@@ -1846,7 +2430,12 @@ class RestRepository extends Query {
1846
2430
  return __privateGet$4(this, _trace).call(this, "search", async () => {
1847
2431
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1848
2432
  const { records } = await searchTable({
1849
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2433
+ pathParams: {
2434
+ workspace: "{workspaceId}",
2435
+ dbBranchName: "{dbBranch}",
2436
+ region: "{region}",
2437
+ tableName: __privateGet$4(this, _table)
2438
+ },
1850
2439
  body: {
1851
2440
  query,
1852
2441
  fuzziness: options.fuzziness,
@@ -1861,22 +2450,43 @@ class RestRepository extends Query {
1861
2450
  return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
1862
2451
  });
1863
2452
  }
2453
+ async aggregate(aggs, filter) {
2454
+ return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
2455
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2456
+ const result = await aggregateTable({
2457
+ pathParams: {
2458
+ workspace: "{workspaceId}",
2459
+ dbBranchName: "{dbBranch}",
2460
+ region: "{region}",
2461
+ tableName: __privateGet$4(this, _table)
2462
+ },
2463
+ body: { aggs, filter },
2464
+ ...fetchProps
2465
+ });
2466
+ return result;
2467
+ });
2468
+ }
1864
2469
  async query(query) {
1865
2470
  return __privateGet$4(this, _trace).call(this, "query", async () => {
1866
2471
  const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1867
2472
  if (cacheQuery)
1868
2473
  return new Page(query, cacheQuery.meta, cacheQuery.records);
1869
2474
  const data = query.getQueryOptions();
1870
- const body = {
1871
- filter: cleanFilter(data.filter),
1872
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1873
- page: data.pagination,
1874
- columns: data.columns
1875
- };
1876
2475
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1877
2476
  const { meta, records: objects } = await queryTable({
1878
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1879
- body,
2477
+ pathParams: {
2478
+ workspace: "{workspaceId}",
2479
+ dbBranchName: "{dbBranch}",
2480
+ region: "{region}",
2481
+ tableName: __privateGet$4(this, _table)
2482
+ },
2483
+ body: {
2484
+ filter: cleanFilter(data.filter),
2485
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2486
+ page: data.pagination,
2487
+ columns: data.columns ?? ["*"]
2488
+ },
2489
+ fetchOptions: data.fetchOptions,
1880
2490
  ...fetchProps
1881
2491
  });
1882
2492
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
@@ -1887,6 +2497,30 @@ class RestRepository extends Query {
1887
2497
  return new Page(query, meta, records);
1888
2498
  });
1889
2499
  }
2500
+ async summarizeTable(query, summaries, summariesFilter) {
2501
+ return __privateGet$4(this, _trace).call(this, "summarize", async () => {
2502
+ const data = query.getQueryOptions();
2503
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2504
+ const result = await summarizeTable({
2505
+ pathParams: {
2506
+ workspace: "{workspaceId}",
2507
+ dbBranchName: "{dbBranch}",
2508
+ region: "{region}",
2509
+ tableName: __privateGet$4(this, _table)
2510
+ },
2511
+ body: {
2512
+ filter: cleanFilter(data.filter),
2513
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2514
+ columns: data.columns,
2515
+ page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
2516
+ summaries,
2517
+ summariesFilter
2518
+ },
2519
+ ...fetchProps
2520
+ });
2521
+ return result;
2522
+ });
2523
+ }
1890
2524
  }
1891
2525
  _table = new WeakMap();
1892
2526
  _getFetchProps = new WeakMap();
@@ -1902,6 +2536,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1902
2536
  pathParams: {
1903
2537
  workspace: "{workspaceId}",
1904
2538
  dbBranchName: "{dbBranch}",
2539
+ region: "{region}",
1905
2540
  tableName: __privateGet$4(this, _table)
1906
2541
  },
1907
2542
  queryParams: { columns },
@@ -1912,47 +2547,68 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1912
2547
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1913
2548
  };
1914
2549
  _insertRecordWithId = new WeakSet();
1915
- insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
2550
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
1916
2551
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1917
2552
  const record = transformObjectLinks(object);
1918
2553
  const response = await insertRecordWithID({
1919
2554
  pathParams: {
1920
2555
  workspace: "{workspaceId}",
1921
2556
  dbBranchName: "{dbBranch}",
2557
+ region: "{region}",
1922
2558
  tableName: __privateGet$4(this, _table),
1923
2559
  recordId
1924
2560
  },
1925
2561
  body: record,
1926
- queryParams: { createOnly: true, columns },
2562
+ queryParams: { createOnly, columns, ifVersion },
1927
2563
  ...fetchProps
1928
2564
  });
1929
2565
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1930
2566
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1931
2567
  };
1932
- _bulkInsertTableRecords = new WeakSet();
1933
- bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
2568
+ _insertRecords = new WeakSet();
2569
+ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
1934
2570
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1935
- const records = objects.map((object) => transformObjectLinks(object));
1936
- const response = await bulkInsertTableRecords({
1937
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1938
- queryParams: { columns },
1939
- body: { records },
1940
- ...fetchProps
1941
- });
1942
- if (!isResponseWithRecords(response)) {
1943
- throw new Error("Request included columns but server didn't include them");
2571
+ const chunkedOperations = chunk(
2572
+ objects.map((object) => ({
2573
+ insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
2574
+ })),
2575
+ BULK_OPERATION_MAX_SIZE
2576
+ );
2577
+ const ids = [];
2578
+ for (const operations of chunkedOperations) {
2579
+ const { results } = await branchTransaction({
2580
+ pathParams: {
2581
+ workspace: "{workspaceId}",
2582
+ dbBranchName: "{dbBranch}",
2583
+ region: "{region}"
2584
+ },
2585
+ body: { operations },
2586
+ ...fetchProps
2587
+ });
2588
+ for (const result of results) {
2589
+ if (result.operation === "insert") {
2590
+ ids.push(result.id);
2591
+ } else {
2592
+ ids.push(null);
2593
+ }
2594
+ }
1944
2595
  }
1945
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1946
- return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
2596
+ return ids;
1947
2597
  };
1948
2598
  _updateRecordWithID = new WeakSet();
1949
- updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2599
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
1950
2600
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1951
- const record = transformObjectLinks(object);
2601
+ const { id: _id, ...record } = transformObjectLinks(object);
1952
2602
  try {
1953
2603
  const response = await updateRecordWithID({
1954
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1955
- queryParams: { columns },
2604
+ pathParams: {
2605
+ workspace: "{workspaceId}",
2606
+ dbBranchName: "{dbBranch}",
2607
+ region: "{region}",
2608
+ tableName: __privateGet$4(this, _table),
2609
+ recordId
2610
+ },
2611
+ queryParams: { columns, ifVersion },
1956
2612
  body: record,
1957
2613
  ...fetchProps
1958
2614
  });
@@ -1965,12 +2621,48 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1965
2621
  throw e;
1966
2622
  }
1967
2623
  };
2624
+ _updateRecords = new WeakSet();
2625
+ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
2626
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2627
+ const chunkedOperations = chunk(
2628
+ objects.map(({ id, ...object }) => ({
2629
+ update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
2630
+ })),
2631
+ BULK_OPERATION_MAX_SIZE
2632
+ );
2633
+ const ids = [];
2634
+ for (const operations of chunkedOperations) {
2635
+ const { results } = await branchTransaction({
2636
+ pathParams: {
2637
+ workspace: "{workspaceId}",
2638
+ dbBranchName: "{dbBranch}",
2639
+ region: "{region}"
2640
+ },
2641
+ body: { operations },
2642
+ ...fetchProps
2643
+ });
2644
+ for (const result of results) {
2645
+ if (result.operation === "update") {
2646
+ ids.push(result.id);
2647
+ } else {
2648
+ ids.push(null);
2649
+ }
2650
+ }
2651
+ }
2652
+ return ids;
2653
+ };
1968
2654
  _upsertRecordWithID = new WeakSet();
1969
- upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2655
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
1970
2656
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1971
2657
  const response = await upsertRecordWithID({
1972
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1973
- queryParams: { columns },
2658
+ pathParams: {
2659
+ workspace: "{workspaceId}",
2660
+ dbBranchName: "{dbBranch}",
2661
+ region: "{region}",
2662
+ tableName: __privateGet$4(this, _table),
2663
+ recordId
2664
+ },
2665
+ queryParams: { columns, ifVersion },
1974
2666
  body: object,
1975
2667
  ...fetchProps
1976
2668
  });
@@ -1982,7 +2674,13 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1982
2674
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1983
2675
  try {
1984
2676
  const response = await deleteRecord({
1985
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2677
+ pathParams: {
2678
+ workspace: "{workspaceId}",
2679
+ dbBranchName: "{dbBranch}",
2680
+ region: "{region}",
2681
+ tableName: __privateGet$4(this, _table),
2682
+ recordId
2683
+ },
1986
2684
  queryParams: { columns },
1987
2685
  ...fetchProps
1988
2686
  });
@@ -1995,6 +2693,25 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1995
2693
  throw e;
1996
2694
  }
1997
2695
  };
2696
+ _deleteRecords = new WeakSet();
2697
+ deleteRecords_fn = async function(recordIds) {
2698
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2699
+ const chunkedOperations = chunk(
2700
+ recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
2701
+ BULK_OPERATION_MAX_SIZE
2702
+ );
2703
+ for (const operations of chunkedOperations) {
2704
+ await branchTransaction({
2705
+ pathParams: {
2706
+ workspace: "{workspaceId}",
2707
+ dbBranchName: "{dbBranch}",
2708
+ region: "{region}"
2709
+ },
2710
+ body: { operations },
2711
+ ...fetchProps
2712
+ });
2713
+ }
2714
+ };
1998
2715
  _setCacheQuery = new WeakSet();
1999
2716
  setCacheQuery_fn = async function(query, meta, records) {
2000
2717
  await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
@@ -2017,7 +2734,7 @@ getSchemaTables_fn$1 = async function() {
2017
2734
  return __privateGet$4(this, _schemaTables$2);
2018
2735
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2019
2736
  const { schema } = await getBranchDetails({
2020
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2737
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2021
2738
  ...fetchProps
2022
2739
  });
2023
2740
  __privateSet$4(this, _schemaTables$2, schema.tables);
@@ -2083,8 +2800,15 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2083
2800
  result.read = function(columns2) {
2084
2801
  return db[table].read(result["id"], columns2);
2085
2802
  };
2086
- result.update = function(data, columns2) {
2087
- return db[table].update(result["id"], data, columns2);
2803
+ result.update = function(data, b, c) {
2804
+ const columns2 = isStringArray(b) ? b : ["*"];
2805
+ const ifVersion = parseIfVersion(b, c);
2806
+ return db[table].update(result["id"], data, columns2, { ifVersion });
2807
+ };
2808
+ result.replace = function(data, b, c) {
2809
+ const columns2 = isStringArray(b) ? b : ["*"];
2810
+ const ifVersion = parseIfVersion(b, c);
2811
+ return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
2088
2812
  };
2089
2813
  result.delete = function() {
2090
2814
  return db[table].delete(result["id"]);
@@ -2092,15 +2816,12 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2092
2816
  result.getMetadata = function() {
2093
2817
  return xata;
2094
2818
  };
2095
- for (const prop of ["read", "update", "delete", "getMetadata"]) {
2819
+ for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
2096
2820
  Object.defineProperty(result, prop, { enumerable: false });
2097
2821
  }
2098
2822
  Object.freeze(result);
2099
2823
  return result;
2100
2824
  };
2101
- function isResponseWithRecords(value) {
2102
- return isObject(value) && Array.isArray(value.records);
2103
- }
2104
2825
  function extractId(value) {
2105
2826
  if (isString(value))
2106
2827
  return value;
@@ -2108,12 +2829,6 @@ function extractId(value) {
2108
2829
  return value.id;
2109
2830
  return void 0;
2110
2831
  }
2111
- function cleanFilter(filter) {
2112
- if (!filter)
2113
- return void 0;
2114
- const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2115
- return values.length > 0 ? filter : void 0;
2116
- }
2117
2832
  function isValidColumn(columns, column) {
2118
2833
  if (columns.includes("*"))
2119
2834
  return true;
@@ -2123,6 +2838,14 @@ function isValidColumn(columns, column) {
2123
2838
  }
2124
2839
  return columns.includes(column.name);
2125
2840
  }
2841
+ function parseIfVersion(...args) {
2842
+ for (const arg of args) {
2843
+ if (isObject(arg) && isNumber(arg.ifVersion)) {
2844
+ return arg.ifVersion;
2845
+ }
2846
+ }
2847
+ return void 0;
2848
+ }
2126
2849
 
2127
2850
  var __accessCheck$3 = (obj, member, msg) => {
2128
2851
  if (!member.has(obj))
@@ -2310,7 +3033,7 @@ search_fn = async function(query, options, getFetchProps) {
2310
3033
  const fetchProps = await getFetchProps();
2311
3034
  const { tables, fuzziness, highlight, prefix } = options ?? {};
2312
3035
  const { records } = await searchBranch({
2313
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
3036
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2314
3037
  body: { tables, query, fuzziness, prefix, highlight },
2315
3038
  ...fetchProps
2316
3039
  });
@@ -2322,7 +3045,7 @@ getSchemaTables_fn = async function(getFetchProps) {
2322
3045
  return __privateGet$1(this, _schemaTables);
2323
3046
  const fetchProps = await getFetchProps();
2324
3047
  const { schema } = await getBranchDetails({
2325
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
3048
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2326
3049
  ...fetchProps
2327
3050
  });
2328
3051
  __privateSet$1(this, _schemaTables, schema.tables);
@@ -2360,14 +3083,17 @@ async function resolveXataBranch(gitBranch, options) {
2360
3083
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2361
3084
  );
2362
3085
  const [protocol, , host, , dbName] = databaseURL.split("/");
2363
- const [workspace] = host.split(".");
3086
+ const urlParts = parseWorkspacesUrlParts(host);
3087
+ if (!urlParts)
3088
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3089
+ const { workspace, region } = urlParts;
2364
3090
  const { fallbackBranch } = getEnvironment();
2365
3091
  const { branch } = await resolveBranch({
2366
3092
  apiKey,
2367
3093
  apiUrl: databaseURL,
2368
3094
  fetchImpl: getFetchImplementation(options?.fetchImpl),
2369
3095
  workspacesApiUrl: `${protocol}//${host}`,
2370
- pathParams: { dbName, workspace },
3096
+ pathParams: { dbName, workspace, region },
2371
3097
  queryParams: { gitBranch, fallbackBranch },
2372
3098
  trace: defaultTrace
2373
3099
  });
@@ -2385,15 +3111,17 @@ async function getDatabaseBranch(branch, options) {
2385
3111
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2386
3112
  );
2387
3113
  const [protocol, , host, , database] = databaseURL.split("/");
2388
- const [workspace] = host.split(".");
2389
- const dbBranchName = `${database}:${branch}`;
3114
+ const urlParts = parseWorkspacesUrlParts(host);
3115
+ if (!urlParts)
3116
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3117
+ const { workspace, region } = urlParts;
2390
3118
  try {
2391
3119
  return await getBranchDetails({
2392
3120
  apiKey,
2393
3121
  apiUrl: databaseURL,
2394
3122
  fetchImpl: getFetchImplementation(options?.fetchImpl),
2395
3123
  workspacesApiUrl: `${protocol}//${host}`,
2396
- pathParams: { dbBranchName, workspace },
3124
+ pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
2397
3125
  trace: defaultTrace
2398
3126
  });
2399
3127
  } catch (err) {
@@ -2472,6 +3200,13 @@ const buildClient = (plugins) => {
2472
3200
  return { databaseURL, branch };
2473
3201
  }
2474
3202
  }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
3203
+ const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
3204
+ const isBrowser = typeof window !== "undefined";
3205
+ if (isBrowser && !enableBrowser) {
3206
+ throw new Error(
3207
+ "You are trying to use Xata from the browser, which is potentially a non-secure environment. If you understand the security concerns, such as leaking your credentials, pass `enableBrowser: true` to the client options to remove this error."
3208
+ );
3209
+ }
2475
3210
  const fetch = getFetchImplementation(options?.fetch);
2476
3211
  const databaseURL = options?.databaseURL || getDatabaseURL();
2477
3212
  const apiKey = options?.apiKey || getAPIKey();
@@ -2484,8 +3219,8 @@ const buildClient = (plugins) => {
2484
3219
  if (!databaseURL) {
2485
3220
  throw new Error("Option databaseURL is required");
2486
3221
  }
2487
- return { fetch, databaseURL, apiKey, branch, cache, trace };
2488
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
3222
+ return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser };
3223
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
2489
3224
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2490
3225
  if (!branchValue)
2491
3226
  throw new Error("Unable to resolve branch value");
@@ -2498,7 +3233,8 @@ const buildClient = (plugins) => {
2498
3233
  const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
2499
3234
  return databaseURL + newPath;
2500
3235
  },
2501
- trace
3236
+ trace,
3237
+ clientID
2502
3238
  };
2503
3239
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2504
3240
  if (__privateGet(this, _branch))
@@ -2632,7 +3368,9 @@ exports.XataPlugin = XataPlugin;
2632
3368
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
2633
3369
  exports.addGitBranchesEntry = addGitBranchesEntry;
2634
3370
  exports.addTableColumn = addTableColumn;
3371
+ exports.aggregateTable = aggregateTable;
2635
3372
  exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
3373
+ exports.branchTransaction = branchTransaction;
2636
3374
  exports.buildClient = buildClient;
2637
3375
  exports.buildWorkerRunner = buildWorkerRunner;
2638
3376
  exports.bulkInsertTableRecords = bulkInsertTableRecords;
@@ -2647,6 +3385,11 @@ exports.createMigrationRequest = createMigrationRequest;
2647
3385
  exports.createTable = createTable;
2648
3386
  exports.createUserAPIKey = createUserAPIKey;
2649
3387
  exports.createWorkspace = createWorkspace;
3388
+ exports.dEPRECATEDcreateDatabase = dEPRECATEDcreateDatabase;
3389
+ exports.dEPRECATEDdeleteDatabase = dEPRECATEDdeleteDatabase;
3390
+ exports.dEPRECATEDgetDatabaseList = dEPRECATEDgetDatabaseList;
3391
+ exports.dEPRECATEDgetDatabaseMetadata = dEPRECATEDgetDatabaseMetadata;
3392
+ exports.dEPRECATEDupdateDatabaseMetadata = dEPRECATEDupdateDatabaseMetadata;
2650
3393
  exports.deleteBranch = deleteBranch;
2651
3394
  exports.deleteColumn = deleteColumn;
2652
3395
  exports.deleteDatabase = deleteDatabase;
@@ -2676,6 +3419,7 @@ exports.getDatabaseList = getDatabaseList;
2676
3419
  exports.getDatabaseMetadata = getDatabaseMetadata;
2677
3420
  exports.getDatabaseURL = getDatabaseURL;
2678
3421
  exports.getGitBranchesMapping = getGitBranchesMapping;
3422
+ exports.getHostUrl = getHostUrl;
2679
3423
  exports.getMigrationRequest = getMigrationRequest;
2680
3424
  exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
2681
3425
  exports.getRecord = getRecord;
@@ -2700,6 +3444,8 @@ exports.insertRecordWithID = insertRecordWithID;
2700
3444
  exports.inviteWorkspaceMember = inviteWorkspaceMember;
2701
3445
  exports.is = is;
2702
3446
  exports.isCursorPaginationOptions = isCursorPaginationOptions;
3447
+ exports.isHostProviderAlias = isHostProviderAlias;
3448
+ exports.isHostProviderBuilder = isHostProviderBuilder;
2703
3449
  exports.isIdentifiable = isIdentifiable;
2704
3450
  exports.isNot = isNot;
2705
3451
  exports.isXataRecord = isXataRecord;
@@ -2707,15 +3453,18 @@ exports.le = le;
2707
3453
  exports.lessEquals = lessEquals;
2708
3454
  exports.lessThan = lessThan;
2709
3455
  exports.lessThanEquals = lessThanEquals;
2710
- exports.listMigrationRequests = listMigrationRequests;
2711
3456
  exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
3457
+ exports.listRegions = listRegions;
2712
3458
  exports.lt = lt;
2713
3459
  exports.lte = lte;
2714
3460
  exports.mergeMigrationRequest = mergeMigrationRequest;
2715
3461
  exports.notExists = notExists;
2716
3462
  exports.operationsByTag = operationsByTag;
3463
+ exports.parseProviderString = parseProviderString;
3464
+ exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
2717
3465
  exports.pattern = pattern;
2718
3466
  exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
3467
+ exports.queryMigrationRequests = queryMigrationRequests;
2719
3468
  exports.queryTable = queryTable;
2720
3469
  exports.removeGitBranchesEntry = removeGitBranchesEntry;
2721
3470
  exports.removeWorkspaceMember = removeWorkspaceMember;