@xata.io/client 0.0.0-alpha.vf0e0021 → 0.0.0-alpha.vf14d3b2

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
@@ -1,5 +1,6 @@
1
- const defaultTrace = async (_name, fn, _options) => {
1
+ const defaultTrace = async (name, fn, _options) => {
2
2
  return await fn({
3
+ name,
3
4
  setAttributes: () => {
4
5
  return;
5
6
  }
@@ -38,6 +39,21 @@ function isString(value) {
38
39
  function isStringArray(value) {
39
40
  return isDefined(value) && Array.isArray(value) && value.every(isString);
40
41
  }
42
+ function isNumber(value) {
43
+ return isDefined(value) && typeof value === "number";
44
+ }
45
+ function parseNumber(value) {
46
+ if (isNumber(value)) {
47
+ return value;
48
+ }
49
+ if (isString(value)) {
50
+ const parsed = Number(value);
51
+ if (!Number.isNaN(parsed)) {
52
+ return parsed;
53
+ }
54
+ }
55
+ return void 0;
56
+ }
41
57
  function toBase64(value) {
42
58
  try {
43
59
  return btoa(value);
@@ -46,10 +62,31 @@ function toBase64(value) {
46
62
  return buf.from(value).toString("base64");
47
63
  }
48
64
  }
65
+ function deepMerge(a, b) {
66
+ const result = { ...a };
67
+ for (const [key, value] of Object.entries(b)) {
68
+ if (isObject(value) && isObject(result[key])) {
69
+ result[key] = deepMerge(result[key], value);
70
+ } else {
71
+ result[key] = value;
72
+ }
73
+ }
74
+ return result;
75
+ }
76
+ function chunk(array, chunkSize) {
77
+ const result = [];
78
+ for (let i = 0; i < array.length; i += chunkSize) {
79
+ result.push(array.slice(i, i + chunkSize));
80
+ }
81
+ return result;
82
+ }
83
+ async function timeout(ms) {
84
+ return new Promise((resolve) => setTimeout(resolve, ms));
85
+ }
49
86
 
50
87
  function getEnvironment() {
51
88
  try {
52
- if (isObject(process) && isObject(process.env)) {
89
+ if (isDefined(process) && isDefined(process.env)) {
53
90
  return {
54
91
  apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
55
92
  databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
@@ -80,6 +117,25 @@ function getEnvironment() {
80
117
  fallbackBranch: getGlobalFallbackBranch()
81
118
  };
82
119
  }
120
+ function getEnableBrowserVariable() {
121
+ try {
122
+ if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
123
+ return process.env.XATA_ENABLE_BROWSER === "true";
124
+ }
125
+ } catch (err) {
126
+ }
127
+ try {
128
+ if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
129
+ return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
130
+ }
131
+ } catch (err) {
132
+ }
133
+ try {
134
+ return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
135
+ } catch (err) {
136
+ return void 0;
137
+ }
138
+ }
83
139
  function getGlobalApiKey() {
84
140
  try {
85
141
  return XATA_API_KEY;
@@ -139,6 +195,29 @@ function getAPIKey() {
139
195
  }
140
196
  }
141
197
 
198
+ var __accessCheck$8 = (obj, member, msg) => {
199
+ if (!member.has(obj))
200
+ throw TypeError("Cannot " + msg);
201
+ };
202
+ var __privateGet$8 = (obj, member, getter) => {
203
+ __accessCheck$8(obj, member, "read from private field");
204
+ return getter ? getter.call(obj) : member.get(obj);
205
+ };
206
+ var __privateAdd$8 = (obj, member, value) => {
207
+ if (member.has(obj))
208
+ throw TypeError("Cannot add the same private member more than once");
209
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
210
+ };
211
+ var __privateSet$8 = (obj, member, value, setter) => {
212
+ __accessCheck$8(obj, member, "write to private field");
213
+ setter ? setter.call(obj, value) : member.set(obj, value);
214
+ return value;
215
+ };
216
+ var __privateMethod$4 = (obj, member, method) => {
217
+ __accessCheck$8(obj, member, "access private method");
218
+ return method;
219
+ };
220
+ var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
142
221
  function getFetchImplementation(userFetch) {
143
222
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
144
223
  const fetchImpl = userFetch ?? globalFetch;
@@ -149,8 +228,81 @@ function getFetchImplementation(userFetch) {
149
228
  }
150
229
  return fetchImpl;
151
230
  }
231
+ class ApiRequestPool {
232
+ constructor(concurrency = 10) {
233
+ __privateAdd$8(this, _enqueue);
234
+ __privateAdd$8(this, _fetch, void 0);
235
+ __privateAdd$8(this, _queue, void 0);
236
+ __privateAdd$8(this, _concurrency, void 0);
237
+ __privateSet$8(this, _queue, []);
238
+ __privateSet$8(this, _concurrency, concurrency);
239
+ this.running = 0;
240
+ this.started = 0;
241
+ }
242
+ setFetch(fetch2) {
243
+ __privateSet$8(this, _fetch, fetch2);
244
+ }
245
+ getFetch() {
246
+ if (!__privateGet$8(this, _fetch)) {
247
+ throw new Error("Fetch not set");
248
+ }
249
+ return __privateGet$8(this, _fetch);
250
+ }
251
+ request(url, options) {
252
+ const start = new Date();
253
+ const fetch2 = this.getFetch();
254
+ const runRequest = async (stalled = false) => {
255
+ const response = await fetch2(url, options);
256
+ if (response.status === 429) {
257
+ const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
258
+ await timeout(rateLimitReset * 1e3);
259
+ return await runRequest(true);
260
+ }
261
+ if (stalled) {
262
+ const stalledTime = new Date().getTime() - start.getTime();
263
+ console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
264
+ }
265
+ return response;
266
+ };
267
+ return __privateMethod$4(this, _enqueue, enqueue_fn).call(this, async () => {
268
+ return await runRequest();
269
+ });
270
+ }
271
+ }
272
+ _fetch = new WeakMap();
273
+ _queue = new WeakMap();
274
+ _concurrency = new WeakMap();
275
+ _enqueue = new WeakSet();
276
+ enqueue_fn = function(task) {
277
+ const promise = new Promise((resolve) => __privateGet$8(this, _queue).push(resolve)).finally(() => {
278
+ this.started--;
279
+ this.running++;
280
+ }).then(() => task()).finally(() => {
281
+ this.running--;
282
+ const next = __privateGet$8(this, _queue).shift();
283
+ if (next !== void 0) {
284
+ this.started++;
285
+ next();
286
+ }
287
+ });
288
+ if (this.running + this.started < __privateGet$8(this, _concurrency)) {
289
+ const next = __privateGet$8(this, _queue).shift();
290
+ if (next !== void 0) {
291
+ this.started++;
292
+ next();
293
+ }
294
+ }
295
+ return promise;
296
+ };
152
297
 
153
- const VERSION = "0.0.0-alpha.vf0e0021";
298
+ function generateUUID() {
299
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
300
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
301
+ return v.toString(16);
302
+ });
303
+ }
304
+
305
+ const VERSION = "0.0.0-alpha.vf14d3b2";
154
306
 
155
307
  class ErrorWithCause extends Error {
156
308
  constructor(message, options) {
@@ -161,7 +313,7 @@ class FetcherError extends ErrorWithCause {
161
313
  constructor(status, data, requestId) {
162
314
  super(getMessage(data));
163
315
  this.status = status;
164
- this.errors = isBulkError(data) ? data.errors : void 0;
316
+ this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
165
317
  this.requestId = requestId;
166
318
  if (data instanceof Error) {
167
319
  this.stack = data.stack;
@@ -193,6 +345,7 @@ function getMessage(data) {
193
345
  }
194
346
  }
195
347
 
348
+ const pool = new ApiRequestPool();
196
349
  const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
197
350
  const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
198
351
  if (value === void 0 || value === null)
@@ -207,58 +360,77 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
207
360
  return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
208
361
  };
209
362
  function buildBaseUrl({
363
+ endpoint,
210
364
  path,
211
365
  workspacesApiUrl,
212
366
  apiUrl,
213
- pathParams
367
+ pathParams = {}
214
368
  }) {
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));
369
+ if (endpoint === "dataPlane") {
370
+ const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
371
+ const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
372
+ return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
373
+ }
374
+ return `${apiUrl}${path}`;
219
375
  }
220
376
  function hostHeader(url) {
221
377
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
222
378
  const { groups } = pattern.exec(url) ?? {};
223
379
  return groups?.host ? { Host: groups.host } : {};
224
380
  }
381
+ const defaultClientID = generateUUID();
225
382
  async function fetch$1({
226
383
  url: path,
227
384
  method,
228
385
  body,
229
- headers,
386
+ headers: customHeaders,
230
387
  pathParams,
231
388
  queryParams,
232
389
  fetchImpl,
233
390
  apiKey,
391
+ endpoint,
234
392
  apiUrl,
235
393
  workspacesApiUrl,
236
- trace
394
+ trace,
395
+ signal,
396
+ clientID,
397
+ sessionID,
398
+ clientName,
399
+ fetchOptions = {}
237
400
  }) {
238
- return trace(
401
+ pool.setFetch(fetchImpl);
402
+ return await trace(
239
403
  `${method.toUpperCase()} ${path}`,
240
- async ({ setAttributes }) => {
241
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
404
+ async ({ name, setAttributes }) => {
405
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
242
406
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
243
407
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
244
408
  setAttributes({
245
409
  [TraceAttributes.HTTP_URL]: url,
246
410
  [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
247
411
  });
248
- const response = await fetchImpl(url, {
412
+ const xataAgent = compact([
413
+ ["client", "TS_SDK"],
414
+ ["version", VERSION],
415
+ isDefined(clientName) ? ["service", clientName] : void 0
416
+ ]).map(([key, value]) => `${key}=${value}`).join("; ");
417
+ const headers = {
418
+ "Accept-Encoding": "identity",
419
+ "Content-Type": "application/json",
420
+ "X-Xata-Client-ID": clientID ?? defaultClientID,
421
+ "X-Xata-Session-ID": sessionID ?? generateUUID(),
422
+ "X-Xata-Agent": xataAgent,
423
+ ...customHeaders,
424
+ ...hostHeader(fullUrl),
425
+ Authorization: `Bearer ${apiKey}`
426
+ };
427
+ const response = await pool.request(url, {
428
+ ...fetchOptions,
249
429
  method: method.toUpperCase(),
250
430
  body: body ? JSON.stringify(body) : void 0,
251
- headers: {
252
- "Content-Type": "application/json",
253
- "User-Agent": `Xata client-ts/${VERSION}`,
254
- ...headers,
255
- ...hostHeader(fullUrl),
256
- Authorization: `Bearer ${apiKey}`
257
- }
431
+ headers,
432
+ signal
258
433
  });
259
- if (response.status === 204) {
260
- return {};
261
- }
262
434
  const { host, protocol } = parseUrl(response.url);
263
435
  const requestId = response.headers?.get("x-request-id") ?? void 0;
264
436
  setAttributes({
@@ -268,6 +440,12 @@ async function fetch$1({
268
440
  [TraceAttributes.HTTP_HOST]: host,
269
441
  [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
270
442
  });
443
+ if (response.status === 204) {
444
+ return {};
445
+ }
446
+ if (response.status === 429) {
447
+ throw new FetcherError(response.status, "Rate limit exceeded", requestId);
448
+ }
271
449
  try {
272
450
  const jsonResponse = await response.json();
273
451
  if (response.ok) {
@@ -290,293 +468,163 @@ function parseUrl(url) {
290
468
  }
291
469
  }
292
470
 
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({
471
+ const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
472
+
473
+ const dEPRECATEDgetDatabaseList = (variables, signal) => dataPlaneFetch({ url: "/dbs", method: "get", ...variables, signal });
474
+ const getBranchList = (variables, signal) => dataPlaneFetch({
380
475
  url: "/dbs/{dbName}",
381
- method: "delete",
382
- ...variables
383
- });
384
- const getDatabaseMetadata = (variables) => fetch$1({
385
- url: "/dbs/{dbName}/metadata",
386
- method: "get",
387
- ...variables
388
- });
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
476
  method: "get",
396
- ...variables
477
+ ...variables,
478
+ signal
397
479
  });
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({
480
+ const dEPRECATEDcreateDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
481
+ const dEPRECATEDdeleteDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "delete", ...variables, signal });
482
+ const dEPRECATEDgetDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "get", ...variables, signal });
483
+ const dEPRECATEDupdateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
484
+ const getBranchDetails = (variables, signal) => dataPlaneFetch({
415
485
  url: "/db/{dbBranchName}",
416
486
  method: "get",
417
- ...variables
487
+ ...variables,
488
+ signal
418
489
  });
419
- const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
420
- const deleteBranch = (variables) => fetch$1({
490
+ const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
491
+ const deleteBranch = (variables, signal) => dataPlaneFetch({
421
492
  url: "/db/{dbBranchName}",
422
493
  method: "delete",
423
- ...variables
494
+ ...variables,
495
+ signal
424
496
  });
425
- const updateBranchMetadata = (variables) => fetch$1({
497
+ const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
426
498
  url: "/db/{dbBranchName}/metadata",
427
499
  method: "put",
428
- ...variables
500
+ ...variables,
501
+ signal
429
502
  });
430
- const getBranchMetadata = (variables) => fetch$1({
503
+ const getBranchMetadata = (variables, signal) => dataPlaneFetch({
431
504
  url: "/db/{dbBranchName}/metadata",
432
505
  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
506
+ ...variables,
507
+ signal
444
508
  });
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({
509
+ const getBranchStats = (variables, signal) => dataPlaneFetch({
449
510
  url: "/db/{dbBranchName}/stats",
450
511
  method: "get",
451
- ...variables
512
+ ...variables,
513
+ signal
514
+ });
515
+ const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
516
+ const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
517
+ const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
518
+ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
519
+ const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
520
+ const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
521
+ const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
522
+ const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
523
+ const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
524
+ const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
525
+ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
526
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
527
+ method: "get",
528
+ ...variables,
529
+ signal
530
+ });
531
+ const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
532
+ const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
533
+ const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
534
+ const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
535
+ const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
536
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
537
+ method: "post",
538
+ ...variables,
539
+ signal
452
540
  });
453
- const createTable = (variables) => fetch$1({
541
+ const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
542
+ const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
543
+ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
544
+ const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
545
+ const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
546
+ const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
547
+ const createTable = (variables, signal) => dataPlaneFetch({
454
548
  url: "/db/{dbBranchName}/tables/{tableName}",
455
549
  method: "put",
456
- ...variables
550
+ ...variables,
551
+ signal
457
552
  });
458
- const deleteTable = (variables) => fetch$1({
553
+ const deleteTable = (variables, signal) => dataPlaneFetch({
459
554
  url: "/db/{dbBranchName}/tables/{tableName}",
460
555
  method: "delete",
461
- ...variables
556
+ ...variables,
557
+ signal
462
558
  });
463
- const updateTable = (variables) => fetch$1({
464
- url: "/db/{dbBranchName}/tables/{tableName}",
465
- method: "patch",
466
- ...variables
467
- });
468
- const getTableSchema = (variables) => fetch$1({
559
+ const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
560
+ const getTableSchema = (variables, signal) => dataPlaneFetch({
469
561
  url: "/db/{dbBranchName}/tables/{tableName}/schema",
470
562
  method: "get",
471
- ...variables
563
+ ...variables,
564
+ signal
472
565
  });
473
- const setTableSchema = (variables) => fetch$1({
474
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
475
- method: "put",
476
- ...variables
477
- });
478
- const getTableColumns = (variables) => fetch$1({
566
+ const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
567
+ const getTableColumns = (variables, signal) => dataPlaneFetch({
479
568
  url: "/db/{dbBranchName}/tables/{tableName}/columns",
480
569
  method: "get",
481
- ...variables
482
- });
483
- const addTableColumn = (variables) => fetch$1({
484
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
485
- method: "post",
486
- ...variables
570
+ ...variables,
571
+ signal
487
572
  });
488
- const getColumn = (variables) => fetch$1({
573
+ const addTableColumn = (variables, signal) => dataPlaneFetch(
574
+ { url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
575
+ );
576
+ const getColumn = (variables, signal) => dataPlaneFetch({
489
577
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
490
578
  method: "get",
491
- ...variables
492
- });
493
- const deleteColumn = (variables) => fetch$1({
494
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
495
- method: "delete",
496
- ...variables
579
+ ...variables,
580
+ signal
497
581
  });
498
- const updateColumn = (variables) => fetch$1({
582
+ const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
583
+ const deleteColumn = (variables, signal) => dataPlaneFetch({
499
584
  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
585
  method: "delete",
510
- ...variables
586
+ ...variables,
587
+ signal
511
588
  });
512
- const getRecord = (variables) => fetch$1({
589
+ const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
590
+ const getRecord = (variables, signal) => dataPlaneFetch({
513
591
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
514
592
  method: "get",
515
- ...variables
593
+ ...variables,
594
+ signal
516
595
  });
517
- const bulkInsertTableRecords = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables });
518
- const queryTable = (variables) => fetch$1({
596
+ const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
597
+ const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
598
+ const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
599
+ const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
600
+ const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
601
+ const queryTable = (variables, signal) => dataPlaneFetch({
519
602
  url: "/db/{dbBranchName}/tables/{tableName}/query",
520
603
  method: "post",
521
- ...variables
522
- });
523
- const searchTable = (variables) => fetch$1({
524
- url: "/db/{dbBranchName}/tables/{tableName}/search",
525
- method: "post",
526
- ...variables
604
+ ...variables,
605
+ signal
527
606
  });
528
- const searchBranch = (variables) => fetch$1({
607
+ const searchBranch = (variables, signal) => dataPlaneFetch({
529
608
  url: "/db/{dbBranchName}/search",
530
609
  method: "post",
531
- ...variables
610
+ ...variables,
611
+ signal
532
612
  });
533
- const summarizeTable = (variables) => fetch$1({
534
- url: "/db/{dbBranchName}/tables/{tableName}/summarize",
613
+ const searchTable = (variables, signal) => dataPlaneFetch({
614
+ url: "/db/{dbBranchName}/tables/{tableName}/search",
535
615
  method: "post",
536
- ...variables
537
- });
538
- const cPgetDatabaseList = (variables) => fetch$1({
539
- url: "/workspaces/{workspaceId}/dbs",
540
- method: "get",
541
- ...variables
616
+ ...variables,
617
+ signal
542
618
  });
543
- const cPcreateDatabase = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables });
544
- const cPdeleteDatabase = (variables) => fetch$1({
545
- url: "/workspaces/{workspaceId}/dbs/{dbName}",
546
- method: "delete",
547
- ...variables
548
- });
549
- const cPgetCPDatabaseMetadata = (variables) => fetch$1(
550
- { url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "get", ...variables }
551
- );
552
- const cPupdateCPDatabaseMetadata = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "patch", ...variables });
553
- const operationsByTag = {
554
- users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
555
- workspaces: {
556
- createWorkspace,
557
- getWorkspacesList,
558
- getWorkspace,
559
- updateWorkspace,
560
- deleteWorkspace,
561
- getWorkspaceMembersList,
562
- updateWorkspaceMemberRole,
563
- removeWorkspaceMember,
564
- inviteWorkspaceMember,
565
- updateWorkspaceMemberInvite,
566
- cancelWorkspaceMemberInvite,
567
- resendWorkspaceMemberInvite,
568
- acceptWorkspaceMemberInvite
569
- },
619
+ const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
620
+ const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
621
+ const operationsByTag$2 = {
570
622
  database: {
571
- getDatabaseList,
572
- createDatabase,
573
- deleteDatabase,
574
- getDatabaseMetadata,
575
- updateDatabaseMetadata,
576
- getGitBranchesMapping,
577
- addGitBranchesEntry,
578
- removeGitBranchesEntry,
579
- resolveBranch
623
+ dEPRECATEDgetDatabaseList,
624
+ dEPRECATEDcreateDatabase,
625
+ dEPRECATEDdeleteDatabase,
626
+ dEPRECATEDgetDatabaseMetadata,
627
+ dEPRECATEDupdateDatabaseMetadata
580
628
  },
581
629
  branch: {
582
630
  getBranchList,
@@ -585,10 +633,35 @@ const operationsByTag = {
585
633
  deleteBranch,
586
634
  updateBranchMetadata,
587
635
  getBranchMetadata,
588
- getBranchStats
636
+ getBranchStats,
637
+ getGitBranchesMapping,
638
+ addGitBranchesEntry,
639
+ removeGitBranchesEntry,
640
+ resolveBranch
641
+ },
642
+ migrations: {
643
+ getBranchMigrationHistory,
644
+ getBranchMigrationPlan,
645
+ executeBranchMigrationPlan,
646
+ getBranchSchemaHistory,
647
+ compareBranchWithUserSchema,
648
+ compareBranchSchemas,
649
+ updateBranchSchema,
650
+ previewBranchSchemaEdit,
651
+ applyBranchSchemaEdit
652
+ },
653
+ records: {
654
+ branchTransaction,
655
+ insertRecord,
656
+ getRecord,
657
+ insertRecordWithID,
658
+ updateRecordWithID,
659
+ upsertRecordWithID,
660
+ deleteRecord,
661
+ bulkInsertTableRecords
589
662
  },
590
663
  migrationRequests: {
591
- listMigrationRequests,
664
+ queryMigrationRequests,
592
665
  createMigrationRequest,
593
666
  getMigrationRequest,
594
667
  updateMigrationRequest,
@@ -597,17 +670,6 @@ const operationsByTag = {
597
670
  getMigrationRequestIsMerged,
598
671
  mergeMigrationRequest
599
672
  },
600
- branchSchema: {
601
- getBranchMigrationHistory,
602
- executeBranchMigrationPlan,
603
- getBranchMigrationPlan,
604
- compareBranchWithUserSchema,
605
- compareBranchSchemas,
606
- updateBranchSchema,
607
- previewBranchSchemaEdit,
608
- applyBranchSchemaEdit,
609
- getBranchSchemaHistory
610
- },
611
673
  table: {
612
674
  createTable,
613
675
  deleteTable,
@@ -617,31 +679,146 @@ const operationsByTag = {
617
679
  getTableColumns,
618
680
  addTableColumn,
619
681
  getColumn,
620
- deleteColumn,
621
- updateColumn
682
+ updateColumn,
683
+ deleteColumn
622
684
  },
623
- records: {
624
- insertRecord,
625
- insertRecordWithID,
626
- updateRecordWithID,
627
- upsertRecordWithID,
628
- deleteRecord,
629
- getRecord,
630
- bulkInsertTableRecords,
631
- queryTable,
632
- searchTable,
633
- searchBranch,
634
- summarizeTable
685
+ searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
686
+ };
687
+
688
+ const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
689
+
690
+ const getUser = (variables, signal) => controlPlaneFetch({
691
+ url: "/user",
692
+ method: "get",
693
+ ...variables,
694
+ signal
695
+ });
696
+ const updateUser = (variables, signal) => controlPlaneFetch({
697
+ url: "/user",
698
+ method: "put",
699
+ ...variables,
700
+ signal
701
+ });
702
+ const deleteUser = (variables, signal) => controlPlaneFetch({
703
+ url: "/user",
704
+ method: "delete",
705
+ ...variables,
706
+ signal
707
+ });
708
+ const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
709
+ url: "/user/keys",
710
+ method: "get",
711
+ ...variables,
712
+ signal
713
+ });
714
+ const createUserAPIKey = (variables, signal) => controlPlaneFetch({
715
+ url: "/user/keys/{keyName}",
716
+ method: "post",
717
+ ...variables,
718
+ signal
719
+ });
720
+ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
721
+ url: "/user/keys/{keyName}",
722
+ method: "delete",
723
+ ...variables,
724
+ signal
725
+ });
726
+ const getWorkspacesList = (variables, signal) => controlPlaneFetch({
727
+ url: "/workspaces",
728
+ method: "get",
729
+ ...variables,
730
+ signal
731
+ });
732
+ const createWorkspace = (variables, signal) => controlPlaneFetch({
733
+ url: "/workspaces",
734
+ method: "post",
735
+ ...variables,
736
+ signal
737
+ });
738
+ const getWorkspace = (variables, signal) => controlPlaneFetch({
739
+ url: "/workspaces/{workspaceId}",
740
+ method: "get",
741
+ ...variables,
742
+ signal
743
+ });
744
+ const updateWorkspace = (variables, signal) => controlPlaneFetch({
745
+ url: "/workspaces/{workspaceId}",
746
+ method: "put",
747
+ ...variables,
748
+ signal
749
+ });
750
+ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
751
+ url: "/workspaces/{workspaceId}",
752
+ method: "delete",
753
+ ...variables,
754
+ signal
755
+ });
756
+ const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
757
+ const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
758
+ const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
759
+ url: "/workspaces/{workspaceId}/members/{userId}",
760
+ method: "delete",
761
+ ...variables,
762
+ signal
763
+ });
764
+ const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
765
+ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
766
+ const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
767
+ const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
768
+ const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
769
+ const getDatabaseList = (variables, signal) => controlPlaneFetch({
770
+ url: "/workspaces/{workspaceId}/dbs",
771
+ method: "get",
772
+ ...variables,
773
+ signal
774
+ });
775
+ const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
776
+ const deleteDatabase = (variables, signal) => controlPlaneFetch({
777
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
778
+ method: "delete",
779
+ ...variables,
780
+ signal
781
+ });
782
+ const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
783
+ const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
784
+ const listRegions = (variables, signal) => controlPlaneFetch({
785
+ url: "/workspaces/{workspaceId}/regions",
786
+ method: "get",
787
+ ...variables,
788
+ signal
789
+ });
790
+ const operationsByTag$1 = {
791
+ users: { getUser, updateUser, deleteUser },
792
+ authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
793
+ workspaces: {
794
+ getWorkspacesList,
795
+ createWorkspace,
796
+ getWorkspace,
797
+ updateWorkspace,
798
+ deleteWorkspace,
799
+ getWorkspaceMembersList,
800
+ updateWorkspaceMemberRole,
801
+ removeWorkspaceMember
802
+ },
803
+ invites: {
804
+ inviteWorkspaceMember,
805
+ updateWorkspaceMemberInvite,
806
+ cancelWorkspaceMemberInvite,
807
+ acceptWorkspaceMemberInvite,
808
+ resendWorkspaceMemberInvite
635
809
  },
636
810
  databases: {
637
- cPgetDatabaseList,
638
- cPcreateDatabase,
639
- cPdeleteDatabase,
640
- cPgetCPDatabaseMetadata,
641
- cPupdateCPDatabaseMetadata
811
+ getDatabaseList,
812
+ createDatabase,
813
+ deleteDatabase,
814
+ getDatabaseMetadata,
815
+ updateDatabaseMetadata,
816
+ listRegions
642
817
  }
643
818
  };
644
819
 
820
+ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
821
+
645
822
  function getHostUrl(provider, type) {
646
823
  if (isHostProviderAlias(provider)) {
647
824
  return providers[provider][type];
@@ -653,11 +830,11 @@ function getHostUrl(provider, type) {
653
830
  const providers = {
654
831
  production: {
655
832
  main: "https://api.xata.io",
656
- workspaces: "https://{workspaceId}.xata.sh"
833
+ workspaces: "https://{workspaceId}.{region}.xata.sh"
657
834
  },
658
835
  staging: {
659
836
  main: "https://staging.xatabase.co",
660
- workspaces: "https://{workspaceId}.staging.xatabase.co"
837
+ workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
661
838
  }
662
839
  };
663
840
  function isHostProviderAlias(alias) {
@@ -666,6 +843,25 @@ function isHostProviderAlias(alias) {
666
843
  function isHostProviderBuilder(builder) {
667
844
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
668
845
  }
846
+ function parseProviderString(provider = "production") {
847
+ if (isHostProviderAlias(provider)) {
848
+ return provider;
849
+ }
850
+ const [main, workspaces] = provider.split(",");
851
+ if (!main || !workspaces)
852
+ return null;
853
+ return { main, workspaces };
854
+ }
855
+ function parseWorkspacesUrlParts(url) {
856
+ if (!isString(url))
857
+ return null;
858
+ const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
859
+ const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))\.xatabase\.co.*/;
860
+ const match = url.match(regex) || url.match(regexStaging);
861
+ if (!match)
862
+ return null;
863
+ return { workspace: match[1], region: match[2] };
864
+ }
669
865
 
670
866
  var __accessCheck$7 = (obj, member, msg) => {
671
867
  if (!member.has(obj))
@@ -693,6 +889,7 @@ class XataApiClient {
693
889
  const provider = options.host ?? "production";
694
890
  const apiKey = options.apiKey ?? getAPIKey();
695
891
  const trace = options.trace ?? defaultTrace;
892
+ const clientID = generateUUID();
696
893
  if (!apiKey) {
697
894
  throw new Error("Could not resolve a valid apiKey");
698
895
  }
@@ -701,7 +898,9 @@ class XataApiClient {
701
898
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
702
899
  fetchImpl: getFetchImplementation(options.fetch),
703
900
  apiKey,
704
- trace
901
+ trace,
902
+ clientName: options.clientName,
903
+ clientID
705
904
  });
706
905
  }
707
906
  get user() {
@@ -709,21 +908,41 @@ class XataApiClient {
709
908
  __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
710
909
  return __privateGet$7(this, _namespaces).user;
711
910
  }
911
+ get authentication() {
912
+ if (!__privateGet$7(this, _namespaces).authentication)
913
+ __privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
914
+ return __privateGet$7(this, _namespaces).authentication;
915
+ }
712
916
  get workspaces() {
713
917
  if (!__privateGet$7(this, _namespaces).workspaces)
714
918
  __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
715
919
  return __privateGet$7(this, _namespaces).workspaces;
716
920
  }
717
- get databases() {
718
- if (!__privateGet$7(this, _namespaces).databases)
719
- __privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
720
- return __privateGet$7(this, _namespaces).databases;
921
+ get invites() {
922
+ if (!__privateGet$7(this, _namespaces).invites)
923
+ __privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
924
+ return __privateGet$7(this, _namespaces).invites;
925
+ }
926
+ get database() {
927
+ if (!__privateGet$7(this, _namespaces).database)
928
+ __privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
929
+ return __privateGet$7(this, _namespaces).database;
721
930
  }
722
931
  get branches() {
723
932
  if (!__privateGet$7(this, _namespaces).branches)
724
933
  __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
725
934
  return __privateGet$7(this, _namespaces).branches;
726
935
  }
936
+ get migrations() {
937
+ if (!__privateGet$7(this, _namespaces).migrations)
938
+ __privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
939
+ return __privateGet$7(this, _namespaces).migrations;
940
+ }
941
+ get migrationRequests() {
942
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
943
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
944
+ return __privateGet$7(this, _namespaces).migrationRequests;
945
+ }
727
946
  get tables() {
728
947
  if (!__privateGet$7(this, _namespaces).tables)
729
948
  __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
@@ -734,15 +953,10 @@ class XataApiClient {
734
953
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
735
954
  return __privateGet$7(this, _namespaces).records;
736
955
  }
737
- get migrationRequests() {
738
- if (!__privateGet$7(this, _namespaces).migrationRequests)
739
- __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
740
- return __privateGet$7(this, _namespaces).migrationRequests;
741
- }
742
- get branchSchema() {
743
- if (!__privateGet$7(this, _namespaces).branchSchema)
744
- __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
745
- return __privateGet$7(this, _namespaces).branchSchema;
956
+ get searchAndFilter() {
957
+ if (!__privateGet$7(this, _namespaces).searchAndFilter)
958
+ __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
959
+ return __privateGet$7(this, _namespaces).searchAndFilter;
746
960
  }
747
961
  }
748
962
  _extraProps = new WeakMap();
@@ -754,24 +968,29 @@ class UserApi {
754
968
  getUser() {
755
969
  return operationsByTag.users.getUser({ ...this.extraProps });
756
970
  }
757
- updateUser(user) {
971
+ updateUser({ user }) {
758
972
  return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
759
973
  }
760
974
  deleteUser() {
761
975
  return operationsByTag.users.deleteUser({ ...this.extraProps });
762
976
  }
977
+ }
978
+ class AuthenticationApi {
979
+ constructor(extraProps) {
980
+ this.extraProps = extraProps;
981
+ }
763
982
  getUserAPIKeys() {
764
- return operationsByTag.users.getUserAPIKeys({ ...this.extraProps });
983
+ return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
765
984
  }
766
- createUserAPIKey(keyName) {
767
- return operationsByTag.users.createUserAPIKey({
768
- pathParams: { keyName },
985
+ createUserAPIKey({ name }) {
986
+ return operationsByTag.authentication.createUserAPIKey({
987
+ pathParams: { keyName: name },
769
988
  ...this.extraProps
770
989
  });
771
990
  }
772
- deleteUserAPIKey(keyName) {
773
- return operationsByTag.users.deleteUserAPIKey({
774
- pathParams: { keyName },
991
+ deleteUserAPIKey({ name }) {
992
+ return operationsByTag.authentication.deleteUserAPIKey({
993
+ pathParams: { keyName: name },
775
994
  ...this.extraProps
776
995
  });
777
996
  }
@@ -780,196 +999,248 @@ class WorkspaceApi {
780
999
  constructor(extraProps) {
781
1000
  this.extraProps = extraProps;
782
1001
  }
783
- createWorkspace(workspaceMeta) {
1002
+ getWorkspacesList() {
1003
+ return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
1004
+ }
1005
+ createWorkspace({ data }) {
784
1006
  return operationsByTag.workspaces.createWorkspace({
785
- body: workspaceMeta,
1007
+ body: data,
786
1008
  ...this.extraProps
787
1009
  });
788
1010
  }
789
- getWorkspacesList() {
790
- return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
791
- }
792
- getWorkspace(workspaceId) {
1011
+ getWorkspace({ workspace }) {
793
1012
  return operationsByTag.workspaces.getWorkspace({
794
- pathParams: { workspaceId },
1013
+ pathParams: { workspaceId: workspace },
795
1014
  ...this.extraProps
796
1015
  });
797
1016
  }
798
- updateWorkspace(workspaceId, workspaceMeta) {
1017
+ updateWorkspace({
1018
+ workspace,
1019
+ update
1020
+ }) {
799
1021
  return operationsByTag.workspaces.updateWorkspace({
800
- pathParams: { workspaceId },
801
- body: workspaceMeta,
1022
+ pathParams: { workspaceId: workspace },
1023
+ body: update,
802
1024
  ...this.extraProps
803
1025
  });
804
1026
  }
805
- deleteWorkspace(workspaceId) {
1027
+ deleteWorkspace({ workspace }) {
806
1028
  return operationsByTag.workspaces.deleteWorkspace({
807
- pathParams: { workspaceId },
1029
+ pathParams: { workspaceId: workspace },
808
1030
  ...this.extraProps
809
1031
  });
810
1032
  }
811
- getWorkspaceMembersList(workspaceId) {
1033
+ getWorkspaceMembersList({ workspace }) {
812
1034
  return operationsByTag.workspaces.getWorkspaceMembersList({
813
- pathParams: { workspaceId },
1035
+ pathParams: { workspaceId: workspace },
814
1036
  ...this.extraProps
815
1037
  });
816
1038
  }
817
- updateWorkspaceMemberRole(workspaceId, userId, role) {
1039
+ updateWorkspaceMemberRole({
1040
+ workspace,
1041
+ user,
1042
+ role
1043
+ }) {
818
1044
  return operationsByTag.workspaces.updateWorkspaceMemberRole({
819
- pathParams: { workspaceId, userId },
1045
+ pathParams: { workspaceId: workspace, userId: user },
820
1046
  body: { role },
821
1047
  ...this.extraProps
822
1048
  });
823
1049
  }
824
- removeWorkspaceMember(workspaceId, userId) {
1050
+ removeWorkspaceMember({
1051
+ workspace,
1052
+ user
1053
+ }) {
825
1054
  return operationsByTag.workspaces.removeWorkspaceMember({
826
- pathParams: { workspaceId, userId },
1055
+ pathParams: { workspaceId: workspace, userId: user },
827
1056
  ...this.extraProps
828
1057
  });
829
1058
  }
830
- inviteWorkspaceMember(workspaceId, email, role) {
831
- return operationsByTag.workspaces.inviteWorkspaceMember({
832
- pathParams: { workspaceId },
1059
+ }
1060
+ class InvitesApi {
1061
+ constructor(extraProps) {
1062
+ this.extraProps = extraProps;
1063
+ }
1064
+ inviteWorkspaceMember({
1065
+ workspace,
1066
+ email,
1067
+ role
1068
+ }) {
1069
+ return operationsByTag.invites.inviteWorkspaceMember({
1070
+ pathParams: { workspaceId: workspace },
833
1071
  body: { email, role },
834
1072
  ...this.extraProps
835
1073
  });
836
1074
  }
837
- updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
838
- return operationsByTag.workspaces.updateWorkspaceMemberInvite({
839
- pathParams: { workspaceId, inviteId },
1075
+ updateWorkspaceMemberInvite({
1076
+ workspace,
1077
+ invite,
1078
+ role
1079
+ }) {
1080
+ return operationsByTag.invites.updateWorkspaceMemberInvite({
1081
+ pathParams: { workspaceId: workspace, inviteId: invite },
840
1082
  body: { role },
841
1083
  ...this.extraProps
842
1084
  });
843
1085
  }
844
- cancelWorkspaceMemberInvite(workspaceId, inviteId) {
845
- return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
846
- pathParams: { workspaceId, inviteId },
1086
+ cancelWorkspaceMemberInvite({
1087
+ workspace,
1088
+ invite
1089
+ }) {
1090
+ return operationsByTag.invites.cancelWorkspaceMemberInvite({
1091
+ pathParams: { workspaceId: workspace, inviteId: invite },
847
1092
  ...this.extraProps
848
1093
  });
849
1094
  }
850
- resendWorkspaceMemberInvite(workspaceId, inviteId) {
851
- return operationsByTag.workspaces.resendWorkspaceMemberInvite({
852
- pathParams: { workspaceId, inviteId },
1095
+ acceptWorkspaceMemberInvite({
1096
+ workspace,
1097
+ key
1098
+ }) {
1099
+ return operationsByTag.invites.acceptWorkspaceMemberInvite({
1100
+ pathParams: { workspaceId: workspace, inviteKey: key },
853
1101
  ...this.extraProps
854
1102
  });
855
1103
  }
856
- acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
857
- return operationsByTag.workspaces.acceptWorkspaceMemberInvite({
858
- pathParams: { workspaceId, inviteKey },
1104
+ resendWorkspaceMemberInvite({
1105
+ workspace,
1106
+ invite
1107
+ }) {
1108
+ return operationsByTag.invites.resendWorkspaceMemberInvite({
1109
+ pathParams: { workspaceId: workspace, inviteId: invite },
859
1110
  ...this.extraProps
860
1111
  });
861
1112
  }
862
1113
  }
863
- class DatabaseApi {
1114
+ class BranchApi {
864
1115
  constructor(extraProps) {
865
1116
  this.extraProps = extraProps;
866
1117
  }
867
- getDatabaseList(workspace) {
868
- return operationsByTag.database.getDatabaseList({
869
- pathParams: { workspace },
870
- ...this.extraProps
871
- });
872
- }
873
- createDatabase(workspace, dbName, options = {}) {
874
- return operationsByTag.database.createDatabase({
875
- pathParams: { workspace, dbName },
876
- body: options,
877
- ...this.extraProps
878
- });
879
- }
880
- deleteDatabase(workspace, dbName) {
881
- return operationsByTag.database.deleteDatabase({
882
- pathParams: { workspace, dbName },
883
- ...this.extraProps
884
- });
885
- }
886
- getDatabaseMetadata(workspace, dbName) {
887
- return operationsByTag.database.getDatabaseMetadata({
888
- pathParams: { workspace, dbName },
889
- ...this.extraProps
890
- });
891
- }
892
- updateDatabaseMetadata(workspace, dbName, options = {}) {
893
- return operationsByTag.database.updateDatabaseMetadata({
894
- pathParams: { workspace, dbName },
895
- body: options,
896
- ...this.extraProps
897
- });
898
- }
899
- getGitBranchesMapping(workspace, dbName) {
900
- return operationsByTag.database.getGitBranchesMapping({
901
- pathParams: { workspace, dbName },
1118
+ getBranchList({
1119
+ workspace,
1120
+ region,
1121
+ database
1122
+ }) {
1123
+ return operationsByTag.branch.getBranchList({
1124
+ pathParams: { workspace, region, dbName: database },
902
1125
  ...this.extraProps
903
1126
  });
904
1127
  }
905
- addGitBranchesEntry(workspace, dbName, body) {
906
- return operationsByTag.database.addGitBranchesEntry({
907
- pathParams: { workspace, dbName },
908
- body,
1128
+ getBranchDetails({
1129
+ workspace,
1130
+ region,
1131
+ database,
1132
+ branch
1133
+ }) {
1134
+ return operationsByTag.branch.getBranchDetails({
1135
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
909
1136
  ...this.extraProps
910
1137
  });
911
1138
  }
912
- removeGitBranchesEntry(workspace, dbName, gitBranch) {
913
- return operationsByTag.database.removeGitBranchesEntry({
914
- pathParams: { workspace, dbName },
915
- queryParams: { gitBranch },
1139
+ createBranch({
1140
+ workspace,
1141
+ region,
1142
+ database,
1143
+ branch,
1144
+ from,
1145
+ metadata
1146
+ }) {
1147
+ return operationsByTag.branch.createBranch({
1148
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1149
+ body: { from, metadata },
916
1150
  ...this.extraProps
917
1151
  });
918
1152
  }
919
- resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
920
- return operationsByTag.database.resolveBranch({
921
- pathParams: { workspace, dbName },
922
- queryParams: { gitBranch, fallbackBranch },
1153
+ deleteBranch({
1154
+ workspace,
1155
+ region,
1156
+ database,
1157
+ branch
1158
+ }) {
1159
+ return operationsByTag.branch.deleteBranch({
1160
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
923
1161
  ...this.extraProps
924
1162
  });
925
1163
  }
926
- }
927
- class BranchApi {
928
- constructor(extraProps) {
929
- this.extraProps = extraProps;
930
- }
931
- getBranchList(workspace, dbName) {
932
- return operationsByTag.branch.getBranchList({
933
- pathParams: { workspace, dbName },
1164
+ updateBranchMetadata({
1165
+ workspace,
1166
+ region,
1167
+ database,
1168
+ branch,
1169
+ metadata
1170
+ }) {
1171
+ return operationsByTag.branch.updateBranchMetadata({
1172
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1173
+ body: metadata,
934
1174
  ...this.extraProps
935
1175
  });
936
1176
  }
937
- getBranchDetails(workspace, database, branch) {
938
- return operationsByTag.branch.getBranchDetails({
939
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1177
+ getBranchMetadata({
1178
+ workspace,
1179
+ region,
1180
+ database,
1181
+ branch
1182
+ }) {
1183
+ return operationsByTag.branch.getBranchMetadata({
1184
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
940
1185
  ...this.extraProps
941
1186
  });
942
1187
  }
943
- createBranch(workspace, database, branch, from, options = {}) {
944
- return operationsByTag.branch.createBranch({
945
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
946
- queryParams: isString(from) ? { from } : void 0,
947
- body: options,
1188
+ getBranchStats({
1189
+ workspace,
1190
+ region,
1191
+ database,
1192
+ branch
1193
+ }) {
1194
+ return operationsByTag.branch.getBranchStats({
1195
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
948
1196
  ...this.extraProps
949
1197
  });
950
1198
  }
951
- deleteBranch(workspace, database, branch) {
952
- return operationsByTag.branch.deleteBranch({
953
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1199
+ getGitBranchesMapping({
1200
+ workspace,
1201
+ region,
1202
+ database
1203
+ }) {
1204
+ return operationsByTag.branch.getGitBranchesMapping({
1205
+ pathParams: { workspace, region, dbName: database },
954
1206
  ...this.extraProps
955
1207
  });
956
1208
  }
957
- updateBranchMetadata(workspace, database, branch, metadata = {}) {
958
- return operationsByTag.branch.updateBranchMetadata({
959
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
960
- body: metadata,
1209
+ addGitBranchesEntry({
1210
+ workspace,
1211
+ region,
1212
+ database,
1213
+ gitBranch,
1214
+ xataBranch
1215
+ }) {
1216
+ return operationsByTag.branch.addGitBranchesEntry({
1217
+ pathParams: { workspace, region, dbName: database },
1218
+ body: { gitBranch, xataBranch },
961
1219
  ...this.extraProps
962
1220
  });
963
1221
  }
964
- getBranchMetadata(workspace, database, branch) {
965
- return operationsByTag.branch.getBranchMetadata({
966
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1222
+ removeGitBranchesEntry({
1223
+ workspace,
1224
+ region,
1225
+ database,
1226
+ gitBranch
1227
+ }) {
1228
+ return operationsByTag.branch.removeGitBranchesEntry({
1229
+ pathParams: { workspace, region, dbName: database },
1230
+ queryParams: { gitBranch },
967
1231
  ...this.extraProps
968
1232
  });
969
1233
  }
970
- getBranchStats(workspace, database, branch) {
971
- return operationsByTag.branch.getBranchStats({
972
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1234
+ resolveBranch({
1235
+ workspace,
1236
+ region,
1237
+ database,
1238
+ gitBranch,
1239
+ fallbackBranch
1240
+ }) {
1241
+ return operationsByTag.branch.resolveBranch({
1242
+ pathParams: { workspace, region, dbName: database },
1243
+ queryParams: { gitBranch, fallbackBranch },
973
1244
  ...this.extraProps
974
1245
  });
975
1246
  }
@@ -978,67 +1249,134 @@ class TableApi {
978
1249
  constructor(extraProps) {
979
1250
  this.extraProps = extraProps;
980
1251
  }
981
- createTable(workspace, database, branch, tableName) {
1252
+ createTable({
1253
+ workspace,
1254
+ region,
1255
+ database,
1256
+ branch,
1257
+ table
1258
+ }) {
982
1259
  return operationsByTag.table.createTable({
983
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1260
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
984
1261
  ...this.extraProps
985
1262
  });
986
1263
  }
987
- deleteTable(workspace, database, branch, tableName) {
1264
+ deleteTable({
1265
+ workspace,
1266
+ region,
1267
+ database,
1268
+ branch,
1269
+ table
1270
+ }) {
988
1271
  return operationsByTag.table.deleteTable({
989
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1272
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
990
1273
  ...this.extraProps
991
1274
  });
992
1275
  }
993
- updateTable(workspace, database, branch, tableName, options) {
1276
+ updateTable({
1277
+ workspace,
1278
+ region,
1279
+ database,
1280
+ branch,
1281
+ table,
1282
+ update
1283
+ }) {
994
1284
  return operationsByTag.table.updateTable({
995
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
996
- body: options,
1285
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1286
+ body: update,
997
1287
  ...this.extraProps
998
1288
  });
999
1289
  }
1000
- getTableSchema(workspace, database, branch, tableName) {
1290
+ getTableSchema({
1291
+ workspace,
1292
+ region,
1293
+ database,
1294
+ branch,
1295
+ table
1296
+ }) {
1001
1297
  return operationsByTag.table.getTableSchema({
1002
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1298
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1003
1299
  ...this.extraProps
1004
1300
  });
1005
1301
  }
1006
- setTableSchema(workspace, database, branch, tableName, options) {
1302
+ setTableSchema({
1303
+ workspace,
1304
+ region,
1305
+ database,
1306
+ branch,
1307
+ table,
1308
+ schema
1309
+ }) {
1007
1310
  return operationsByTag.table.setTableSchema({
1008
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1009
- body: options,
1311
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1312
+ body: schema,
1010
1313
  ...this.extraProps
1011
1314
  });
1012
1315
  }
1013
- getTableColumns(workspace, database, branch, tableName) {
1316
+ getTableColumns({
1317
+ workspace,
1318
+ region,
1319
+ database,
1320
+ branch,
1321
+ table
1322
+ }) {
1014
1323
  return operationsByTag.table.getTableColumns({
1015
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1324
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1016
1325
  ...this.extraProps
1017
1326
  });
1018
1327
  }
1019
- addTableColumn(workspace, database, branch, tableName, column) {
1328
+ addTableColumn({
1329
+ workspace,
1330
+ region,
1331
+ database,
1332
+ branch,
1333
+ table,
1334
+ column
1335
+ }) {
1020
1336
  return operationsByTag.table.addTableColumn({
1021
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1337
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1022
1338
  body: column,
1023
1339
  ...this.extraProps
1024
1340
  });
1025
1341
  }
1026
- getColumn(workspace, database, branch, tableName, columnName) {
1342
+ getColumn({
1343
+ workspace,
1344
+ region,
1345
+ database,
1346
+ branch,
1347
+ table,
1348
+ column
1349
+ }) {
1027
1350
  return operationsByTag.table.getColumn({
1028
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1351
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1029
1352
  ...this.extraProps
1030
1353
  });
1031
1354
  }
1032
- deleteColumn(workspace, database, branch, tableName, columnName) {
1033
- return operationsByTag.table.deleteColumn({
1034
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1355
+ updateColumn({
1356
+ workspace,
1357
+ region,
1358
+ database,
1359
+ branch,
1360
+ table,
1361
+ column,
1362
+ update
1363
+ }) {
1364
+ return operationsByTag.table.updateColumn({
1365
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1366
+ body: update,
1035
1367
  ...this.extraProps
1036
1368
  });
1037
1369
  }
1038
- updateColumn(workspace, database, branch, tableName, columnName, options) {
1039
- return operationsByTag.table.updateColumn({
1040
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1041
- body: options,
1370
+ deleteColumn({
1371
+ workspace,
1372
+ region,
1373
+ database,
1374
+ branch,
1375
+ table,
1376
+ column
1377
+ }) {
1378
+ return operationsByTag.table.deleteColumn({
1379
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1042
1380
  ...this.extraProps
1043
1381
  });
1044
1382
  }
@@ -1047,85 +1385,228 @@ class RecordsApi {
1047
1385
  constructor(extraProps) {
1048
1386
  this.extraProps = extraProps;
1049
1387
  }
1050
- insertRecord(workspace, database, branch, tableName, record, options = {}) {
1388
+ insertRecord({
1389
+ workspace,
1390
+ region,
1391
+ database,
1392
+ branch,
1393
+ table,
1394
+ record,
1395
+ columns
1396
+ }) {
1051
1397
  return operationsByTag.records.insertRecord({
1052
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1053
- queryParams: options,
1398
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1399
+ queryParams: { columns },
1054
1400
  body: record,
1055
1401
  ...this.extraProps
1056
1402
  });
1057
1403
  }
1058
- insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1404
+ getRecord({
1405
+ workspace,
1406
+ region,
1407
+ database,
1408
+ branch,
1409
+ table,
1410
+ id,
1411
+ columns
1412
+ }) {
1413
+ return operationsByTag.records.getRecord({
1414
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1415
+ queryParams: { columns },
1416
+ ...this.extraProps
1417
+ });
1418
+ }
1419
+ insertRecordWithID({
1420
+ workspace,
1421
+ region,
1422
+ database,
1423
+ branch,
1424
+ table,
1425
+ id,
1426
+ record,
1427
+ columns,
1428
+ createOnly,
1429
+ ifVersion
1430
+ }) {
1059
1431
  return operationsByTag.records.insertRecordWithID({
1060
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1061
- queryParams: options,
1432
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1433
+ queryParams: { columns, createOnly, ifVersion },
1062
1434
  body: record,
1063
1435
  ...this.extraProps
1064
1436
  });
1065
1437
  }
1066
- updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1438
+ updateRecordWithID({
1439
+ workspace,
1440
+ region,
1441
+ database,
1442
+ branch,
1443
+ table,
1444
+ id,
1445
+ record,
1446
+ columns,
1447
+ ifVersion
1448
+ }) {
1067
1449
  return operationsByTag.records.updateRecordWithID({
1068
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1069
- queryParams: options,
1450
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1451
+ queryParams: { columns, ifVersion },
1070
1452
  body: record,
1071
1453
  ...this.extraProps
1072
1454
  });
1073
1455
  }
1074
- upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1456
+ upsertRecordWithID({
1457
+ workspace,
1458
+ region,
1459
+ database,
1460
+ branch,
1461
+ table,
1462
+ id,
1463
+ record,
1464
+ columns,
1465
+ ifVersion
1466
+ }) {
1075
1467
  return operationsByTag.records.upsertRecordWithID({
1076
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1077
- queryParams: options,
1468
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1469
+ queryParams: { columns, ifVersion },
1078
1470
  body: record,
1079
1471
  ...this.extraProps
1080
1472
  });
1081
1473
  }
1082
- deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
1474
+ deleteRecord({
1475
+ workspace,
1476
+ region,
1477
+ database,
1478
+ branch,
1479
+ table,
1480
+ id,
1481
+ columns
1482
+ }) {
1083
1483
  return operationsByTag.records.deleteRecord({
1084
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1085
- queryParams: options,
1086
- ...this.extraProps
1087
- });
1088
- }
1089
- getRecord(workspace, database, branch, tableName, recordId, options = {}) {
1090
- return operationsByTag.records.getRecord({
1091
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1092
- queryParams: options,
1484
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1485
+ queryParams: { columns },
1093
1486
  ...this.extraProps
1094
1487
  });
1095
1488
  }
1096
- bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
1489
+ bulkInsertTableRecords({
1490
+ workspace,
1491
+ region,
1492
+ database,
1493
+ branch,
1494
+ table,
1495
+ records,
1496
+ columns
1497
+ }) {
1097
1498
  return operationsByTag.records.bulkInsertTableRecords({
1098
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1099
- queryParams: options,
1499
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1500
+ queryParams: { columns },
1100
1501
  body: { records },
1101
1502
  ...this.extraProps
1102
1503
  });
1103
1504
  }
1104
- queryTable(workspace, database, branch, tableName, query) {
1105
- return operationsByTag.records.queryTable({
1106
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1107
- body: query,
1108
- ...this.extraProps
1109
- });
1110
- }
1111
- searchTable(workspace, database, branch, tableName, query) {
1112
- return operationsByTag.records.searchTable({
1113
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1114
- body: query,
1505
+ branchTransaction({
1506
+ workspace,
1507
+ region,
1508
+ database,
1509
+ branch,
1510
+ operations
1511
+ }) {
1512
+ return operationsByTag.records.branchTransaction({
1513
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1514
+ body: { operations },
1115
1515
  ...this.extraProps
1116
1516
  });
1117
1517
  }
1118
- searchBranch(workspace, database, branch, query) {
1119
- return operationsByTag.records.searchBranch({
1120
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1121
- body: query,
1122
- ...this.extraProps
1123
- });
1518
+ }
1519
+ class SearchAndFilterApi {
1520
+ constructor(extraProps) {
1521
+ this.extraProps = extraProps;
1124
1522
  }
1125
- summarizeTable(workspace, database, branch, tableName, query) {
1126
- return operationsByTag.records.summarizeTable({
1127
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1128
- body: query,
1523
+ queryTable({
1524
+ workspace,
1525
+ region,
1526
+ database,
1527
+ branch,
1528
+ table,
1529
+ filter,
1530
+ sort,
1531
+ page,
1532
+ columns,
1533
+ consistency
1534
+ }) {
1535
+ return operationsByTag.searchAndFilter.queryTable({
1536
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1537
+ body: { filter, sort, page, columns, consistency },
1538
+ ...this.extraProps
1539
+ });
1540
+ }
1541
+ searchTable({
1542
+ workspace,
1543
+ region,
1544
+ database,
1545
+ branch,
1546
+ table,
1547
+ query,
1548
+ fuzziness,
1549
+ target,
1550
+ prefix,
1551
+ filter,
1552
+ highlight,
1553
+ boosters
1554
+ }) {
1555
+ return operationsByTag.searchAndFilter.searchTable({
1556
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1557
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
1558
+ ...this.extraProps
1559
+ });
1560
+ }
1561
+ searchBranch({
1562
+ workspace,
1563
+ region,
1564
+ database,
1565
+ branch,
1566
+ tables,
1567
+ query,
1568
+ fuzziness,
1569
+ prefix,
1570
+ highlight
1571
+ }) {
1572
+ return operationsByTag.searchAndFilter.searchBranch({
1573
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1574
+ body: { tables, query, fuzziness, prefix, highlight },
1575
+ ...this.extraProps
1576
+ });
1577
+ }
1578
+ summarizeTable({
1579
+ workspace,
1580
+ region,
1581
+ database,
1582
+ branch,
1583
+ table,
1584
+ filter,
1585
+ columns,
1586
+ summaries,
1587
+ sort,
1588
+ summariesFilter,
1589
+ page,
1590
+ consistency
1591
+ }) {
1592
+ return operationsByTag.searchAndFilter.summarizeTable({
1593
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1594
+ body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
1595
+ ...this.extraProps
1596
+ });
1597
+ }
1598
+ aggregateTable({
1599
+ workspace,
1600
+ region,
1601
+ database,
1602
+ branch,
1603
+ table,
1604
+ filter,
1605
+ aggs
1606
+ }) {
1607
+ return operationsByTag.searchAndFilter.aggregateTable({
1608
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1609
+ body: { filter, aggs },
1129
1610
  ...this.extraProps
1130
1611
  });
1131
1612
  }
@@ -1134,123 +1615,281 @@ class MigrationRequestsApi {
1134
1615
  constructor(extraProps) {
1135
1616
  this.extraProps = extraProps;
1136
1617
  }
1137
- listMigrationRequests(workspace, database, options = {}) {
1138
- return operationsByTag.migrationRequests.listMigrationRequests({
1139
- pathParams: { workspace, dbName: database },
1140
- body: options,
1141
- ...this.extraProps
1142
- });
1143
- }
1144
- createMigrationRequest(workspace, database, options) {
1618
+ queryMigrationRequests({
1619
+ workspace,
1620
+ region,
1621
+ database,
1622
+ filter,
1623
+ sort,
1624
+ page,
1625
+ columns
1626
+ }) {
1627
+ return operationsByTag.migrationRequests.queryMigrationRequests({
1628
+ pathParams: { workspace, region, dbName: database },
1629
+ body: { filter, sort, page, columns },
1630
+ ...this.extraProps
1631
+ });
1632
+ }
1633
+ createMigrationRequest({
1634
+ workspace,
1635
+ region,
1636
+ database,
1637
+ migration
1638
+ }) {
1145
1639
  return operationsByTag.migrationRequests.createMigrationRequest({
1146
- pathParams: { workspace, dbName: database },
1147
- body: options,
1640
+ pathParams: { workspace, region, dbName: database },
1641
+ body: migration,
1148
1642
  ...this.extraProps
1149
1643
  });
1150
1644
  }
1151
- getMigrationRequest(workspace, database, migrationRequest) {
1645
+ getMigrationRequest({
1646
+ workspace,
1647
+ region,
1648
+ database,
1649
+ migrationRequest
1650
+ }) {
1152
1651
  return operationsByTag.migrationRequests.getMigrationRequest({
1153
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1652
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1154
1653
  ...this.extraProps
1155
1654
  });
1156
1655
  }
1157
- updateMigrationRequest(workspace, database, migrationRequest, options) {
1656
+ updateMigrationRequest({
1657
+ workspace,
1658
+ region,
1659
+ database,
1660
+ migrationRequest,
1661
+ update
1662
+ }) {
1158
1663
  return operationsByTag.migrationRequests.updateMigrationRequest({
1159
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1160
- body: options,
1664
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1665
+ body: update,
1161
1666
  ...this.extraProps
1162
1667
  });
1163
1668
  }
1164
- listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1669
+ listMigrationRequestsCommits({
1670
+ workspace,
1671
+ region,
1672
+ database,
1673
+ migrationRequest,
1674
+ page
1675
+ }) {
1165
1676
  return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1166
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1167
- body: options,
1677
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1678
+ body: { page },
1168
1679
  ...this.extraProps
1169
1680
  });
1170
1681
  }
1171
- compareMigrationRequest(workspace, database, migrationRequest) {
1682
+ compareMigrationRequest({
1683
+ workspace,
1684
+ region,
1685
+ database,
1686
+ migrationRequest
1687
+ }) {
1172
1688
  return operationsByTag.migrationRequests.compareMigrationRequest({
1173
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1689
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1174
1690
  ...this.extraProps
1175
1691
  });
1176
1692
  }
1177
- getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1693
+ getMigrationRequestIsMerged({
1694
+ workspace,
1695
+ region,
1696
+ database,
1697
+ migrationRequest
1698
+ }) {
1178
1699
  return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1179
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1700
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1180
1701
  ...this.extraProps
1181
1702
  });
1182
1703
  }
1183
- mergeMigrationRequest(workspace, database, migrationRequest) {
1704
+ mergeMigrationRequest({
1705
+ workspace,
1706
+ region,
1707
+ database,
1708
+ migrationRequest
1709
+ }) {
1184
1710
  return operationsByTag.migrationRequests.mergeMigrationRequest({
1185
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1711
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1186
1712
  ...this.extraProps
1187
1713
  });
1188
1714
  }
1189
1715
  }
1190
- class BranchSchemaApi {
1716
+ class MigrationsApi {
1191
1717
  constructor(extraProps) {
1192
1718
  this.extraProps = extraProps;
1193
1719
  }
1194
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
1195
- return operationsByTag.branchSchema.getBranchMigrationHistory({
1196
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1197
- body: options,
1720
+ getBranchMigrationHistory({
1721
+ workspace,
1722
+ region,
1723
+ database,
1724
+ branch,
1725
+ limit,
1726
+ startFrom
1727
+ }) {
1728
+ return operationsByTag.migrations.getBranchMigrationHistory({
1729
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1730
+ body: { limit, startFrom },
1731
+ ...this.extraProps
1732
+ });
1733
+ }
1734
+ getBranchMigrationPlan({
1735
+ workspace,
1736
+ region,
1737
+ database,
1738
+ branch,
1739
+ schema
1740
+ }) {
1741
+ return operationsByTag.migrations.getBranchMigrationPlan({
1742
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1743
+ body: schema,
1198
1744
  ...this.extraProps
1199
1745
  });
1200
1746
  }
1201
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1202
- return operationsByTag.branchSchema.executeBranchMigrationPlan({
1203
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1204
- body: migrationPlan,
1747
+ executeBranchMigrationPlan({
1748
+ workspace,
1749
+ region,
1750
+ database,
1751
+ branch,
1752
+ plan
1753
+ }) {
1754
+ return operationsByTag.migrations.executeBranchMigrationPlan({
1755
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1756
+ body: plan,
1205
1757
  ...this.extraProps
1206
1758
  });
1207
1759
  }
1208
- getBranchMigrationPlan(workspace, database, branch, schema) {
1209
- return operationsByTag.branchSchema.getBranchMigrationPlan({
1210
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1211
- body: schema,
1760
+ getBranchSchemaHistory({
1761
+ workspace,
1762
+ region,
1763
+ database,
1764
+ branch,
1765
+ page
1766
+ }) {
1767
+ return operationsByTag.migrations.getBranchSchemaHistory({
1768
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1769
+ body: { page },
1212
1770
  ...this.extraProps
1213
1771
  });
1214
1772
  }
1215
- compareBranchWithUserSchema(workspace, database, branch, schema) {
1216
- return operationsByTag.branchSchema.compareBranchWithUserSchema({
1217
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1773
+ compareBranchWithUserSchema({
1774
+ workspace,
1775
+ region,
1776
+ database,
1777
+ branch,
1778
+ schema
1779
+ }) {
1780
+ return operationsByTag.migrations.compareBranchWithUserSchema({
1781
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1218
1782
  body: { schema },
1219
1783
  ...this.extraProps
1220
1784
  });
1221
1785
  }
1222
- compareBranchSchemas(workspace, database, branch, branchName, schema) {
1223
- return operationsByTag.branchSchema.compareBranchSchemas({
1224
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1786
+ compareBranchSchemas({
1787
+ workspace,
1788
+ region,
1789
+ database,
1790
+ branch,
1791
+ compare,
1792
+ schema
1793
+ }) {
1794
+ return operationsByTag.migrations.compareBranchSchemas({
1795
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
1225
1796
  body: { schema },
1226
1797
  ...this.extraProps
1227
1798
  });
1228
1799
  }
1229
- updateBranchSchema(workspace, database, branch, migration) {
1230
- return operationsByTag.branchSchema.updateBranchSchema({
1231
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1800
+ updateBranchSchema({
1801
+ workspace,
1802
+ region,
1803
+ database,
1804
+ branch,
1805
+ migration
1806
+ }) {
1807
+ return operationsByTag.migrations.updateBranchSchema({
1808
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1232
1809
  body: migration,
1233
1810
  ...this.extraProps
1234
1811
  });
1235
1812
  }
1236
- previewBranchSchemaEdit(workspace, database, branch, migration) {
1237
- return operationsByTag.branchSchema.previewBranchSchemaEdit({
1238
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1239
- body: migration,
1813
+ previewBranchSchemaEdit({
1814
+ workspace,
1815
+ region,
1816
+ database,
1817
+ branch,
1818
+ data
1819
+ }) {
1820
+ return operationsByTag.migrations.previewBranchSchemaEdit({
1821
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1822
+ body: data,
1240
1823
  ...this.extraProps
1241
1824
  });
1242
1825
  }
1243
- applyBranchSchemaEdit(workspace, database, branch, edits) {
1244
- return operationsByTag.branchSchema.applyBranchSchemaEdit({
1245
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1826
+ applyBranchSchemaEdit({
1827
+ workspace,
1828
+ region,
1829
+ database,
1830
+ branch,
1831
+ edits
1832
+ }) {
1833
+ return operationsByTag.migrations.applyBranchSchemaEdit({
1834
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1246
1835
  body: { edits },
1247
1836
  ...this.extraProps
1248
1837
  });
1249
1838
  }
1250
- getBranchSchemaHistory(workspace, database, branch, options = {}) {
1251
- return operationsByTag.branchSchema.getBranchSchemaHistory({
1252
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1253
- body: options,
1839
+ }
1840
+ class DatabaseApi {
1841
+ constructor(extraProps) {
1842
+ this.extraProps = extraProps;
1843
+ }
1844
+ getDatabaseList({ workspace }) {
1845
+ return operationsByTag.databases.getDatabaseList({
1846
+ pathParams: { workspaceId: workspace },
1847
+ ...this.extraProps
1848
+ });
1849
+ }
1850
+ createDatabase({
1851
+ workspace,
1852
+ database,
1853
+ data
1854
+ }) {
1855
+ return operationsByTag.databases.createDatabase({
1856
+ pathParams: { workspaceId: workspace, dbName: database },
1857
+ body: data,
1858
+ ...this.extraProps
1859
+ });
1860
+ }
1861
+ deleteDatabase({
1862
+ workspace,
1863
+ database
1864
+ }) {
1865
+ return operationsByTag.databases.deleteDatabase({
1866
+ pathParams: { workspaceId: workspace, dbName: database },
1867
+ ...this.extraProps
1868
+ });
1869
+ }
1870
+ getDatabaseMetadata({
1871
+ workspace,
1872
+ database
1873
+ }) {
1874
+ return operationsByTag.databases.getDatabaseMetadata({
1875
+ pathParams: { workspaceId: workspace, dbName: database },
1876
+ ...this.extraProps
1877
+ });
1878
+ }
1879
+ updateDatabaseMetadata({
1880
+ workspace,
1881
+ database,
1882
+ metadata
1883
+ }) {
1884
+ return operationsByTag.databases.updateDatabaseMetadata({
1885
+ pathParams: { workspaceId: workspace, dbName: database },
1886
+ body: metadata,
1887
+ ...this.extraProps
1888
+ });
1889
+ }
1890
+ listRegions({ workspace }) {
1891
+ return operationsByTag.databases.listRegions({
1892
+ pathParams: { workspaceId: workspace },
1254
1893
  ...this.extraProps
1255
1894
  });
1256
1895
  }
@@ -1266,6 +1905,13 @@ class XataApiPlugin {
1266
1905
  class XataPlugin {
1267
1906
  }
1268
1907
 
1908
+ function cleanFilter(filter) {
1909
+ if (!filter)
1910
+ return void 0;
1911
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
1912
+ return values.length > 0 ? filter : void 0;
1913
+ }
1914
+
1269
1915
  var __accessCheck$6 = (obj, member, msg) => {
1270
1916
  if (!member.has(obj))
1271
1917
  throw TypeError("Cannot " + msg);
@@ -1298,11 +1944,11 @@ class Page {
1298
1944
  async previousPage(size, offset) {
1299
1945
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
1300
1946
  }
1301
- async firstPage(size, offset) {
1302
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
1947
+ async startPage(size, offset) {
1948
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
1303
1949
  }
1304
- async lastPage(size, offset) {
1305
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
1950
+ async endPage(size, offset) {
1951
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
1306
1952
  }
1307
1953
  hasNextPage() {
1308
1954
  return this.meta.page.more;
@@ -1314,7 +1960,7 @@ const PAGINATION_DEFAULT_SIZE = 20;
1314
1960
  const PAGINATION_MAX_OFFSET = 800;
1315
1961
  const PAGINATION_DEFAULT_OFFSET = 0;
1316
1962
  function isCursorPaginationOptions(options) {
1317
- return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
1963
+ return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
1318
1964
  }
1319
1965
  const _RecordArray = class extends Array {
1320
1966
  constructor(...args) {
@@ -1346,12 +1992,12 @@ const _RecordArray = class extends Array {
1346
1992
  const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
1347
1993
  return new _RecordArray(newPage);
1348
1994
  }
1349
- async firstPage(size, offset) {
1350
- const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
1995
+ async startPage(size, offset) {
1996
+ const newPage = await __privateGet$6(this, _page).startPage(size, offset);
1351
1997
  return new _RecordArray(newPage);
1352
1998
  }
1353
- async lastPage(size, offset) {
1354
- const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
1999
+ async endPage(size, offset) {
2000
+ const newPage = await __privateGet$6(this, _page).endPage(size, offset);
1355
2001
  return new _RecordArray(newPage);
1356
2002
  }
1357
2003
  hasNextPage() {
@@ -1405,9 +2051,11 @@ const _Query = class {
1405
2051
  __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
1406
2052
  __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
1407
2053
  __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
1408
- __privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
2054
+ __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
2055
+ __privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
1409
2056
  __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
1410
2057
  __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
2058
+ __privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
1411
2059
  this.any = this.any.bind(this);
1412
2060
  this.all = this.all.bind(this);
1413
2061
  this.not = this.not.bind(this);
@@ -1521,19 +2169,29 @@ const _Query = class {
1521
2169
  throw new Error("No results found.");
1522
2170
  return records[0];
1523
2171
  }
2172
+ async summarize(params = {}) {
2173
+ const { summaries, summariesFilter, ...options } = params;
2174
+ const query = new _Query(
2175
+ __privateGet$5(this, _repository),
2176
+ __privateGet$5(this, _table$1),
2177
+ options,
2178
+ __privateGet$5(this, _data)
2179
+ );
2180
+ return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
2181
+ }
1524
2182
  cache(ttl) {
1525
2183
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1526
2184
  }
1527
2185
  nextPage(size, offset) {
1528
- return this.firstPage(size, offset);
2186
+ return this.startPage(size, offset);
1529
2187
  }
1530
2188
  previousPage(size, offset) {
1531
- return this.firstPage(size, offset);
2189
+ return this.startPage(size, offset);
1532
2190
  }
1533
- firstPage(size, offset) {
2191
+ startPage(size, offset) {
1534
2192
  return this.getPaginated({ pagination: { size, offset } });
1535
2193
  }
1536
- lastPage(size, offset) {
2194
+ endPage(size, offset) {
1537
2195
  return this.getPaginated({ pagination: { size, offset, before: "end" } });
1538
2196
  }
1539
2197
  hasNextPage() {
@@ -1557,7 +2215,7 @@ cleanFilterConstraint_fn = function(column, value) {
1557
2215
  };
1558
2216
  function cleanParent(data, parent) {
1559
2217
  if (isCursorPaginationOptions(data.pagination)) {
1560
- return { ...parent, sorting: void 0, filter: void 0 };
2218
+ return { ...parent, sort: void 0, filter: void 0 };
1561
2219
  }
1562
2220
  return parent;
1563
2221
  }
@@ -1616,7 +2274,8 @@ var __privateMethod$2 = (obj, member, method) => {
1616
2274
  __accessCheck$4(obj, member, "access private method");
1617
2275
  return method;
1618
2276
  };
1619
- var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
2277
+ 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;
2278
+ const BULK_OPERATION_MAX_SIZE = 1e3;
1620
2279
  class Repository extends Query {
1621
2280
  }
1622
2281
  class RestRepository extends Query {
@@ -1628,10 +2287,12 @@ class RestRepository extends Query {
1628
2287
  );
1629
2288
  __privateAdd$4(this, _insertRecordWithoutId);
1630
2289
  __privateAdd$4(this, _insertRecordWithId);
1631
- __privateAdd$4(this, _bulkInsertTableRecords);
2290
+ __privateAdd$4(this, _insertRecords);
1632
2291
  __privateAdd$4(this, _updateRecordWithID);
2292
+ __privateAdd$4(this, _updateRecords);
1633
2293
  __privateAdd$4(this, _upsertRecordWithID);
1634
2294
  __privateAdd$4(this, _deleteRecord);
2295
+ __privateAdd$4(this, _deleteRecords);
1635
2296
  __privateAdd$4(this, _setCacheQuery);
1636
2297
  __privateAdd$4(this, _getCacheQuery);
1637
2298
  __privateAdd$4(this, _getSchemaTables$1);
@@ -1642,10 +2303,13 @@ class RestRepository extends Query {
1642
2303
  __privateAdd$4(this, _schemaTables$2, void 0);
1643
2304
  __privateAdd$4(this, _trace, void 0);
1644
2305
  __privateSet$4(this, _table, options.table);
1645
- __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1646
2306
  __privateSet$4(this, _db, options.db);
1647
2307
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1648
2308
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
2309
+ __privateSet$4(this, _getFetchProps, async () => {
2310
+ const props = await options.pluginOptions.getFetchProps();
2311
+ return { ...props, sessionID: generateUUID() };
2312
+ });
1649
2313
  const trace = options.pluginOptions.trace ?? defaultTrace;
1650
2314
  __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
1651
2315
  return trace(name, fn, {
@@ -1656,25 +2320,28 @@ class RestRepository extends Query {
1656
2320
  });
1657
2321
  });
1658
2322
  }
1659
- async create(a, b, c) {
2323
+ async create(a, b, c, d) {
1660
2324
  return __privateGet$4(this, _trace).call(this, "create", async () => {
2325
+ const ifVersion = parseIfVersion(b, c, d);
1661
2326
  if (Array.isArray(a)) {
1662
2327
  if (a.length === 0)
1663
2328
  return [];
1664
- const columns = isStringArray(b) ? b : void 0;
1665
- return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
2329
+ const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
2330
+ const columns = isStringArray(b) ? b : ["*"];
2331
+ const result = await this.read(ids, columns);
2332
+ return result;
1666
2333
  }
1667
2334
  if (isString(a) && isObject(b)) {
1668
2335
  if (a === "")
1669
2336
  throw new Error("The id can't be empty");
1670
2337
  const columns = isStringArray(c) ? c : void 0;
1671
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
2338
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
1672
2339
  }
1673
2340
  if (isObject(a) && isString(a.id)) {
1674
2341
  if (a.id === "")
1675
2342
  throw new Error("The id can't be empty");
1676
2343
  const columns = isStringArray(b) ? b : void 0;
1677
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2344
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
1678
2345
  }
1679
2346
  if (isObject(a)) {
1680
2347
  const columns = isStringArray(b) ? b : void 0;
@@ -1705,6 +2372,7 @@ class RestRepository extends Query {
1705
2372
  pathParams: {
1706
2373
  workspace: "{workspaceId}",
1707
2374
  dbBranchName: "{dbBranch}",
2375
+ region: "{region}",
1708
2376
  tableName: __privateGet$4(this, _table),
1709
2377
  recordId: id
1710
2378
  },
@@ -1742,31 +2410,42 @@ class RestRepository extends Query {
1742
2410
  return result;
1743
2411
  });
1744
2412
  }
1745
- async update(a, b, c) {
2413
+ async update(a, b, c, d) {
1746
2414
  return __privateGet$4(this, _trace).call(this, "update", async () => {
2415
+ const ifVersion = parseIfVersion(b, c, d);
1747
2416
  if (Array.isArray(a)) {
1748
2417
  if (a.length === 0)
1749
2418
  return [];
1750
- if (a.length > 100) {
1751
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1752
- }
2419
+ const existing = await this.read(a, ["id"]);
2420
+ const updates = a.filter((_item, index) => existing[index] !== null);
2421
+ await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
2422
+ ifVersion,
2423
+ upsert: false
2424
+ });
1753
2425
  const columns = isStringArray(b) ? b : ["*"];
1754
- return Promise.all(a.map((object) => this.update(object, columns)));
1755
- }
1756
- if (isString(a) && isObject(b)) {
1757
- const columns = isStringArray(c) ? c : void 0;
1758
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
2426
+ const result = await this.read(a, columns);
2427
+ return result;
1759
2428
  }
1760
- if (isObject(a) && isString(a.id)) {
1761
- const columns = isStringArray(b) ? b : void 0;
1762
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2429
+ try {
2430
+ if (isString(a) && isObject(b)) {
2431
+ const columns = isStringArray(c) ? c : void 0;
2432
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2433
+ }
2434
+ if (isObject(a) && isString(a.id)) {
2435
+ const columns = isStringArray(b) ? b : void 0;
2436
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2437
+ }
2438
+ } catch (error) {
2439
+ if (error.status === 422)
2440
+ return null;
2441
+ throw error;
1763
2442
  }
1764
2443
  throw new Error("Invalid arguments for update method");
1765
2444
  });
1766
2445
  }
1767
- async updateOrThrow(a, b, c) {
2446
+ async updateOrThrow(a, b, c, d) {
1768
2447
  return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1769
- const result = await this.update(a, b, c);
2448
+ const result = await this.update(a, b, c, d);
1770
2449
  if (Array.isArray(result)) {
1771
2450
  const missingIds = compact(
1772
2451
  a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
@@ -1783,37 +2462,69 @@ class RestRepository extends Query {
1783
2462
  return result;
1784
2463
  });
1785
2464
  }
1786
- async createOrUpdate(a, b, c) {
2465
+ async createOrUpdate(a, b, c, d) {
1787
2466
  return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
2467
+ const ifVersion = parseIfVersion(b, c, d);
1788
2468
  if (Array.isArray(a)) {
1789
2469
  if (a.length === 0)
1790
2470
  return [];
1791
- if (a.length > 100) {
1792
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1793
- }
2471
+ await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
2472
+ ifVersion,
2473
+ upsert: true
2474
+ });
1794
2475
  const columns = isStringArray(b) ? b : ["*"];
1795
- return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
2476
+ const result = await this.read(a, columns);
2477
+ return result;
1796
2478
  }
1797
2479
  if (isString(a) && isObject(b)) {
1798
2480
  const columns = isStringArray(c) ? c : void 0;
1799
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
2481
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1800
2482
  }
1801
2483
  if (isObject(a) && isString(a.id)) {
1802
2484
  const columns = isStringArray(c) ? c : void 0;
1803
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2485
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
1804
2486
  }
1805
2487
  throw new Error("Invalid arguments for createOrUpdate method");
1806
2488
  });
1807
2489
  }
2490
+ async createOrReplace(a, b, c, d) {
2491
+ return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
2492
+ const ifVersion = parseIfVersion(b, c, d);
2493
+ if (Array.isArray(a)) {
2494
+ if (a.length === 0)
2495
+ return [];
2496
+ const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
2497
+ const columns = isStringArray(b) ? b : ["*"];
2498
+ const result = await this.read(ids, columns);
2499
+ return result;
2500
+ }
2501
+ if (isString(a) && isObject(b)) {
2502
+ const columns = isStringArray(c) ? c : void 0;
2503
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
2504
+ }
2505
+ if (isObject(a) && isString(a.id)) {
2506
+ const columns = isStringArray(c) ? c : void 0;
2507
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
2508
+ }
2509
+ throw new Error("Invalid arguments for createOrReplace method");
2510
+ });
2511
+ }
1808
2512
  async delete(a, b) {
1809
2513
  return __privateGet$4(this, _trace).call(this, "delete", async () => {
1810
2514
  if (Array.isArray(a)) {
1811
2515
  if (a.length === 0)
1812
2516
  return [];
1813
- if (a.length > 100) {
1814
- console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1815
- }
1816
- return Promise.all(a.map((id) => this.delete(id, b)));
2517
+ const ids = a.map((o) => {
2518
+ if (isString(o))
2519
+ return o;
2520
+ if (isString(o.id))
2521
+ return o.id;
2522
+ throw new Error("Invalid arguments for delete method");
2523
+ });
2524
+ const columns = isStringArray(b) ? b : ["*"];
2525
+ const result = await this.read(a, columns);
2526
+ await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
2527
+ return result;
1817
2528
  }
1818
2529
  if (isString(a)) {
1819
2530
  return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
@@ -1846,14 +2557,21 @@ class RestRepository extends Query {
1846
2557
  return __privateGet$4(this, _trace).call(this, "search", async () => {
1847
2558
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1848
2559
  const { records } = await searchTable({
1849
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2560
+ pathParams: {
2561
+ workspace: "{workspaceId}",
2562
+ dbBranchName: "{dbBranch}",
2563
+ region: "{region}",
2564
+ tableName: __privateGet$4(this, _table)
2565
+ },
1850
2566
  body: {
1851
2567
  query,
1852
2568
  fuzziness: options.fuzziness,
1853
2569
  prefix: options.prefix,
1854
2570
  highlight: options.highlight,
1855
2571
  filter: options.filter,
1856
- boosters: options.boosters
2572
+ boosters: options.boosters,
2573
+ page: options.page,
2574
+ target: options.target
1857
2575
  },
1858
2576
  ...fetchProps
1859
2577
  });
@@ -1861,22 +2579,44 @@ class RestRepository extends Query {
1861
2579
  return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
1862
2580
  });
1863
2581
  }
2582
+ async aggregate(aggs, filter) {
2583
+ return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
2584
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2585
+ const result = await aggregateTable({
2586
+ pathParams: {
2587
+ workspace: "{workspaceId}",
2588
+ dbBranchName: "{dbBranch}",
2589
+ region: "{region}",
2590
+ tableName: __privateGet$4(this, _table)
2591
+ },
2592
+ body: { aggs, filter },
2593
+ ...fetchProps
2594
+ });
2595
+ return result;
2596
+ });
2597
+ }
1864
2598
  async query(query) {
1865
2599
  return __privateGet$4(this, _trace).call(this, "query", async () => {
1866
2600
  const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1867
2601
  if (cacheQuery)
1868
2602
  return new Page(query, cacheQuery.meta, cacheQuery.records);
1869
2603
  const data = query.getQueryOptions();
1870
- const body = {
1871
- filter: cleanFilter(data.filter),
1872
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1873
- page: data.pagination,
1874
- columns: data.columns
1875
- };
1876
2604
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1877
2605
  const { meta, records: objects } = await queryTable({
1878
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1879
- body,
2606
+ pathParams: {
2607
+ workspace: "{workspaceId}",
2608
+ dbBranchName: "{dbBranch}",
2609
+ region: "{region}",
2610
+ tableName: __privateGet$4(this, _table)
2611
+ },
2612
+ body: {
2613
+ filter: cleanFilter(data.filter),
2614
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2615
+ page: data.pagination,
2616
+ columns: data.columns ?? ["*"],
2617
+ consistency: data.consistency
2618
+ },
2619
+ fetchOptions: data.fetchOptions,
1880
2620
  ...fetchProps
1881
2621
  });
1882
2622
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
@@ -1887,6 +2627,31 @@ class RestRepository extends Query {
1887
2627
  return new Page(query, meta, records);
1888
2628
  });
1889
2629
  }
2630
+ async summarizeTable(query, summaries, summariesFilter) {
2631
+ return __privateGet$4(this, _trace).call(this, "summarize", async () => {
2632
+ const data = query.getQueryOptions();
2633
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2634
+ const result = await summarizeTable({
2635
+ pathParams: {
2636
+ workspace: "{workspaceId}",
2637
+ dbBranchName: "{dbBranch}",
2638
+ region: "{region}",
2639
+ tableName: __privateGet$4(this, _table)
2640
+ },
2641
+ body: {
2642
+ filter: cleanFilter(data.filter),
2643
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2644
+ columns: data.columns,
2645
+ consistency: data.consistency,
2646
+ page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
2647
+ summaries,
2648
+ summariesFilter
2649
+ },
2650
+ ...fetchProps
2651
+ });
2652
+ return result;
2653
+ });
2654
+ }
1890
2655
  }
1891
2656
  _table = new WeakMap();
1892
2657
  _getFetchProps = new WeakMap();
@@ -1902,6 +2667,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1902
2667
  pathParams: {
1903
2668
  workspace: "{workspaceId}",
1904
2669
  dbBranchName: "{dbBranch}",
2670
+ region: "{region}",
1905
2671
  tableName: __privateGet$4(this, _table)
1906
2672
  },
1907
2673
  queryParams: { columns },
@@ -1912,47 +2678,68 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1912
2678
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1913
2679
  };
1914
2680
  _insertRecordWithId = new WeakSet();
1915
- insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
2681
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
1916
2682
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1917
2683
  const record = transformObjectLinks(object);
1918
2684
  const response = await insertRecordWithID({
1919
2685
  pathParams: {
1920
2686
  workspace: "{workspaceId}",
1921
2687
  dbBranchName: "{dbBranch}",
2688
+ region: "{region}",
1922
2689
  tableName: __privateGet$4(this, _table),
1923
2690
  recordId
1924
2691
  },
1925
2692
  body: record,
1926
- queryParams: { createOnly: true, columns },
2693
+ queryParams: { createOnly, columns, ifVersion },
1927
2694
  ...fetchProps
1928
2695
  });
1929
2696
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1930
2697
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1931
2698
  };
1932
- _bulkInsertTableRecords = new WeakSet();
1933
- bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
2699
+ _insertRecords = new WeakSet();
2700
+ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
1934
2701
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1935
- const records = objects.map((object) => transformObjectLinks(object));
1936
- const response = await bulkInsertTableRecords({
1937
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1938
- queryParams: { columns },
1939
- body: { records },
1940
- ...fetchProps
1941
- });
1942
- if (!isResponseWithRecords(response)) {
1943
- throw new Error("Request included columns but server didn't include them");
2702
+ const chunkedOperations = chunk(
2703
+ objects.map((object) => ({
2704
+ insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
2705
+ })),
2706
+ BULK_OPERATION_MAX_SIZE
2707
+ );
2708
+ const ids = [];
2709
+ for (const operations of chunkedOperations) {
2710
+ const { results } = await branchTransaction({
2711
+ pathParams: {
2712
+ workspace: "{workspaceId}",
2713
+ dbBranchName: "{dbBranch}",
2714
+ region: "{region}"
2715
+ },
2716
+ body: { operations },
2717
+ ...fetchProps
2718
+ });
2719
+ for (const result of results) {
2720
+ if (result.operation === "insert") {
2721
+ ids.push(result.id);
2722
+ } else {
2723
+ ids.push(null);
2724
+ }
2725
+ }
1944
2726
  }
1945
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1946
- return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
2727
+ return ids;
1947
2728
  };
1948
2729
  _updateRecordWithID = new WeakSet();
1949
- updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2730
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
1950
2731
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1951
- const record = transformObjectLinks(object);
2732
+ const { id: _id, ...record } = transformObjectLinks(object);
1952
2733
  try {
1953
2734
  const response = await updateRecordWithID({
1954
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1955
- queryParams: { columns },
2735
+ pathParams: {
2736
+ workspace: "{workspaceId}",
2737
+ dbBranchName: "{dbBranch}",
2738
+ region: "{region}",
2739
+ tableName: __privateGet$4(this, _table),
2740
+ recordId
2741
+ },
2742
+ queryParams: { columns, ifVersion },
1956
2743
  body: record,
1957
2744
  ...fetchProps
1958
2745
  });
@@ -1965,12 +2752,48 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1965
2752
  throw e;
1966
2753
  }
1967
2754
  };
2755
+ _updateRecords = new WeakSet();
2756
+ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
2757
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2758
+ const chunkedOperations = chunk(
2759
+ objects.map(({ id, ...object }) => ({
2760
+ update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
2761
+ })),
2762
+ BULK_OPERATION_MAX_SIZE
2763
+ );
2764
+ const ids = [];
2765
+ for (const operations of chunkedOperations) {
2766
+ const { results } = await branchTransaction({
2767
+ pathParams: {
2768
+ workspace: "{workspaceId}",
2769
+ dbBranchName: "{dbBranch}",
2770
+ region: "{region}"
2771
+ },
2772
+ body: { operations },
2773
+ ...fetchProps
2774
+ });
2775
+ for (const result of results) {
2776
+ if (result.operation === "update") {
2777
+ ids.push(result.id);
2778
+ } else {
2779
+ ids.push(null);
2780
+ }
2781
+ }
2782
+ }
2783
+ return ids;
2784
+ };
1968
2785
  _upsertRecordWithID = new WeakSet();
1969
- upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2786
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
1970
2787
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1971
2788
  const response = await upsertRecordWithID({
1972
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1973
- queryParams: { columns },
2789
+ pathParams: {
2790
+ workspace: "{workspaceId}",
2791
+ dbBranchName: "{dbBranch}",
2792
+ region: "{region}",
2793
+ tableName: __privateGet$4(this, _table),
2794
+ recordId
2795
+ },
2796
+ queryParams: { columns, ifVersion },
1974
2797
  body: object,
1975
2798
  ...fetchProps
1976
2799
  });
@@ -1982,7 +2805,13 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1982
2805
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1983
2806
  try {
1984
2807
  const response = await deleteRecord({
1985
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2808
+ pathParams: {
2809
+ workspace: "{workspaceId}",
2810
+ dbBranchName: "{dbBranch}",
2811
+ region: "{region}",
2812
+ tableName: __privateGet$4(this, _table),
2813
+ recordId
2814
+ },
1986
2815
  queryParams: { columns },
1987
2816
  ...fetchProps
1988
2817
  });
@@ -1995,6 +2824,25 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1995
2824
  throw e;
1996
2825
  }
1997
2826
  };
2827
+ _deleteRecords = new WeakSet();
2828
+ deleteRecords_fn = async function(recordIds) {
2829
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2830
+ const chunkedOperations = chunk(
2831
+ recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
2832
+ BULK_OPERATION_MAX_SIZE
2833
+ );
2834
+ for (const operations of chunkedOperations) {
2835
+ await branchTransaction({
2836
+ pathParams: {
2837
+ workspace: "{workspaceId}",
2838
+ dbBranchName: "{dbBranch}",
2839
+ region: "{region}"
2840
+ },
2841
+ body: { operations },
2842
+ ...fetchProps
2843
+ });
2844
+ }
2845
+ };
1998
2846
  _setCacheQuery = new WeakSet();
1999
2847
  setCacheQuery_fn = async function(query, meta, records) {
2000
2848
  await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
@@ -2017,7 +2865,7 @@ getSchemaTables_fn$1 = async function() {
2017
2865
  return __privateGet$4(this, _schemaTables$2);
2018
2866
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2019
2867
  const { schema } = await getBranchDetails({
2020
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2868
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2021
2869
  ...fetchProps
2022
2870
  });
2023
2871
  __privateSet$4(this, _schemaTables$2, schema.tables);
@@ -2043,10 +2891,10 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2043
2891
  const value = result[column.name];
2044
2892
  switch (column.type) {
2045
2893
  case "datetime": {
2046
- const date = value !== void 0 ? new Date(value) : void 0;
2047
- if (date && isNaN(date.getTime())) {
2894
+ const date = value !== void 0 ? new Date(value) : null;
2895
+ if (date !== null && isNaN(date.getTime())) {
2048
2896
  console.error(`Failed to parse date ${value} for field ${column.name}`);
2049
- } else if (date) {
2897
+ } else {
2050
2898
  result[column.name] = date;
2051
2899
  }
2052
2900
  break;
@@ -2083,8 +2931,15 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2083
2931
  result.read = function(columns2) {
2084
2932
  return db[table].read(result["id"], columns2);
2085
2933
  };
2086
- result.update = function(data, columns2) {
2087
- return db[table].update(result["id"], data, columns2);
2934
+ result.update = function(data, b, c) {
2935
+ const columns2 = isStringArray(b) ? b : ["*"];
2936
+ const ifVersion = parseIfVersion(b, c);
2937
+ return db[table].update(result["id"], data, columns2, { ifVersion });
2938
+ };
2939
+ result.replace = function(data, b, c) {
2940
+ const columns2 = isStringArray(b) ? b : ["*"];
2941
+ const ifVersion = parseIfVersion(b, c);
2942
+ return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
2088
2943
  };
2089
2944
  result.delete = function() {
2090
2945
  return db[table].delete(result["id"]);
@@ -2092,15 +2947,12 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2092
2947
  result.getMetadata = function() {
2093
2948
  return xata;
2094
2949
  };
2095
- for (const prop of ["read", "update", "delete", "getMetadata"]) {
2950
+ for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
2096
2951
  Object.defineProperty(result, prop, { enumerable: false });
2097
2952
  }
2098
2953
  Object.freeze(result);
2099
2954
  return result;
2100
2955
  };
2101
- function isResponseWithRecords(value) {
2102
- return isObject(value) && Array.isArray(value.records);
2103
- }
2104
2956
  function extractId(value) {
2105
2957
  if (isString(value))
2106
2958
  return value;
@@ -2108,12 +2960,6 @@ function extractId(value) {
2108
2960
  return value.id;
2109
2961
  return void 0;
2110
2962
  }
2111
- function cleanFilter(filter) {
2112
- if (!filter)
2113
- return void 0;
2114
- const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2115
- return values.length > 0 ? filter : void 0;
2116
- }
2117
2963
  function isValidColumn(columns, column) {
2118
2964
  if (columns.includes("*"))
2119
2965
  return true;
@@ -2123,6 +2969,14 @@ function isValidColumn(columns, column) {
2123
2969
  }
2124
2970
  return columns.includes(column.name);
2125
2971
  }
2972
+ function parseIfVersion(...args) {
2973
+ for (const arg of args) {
2974
+ if (isObject(arg) && isNumber(arg.ifVersion)) {
2975
+ return arg.ifVersion;
2976
+ }
2977
+ }
2978
+ return void 0;
2979
+ }
2126
2980
 
2127
2981
  var __accessCheck$3 = (obj, member, msg) => {
2128
2982
  if (!member.has(obj))
@@ -2308,10 +3162,10 @@ _schemaTables = new WeakMap();
2308
3162
  _search = new WeakSet();
2309
3163
  search_fn = async function(query, options, getFetchProps) {
2310
3164
  const fetchProps = await getFetchProps();
2311
- const { tables, fuzziness, highlight, prefix } = options ?? {};
3165
+ const { tables, fuzziness, highlight, prefix, page } = options ?? {};
2312
3166
  const { records } = await searchBranch({
2313
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2314
- body: { tables, query, fuzziness, prefix, highlight },
3167
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3168
+ body: { tables, query, fuzziness, prefix, highlight, page },
2315
3169
  ...fetchProps
2316
3170
  });
2317
3171
  return records;
@@ -2322,25 +3176,37 @@ getSchemaTables_fn = async function(getFetchProps) {
2322
3176
  return __privateGet$1(this, _schemaTables);
2323
3177
  const fetchProps = await getFetchProps();
2324
3178
  const { schema } = await getBranchDetails({
2325
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
3179
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2326
3180
  ...fetchProps
2327
3181
  });
2328
3182
  __privateSet$1(this, _schemaTables, schema.tables);
2329
3183
  return schema.tables;
2330
3184
  };
2331
3185
 
3186
+ class TransactionPlugin extends XataPlugin {
3187
+ build({ getFetchProps }) {
3188
+ return {
3189
+ run: async (operations) => {
3190
+ const fetchProps = await getFetchProps();
3191
+ const response = await branchTransaction({
3192
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3193
+ body: { operations },
3194
+ ...fetchProps
3195
+ });
3196
+ return response;
3197
+ }
3198
+ };
3199
+ }
3200
+ }
3201
+
2332
3202
  const isBranchStrategyBuilder = (strategy) => {
2333
3203
  return typeof strategy === "function";
2334
3204
  };
2335
3205
 
2336
3206
  async function getCurrentBranchName(options) {
2337
3207
  const { branch, envBranch } = getEnvironment();
2338
- if (branch) {
2339
- const details = await getDatabaseBranch(branch, options);
2340
- if (details)
2341
- return branch;
2342
- console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
2343
- }
3208
+ if (branch)
3209
+ return branch;
2344
3210
  const gitBranch = envBranch || await getGitBranch();
2345
3211
  return resolveXataBranch(gitBranch, options);
2346
3212
  }
@@ -2360,16 +3226,20 @@ async function resolveXataBranch(gitBranch, options) {
2360
3226
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2361
3227
  );
2362
3228
  const [protocol, , host, , dbName] = databaseURL.split("/");
2363
- const [workspace] = host.split(".");
3229
+ const urlParts = parseWorkspacesUrlParts(host);
3230
+ if (!urlParts)
3231
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3232
+ const { workspace, region } = urlParts;
2364
3233
  const { fallbackBranch } = getEnvironment();
2365
3234
  const { branch } = await resolveBranch({
2366
3235
  apiKey,
2367
3236
  apiUrl: databaseURL,
2368
3237
  fetchImpl: getFetchImplementation(options?.fetchImpl),
2369
3238
  workspacesApiUrl: `${protocol}//${host}`,
2370
- pathParams: { dbName, workspace },
3239
+ pathParams: { dbName, workspace, region },
2371
3240
  queryParams: { gitBranch, fallbackBranch },
2372
- trace: defaultTrace
3241
+ trace: defaultTrace,
3242
+ clientName: options?.clientName
2373
3243
  });
2374
3244
  return branch;
2375
3245
  }
@@ -2385,15 +3255,17 @@ async function getDatabaseBranch(branch, options) {
2385
3255
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2386
3256
  );
2387
3257
  const [protocol, , host, , database] = databaseURL.split("/");
2388
- const [workspace] = host.split(".");
2389
- const dbBranchName = `${database}:${branch}`;
3258
+ const urlParts = parseWorkspacesUrlParts(host);
3259
+ if (!urlParts)
3260
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3261
+ const { workspace, region } = urlParts;
2390
3262
  try {
2391
3263
  return await getBranchDetails({
2392
3264
  apiKey,
2393
3265
  apiUrl: databaseURL,
2394
3266
  fetchImpl: getFetchImplementation(options?.fetchImpl),
2395
3267
  workspacesApiUrl: `${protocol}//${host}`,
2396
- pathParams: { dbBranchName, workspace },
3268
+ pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
2397
3269
  trace: defaultTrace
2398
3270
  });
2399
3271
  } catch (err) {
@@ -2451,8 +3323,10 @@ const buildClient = (plugins) => {
2451
3323
  };
2452
3324
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
2453
3325
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
3326
+ const transactions = new TransactionPlugin().build(pluginOptions);
2454
3327
  this.db = db;
2455
3328
  this.search = search;
3329
+ this.transactions = transactions;
2456
3330
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
2457
3331
  if (namespace === void 0)
2458
3332
  continue;
@@ -2472,20 +3346,41 @@ const buildClient = (plugins) => {
2472
3346
  return { databaseURL, branch };
2473
3347
  }
2474
3348
  }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
3349
+ const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
3350
+ const isBrowser = typeof window !== "undefined";
3351
+ if (isBrowser && !enableBrowser) {
3352
+ throw new Error(
3353
+ "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."
3354
+ );
3355
+ }
2475
3356
  const fetch = getFetchImplementation(options?.fetch);
2476
3357
  const databaseURL = options?.databaseURL || getDatabaseURL();
2477
3358
  const apiKey = options?.apiKey || getAPIKey();
2478
3359
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
2479
3360
  const trace = options?.trace ?? defaultTrace;
2480
- const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
3361
+ const clientName = options?.clientName;
3362
+ const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({
3363
+ apiKey,
3364
+ databaseURL,
3365
+ fetchImpl: options?.fetch,
3366
+ clientName: options?.clientName
3367
+ });
2481
3368
  if (!apiKey) {
2482
3369
  throw new Error("Option apiKey is required");
2483
3370
  }
2484
3371
  if (!databaseURL) {
2485
3372
  throw new Error("Option databaseURL is required");
2486
3373
  }
2487
- return { fetch, databaseURL, apiKey, branch, cache, trace };
2488
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
3374
+ return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser, clientName };
3375
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
3376
+ fetch,
3377
+ apiKey,
3378
+ databaseURL,
3379
+ branch,
3380
+ trace,
3381
+ clientID,
3382
+ clientName
3383
+ }) {
2489
3384
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2490
3385
  if (!branchValue)
2491
3386
  throw new Error("Unable to resolve branch value");
@@ -2498,7 +3393,9 @@ const buildClient = (plugins) => {
2498
3393
  const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
2499
3394
  return databaseURL + newPath;
2500
3395
  },
2501
- trace
3396
+ trace,
3397
+ clientID,
3398
+ clientName
2502
3399
  };
2503
3400
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2504
3401
  if (__privateGet(this, _branch))
@@ -2589,7 +3486,7 @@ const deserialize = (json) => {
2589
3486
  };
2590
3487
 
2591
3488
  function buildWorkerRunner(config) {
2592
- return function xataWorker(name, _worker) {
3489
+ return function xataWorker(name, worker) {
2593
3490
  return async (...args) => {
2594
3491
  const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
2595
3492
  const result = await fetch(url, {
@@ -2610,5 +3507,5 @@ class XataError extends Error {
2610
3507
  }
2611
3508
  }
2612
3509
 
2613
- 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, cPcreateDatabase, cPdeleteDatabase, cPgetCPDatabaseMetadata, cPgetDatabaseList, cPupdateCPDatabaseMetadata, 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 };
3510
+ 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 };
2614
3511
  //# sourceMappingURL=index.mjs.map