@xata.io/client 0.0.0-alpha.vf7fccd9 → 0.0.0-alpha.vf81a0c6

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