@xata.io/client 0.0.0-alpha.vfe9bed6 → 0.0.0-alpha.vfed34c9

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,16 +62,39 @@ 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(),
56
93
  branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
57
- envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
58
- fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
94
+ deployPreview: process.env.XATA_PREVIEW,
95
+ deployPreviewBranch: process.env.XATA_PREVIEW_BRANCH,
96
+ vercelGitCommitRef: process.env.VERCEL_GIT_COMMIT_REF,
97
+ vercelGitRepoOwner: process.env.VERCEL_GIT_REPO_OWNER
59
98
  };
60
99
  }
61
100
  } catch (err) {
@@ -66,8 +105,10 @@ function getEnvironment() {
66
105
  apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
67
106
  databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
68
107
  branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
69
- envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
70
- fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
108
+ deployPreview: Deno.env.get("XATA_PREVIEW"),
109
+ deployPreviewBranch: Deno.env.get("XATA_PREVIEW_BRANCH"),
110
+ vercelGitCommitRef: Deno.env.get("VERCEL_GIT_COMMIT_REF"),
111
+ vercelGitRepoOwner: Deno.env.get("VERCEL_GIT_REPO_OWNER")
71
112
  };
72
113
  }
73
114
  } catch (err) {
@@ -76,10 +117,31 @@ function getEnvironment() {
76
117
  apiKey: getGlobalApiKey(),
77
118
  databaseURL: getGlobalDatabaseURL(),
78
119
  branch: getGlobalBranch(),
79
- envBranch: void 0,
80
- fallbackBranch: getGlobalFallbackBranch()
120
+ deployPreview: void 0,
121
+ deployPreviewBranch: void 0,
122
+ vercelGitCommitRef: void 0,
123
+ vercelGitRepoOwner: void 0
81
124
  };
82
125
  }
126
+ function getEnableBrowserVariable() {
127
+ try {
128
+ if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
129
+ return process.env.XATA_ENABLE_BROWSER === "true";
130
+ }
131
+ } catch (err) {
132
+ }
133
+ try {
134
+ if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
135
+ return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
136
+ }
137
+ } catch (err) {
138
+ }
139
+ try {
140
+ return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
141
+ } catch (err) {
142
+ return void 0;
143
+ }
144
+ }
83
145
  function getGlobalApiKey() {
84
146
  try {
85
147
  return XATA_API_KEY;
@@ -101,44 +163,76 @@ function getGlobalBranch() {
101
163
  return void 0;
102
164
  }
103
165
  }
104
- function getGlobalFallbackBranch() {
166
+ function getDatabaseURL() {
105
167
  try {
106
- return XATA_FALLBACK_BRANCH;
168
+ const { databaseURL } = getEnvironment();
169
+ return databaseURL;
107
170
  } catch (err) {
108
171
  return void 0;
109
172
  }
110
173
  }
111
- async function getGitBranch() {
112
- const cmd = ["git", "branch", "--show-current"];
113
- const fullCmd = cmd.join(" ");
114
- const nodeModule = ["child", "process"].join("_");
115
- const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
174
+ function getAPIKey() {
116
175
  try {
117
- if (typeof require === "function") {
118
- return require(nodeModule).execSync(fullCmd, execOptions).trim();
119
- }
120
- const { execSync } = await import(nodeModule);
121
- return execSync(fullCmd, execOptions).toString().trim();
176
+ const { apiKey } = getEnvironment();
177
+ return apiKey;
122
178
  } catch (err) {
179
+ return void 0;
123
180
  }
181
+ }
182
+ function getBranch() {
124
183
  try {
125
- if (isObject(Deno)) {
126
- const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
127
- return new TextDecoder().decode(await process2.output()).trim();
128
- }
184
+ const { branch } = getEnvironment();
185
+ return branch ?? "main";
129
186
  } catch (err) {
187
+ return void 0;
130
188
  }
131
189
  }
132
-
133
- function getAPIKey() {
190
+ function buildPreviewBranchName({ org, branch }) {
191
+ return `preview-${org}-${branch}`;
192
+ }
193
+ function getPreviewBranch() {
134
194
  try {
135
- const { apiKey } = getEnvironment();
136
- return apiKey;
195
+ const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = getEnvironment();
196
+ if (deployPreviewBranch)
197
+ return deployPreviewBranch;
198
+ switch (deployPreview) {
199
+ case "vercel": {
200
+ if (!vercelGitCommitRef || !vercelGitRepoOwner) {
201
+ console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
202
+ return void 0;
203
+ }
204
+ return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
205
+ }
206
+ }
207
+ return void 0;
137
208
  } catch (err) {
138
209
  return void 0;
139
210
  }
140
211
  }
141
212
 
213
+ var __accessCheck$8 = (obj, member, msg) => {
214
+ if (!member.has(obj))
215
+ throw TypeError("Cannot " + msg);
216
+ };
217
+ var __privateGet$8 = (obj, member, getter) => {
218
+ __accessCheck$8(obj, member, "read from private field");
219
+ return getter ? getter.call(obj) : member.get(obj);
220
+ };
221
+ var __privateAdd$8 = (obj, member, value) => {
222
+ if (member.has(obj))
223
+ throw TypeError("Cannot add the same private member more than once");
224
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
225
+ };
226
+ var __privateSet$8 = (obj, member, value, setter) => {
227
+ __accessCheck$8(obj, member, "write to private field");
228
+ setter ? setter.call(obj, value) : member.set(obj, value);
229
+ return value;
230
+ };
231
+ var __privateMethod$4 = (obj, member, method) => {
232
+ __accessCheck$8(obj, member, "access private method");
233
+ return method;
234
+ };
235
+ var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
142
236
  function getFetchImplementation(userFetch) {
143
237
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
144
238
  const fetchImpl = userFetch ?? globalFetch;
@@ -149,8 +243,254 @@ function getFetchImplementation(userFetch) {
149
243
  }
150
244
  return fetchImpl;
151
245
  }
246
+ class ApiRequestPool {
247
+ constructor(concurrency = 10) {
248
+ __privateAdd$8(this, _enqueue);
249
+ __privateAdd$8(this, _fetch, void 0);
250
+ __privateAdd$8(this, _queue, void 0);
251
+ __privateAdd$8(this, _concurrency, void 0);
252
+ __privateSet$8(this, _queue, []);
253
+ __privateSet$8(this, _concurrency, concurrency);
254
+ this.running = 0;
255
+ this.started = 0;
256
+ }
257
+ setFetch(fetch2) {
258
+ __privateSet$8(this, _fetch, fetch2);
259
+ }
260
+ getFetch() {
261
+ if (!__privateGet$8(this, _fetch)) {
262
+ throw new Error("Fetch not set");
263
+ }
264
+ return __privateGet$8(this, _fetch);
265
+ }
266
+ request(url, options) {
267
+ const start = /* @__PURE__ */ new Date();
268
+ const fetch2 = this.getFetch();
269
+ const runRequest = async (stalled = false) => {
270
+ const response = await fetch2(url, options);
271
+ if (response.status === 429) {
272
+ const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
273
+ await timeout(rateLimitReset * 1e3);
274
+ return await runRequest(true);
275
+ }
276
+ if (stalled) {
277
+ const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
278
+ console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
279
+ }
280
+ return response;
281
+ };
282
+ return __privateMethod$4(this, _enqueue, enqueue_fn).call(this, async () => {
283
+ return await runRequest();
284
+ });
285
+ }
286
+ }
287
+ _fetch = new WeakMap();
288
+ _queue = new WeakMap();
289
+ _concurrency = new WeakMap();
290
+ _enqueue = new WeakSet();
291
+ enqueue_fn = function(task) {
292
+ const promise = new Promise((resolve) => __privateGet$8(this, _queue).push(resolve)).finally(() => {
293
+ this.started--;
294
+ this.running++;
295
+ }).then(() => task()).finally(() => {
296
+ this.running--;
297
+ const next = __privateGet$8(this, _queue).shift();
298
+ if (next !== void 0) {
299
+ this.started++;
300
+ next();
301
+ }
302
+ });
303
+ if (this.running + this.started < __privateGet$8(this, _concurrency)) {
304
+ const next = __privateGet$8(this, _queue).shift();
305
+ if (next !== void 0) {
306
+ this.started++;
307
+ next();
308
+ }
309
+ }
310
+ return promise;
311
+ };
312
+
313
+ function generateUUID() {
314
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
315
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
316
+ return v.toString(16);
317
+ });
318
+ }
319
+
320
+ async function getBytes(stream, onChunk) {
321
+ const reader = stream.getReader();
322
+ let result;
323
+ while (!(result = await reader.read()).done) {
324
+ onChunk(result.value);
325
+ }
326
+ }
327
+ function getLines(onLine) {
328
+ let buffer;
329
+ let position;
330
+ let fieldLength;
331
+ let discardTrailingNewline = false;
332
+ return function onChunk(arr) {
333
+ if (buffer === void 0) {
334
+ buffer = arr;
335
+ position = 0;
336
+ fieldLength = -1;
337
+ } else {
338
+ buffer = concat(buffer, arr);
339
+ }
340
+ const bufLength = buffer.length;
341
+ let lineStart = 0;
342
+ while (position < bufLength) {
343
+ if (discardTrailingNewline) {
344
+ if (buffer[position] === 10 /* NewLine */) {
345
+ lineStart = ++position;
346
+ }
347
+ discardTrailingNewline = false;
348
+ }
349
+ let lineEnd = -1;
350
+ for (; position < bufLength && lineEnd === -1; ++position) {
351
+ switch (buffer[position]) {
352
+ case 58 /* Colon */:
353
+ if (fieldLength === -1) {
354
+ fieldLength = position - lineStart;
355
+ }
356
+ break;
357
+ case 13 /* CarriageReturn */:
358
+ discardTrailingNewline = true;
359
+ case 10 /* NewLine */:
360
+ lineEnd = position;
361
+ break;
362
+ }
363
+ }
364
+ if (lineEnd === -1) {
365
+ break;
366
+ }
367
+ onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
368
+ lineStart = position;
369
+ fieldLength = -1;
370
+ }
371
+ if (lineStart === bufLength) {
372
+ buffer = void 0;
373
+ } else if (lineStart !== 0) {
374
+ buffer = buffer.subarray(lineStart);
375
+ position -= lineStart;
376
+ }
377
+ };
378
+ }
379
+ function getMessages(onId, onRetry, onMessage) {
380
+ let message = newMessage();
381
+ const decoder = new TextDecoder();
382
+ return function onLine(line, fieldLength) {
383
+ if (line.length === 0) {
384
+ onMessage?.(message);
385
+ message = newMessage();
386
+ } else if (fieldLength > 0) {
387
+ const field = decoder.decode(line.subarray(0, fieldLength));
388
+ const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
389
+ const value = decoder.decode(line.subarray(valueOffset));
390
+ switch (field) {
391
+ case "data":
392
+ message.data = message.data ? message.data + "\n" + value : value;
393
+ break;
394
+ case "event":
395
+ message.event = value;
396
+ break;
397
+ case "id":
398
+ onId(message.id = value);
399
+ break;
400
+ case "retry":
401
+ const retry = parseInt(value, 10);
402
+ if (!isNaN(retry)) {
403
+ onRetry(message.retry = retry);
404
+ }
405
+ break;
406
+ }
407
+ }
408
+ };
409
+ }
410
+ function concat(a, b) {
411
+ const res = new Uint8Array(a.length + b.length);
412
+ res.set(a);
413
+ res.set(b, a.length);
414
+ return res;
415
+ }
416
+ function newMessage() {
417
+ return {
418
+ data: "",
419
+ event: "",
420
+ id: "",
421
+ retry: void 0
422
+ };
423
+ }
424
+ const EventStreamContentType = "text/event-stream";
425
+ const LastEventId = "last-event-id";
426
+ function fetchEventSource(input, {
427
+ signal: inputSignal,
428
+ headers: inputHeaders,
429
+ onopen: inputOnOpen,
430
+ onmessage,
431
+ onclose,
432
+ onerror,
433
+ fetch: inputFetch,
434
+ ...rest
435
+ }) {
436
+ return new Promise((resolve, reject) => {
437
+ const headers = { ...inputHeaders };
438
+ if (!headers.accept) {
439
+ headers.accept = EventStreamContentType;
440
+ }
441
+ let curRequestController;
442
+ function dispose() {
443
+ curRequestController.abort();
444
+ }
445
+ inputSignal?.addEventListener("abort", () => {
446
+ dispose();
447
+ resolve();
448
+ });
449
+ const fetchImpl = inputFetch ?? fetch;
450
+ const onopen = inputOnOpen ?? defaultOnOpen;
451
+ async function create() {
452
+ curRequestController = new AbortController();
453
+ try {
454
+ const response = await fetchImpl(input, {
455
+ ...rest,
456
+ headers,
457
+ signal: curRequestController.signal
458
+ });
459
+ await onopen(response);
460
+ await getBytes(
461
+ response.body,
462
+ getLines(
463
+ getMessages(
464
+ (id) => {
465
+ if (id) {
466
+ headers[LastEventId] = id;
467
+ } else {
468
+ delete headers[LastEventId];
469
+ }
470
+ },
471
+ (_retry) => {
472
+ },
473
+ onmessage
474
+ )
475
+ )
476
+ );
477
+ onclose?.();
478
+ dispose();
479
+ resolve();
480
+ } catch (err) {
481
+ }
482
+ }
483
+ create();
484
+ });
485
+ }
486
+ function defaultOnOpen(response) {
487
+ const contentType = response.headers?.get("content-type");
488
+ if (!contentType?.startsWith(EventStreamContentType)) {
489
+ throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
490
+ }
491
+ }
152
492
 
153
- const VERSION = "0.0.0-alpha.vfe9bed6";
493
+ const VERSION = "0.24.3";
154
494
 
155
495
  class ErrorWithCause extends Error {
156
496
  constructor(message, options) {
@@ -161,7 +501,7 @@ class FetcherError extends ErrorWithCause {
161
501
  constructor(status, data, requestId) {
162
502
  super(getMessage(data));
163
503
  this.status = status;
164
- this.errors = isBulkError(data) ? data.errors : void 0;
504
+ this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
165
505
  this.requestId = requestId;
166
506
  if (data instanceof Error) {
167
507
  this.stack = data.stack;
@@ -193,6 +533,7 @@ function getMessage(data) {
193
533
  }
194
534
  }
195
535
 
536
+ const pool = new ApiRequestPool();
196
537
  const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
197
538
  const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
198
539
  if (value === void 0 || value === null)
@@ -207,58 +548,79 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
207
548
  return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
208
549
  };
209
550
  function buildBaseUrl({
551
+ endpoint,
210
552
  path,
211
553
  workspacesApiUrl,
212
554
  apiUrl,
213
- pathParams
555
+ pathParams = {}
214
556
  }) {
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));
557
+ if (endpoint === "dataPlane") {
558
+ const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
559
+ const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
560
+ return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
561
+ }
562
+ return `${apiUrl}${path}`;
219
563
  }
220
564
  function hostHeader(url) {
221
565
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
222
566
  const { groups } = pattern.exec(url) ?? {};
223
567
  return groups?.host ? { Host: groups.host } : {};
224
568
  }
569
+ const defaultClientID = generateUUID();
225
570
  async function fetch$1({
226
571
  url: path,
227
572
  method,
228
573
  body,
229
- headers,
574
+ headers: customHeaders,
230
575
  pathParams,
231
576
  queryParams,
232
- fetchImpl,
577
+ fetch: fetch2,
233
578
  apiKey,
579
+ endpoint,
234
580
  apiUrl,
235
581
  workspacesApiUrl,
236
- trace
582
+ trace,
583
+ signal,
584
+ clientID,
585
+ sessionID,
586
+ clientName,
587
+ xataAgentExtra,
588
+ fetchOptions = {}
237
589
  }) {
238
- return trace(
590
+ pool.setFetch(fetch2);
591
+ return await trace(
239
592
  `${method.toUpperCase()} ${path}`,
240
593
  async ({ setAttributes }) => {
241
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
594
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
242
595
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
243
596
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
244
597
  setAttributes({
245
598
  [TraceAttributes.HTTP_URL]: url,
246
599
  [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
247
600
  });
248
- const response = await fetchImpl(url, {
601
+ const xataAgent = compact([
602
+ ["client", "TS_SDK"],
603
+ ["version", VERSION],
604
+ isDefined(clientName) ? ["service", clientName] : void 0,
605
+ ...Object.entries(xataAgentExtra ?? {})
606
+ ]).map(([key, value]) => `${key}=${value}`).join("; ");
607
+ const headers = {
608
+ "Accept-Encoding": "identity",
609
+ "Content-Type": "application/json",
610
+ "X-Xata-Client-ID": clientID ?? defaultClientID,
611
+ "X-Xata-Session-ID": sessionID ?? generateUUID(),
612
+ "X-Xata-Agent": xataAgent,
613
+ ...customHeaders,
614
+ ...hostHeader(fullUrl),
615
+ Authorization: `Bearer ${apiKey}`
616
+ };
617
+ const response = await pool.request(url, {
618
+ ...fetchOptions,
249
619
  method: method.toUpperCase(),
250
620
  body: body ? JSON.stringify(body) : void 0,
251
- headers: {
252
- "Content-Type": "application/json",
253
- "User-Agent": `Xata client-ts/${VERSION}`,
254
- ...headers,
255
- ...hostHeader(fullUrl),
256
- Authorization: `Bearer ${apiKey}`
257
- }
621
+ headers,
622
+ signal
258
623
  });
259
- if (response.status === 204) {
260
- return {};
261
- }
262
624
  const { host, protocol } = parseUrl(response.url);
263
625
  const requestId = response.headers?.get("x-request-id") ?? void 0;
264
626
  setAttributes({
@@ -268,6 +630,15 @@ async function fetch$1({
268
630
  [TraceAttributes.HTTP_HOST]: host,
269
631
  [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
270
632
  });
633
+ const message = response.headers?.get("x-xata-message");
634
+ if (message)
635
+ console.warn(message);
636
+ if (response.status === 204) {
637
+ return {};
638
+ }
639
+ if (response.status === 429) {
640
+ throw new FetcherError(response.status, "Rate limit exceeded", requestId);
641
+ }
271
642
  try {
272
643
  const jsonResponse = await response.json();
273
644
  if (response.ok) {
@@ -281,6 +652,59 @@ async function fetch$1({
281
652
  { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
282
653
  );
283
654
  }
655
+ function fetchSSERequest({
656
+ url: path,
657
+ method,
658
+ body,
659
+ headers: customHeaders,
660
+ pathParams,
661
+ queryParams,
662
+ fetch: fetch2,
663
+ apiKey,
664
+ endpoint,
665
+ apiUrl,
666
+ workspacesApiUrl,
667
+ onMessage,
668
+ onError,
669
+ onClose,
670
+ signal,
671
+ clientID,
672
+ sessionID,
673
+ clientName,
674
+ xataAgentExtra
675
+ }) {
676
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
677
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
678
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
679
+ void fetchEventSource(url, {
680
+ method,
681
+ body: JSON.stringify(body),
682
+ fetch: fetch2,
683
+ signal,
684
+ headers: {
685
+ "X-Xata-Client-ID": clientID ?? defaultClientID,
686
+ "X-Xata-Session-ID": sessionID ?? generateUUID(),
687
+ "X-Xata-Agent": compact([
688
+ ["client", "TS_SDK"],
689
+ ["version", VERSION],
690
+ isDefined(clientName) ? ["service", clientName] : void 0,
691
+ ...Object.entries(xataAgentExtra ?? {})
692
+ ]).map(([key, value]) => `${key}=${value}`).join("; "),
693
+ ...customHeaders,
694
+ Authorization: `Bearer ${apiKey}`,
695
+ "Content-Type": "application/json"
696
+ },
697
+ onmessage(ev) {
698
+ onMessage?.(JSON.parse(ev.data));
699
+ },
700
+ onerror(ev) {
701
+ onError?.(JSON.parse(ev.data));
702
+ },
703
+ onclose() {
704
+ onClose?.();
705
+ }
706
+ });
707
+ }
284
708
  function parseUrl(url) {
285
709
  try {
286
710
  const { host, protocol } = new URL(url);
@@ -290,290 +714,242 @@ function parseUrl(url) {
290
714
  }
291
715
  }
292
716
 
293
- const getUser = (variables) => fetch$1({ url: "/user", method: "get", ...variables });
294
- const updateUser = (variables) => fetch$1({ url: "/user", method: "put", ...variables });
295
- const deleteUser = (variables) => fetch$1({ url: "/user", method: "delete", ...variables });
296
- const getUserAPIKeys = (variables) => fetch$1({
297
- url: "/user/keys",
298
- method: "get",
299
- ...variables
300
- });
301
- const createUserAPIKey = (variables) => fetch$1({
302
- url: "/user/keys/{keyName}",
303
- method: "post",
304
- ...variables
305
- });
306
- const deleteUserAPIKey = (variables) => fetch$1({
307
- url: "/user/keys/{keyName}",
308
- method: "delete",
309
- ...variables
310
- });
311
- const createWorkspace = (variables) => fetch$1({
312
- url: "/workspaces",
313
- method: "post",
314
- ...variables
315
- });
316
- const getWorkspacesList = (variables) => fetch$1({
317
- url: "/workspaces",
318
- method: "get",
319
- ...variables
320
- });
321
- const getWorkspace = (variables) => fetch$1({
322
- url: "/workspaces/{workspaceId}",
717
+ const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
718
+
719
+ const getBranchList = (variables, signal) => dataPlaneFetch({
720
+ url: "/dbs/{dbName}",
323
721
  method: "get",
324
- ...variables
325
- });
326
- const updateWorkspace = (variables) => fetch$1({
327
- url: "/workspaces/{workspaceId}",
328
- method: "put",
329
- ...variables
330
- });
331
- const deleteWorkspace = (variables) => fetch$1({
332
- url: "/workspaces/{workspaceId}",
333
- method: "delete",
334
- ...variables
722
+ ...variables,
723
+ signal
335
724
  });
336
- const getWorkspaceMembersList = (variables) => fetch$1({
337
- url: "/workspaces/{workspaceId}/members",
725
+ const getBranchDetails = (variables, signal) => dataPlaneFetch({
726
+ url: "/db/{dbBranchName}",
338
727
  method: "get",
339
- ...variables
340
- });
341
- const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
342
- const removeWorkspaceMember = (variables) => fetch$1({
343
- url: "/workspaces/{workspaceId}/members/{userId}",
344
- method: "delete",
345
- ...variables
728
+ ...variables,
729
+ signal
346
730
  });
347
- const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
348
- const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
349
- const cancelWorkspaceMemberInvite = (variables) => fetch$1({
350
- url: "/workspaces/{workspaceId}/invites/{inviteId}",
731
+ const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
732
+ const deleteBranch = (variables, signal) => dataPlaneFetch({
733
+ url: "/db/{dbBranchName}",
351
734
  method: "delete",
352
- ...variables
735
+ ...variables,
736
+ signal
353
737
  });
354
- const resendWorkspaceMemberInvite = (variables) => fetch$1({
355
- url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
738
+ const copyBranch = (variables, signal) => dataPlaneFetch({
739
+ url: "/db/{dbBranchName}/copy",
356
740
  method: "post",
357
- ...variables
741
+ ...variables,
742
+ signal
358
743
  });
359
- const acceptWorkspaceMemberInvite = (variables) => fetch$1({
360
- url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
361
- method: "post",
362
- ...variables
363
- });
364
- const getDatabaseList = (variables) => fetch$1({
365
- url: "/dbs",
366
- method: "get",
367
- ...variables
368
- });
369
- const getBranchList = (variables) => fetch$1({
370
- url: "/dbs/{dbName}",
371
- method: "get",
372
- ...variables
373
- });
374
- const createDatabase = (variables) => fetch$1({
375
- url: "/dbs/{dbName}",
744
+ const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
745
+ url: "/db/{dbBranchName}/metadata",
376
746
  method: "put",
377
- ...variables
747
+ ...variables,
748
+ signal
378
749
  });
379
- const deleteDatabase = (variables) => fetch$1({
380
- url: "/dbs/{dbName}",
381
- method: "delete",
382
- ...variables
383
- });
384
- const getDatabaseMetadata = (variables) => fetch$1({
385
- url: "/dbs/{dbName}/metadata",
750
+ const getBranchMetadata = (variables, signal) => dataPlaneFetch({
751
+ url: "/db/{dbBranchName}/metadata",
386
752
  method: "get",
387
- ...variables
753
+ ...variables,
754
+ signal
388
755
  });
389
- const updateDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
390
- const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
391
- const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
392
- const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
393
- const resolveBranch = (variables) => fetch$1({
394
- url: "/dbs/{dbName}/resolveBranch",
756
+ const getBranchStats = (variables, signal) => dataPlaneFetch({
757
+ url: "/db/{dbBranchName}/stats",
395
758
  method: "get",
396
- ...variables
759
+ ...variables,
760
+ signal
397
761
  });
398
- const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
399
- const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
400
- const getMigrationRequest = (variables) => fetch$1({
762
+ const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
763
+ const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
764
+ const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
765
+ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
766
+ const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
767
+ const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
768
+ const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
769
+ const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
770
+ const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
771
+ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
401
772
  url: "/dbs/{dbName}/migrations/{mrNumber}",
402
773
  method: "get",
403
- ...variables
774
+ ...variables,
775
+ signal
404
776
  });
405
- const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
406
- const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
407
- const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
408
- const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
409
- const mergeMigrationRequest = (variables) => fetch$1({
777
+ const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
778
+ const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
779
+ const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
780
+ const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
781
+ const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
410
782
  url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
411
783
  method: "post",
412
- ...variables
784
+ ...variables,
785
+ signal
413
786
  });
414
- const getBranchDetails = (variables) => fetch$1({
415
- url: "/db/{dbBranchName}",
416
- method: "get",
417
- ...variables
418
- });
419
- const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
420
- const deleteBranch = (variables) => fetch$1({
421
- url: "/db/{dbBranchName}",
422
- method: "delete",
423
- ...variables
424
- });
425
- const updateBranchMetadata = (variables) => fetch$1({
426
- url: "/db/{dbBranchName}/metadata",
427
- method: "put",
428
- ...variables
429
- });
430
- const getBranchMetadata = (variables) => fetch$1({
431
- url: "/db/{dbBranchName}/metadata",
432
- method: "get",
433
- ...variables
434
- });
435
- const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
436
- const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
437
- const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
438
- const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
439
- const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
440
- const updateBranchSchema = (variables) => fetch$1({
441
- url: "/db/{dbBranchName}/schema/update",
442
- method: "post",
443
- ...variables
444
- });
445
- const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
446
- const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
447
- const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
448
- const getBranchStats = (variables) => fetch$1({
449
- url: "/db/{dbBranchName}/stats",
450
- method: "get",
451
- ...variables
452
- });
453
- const createTable = (variables) => fetch$1({
787
+ const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
788
+ const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
789
+ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
790
+ const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
791
+ const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
792
+ const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
793
+ const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
794
+ const createTable = (variables, signal) => dataPlaneFetch({
454
795
  url: "/db/{dbBranchName}/tables/{tableName}",
455
796
  method: "put",
456
- ...variables
797
+ ...variables,
798
+ signal
457
799
  });
458
- const deleteTable = (variables) => fetch$1({
800
+ const deleteTable = (variables, signal) => dataPlaneFetch({
459
801
  url: "/db/{dbBranchName}/tables/{tableName}",
460
802
  method: "delete",
461
- ...variables
803
+ ...variables,
804
+ signal
462
805
  });
463
- const updateTable = (variables) => fetch$1({
464
- url: "/db/{dbBranchName}/tables/{tableName}",
465
- method: "patch",
466
- ...variables
467
- });
468
- const getTableSchema = (variables) => fetch$1({
806
+ const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
807
+ const getTableSchema = (variables, signal) => dataPlaneFetch({
469
808
  url: "/db/{dbBranchName}/tables/{tableName}/schema",
470
809
  method: "get",
471
- ...variables
472
- });
473
- const setTableSchema = (variables) => fetch$1({
474
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
475
- method: "put",
476
- ...variables
810
+ ...variables,
811
+ signal
477
812
  });
478
- const getTableColumns = (variables) => fetch$1({
813
+ const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
814
+ const getTableColumns = (variables, signal) => dataPlaneFetch({
479
815
  url: "/db/{dbBranchName}/tables/{tableName}/columns",
480
816
  method: "get",
481
- ...variables
817
+ ...variables,
818
+ signal
482
819
  });
483
- const addTableColumn = (variables) => fetch$1({
484
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
485
- method: "post",
486
- ...variables
487
- });
488
- const getColumn = (variables) => fetch$1({
820
+ const addTableColumn = (variables, signal) => dataPlaneFetch(
821
+ { url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
822
+ );
823
+ const getColumn = (variables, signal) => dataPlaneFetch({
489
824
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
490
825
  method: "get",
491
- ...variables
826
+ ...variables,
827
+ signal
492
828
  });
493
- const deleteColumn = (variables) => fetch$1({
829
+ const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
830
+ const deleteColumn = (variables, signal) => dataPlaneFetch({
494
831
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
495
832
  method: "delete",
496
- ...variables
833
+ ...variables,
834
+ signal
497
835
  });
498
- const updateColumn = (variables) => fetch$1({
499
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
500
- method: "patch",
501
- ...variables
836
+ const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
837
+ const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
838
+ const getFileItem = (variables, signal) => dataPlaneFetch({
839
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
840
+ method: "get",
841
+ ...variables,
842
+ signal
502
843
  });
503
- const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
504
- const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
505
- const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
506
- const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
507
- const deleteRecord = (variables) => fetch$1({
508
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
844
+ const putFileItem = (variables, signal) => dataPlaneFetch({
845
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
846
+ method: "put",
847
+ ...variables,
848
+ signal
849
+ });
850
+ const deleteFileItem = (variables, signal) => dataPlaneFetch({
851
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
509
852
  method: "delete",
510
- ...variables
853
+ ...variables,
854
+ signal
511
855
  });
512
- const getRecord = (variables) => fetch$1({
856
+ const getFile = (variables, signal) => dataPlaneFetch({
857
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
858
+ method: "get",
859
+ ...variables,
860
+ signal
861
+ });
862
+ const putFile = (variables, signal) => dataPlaneFetch({
863
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
864
+ method: "put",
865
+ ...variables,
866
+ signal
867
+ });
868
+ const deleteFile = (variables, signal) => dataPlaneFetch({
869
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
870
+ method: "delete",
871
+ ...variables,
872
+ signal
873
+ });
874
+ const getRecord = (variables, signal) => dataPlaneFetch({
513
875
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
514
876
  method: "get",
515
- ...variables
877
+ ...variables,
878
+ signal
516
879
  });
517
- const bulkInsertTableRecords = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables });
518
- const queryTable = (variables) => fetch$1({
880
+ const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
881
+ const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
882
+ const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
883
+ const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
884
+ const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
885
+ const queryTable = (variables, signal) => dataPlaneFetch({
519
886
  url: "/db/{dbBranchName}/tables/{tableName}/query",
520
887
  method: "post",
521
- ...variables
888
+ ...variables,
889
+ signal
890
+ });
891
+ const searchBranch = (variables, signal) => dataPlaneFetch({
892
+ url: "/db/{dbBranchName}/search",
893
+ method: "post",
894
+ ...variables,
895
+ signal
522
896
  });
523
- const searchTable = (variables) => fetch$1({
897
+ const searchTable = (variables, signal) => dataPlaneFetch({
524
898
  url: "/db/{dbBranchName}/tables/{tableName}/search",
525
899
  method: "post",
526
- ...variables
900
+ ...variables,
901
+ signal
527
902
  });
528
- const searchBranch = (variables) => fetch$1({
529
- url: "/db/{dbBranchName}/search",
903
+ const sqlQuery = (variables, signal) => dataPlaneFetch({
904
+ url: "/db/{dbBranchName}/sql",
530
905
  method: "post",
531
- ...variables
906
+ ...variables,
907
+ signal
532
908
  });
533
- const summarizeTable = (variables) => fetch$1({
534
- url: "/db/{dbBranchName}/tables/{tableName}/summarize",
909
+ const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
910
+ const askTable = (variables, signal) => dataPlaneFetch({
911
+ url: "/db/{dbBranchName}/tables/{tableName}/ask",
535
912
  method: "post",
536
- ...variables
913
+ ...variables,
914
+ signal
537
915
  });
538
- const operationsByTag = {
539
- users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
540
- workspaces: {
541
- createWorkspace,
542
- getWorkspacesList,
543
- getWorkspace,
544
- updateWorkspace,
545
- deleteWorkspace,
546
- getWorkspaceMembersList,
547
- updateWorkspaceMemberRole,
548
- removeWorkspaceMember,
549
- inviteWorkspaceMember,
550
- updateWorkspaceMemberInvite,
551
- cancelWorkspaceMemberInvite,
552
- resendWorkspaceMemberInvite,
553
- acceptWorkspaceMemberInvite
554
- },
555
- database: {
556
- getDatabaseList,
557
- createDatabase,
558
- deleteDatabase,
559
- getDatabaseMetadata,
560
- updateDatabaseMetadata,
561
- getGitBranchesMapping,
562
- addGitBranchesEntry,
563
- removeGitBranchesEntry,
564
- resolveBranch
565
- },
916
+ const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
917
+ const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
918
+ const fileAccess = (variables, signal) => dataPlaneFetch({
919
+ url: "/file/{fileId}",
920
+ method: "get",
921
+ ...variables,
922
+ signal
923
+ });
924
+ const operationsByTag$2 = {
566
925
  branch: {
567
926
  getBranchList,
568
927
  getBranchDetails,
569
928
  createBranch,
570
929
  deleteBranch,
930
+ copyBranch,
571
931
  updateBranchMetadata,
572
932
  getBranchMetadata,
573
- getBranchStats
933
+ getBranchStats,
934
+ getGitBranchesMapping,
935
+ addGitBranchesEntry,
936
+ removeGitBranchesEntry,
937
+ resolveBranch
938
+ },
939
+ migrations: {
940
+ getBranchMigrationHistory,
941
+ getBranchMigrationPlan,
942
+ executeBranchMigrationPlan,
943
+ getBranchSchemaHistory,
944
+ compareBranchWithUserSchema,
945
+ compareBranchSchemas,
946
+ updateBranchSchema,
947
+ previewBranchSchemaEdit,
948
+ applyBranchSchemaEdit,
949
+ pushBranchMigrations
574
950
  },
575
951
  migrationRequests: {
576
- listMigrationRequests,
952
+ queryMigrationRequests,
577
953
  createMigrationRequest,
578
954
  getMigrationRequest,
579
955
  updateMigrationRequest,
@@ -582,17 +958,6 @@ const operationsByTag = {
582
958
  getMigrationRequestIsMerged,
583
959
  mergeMigrationRequest
584
960
  },
585
- branchSchema: {
586
- getBranchMigrationHistory,
587
- executeBranchMigrationPlan,
588
- getBranchMigrationPlan,
589
- compareBranchWithUserSchema,
590
- compareBranchSchemas,
591
- updateBranchSchema,
592
- previewBranchSchemaEdit,
593
- applyBranchSchemaEdit,
594
- getBranchSchemaHistory
595
- },
596
961
  table: {
597
962
  createTable,
598
963
  deleteTable,
@@ -602,24 +967,174 @@ const operationsByTag = {
602
967
  getTableColumns,
603
968
  addTableColumn,
604
969
  getColumn,
605
- deleteColumn,
606
- updateColumn
970
+ updateColumn,
971
+ deleteColumn
607
972
  },
608
973
  records: {
974
+ branchTransaction,
609
975
  insertRecord,
976
+ getRecord,
610
977
  insertRecordWithID,
611
978
  updateRecordWithID,
612
979
  upsertRecordWithID,
613
980
  deleteRecord,
614
- getRecord,
615
- bulkInsertTableRecords,
981
+ bulkInsertTableRecords
982
+ },
983
+ files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
984
+ searchAndFilter: {
616
985
  queryTable,
617
- searchTable,
618
986
  searchBranch,
619
- summarizeTable
987
+ searchTable,
988
+ sqlQuery,
989
+ vectorSearchTable,
990
+ askTable,
991
+ summarizeTable,
992
+ aggregateTable
620
993
  }
621
994
  };
622
995
 
996
+ const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
997
+
998
+ const getUser = (variables, signal) => controlPlaneFetch({
999
+ url: "/user",
1000
+ method: "get",
1001
+ ...variables,
1002
+ signal
1003
+ });
1004
+ const updateUser = (variables, signal) => controlPlaneFetch({
1005
+ url: "/user",
1006
+ method: "put",
1007
+ ...variables,
1008
+ signal
1009
+ });
1010
+ const deleteUser = (variables, signal) => controlPlaneFetch({
1011
+ url: "/user",
1012
+ method: "delete",
1013
+ ...variables,
1014
+ signal
1015
+ });
1016
+ const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
1017
+ url: "/user/keys",
1018
+ method: "get",
1019
+ ...variables,
1020
+ signal
1021
+ });
1022
+ const createUserAPIKey = (variables, signal) => controlPlaneFetch({
1023
+ url: "/user/keys/{keyName}",
1024
+ method: "post",
1025
+ ...variables,
1026
+ signal
1027
+ });
1028
+ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
1029
+ url: "/user/keys/{keyName}",
1030
+ method: "delete",
1031
+ ...variables,
1032
+ signal
1033
+ });
1034
+ const getWorkspacesList = (variables, signal) => controlPlaneFetch({
1035
+ url: "/workspaces",
1036
+ method: "get",
1037
+ ...variables,
1038
+ signal
1039
+ });
1040
+ const createWorkspace = (variables, signal) => controlPlaneFetch({
1041
+ url: "/workspaces",
1042
+ method: "post",
1043
+ ...variables,
1044
+ signal
1045
+ });
1046
+ const getWorkspace = (variables, signal) => controlPlaneFetch({
1047
+ url: "/workspaces/{workspaceId}",
1048
+ method: "get",
1049
+ ...variables,
1050
+ signal
1051
+ });
1052
+ const updateWorkspace = (variables, signal) => controlPlaneFetch({
1053
+ url: "/workspaces/{workspaceId}",
1054
+ method: "put",
1055
+ ...variables,
1056
+ signal
1057
+ });
1058
+ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
1059
+ url: "/workspaces/{workspaceId}",
1060
+ method: "delete",
1061
+ ...variables,
1062
+ signal
1063
+ });
1064
+ const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
1065
+ const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
1066
+ const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
1067
+ url: "/workspaces/{workspaceId}/members/{userId}",
1068
+ method: "delete",
1069
+ ...variables,
1070
+ signal
1071
+ });
1072
+ const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
1073
+ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
1074
+ const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
1075
+ const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
1076
+ const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
1077
+ const getDatabaseList = (variables, signal) => controlPlaneFetch({
1078
+ url: "/workspaces/{workspaceId}/dbs",
1079
+ method: "get",
1080
+ ...variables,
1081
+ signal
1082
+ });
1083
+ const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
1084
+ const deleteDatabase = (variables, signal) => controlPlaneFetch({
1085
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
1086
+ method: "delete",
1087
+ ...variables,
1088
+ signal
1089
+ });
1090
+ const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
1091
+ const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
1092
+ const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
1093
+ const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
1094
+ const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
1095
+ const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
1096
+ const listRegions = (variables, signal) => controlPlaneFetch({
1097
+ url: "/workspaces/{workspaceId}/regions",
1098
+ method: "get",
1099
+ ...variables,
1100
+ signal
1101
+ });
1102
+ const operationsByTag$1 = {
1103
+ users: { getUser, updateUser, deleteUser },
1104
+ authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
1105
+ workspaces: {
1106
+ getWorkspacesList,
1107
+ createWorkspace,
1108
+ getWorkspace,
1109
+ updateWorkspace,
1110
+ deleteWorkspace,
1111
+ getWorkspaceMembersList,
1112
+ updateWorkspaceMemberRole,
1113
+ removeWorkspaceMember
1114
+ },
1115
+ invites: {
1116
+ inviteWorkspaceMember,
1117
+ updateWorkspaceMemberInvite,
1118
+ cancelWorkspaceMemberInvite,
1119
+ acceptWorkspaceMemberInvite,
1120
+ resendWorkspaceMemberInvite
1121
+ },
1122
+ databases: {
1123
+ getDatabaseList,
1124
+ createDatabase,
1125
+ deleteDatabase,
1126
+ getDatabaseMetadata,
1127
+ updateDatabaseMetadata,
1128
+ renameDatabase,
1129
+ getDatabaseGithubSettings,
1130
+ updateDatabaseGithubSettings,
1131
+ deleteDatabaseGithubSettings,
1132
+ listRegions
1133
+ }
1134
+ };
1135
+
1136
+ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
1137
+
623
1138
  function getHostUrl(provider, type) {
624
1139
  if (isHostProviderAlias(provider)) {
625
1140
  return providers[provider][type];
@@ -631,11 +1146,15 @@ function getHostUrl(provider, type) {
631
1146
  const providers = {
632
1147
  production: {
633
1148
  main: "https://api.xata.io",
634
- workspaces: "https://{workspaceId}.xata.sh"
1149
+ workspaces: "https://{workspaceId}.{region}.xata.sh"
635
1150
  },
636
1151
  staging: {
637
- main: "https://staging.xatabase.co",
638
- workspaces: "https://{workspaceId}.staging.xatabase.co"
1152
+ main: "https://api.staging-xata.dev",
1153
+ workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
1154
+ },
1155
+ dev: {
1156
+ main: "https://api.dev-xata.dev",
1157
+ workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
639
1158
  }
640
1159
  };
641
1160
  function isHostProviderAlias(alias) {
@@ -644,6 +1163,32 @@ function isHostProviderAlias(alias) {
644
1163
  function isHostProviderBuilder(builder) {
645
1164
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
646
1165
  }
1166
+ function parseProviderString(provider = "production") {
1167
+ if (isHostProviderAlias(provider)) {
1168
+ return provider;
1169
+ }
1170
+ const [main, workspaces] = provider.split(",");
1171
+ if (!main || !workspaces)
1172
+ return null;
1173
+ return { main, workspaces };
1174
+ }
1175
+ function buildProviderString(provider) {
1176
+ if (isHostProviderAlias(provider))
1177
+ return provider;
1178
+ return `${provider.main},${provider.workspaces}`;
1179
+ }
1180
+ function parseWorkspacesUrlParts(url) {
1181
+ if (!isString(url))
1182
+ return null;
1183
+ const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
1184
+ const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
1185
+ const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
1186
+ const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
1187
+ const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
1188
+ if (!match)
1189
+ return null;
1190
+ return { workspace: match[1], region: match[2] };
1191
+ }
647
1192
 
648
1193
  var __accessCheck$7 = (obj, member, msg) => {
649
1194
  if (!member.has(obj))
@@ -671,15 +1216,19 @@ class XataApiClient {
671
1216
  const provider = options.host ?? "production";
672
1217
  const apiKey = options.apiKey ?? getAPIKey();
673
1218
  const trace = options.trace ?? defaultTrace;
1219
+ const clientID = generateUUID();
674
1220
  if (!apiKey) {
675
1221
  throw new Error("Could not resolve a valid apiKey");
676
1222
  }
677
1223
  __privateSet$7(this, _extraProps, {
678
1224
  apiUrl: getHostUrl(provider, "main"),
679
1225
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
680
- fetchImpl: getFetchImplementation(options.fetch),
1226
+ fetch: getFetchImplementation(options.fetch),
681
1227
  apiKey,
682
- trace
1228
+ trace,
1229
+ clientName: options.clientName,
1230
+ xataAgentExtra: options.xataAgentExtra,
1231
+ clientID
683
1232
  });
684
1233
  }
685
1234
  get user() {
@@ -687,21 +1236,41 @@ class XataApiClient {
687
1236
  __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
688
1237
  return __privateGet$7(this, _namespaces).user;
689
1238
  }
1239
+ get authentication() {
1240
+ if (!__privateGet$7(this, _namespaces).authentication)
1241
+ __privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
1242
+ return __privateGet$7(this, _namespaces).authentication;
1243
+ }
690
1244
  get workspaces() {
691
1245
  if (!__privateGet$7(this, _namespaces).workspaces)
692
1246
  __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
693
1247
  return __privateGet$7(this, _namespaces).workspaces;
694
1248
  }
695
- get databases() {
696
- if (!__privateGet$7(this, _namespaces).databases)
697
- __privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
698
- return __privateGet$7(this, _namespaces).databases;
1249
+ get invites() {
1250
+ if (!__privateGet$7(this, _namespaces).invites)
1251
+ __privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
1252
+ return __privateGet$7(this, _namespaces).invites;
1253
+ }
1254
+ get database() {
1255
+ if (!__privateGet$7(this, _namespaces).database)
1256
+ __privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
1257
+ return __privateGet$7(this, _namespaces).database;
699
1258
  }
700
1259
  get branches() {
701
1260
  if (!__privateGet$7(this, _namespaces).branches)
702
1261
  __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
703
1262
  return __privateGet$7(this, _namespaces).branches;
704
1263
  }
1264
+ get migrations() {
1265
+ if (!__privateGet$7(this, _namespaces).migrations)
1266
+ __privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
1267
+ return __privateGet$7(this, _namespaces).migrations;
1268
+ }
1269
+ get migrationRequests() {
1270
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
1271
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
1272
+ return __privateGet$7(this, _namespaces).migrationRequests;
1273
+ }
705
1274
  get tables() {
706
1275
  if (!__privateGet$7(this, _namespaces).tables)
707
1276
  __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
@@ -712,15 +1281,15 @@ class XataApiClient {
712
1281
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
713
1282
  return __privateGet$7(this, _namespaces).records;
714
1283
  }
715
- get migrationRequests() {
716
- if (!__privateGet$7(this, _namespaces).migrationRequests)
717
- __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
718
- return __privateGet$7(this, _namespaces).migrationRequests;
1284
+ get files() {
1285
+ if (!__privateGet$7(this, _namespaces).files)
1286
+ __privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
1287
+ return __privateGet$7(this, _namespaces).files;
719
1288
  }
720
- get branchSchema() {
721
- if (!__privateGet$7(this, _namespaces).branchSchema)
722
- __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
723
- return __privateGet$7(this, _namespaces).branchSchema;
1289
+ get searchAndFilter() {
1290
+ if (!__privateGet$7(this, _namespaces).searchAndFilter)
1291
+ __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
1292
+ return __privateGet$7(this, _namespaces).searchAndFilter;
724
1293
  }
725
1294
  }
726
1295
  _extraProps = new WeakMap();
@@ -732,24 +1301,29 @@ class UserApi {
732
1301
  getUser() {
733
1302
  return operationsByTag.users.getUser({ ...this.extraProps });
734
1303
  }
735
- updateUser(user) {
1304
+ updateUser({ user }) {
736
1305
  return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
737
1306
  }
738
1307
  deleteUser() {
739
1308
  return operationsByTag.users.deleteUser({ ...this.extraProps });
740
1309
  }
1310
+ }
1311
+ class AuthenticationApi {
1312
+ constructor(extraProps) {
1313
+ this.extraProps = extraProps;
1314
+ }
741
1315
  getUserAPIKeys() {
742
- return operationsByTag.users.getUserAPIKeys({ ...this.extraProps });
1316
+ return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
743
1317
  }
744
- createUserAPIKey(keyName) {
745
- return operationsByTag.users.createUserAPIKey({
746
- pathParams: { keyName },
1318
+ createUserAPIKey({ name }) {
1319
+ return operationsByTag.authentication.createUserAPIKey({
1320
+ pathParams: { keyName: name },
747
1321
  ...this.extraProps
748
1322
  });
749
1323
  }
750
- deleteUserAPIKey(keyName) {
751
- return operationsByTag.users.deleteUserAPIKey({
752
- pathParams: { keyName },
1324
+ deleteUserAPIKey({ name }) {
1325
+ return operationsByTag.authentication.deleteUserAPIKey({
1326
+ pathParams: { keyName: name },
753
1327
  ...this.extraProps
754
1328
  });
755
1329
  }
@@ -758,492 +1332,1178 @@ class WorkspaceApi {
758
1332
  constructor(extraProps) {
759
1333
  this.extraProps = extraProps;
760
1334
  }
761
- createWorkspace(workspaceMeta) {
1335
+ getWorkspacesList() {
1336
+ return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
1337
+ }
1338
+ createWorkspace({ data }) {
762
1339
  return operationsByTag.workspaces.createWorkspace({
763
- body: workspaceMeta,
1340
+ body: data,
764
1341
  ...this.extraProps
765
1342
  });
766
1343
  }
767
- getWorkspacesList() {
768
- return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
769
- }
770
- getWorkspace(workspaceId) {
1344
+ getWorkspace({ workspace }) {
771
1345
  return operationsByTag.workspaces.getWorkspace({
772
- pathParams: { workspaceId },
1346
+ pathParams: { workspaceId: workspace },
773
1347
  ...this.extraProps
774
1348
  });
775
1349
  }
776
- updateWorkspace(workspaceId, workspaceMeta) {
1350
+ updateWorkspace({
1351
+ workspace,
1352
+ update
1353
+ }) {
777
1354
  return operationsByTag.workspaces.updateWorkspace({
778
- pathParams: { workspaceId },
779
- body: workspaceMeta,
1355
+ pathParams: { workspaceId: workspace },
1356
+ body: update,
780
1357
  ...this.extraProps
781
1358
  });
782
1359
  }
783
- deleteWorkspace(workspaceId) {
1360
+ deleteWorkspace({ workspace }) {
784
1361
  return operationsByTag.workspaces.deleteWorkspace({
785
- pathParams: { workspaceId },
1362
+ pathParams: { workspaceId: workspace },
786
1363
  ...this.extraProps
787
1364
  });
788
1365
  }
789
- getWorkspaceMembersList(workspaceId) {
1366
+ getWorkspaceMembersList({ workspace }) {
790
1367
  return operationsByTag.workspaces.getWorkspaceMembersList({
791
- pathParams: { workspaceId },
1368
+ pathParams: { workspaceId: workspace },
792
1369
  ...this.extraProps
793
1370
  });
794
1371
  }
795
- updateWorkspaceMemberRole(workspaceId, userId, role) {
1372
+ updateWorkspaceMemberRole({
1373
+ workspace,
1374
+ user,
1375
+ role
1376
+ }) {
796
1377
  return operationsByTag.workspaces.updateWorkspaceMemberRole({
797
- pathParams: { workspaceId, userId },
1378
+ pathParams: { workspaceId: workspace, userId: user },
798
1379
  body: { role },
799
1380
  ...this.extraProps
800
1381
  });
801
1382
  }
802
- removeWorkspaceMember(workspaceId, userId) {
1383
+ removeWorkspaceMember({
1384
+ workspace,
1385
+ user
1386
+ }) {
803
1387
  return operationsByTag.workspaces.removeWorkspaceMember({
804
- pathParams: { workspaceId, userId },
1388
+ pathParams: { workspaceId: workspace, userId: user },
805
1389
  ...this.extraProps
806
1390
  });
807
1391
  }
808
- inviteWorkspaceMember(workspaceId, email, role) {
809
- return operationsByTag.workspaces.inviteWorkspaceMember({
810
- pathParams: { workspaceId },
1392
+ }
1393
+ class InvitesApi {
1394
+ constructor(extraProps) {
1395
+ this.extraProps = extraProps;
1396
+ }
1397
+ inviteWorkspaceMember({
1398
+ workspace,
1399
+ email,
1400
+ role
1401
+ }) {
1402
+ return operationsByTag.invites.inviteWorkspaceMember({
1403
+ pathParams: { workspaceId: workspace },
811
1404
  body: { email, role },
812
1405
  ...this.extraProps
813
1406
  });
814
1407
  }
815
- updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
816
- return operationsByTag.workspaces.updateWorkspaceMemberInvite({
817
- pathParams: { workspaceId, inviteId },
1408
+ updateWorkspaceMemberInvite({
1409
+ workspace,
1410
+ invite,
1411
+ role
1412
+ }) {
1413
+ return operationsByTag.invites.updateWorkspaceMemberInvite({
1414
+ pathParams: { workspaceId: workspace, inviteId: invite },
818
1415
  body: { role },
819
1416
  ...this.extraProps
820
1417
  });
821
1418
  }
822
- cancelWorkspaceMemberInvite(workspaceId, inviteId) {
823
- return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
824
- pathParams: { workspaceId, inviteId },
1419
+ cancelWorkspaceMemberInvite({
1420
+ workspace,
1421
+ invite
1422
+ }) {
1423
+ return operationsByTag.invites.cancelWorkspaceMemberInvite({
1424
+ pathParams: { workspaceId: workspace, inviteId: invite },
825
1425
  ...this.extraProps
826
1426
  });
827
1427
  }
828
- resendWorkspaceMemberInvite(workspaceId, inviteId) {
829
- return operationsByTag.workspaces.resendWorkspaceMemberInvite({
830
- pathParams: { workspaceId, inviteId },
1428
+ acceptWorkspaceMemberInvite({
1429
+ workspace,
1430
+ key
1431
+ }) {
1432
+ return operationsByTag.invites.acceptWorkspaceMemberInvite({
1433
+ pathParams: { workspaceId: workspace, inviteKey: key },
831
1434
  ...this.extraProps
832
1435
  });
833
1436
  }
834
- acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
835
- return operationsByTag.workspaces.acceptWorkspaceMemberInvite({
836
- pathParams: { workspaceId, inviteKey },
1437
+ resendWorkspaceMemberInvite({
1438
+ workspace,
1439
+ invite
1440
+ }) {
1441
+ return operationsByTag.invites.resendWorkspaceMemberInvite({
1442
+ pathParams: { workspaceId: workspace, inviteId: invite },
837
1443
  ...this.extraProps
838
1444
  });
839
1445
  }
840
1446
  }
841
- class DatabaseApi {
1447
+ class BranchApi {
842
1448
  constructor(extraProps) {
843
1449
  this.extraProps = extraProps;
844
1450
  }
845
- getDatabaseList(workspace) {
846
- return operationsByTag.database.getDatabaseList({
847
- pathParams: { workspace },
1451
+ getBranchList({
1452
+ workspace,
1453
+ region,
1454
+ database
1455
+ }) {
1456
+ return operationsByTag.branch.getBranchList({
1457
+ pathParams: { workspace, region, dbName: database },
1458
+ ...this.extraProps
1459
+ });
1460
+ }
1461
+ getBranchDetails({
1462
+ workspace,
1463
+ region,
1464
+ database,
1465
+ branch
1466
+ }) {
1467
+ return operationsByTag.branch.getBranchDetails({
1468
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
848
1469
  ...this.extraProps
849
1470
  });
850
1471
  }
851
- createDatabase(workspace, dbName, options = {}) {
852
- return operationsByTag.database.createDatabase({
853
- pathParams: { workspace, dbName },
854
- body: options,
1472
+ createBranch({
1473
+ workspace,
1474
+ region,
1475
+ database,
1476
+ branch,
1477
+ from,
1478
+ metadata
1479
+ }) {
1480
+ return operationsByTag.branch.createBranch({
1481
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1482
+ body: { from, metadata },
855
1483
  ...this.extraProps
856
1484
  });
857
1485
  }
858
- deleteDatabase(workspace, dbName) {
859
- return operationsByTag.database.deleteDatabase({
860
- pathParams: { workspace, dbName },
1486
+ deleteBranch({
1487
+ workspace,
1488
+ region,
1489
+ database,
1490
+ branch
1491
+ }) {
1492
+ return operationsByTag.branch.deleteBranch({
1493
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
861
1494
  ...this.extraProps
862
1495
  });
863
1496
  }
864
- getDatabaseMetadata(workspace, dbName) {
865
- return operationsByTag.database.getDatabaseMetadata({
866
- pathParams: { workspace, dbName },
1497
+ copyBranch({
1498
+ workspace,
1499
+ region,
1500
+ database,
1501
+ branch,
1502
+ destinationBranch,
1503
+ limit
1504
+ }) {
1505
+ return operationsByTag.branch.copyBranch({
1506
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1507
+ body: { destinationBranch, limit },
867
1508
  ...this.extraProps
868
1509
  });
869
1510
  }
870
- updateDatabaseMetadata(workspace, dbName, options = {}) {
871
- return operationsByTag.database.updateDatabaseMetadata({
872
- pathParams: { workspace, dbName },
873
- body: options,
1511
+ updateBranchMetadata({
1512
+ workspace,
1513
+ region,
1514
+ database,
1515
+ branch,
1516
+ metadata
1517
+ }) {
1518
+ return operationsByTag.branch.updateBranchMetadata({
1519
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1520
+ body: metadata,
874
1521
  ...this.extraProps
875
1522
  });
876
1523
  }
877
- getGitBranchesMapping(workspace, dbName) {
878
- return operationsByTag.database.getGitBranchesMapping({
879
- pathParams: { workspace, dbName },
1524
+ getBranchMetadata({
1525
+ workspace,
1526
+ region,
1527
+ database,
1528
+ branch
1529
+ }) {
1530
+ return operationsByTag.branch.getBranchMetadata({
1531
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
880
1532
  ...this.extraProps
881
1533
  });
882
1534
  }
883
- addGitBranchesEntry(workspace, dbName, body) {
884
- return operationsByTag.database.addGitBranchesEntry({
885
- pathParams: { workspace, dbName },
886
- body,
1535
+ getBranchStats({
1536
+ workspace,
1537
+ region,
1538
+ database,
1539
+ branch
1540
+ }) {
1541
+ return operationsByTag.branch.getBranchStats({
1542
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
887
1543
  ...this.extraProps
888
1544
  });
889
1545
  }
890
- removeGitBranchesEntry(workspace, dbName, gitBranch) {
891
- return operationsByTag.database.removeGitBranchesEntry({
892
- pathParams: { workspace, dbName },
1546
+ getGitBranchesMapping({
1547
+ workspace,
1548
+ region,
1549
+ database
1550
+ }) {
1551
+ return operationsByTag.branch.getGitBranchesMapping({
1552
+ pathParams: { workspace, region, dbName: database },
1553
+ ...this.extraProps
1554
+ });
1555
+ }
1556
+ addGitBranchesEntry({
1557
+ workspace,
1558
+ region,
1559
+ database,
1560
+ gitBranch,
1561
+ xataBranch
1562
+ }) {
1563
+ return operationsByTag.branch.addGitBranchesEntry({
1564
+ pathParams: { workspace, region, dbName: database },
1565
+ body: { gitBranch, xataBranch },
1566
+ ...this.extraProps
1567
+ });
1568
+ }
1569
+ removeGitBranchesEntry({
1570
+ workspace,
1571
+ region,
1572
+ database,
1573
+ gitBranch
1574
+ }) {
1575
+ return operationsByTag.branch.removeGitBranchesEntry({
1576
+ pathParams: { workspace, region, dbName: database },
893
1577
  queryParams: { gitBranch },
894
1578
  ...this.extraProps
895
1579
  });
896
1580
  }
897
- resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
898
- return operationsByTag.database.resolveBranch({
899
- pathParams: { workspace, dbName },
1581
+ resolveBranch({
1582
+ workspace,
1583
+ region,
1584
+ database,
1585
+ gitBranch,
1586
+ fallbackBranch
1587
+ }) {
1588
+ return operationsByTag.branch.resolveBranch({
1589
+ pathParams: { workspace, region, dbName: database },
900
1590
  queryParams: { gitBranch, fallbackBranch },
901
1591
  ...this.extraProps
902
1592
  });
903
1593
  }
904
1594
  }
905
- class BranchApi {
1595
+ class TableApi {
906
1596
  constructor(extraProps) {
907
1597
  this.extraProps = extraProps;
908
1598
  }
909
- getBranchList(workspace, dbName) {
910
- return operationsByTag.branch.getBranchList({
911
- pathParams: { workspace, dbName },
1599
+ createTable({
1600
+ workspace,
1601
+ region,
1602
+ database,
1603
+ branch,
1604
+ table
1605
+ }) {
1606
+ return operationsByTag.table.createTable({
1607
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
912
1608
  ...this.extraProps
913
1609
  });
914
1610
  }
915
- getBranchDetails(workspace, database, branch) {
916
- return operationsByTag.branch.getBranchDetails({
917
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1611
+ deleteTable({
1612
+ workspace,
1613
+ region,
1614
+ database,
1615
+ branch,
1616
+ table
1617
+ }) {
1618
+ return operationsByTag.table.deleteTable({
1619
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
918
1620
  ...this.extraProps
919
1621
  });
920
1622
  }
921
- createBranch(workspace, database, branch, from, options = {}) {
922
- return operationsByTag.branch.createBranch({
923
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
924
- queryParams: isString(from) ? { from } : void 0,
925
- body: options,
1623
+ updateTable({
1624
+ workspace,
1625
+ region,
1626
+ database,
1627
+ branch,
1628
+ table,
1629
+ update
1630
+ }) {
1631
+ return operationsByTag.table.updateTable({
1632
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1633
+ body: update,
926
1634
  ...this.extraProps
927
1635
  });
928
1636
  }
929
- deleteBranch(workspace, database, branch) {
930
- return operationsByTag.branch.deleteBranch({
931
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1637
+ getTableSchema({
1638
+ workspace,
1639
+ region,
1640
+ database,
1641
+ branch,
1642
+ table
1643
+ }) {
1644
+ return operationsByTag.table.getTableSchema({
1645
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
932
1646
  ...this.extraProps
933
1647
  });
934
1648
  }
935
- updateBranchMetadata(workspace, database, branch, metadata = {}) {
936
- return operationsByTag.branch.updateBranchMetadata({
937
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
938
- body: metadata,
1649
+ setTableSchema({
1650
+ workspace,
1651
+ region,
1652
+ database,
1653
+ branch,
1654
+ table,
1655
+ schema
1656
+ }) {
1657
+ return operationsByTag.table.setTableSchema({
1658
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1659
+ body: schema,
939
1660
  ...this.extraProps
940
1661
  });
941
1662
  }
942
- getBranchMetadata(workspace, database, branch) {
943
- return operationsByTag.branch.getBranchMetadata({
944
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1663
+ getTableColumns({
1664
+ workspace,
1665
+ region,
1666
+ database,
1667
+ branch,
1668
+ table
1669
+ }) {
1670
+ return operationsByTag.table.getTableColumns({
1671
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
945
1672
  ...this.extraProps
946
1673
  });
947
1674
  }
948
- getBranchStats(workspace, database, branch) {
949
- return operationsByTag.branch.getBranchStats({
950
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1675
+ addTableColumn({
1676
+ workspace,
1677
+ region,
1678
+ database,
1679
+ branch,
1680
+ table,
1681
+ column
1682
+ }) {
1683
+ return operationsByTag.table.addTableColumn({
1684
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1685
+ body: column,
1686
+ ...this.extraProps
1687
+ });
1688
+ }
1689
+ getColumn({
1690
+ workspace,
1691
+ region,
1692
+ database,
1693
+ branch,
1694
+ table,
1695
+ column
1696
+ }) {
1697
+ return operationsByTag.table.getColumn({
1698
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1699
+ ...this.extraProps
1700
+ });
1701
+ }
1702
+ updateColumn({
1703
+ workspace,
1704
+ region,
1705
+ database,
1706
+ branch,
1707
+ table,
1708
+ column,
1709
+ update
1710
+ }) {
1711
+ return operationsByTag.table.updateColumn({
1712
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1713
+ body: update,
1714
+ ...this.extraProps
1715
+ });
1716
+ }
1717
+ deleteColumn({
1718
+ workspace,
1719
+ region,
1720
+ database,
1721
+ branch,
1722
+ table,
1723
+ column
1724
+ }) {
1725
+ return operationsByTag.table.deleteColumn({
1726
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
951
1727
  ...this.extraProps
952
1728
  });
953
1729
  }
954
1730
  }
955
- class TableApi {
1731
+ class RecordsApi {
956
1732
  constructor(extraProps) {
957
1733
  this.extraProps = extraProps;
958
1734
  }
959
- createTable(workspace, database, branch, tableName) {
960
- return operationsByTag.table.createTable({
961
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1735
+ insertRecord({
1736
+ workspace,
1737
+ region,
1738
+ database,
1739
+ branch,
1740
+ table,
1741
+ record,
1742
+ columns
1743
+ }) {
1744
+ return operationsByTag.records.insertRecord({
1745
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1746
+ queryParams: { columns },
1747
+ body: record,
962
1748
  ...this.extraProps
963
1749
  });
964
1750
  }
965
- deleteTable(workspace, database, branch, tableName) {
966
- return operationsByTag.table.deleteTable({
967
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1751
+ getRecord({
1752
+ workspace,
1753
+ region,
1754
+ database,
1755
+ branch,
1756
+ table,
1757
+ id,
1758
+ columns
1759
+ }) {
1760
+ return operationsByTag.records.getRecord({
1761
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1762
+ queryParams: { columns },
968
1763
  ...this.extraProps
969
1764
  });
970
1765
  }
971
- updateTable(workspace, database, branch, tableName, options) {
972
- return operationsByTag.table.updateTable({
973
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
974
- body: options,
1766
+ insertRecordWithID({
1767
+ workspace,
1768
+ region,
1769
+ database,
1770
+ branch,
1771
+ table,
1772
+ id,
1773
+ record,
1774
+ columns,
1775
+ createOnly,
1776
+ ifVersion
1777
+ }) {
1778
+ return operationsByTag.records.insertRecordWithID({
1779
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1780
+ queryParams: { columns, createOnly, ifVersion },
1781
+ body: record,
1782
+ ...this.extraProps
1783
+ });
1784
+ }
1785
+ updateRecordWithID({
1786
+ workspace,
1787
+ region,
1788
+ database,
1789
+ branch,
1790
+ table,
1791
+ id,
1792
+ record,
1793
+ columns,
1794
+ ifVersion
1795
+ }) {
1796
+ return operationsByTag.records.updateRecordWithID({
1797
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1798
+ queryParams: { columns, ifVersion },
1799
+ body: record,
1800
+ ...this.extraProps
1801
+ });
1802
+ }
1803
+ upsertRecordWithID({
1804
+ workspace,
1805
+ region,
1806
+ database,
1807
+ branch,
1808
+ table,
1809
+ id,
1810
+ record,
1811
+ columns,
1812
+ ifVersion
1813
+ }) {
1814
+ return operationsByTag.records.upsertRecordWithID({
1815
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1816
+ queryParams: { columns, ifVersion },
1817
+ body: record,
975
1818
  ...this.extraProps
976
1819
  });
977
1820
  }
978
- getTableSchema(workspace, database, branch, tableName) {
979
- return operationsByTag.table.getTableSchema({
980
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1821
+ deleteRecord({
1822
+ workspace,
1823
+ region,
1824
+ database,
1825
+ branch,
1826
+ table,
1827
+ id,
1828
+ columns
1829
+ }) {
1830
+ return operationsByTag.records.deleteRecord({
1831
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1832
+ queryParams: { columns },
1833
+ ...this.extraProps
1834
+ });
1835
+ }
1836
+ bulkInsertTableRecords({
1837
+ workspace,
1838
+ region,
1839
+ database,
1840
+ branch,
1841
+ table,
1842
+ records,
1843
+ columns
1844
+ }) {
1845
+ return operationsByTag.records.bulkInsertTableRecords({
1846
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1847
+ queryParams: { columns },
1848
+ body: { records },
1849
+ ...this.extraProps
1850
+ });
1851
+ }
1852
+ branchTransaction({
1853
+ workspace,
1854
+ region,
1855
+ database,
1856
+ branch,
1857
+ operations
1858
+ }) {
1859
+ return operationsByTag.records.branchTransaction({
1860
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1861
+ body: { operations },
1862
+ ...this.extraProps
1863
+ });
1864
+ }
1865
+ }
1866
+ class FilesApi {
1867
+ constructor(extraProps) {
1868
+ this.extraProps = extraProps;
1869
+ }
1870
+ getFileItem({
1871
+ workspace,
1872
+ region,
1873
+ database,
1874
+ branch,
1875
+ table,
1876
+ record,
1877
+ column,
1878
+ fileId
1879
+ }) {
1880
+ return operationsByTag.files.getFileItem({
1881
+ pathParams: {
1882
+ workspace,
1883
+ region,
1884
+ dbBranchName: `${database}:${branch}`,
1885
+ tableName: table,
1886
+ recordId: record,
1887
+ columnName: column,
1888
+ fileId
1889
+ },
1890
+ ...this.extraProps
1891
+ });
1892
+ }
1893
+ putFileItem({
1894
+ workspace,
1895
+ region,
1896
+ database,
1897
+ branch,
1898
+ table,
1899
+ record,
1900
+ column,
1901
+ fileId,
1902
+ file
1903
+ }) {
1904
+ return operationsByTag.files.putFileItem({
1905
+ pathParams: {
1906
+ workspace,
1907
+ region,
1908
+ dbBranchName: `${database}:${branch}`,
1909
+ tableName: table,
1910
+ recordId: record,
1911
+ columnName: column,
1912
+ fileId
1913
+ },
1914
+ // @ts-ignore
1915
+ body: file,
1916
+ ...this.extraProps
1917
+ });
1918
+ }
1919
+ deleteFileItem({
1920
+ workspace,
1921
+ region,
1922
+ database,
1923
+ branch,
1924
+ table,
1925
+ record,
1926
+ column,
1927
+ fileId
1928
+ }) {
1929
+ return operationsByTag.files.deleteFileItem({
1930
+ pathParams: {
1931
+ workspace,
1932
+ region,
1933
+ dbBranchName: `${database}:${branch}`,
1934
+ tableName: table,
1935
+ recordId: record,
1936
+ columnName: column,
1937
+ fileId
1938
+ },
1939
+ ...this.extraProps
1940
+ });
1941
+ }
1942
+ getFile({
1943
+ workspace,
1944
+ region,
1945
+ database,
1946
+ branch,
1947
+ table,
1948
+ record,
1949
+ column
1950
+ }) {
1951
+ return operationsByTag.files.getFile({
1952
+ pathParams: {
1953
+ workspace,
1954
+ region,
1955
+ dbBranchName: `${database}:${branch}`,
1956
+ tableName: table,
1957
+ recordId: record,
1958
+ columnName: column
1959
+ },
1960
+ ...this.extraProps
1961
+ });
1962
+ }
1963
+ putFile({
1964
+ workspace,
1965
+ region,
1966
+ database,
1967
+ branch,
1968
+ table,
1969
+ record,
1970
+ column,
1971
+ file
1972
+ }) {
1973
+ return operationsByTag.files.putFile({
1974
+ pathParams: {
1975
+ workspace,
1976
+ region,
1977
+ dbBranchName: `${database}:${branch}`,
1978
+ tableName: table,
1979
+ recordId: record,
1980
+ columnName: column
1981
+ },
1982
+ body: file,
1983
+ ...this.extraProps
1984
+ });
1985
+ }
1986
+ deleteFile({
1987
+ workspace,
1988
+ region,
1989
+ database,
1990
+ branch,
1991
+ table,
1992
+ record,
1993
+ column
1994
+ }) {
1995
+ return operationsByTag.files.deleteFile({
1996
+ pathParams: {
1997
+ workspace,
1998
+ region,
1999
+ dbBranchName: `${database}:${branch}`,
2000
+ tableName: table,
2001
+ recordId: record,
2002
+ columnName: column
2003
+ },
2004
+ ...this.extraProps
2005
+ });
2006
+ }
2007
+ fileAccess({
2008
+ workspace,
2009
+ region,
2010
+ fileId,
2011
+ verify
2012
+ }) {
2013
+ return operationsByTag.files.fileAccess({
2014
+ pathParams: {
2015
+ workspace,
2016
+ region,
2017
+ fileId
2018
+ },
2019
+ queryParams: { verify },
2020
+ ...this.extraProps
2021
+ });
2022
+ }
2023
+ }
2024
+ class SearchAndFilterApi {
2025
+ constructor(extraProps) {
2026
+ this.extraProps = extraProps;
2027
+ }
2028
+ queryTable({
2029
+ workspace,
2030
+ region,
2031
+ database,
2032
+ branch,
2033
+ table,
2034
+ filter,
2035
+ sort,
2036
+ page,
2037
+ columns,
2038
+ consistency
2039
+ }) {
2040
+ return operationsByTag.searchAndFilter.queryTable({
2041
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2042
+ body: { filter, sort, page, columns, consistency },
981
2043
  ...this.extraProps
982
2044
  });
983
2045
  }
984
- setTableSchema(workspace, database, branch, tableName, options) {
985
- return operationsByTag.table.setTableSchema({
986
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
987
- body: options,
2046
+ searchTable({
2047
+ workspace,
2048
+ region,
2049
+ database,
2050
+ branch,
2051
+ table,
2052
+ query,
2053
+ fuzziness,
2054
+ target,
2055
+ prefix,
2056
+ filter,
2057
+ highlight,
2058
+ boosters
2059
+ }) {
2060
+ return operationsByTag.searchAndFilter.searchTable({
2061
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2062
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
988
2063
  ...this.extraProps
989
2064
  });
990
2065
  }
991
- getTableColumns(workspace, database, branch, tableName) {
992
- return operationsByTag.table.getTableColumns({
993
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
2066
+ searchBranch({
2067
+ workspace,
2068
+ region,
2069
+ database,
2070
+ branch,
2071
+ tables,
2072
+ query,
2073
+ fuzziness,
2074
+ prefix,
2075
+ highlight
2076
+ }) {
2077
+ return operationsByTag.searchAndFilter.searchBranch({
2078
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2079
+ body: { tables, query, fuzziness, prefix, highlight },
994
2080
  ...this.extraProps
995
2081
  });
996
2082
  }
997
- addTableColumn(workspace, database, branch, tableName, column) {
998
- return operationsByTag.table.addTableColumn({
999
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1000
- body: column,
2083
+ vectorSearchTable({
2084
+ workspace,
2085
+ region,
2086
+ database,
2087
+ branch,
2088
+ table,
2089
+ queryVector,
2090
+ column,
2091
+ similarityFunction,
2092
+ size,
2093
+ filter
2094
+ }) {
2095
+ return operationsByTag.searchAndFilter.vectorSearchTable({
2096
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2097
+ body: { queryVector, column, similarityFunction, size, filter },
1001
2098
  ...this.extraProps
1002
2099
  });
1003
2100
  }
1004
- getColumn(workspace, database, branch, tableName, columnName) {
1005
- return operationsByTag.table.getColumn({
1006
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
2101
+ askTable({
2102
+ workspace,
2103
+ region,
2104
+ database,
2105
+ branch,
2106
+ table,
2107
+ options
2108
+ }) {
2109
+ return operationsByTag.searchAndFilter.askTable({
2110
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2111
+ body: { ...options },
1007
2112
  ...this.extraProps
1008
2113
  });
1009
2114
  }
1010
- deleteColumn(workspace, database, branch, tableName, columnName) {
1011
- return operationsByTag.table.deleteColumn({
1012
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
2115
+ summarizeTable({
2116
+ workspace,
2117
+ region,
2118
+ database,
2119
+ branch,
2120
+ table,
2121
+ filter,
2122
+ columns,
2123
+ summaries,
2124
+ sort,
2125
+ summariesFilter,
2126
+ page,
2127
+ consistency
2128
+ }) {
2129
+ return operationsByTag.searchAndFilter.summarizeTable({
2130
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2131
+ body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
1013
2132
  ...this.extraProps
1014
2133
  });
1015
2134
  }
1016
- updateColumn(workspace, database, branch, tableName, columnName, options) {
1017
- return operationsByTag.table.updateColumn({
1018
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1019
- body: options,
2135
+ aggregateTable({
2136
+ workspace,
2137
+ region,
2138
+ database,
2139
+ branch,
2140
+ table,
2141
+ filter,
2142
+ aggs
2143
+ }) {
2144
+ return operationsByTag.searchAndFilter.aggregateTable({
2145
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2146
+ body: { filter, aggs },
1020
2147
  ...this.extraProps
1021
2148
  });
1022
2149
  }
1023
2150
  }
1024
- class RecordsApi {
2151
+ class MigrationRequestsApi {
1025
2152
  constructor(extraProps) {
1026
2153
  this.extraProps = extraProps;
1027
2154
  }
1028
- insertRecord(workspace, database, branch, tableName, record, options = {}) {
1029
- return operationsByTag.records.insertRecord({
1030
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1031
- queryParams: options,
1032
- body: record,
2155
+ queryMigrationRequests({
2156
+ workspace,
2157
+ region,
2158
+ database,
2159
+ filter,
2160
+ sort,
2161
+ page,
2162
+ columns
2163
+ }) {
2164
+ return operationsByTag.migrationRequests.queryMigrationRequests({
2165
+ pathParams: { workspace, region, dbName: database },
2166
+ body: { filter, sort, page, columns },
1033
2167
  ...this.extraProps
1034
2168
  });
1035
2169
  }
1036
- insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1037
- return operationsByTag.records.insertRecordWithID({
1038
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1039
- queryParams: options,
1040
- body: record,
2170
+ createMigrationRequest({
2171
+ workspace,
2172
+ region,
2173
+ database,
2174
+ migration
2175
+ }) {
2176
+ return operationsByTag.migrationRequests.createMigrationRequest({
2177
+ pathParams: { workspace, region, dbName: database },
2178
+ body: migration,
1041
2179
  ...this.extraProps
1042
2180
  });
1043
2181
  }
1044
- updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1045
- return operationsByTag.records.updateRecordWithID({
1046
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1047
- queryParams: options,
1048
- body: record,
2182
+ getMigrationRequest({
2183
+ workspace,
2184
+ region,
2185
+ database,
2186
+ migrationRequest
2187
+ }) {
2188
+ return operationsByTag.migrationRequests.getMigrationRequest({
2189
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1049
2190
  ...this.extraProps
1050
2191
  });
1051
2192
  }
1052
- upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1053
- return operationsByTag.records.upsertRecordWithID({
1054
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1055
- queryParams: options,
1056
- body: record,
2193
+ updateMigrationRequest({
2194
+ workspace,
2195
+ region,
2196
+ database,
2197
+ migrationRequest,
2198
+ update
2199
+ }) {
2200
+ return operationsByTag.migrationRequests.updateMigrationRequest({
2201
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
2202
+ body: update,
1057
2203
  ...this.extraProps
1058
2204
  });
1059
2205
  }
1060
- deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
1061
- return operationsByTag.records.deleteRecord({
1062
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1063
- queryParams: options,
2206
+ listMigrationRequestsCommits({
2207
+ workspace,
2208
+ region,
2209
+ database,
2210
+ migrationRequest,
2211
+ page
2212
+ }) {
2213
+ return operationsByTag.migrationRequests.listMigrationRequestsCommits({
2214
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
2215
+ body: { page },
1064
2216
  ...this.extraProps
1065
2217
  });
1066
2218
  }
1067
- getRecord(workspace, database, branch, tableName, recordId, options = {}) {
1068
- return operationsByTag.records.getRecord({
1069
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1070
- queryParams: options,
2219
+ compareMigrationRequest({
2220
+ workspace,
2221
+ region,
2222
+ database,
2223
+ migrationRequest
2224
+ }) {
2225
+ return operationsByTag.migrationRequests.compareMigrationRequest({
2226
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1071
2227
  ...this.extraProps
1072
2228
  });
1073
2229
  }
1074
- bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
1075
- return operationsByTag.records.bulkInsertTableRecords({
1076
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1077
- queryParams: options,
1078
- body: { records },
2230
+ getMigrationRequestIsMerged({
2231
+ workspace,
2232
+ region,
2233
+ database,
2234
+ migrationRequest
2235
+ }) {
2236
+ return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
2237
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1079
2238
  ...this.extraProps
1080
2239
  });
1081
2240
  }
1082
- queryTable(workspace, database, branch, tableName, query) {
1083
- return operationsByTag.records.queryTable({
1084
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1085
- body: query,
2241
+ mergeMigrationRequest({
2242
+ workspace,
2243
+ region,
2244
+ database,
2245
+ migrationRequest
2246
+ }) {
2247
+ return operationsByTag.migrationRequests.mergeMigrationRequest({
2248
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1086
2249
  ...this.extraProps
1087
2250
  });
1088
2251
  }
1089
- searchTable(workspace, database, branch, tableName, query) {
1090
- return operationsByTag.records.searchTable({
1091
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1092
- body: query,
1093
- ...this.extraProps
1094
- });
2252
+ }
2253
+ class MigrationsApi {
2254
+ constructor(extraProps) {
2255
+ this.extraProps = extraProps;
1095
2256
  }
1096
- searchBranch(workspace, database, branch, query) {
1097
- return operationsByTag.records.searchBranch({
1098
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1099
- body: query,
2257
+ getBranchMigrationHistory({
2258
+ workspace,
2259
+ region,
2260
+ database,
2261
+ branch,
2262
+ limit,
2263
+ startFrom
2264
+ }) {
2265
+ return operationsByTag.migrations.getBranchMigrationHistory({
2266
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2267
+ body: { limit, startFrom },
1100
2268
  ...this.extraProps
1101
2269
  });
1102
2270
  }
1103
- summarizeTable(workspace, database, branch, tableName, query) {
1104
- return operationsByTag.records.summarizeTable({
1105
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1106
- body: query,
2271
+ getBranchMigrationPlan({
2272
+ workspace,
2273
+ region,
2274
+ database,
2275
+ branch,
2276
+ schema
2277
+ }) {
2278
+ return operationsByTag.migrations.getBranchMigrationPlan({
2279
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2280
+ body: schema,
1107
2281
  ...this.extraProps
1108
2282
  });
1109
2283
  }
1110
- }
1111
- class MigrationRequestsApi {
1112
- constructor(extraProps) {
1113
- this.extraProps = extraProps;
1114
- }
1115
- listMigrationRequests(workspace, database, options = {}) {
1116
- return operationsByTag.migrationRequests.listMigrationRequests({
1117
- pathParams: { workspace, dbName: database },
1118
- body: options,
2284
+ executeBranchMigrationPlan({
2285
+ workspace,
2286
+ region,
2287
+ database,
2288
+ branch,
2289
+ plan
2290
+ }) {
2291
+ return operationsByTag.migrations.executeBranchMigrationPlan({
2292
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2293
+ body: plan,
1119
2294
  ...this.extraProps
1120
2295
  });
1121
2296
  }
1122
- createMigrationRequest(workspace, database, options) {
1123
- return operationsByTag.migrationRequests.createMigrationRequest({
1124
- pathParams: { workspace, dbName: database },
1125
- body: options,
2297
+ getBranchSchemaHistory({
2298
+ workspace,
2299
+ region,
2300
+ database,
2301
+ branch,
2302
+ page
2303
+ }) {
2304
+ return operationsByTag.migrations.getBranchSchemaHistory({
2305
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2306
+ body: { page },
1126
2307
  ...this.extraProps
1127
2308
  });
1128
2309
  }
1129
- getMigrationRequest(workspace, database, migrationRequest) {
1130
- return operationsByTag.migrationRequests.getMigrationRequest({
1131
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
2310
+ compareBranchWithUserSchema({
2311
+ workspace,
2312
+ region,
2313
+ database,
2314
+ branch,
2315
+ schema,
2316
+ schemaOperations,
2317
+ branchOperations
2318
+ }) {
2319
+ return operationsByTag.migrations.compareBranchWithUserSchema({
2320
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2321
+ body: { schema, schemaOperations, branchOperations },
1132
2322
  ...this.extraProps
1133
2323
  });
1134
2324
  }
1135
- updateMigrationRequest(workspace, database, migrationRequest, options) {
1136
- return operationsByTag.migrationRequests.updateMigrationRequest({
1137
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1138
- body: options,
2325
+ compareBranchSchemas({
2326
+ workspace,
2327
+ region,
2328
+ database,
2329
+ branch,
2330
+ compare,
2331
+ sourceBranchOperations,
2332
+ targetBranchOperations
2333
+ }) {
2334
+ return operationsByTag.migrations.compareBranchSchemas({
2335
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
2336
+ body: { sourceBranchOperations, targetBranchOperations },
1139
2337
  ...this.extraProps
1140
2338
  });
1141
2339
  }
1142
- listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1143
- return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1144
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1145
- body: options,
2340
+ updateBranchSchema({
2341
+ workspace,
2342
+ region,
2343
+ database,
2344
+ branch,
2345
+ migration
2346
+ }) {
2347
+ return operationsByTag.migrations.updateBranchSchema({
2348
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2349
+ body: migration,
1146
2350
  ...this.extraProps
1147
2351
  });
1148
2352
  }
1149
- compareMigrationRequest(workspace, database, migrationRequest) {
1150
- return operationsByTag.migrationRequests.compareMigrationRequest({
1151
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
2353
+ previewBranchSchemaEdit({
2354
+ workspace,
2355
+ region,
2356
+ database,
2357
+ branch,
2358
+ data
2359
+ }) {
2360
+ return operationsByTag.migrations.previewBranchSchemaEdit({
2361
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2362
+ body: data,
1152
2363
  ...this.extraProps
1153
2364
  });
1154
2365
  }
1155
- getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1156
- return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1157
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
2366
+ applyBranchSchemaEdit({
2367
+ workspace,
2368
+ region,
2369
+ database,
2370
+ branch,
2371
+ edits
2372
+ }) {
2373
+ return operationsByTag.migrations.applyBranchSchemaEdit({
2374
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2375
+ body: { edits },
1158
2376
  ...this.extraProps
1159
2377
  });
1160
2378
  }
1161
- mergeMigrationRequest(workspace, database, migrationRequest) {
1162
- return operationsByTag.migrationRequests.mergeMigrationRequest({
1163
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
2379
+ pushBranchMigrations({
2380
+ workspace,
2381
+ region,
2382
+ database,
2383
+ branch,
2384
+ migrations
2385
+ }) {
2386
+ return operationsByTag.migrations.pushBranchMigrations({
2387
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2388
+ body: { migrations },
1164
2389
  ...this.extraProps
1165
2390
  });
1166
2391
  }
1167
2392
  }
1168
- class BranchSchemaApi {
2393
+ class DatabaseApi {
1169
2394
  constructor(extraProps) {
1170
2395
  this.extraProps = extraProps;
1171
2396
  }
1172
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
1173
- return operationsByTag.branchSchema.getBranchMigrationHistory({
1174
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1175
- body: options,
2397
+ getDatabaseList({ workspace }) {
2398
+ return operationsByTag.databases.getDatabaseList({
2399
+ pathParams: { workspaceId: workspace },
1176
2400
  ...this.extraProps
1177
2401
  });
1178
2402
  }
1179
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1180
- return operationsByTag.branchSchema.executeBranchMigrationPlan({
1181
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1182
- body: migrationPlan,
2403
+ createDatabase({
2404
+ workspace,
2405
+ database,
2406
+ data
2407
+ }) {
2408
+ return operationsByTag.databases.createDatabase({
2409
+ pathParams: { workspaceId: workspace, dbName: database },
2410
+ body: data,
1183
2411
  ...this.extraProps
1184
2412
  });
1185
2413
  }
1186
- getBranchMigrationPlan(workspace, database, branch, schema) {
1187
- return operationsByTag.branchSchema.getBranchMigrationPlan({
1188
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1189
- body: schema,
2414
+ deleteDatabase({
2415
+ workspace,
2416
+ database
2417
+ }) {
2418
+ return operationsByTag.databases.deleteDatabase({
2419
+ pathParams: { workspaceId: workspace, dbName: database },
1190
2420
  ...this.extraProps
1191
2421
  });
1192
2422
  }
1193
- compareBranchWithUserSchema(workspace, database, branch, schema) {
1194
- return operationsByTag.branchSchema.compareBranchWithUserSchema({
1195
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1196
- body: { schema },
2423
+ getDatabaseMetadata({
2424
+ workspace,
2425
+ database
2426
+ }) {
2427
+ return operationsByTag.databases.getDatabaseMetadata({
2428
+ pathParams: { workspaceId: workspace, dbName: database },
1197
2429
  ...this.extraProps
1198
2430
  });
1199
2431
  }
1200
- compareBranchSchemas(workspace, database, branch, branchName, schema) {
1201
- return operationsByTag.branchSchema.compareBranchSchemas({
1202
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1203
- body: { schema },
2432
+ updateDatabaseMetadata({
2433
+ workspace,
2434
+ database,
2435
+ metadata
2436
+ }) {
2437
+ return operationsByTag.databases.updateDatabaseMetadata({
2438
+ pathParams: { workspaceId: workspace, dbName: database },
2439
+ body: metadata,
1204
2440
  ...this.extraProps
1205
2441
  });
1206
2442
  }
1207
- updateBranchSchema(workspace, database, branch, migration) {
1208
- return operationsByTag.branchSchema.updateBranchSchema({
1209
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1210
- body: migration,
2443
+ renameDatabase({
2444
+ workspace,
2445
+ database,
2446
+ newName
2447
+ }) {
2448
+ return operationsByTag.databases.renameDatabase({
2449
+ pathParams: { workspaceId: workspace, dbName: database },
2450
+ body: { newName },
1211
2451
  ...this.extraProps
1212
2452
  });
1213
2453
  }
1214
- previewBranchSchemaEdit(workspace, database, branch, migration) {
1215
- return operationsByTag.branchSchema.previewBranchSchemaEdit({
1216
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1217
- body: migration,
2454
+ getDatabaseGithubSettings({
2455
+ workspace,
2456
+ database
2457
+ }) {
2458
+ return operationsByTag.databases.getDatabaseGithubSettings({
2459
+ pathParams: { workspaceId: workspace, dbName: database },
1218
2460
  ...this.extraProps
1219
2461
  });
1220
2462
  }
1221
- applyBranchSchemaEdit(workspace, database, branch, edits) {
1222
- return operationsByTag.branchSchema.applyBranchSchemaEdit({
1223
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1224
- body: { edits },
2463
+ updateDatabaseGithubSettings({
2464
+ workspace,
2465
+ database,
2466
+ settings
2467
+ }) {
2468
+ return operationsByTag.databases.updateDatabaseGithubSettings({
2469
+ pathParams: { workspaceId: workspace, dbName: database },
2470
+ body: settings,
2471
+ ...this.extraProps
2472
+ });
2473
+ }
2474
+ deleteDatabaseGithubSettings({
2475
+ workspace,
2476
+ database
2477
+ }) {
2478
+ return operationsByTag.databases.deleteDatabaseGithubSettings({
2479
+ pathParams: { workspaceId: workspace, dbName: database },
1225
2480
  ...this.extraProps
1226
2481
  });
1227
2482
  }
1228
- getBranchSchemaHistory(workspace, database, branch, options = {}) {
1229
- return operationsByTag.branchSchema.getBranchSchemaHistory({
1230
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1231
- body: options,
2483
+ listRegions({ workspace }) {
2484
+ return operationsByTag.databases.listRegions({
2485
+ pathParams: { workspaceId: workspace },
1232
2486
  ...this.extraProps
1233
2487
  });
1234
2488
  }
1235
2489
  }
1236
2490
 
1237
2491
  class XataApiPlugin {
1238
- async build(options) {
1239
- const { fetchImpl, apiKey } = await options.getFetchProps();
1240
- return new XataApiClient({ fetch: fetchImpl, apiKey });
2492
+ build(options) {
2493
+ return new XataApiClient(options);
1241
2494
  }
1242
2495
  }
1243
2496
 
1244
2497
  class XataPlugin {
1245
2498
  }
1246
2499
 
2500
+ function cleanFilter(filter) {
2501
+ if (!filter)
2502
+ return void 0;
2503
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2504
+ return values.length > 0 ? filter : void 0;
2505
+ }
2506
+
1247
2507
  var __accessCheck$6 = (obj, member, msg) => {
1248
2508
  if (!member.has(obj))
1249
2509
  throw TypeError("Cannot " + msg);
@@ -1270,18 +2530,46 @@ class Page {
1270
2530
  this.meta = meta;
1271
2531
  this.records = new RecordArray(this, records);
1272
2532
  }
2533
+ /**
2534
+ * Retrieves the next page of results.
2535
+ * @param size Maximum number of results to be retrieved.
2536
+ * @param offset Number of results to skip when retrieving the results.
2537
+ * @returns The next page or results.
2538
+ */
1273
2539
  async nextPage(size, offset) {
1274
2540
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
1275
2541
  }
2542
+ /**
2543
+ * Retrieves the previous page of results.
2544
+ * @param size Maximum number of results to be retrieved.
2545
+ * @param offset Number of results to skip when retrieving the results.
2546
+ * @returns The previous page or results.
2547
+ */
1276
2548
  async previousPage(size, offset) {
1277
2549
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
1278
2550
  }
1279
- async firstPage(size, offset) {
1280
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
1281
- }
1282
- async lastPage(size, offset) {
1283
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
1284
- }
2551
+ /**
2552
+ * Retrieves the start page of results.
2553
+ * @param size Maximum number of results to be retrieved.
2554
+ * @param offset Number of results to skip when retrieving the results.
2555
+ * @returns The start page or results.
2556
+ */
2557
+ async startPage(size, offset) {
2558
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
2559
+ }
2560
+ /**
2561
+ * Retrieves the end page of results.
2562
+ * @param size Maximum number of results to be retrieved.
2563
+ * @param offset Number of results to skip when retrieving the results.
2564
+ * @returns The end page or results.
2565
+ */
2566
+ async endPage(size, offset) {
2567
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
2568
+ }
2569
+ /**
2570
+ * Shortcut method to check if there will be additional results if the next page of results is retrieved.
2571
+ * @returns Whether or not there will be additional results in the next page of results.
2572
+ */
1285
2573
  hasNextPage() {
1286
2574
  return this.meta.page.more;
1287
2575
  }
@@ -1292,7 +2580,7 @@ const PAGINATION_DEFAULT_SIZE = 20;
1292
2580
  const PAGINATION_MAX_OFFSET = 800;
1293
2581
  const PAGINATION_DEFAULT_OFFSET = 0;
1294
2582
  function isCursorPaginationOptions(options) {
1295
- return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
2583
+ return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
1296
2584
  }
1297
2585
  const _RecordArray = class extends Array {
1298
2586
  constructor(...args) {
@@ -1313,25 +2601,54 @@ const _RecordArray = class extends Array {
1313
2601
  toArray() {
1314
2602
  return new Array(...this);
1315
2603
  }
2604
+ toSerializable() {
2605
+ return JSON.parse(this.toString());
2606
+ }
2607
+ toString() {
2608
+ return JSON.stringify(this.toArray());
2609
+ }
1316
2610
  map(callbackfn, thisArg) {
1317
2611
  return this.toArray().map(callbackfn, thisArg);
1318
2612
  }
2613
+ /**
2614
+ * Retrieve next page of records
2615
+ *
2616
+ * @returns A new array of objects
2617
+ */
1319
2618
  async nextPage(size, offset) {
1320
2619
  const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
1321
2620
  return new _RecordArray(newPage);
1322
2621
  }
2622
+ /**
2623
+ * Retrieve previous page of records
2624
+ *
2625
+ * @returns A new array of objects
2626
+ */
1323
2627
  async previousPage(size, offset) {
1324
2628
  const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
1325
2629
  return new _RecordArray(newPage);
1326
2630
  }
1327
- async firstPage(size, offset) {
1328
- const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
2631
+ /**
2632
+ * Retrieve start page of records
2633
+ *
2634
+ * @returns A new array of objects
2635
+ */
2636
+ async startPage(size, offset) {
2637
+ const newPage = await __privateGet$6(this, _page).startPage(size, offset);
1329
2638
  return new _RecordArray(newPage);
1330
2639
  }
1331
- async lastPage(size, offset) {
1332
- const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
2640
+ /**
2641
+ * Retrieve end page of records
2642
+ *
2643
+ * @returns A new array of objects
2644
+ */
2645
+ async endPage(size, offset) {
2646
+ const newPage = await __privateGet$6(this, _page).endPage(size, offset);
1333
2647
  return new _RecordArray(newPage);
1334
2648
  }
2649
+ /**
2650
+ * @returns Boolean indicating if there is a next page
2651
+ */
1335
2652
  hasNextPage() {
1336
2653
  return __privateGet$6(this, _page).meta.page.more;
1337
2654
  }
@@ -1368,7 +2685,8 @@ const _Query = class {
1368
2685
  __privateAdd$5(this, _table$1, void 0);
1369
2686
  __privateAdd$5(this, _repository, void 0);
1370
2687
  __privateAdd$5(this, _data, { filter: {} });
1371
- this.meta = { page: { cursor: "start", more: true } };
2688
+ // Implements pagination
2689
+ this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
1372
2690
  this.records = new RecordArray(this, []);
1373
2691
  __privateSet$5(this, _table$1, table);
1374
2692
  if (repository) {
@@ -1383,9 +2701,11 @@ const _Query = class {
1383
2701
  __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
1384
2702
  __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
1385
2703
  __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
1386
- __privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
2704
+ __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
2705
+ __privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
1387
2706
  __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
1388
2707
  __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
2708
+ __privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
1389
2709
  this.any = this.any.bind(this);
1390
2710
  this.all = this.all.bind(this);
1391
2711
  this.not = this.not.bind(this);
@@ -1403,18 +2723,38 @@ const _Query = class {
1403
2723
  const key = JSON.stringify({ columns, filter, sort, pagination });
1404
2724
  return toBase64(key);
1405
2725
  }
2726
+ /**
2727
+ * Builds a new query object representing a logical OR between the given subqueries.
2728
+ * @param queries An array of subqueries.
2729
+ * @returns A new Query object.
2730
+ */
1406
2731
  any(...queries) {
1407
2732
  const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
1408
2733
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
1409
2734
  }
2735
+ /**
2736
+ * Builds a new query object representing a logical AND between the given subqueries.
2737
+ * @param queries An array of subqueries.
2738
+ * @returns A new Query object.
2739
+ */
1410
2740
  all(...queries) {
1411
2741
  const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
1412
2742
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1413
2743
  }
2744
+ /**
2745
+ * Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
2746
+ * @param queries An array of subqueries.
2747
+ * @returns A new Query object.
2748
+ */
1414
2749
  not(...queries) {
1415
2750
  const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
1416
2751
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
1417
2752
  }
2753
+ /**
2754
+ * Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
2755
+ * @param queries An array of subqueries.
2756
+ * @returns A new Query object.
2757
+ */
1418
2758
  none(...queries) {
1419
2759
  const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
1420
2760
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
@@ -1437,6 +2777,11 @@ const _Query = class {
1437
2777
  const sort = [...originalSort, { column, direction }];
1438
2778
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
1439
2779
  }
2780
+ /**
2781
+ * Builds a new query specifying the set of columns to be returned in the query response.
2782
+ * @param columns Array of column names to be returned by the query.
2783
+ * @returns A new Query object.
2784
+ */
1440
2785
  select(columns) {
1441
2786
  return new _Query(
1442
2787
  __privateGet$5(this, _repository),
@@ -1449,6 +2794,12 @@ const _Query = class {
1449
2794
  const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
1450
2795
  return __privateGet$5(this, _repository).query(query);
1451
2796
  }
2797
+ /**
2798
+ * Get results in an iterator
2799
+ *
2800
+ * @async
2801
+ * @returns Async interable of results
2802
+ */
1452
2803
  async *[Symbol.asyncIterator]() {
1453
2804
  for await (const [record] of this.getIterator({ batchSize: 1 })) {
1454
2805
  yield record;
@@ -1499,21 +2850,59 @@ const _Query = class {
1499
2850
  throw new Error("No results found.");
1500
2851
  return records[0];
1501
2852
  }
2853
+ async summarize(params = {}) {
2854
+ const { summaries, summariesFilter, ...options } = params;
2855
+ const query = new _Query(
2856
+ __privateGet$5(this, _repository),
2857
+ __privateGet$5(this, _table$1),
2858
+ options,
2859
+ __privateGet$5(this, _data)
2860
+ );
2861
+ return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
2862
+ }
2863
+ /**
2864
+ * Builds a new query object adding a cache TTL in milliseconds.
2865
+ * @param ttl The cache TTL in milliseconds.
2866
+ * @returns A new Query object.
2867
+ */
1502
2868
  cache(ttl) {
1503
2869
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1504
2870
  }
2871
+ /**
2872
+ * Retrieve next page of records
2873
+ *
2874
+ * @returns A new page object.
2875
+ */
1505
2876
  nextPage(size, offset) {
1506
- return this.firstPage(size, offset);
2877
+ return this.startPage(size, offset);
1507
2878
  }
2879
+ /**
2880
+ * Retrieve previous page of records
2881
+ *
2882
+ * @returns A new page object
2883
+ */
1508
2884
  previousPage(size, offset) {
1509
- return this.firstPage(size, offset);
1510
- }
1511
- firstPage(size, offset) {
2885
+ return this.startPage(size, offset);
2886
+ }
2887
+ /**
2888
+ * Retrieve start page of records
2889
+ *
2890
+ * @returns A new page object
2891
+ */
2892
+ startPage(size, offset) {
1512
2893
  return this.getPaginated({ pagination: { size, offset } });
1513
2894
  }
1514
- lastPage(size, offset) {
2895
+ /**
2896
+ * Retrieve last page of records
2897
+ *
2898
+ * @returns A new page object
2899
+ */
2900
+ endPage(size, offset) {
1515
2901
  return this.getPaginated({ pagination: { size, offset, before: "end" } });
1516
2902
  }
2903
+ /**
2904
+ * @returns Boolean indicating if there is a next page
2905
+ */
1517
2906
  hasNextPage() {
1518
2907
  return this.meta.page.more;
1519
2908
  }
@@ -1535,7 +2924,7 @@ cleanFilterConstraint_fn = function(column, value) {
1535
2924
  };
1536
2925
  function cleanParent(data, parent) {
1537
2926
  if (isCursorPaginationOptions(data.pagination)) {
1538
- return { ...parent, sorting: void 0, filter: void 0 };
2927
+ return { ...parent, sort: void 0, filter: void 0 };
1539
2928
  }
1540
2929
  return parent;
1541
2930
  }
@@ -1553,7 +2942,11 @@ function isSortFilterString(value) {
1553
2942
  return isString(value);
1554
2943
  }
1555
2944
  function isSortFilterBase(filter) {
1556
- return isObject(filter) && Object.values(filter).every((value) => value === "asc" || value === "desc");
2945
+ return isObject(filter) && Object.entries(filter).every(([key, value]) => {
2946
+ if (key === "*")
2947
+ return value === "random";
2948
+ return value === "asc" || value === "desc";
2949
+ });
1557
2950
  }
1558
2951
  function isSortFilterObject(filter) {
1559
2952
  return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
@@ -1594,7 +2987,8 @@ var __privateMethod$2 = (obj, member, method) => {
1594
2987
  __accessCheck$4(obj, member, "access private method");
1595
2988
  return method;
1596
2989
  };
1597
- var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
2990
+ 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;
2991
+ const BULK_OPERATION_MAX_SIZE = 1e3;
1598
2992
  class Repository extends Query {
1599
2993
  }
1600
2994
  class RestRepository extends Query {
@@ -1606,10 +3000,12 @@ class RestRepository extends Query {
1606
3000
  );
1607
3001
  __privateAdd$4(this, _insertRecordWithoutId);
1608
3002
  __privateAdd$4(this, _insertRecordWithId);
1609
- __privateAdd$4(this, _bulkInsertTableRecords);
3003
+ __privateAdd$4(this, _insertRecords);
1610
3004
  __privateAdd$4(this, _updateRecordWithID);
3005
+ __privateAdd$4(this, _updateRecords);
1611
3006
  __privateAdd$4(this, _upsertRecordWithID);
1612
3007
  __privateAdd$4(this, _deleteRecord);
3008
+ __privateAdd$4(this, _deleteRecords);
1613
3009
  __privateAdd$4(this, _setCacheQuery);
1614
3010
  __privateAdd$4(this, _getCacheQuery);
1615
3011
  __privateAdd$4(this, _getSchemaTables$1);
@@ -1620,10 +3016,10 @@ class RestRepository extends Query {
1620
3016
  __privateAdd$4(this, _schemaTables$2, void 0);
1621
3017
  __privateAdd$4(this, _trace, void 0);
1622
3018
  __privateSet$4(this, _table, options.table);
1623
- __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1624
3019
  __privateSet$4(this, _db, options.db);
1625
3020
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1626
3021
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
3022
+ __privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
1627
3023
  const trace = options.pluginOptions.trace ?? defaultTrace;
1628
3024
  __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
1629
3025
  return trace(name, fn, {
@@ -1634,25 +3030,28 @@ class RestRepository extends Query {
1634
3030
  });
1635
3031
  });
1636
3032
  }
1637
- async create(a, b, c) {
3033
+ async create(a, b, c, d) {
1638
3034
  return __privateGet$4(this, _trace).call(this, "create", async () => {
3035
+ const ifVersion = parseIfVersion(b, c, d);
1639
3036
  if (Array.isArray(a)) {
1640
3037
  if (a.length === 0)
1641
3038
  return [];
1642
- const columns = isStringArray(b) ? b : void 0;
1643
- return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
3039
+ const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
3040
+ const columns = isStringArray(b) ? b : ["*"];
3041
+ const result = await this.read(ids, columns);
3042
+ return result;
1644
3043
  }
1645
3044
  if (isString(a) && isObject(b)) {
1646
3045
  if (a === "")
1647
3046
  throw new Error("The id can't be empty");
1648
3047
  const columns = isStringArray(c) ? c : void 0;
1649
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
3048
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
1650
3049
  }
1651
3050
  if (isObject(a) && isString(a.id)) {
1652
3051
  if (a.id === "")
1653
3052
  throw new Error("The id can't be empty");
1654
3053
  const columns = isStringArray(b) ? b : void 0;
1655
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
3054
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
1656
3055
  }
1657
3056
  if (isObject(a)) {
1658
3057
  const columns = isStringArray(b) ? b : void 0;
@@ -1677,20 +3076,20 @@ class RestRepository extends Query {
1677
3076
  }
1678
3077
  const id = extractId(a);
1679
3078
  if (id) {
1680
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1681
3079
  try {
1682
3080
  const response = await getRecord({
1683
3081
  pathParams: {
1684
3082
  workspace: "{workspaceId}",
1685
3083
  dbBranchName: "{dbBranch}",
3084
+ region: "{region}",
1686
3085
  tableName: __privateGet$4(this, _table),
1687
3086
  recordId: id
1688
3087
  },
1689
3088
  queryParams: { columns },
1690
- ...fetchProps
3089
+ ...__privateGet$4(this, _getFetchProps).call(this)
1691
3090
  });
1692
3091
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1693
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
3092
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1694
3093
  } catch (e) {
1695
3094
  if (isObject(e) && e.status === 404) {
1696
3095
  return null;
@@ -1720,31 +3119,42 @@ class RestRepository extends Query {
1720
3119
  return result;
1721
3120
  });
1722
3121
  }
1723
- async update(a, b, c) {
3122
+ async update(a, b, c, d) {
1724
3123
  return __privateGet$4(this, _trace).call(this, "update", async () => {
3124
+ const ifVersion = parseIfVersion(b, c, d);
1725
3125
  if (Array.isArray(a)) {
1726
3126
  if (a.length === 0)
1727
3127
  return [];
1728
- if (a.length > 100) {
1729
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1730
- }
3128
+ const existing = await this.read(a, ["id"]);
3129
+ const updates = a.filter((_item, index) => existing[index] !== null);
3130
+ await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
3131
+ ifVersion,
3132
+ upsert: false
3133
+ });
1731
3134
  const columns = isStringArray(b) ? b : ["*"];
1732
- return Promise.all(a.map((object) => this.update(object, columns)));
1733
- }
1734
- if (isString(a) && isObject(b)) {
1735
- const columns = isStringArray(c) ? c : void 0;
1736
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
3135
+ const result = await this.read(a, columns);
3136
+ return result;
1737
3137
  }
1738
- if (isObject(a) && isString(a.id)) {
1739
- const columns = isStringArray(b) ? b : void 0;
1740
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
3138
+ try {
3139
+ if (isString(a) && isObject(b)) {
3140
+ const columns = isStringArray(c) ? c : void 0;
3141
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
3142
+ }
3143
+ if (isObject(a) && isString(a.id)) {
3144
+ const columns = isStringArray(b) ? b : void 0;
3145
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3146
+ }
3147
+ } catch (error) {
3148
+ if (error.status === 422)
3149
+ return null;
3150
+ throw error;
1741
3151
  }
1742
3152
  throw new Error("Invalid arguments for update method");
1743
3153
  });
1744
3154
  }
1745
- async updateOrThrow(a, b, c) {
3155
+ async updateOrThrow(a, b, c, d) {
1746
3156
  return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1747
- const result = await this.update(a, b, c);
3157
+ const result = await this.update(a, b, c, d);
1748
3158
  if (Array.isArray(result)) {
1749
3159
  const missingIds = compact(
1750
3160
  a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
@@ -1761,37 +3171,89 @@ class RestRepository extends Query {
1761
3171
  return result;
1762
3172
  });
1763
3173
  }
1764
- async createOrUpdate(a, b, c) {
3174
+ async createOrUpdate(a, b, c, d) {
1765
3175
  return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
3176
+ const ifVersion = parseIfVersion(b, c, d);
1766
3177
  if (Array.isArray(a)) {
1767
3178
  if (a.length === 0)
1768
3179
  return [];
1769
- if (a.length > 100) {
1770
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1771
- }
3180
+ await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
3181
+ ifVersion,
3182
+ upsert: true
3183
+ });
1772
3184
  const columns = isStringArray(b) ? b : ["*"];
1773
- return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
3185
+ const result = await this.read(a, columns);
3186
+ return result;
1774
3187
  }
1775
3188
  if (isString(a) && isObject(b)) {
3189
+ if (a === "")
3190
+ throw new Error("The id can't be empty");
1776
3191
  const columns = isStringArray(c) ? c : void 0;
1777
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
3192
+ return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1778
3193
  }
1779
3194
  if (isObject(a) && isString(a.id)) {
3195
+ if (a.id === "")
3196
+ throw new Error("The id can't be empty");
1780
3197
  const columns = isStringArray(c) ? c : void 0;
1781
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
3198
+ return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3199
+ }
3200
+ if (!isDefined(a) && isObject(b)) {
3201
+ return await this.create(b, c);
3202
+ }
3203
+ if (isObject(a) && !isDefined(a.id)) {
3204
+ return await this.create(a, b);
1782
3205
  }
1783
3206
  throw new Error("Invalid arguments for createOrUpdate method");
1784
3207
  });
1785
3208
  }
3209
+ async createOrReplace(a, b, c, d) {
3210
+ return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
3211
+ const ifVersion = parseIfVersion(b, c, d);
3212
+ if (Array.isArray(a)) {
3213
+ if (a.length === 0)
3214
+ return [];
3215
+ const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
3216
+ const columns = isStringArray(b) ? b : ["*"];
3217
+ const result = await this.read(ids, columns);
3218
+ return result;
3219
+ }
3220
+ if (isString(a) && isObject(b)) {
3221
+ if (a === "")
3222
+ throw new Error("The id can't be empty");
3223
+ const columns = isStringArray(c) ? c : void 0;
3224
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
3225
+ }
3226
+ if (isObject(a) && isString(a.id)) {
3227
+ if (a.id === "")
3228
+ throw new Error("The id can't be empty");
3229
+ const columns = isStringArray(c) ? c : void 0;
3230
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
3231
+ }
3232
+ if (!isDefined(a) && isObject(b)) {
3233
+ return await this.create(b, c);
3234
+ }
3235
+ if (isObject(a) && !isDefined(a.id)) {
3236
+ return await this.create(a, b);
3237
+ }
3238
+ throw new Error("Invalid arguments for createOrReplace method");
3239
+ });
3240
+ }
1786
3241
  async delete(a, b) {
1787
3242
  return __privateGet$4(this, _trace).call(this, "delete", async () => {
1788
3243
  if (Array.isArray(a)) {
1789
3244
  if (a.length === 0)
1790
3245
  return [];
1791
- if (a.length > 100) {
1792
- console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1793
- }
1794
- return Promise.all(a.map((id) => this.delete(id, b)));
3246
+ const ids = a.map((o) => {
3247
+ if (isString(o))
3248
+ return o;
3249
+ if (isString(o.id))
3250
+ return o.id;
3251
+ throw new Error("Invalid arguments for delete method");
3252
+ });
3253
+ const columns = isStringArray(b) ? b : ["*"];
3254
+ const result = await this.read(a, columns);
3255
+ await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
3256
+ return result;
1795
3257
  }
1796
3258
  if (isString(a)) {
1797
3259
  return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
@@ -1822,21 +3284,64 @@ class RestRepository extends Query {
1822
3284
  }
1823
3285
  async search(query, options = {}) {
1824
3286
  return __privateGet$4(this, _trace).call(this, "search", async () => {
1825
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1826
3287
  const { records } = await searchTable({
1827
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
3288
+ pathParams: {
3289
+ workspace: "{workspaceId}",
3290
+ dbBranchName: "{dbBranch}",
3291
+ region: "{region}",
3292
+ tableName: __privateGet$4(this, _table)
3293
+ },
1828
3294
  body: {
1829
3295
  query,
1830
3296
  fuzziness: options.fuzziness,
1831
3297
  prefix: options.prefix,
1832
3298
  highlight: options.highlight,
1833
3299
  filter: options.filter,
1834
- boosters: options.boosters
3300
+ boosters: options.boosters,
3301
+ page: options.page,
3302
+ target: options.target
1835
3303
  },
1836
- ...fetchProps
3304
+ ...__privateGet$4(this, _getFetchProps).call(this)
1837
3305
  });
1838
3306
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1839
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
3307
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3308
+ });
3309
+ }
3310
+ async vectorSearch(column, query, options) {
3311
+ return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
3312
+ const { records } = await vectorSearchTable({
3313
+ pathParams: {
3314
+ workspace: "{workspaceId}",
3315
+ dbBranchName: "{dbBranch}",
3316
+ region: "{region}",
3317
+ tableName: __privateGet$4(this, _table)
3318
+ },
3319
+ body: {
3320
+ column,
3321
+ queryVector: query,
3322
+ similarityFunction: options?.similarityFunction,
3323
+ size: options?.size,
3324
+ filter: options?.filter
3325
+ },
3326
+ ...__privateGet$4(this, _getFetchProps).call(this)
3327
+ });
3328
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3329
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3330
+ });
3331
+ }
3332
+ async aggregate(aggs, filter) {
3333
+ return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
3334
+ const result = await aggregateTable({
3335
+ pathParams: {
3336
+ workspace: "{workspaceId}",
3337
+ dbBranchName: "{dbBranch}",
3338
+ region: "{region}",
3339
+ tableName: __privateGet$4(this, _table)
3340
+ },
3341
+ body: { aggs, filter },
3342
+ ...__privateGet$4(this, _getFetchProps).call(this)
3343
+ });
3344
+ return result;
1840
3345
  });
1841
3346
  }
1842
3347
  async query(query) {
@@ -1845,24 +3350,83 @@ class RestRepository extends Query {
1845
3350
  if (cacheQuery)
1846
3351
  return new Page(query, cacheQuery.meta, cacheQuery.records);
1847
3352
  const data = query.getQueryOptions();
1848
- const body = {
1849
- filter: cleanFilter(data.filter),
1850
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1851
- page: data.pagination,
1852
- columns: data.columns
1853
- };
1854
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1855
3353
  const { meta, records: objects } = await queryTable({
1856
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1857
- body,
1858
- ...fetchProps
3354
+ pathParams: {
3355
+ workspace: "{workspaceId}",
3356
+ dbBranchName: "{dbBranch}",
3357
+ region: "{region}",
3358
+ tableName: __privateGet$4(this, _table)
3359
+ },
3360
+ body: {
3361
+ filter: cleanFilter(data.filter),
3362
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
3363
+ page: data.pagination,
3364
+ columns: data.columns ?? ["*"],
3365
+ consistency: data.consistency
3366
+ },
3367
+ fetchOptions: data.fetchOptions,
3368
+ ...__privateGet$4(this, _getFetchProps).call(this)
1859
3369
  });
1860
3370
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1861
- const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
3371
+ const records = objects.map(
3372
+ (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
3373
+ );
1862
3374
  await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1863
3375
  return new Page(query, meta, records);
1864
3376
  });
1865
3377
  }
3378
+ async summarizeTable(query, summaries, summariesFilter) {
3379
+ return __privateGet$4(this, _trace).call(this, "summarize", async () => {
3380
+ const data = query.getQueryOptions();
3381
+ const result = await summarizeTable({
3382
+ pathParams: {
3383
+ workspace: "{workspaceId}",
3384
+ dbBranchName: "{dbBranch}",
3385
+ region: "{region}",
3386
+ tableName: __privateGet$4(this, _table)
3387
+ },
3388
+ body: {
3389
+ filter: cleanFilter(data.filter),
3390
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
3391
+ columns: data.columns,
3392
+ consistency: data.consistency,
3393
+ page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
3394
+ summaries,
3395
+ summariesFilter
3396
+ },
3397
+ ...__privateGet$4(this, _getFetchProps).call(this)
3398
+ });
3399
+ return result;
3400
+ });
3401
+ }
3402
+ ask(question, options) {
3403
+ const params = {
3404
+ pathParams: {
3405
+ workspace: "{workspaceId}",
3406
+ dbBranchName: "{dbBranch}",
3407
+ region: "{region}",
3408
+ tableName: __privateGet$4(this, _table)
3409
+ },
3410
+ body: {
3411
+ question,
3412
+ ...options
3413
+ },
3414
+ ...__privateGet$4(this, _getFetchProps).call(this)
3415
+ };
3416
+ if (options?.onMessage) {
3417
+ fetchSSERequest({
3418
+ endpoint: "dataPlane",
3419
+ url: "/db/{dbBranchName}/tables/{tableName}/ask",
3420
+ method: "POST",
3421
+ onMessage: (message) => {
3422
+ options.onMessage?.({ answer: message.text, records: message.records });
3423
+ },
3424
+ ...params
3425
+ });
3426
+ } else {
3427
+ return askTable(params);
3428
+ }
3429
+ }
1866
3430
  }
1867
3431
  _table = new WeakMap();
1868
3432
  _getFetchProps = new WeakMap();
@@ -1872,68 +3436,90 @@ _schemaTables$2 = new WeakMap();
1872
3436
  _trace = new WeakMap();
1873
3437
  _insertRecordWithoutId = new WeakSet();
1874
3438
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1875
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1876
3439
  const record = transformObjectLinks(object);
1877
3440
  const response = await insertRecord({
1878
3441
  pathParams: {
1879
3442
  workspace: "{workspaceId}",
1880
3443
  dbBranchName: "{dbBranch}",
3444
+ region: "{region}",
1881
3445
  tableName: __privateGet$4(this, _table)
1882
3446
  },
1883
3447
  queryParams: { columns },
1884
3448
  body: record,
1885
- ...fetchProps
3449
+ ...__privateGet$4(this, _getFetchProps).call(this)
1886
3450
  });
1887
3451
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1888
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
3452
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1889
3453
  };
1890
3454
  _insertRecordWithId = new WeakSet();
1891
- insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
1892
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
3455
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
3456
+ if (!recordId)
3457
+ return null;
1893
3458
  const record = transformObjectLinks(object);
1894
3459
  const response = await insertRecordWithID({
1895
3460
  pathParams: {
1896
3461
  workspace: "{workspaceId}",
1897
3462
  dbBranchName: "{dbBranch}",
3463
+ region: "{region}",
1898
3464
  tableName: __privateGet$4(this, _table),
1899
3465
  recordId
1900
3466
  },
1901
3467
  body: record,
1902
- queryParams: { createOnly: true, columns },
1903
- ...fetchProps
3468
+ queryParams: { createOnly, columns, ifVersion },
3469
+ ...__privateGet$4(this, _getFetchProps).call(this)
1904
3470
  });
1905
3471
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1906
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1907
- };
1908
- _bulkInsertTableRecords = new WeakSet();
1909
- bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1910
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1911
- const records = objects.map((object) => transformObjectLinks(object));
1912
- const response = await bulkInsertTableRecords({
1913
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1914
- queryParams: { columns },
1915
- body: { records },
1916
- ...fetchProps
1917
- });
1918
- if (!isResponseWithRecords(response)) {
1919
- throw new Error("Request included columns but server didn't include them");
3472
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
3473
+ };
3474
+ _insertRecords = new WeakSet();
3475
+ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
3476
+ const chunkedOperations = chunk(
3477
+ objects.map((object) => ({
3478
+ insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
3479
+ })),
3480
+ BULK_OPERATION_MAX_SIZE
3481
+ );
3482
+ const ids = [];
3483
+ for (const operations of chunkedOperations) {
3484
+ const { results } = await branchTransaction({
3485
+ pathParams: {
3486
+ workspace: "{workspaceId}",
3487
+ dbBranchName: "{dbBranch}",
3488
+ region: "{region}"
3489
+ },
3490
+ body: { operations },
3491
+ ...__privateGet$4(this, _getFetchProps).call(this)
3492
+ });
3493
+ for (const result of results) {
3494
+ if (result.operation === "insert") {
3495
+ ids.push(result.id);
3496
+ } else {
3497
+ ids.push(null);
3498
+ }
3499
+ }
1920
3500
  }
1921
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1922
- return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
3501
+ return ids;
1923
3502
  };
1924
3503
  _updateRecordWithID = new WeakSet();
1925
- updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1926
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1927
- const record = transformObjectLinks(object);
3504
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
3505
+ if (!recordId)
3506
+ return null;
3507
+ const { id: _id, ...record } = transformObjectLinks(object);
1928
3508
  try {
1929
3509
  const response = await updateRecordWithID({
1930
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1931
- queryParams: { columns },
3510
+ pathParams: {
3511
+ workspace: "{workspaceId}",
3512
+ dbBranchName: "{dbBranch}",
3513
+ region: "{region}",
3514
+ tableName: __privateGet$4(this, _table),
3515
+ recordId
3516
+ },
3517
+ queryParams: { columns, ifVersion },
1932
3518
  body: record,
1933
- ...fetchProps
3519
+ ...__privateGet$4(this, _getFetchProps).call(this)
1934
3520
  });
1935
3521
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1936
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
3522
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1937
3523
  } catch (e) {
1938
3524
  if (isObject(e) && e.status === 404) {
1939
3525
  return null;
@@ -1941,29 +3527,72 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1941
3527
  throw e;
1942
3528
  }
1943
3529
  };
3530
+ _updateRecords = new WeakSet();
3531
+ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
3532
+ const chunkedOperations = chunk(
3533
+ objects.map(({ id, ...object }) => ({
3534
+ update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
3535
+ })),
3536
+ BULK_OPERATION_MAX_SIZE
3537
+ );
3538
+ const ids = [];
3539
+ for (const operations of chunkedOperations) {
3540
+ const { results } = await branchTransaction({
3541
+ pathParams: {
3542
+ workspace: "{workspaceId}",
3543
+ dbBranchName: "{dbBranch}",
3544
+ region: "{region}"
3545
+ },
3546
+ body: { operations },
3547
+ ...__privateGet$4(this, _getFetchProps).call(this)
3548
+ });
3549
+ for (const result of results) {
3550
+ if (result.operation === "update") {
3551
+ ids.push(result.id);
3552
+ } else {
3553
+ ids.push(null);
3554
+ }
3555
+ }
3556
+ }
3557
+ return ids;
3558
+ };
1944
3559
  _upsertRecordWithID = new WeakSet();
1945
- upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1946
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
3560
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
3561
+ if (!recordId)
3562
+ return null;
1947
3563
  const response = await upsertRecordWithID({
1948
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1949
- queryParams: { columns },
3564
+ pathParams: {
3565
+ workspace: "{workspaceId}",
3566
+ dbBranchName: "{dbBranch}",
3567
+ region: "{region}",
3568
+ tableName: __privateGet$4(this, _table),
3569
+ recordId
3570
+ },
3571
+ queryParams: { columns, ifVersion },
1950
3572
  body: object,
1951
- ...fetchProps
3573
+ ...__privateGet$4(this, _getFetchProps).call(this)
1952
3574
  });
1953
3575
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1954
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
3576
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1955
3577
  };
1956
3578
  _deleteRecord = new WeakSet();
1957
3579
  deleteRecord_fn = async function(recordId, columns = ["*"]) {
1958
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
3580
+ if (!recordId)
3581
+ return null;
1959
3582
  try {
1960
3583
  const response = await deleteRecord({
1961
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
3584
+ pathParams: {
3585
+ workspace: "{workspaceId}",
3586
+ dbBranchName: "{dbBranch}",
3587
+ region: "{region}",
3588
+ tableName: __privateGet$4(this, _table),
3589
+ recordId
3590
+ },
1962
3591
  queryParams: { columns },
1963
- ...fetchProps
3592
+ ...__privateGet$4(this, _getFetchProps).call(this)
1964
3593
  });
1965
3594
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1966
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
3595
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1967
3596
  } catch (e) {
1968
3597
  if (isObject(e) && e.status === 404) {
1969
3598
  return null;
@@ -1971,17 +3600,36 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1971
3600
  throw e;
1972
3601
  }
1973
3602
  };
3603
+ _deleteRecords = new WeakSet();
3604
+ deleteRecords_fn = async function(recordIds) {
3605
+ const chunkedOperations = chunk(
3606
+ compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
3607
+ BULK_OPERATION_MAX_SIZE
3608
+ );
3609
+ for (const operations of chunkedOperations) {
3610
+ await branchTransaction({
3611
+ pathParams: {
3612
+ workspace: "{workspaceId}",
3613
+ dbBranchName: "{dbBranch}",
3614
+ region: "{region}"
3615
+ },
3616
+ body: { operations },
3617
+ ...__privateGet$4(this, _getFetchProps).call(this)
3618
+ });
3619
+ }
3620
+ };
1974
3621
  _setCacheQuery = new WeakSet();
1975
3622
  setCacheQuery_fn = async function(query, meta, records) {
1976
- await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
3623
+ await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
1977
3624
  };
1978
3625
  _getCacheQuery = new WeakSet();
1979
3626
  getCacheQuery_fn = async function(query) {
1980
3627
  const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
1981
- const result = await __privateGet$4(this, _cache).get(key);
3628
+ const result = await __privateGet$4(this, _cache)?.get(key);
1982
3629
  if (!result)
1983
3630
  return null;
1984
- const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
3631
+ const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
3632
+ const { cache: ttl = defaultTTL } = query.getQueryOptions();
1985
3633
  if (ttl < 0)
1986
3634
  return null;
1987
3635
  const hasExpired = result.date.getTime() + ttl < Date.now();
@@ -1991,10 +3639,9 @@ _getSchemaTables$1 = new WeakSet();
1991
3639
  getSchemaTables_fn$1 = async function() {
1992
3640
  if (__privateGet$4(this, _schemaTables$2))
1993
3641
  return __privateGet$4(this, _schemaTables$2);
1994
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1995
3642
  const { schema } = await getBranchDetails({
1996
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1997
- ...fetchProps
3643
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3644
+ ...__privateGet$4(this, _getFetchProps).call(this)
1998
3645
  });
1999
3646
  __privateSet$4(this, _schemaTables$2, schema.tables);
2000
3647
  return schema.tables;
@@ -2006,22 +3653,24 @@ const transformObjectLinks = (object) => {
2006
3653
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
2007
3654
  }, {});
2008
3655
  };
2009
- const initObject = (db, schemaTables, table, object) => {
2010
- const result = {};
3656
+ const initObject = (db, schemaTables, table, object, selectedColumns) => {
3657
+ const data = {};
2011
3658
  const { xata, ...rest } = object ?? {};
2012
- Object.assign(result, rest);
3659
+ Object.assign(data, rest);
2013
3660
  const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
2014
3661
  if (!columns)
2015
3662
  console.error(`Table ${table} not found in schema`);
2016
3663
  for (const column of columns ?? []) {
2017
- const value = result[column.name];
3664
+ if (!isValidColumn(selectedColumns, column))
3665
+ continue;
3666
+ const value = data[column.name];
2018
3667
  switch (column.type) {
2019
3668
  case "datetime": {
2020
- const date = value !== void 0 ? new Date(value) : void 0;
2021
- if (date && isNaN(date.getTime())) {
3669
+ const date = value !== void 0 ? new Date(value) : null;
3670
+ if (date !== null && isNaN(date.getTime())) {
2022
3671
  console.error(`Failed to parse date ${value} for field ${column.name}`);
2023
- } else if (date) {
2024
- result[column.name] = date;
3672
+ } else {
3673
+ data[column.name] = date;
2025
3674
  }
2026
3675
  break;
2027
3676
  }
@@ -2030,41 +3679,65 @@ const initObject = (db, schemaTables, table, object) => {
2030
3679
  if (!linkTable) {
2031
3680
  console.error(`Failed to parse link for field ${column.name}`);
2032
3681
  } else if (isObject(value)) {
2033
- result[column.name] = initObject(db, schemaTables, linkTable, value);
3682
+ const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
3683
+ if (item === column.name) {
3684
+ return [...acc, "*"];
3685
+ }
3686
+ if (item.startsWith(`${column.name}.`)) {
3687
+ const [, ...path] = item.split(".");
3688
+ return [...acc, path.join(".")];
3689
+ }
3690
+ return acc;
3691
+ }, []);
3692
+ data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2034
3693
  } else {
2035
- result[column.name] = null;
3694
+ data[column.name] = null;
2036
3695
  }
2037
3696
  break;
2038
3697
  }
2039
3698
  default:
2040
- result[column.name] = value ?? null;
3699
+ data[column.name] = value ?? null;
2041
3700
  if (column.notNull === true && value === null) {
2042
3701
  console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2043
3702
  }
2044
3703
  break;
2045
3704
  }
2046
3705
  }
2047
- result.read = function(columns2) {
2048
- return db[table].read(result["id"], columns2);
3706
+ const record = { ...data };
3707
+ const serializable = { xata, ...transformObjectLinks(data) };
3708
+ const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
3709
+ record.read = function(columns2) {
3710
+ return db[table].read(record["id"], columns2);
3711
+ };
3712
+ record.update = function(data2, b, c) {
3713
+ const columns2 = isStringArray(b) ? b : ["*"];
3714
+ const ifVersion = parseIfVersion(b, c);
3715
+ return db[table].update(record["id"], data2, columns2, { ifVersion });
3716
+ };
3717
+ record.replace = function(data2, b, c) {
3718
+ const columns2 = isStringArray(b) ? b : ["*"];
3719
+ const ifVersion = parseIfVersion(b, c);
3720
+ return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
2049
3721
  };
2050
- result.update = function(data, columns2) {
2051
- return db[table].update(result["id"], data, columns2);
3722
+ record.delete = function() {
3723
+ return db[table].delete(record["id"]);
2052
3724
  };
2053
- result.delete = function() {
2054
- return db[table].delete(result["id"]);
3725
+ record.xata = Object.freeze(metadata);
3726
+ record.getMetadata = function() {
3727
+ return record.xata;
2055
3728
  };
2056
- result.getMetadata = function() {
2057
- return xata;
3729
+ record.toSerializable = function() {
3730
+ return JSON.parse(JSON.stringify(serializable));
2058
3731
  };
2059
- for (const prop of ["read", "update", "delete", "getMetadata"]) {
2060
- Object.defineProperty(result, prop, { enumerable: false });
3732
+ record.toString = function() {
3733
+ return JSON.stringify(transformObjectLinks(serializable));
3734
+ };
3735
+ for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
3736
+ Object.defineProperty(record, prop, { enumerable: false });
2061
3737
  }
2062
- Object.freeze(result);
2063
- return result;
3738
+ Object.freeze(record);
3739
+ return record;
2064
3740
  };
2065
- function isResponseWithRecords(value) {
2066
- return isObject(value) && Array.isArray(value.records);
2067
- }
2068
3741
  function extractId(value) {
2069
3742
  if (isString(value))
2070
3743
  return value;
@@ -2072,11 +3745,22 @@ function extractId(value) {
2072
3745
  return value.id;
2073
3746
  return void 0;
2074
3747
  }
2075
- function cleanFilter(filter) {
2076
- if (!filter)
2077
- return void 0;
2078
- const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2079
- return values.length > 0 ? filter : void 0;
3748
+ function isValidColumn(columns, column) {
3749
+ if (columns.includes("*"))
3750
+ return true;
3751
+ if (column.type === "link") {
3752
+ const linkColumns = columns.filter((item) => item.startsWith(column.name));
3753
+ return linkColumns.length > 0;
3754
+ }
3755
+ return columns.includes(column.name);
3756
+ }
3757
+ function parseIfVersion(...args) {
3758
+ for (const arg of args) {
3759
+ if (isObject(arg) && isNumber(arg.ifVersion)) {
3760
+ return arg.ifVersion;
3761
+ }
3762
+ }
3763
+ return void 0;
2080
3764
  }
2081
3765
 
2082
3766
  var __accessCheck$3 = (obj, member, msg) => {
@@ -2236,23 +3920,23 @@ class SearchPlugin extends XataPlugin {
2236
3920
  __privateAdd$1(this, _schemaTables, void 0);
2237
3921
  __privateSet$1(this, _schemaTables, schemaTables);
2238
3922
  }
2239
- build({ getFetchProps }) {
3923
+ build(pluginOptions) {
2240
3924
  return {
2241
3925
  all: async (query, options = {}) => {
2242
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
2243
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
3926
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
3927
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
2244
3928
  return records.map((record) => {
2245
3929
  const { table = "orphan" } = record.xata;
2246
- return { table, record: initObject(this.db, schemaTables, table, record) };
3930
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
2247
3931
  });
2248
3932
  },
2249
3933
  byTable: async (query, options = {}) => {
2250
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
2251
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
3934
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
3935
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
2252
3936
  return records.reduce((acc, record) => {
2253
3937
  const { table = "orphan" } = record.xata;
2254
3938
  const items = acc[table] ?? [];
2255
- const item = initObject(this.db, schemaTables, table, record);
3939
+ const item = initObject(this.db, schemaTables, table, record, ["*"]);
2256
3940
  return { ...acc, [table]: [...items, item] };
2257
3941
  }, {});
2258
3942
  }
@@ -2261,108 +3945,40 @@ class SearchPlugin extends XataPlugin {
2261
3945
  }
2262
3946
  _schemaTables = new WeakMap();
2263
3947
  _search = new WeakSet();
2264
- search_fn = async function(query, options, getFetchProps) {
2265
- const fetchProps = await getFetchProps();
2266
- const { tables, fuzziness, highlight, prefix } = options ?? {};
3948
+ search_fn = async function(query, options, pluginOptions) {
3949
+ const { tables, fuzziness, highlight, prefix, page } = options ?? {};
2267
3950
  const { records } = await searchBranch({
2268
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2269
- body: { tables, query, fuzziness, prefix, highlight },
2270
- ...fetchProps
3951
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3952
+ // @ts-ignore https://github.com/xataio/client-ts/issues/313
3953
+ body: { tables, query, fuzziness, prefix, highlight, page },
3954
+ ...pluginOptions
2271
3955
  });
2272
3956
  return records;
2273
3957
  };
2274
3958
  _getSchemaTables = new WeakSet();
2275
- getSchemaTables_fn = async function(getFetchProps) {
3959
+ getSchemaTables_fn = async function(pluginOptions) {
2276
3960
  if (__privateGet$1(this, _schemaTables))
2277
3961
  return __privateGet$1(this, _schemaTables);
2278
- const fetchProps = await getFetchProps();
2279
3962
  const { schema } = await getBranchDetails({
2280
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2281
- ...fetchProps
3963
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3964
+ ...pluginOptions
2282
3965
  });
2283
3966
  __privateSet$1(this, _schemaTables, schema.tables);
2284
3967
  return schema.tables;
2285
3968
  };
2286
3969
 
2287
- const isBranchStrategyBuilder = (strategy) => {
2288
- return typeof strategy === "function";
2289
- };
2290
-
2291
- async function getCurrentBranchName(options) {
2292
- const { branch, envBranch } = getEnvironment();
2293
- if (branch) {
2294
- const details = await getDatabaseBranch(branch, options);
2295
- if (details)
2296
- return branch;
2297
- console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
2298
- }
2299
- const gitBranch = envBranch || await getGitBranch();
2300
- return resolveXataBranch(gitBranch, options);
2301
- }
2302
- async function getCurrentBranchDetails(options) {
2303
- const branch = await getCurrentBranchName(options);
2304
- return getDatabaseBranch(branch, options);
2305
- }
2306
- async function resolveXataBranch(gitBranch, options) {
2307
- const databaseURL = options?.databaseURL || getDatabaseURL();
2308
- const apiKey = options?.apiKey || getAPIKey();
2309
- if (!databaseURL)
2310
- throw new Error(
2311
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2312
- );
2313
- if (!apiKey)
2314
- throw new Error(
2315
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2316
- );
2317
- const [protocol, , host, , dbName] = databaseURL.split("/");
2318
- const [workspace] = host.split(".");
2319
- const { fallbackBranch } = getEnvironment();
2320
- const { branch } = await resolveBranch({
2321
- apiKey,
2322
- apiUrl: databaseURL,
2323
- fetchImpl: getFetchImplementation(options?.fetchImpl),
2324
- workspacesApiUrl: `${protocol}//${host}`,
2325
- pathParams: { dbName, workspace },
2326
- queryParams: { gitBranch, fallbackBranch },
2327
- trace: defaultTrace
2328
- });
2329
- return branch;
2330
- }
2331
- async function getDatabaseBranch(branch, options) {
2332
- const databaseURL = options?.databaseURL || getDatabaseURL();
2333
- const apiKey = options?.apiKey || getAPIKey();
2334
- if (!databaseURL)
2335
- throw new Error(
2336
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2337
- );
2338
- if (!apiKey)
2339
- throw new Error(
2340
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2341
- );
2342
- const [protocol, , host, , database] = databaseURL.split("/");
2343
- const [workspace] = host.split(".");
2344
- const dbBranchName = `${database}:${branch}`;
2345
- try {
2346
- return await getBranchDetails({
2347
- apiKey,
2348
- apiUrl: databaseURL,
2349
- fetchImpl: getFetchImplementation(options?.fetchImpl),
2350
- workspacesApiUrl: `${protocol}//${host}`,
2351
- pathParams: { dbBranchName, workspace },
2352
- trace: defaultTrace
2353
- });
2354
- } catch (err) {
2355
- if (isObject(err) && err.status === 404)
2356
- return null;
2357
- throw err;
2358
- }
2359
- }
2360
- function getDatabaseURL() {
2361
- try {
2362
- const { databaseURL } = getEnvironment();
2363
- return databaseURL;
2364
- } catch (err) {
2365
- return void 0;
3970
+ class TransactionPlugin extends XataPlugin {
3971
+ build(pluginOptions) {
3972
+ return {
3973
+ run: async (operations) => {
3974
+ const response = await branchTransaction({
3975
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3976
+ body: { operations },
3977
+ ...pluginOptions
3978
+ });
3979
+ return response;
3980
+ }
3981
+ };
2366
3982
  }
2367
3983
  }
2368
3984
 
@@ -2389,88 +4005,116 @@ var __privateMethod = (obj, member, method) => {
2389
4005
  return method;
2390
4006
  };
2391
4007
  const buildClient = (plugins) => {
2392
- var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
4008
+ var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
2393
4009
  return _a = class {
2394
4010
  constructor(options = {}, schemaTables) {
2395
4011
  __privateAdd(this, _parseOptions);
2396
4012
  __privateAdd(this, _getFetchProps);
2397
- __privateAdd(this, _evaluateBranch);
2398
- __privateAdd(this, _branch, void 0);
2399
4013
  __privateAdd(this, _options, void 0);
2400
4014
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
2401
4015
  __privateSet(this, _options, safeOptions);
2402
4016
  const pluginOptions = {
2403
- getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
4017
+ ...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
2404
4018
  cache: safeOptions.cache,
2405
- trace: safeOptions.trace
4019
+ host: safeOptions.host
2406
4020
  };
2407
4021
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
2408
4022
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
4023
+ const transactions = new TransactionPlugin().build(pluginOptions);
2409
4024
  this.db = db;
2410
4025
  this.search = search;
4026
+ this.transactions = transactions;
2411
4027
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
2412
4028
  if (namespace === void 0)
2413
4029
  continue;
2414
- const result = namespace.build(pluginOptions);
2415
- if (result instanceof Promise) {
2416
- void result.then((namespace2) => {
2417
- this[key] = namespace2;
2418
- });
2419
- } else {
2420
- this[key] = result;
2421
- }
4030
+ this[key] = namespace.build(pluginOptions);
2422
4031
  }
2423
4032
  }
2424
4033
  async getConfig() {
2425
4034
  const databaseURL = __privateGet(this, _options).databaseURL;
2426
- const branch = await __privateGet(this, _options).branch();
4035
+ const branch = __privateGet(this, _options).branch;
2427
4036
  return { databaseURL, branch };
2428
4037
  }
2429
- }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
4038
+ }, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
4039
+ const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
4040
+ const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
4041
+ if (isBrowser && !enableBrowser) {
4042
+ throw new Error(
4043
+ "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."
4044
+ );
4045
+ }
2430
4046
  const fetch = getFetchImplementation(options?.fetch);
2431
4047
  const databaseURL = options?.databaseURL || getDatabaseURL();
2432
4048
  const apiKey = options?.apiKey || getAPIKey();
2433
4049
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
2434
4050
  const trace = options?.trace ?? defaultTrace;
2435
- const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
4051
+ const clientName = options?.clientName;
4052
+ const host = options?.host ?? "production";
4053
+ const xataAgentExtra = options?.xataAgentExtra;
2436
4054
  if (!apiKey) {
2437
4055
  throw new Error("Option apiKey is required");
2438
4056
  }
2439
4057
  if (!databaseURL) {
2440
4058
  throw new Error("Option databaseURL is required");
2441
4059
  }
2442
- return { fetch, databaseURL, apiKey, branch, cache, trace };
2443
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
2444
- const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2445
- if (!branchValue)
2446
- throw new Error("Unable to resolve branch value");
4060
+ const envBranch = getBranch();
4061
+ const previewBranch = getPreviewBranch();
4062
+ const branch = options?.branch || previewBranch || envBranch || "main";
4063
+ if (!!previewBranch && branch !== previewBranch) {
4064
+ console.warn(
4065
+ `Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
4066
+ );
4067
+ } else if (!!envBranch && branch !== envBranch) {
4068
+ console.warn(
4069
+ `Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
4070
+ );
4071
+ } else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
4072
+ console.warn(
4073
+ `Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
4074
+ );
4075
+ } else if (!previewBranch && !envBranch && options?.branch === void 0) {
4076
+ console.warn(
4077
+ `No branch was passed to the client constructor. Using default branch ${branch}. You can set the branch with the environment variable XATA_BRANCH or by passing the branch option to the client constructor.`
4078
+ );
4079
+ }
4080
+ return {
4081
+ fetch,
4082
+ databaseURL,
4083
+ apiKey,
4084
+ branch,
4085
+ cache,
4086
+ trace,
4087
+ host,
4088
+ clientID: generateUUID(),
4089
+ enableBrowser,
4090
+ clientName,
4091
+ xataAgentExtra
4092
+ };
4093
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
4094
+ fetch,
4095
+ apiKey,
4096
+ databaseURL,
4097
+ branch,
4098
+ trace,
4099
+ clientID,
4100
+ clientName,
4101
+ xataAgentExtra
4102
+ }) {
2447
4103
  return {
2448
- fetchImpl: fetch,
4104
+ fetch,
2449
4105
  apiKey,
2450
4106
  apiUrl: "",
4107
+ // Instead of using workspace and dbBranch, we inject a probably CNAME'd URL
2451
4108
  workspacesApiUrl: (path, params) => {
2452
4109
  const hasBranch = params.dbBranchName ?? params.branch;
2453
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
4110
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
2454
4111
  return databaseURL + newPath;
2455
4112
  },
2456
- trace
2457
- };
2458
- }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2459
- if (__privateGet(this, _branch))
2460
- return __privateGet(this, _branch);
2461
- if (param === void 0)
2462
- return void 0;
2463
- const strategies = Array.isArray(param) ? [...param] : [param];
2464
- const evaluateBranch = async (strategy) => {
2465
- return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
4113
+ trace,
4114
+ clientID,
4115
+ clientName,
4116
+ xataAgentExtra
2466
4117
  };
2467
- for await (const strategy of strategies) {
2468
- const branch = await evaluateBranch(strategy);
2469
- if (branch) {
2470
- __privateSet(this, _branch, branch);
2471
- return branch;
2472
- }
2473
- }
2474
4118
  }, _a;
2475
4119
  };
2476
4120
  class BaseClient extends buildClient() {
@@ -2544,7 +4188,7 @@ const deserialize = (json) => {
2544
4188
  };
2545
4189
 
2546
4190
  function buildWorkerRunner(config) {
2547
- return function xataWorker(name, _worker) {
4191
+ return function xataWorker(name, worker) {
2548
4192
  return async (...args) => {
2549
4193
  const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
2550
4194
  const result = await fetch(url, {
@@ -2565,5 +4209,5 @@ class XataError extends Error {
2565
4209
  }
2566
4210
  }
2567
4211
 
2568
- export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, applyBranchSchemaEdit, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequests, listMigrationRequestsCommits, lt, lte, mergeMigrationRequest, notExists, operationsByTag, pattern, previewBranchSchemaEdit, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
4212
+ 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, askTable, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, ge, getAPIKey, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, 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, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
2569
4213
  //# sourceMappingURL=index.mjs.map