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

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