@xata.io/client 0.0.0-alpha.vf8b33c9 → 0.0.0-alpha.vf8f3b02

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