@xata.io/client 0.0.0-alpha.vf1f4abe → 0.0.0-alpha.vf20a10c

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