@xata.io/client 0.0.0-alpha.vf5a6674 → 0.0.0-alpha.vf5fbc45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
- const defaultTrace = async (_name, fn, _options) => {
1
+ const defaultTrace = async (name, fn, _options) => {
2
2
  return await fn({
3
+ name,
3
4
  setAttributes: () => {
4
5
  return;
5
6
  }
@@ -26,8 +27,11 @@ function notEmpty(value) {
26
27
  function compact(arr) {
27
28
  return arr.filter(notEmpty);
28
29
  }
30
+ function compactObject(obj) {
31
+ return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
32
+ }
29
33
  function isObject(value) {
30
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
34
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof Blob);
31
35
  }
32
36
  function isDefined(value) {
33
37
  return value !== null && value !== void 0;
@@ -38,6 +42,21 @@ function isString(value) {
38
42
  function isStringArray(value) {
39
43
  return isDefined(value) && Array.isArray(value) && value.every(isString);
40
44
  }
45
+ function isNumber(value) {
46
+ return isDefined(value) && typeof value === "number";
47
+ }
48
+ function parseNumber(value) {
49
+ if (isNumber(value)) {
50
+ return value;
51
+ }
52
+ if (isString(value)) {
53
+ const parsed = Number(value);
54
+ if (!Number.isNaN(parsed)) {
55
+ return parsed;
56
+ }
57
+ }
58
+ return void 0;
59
+ }
41
60
  function toBase64(value) {
42
61
  try {
43
62
  return btoa(value);
@@ -46,16 +65,60 @@ function toBase64(value) {
46
65
  return buf.from(value).toString("base64");
47
66
  }
48
67
  }
68
+ function deepMerge(a, b) {
69
+ const result = { ...a };
70
+ for (const [key, value] of Object.entries(b)) {
71
+ if (isObject(value) && isObject(result[key])) {
72
+ result[key] = deepMerge(result[key], value);
73
+ } else {
74
+ result[key] = value;
75
+ }
76
+ }
77
+ return result;
78
+ }
79
+ function chunk(array, chunkSize) {
80
+ const result = [];
81
+ for (let i = 0; i < array.length; i += chunkSize) {
82
+ result.push(array.slice(i, i + chunkSize));
83
+ }
84
+ return result;
85
+ }
86
+ async function timeout(ms) {
87
+ return new Promise((resolve) => setTimeout(resolve, ms));
88
+ }
89
+ function timeoutWithCancel(ms) {
90
+ let timeoutId;
91
+ const promise = new Promise((resolve) => {
92
+ timeoutId = setTimeout(() => {
93
+ resolve();
94
+ }, ms);
95
+ });
96
+ return {
97
+ cancel: () => clearTimeout(timeoutId),
98
+ promise
99
+ };
100
+ }
101
+ function promiseMap(inputValues, mapper) {
102
+ const reducer = (acc$, inputValue) => acc$.then(
103
+ (acc) => mapper(inputValue).then((result) => {
104
+ acc.push(result);
105
+ return acc;
106
+ })
107
+ );
108
+ return inputValues.reduce(reducer, Promise.resolve([]));
109
+ }
49
110
 
50
111
  function getEnvironment() {
51
112
  try {
52
- if (isObject(process) && isObject(process.env)) {
113
+ if (isDefined(process) && isDefined(process.env)) {
53
114
  return {
54
115
  apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
55
116
  databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
56
117
  branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
57
- envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
58
- fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
118
+ deployPreview: process.env.XATA_PREVIEW,
119
+ deployPreviewBranch: process.env.XATA_PREVIEW_BRANCH,
120
+ vercelGitCommitRef: process.env.VERCEL_GIT_COMMIT_REF,
121
+ vercelGitRepoOwner: process.env.VERCEL_GIT_REPO_OWNER
59
122
  };
60
123
  }
61
124
  } catch (err) {
@@ -66,8 +129,10 @@ function getEnvironment() {
66
129
  apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
67
130
  databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
68
131
  branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
69
- envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
70
- fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
132
+ deployPreview: Deno.env.get("XATA_PREVIEW"),
133
+ deployPreviewBranch: Deno.env.get("XATA_PREVIEW_BRANCH"),
134
+ vercelGitCommitRef: Deno.env.get("VERCEL_GIT_COMMIT_REF"),
135
+ vercelGitRepoOwner: Deno.env.get("VERCEL_GIT_REPO_OWNER")
71
136
  };
72
137
  }
73
138
  } catch (err) {
@@ -76,10 +141,31 @@ function getEnvironment() {
76
141
  apiKey: getGlobalApiKey(),
77
142
  databaseURL: getGlobalDatabaseURL(),
78
143
  branch: getGlobalBranch(),
79
- envBranch: void 0,
80
- fallbackBranch: getGlobalFallbackBranch()
144
+ deployPreview: void 0,
145
+ deployPreviewBranch: void 0,
146
+ vercelGitCommitRef: void 0,
147
+ vercelGitRepoOwner: void 0
81
148
  };
82
149
  }
150
+ function getEnableBrowserVariable() {
151
+ try {
152
+ if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
153
+ return process.env.XATA_ENABLE_BROWSER === "true";
154
+ }
155
+ } catch (err) {
156
+ }
157
+ try {
158
+ if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
159
+ return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
160
+ }
161
+ } catch (err) {
162
+ }
163
+ try {
164
+ return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
165
+ } catch (err) {
166
+ return void 0;
167
+ }
168
+ }
83
169
  function getGlobalApiKey() {
84
170
  try {
85
171
  return XATA_API_KEY;
@@ -101,44 +187,83 @@ function getGlobalBranch() {
101
187
  return void 0;
102
188
  }
103
189
  }
104
- function getGlobalFallbackBranch() {
190
+ function getDatabaseURL() {
105
191
  try {
106
- return XATA_FALLBACK_BRANCH;
192
+ const { databaseURL } = getEnvironment();
193
+ return databaseURL;
107
194
  } catch (err) {
108
195
  return void 0;
109
196
  }
110
197
  }
111
- async function getGitBranch() {
112
- const cmd = ["git", "branch", "--show-current"];
113
- const fullCmd = cmd.join(" ");
114
- const nodeModule = ["child", "process"].join("_");
115
- const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
198
+ function getAPIKey() {
116
199
  try {
117
- if (typeof require === "function") {
118
- return require(nodeModule).execSync(fullCmd, execOptions).trim();
119
- }
120
- const { execSync } = await import(nodeModule);
121
- return execSync(fullCmd, execOptions).toString().trim();
200
+ const { apiKey } = getEnvironment();
201
+ return apiKey;
122
202
  } catch (err) {
203
+ return void 0;
123
204
  }
205
+ }
206
+ function getBranch() {
124
207
  try {
125
- if (isObject(Deno)) {
126
- const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
127
- return new TextDecoder().decode(await process2.output()).trim();
128
- }
208
+ const { branch } = getEnvironment();
209
+ return branch;
129
210
  } catch (err) {
211
+ return void 0;
130
212
  }
131
213
  }
132
-
133
- function getAPIKey() {
214
+ function buildPreviewBranchName({ org, branch }) {
215
+ return `preview-${org}-${branch}`;
216
+ }
217
+ function getPreviewBranch() {
134
218
  try {
135
- const { apiKey } = getEnvironment();
136
- return apiKey;
219
+ const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = getEnvironment();
220
+ if (deployPreviewBranch)
221
+ return deployPreviewBranch;
222
+ switch (deployPreview) {
223
+ case "vercel": {
224
+ if (!vercelGitCommitRef || !vercelGitRepoOwner) {
225
+ console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
226
+ return void 0;
227
+ }
228
+ return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
229
+ }
230
+ }
231
+ return void 0;
137
232
  } catch (err) {
138
233
  return void 0;
139
234
  }
140
235
  }
141
236
 
237
+ var __defProp$8 = Object.defineProperty;
238
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
239
+ var __publicField$8 = (obj, key, value) => {
240
+ __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
241
+ return value;
242
+ };
243
+ var __accessCheck$8 = (obj, member, msg) => {
244
+ if (!member.has(obj))
245
+ throw TypeError("Cannot " + msg);
246
+ };
247
+ var __privateGet$8 = (obj, member, getter) => {
248
+ __accessCheck$8(obj, member, "read from private field");
249
+ return getter ? getter.call(obj) : member.get(obj);
250
+ };
251
+ var __privateAdd$8 = (obj, member, value) => {
252
+ if (member.has(obj))
253
+ throw TypeError("Cannot add the same private member more than once");
254
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
255
+ };
256
+ var __privateSet$8 = (obj, member, value, setter) => {
257
+ __accessCheck$8(obj, member, "write to private field");
258
+ setter ? setter.call(obj, value) : member.set(obj, value);
259
+ return value;
260
+ };
261
+ var __privateMethod$4 = (obj, member, method) => {
262
+ __accessCheck$8(obj, member, "access private method");
263
+ return method;
264
+ };
265
+ var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
266
+ const REQUEST_TIMEOUT = 3e4;
142
267
  function getFetchImplementation(userFetch) {
143
268
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
144
269
  const fetchImpl = userFetch ?? globalFetch;
@@ -149,19 +274,281 @@ function getFetchImplementation(userFetch) {
149
274
  }
150
275
  return fetchImpl;
151
276
  }
277
+ class ApiRequestPool {
278
+ constructor(concurrency = 10) {
279
+ __privateAdd$8(this, _enqueue);
280
+ __privateAdd$8(this, _fetch, void 0);
281
+ __privateAdd$8(this, _queue, void 0);
282
+ __privateAdd$8(this, _concurrency, void 0);
283
+ __publicField$8(this, "running");
284
+ __publicField$8(this, "started");
285
+ __privateSet$8(this, _queue, []);
286
+ __privateSet$8(this, _concurrency, concurrency);
287
+ this.running = 0;
288
+ this.started = 0;
289
+ }
290
+ setFetch(fetch2) {
291
+ __privateSet$8(this, _fetch, fetch2);
292
+ }
293
+ getFetch() {
294
+ if (!__privateGet$8(this, _fetch)) {
295
+ throw new Error("Fetch not set");
296
+ }
297
+ return __privateGet$8(this, _fetch);
298
+ }
299
+ request(url, options) {
300
+ const start = /* @__PURE__ */ new Date();
301
+ const fetchImpl = this.getFetch();
302
+ const runRequest = async (stalled = false) => {
303
+ const { promise, cancel } = timeoutWithCancel(REQUEST_TIMEOUT);
304
+ const response = await Promise.race([fetchImpl(url, options), promise.then(() => null)]).finally(cancel);
305
+ if (!response) {
306
+ throw new Error("Request timed out");
307
+ }
308
+ if (response.status === 429) {
309
+ const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
310
+ await timeout(rateLimitReset * 1e3);
311
+ return await runRequest(true);
312
+ }
313
+ if (stalled) {
314
+ const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
315
+ console.warn(`A request to Xata hit branch rate limits, was retried and stalled for ${stalledTime}ms`);
316
+ }
317
+ return response;
318
+ };
319
+ return __privateMethod$4(this, _enqueue, enqueue_fn).call(this, async () => {
320
+ return await runRequest();
321
+ });
322
+ }
323
+ }
324
+ _fetch = new WeakMap();
325
+ _queue = new WeakMap();
326
+ _concurrency = new WeakMap();
327
+ _enqueue = new WeakSet();
328
+ enqueue_fn = function(task) {
329
+ const promise = new Promise((resolve) => __privateGet$8(this, _queue).push(resolve)).finally(() => {
330
+ this.started--;
331
+ this.running++;
332
+ }).then(() => task()).finally(() => {
333
+ this.running--;
334
+ const next = __privateGet$8(this, _queue).shift();
335
+ if (next !== void 0) {
336
+ this.started++;
337
+ next();
338
+ }
339
+ });
340
+ if (this.running + this.started < __privateGet$8(this, _concurrency)) {
341
+ const next = __privateGet$8(this, _queue).shift();
342
+ if (next !== void 0) {
343
+ this.started++;
344
+ next();
345
+ }
346
+ }
347
+ return promise;
348
+ };
349
+
350
+ function generateUUID() {
351
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
352
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
353
+ return v.toString(16);
354
+ });
355
+ }
356
+
357
+ async function getBytes(stream, onChunk) {
358
+ const reader = stream.getReader();
359
+ let result;
360
+ while (!(result = await reader.read()).done) {
361
+ onChunk(result.value);
362
+ }
363
+ }
364
+ function getLines(onLine) {
365
+ let buffer;
366
+ let position;
367
+ let fieldLength;
368
+ let discardTrailingNewline = false;
369
+ return function onChunk(arr) {
370
+ if (buffer === void 0) {
371
+ buffer = arr;
372
+ position = 0;
373
+ fieldLength = -1;
374
+ } else {
375
+ buffer = concat(buffer, arr);
376
+ }
377
+ const bufLength = buffer.length;
378
+ let lineStart = 0;
379
+ while (position < bufLength) {
380
+ if (discardTrailingNewline) {
381
+ if (buffer[position] === 10 /* NewLine */) {
382
+ lineStart = ++position;
383
+ }
384
+ discardTrailingNewline = false;
385
+ }
386
+ let lineEnd = -1;
387
+ for (; position < bufLength && lineEnd === -1; ++position) {
388
+ switch (buffer[position]) {
389
+ case 58 /* Colon */:
390
+ if (fieldLength === -1) {
391
+ fieldLength = position - lineStart;
392
+ }
393
+ break;
394
+ case 13 /* CarriageReturn */:
395
+ discardTrailingNewline = true;
396
+ case 10 /* NewLine */:
397
+ lineEnd = position;
398
+ break;
399
+ }
400
+ }
401
+ if (lineEnd === -1) {
402
+ break;
403
+ }
404
+ onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
405
+ lineStart = position;
406
+ fieldLength = -1;
407
+ }
408
+ if (lineStart === bufLength) {
409
+ buffer = void 0;
410
+ } else if (lineStart !== 0) {
411
+ buffer = buffer.subarray(lineStart);
412
+ position -= lineStart;
413
+ }
414
+ };
415
+ }
416
+ function getMessages(onId, onRetry, onMessage) {
417
+ let message = newMessage();
418
+ const decoder = new TextDecoder();
419
+ return function onLine(line, fieldLength) {
420
+ if (line.length === 0) {
421
+ onMessage?.(message);
422
+ message = newMessage();
423
+ } else if (fieldLength > 0) {
424
+ const field = decoder.decode(line.subarray(0, fieldLength));
425
+ const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
426
+ const value = decoder.decode(line.subarray(valueOffset));
427
+ switch (field) {
428
+ case "data":
429
+ message.data = message.data ? message.data + "\n" + value : value;
430
+ break;
431
+ case "event":
432
+ message.event = value;
433
+ break;
434
+ case "id":
435
+ onId(message.id = value);
436
+ break;
437
+ case "retry":
438
+ const retry = parseInt(value, 10);
439
+ if (!isNaN(retry)) {
440
+ onRetry(message.retry = retry);
441
+ }
442
+ break;
443
+ }
444
+ }
445
+ };
446
+ }
447
+ function concat(a, b) {
448
+ const res = new Uint8Array(a.length + b.length);
449
+ res.set(a);
450
+ res.set(b, a.length);
451
+ return res;
452
+ }
453
+ function newMessage() {
454
+ return {
455
+ data: "",
456
+ event: "",
457
+ id: "",
458
+ retry: void 0
459
+ };
460
+ }
461
+ const EventStreamContentType = "text/event-stream";
462
+ const LastEventId = "last-event-id";
463
+ function fetchEventSource(input, {
464
+ signal: inputSignal,
465
+ headers: inputHeaders,
466
+ onopen: inputOnOpen,
467
+ onmessage,
468
+ onclose,
469
+ onerror,
470
+ fetch: inputFetch,
471
+ ...rest
472
+ }) {
473
+ return new Promise((resolve, reject) => {
474
+ const headers = { ...inputHeaders };
475
+ if (!headers.accept) {
476
+ headers.accept = EventStreamContentType;
477
+ }
478
+ let curRequestController;
479
+ function dispose() {
480
+ curRequestController.abort();
481
+ }
482
+ inputSignal?.addEventListener("abort", () => {
483
+ dispose();
484
+ resolve();
485
+ });
486
+ const fetchImpl = inputFetch ?? fetch;
487
+ const onopen = inputOnOpen ?? defaultOnOpen;
488
+ async function create() {
489
+ curRequestController = new AbortController();
490
+ try {
491
+ const response = await fetchImpl(input, {
492
+ ...rest,
493
+ headers,
494
+ signal: curRequestController.signal
495
+ });
496
+ await onopen(response);
497
+ await getBytes(
498
+ response.body,
499
+ getLines(
500
+ getMessages(
501
+ (id) => {
502
+ if (id) {
503
+ headers[LastEventId] = id;
504
+ } else {
505
+ delete headers[LastEventId];
506
+ }
507
+ },
508
+ (_retry) => {
509
+ },
510
+ onmessage
511
+ )
512
+ )
513
+ );
514
+ onclose?.();
515
+ dispose();
516
+ resolve();
517
+ } catch (err) {
518
+ }
519
+ }
520
+ create();
521
+ });
522
+ }
523
+ function defaultOnOpen(response) {
524
+ const contentType = response.headers?.get("content-type");
525
+ if (!contentType?.startsWith(EventStreamContentType)) {
526
+ throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
527
+ }
528
+ }
152
529
 
153
- const VERSION = "0.0.0-alpha.vf5a6674";
530
+ const VERSION = "0.26.1";
154
531
 
532
+ var __defProp$7 = Object.defineProperty;
533
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
534
+ var __publicField$7 = (obj, key, value) => {
535
+ __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
536
+ return value;
537
+ };
155
538
  class ErrorWithCause extends Error {
156
539
  constructor(message, options) {
157
540
  super(message, options);
541
+ __publicField$7(this, "cause");
158
542
  }
159
543
  }
160
544
  class FetcherError extends ErrorWithCause {
161
545
  constructor(status, data, requestId) {
162
546
  super(getMessage(data));
547
+ __publicField$7(this, "status");
548
+ __publicField$7(this, "requestId");
549
+ __publicField$7(this, "errors");
163
550
  this.status = status;
164
- this.errors = isBulkError(data) ? data.errors : void 0;
551
+ this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
165
552
  this.requestId = requestId;
166
553
  if (data instanceof Error) {
167
554
  this.stack = data.stack;
@@ -193,6 +580,7 @@ function getMessage(data) {
193
580
  }
194
581
  }
195
582
 
583
+ const pool = new ApiRequestPool();
196
584
  const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
197
585
  const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
198
586
  if (value === void 0 || value === null)
@@ -207,64 +595,92 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
207
595
  return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
208
596
  };
209
597
  function buildBaseUrl({
598
+ endpoint,
210
599
  path,
211
600
  workspacesApiUrl,
212
601
  apiUrl,
213
- pathParams
602
+ pathParams = {}
214
603
  }) {
215
- if (pathParams?.workspace === void 0 || !path.startsWith("/db"))
216
- return `${apiUrl}${path}`;
217
- const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
218
- return url.replace("{workspaceId}", String(pathParams.workspace));
604
+ if (endpoint === "dataPlane") {
605
+ const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
606
+ const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
607
+ return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
608
+ }
609
+ return `${apiUrl}${path}`;
219
610
  }
220
611
  function hostHeader(url) {
221
612
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
222
613
  const { groups } = pattern.exec(url) ?? {};
223
614
  return groups?.host ? { Host: groups.host } : {};
224
615
  }
616
+ async function parseBody(body, headers) {
617
+ if (!isDefined(body))
618
+ return void 0;
619
+ if (body instanceof Blob || typeof body.text === "function") {
620
+ return body;
621
+ }
622
+ const { "Content-Type": contentType } = headers ?? {};
623
+ if (String(contentType).toLowerCase() === "application/json" && isObject(body)) {
624
+ return JSON.stringify(body);
625
+ }
626
+ return body;
627
+ }
628
+ const defaultClientID = generateUUID();
225
629
  async function fetch$1({
226
630
  url: path,
227
631
  method,
228
632
  body,
229
- headers,
633
+ headers: customHeaders,
230
634
  pathParams,
231
635
  queryParams,
232
- fetchImpl,
636
+ fetch: fetch2,
233
637
  apiKey,
638
+ endpoint,
234
639
  apiUrl,
235
640
  workspacesApiUrl,
236
641
  trace,
237
642
  signal,
238
643
  clientID,
239
- sessionID
644
+ sessionID,
645
+ clientName,
646
+ xataAgentExtra,
647
+ fetchOptions = {},
648
+ rawResponse = false
240
649
  }) {
241
- return trace(
650
+ pool.setFetch(fetch2);
651
+ return await trace(
242
652
  `${method.toUpperCase()} ${path}`,
243
653
  async ({ setAttributes }) => {
244
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
654
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
245
655
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
246
656
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
247
657
  setAttributes({
248
658
  [TraceAttributes.HTTP_URL]: url,
249
659
  [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
250
660
  });
251
- const response = await fetchImpl(url, {
661
+ const xataAgent = compact([
662
+ ["client", "TS_SDK"],
663
+ ["version", VERSION],
664
+ isDefined(clientName) ? ["service", clientName] : void 0,
665
+ ...Object.entries(xataAgentExtra ?? {})
666
+ ]).map(([key, value]) => `${key}=${value}`).join("; ");
667
+ const headers = compactObject({
668
+ "Accept-Encoding": "identity",
669
+ "Content-Type": "application/json",
670
+ "X-Xata-Client-ID": clientID ?? defaultClientID,
671
+ "X-Xata-Session-ID": sessionID ?? generateUUID(),
672
+ "X-Xata-Agent": xataAgent,
673
+ ...customHeaders,
674
+ ...hostHeader(fullUrl),
675
+ Authorization: `Bearer ${apiKey}`
676
+ });
677
+ const response = await pool.request(url, {
678
+ ...fetchOptions,
252
679
  method: method.toUpperCase(),
253
- body: body ? JSON.stringify(body) : void 0,
254
- headers: {
255
- "Content-Type": "application/json",
256
- "User-Agent": `Xata client-ts/${VERSION}`,
257
- "X-Xata-Client-ID": clientID ?? "",
258
- "X-Xata-Session-ID": sessionID ?? "",
259
- ...headers,
260
- ...hostHeader(fullUrl),
261
- Authorization: `Bearer ${apiKey}`
262
- },
680
+ body: await parseBody(body, headers),
681
+ headers,
263
682
  signal
264
683
  });
265
- if (response.status === 204) {
266
- return {};
267
- }
268
684
  const { host, protocol } = parseUrl(response.url);
269
685
  const requestId = response.headers?.get("x-request-id") ?? void 0;
270
686
  setAttributes({
@@ -274,8 +690,17 @@ async function fetch$1({
274
690
  [TraceAttributes.HTTP_HOST]: host,
275
691
  [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
276
692
  });
693
+ const message = response.headers?.get("x-xata-message");
694
+ if (message)
695
+ console.warn(message);
696
+ if (response.status === 204) {
697
+ return {};
698
+ }
699
+ if (response.status === 429) {
700
+ throw new FetcherError(response.status, "Rate limit exceeded", requestId);
701
+ }
277
702
  try {
278
- const jsonResponse = await response.json();
703
+ const jsonResponse = rawResponse ? await response.blob() : await response.json();
279
704
  if (response.ok) {
280
705
  return jsonResponse;
281
706
  }
@@ -287,6 +712,59 @@ async function fetch$1({
287
712
  { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
288
713
  );
289
714
  }
715
+ function fetchSSERequest({
716
+ url: path,
717
+ method,
718
+ body,
719
+ headers: customHeaders,
720
+ pathParams,
721
+ queryParams,
722
+ fetch: fetch2,
723
+ apiKey,
724
+ endpoint,
725
+ apiUrl,
726
+ workspacesApiUrl,
727
+ onMessage,
728
+ onError,
729
+ onClose,
730
+ signal,
731
+ clientID,
732
+ sessionID,
733
+ clientName,
734
+ xataAgentExtra
735
+ }) {
736
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
737
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
738
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
739
+ void fetchEventSource(url, {
740
+ method,
741
+ body: JSON.stringify(body),
742
+ fetch: fetch2,
743
+ signal,
744
+ headers: {
745
+ "X-Xata-Client-ID": clientID ?? defaultClientID,
746
+ "X-Xata-Session-ID": sessionID ?? generateUUID(),
747
+ "X-Xata-Agent": compact([
748
+ ["client", "TS_SDK"],
749
+ ["version", VERSION],
750
+ isDefined(clientName) ? ["service", clientName] : void 0,
751
+ ...Object.entries(xataAgentExtra ?? {})
752
+ ]).map(([key, value]) => `${key}=${value}`).join("; "),
753
+ ...customHeaders,
754
+ Authorization: `Bearer ${apiKey}`,
755
+ "Content-Type": "application/json"
756
+ },
757
+ onmessage(ev) {
758
+ onMessage?.(JSON.parse(ev.data));
759
+ },
760
+ onerror(ev) {
761
+ onError?.(JSON.parse(ev.data));
762
+ },
763
+ onclose() {
764
+ onClose?.();
765
+ }
766
+ });
767
+ }
290
768
  function parseUrl(url) {
291
769
  try {
292
770
  const { host, protocol } = new URL(url);
@@ -296,329 +774,430 @@ function parseUrl(url) {
296
774
  }
297
775
  }
298
776
 
299
- const getUser = (variables, signal) => fetch$1({ url: "/user", method: "get", ...variables, signal });
300
- const updateUser = (variables, signal) => fetch$1({
301
- url: "/user",
302
- method: "put",
303
- ...variables,
304
- signal
305
- });
306
- const deleteUser = (variables, signal) => fetch$1({ url: "/user", method: "delete", ...variables, signal });
307
- const getUserAPIKeys = (variables, signal) => fetch$1({
308
- url: "/user/keys",
777
+ const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
778
+
779
+ const getBranchList = (variables, signal) => dataPlaneFetch({
780
+ url: "/dbs/{dbName}",
309
781
  method: "get",
310
782
  ...variables,
311
783
  signal
312
784
  });
313
- const createUserAPIKey = (variables, signal) => fetch$1({
314
- url: "/user/keys/{keyName}",
315
- method: "post",
785
+ const getBranchDetails = (variables, signal) => dataPlaneFetch({
786
+ url: "/db/{dbBranchName}",
787
+ method: "get",
316
788
  ...variables,
317
789
  signal
318
790
  });
319
- const deleteUserAPIKey = (variables, signal) => fetch$1({
320
- url: "/user/keys/{keyName}",
791
+ const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
792
+ const deleteBranch = (variables, signal) => dataPlaneFetch({
793
+ url: "/db/{dbBranchName}",
321
794
  method: "delete",
322
795
  ...variables,
323
796
  signal
324
797
  });
325
- const getWorkspacesList = (variables, signal) => fetch$1({
326
- url: "/workspaces",
327
- method: "get",
328
- ...variables,
329
- signal
330
- });
331
- const createWorkspace = (variables, signal) => fetch$1({
332
- url: "/workspaces",
798
+ const copyBranch = (variables, signal) => dataPlaneFetch({
799
+ url: "/db/{dbBranchName}/copy",
333
800
  method: "post",
334
801
  ...variables,
335
802
  signal
336
803
  });
337
- const getWorkspace = (variables, signal) => fetch$1({
338
- url: "/workspaces/{workspaceId}",
339
- method: "get",
340
- ...variables,
341
- signal
342
- });
343
- const updateWorkspace = (variables, signal) => fetch$1({
344
- url: "/workspaces/{workspaceId}",
804
+ const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
805
+ url: "/db/{dbBranchName}/metadata",
345
806
  method: "put",
346
807
  ...variables,
347
808
  signal
348
809
  });
349
- const deleteWorkspace = (variables, signal) => fetch$1({
350
- url: "/workspaces/{workspaceId}",
351
- method: "delete",
810
+ const getBranchMetadata = (variables, signal) => dataPlaneFetch({
811
+ url: "/db/{dbBranchName}/metadata",
812
+ method: "get",
352
813
  ...variables,
353
814
  signal
354
815
  });
355
- const getWorkspaceMembersList = (variables, signal) => fetch$1({
356
- url: "/workspaces/{workspaceId}/members",
816
+ const getBranchStats = (variables, signal) => dataPlaneFetch({
817
+ url: "/db/{dbBranchName}/stats",
357
818
  method: "get",
358
819
  ...variables,
359
820
  signal
360
821
  });
361
- const updateWorkspaceMemberRole = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
362
- const removeWorkspaceMember = (variables, signal) => fetch$1({
363
- url: "/workspaces/{workspaceId}/members/{userId}",
364
- method: "delete",
822
+ const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
823
+ const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
824
+ const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
825
+ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
826
+ const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
827
+ const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
828
+ const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
829
+ const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
830
+ const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
831
+ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
832
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
833
+ method: "get",
365
834
  ...variables,
366
835
  signal
367
836
  });
368
- const inviteWorkspaceMember = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
369
- const updateWorkspaceMemberInvite = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
370
- const cancelWorkspaceMemberInvite = (variables, signal) => fetch$1({
371
- url: "/workspaces/{workspaceId}/invites/{inviteId}",
372
- method: "delete",
837
+ const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
838
+ const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
839
+ const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
840
+ const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
841
+ const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
842
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
843
+ method: "post",
373
844
  ...variables,
374
845
  signal
375
846
  });
376
- const acceptWorkspaceMemberInvite = (variables, signal) => fetch$1({
377
- url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
378
- method: "post",
847
+ const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
848
+ const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
849
+ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
850
+ const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
851
+ const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
852
+ const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
853
+ const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
854
+ const createTable = (variables, signal) => dataPlaneFetch({
855
+ url: "/db/{dbBranchName}/tables/{tableName}",
856
+ method: "put",
379
857
  ...variables,
380
858
  signal
381
859
  });
382
- const resendWorkspaceMemberInvite = (variables, signal) => fetch$1({
383
- url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
384
- method: "post",
860
+ const deleteTable = (variables, signal) => dataPlaneFetch({
861
+ url: "/db/{dbBranchName}/tables/{tableName}",
862
+ method: "delete",
385
863
  ...variables,
386
864
  signal
387
865
  });
388
- const getDatabaseList = (variables, signal) => fetch$1({
389
- url: "/dbs",
866
+ const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
867
+ const getTableSchema = (variables, signal) => dataPlaneFetch({
868
+ url: "/db/{dbBranchName}/tables/{tableName}/schema",
390
869
  method: "get",
391
870
  ...variables,
392
871
  signal
393
872
  });
394
- const getBranchList = (variables, signal) => fetch$1({
395
- url: "/dbs/{dbName}",
873
+ const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
874
+ const getTableColumns = (variables, signal) => dataPlaneFetch({
875
+ url: "/db/{dbBranchName}/tables/{tableName}/columns",
396
876
  method: "get",
397
877
  ...variables,
398
878
  signal
399
879
  });
400
- const createDatabase = (variables, signal) => fetch$1({
401
- url: "/dbs/{dbName}",
402
- method: "put",
880
+ const addTableColumn = (variables, signal) => dataPlaneFetch(
881
+ { url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
882
+ );
883
+ const getColumn = (variables, signal) => dataPlaneFetch({
884
+ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
885
+ method: "get",
403
886
  ...variables,
404
887
  signal
405
888
  });
406
- const deleteDatabase = (variables, signal) => fetch$1({
407
- url: "/dbs/{dbName}",
889
+ const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
890
+ const deleteColumn = (variables, signal) => dataPlaneFetch({
891
+ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
408
892
  method: "delete",
409
893
  ...variables,
410
894
  signal
411
895
  });
412
- const getDatabaseMetadata = (variables, signal) => fetch$1({
413
- url: "/dbs/{dbName}/metadata",
896
+ const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
897
+ const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
898
+ const getFileItem = (variables, signal) => dataPlaneFetch({
899
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
414
900
  method: "get",
415
901
  ...variables,
416
902
  signal
417
903
  });
418
- const updateDatabaseMetadata = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
419
- const getBranchDetails = (variables, signal) => fetch$1({
420
- url: "/db/{dbBranchName}",
421
- method: "get",
904
+ const putFileItem = (variables, signal) => dataPlaneFetch({
905
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
906
+ method: "put",
422
907
  ...variables,
423
908
  signal
424
909
  });
425
- const createBranch = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
426
- const deleteBranch = (variables, signal) => fetch$1({
427
- url: "/db/{dbBranchName}",
910
+ const deleteFileItem = (variables, signal) => dataPlaneFetch({
911
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
428
912
  method: "delete",
429
913
  ...variables,
430
914
  signal
431
915
  });
432
- const updateBranchMetadata = (variables, signal) => fetch$1({
433
- url: "/db/{dbBranchName}/metadata",
434
- method: "put",
435
- ...variables,
436
- signal
437
- });
438
- const getBranchMetadata = (variables, signal) => fetch$1({
439
- url: "/db/{dbBranchName}/metadata",
916
+ const getFile = (variables, signal) => dataPlaneFetch({
917
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
440
918
  method: "get",
441
919
  ...variables,
442
920
  signal
443
921
  });
444
- const getBranchStats = (variables, signal) => fetch$1({
445
- url: "/db/{dbBranchName}/stats",
446
- method: "get",
922
+ const putFile = (variables, signal) => dataPlaneFetch({
923
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
924
+ method: "put",
447
925
  ...variables,
448
926
  signal
449
927
  });
450
- const getGitBranchesMapping = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
451
- const addGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
452
- const removeGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
453
- const resolveBranch = (variables, signal) => fetch$1({
454
- url: "/dbs/{dbName}/resolveBranch",
455
- method: "get",
928
+ const deleteFile = (variables, signal) => dataPlaneFetch({
929
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
930
+ method: "delete",
456
931
  ...variables,
457
932
  signal
458
933
  });
459
- const getBranchMigrationHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
460
- const getBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
461
- const executeBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
462
- const queryMigrationRequests = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
463
- const createMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
464
- const getMigrationRequest = (variables, signal) => fetch$1({
465
- url: "/dbs/{dbName}/migrations/{mrNumber}",
934
+ const getRecord = (variables, signal) => dataPlaneFetch({
935
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
466
936
  method: "get",
467
937
  ...variables,
468
938
  signal
469
939
  });
470
- const updateMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
471
- const listMigrationRequestsCommits = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
472
- const compareMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
473
- const getMigrationRequestIsMerged = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
474
- const mergeMigrationRequest = (variables, signal) => fetch$1({
475
- url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
940
+ const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
941
+ const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
942
+ const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
943
+ const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
944
+ const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
945
+ const queryTable = (variables, signal) => dataPlaneFetch({
946
+ url: "/db/{dbBranchName}/tables/{tableName}/query",
476
947
  method: "post",
477
948
  ...variables,
478
949
  signal
479
950
  });
480
- const getBranchSchemaHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
481
- const compareBranchWithUserSchema = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
482
- const compareBranchSchemas = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
483
- const updateBranchSchema = (variables, signal) => fetch$1({
484
- url: "/db/{dbBranchName}/schema/update",
951
+ const searchBranch = (variables, signal) => dataPlaneFetch({
952
+ url: "/db/{dbBranchName}/search",
485
953
  method: "post",
486
954
  ...variables,
487
955
  signal
488
956
  });
489
- const previewBranchSchemaEdit = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
490
- const applyBranchSchemaEdit = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
491
- const createTable = (variables, signal) => fetch$1({
492
- url: "/db/{dbBranchName}/tables/{tableName}",
493
- method: "put",
494
- ...variables,
495
- signal
496
- });
497
- const deleteTable = (variables, signal) => fetch$1({
498
- url: "/db/{dbBranchName}/tables/{tableName}",
499
- method: "delete",
957
+ const searchTable = (variables, signal) => dataPlaneFetch({
958
+ url: "/db/{dbBranchName}/tables/{tableName}/search",
959
+ method: "post",
500
960
  ...variables,
501
961
  signal
502
962
  });
503
- const updateTable = (variables, signal) => fetch$1({
504
- url: "/db/{dbBranchName}/tables/{tableName}",
505
- method: "patch",
963
+ const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
964
+ const askTable = (variables, signal) => dataPlaneFetch({
965
+ url: "/db/{dbBranchName}/tables/{tableName}/ask",
966
+ method: "post",
506
967
  ...variables,
507
968
  signal
508
969
  });
509
- const getTableSchema = (variables, signal) => fetch$1({
510
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
970
+ const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
971
+ const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
972
+ const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
973
+ const fileAccess = (variables, signal) => dataPlaneFetch({
974
+ url: "/file/{fileId}",
511
975
  method: "get",
512
976
  ...variables,
513
977
  signal
514
978
  });
515
- const setTableSchema = (variables, signal) => fetch$1({
516
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
517
- method: "put",
979
+ const sqlQuery = (variables, signal) => dataPlaneFetch({
980
+ url: "/db/{dbBranchName}/sql",
981
+ method: "post",
518
982
  ...variables,
519
983
  signal
520
984
  });
521
- const getTableColumns = (variables, signal) => fetch$1({
522
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
985
+ const operationsByTag$2 = {
986
+ branch: {
987
+ getBranchList,
988
+ getBranchDetails,
989
+ createBranch,
990
+ deleteBranch,
991
+ copyBranch,
992
+ updateBranchMetadata,
993
+ getBranchMetadata,
994
+ getBranchStats,
995
+ getGitBranchesMapping,
996
+ addGitBranchesEntry,
997
+ removeGitBranchesEntry,
998
+ resolveBranch
999
+ },
1000
+ migrations: {
1001
+ getBranchMigrationHistory,
1002
+ getBranchMigrationPlan,
1003
+ executeBranchMigrationPlan,
1004
+ getBranchSchemaHistory,
1005
+ compareBranchWithUserSchema,
1006
+ compareBranchSchemas,
1007
+ updateBranchSchema,
1008
+ previewBranchSchemaEdit,
1009
+ applyBranchSchemaEdit,
1010
+ pushBranchMigrations
1011
+ },
1012
+ migrationRequests: {
1013
+ queryMigrationRequests,
1014
+ createMigrationRequest,
1015
+ getMigrationRequest,
1016
+ updateMigrationRequest,
1017
+ listMigrationRequestsCommits,
1018
+ compareMigrationRequest,
1019
+ getMigrationRequestIsMerged,
1020
+ mergeMigrationRequest
1021
+ },
1022
+ table: {
1023
+ createTable,
1024
+ deleteTable,
1025
+ updateTable,
1026
+ getTableSchema,
1027
+ setTableSchema,
1028
+ getTableColumns,
1029
+ addTableColumn,
1030
+ getColumn,
1031
+ updateColumn,
1032
+ deleteColumn
1033
+ },
1034
+ records: {
1035
+ branchTransaction,
1036
+ insertRecord,
1037
+ getRecord,
1038
+ insertRecordWithID,
1039
+ updateRecordWithID,
1040
+ upsertRecordWithID,
1041
+ deleteRecord,
1042
+ bulkInsertTableRecords
1043
+ },
1044
+ files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
1045
+ searchAndFilter: {
1046
+ queryTable,
1047
+ searchBranch,
1048
+ searchTable,
1049
+ vectorSearchTable,
1050
+ askTable,
1051
+ askTableSession,
1052
+ summarizeTable,
1053
+ aggregateTable
1054
+ },
1055
+ sql: { sqlQuery }
1056
+ };
1057
+
1058
+ const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
1059
+
1060
+ const getAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "get", ...variables, signal });
1061
+ const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
1062
+ const getUser = (variables, signal) => controlPlaneFetch({
1063
+ url: "/user",
523
1064
  method: "get",
524
1065
  ...variables,
525
1066
  signal
526
1067
  });
527
- const addTableColumn = (variables, signal) => fetch$1({
528
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
529
- method: "post",
1068
+ const updateUser = (variables, signal) => controlPlaneFetch({
1069
+ url: "/user",
1070
+ method: "put",
530
1071
  ...variables,
531
1072
  signal
532
1073
  });
533
- const getColumn = (variables, signal) => fetch$1({
534
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
1074
+ const deleteUser = (variables, signal) => controlPlaneFetch({
1075
+ url: "/user",
1076
+ method: "delete",
1077
+ ...variables,
1078
+ signal
1079
+ });
1080
+ const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
1081
+ url: "/user/keys",
535
1082
  method: "get",
536
1083
  ...variables,
537
1084
  signal
538
1085
  });
539
- const updateColumn = (variables, signal) => fetch$1({
540
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
541
- method: "patch",
1086
+ const createUserAPIKey = (variables, signal) => controlPlaneFetch({
1087
+ url: "/user/keys/{keyName}",
1088
+ method: "post",
542
1089
  ...variables,
543
1090
  signal
544
1091
  });
545
- const deleteColumn = (variables, signal) => fetch$1({
546
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
1092
+ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
1093
+ url: "/user/keys/{keyName}",
547
1094
  method: "delete",
548
1095
  ...variables,
549
1096
  signal
550
1097
  });
551
- const insertRecord = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
552
- const getRecord = (variables, signal) => fetch$1({
553
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
1098
+ const getUserOAuthClients = (variables, signal) => controlPlaneFetch({
1099
+ url: "/user/oauth/clients",
554
1100
  method: "get",
555
1101
  ...variables,
556
1102
  signal
557
1103
  });
558
- const insertRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
559
- const updateRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
560
- const upsertRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
561
- const deleteRecord = (variables, signal) => fetch$1({
562
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
1104
+ const deleteUserOAuthClient = (variables, signal) => controlPlaneFetch({
1105
+ url: "/user/oauth/clients/{clientId}",
563
1106
  method: "delete",
564
1107
  ...variables,
565
1108
  signal
566
1109
  });
567
- const bulkInsertTableRecords = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
568
- const queryTable = (variables, signal) => fetch$1({
569
- url: "/db/{dbBranchName}/tables/{tableName}/query",
570
- method: "post",
1110
+ const getUserOAuthAccessTokens = (variables, signal) => controlPlaneFetch({
1111
+ url: "/user/oauth/tokens",
1112
+ method: "get",
571
1113
  ...variables,
572
1114
  signal
573
1115
  });
574
- const searchBranch = (variables, signal) => fetch$1({
575
- url: "/db/{dbBranchName}/search",
576
- method: "post",
1116
+ const deleteOAuthAccessToken = (variables, signal) => controlPlaneFetch({
1117
+ url: "/user/oauth/tokens/{token}",
1118
+ method: "delete",
577
1119
  ...variables,
578
1120
  signal
579
1121
  });
580
- const searchTable = (variables, signal) => fetch$1({
581
- url: "/db/{dbBranchName}/tables/{tableName}/search",
582
- method: "post",
1122
+ const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({ url: "/user/oauth/tokens/{token}", method: "patch", ...variables, signal });
1123
+ const getWorkspacesList = (variables, signal) => controlPlaneFetch({
1124
+ url: "/workspaces",
1125
+ method: "get",
583
1126
  ...variables,
584
1127
  signal
585
1128
  });
586
- const summarizeTable = (variables, signal) => fetch$1({
587
- url: "/db/{dbBranchName}/tables/{tableName}/summarize",
1129
+ const createWorkspace = (variables, signal) => controlPlaneFetch({
1130
+ url: "/workspaces",
588
1131
  method: "post",
589
1132
  ...variables,
590
1133
  signal
591
1134
  });
592
- const aggregateTable = (variables, signal) => fetch$1({
593
- url: "/db/{dbBranchName}/tables/{tableName}/aggregate",
594
- method: "post",
1135
+ const getWorkspace = (variables, signal) => controlPlaneFetch({
1136
+ url: "/workspaces/{workspaceId}",
1137
+ method: "get",
1138
+ ...variables,
1139
+ signal
1140
+ });
1141
+ const updateWorkspace = (variables, signal) => controlPlaneFetch({
1142
+ url: "/workspaces/{workspaceId}",
1143
+ method: "put",
1144
+ ...variables,
1145
+ signal
1146
+ });
1147
+ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
1148
+ url: "/workspaces/{workspaceId}",
1149
+ method: "delete",
1150
+ ...variables,
1151
+ signal
1152
+ });
1153
+ const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
1154
+ const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
1155
+ const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
1156
+ url: "/workspaces/{workspaceId}/members/{userId}",
1157
+ method: "delete",
595
1158
  ...variables,
596
1159
  signal
597
1160
  });
598
- const cPGetDatabaseList = (variables, signal) => fetch$1({
1161
+ const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
1162
+ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
1163
+ const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
1164
+ const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
1165
+ const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
1166
+ const getDatabaseList = (variables, signal) => controlPlaneFetch({
599
1167
  url: "/workspaces/{workspaceId}/dbs",
600
1168
  method: "get",
601
1169
  ...variables,
602
1170
  signal
603
1171
  });
604
- const cPCreateDatabase = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
605
- const cPDeleteDatabase = (variables, signal) => fetch$1({
1172
+ const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
1173
+ const deleteDatabase = (variables, signal) => controlPlaneFetch({
606
1174
  url: "/workspaces/{workspaceId}/dbs/{dbName}",
607
1175
  method: "delete",
608
1176
  ...variables,
609
1177
  signal
610
1178
  });
611
- const cPGetCPDatabaseMetadata = (variables, signal) => fetch$1(
612
- { url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "get", ...variables, signal }
613
- );
614
- const cPUpdateCPDatabaseMetadata = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
615
- const listRegions = (variables, signal) => fetch$1({
1179
+ const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
1180
+ const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
1181
+ const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
1182
+ const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
1183
+ const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
1184
+ const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
1185
+ const listRegions = (variables, signal) => controlPlaneFetch({
616
1186
  url: "/workspaces/{workspaceId}/regions",
617
1187
  method: "get",
618
1188
  ...variables,
619
1189
  signal
620
1190
  });
621
- const operationsByTag = {
1191
+ const operationsByTag$1 = {
1192
+ oAuth: {
1193
+ getAuthorizationCode,
1194
+ grantAuthorizationCode,
1195
+ getUserOAuthClients,
1196
+ deleteUserOAuthClient,
1197
+ getUserOAuthAccessTokens,
1198
+ deleteOAuthAccessToken,
1199
+ updateOAuthAccessToken
1200
+ },
622
1201
  users: { getUser, updateUser, deleteUser },
623
1202
  authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
624
1203
  workspaces: {
@@ -638,73 +1217,22 @@ const operationsByTag = {
638
1217
  acceptWorkspaceMemberInvite,
639
1218
  resendWorkspaceMemberInvite
640
1219
  },
641
- database: { getDatabaseList, createDatabase, deleteDatabase, getDatabaseMetadata, updateDatabaseMetadata },
642
- branch: {
643
- getBranchList,
644
- getBranchDetails,
645
- createBranch,
646
- deleteBranch,
647
- updateBranchMetadata,
648
- getBranchMetadata,
649
- getBranchStats,
650
- getGitBranchesMapping,
651
- addGitBranchesEntry,
652
- removeGitBranchesEntry,
653
- resolveBranch
654
- },
655
- migrations: {
656
- getBranchMigrationHistory,
657
- getBranchMigrationPlan,
658
- executeBranchMigrationPlan,
659
- getBranchSchemaHistory,
660
- compareBranchWithUserSchema,
661
- compareBranchSchemas,
662
- updateBranchSchema,
663
- previewBranchSchemaEdit,
664
- applyBranchSchemaEdit
665
- },
666
- migrationRequests: {
667
- queryMigrationRequests,
668
- createMigrationRequest,
669
- getMigrationRequest,
670
- updateMigrationRequest,
671
- listMigrationRequestsCommits,
672
- compareMigrationRequest,
673
- getMigrationRequestIsMerged,
674
- mergeMigrationRequest
675
- },
676
- table: {
677
- createTable,
678
- deleteTable,
679
- updateTable,
680
- getTableSchema,
681
- setTableSchema,
682
- getTableColumns,
683
- addTableColumn,
684
- getColumn,
685
- updateColumn,
686
- deleteColumn
687
- },
688
- records: {
689
- insertRecord,
690
- getRecord,
691
- insertRecordWithID,
692
- updateRecordWithID,
693
- upsertRecordWithID,
694
- deleteRecord,
695
- bulkInsertTableRecords
696
- },
697
- searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable },
698
1220
  databases: {
699
- cPGetDatabaseList,
700
- cPCreateDatabase,
701
- cPDeleteDatabase,
702
- cPGetCPDatabaseMetadata,
703
- cPUpdateCPDatabaseMetadata,
1221
+ getDatabaseList,
1222
+ createDatabase,
1223
+ deleteDatabase,
1224
+ getDatabaseMetadata,
1225
+ updateDatabaseMetadata,
1226
+ renameDatabase,
1227
+ getDatabaseGithubSettings,
1228
+ updateDatabaseGithubSettings,
1229
+ deleteDatabaseGithubSettings,
704
1230
  listRegions
705
1231
  }
706
1232
  };
707
1233
 
1234
+ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
1235
+
708
1236
  function getHostUrl(provider, type) {
709
1237
  if (isHostProviderAlias(provider)) {
710
1238
  return providers[provider][type];
@@ -716,11 +1244,15 @@ function getHostUrl(provider, type) {
716
1244
  const providers = {
717
1245
  production: {
718
1246
  main: "https://api.xata.io",
719
- workspaces: "https://{workspaceId}.xata.sh"
1247
+ workspaces: "https://{workspaceId}.{region}.xata.sh"
720
1248
  },
721
1249
  staging: {
722
- main: "https://staging.xatabase.co",
723
- workspaces: "https://{workspaceId}.staging.xatabase.co"
1250
+ main: "https://api.staging-xata.dev",
1251
+ workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
1252
+ },
1253
+ dev: {
1254
+ main: "https://api.dev-xata.dev",
1255
+ workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
724
1256
  }
725
1257
  };
726
1258
  function isHostProviderAlias(alias) {
@@ -738,6 +1270,23 @@ function parseProviderString(provider = "production") {
738
1270
  return null;
739
1271
  return { main, workspaces };
740
1272
  }
1273
+ function buildProviderString(provider) {
1274
+ if (isHostProviderAlias(provider))
1275
+ return provider;
1276
+ return `${provider.main},${provider.workspaces}`;
1277
+ }
1278
+ function parseWorkspacesUrlParts(url) {
1279
+ if (!isString(url))
1280
+ return null;
1281
+ const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
1282
+ const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
1283
+ const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
1284
+ const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
1285
+ const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
1286
+ if (!match)
1287
+ return null;
1288
+ return { workspace: match[1], region: match[2] };
1289
+ }
741
1290
 
742
1291
  var __accessCheck$7 = (obj, member, msg) => {
743
1292
  if (!member.has(obj))
@@ -765,15 +1314,19 @@ class XataApiClient {
765
1314
  const provider = options.host ?? "production";
766
1315
  const apiKey = options.apiKey ?? getAPIKey();
767
1316
  const trace = options.trace ?? defaultTrace;
1317
+ const clientID = generateUUID();
768
1318
  if (!apiKey) {
769
1319
  throw new Error("Could not resolve a valid apiKey");
770
1320
  }
771
1321
  __privateSet$7(this, _extraProps, {
772
1322
  apiUrl: getHostUrl(provider, "main"),
773
1323
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
774
- fetchImpl: getFetchImplementation(options.fetch),
1324
+ fetch: getFetchImplementation(options.fetch),
775
1325
  apiKey,
776
- trace
1326
+ trace,
1327
+ clientName: options.clientName,
1328
+ xataAgentExtra: options.xataAgentExtra,
1329
+ clientID
777
1330
  });
778
1331
  }
779
1332
  get user() {
@@ -826,16 +1379,16 @@ class XataApiClient {
826
1379
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
827
1380
  return __privateGet$7(this, _namespaces).records;
828
1381
  }
1382
+ get files() {
1383
+ if (!__privateGet$7(this, _namespaces).files)
1384
+ __privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
1385
+ return __privateGet$7(this, _namespaces).files;
1386
+ }
829
1387
  get searchAndFilter() {
830
1388
  if (!__privateGet$7(this, _namespaces).searchAndFilter)
831
1389
  __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
832
1390
  return __privateGet$7(this, _namespaces).searchAndFilter;
833
1391
  }
834
- get databases() {
835
- if (!__privateGet$7(this, _namespaces).databases)
836
- __privateGet$7(this, _namespaces).databases = new DatabasesApi(__privateGet$7(this, _extraProps));
837
- return __privateGet$7(this, _namespaces).databases;
838
- }
839
1392
  }
840
1393
  _extraProps = new WeakMap();
841
1394
  _namespaces = new WeakMap();
@@ -846,7 +1399,7 @@ class UserApi {
846
1399
  getUser() {
847
1400
  return operationsByTag.users.getUser({ ...this.extraProps });
848
1401
  }
849
- updateUser(user) {
1402
+ updateUser({ user }) {
850
1403
  return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
851
1404
  }
852
1405
  deleteUser() {
@@ -860,15 +1413,15 @@ class AuthenticationApi {
860
1413
  getUserAPIKeys() {
861
1414
  return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
862
1415
  }
863
- createUserAPIKey(keyName) {
1416
+ createUserAPIKey({ name }) {
864
1417
  return operationsByTag.authentication.createUserAPIKey({
865
- pathParams: { keyName },
1418
+ pathParams: { keyName: name },
866
1419
  ...this.extraProps
867
1420
  });
868
1421
  }
869
- deleteUserAPIKey(keyName) {
1422
+ deleteUserAPIKey({ name }) {
870
1423
  return operationsByTag.authentication.deleteUserAPIKey({
871
- pathParams: { keyName },
1424
+ pathParams: { keyName: name },
872
1425
  ...this.extraProps
873
1426
  });
874
1427
  }
@@ -880,47 +1433,57 @@ class WorkspaceApi {
880
1433
  getWorkspacesList() {
881
1434
  return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
882
1435
  }
883
- createWorkspace(workspaceMeta) {
1436
+ createWorkspace({ data }) {
884
1437
  return operationsByTag.workspaces.createWorkspace({
885
- body: workspaceMeta,
1438
+ body: data,
886
1439
  ...this.extraProps
887
1440
  });
888
1441
  }
889
- getWorkspace(workspaceId) {
1442
+ getWorkspace({ workspace }) {
890
1443
  return operationsByTag.workspaces.getWorkspace({
891
- pathParams: { workspaceId },
1444
+ pathParams: { workspaceId: workspace },
892
1445
  ...this.extraProps
893
1446
  });
894
1447
  }
895
- updateWorkspace(workspaceId, workspaceMeta) {
1448
+ updateWorkspace({
1449
+ workspace,
1450
+ update
1451
+ }) {
896
1452
  return operationsByTag.workspaces.updateWorkspace({
897
- pathParams: { workspaceId },
898
- body: workspaceMeta,
1453
+ pathParams: { workspaceId: workspace },
1454
+ body: update,
899
1455
  ...this.extraProps
900
1456
  });
901
1457
  }
902
- deleteWorkspace(workspaceId) {
1458
+ deleteWorkspace({ workspace }) {
903
1459
  return operationsByTag.workspaces.deleteWorkspace({
904
- pathParams: { workspaceId },
1460
+ pathParams: { workspaceId: workspace },
905
1461
  ...this.extraProps
906
1462
  });
907
1463
  }
908
- getWorkspaceMembersList(workspaceId) {
1464
+ getWorkspaceMembersList({ workspace }) {
909
1465
  return operationsByTag.workspaces.getWorkspaceMembersList({
910
- pathParams: { workspaceId },
1466
+ pathParams: { workspaceId: workspace },
911
1467
  ...this.extraProps
912
1468
  });
913
1469
  }
914
- updateWorkspaceMemberRole(workspaceId, userId, role) {
1470
+ updateWorkspaceMemberRole({
1471
+ workspace,
1472
+ user,
1473
+ role
1474
+ }) {
915
1475
  return operationsByTag.workspaces.updateWorkspaceMemberRole({
916
- pathParams: { workspaceId, userId },
1476
+ pathParams: { workspaceId: workspace, userId: user },
917
1477
  body: { role },
918
1478
  ...this.extraProps
919
1479
  });
920
1480
  }
921
- removeWorkspaceMember(workspaceId, userId) {
1481
+ removeWorkspaceMember({
1482
+ workspace,
1483
+ user
1484
+ }) {
922
1485
  return operationsByTag.workspaces.removeWorkspaceMember({
923
- pathParams: { workspaceId, userId },
1486
+ pathParams: { workspaceId: workspace, userId: user },
924
1487
  ...this.extraProps
925
1488
  });
926
1489
  }
@@ -929,72 +1492,52 @@ class InvitesApi {
929
1492
  constructor(extraProps) {
930
1493
  this.extraProps = extraProps;
931
1494
  }
932
- inviteWorkspaceMember(workspaceId, email, role) {
1495
+ inviteWorkspaceMember({
1496
+ workspace,
1497
+ email,
1498
+ role
1499
+ }) {
933
1500
  return operationsByTag.invites.inviteWorkspaceMember({
934
- pathParams: { workspaceId },
1501
+ pathParams: { workspaceId: workspace },
935
1502
  body: { email, role },
936
1503
  ...this.extraProps
937
1504
  });
938
1505
  }
939
- updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
1506
+ updateWorkspaceMemberInvite({
1507
+ workspace,
1508
+ invite,
1509
+ role
1510
+ }) {
940
1511
  return operationsByTag.invites.updateWorkspaceMemberInvite({
941
- pathParams: { workspaceId, inviteId },
1512
+ pathParams: { workspaceId: workspace, inviteId: invite },
942
1513
  body: { role },
943
1514
  ...this.extraProps
944
1515
  });
945
1516
  }
946
- cancelWorkspaceMemberInvite(workspaceId, inviteId) {
1517
+ cancelWorkspaceMemberInvite({
1518
+ workspace,
1519
+ invite
1520
+ }) {
947
1521
  return operationsByTag.invites.cancelWorkspaceMemberInvite({
948
- pathParams: { workspaceId, inviteId },
1522
+ pathParams: { workspaceId: workspace, inviteId: invite },
949
1523
  ...this.extraProps
950
1524
  });
951
1525
  }
952
- acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
1526
+ acceptWorkspaceMemberInvite({
1527
+ workspace,
1528
+ key
1529
+ }) {
953
1530
  return operationsByTag.invites.acceptWorkspaceMemberInvite({
954
- pathParams: { workspaceId, inviteKey },
1531
+ pathParams: { workspaceId: workspace, inviteKey: key },
955
1532
  ...this.extraProps
956
1533
  });
957
1534
  }
958
- resendWorkspaceMemberInvite(workspaceId, inviteId) {
1535
+ resendWorkspaceMemberInvite({
1536
+ workspace,
1537
+ invite
1538
+ }) {
959
1539
  return operationsByTag.invites.resendWorkspaceMemberInvite({
960
- pathParams: { workspaceId, inviteId },
961
- ...this.extraProps
962
- });
963
- }
964
- }
965
- class DatabaseApi {
966
- constructor(extraProps) {
967
- this.extraProps = extraProps;
968
- }
969
- getDatabaseList(workspace) {
970
- return operationsByTag.database.getDatabaseList({
971
- pathParams: { workspace },
972
- ...this.extraProps
973
- });
974
- }
975
- createDatabase(workspace, dbName, options = {}) {
976
- return operationsByTag.database.createDatabase({
977
- pathParams: { workspace, dbName },
978
- body: options,
979
- ...this.extraProps
980
- });
981
- }
982
- deleteDatabase(workspace, dbName) {
983
- return operationsByTag.database.deleteDatabase({
984
- pathParams: { workspace, dbName },
985
- ...this.extraProps
986
- });
987
- }
988
- getDatabaseMetadata(workspace, dbName) {
989
- return operationsByTag.database.getDatabaseMetadata({
990
- pathParams: { workspace, dbName },
991
- ...this.extraProps
992
- });
993
- }
994
- updateDatabaseMetadata(workspace, dbName, options = {}) {
995
- return operationsByTag.database.updateDatabaseMetadata({
996
- pathParams: { workspace, dbName },
997
- body: options,
1540
+ pathParams: { workspaceId: workspace, inviteId: invite },
998
1541
  ...this.extraProps
999
1542
  });
1000
1543
  }
@@ -1003,74 +1546,145 @@ class BranchApi {
1003
1546
  constructor(extraProps) {
1004
1547
  this.extraProps = extraProps;
1005
1548
  }
1006
- getBranchList(workspace, dbName) {
1549
+ getBranchList({
1550
+ workspace,
1551
+ region,
1552
+ database
1553
+ }) {
1007
1554
  return operationsByTag.branch.getBranchList({
1008
- pathParams: { workspace, dbName },
1555
+ pathParams: { workspace, region, dbName: database },
1009
1556
  ...this.extraProps
1010
1557
  });
1011
1558
  }
1012
- getBranchDetails(workspace, database, branch) {
1559
+ getBranchDetails({
1560
+ workspace,
1561
+ region,
1562
+ database,
1563
+ branch
1564
+ }) {
1013
1565
  return operationsByTag.branch.getBranchDetails({
1014
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1566
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1015
1567
  ...this.extraProps
1016
1568
  });
1017
1569
  }
1018
- createBranch(workspace, database, branch, from, options = {}) {
1570
+ createBranch({
1571
+ workspace,
1572
+ region,
1573
+ database,
1574
+ branch,
1575
+ from,
1576
+ metadata
1577
+ }) {
1019
1578
  return operationsByTag.branch.createBranch({
1020
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1021
- queryParams: isString(from) ? { from } : void 0,
1022
- body: options,
1579
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1580
+ body: { from, metadata },
1023
1581
  ...this.extraProps
1024
1582
  });
1025
1583
  }
1026
- deleteBranch(workspace, database, branch) {
1584
+ deleteBranch({
1585
+ workspace,
1586
+ region,
1587
+ database,
1588
+ branch
1589
+ }) {
1027
1590
  return operationsByTag.branch.deleteBranch({
1028
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1591
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1029
1592
  ...this.extraProps
1030
1593
  });
1031
1594
  }
1032
- updateBranchMetadata(workspace, database, branch, metadata = {}) {
1595
+ copyBranch({
1596
+ workspace,
1597
+ region,
1598
+ database,
1599
+ branch,
1600
+ destinationBranch,
1601
+ limit
1602
+ }) {
1603
+ return operationsByTag.branch.copyBranch({
1604
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1605
+ body: { destinationBranch, limit },
1606
+ ...this.extraProps
1607
+ });
1608
+ }
1609
+ updateBranchMetadata({
1610
+ workspace,
1611
+ region,
1612
+ database,
1613
+ branch,
1614
+ metadata
1615
+ }) {
1033
1616
  return operationsByTag.branch.updateBranchMetadata({
1034
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1617
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1035
1618
  body: metadata,
1036
1619
  ...this.extraProps
1037
1620
  });
1038
1621
  }
1039
- getBranchMetadata(workspace, database, branch) {
1622
+ getBranchMetadata({
1623
+ workspace,
1624
+ region,
1625
+ database,
1626
+ branch
1627
+ }) {
1040
1628
  return operationsByTag.branch.getBranchMetadata({
1041
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1629
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1042
1630
  ...this.extraProps
1043
1631
  });
1044
1632
  }
1045
- getBranchStats(workspace, database, branch) {
1633
+ getBranchStats({
1634
+ workspace,
1635
+ region,
1636
+ database,
1637
+ branch
1638
+ }) {
1046
1639
  return operationsByTag.branch.getBranchStats({
1047
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1640
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1048
1641
  ...this.extraProps
1049
1642
  });
1050
1643
  }
1051
- getGitBranchesMapping(workspace, dbName) {
1644
+ getGitBranchesMapping({
1645
+ workspace,
1646
+ region,
1647
+ database
1648
+ }) {
1052
1649
  return operationsByTag.branch.getGitBranchesMapping({
1053
- pathParams: { workspace, dbName },
1650
+ pathParams: { workspace, region, dbName: database },
1054
1651
  ...this.extraProps
1055
1652
  });
1056
1653
  }
1057
- addGitBranchesEntry(workspace, dbName, body) {
1654
+ addGitBranchesEntry({
1655
+ workspace,
1656
+ region,
1657
+ database,
1658
+ gitBranch,
1659
+ xataBranch
1660
+ }) {
1058
1661
  return operationsByTag.branch.addGitBranchesEntry({
1059
- pathParams: { workspace, dbName },
1060
- body,
1662
+ pathParams: { workspace, region, dbName: database },
1663
+ body: { gitBranch, xataBranch },
1061
1664
  ...this.extraProps
1062
1665
  });
1063
1666
  }
1064
- removeGitBranchesEntry(workspace, dbName, gitBranch) {
1667
+ removeGitBranchesEntry({
1668
+ workspace,
1669
+ region,
1670
+ database,
1671
+ gitBranch
1672
+ }) {
1065
1673
  return operationsByTag.branch.removeGitBranchesEntry({
1066
- pathParams: { workspace, dbName },
1674
+ pathParams: { workspace, region, dbName: database },
1067
1675
  queryParams: { gitBranch },
1068
1676
  ...this.extraProps
1069
1677
  });
1070
1678
  }
1071
- resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
1679
+ resolveBranch({
1680
+ workspace,
1681
+ region,
1682
+ database,
1683
+ gitBranch,
1684
+ fallbackBranch
1685
+ }) {
1072
1686
  return operationsByTag.branch.resolveBranch({
1073
- pathParams: { workspace, dbName },
1687
+ pathParams: { workspace, region, dbName: database },
1074
1688
  queryParams: { gitBranch, fallbackBranch },
1075
1689
  ...this.extraProps
1076
1690
  });
@@ -1080,67 +1694,134 @@ class TableApi {
1080
1694
  constructor(extraProps) {
1081
1695
  this.extraProps = extraProps;
1082
1696
  }
1083
- createTable(workspace, database, branch, tableName) {
1697
+ createTable({
1698
+ workspace,
1699
+ region,
1700
+ database,
1701
+ branch,
1702
+ table
1703
+ }) {
1084
1704
  return operationsByTag.table.createTable({
1085
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1705
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1086
1706
  ...this.extraProps
1087
1707
  });
1088
1708
  }
1089
- deleteTable(workspace, database, branch, tableName) {
1709
+ deleteTable({
1710
+ workspace,
1711
+ region,
1712
+ database,
1713
+ branch,
1714
+ table
1715
+ }) {
1090
1716
  return operationsByTag.table.deleteTable({
1091
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1717
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1092
1718
  ...this.extraProps
1093
1719
  });
1094
1720
  }
1095
- updateTable(workspace, database, branch, tableName, options) {
1721
+ updateTable({
1722
+ workspace,
1723
+ region,
1724
+ database,
1725
+ branch,
1726
+ table,
1727
+ update
1728
+ }) {
1096
1729
  return operationsByTag.table.updateTable({
1097
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1098
- body: options,
1730
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1731
+ body: update,
1099
1732
  ...this.extraProps
1100
1733
  });
1101
1734
  }
1102
- getTableSchema(workspace, database, branch, tableName) {
1735
+ getTableSchema({
1736
+ workspace,
1737
+ region,
1738
+ database,
1739
+ branch,
1740
+ table
1741
+ }) {
1103
1742
  return operationsByTag.table.getTableSchema({
1104
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1743
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1105
1744
  ...this.extraProps
1106
1745
  });
1107
1746
  }
1108
- setTableSchema(workspace, database, branch, tableName, options) {
1747
+ setTableSchema({
1748
+ workspace,
1749
+ region,
1750
+ database,
1751
+ branch,
1752
+ table,
1753
+ schema
1754
+ }) {
1109
1755
  return operationsByTag.table.setTableSchema({
1110
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1111
- body: options,
1756
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1757
+ body: schema,
1112
1758
  ...this.extraProps
1113
1759
  });
1114
1760
  }
1115
- getTableColumns(workspace, database, branch, tableName) {
1761
+ getTableColumns({
1762
+ workspace,
1763
+ region,
1764
+ database,
1765
+ branch,
1766
+ table
1767
+ }) {
1116
1768
  return operationsByTag.table.getTableColumns({
1117
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1769
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1118
1770
  ...this.extraProps
1119
1771
  });
1120
1772
  }
1121
- addTableColumn(workspace, database, branch, tableName, column) {
1773
+ addTableColumn({
1774
+ workspace,
1775
+ region,
1776
+ database,
1777
+ branch,
1778
+ table,
1779
+ column
1780
+ }) {
1122
1781
  return operationsByTag.table.addTableColumn({
1123
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1782
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1124
1783
  body: column,
1125
1784
  ...this.extraProps
1126
1785
  });
1127
1786
  }
1128
- getColumn(workspace, database, branch, tableName, columnName) {
1787
+ getColumn({
1788
+ workspace,
1789
+ region,
1790
+ database,
1791
+ branch,
1792
+ table,
1793
+ column
1794
+ }) {
1129
1795
  return operationsByTag.table.getColumn({
1130
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1796
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1131
1797
  ...this.extraProps
1132
1798
  });
1133
1799
  }
1134
- updateColumn(workspace, database, branch, tableName, columnName, options) {
1800
+ updateColumn({
1801
+ workspace,
1802
+ region,
1803
+ database,
1804
+ branch,
1805
+ table,
1806
+ column,
1807
+ update
1808
+ }) {
1135
1809
  return operationsByTag.table.updateColumn({
1136
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1137
- body: options,
1810
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1811
+ body: update,
1138
1812
  ...this.extraProps
1139
1813
  });
1140
1814
  }
1141
- deleteColumn(workspace, database, branch, tableName, columnName) {
1815
+ deleteColumn({
1816
+ workspace,
1817
+ region,
1818
+ database,
1819
+ branch,
1820
+ table,
1821
+ column
1822
+ }) {
1142
1823
  return operationsByTag.table.deleteColumn({
1143
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1824
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1144
1825
  ...this.extraProps
1145
1826
  });
1146
1827
  }
@@ -1149,97 +1830,433 @@ class RecordsApi {
1149
1830
  constructor(extraProps) {
1150
1831
  this.extraProps = extraProps;
1151
1832
  }
1152
- insertRecord(workspace, database, branch, tableName, record, options = {}) {
1833
+ insertRecord({
1834
+ workspace,
1835
+ region,
1836
+ database,
1837
+ branch,
1838
+ table,
1839
+ record,
1840
+ columns
1841
+ }) {
1153
1842
  return operationsByTag.records.insertRecord({
1154
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1155
- queryParams: options,
1843
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1844
+ queryParams: { columns },
1156
1845
  body: record,
1157
1846
  ...this.extraProps
1158
1847
  });
1159
1848
  }
1160
- getRecord(workspace, database, branch, tableName, recordId, options = {}) {
1849
+ getRecord({
1850
+ workspace,
1851
+ region,
1852
+ database,
1853
+ branch,
1854
+ table,
1855
+ id,
1856
+ columns
1857
+ }) {
1161
1858
  return operationsByTag.records.getRecord({
1162
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1163
- queryParams: options,
1859
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1860
+ queryParams: { columns },
1164
1861
  ...this.extraProps
1165
1862
  });
1166
1863
  }
1167
- insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1864
+ insertRecordWithID({
1865
+ workspace,
1866
+ region,
1867
+ database,
1868
+ branch,
1869
+ table,
1870
+ id,
1871
+ record,
1872
+ columns,
1873
+ createOnly,
1874
+ ifVersion
1875
+ }) {
1168
1876
  return operationsByTag.records.insertRecordWithID({
1169
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1170
- queryParams: options,
1877
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1878
+ queryParams: { columns, createOnly, ifVersion },
1171
1879
  body: record,
1172
1880
  ...this.extraProps
1173
1881
  });
1174
1882
  }
1175
- updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1883
+ updateRecordWithID({
1884
+ workspace,
1885
+ region,
1886
+ database,
1887
+ branch,
1888
+ table,
1889
+ id,
1890
+ record,
1891
+ columns,
1892
+ ifVersion
1893
+ }) {
1176
1894
  return operationsByTag.records.updateRecordWithID({
1177
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1178
- queryParams: options,
1895
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1896
+ queryParams: { columns, ifVersion },
1179
1897
  body: record,
1180
1898
  ...this.extraProps
1181
1899
  });
1182
1900
  }
1183
- upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1901
+ upsertRecordWithID({
1902
+ workspace,
1903
+ region,
1904
+ database,
1905
+ branch,
1906
+ table,
1907
+ id,
1908
+ record,
1909
+ columns,
1910
+ ifVersion
1911
+ }) {
1184
1912
  return operationsByTag.records.upsertRecordWithID({
1185
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1186
- queryParams: options,
1913
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1914
+ queryParams: { columns, ifVersion },
1187
1915
  body: record,
1188
1916
  ...this.extraProps
1189
1917
  });
1190
1918
  }
1191
- deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
1919
+ deleteRecord({
1920
+ workspace,
1921
+ region,
1922
+ database,
1923
+ branch,
1924
+ table,
1925
+ id,
1926
+ columns
1927
+ }) {
1192
1928
  return operationsByTag.records.deleteRecord({
1193
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1194
- queryParams: options,
1929
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1930
+ queryParams: { columns },
1195
1931
  ...this.extraProps
1196
1932
  });
1197
1933
  }
1198
- bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
1934
+ bulkInsertTableRecords({
1935
+ workspace,
1936
+ region,
1937
+ database,
1938
+ branch,
1939
+ table,
1940
+ records,
1941
+ columns
1942
+ }) {
1199
1943
  return operationsByTag.records.bulkInsertTableRecords({
1200
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1201
- queryParams: options,
1944
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1945
+ queryParams: { columns },
1202
1946
  body: { records },
1203
1947
  ...this.extraProps
1204
1948
  });
1205
1949
  }
1950
+ branchTransaction({
1951
+ workspace,
1952
+ region,
1953
+ database,
1954
+ branch,
1955
+ operations
1956
+ }) {
1957
+ return operationsByTag.records.branchTransaction({
1958
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1959
+ body: { operations },
1960
+ ...this.extraProps
1961
+ });
1962
+ }
1963
+ }
1964
+ class FilesApi {
1965
+ constructor(extraProps) {
1966
+ this.extraProps = extraProps;
1967
+ }
1968
+ getFileItem({
1969
+ workspace,
1970
+ region,
1971
+ database,
1972
+ branch,
1973
+ table,
1974
+ record,
1975
+ column,
1976
+ fileId
1977
+ }) {
1978
+ return operationsByTag.files.getFileItem({
1979
+ pathParams: {
1980
+ workspace,
1981
+ region,
1982
+ dbBranchName: `${database}:${branch}`,
1983
+ tableName: table,
1984
+ recordId: record,
1985
+ columnName: column,
1986
+ fileId
1987
+ },
1988
+ ...this.extraProps
1989
+ });
1990
+ }
1991
+ putFileItem({
1992
+ workspace,
1993
+ region,
1994
+ database,
1995
+ branch,
1996
+ table,
1997
+ record,
1998
+ column,
1999
+ fileId,
2000
+ file
2001
+ }) {
2002
+ return operationsByTag.files.putFileItem({
2003
+ pathParams: {
2004
+ workspace,
2005
+ region,
2006
+ dbBranchName: `${database}:${branch}`,
2007
+ tableName: table,
2008
+ recordId: record,
2009
+ columnName: column,
2010
+ fileId
2011
+ },
2012
+ // @ts-ignore
2013
+ body: file,
2014
+ ...this.extraProps
2015
+ });
2016
+ }
2017
+ deleteFileItem({
2018
+ workspace,
2019
+ region,
2020
+ database,
2021
+ branch,
2022
+ table,
2023
+ record,
2024
+ column,
2025
+ fileId
2026
+ }) {
2027
+ return operationsByTag.files.deleteFileItem({
2028
+ pathParams: {
2029
+ workspace,
2030
+ region,
2031
+ dbBranchName: `${database}:${branch}`,
2032
+ tableName: table,
2033
+ recordId: record,
2034
+ columnName: column,
2035
+ fileId
2036
+ },
2037
+ ...this.extraProps
2038
+ });
2039
+ }
2040
+ getFile({
2041
+ workspace,
2042
+ region,
2043
+ database,
2044
+ branch,
2045
+ table,
2046
+ record,
2047
+ column
2048
+ }) {
2049
+ return operationsByTag.files.getFile({
2050
+ pathParams: {
2051
+ workspace,
2052
+ region,
2053
+ dbBranchName: `${database}:${branch}`,
2054
+ tableName: table,
2055
+ recordId: record,
2056
+ columnName: column
2057
+ },
2058
+ ...this.extraProps
2059
+ });
2060
+ }
2061
+ putFile({
2062
+ workspace,
2063
+ region,
2064
+ database,
2065
+ branch,
2066
+ table,
2067
+ record,
2068
+ column,
2069
+ file
2070
+ }) {
2071
+ return operationsByTag.files.putFile({
2072
+ pathParams: {
2073
+ workspace,
2074
+ region,
2075
+ dbBranchName: `${database}:${branch}`,
2076
+ tableName: table,
2077
+ recordId: record,
2078
+ columnName: column
2079
+ },
2080
+ body: file,
2081
+ ...this.extraProps
2082
+ });
2083
+ }
2084
+ deleteFile({
2085
+ workspace,
2086
+ region,
2087
+ database,
2088
+ branch,
2089
+ table,
2090
+ record,
2091
+ column
2092
+ }) {
2093
+ return operationsByTag.files.deleteFile({
2094
+ pathParams: {
2095
+ workspace,
2096
+ region,
2097
+ dbBranchName: `${database}:${branch}`,
2098
+ tableName: table,
2099
+ recordId: record,
2100
+ columnName: column
2101
+ },
2102
+ ...this.extraProps
2103
+ });
2104
+ }
2105
+ fileAccess({
2106
+ workspace,
2107
+ region,
2108
+ fileId,
2109
+ verify
2110
+ }) {
2111
+ return operationsByTag.files.fileAccess({
2112
+ pathParams: {
2113
+ workspace,
2114
+ region,
2115
+ fileId
2116
+ },
2117
+ queryParams: { verify },
2118
+ ...this.extraProps
2119
+ });
2120
+ }
1206
2121
  }
1207
2122
  class SearchAndFilterApi {
1208
2123
  constructor(extraProps) {
1209
2124
  this.extraProps = extraProps;
1210
2125
  }
1211
- queryTable(workspace, database, branch, tableName, query) {
2126
+ queryTable({
2127
+ workspace,
2128
+ region,
2129
+ database,
2130
+ branch,
2131
+ table,
2132
+ filter,
2133
+ sort,
2134
+ page,
2135
+ columns,
2136
+ consistency
2137
+ }) {
1212
2138
  return operationsByTag.searchAndFilter.queryTable({
1213
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1214
- body: query,
2139
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2140
+ body: { filter, sort, page, columns, consistency },
1215
2141
  ...this.extraProps
1216
2142
  });
1217
2143
  }
1218
- searchTable(workspace, database, branch, tableName, query) {
2144
+ searchTable({
2145
+ workspace,
2146
+ region,
2147
+ database,
2148
+ branch,
2149
+ table,
2150
+ query,
2151
+ fuzziness,
2152
+ target,
2153
+ prefix,
2154
+ filter,
2155
+ highlight,
2156
+ boosters
2157
+ }) {
1219
2158
  return operationsByTag.searchAndFilter.searchTable({
1220
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1221
- body: query,
2159
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2160
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
1222
2161
  ...this.extraProps
1223
2162
  });
1224
2163
  }
1225
- searchBranch(workspace, database, branch, query) {
2164
+ searchBranch({
2165
+ workspace,
2166
+ region,
2167
+ database,
2168
+ branch,
2169
+ tables,
2170
+ query,
2171
+ fuzziness,
2172
+ prefix,
2173
+ highlight
2174
+ }) {
1226
2175
  return operationsByTag.searchAndFilter.searchBranch({
1227
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1228
- body: query,
2176
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2177
+ body: { tables, query, fuzziness, prefix, highlight },
1229
2178
  ...this.extraProps
1230
2179
  });
1231
2180
  }
1232
- summarizeTable(workspace, database, branch, tableName, query) {
2181
+ vectorSearchTable({
2182
+ workspace,
2183
+ region,
2184
+ database,
2185
+ branch,
2186
+ table,
2187
+ queryVector,
2188
+ column,
2189
+ similarityFunction,
2190
+ size,
2191
+ filter
2192
+ }) {
2193
+ return operationsByTag.searchAndFilter.vectorSearchTable({
2194
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2195
+ body: { queryVector, column, similarityFunction, size, filter },
2196
+ ...this.extraProps
2197
+ });
2198
+ }
2199
+ askTable({
2200
+ workspace,
2201
+ region,
2202
+ database,
2203
+ branch,
2204
+ table,
2205
+ options
2206
+ }) {
2207
+ return operationsByTag.searchAndFilter.askTable({
2208
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2209
+ body: { ...options },
2210
+ ...this.extraProps
2211
+ });
2212
+ }
2213
+ askTableSession({
2214
+ workspace,
2215
+ region,
2216
+ database,
2217
+ branch,
2218
+ table,
2219
+ sessionId,
2220
+ message
2221
+ }) {
2222
+ return operationsByTag.searchAndFilter.askTableSession({
2223
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
2224
+ body: { message },
2225
+ ...this.extraProps
2226
+ });
2227
+ }
2228
+ summarizeTable({
2229
+ workspace,
2230
+ region,
2231
+ database,
2232
+ branch,
2233
+ table,
2234
+ filter,
2235
+ columns,
2236
+ summaries,
2237
+ sort,
2238
+ summariesFilter,
2239
+ page,
2240
+ consistency
2241
+ }) {
1233
2242
  return operationsByTag.searchAndFilter.summarizeTable({
1234
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1235
- body: query,
2243
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2244
+ body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
1236
2245
  ...this.extraProps
1237
2246
  });
1238
2247
  }
1239
- aggregateTable(workspace, database, branch, tableName, query) {
2248
+ aggregateTable({
2249
+ workspace,
2250
+ region,
2251
+ database,
2252
+ branch,
2253
+ table,
2254
+ filter,
2255
+ aggs
2256
+ }) {
1240
2257
  return operationsByTag.searchAndFilter.aggregateTable({
1241
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1242
- body: query,
2258
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2259
+ body: { filter, aggs },
1243
2260
  ...this.extraProps
1244
2261
  });
1245
2262
  }
@@ -1248,55 +2265,100 @@ class MigrationRequestsApi {
1248
2265
  constructor(extraProps) {
1249
2266
  this.extraProps = extraProps;
1250
2267
  }
1251
- queryMigrationRequests(workspace, database, options = {}) {
2268
+ queryMigrationRequests({
2269
+ workspace,
2270
+ region,
2271
+ database,
2272
+ filter,
2273
+ sort,
2274
+ page,
2275
+ columns
2276
+ }) {
1252
2277
  return operationsByTag.migrationRequests.queryMigrationRequests({
1253
- pathParams: { workspace, dbName: database },
1254
- body: options,
2278
+ pathParams: { workspace, region, dbName: database },
2279
+ body: { filter, sort, page, columns },
1255
2280
  ...this.extraProps
1256
2281
  });
1257
2282
  }
1258
- createMigrationRequest(workspace, database, options) {
2283
+ createMigrationRequest({
2284
+ workspace,
2285
+ region,
2286
+ database,
2287
+ migration
2288
+ }) {
1259
2289
  return operationsByTag.migrationRequests.createMigrationRequest({
1260
- pathParams: { workspace, dbName: database },
1261
- body: options,
2290
+ pathParams: { workspace, region, dbName: database },
2291
+ body: migration,
1262
2292
  ...this.extraProps
1263
2293
  });
1264
2294
  }
1265
- getMigrationRequest(workspace, database, migrationRequest) {
2295
+ getMigrationRequest({
2296
+ workspace,
2297
+ region,
2298
+ database,
2299
+ migrationRequest
2300
+ }) {
1266
2301
  return operationsByTag.migrationRequests.getMigrationRequest({
1267
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
2302
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1268
2303
  ...this.extraProps
1269
2304
  });
1270
2305
  }
1271
- updateMigrationRequest(workspace, database, migrationRequest, options) {
2306
+ updateMigrationRequest({
2307
+ workspace,
2308
+ region,
2309
+ database,
2310
+ migrationRequest,
2311
+ update
2312
+ }) {
1272
2313
  return operationsByTag.migrationRequests.updateMigrationRequest({
1273
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1274
- body: options,
2314
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
2315
+ body: update,
1275
2316
  ...this.extraProps
1276
2317
  });
1277
2318
  }
1278
- listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
2319
+ listMigrationRequestsCommits({
2320
+ workspace,
2321
+ region,
2322
+ database,
2323
+ migrationRequest,
2324
+ page
2325
+ }) {
1279
2326
  return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1280
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1281
- body: options,
2327
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
2328
+ body: { page },
1282
2329
  ...this.extraProps
1283
2330
  });
1284
2331
  }
1285
- compareMigrationRequest(workspace, database, migrationRequest) {
2332
+ compareMigrationRequest({
2333
+ workspace,
2334
+ region,
2335
+ database,
2336
+ migrationRequest
2337
+ }) {
1286
2338
  return operationsByTag.migrationRequests.compareMigrationRequest({
1287
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
2339
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1288
2340
  ...this.extraProps
1289
2341
  });
1290
2342
  }
1291
- getMigrationRequestIsMerged(workspace, database, migrationRequest) {
2343
+ getMigrationRequestIsMerged({
2344
+ workspace,
2345
+ region,
2346
+ database,
2347
+ migrationRequest
2348
+ }) {
1292
2349
  return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1293
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
2350
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1294
2351
  ...this.extraProps
1295
2352
  });
1296
2353
  }
1297
- mergeMigrationRequest(workspace, database, migrationRequest) {
2354
+ mergeMigrationRequest({
2355
+ workspace,
2356
+ region,
2357
+ database,
2358
+ migrationRequest
2359
+ }) {
1298
2360
  return operationsByTag.migrationRequests.mergeMigrationRequest({
1299
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
2361
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1300
2362
  ...this.extraProps
1301
2363
  });
1302
2364
  }
@@ -1305,138 +2367,532 @@ class MigrationsApi {
1305
2367
  constructor(extraProps) {
1306
2368
  this.extraProps = extraProps;
1307
2369
  }
1308
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
2370
+ getBranchMigrationHistory({
2371
+ workspace,
2372
+ region,
2373
+ database,
2374
+ branch,
2375
+ limit,
2376
+ startFrom
2377
+ }) {
1309
2378
  return operationsByTag.migrations.getBranchMigrationHistory({
1310
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1311
- body: options,
2379
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2380
+ body: { limit, startFrom },
1312
2381
  ...this.extraProps
1313
2382
  });
1314
2383
  }
1315
- getBranchMigrationPlan(workspace, database, branch, schema) {
2384
+ getBranchMigrationPlan({
2385
+ workspace,
2386
+ region,
2387
+ database,
2388
+ branch,
2389
+ schema
2390
+ }) {
1316
2391
  return operationsByTag.migrations.getBranchMigrationPlan({
1317
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
2392
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1318
2393
  body: schema,
1319
2394
  ...this.extraProps
1320
2395
  });
1321
2396
  }
1322
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
2397
+ executeBranchMigrationPlan({
2398
+ workspace,
2399
+ region,
2400
+ database,
2401
+ branch,
2402
+ plan
2403
+ }) {
1323
2404
  return operationsByTag.migrations.executeBranchMigrationPlan({
1324
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1325
- body: migrationPlan,
2405
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2406
+ body: plan,
1326
2407
  ...this.extraProps
1327
2408
  });
1328
2409
  }
1329
- getBranchSchemaHistory(workspace, database, branch, options = {}) {
2410
+ getBranchSchemaHistory({
2411
+ workspace,
2412
+ region,
2413
+ database,
2414
+ branch,
2415
+ page
2416
+ }) {
1330
2417
  return operationsByTag.migrations.getBranchSchemaHistory({
1331
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1332
- body: options,
2418
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2419
+ body: { page },
1333
2420
  ...this.extraProps
1334
2421
  });
1335
2422
  }
1336
- compareBranchWithUserSchema(workspace, database, branch, schema) {
2423
+ compareBranchWithUserSchema({
2424
+ workspace,
2425
+ region,
2426
+ database,
2427
+ branch,
2428
+ schema,
2429
+ schemaOperations,
2430
+ branchOperations
2431
+ }) {
1337
2432
  return operationsByTag.migrations.compareBranchWithUserSchema({
1338
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1339
- body: { schema },
2433
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2434
+ body: { schema, schemaOperations, branchOperations },
1340
2435
  ...this.extraProps
1341
2436
  });
1342
2437
  }
1343
- compareBranchSchemas(workspace, database, branch, branchName, schema) {
2438
+ compareBranchSchemas({
2439
+ workspace,
2440
+ region,
2441
+ database,
2442
+ branch,
2443
+ compare,
2444
+ sourceBranchOperations,
2445
+ targetBranchOperations
2446
+ }) {
1344
2447
  return operationsByTag.migrations.compareBranchSchemas({
1345
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1346
- body: { schema },
2448
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
2449
+ body: { sourceBranchOperations, targetBranchOperations },
1347
2450
  ...this.extraProps
1348
2451
  });
1349
2452
  }
1350
- updateBranchSchema(workspace, database, branch, migration) {
2453
+ updateBranchSchema({
2454
+ workspace,
2455
+ region,
2456
+ database,
2457
+ branch,
2458
+ migration
2459
+ }) {
1351
2460
  return operationsByTag.migrations.updateBranchSchema({
1352
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
2461
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1353
2462
  body: migration,
1354
2463
  ...this.extraProps
1355
2464
  });
1356
2465
  }
1357
- previewBranchSchemaEdit(workspace, database, branch, migration) {
2466
+ previewBranchSchemaEdit({
2467
+ workspace,
2468
+ region,
2469
+ database,
2470
+ branch,
2471
+ data
2472
+ }) {
1358
2473
  return operationsByTag.migrations.previewBranchSchemaEdit({
1359
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1360
- body: migration,
2474
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2475
+ body: data,
1361
2476
  ...this.extraProps
1362
2477
  });
1363
2478
  }
1364
- applyBranchSchemaEdit(workspace, database, branch, edits) {
2479
+ applyBranchSchemaEdit({
2480
+ workspace,
2481
+ region,
2482
+ database,
2483
+ branch,
2484
+ edits
2485
+ }) {
1365
2486
  return operationsByTag.migrations.applyBranchSchemaEdit({
1366
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
2487
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1367
2488
  body: { edits },
1368
2489
  ...this.extraProps
1369
2490
  });
1370
2491
  }
2492
+ pushBranchMigrations({
2493
+ workspace,
2494
+ region,
2495
+ database,
2496
+ branch,
2497
+ migrations
2498
+ }) {
2499
+ return operationsByTag.migrations.pushBranchMigrations({
2500
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2501
+ body: { migrations },
2502
+ ...this.extraProps
2503
+ });
2504
+ }
1371
2505
  }
1372
- class DatabasesApi {
2506
+ class DatabaseApi {
1373
2507
  constructor(extraProps) {
1374
2508
  this.extraProps = extraProps;
1375
2509
  }
1376
- getDatabaseList(workspaceId) {
1377
- return operationsByTag.databases.cPGetDatabaseList({
1378
- pathParams: { workspaceId },
2510
+ getDatabaseList({ workspace }) {
2511
+ return operationsByTag.databases.getDatabaseList({
2512
+ pathParams: { workspaceId: workspace },
2513
+ ...this.extraProps
2514
+ });
2515
+ }
2516
+ createDatabase({
2517
+ workspace,
2518
+ database,
2519
+ data,
2520
+ headers
2521
+ }) {
2522
+ return operationsByTag.databases.createDatabase({
2523
+ pathParams: { workspaceId: workspace, dbName: database },
2524
+ body: data,
2525
+ headers,
2526
+ ...this.extraProps
2527
+ });
2528
+ }
2529
+ deleteDatabase({
2530
+ workspace,
2531
+ database
2532
+ }) {
2533
+ return operationsByTag.databases.deleteDatabase({
2534
+ pathParams: { workspaceId: workspace, dbName: database },
2535
+ ...this.extraProps
2536
+ });
2537
+ }
2538
+ getDatabaseMetadata({
2539
+ workspace,
2540
+ database
2541
+ }) {
2542
+ return operationsByTag.databases.getDatabaseMetadata({
2543
+ pathParams: { workspaceId: workspace, dbName: database },
2544
+ ...this.extraProps
2545
+ });
2546
+ }
2547
+ updateDatabaseMetadata({
2548
+ workspace,
2549
+ database,
2550
+ metadata
2551
+ }) {
2552
+ return operationsByTag.databases.updateDatabaseMetadata({
2553
+ pathParams: { workspaceId: workspace, dbName: database },
2554
+ body: metadata,
1379
2555
  ...this.extraProps
1380
2556
  });
1381
2557
  }
1382
- createDatabase(workspaceId, dbName, options) {
1383
- return operationsByTag.databases.cPCreateDatabase({
1384
- pathParams: { workspaceId, dbName },
1385
- body: options,
2558
+ renameDatabase({
2559
+ workspace,
2560
+ database,
2561
+ newName
2562
+ }) {
2563
+ return operationsByTag.databases.renameDatabase({
2564
+ pathParams: { workspaceId: workspace, dbName: database },
2565
+ body: { newName },
1386
2566
  ...this.extraProps
1387
2567
  });
1388
2568
  }
1389
- deleteDatabase(workspaceId, dbName) {
1390
- return operationsByTag.databases.cPDeleteDatabase({
1391
- pathParams: { workspaceId, dbName },
2569
+ getDatabaseGithubSettings({
2570
+ workspace,
2571
+ database
2572
+ }) {
2573
+ return operationsByTag.databases.getDatabaseGithubSettings({
2574
+ pathParams: { workspaceId: workspace, dbName: database },
1392
2575
  ...this.extraProps
1393
2576
  });
1394
2577
  }
1395
- getDatabaseMetadata(workspaceId, dbName) {
1396
- return operationsByTag.databases.cPGetCPDatabaseMetadata({
1397
- pathParams: { workspaceId, dbName },
2578
+ updateDatabaseGithubSettings({
2579
+ workspace,
2580
+ database,
2581
+ settings
2582
+ }) {
2583
+ return operationsByTag.databases.updateDatabaseGithubSettings({
2584
+ pathParams: { workspaceId: workspace, dbName: database },
2585
+ body: settings,
1398
2586
  ...this.extraProps
1399
2587
  });
1400
2588
  }
1401
- updateDatabaseMetadata(workspaceId, dbName, metadata) {
1402
- return operationsByTag.databases.cPUpdateCPDatabaseMetadata({
1403
- pathParams: { workspaceId, dbName },
1404
- body: metadata,
1405
- ...this.extraProps
1406
- });
2589
+ deleteDatabaseGithubSettings({
2590
+ workspace,
2591
+ database
2592
+ }) {
2593
+ return operationsByTag.databases.deleteDatabaseGithubSettings({
2594
+ pathParams: { workspaceId: workspace, dbName: database },
2595
+ ...this.extraProps
2596
+ });
2597
+ }
2598
+ listRegions({ workspace }) {
2599
+ return operationsByTag.databases.listRegions({
2600
+ pathParams: { workspaceId: workspace },
2601
+ ...this.extraProps
2602
+ });
2603
+ }
2604
+ }
2605
+
2606
+ class XataApiPlugin {
2607
+ build(options) {
2608
+ return new XataApiClient(options);
2609
+ }
2610
+ }
2611
+
2612
+ class XataPlugin {
2613
+ }
2614
+
2615
+ class FilesPlugin extends XataPlugin {
2616
+ build(pluginOptions) {
2617
+ return {
2618
+ download: async (location) => {
2619
+ const { table, record, column, fileId = "" } = location ?? {};
2620
+ return await getFileItem({
2621
+ pathParams: {
2622
+ workspace: "{workspaceId}",
2623
+ dbBranchName: "{dbBranch}",
2624
+ region: "{region}",
2625
+ tableName: table ?? "",
2626
+ recordId: record ?? "",
2627
+ columnName: column ?? "",
2628
+ fileId
2629
+ },
2630
+ ...pluginOptions,
2631
+ rawResponse: true
2632
+ });
2633
+ },
2634
+ upload: async (location, file) => {
2635
+ const { table, record, column, fileId = "" } = location ?? {};
2636
+ const contentType = getContentType(file);
2637
+ return await putFileItem({
2638
+ ...pluginOptions,
2639
+ pathParams: {
2640
+ workspace: "{workspaceId}",
2641
+ dbBranchName: "{dbBranch}",
2642
+ region: "{region}",
2643
+ tableName: table ?? "",
2644
+ recordId: record ?? "",
2645
+ columnName: column ?? "",
2646
+ fileId
2647
+ },
2648
+ body: file,
2649
+ headers: { "Content-Type": contentType }
2650
+ });
2651
+ },
2652
+ delete: async (location) => {
2653
+ const { table, record, column, fileId = "" } = location ?? {};
2654
+ return await deleteFileItem({
2655
+ pathParams: {
2656
+ workspace: "{workspaceId}",
2657
+ dbBranchName: "{dbBranch}",
2658
+ region: "{region}",
2659
+ tableName: table ?? "",
2660
+ recordId: record ?? "",
2661
+ columnName: column ?? "",
2662
+ fileId
2663
+ },
2664
+ ...pluginOptions
2665
+ });
2666
+ }
2667
+ };
2668
+ }
2669
+ }
2670
+ function getContentType(file) {
2671
+ if (typeof file === "string") {
2672
+ return "text/plain";
2673
+ }
2674
+ if (file instanceof Blob) {
2675
+ return file.type;
2676
+ }
2677
+ try {
2678
+ return file.type;
2679
+ } catch (e) {
2680
+ }
2681
+ return "application/octet-stream";
2682
+ }
2683
+
2684
+ function buildTransformString(transformations) {
2685
+ return transformations.flatMap(
2686
+ (t) => Object.entries(t).map(([key, value]) => {
2687
+ if (key === "trim") {
2688
+ const { left = 0, top = 0, right = 0, bottom = 0 } = value;
2689
+ return `${key}=${[top, right, bottom, left].join(";")}`;
2690
+ }
2691
+ if (key === "gravity" && typeof value === "object") {
2692
+ const { x = 0.5, y = 0.5 } = value;
2693
+ return `${key}=${[x, y].join("x")}`;
2694
+ }
2695
+ return `${key}=${value}`;
2696
+ })
2697
+ ).join(",");
2698
+ }
2699
+ function transformImage(url, ...transformations) {
2700
+ if (!isDefined(url))
2701
+ return void 0;
2702
+ const newTransformations = buildTransformString(transformations);
2703
+ const { hostname, pathname, search } = new URL(url);
2704
+ const pathParts = pathname.split("/");
2705
+ const transformIndex = pathParts.findIndex((part) => part === "transform");
2706
+ const removedItems = transformIndex >= 0 ? pathParts.splice(transformIndex, 2) : [];
2707
+ const transform = `/transform/${[removedItems[1], newTransformations].filter(isDefined).join(",")}`;
2708
+ const path = pathParts.join("/");
2709
+ return `https://${hostname}${transform}${path}${search}`;
2710
+ }
2711
+
2712
+ var __defProp$6 = Object.defineProperty;
2713
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2714
+ var __publicField$6 = (obj, key, value) => {
2715
+ __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
2716
+ return value;
2717
+ };
2718
+ class XataFile {
2719
+ constructor(file) {
2720
+ /**
2721
+ * Name of this file.
2722
+ */
2723
+ __publicField$6(this, "name");
2724
+ /**
2725
+ * Media type of this file.
2726
+ */
2727
+ __publicField$6(this, "mediaType");
2728
+ /**
2729
+ * Base64 encoded content of this file.
2730
+ */
2731
+ __publicField$6(this, "base64Content");
2732
+ /**
2733
+ * Whether to enable public url for this file.
2734
+ */
2735
+ __publicField$6(this, "enablePublicUrl");
2736
+ /**
2737
+ * Timeout for the signed url.
2738
+ */
2739
+ __publicField$6(this, "signedUrlTimeout");
2740
+ /**
2741
+ * Size of this file.
2742
+ */
2743
+ __publicField$6(this, "size");
2744
+ /**
2745
+ * Version of this file.
2746
+ */
2747
+ __publicField$6(this, "version");
2748
+ /**
2749
+ * Url of this file.
2750
+ */
2751
+ __publicField$6(this, "url");
2752
+ /**
2753
+ * Signed url of this file.
2754
+ */
2755
+ __publicField$6(this, "signedUrl");
2756
+ /**
2757
+ * Attributes of this file.
2758
+ */
2759
+ __publicField$6(this, "attributes");
2760
+ this.name = file.name || "";
2761
+ this.mediaType = file.mediaType || "application/octet-stream";
2762
+ this.base64Content = file.base64Content;
2763
+ this.enablePublicUrl = file.enablePublicUrl ?? false;
2764
+ this.signedUrlTimeout = file.signedUrlTimeout ?? 300;
2765
+ this.size = file.size ?? 0;
2766
+ this.version = file.version ?? 1;
2767
+ this.url = file.url || "";
2768
+ this.signedUrl = file.signedUrl;
2769
+ this.attributes = file.attributes || {};
2770
+ }
2771
+ static fromBuffer(buffer, options = {}) {
2772
+ const base64Content = buffer.toString("base64");
2773
+ return new XataFile({ ...options, base64Content });
2774
+ }
2775
+ toBuffer() {
2776
+ if (!this.base64Content) {
2777
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2778
+ }
2779
+ return Buffer.from(this.base64Content, "base64");
2780
+ }
2781
+ static fromArrayBuffer(arrayBuffer, options = {}) {
2782
+ const uint8Array = new Uint8Array(arrayBuffer);
2783
+ return this.fromUint8Array(uint8Array, options);
2784
+ }
2785
+ toArrayBuffer() {
2786
+ if (!this.base64Content) {
2787
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2788
+ }
2789
+ const binary = atob(this.base64Content);
2790
+ return new ArrayBuffer(binary.length);
2791
+ }
2792
+ static fromUint8Array(uint8Array, options = {}) {
2793
+ let binary = "";
2794
+ for (let i = 0; i < uint8Array.byteLength; i++) {
2795
+ binary += String.fromCharCode(uint8Array[i]);
2796
+ }
2797
+ const base64Content = btoa(binary);
2798
+ return new XataFile({ ...options, base64Content });
2799
+ }
2800
+ toUint8Array() {
2801
+ if (!this.base64Content) {
2802
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2803
+ }
2804
+ const binary = atob(this.base64Content);
2805
+ const uint8Array = new Uint8Array(binary.length);
2806
+ for (let i = 0; i < binary.length; i++) {
2807
+ uint8Array[i] = binary.charCodeAt(i);
2808
+ }
2809
+ return uint8Array;
2810
+ }
2811
+ static async fromBlob(file, options = {}) {
2812
+ const name = options.name ?? file.name;
2813
+ const mediaType = file.type;
2814
+ const arrayBuffer = await file.arrayBuffer();
2815
+ return this.fromArrayBuffer(arrayBuffer, { ...options, name, mediaType });
2816
+ }
2817
+ toBlob() {
2818
+ if (!this.base64Content) {
2819
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2820
+ }
2821
+ const binary = atob(this.base64Content);
2822
+ const uint8Array = new Uint8Array(binary.length);
2823
+ for (let i = 0; i < binary.length; i++) {
2824
+ uint8Array[i] = binary.charCodeAt(i);
2825
+ }
2826
+ return new Blob([uint8Array], { type: this.mediaType });
2827
+ }
2828
+ static fromString(string, options = {}) {
2829
+ const base64Content = btoa(string);
2830
+ return new XataFile({ ...options, base64Content });
2831
+ }
2832
+ toString() {
2833
+ if (!this.base64Content) {
2834
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2835
+ }
2836
+ return atob(this.base64Content);
1407
2837
  }
1408
- listRegions(workspaceId) {
1409
- return operationsByTag.databases.listRegions({
1410
- pathParams: { workspaceId },
1411
- ...this.extraProps
1412
- });
2838
+ static fromBase64(base64Content, options = {}) {
2839
+ return new XataFile({ ...options, base64Content });
1413
2840
  }
1414
- }
1415
-
1416
- class XataApiPlugin {
1417
- async build(options) {
1418
- const { fetchImpl, apiKey } = await options.getFetchProps();
1419
- return new XataApiClient({ fetch: fetchImpl, apiKey });
2841
+ toBase64() {
2842
+ if (!this.base64Content) {
2843
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2844
+ }
2845
+ return this.base64Content;
2846
+ }
2847
+ transform(...options) {
2848
+ return {
2849
+ url: transformImage(this.url, ...options),
2850
+ signedUrl: transformImage(this.signedUrl, ...options),
2851
+ metadataUrl: transformImage(this.url, ...options, { format: "json" }),
2852
+ metadataSignedUrl: transformImage(this.signedUrl, ...options, { format: "json" })
2853
+ };
1420
2854
  }
1421
2855
  }
1422
-
1423
- class XataPlugin {
1424
- }
1425
-
1426
- function generateUUID() {
1427
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
1428
- const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
1429
- return v.toString(16);
1430
- });
1431
- }
2856
+ const parseInputFileEntry = async (entry) => {
2857
+ if (!isDefined(entry))
2858
+ return null;
2859
+ const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
2860
+ return compactObject({ id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout });
2861
+ };
1432
2862
 
1433
2863
  function cleanFilter(filter) {
1434
- if (!filter)
2864
+ if (!isDefined(filter))
1435
2865
  return void 0;
1436
- const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
1437
- return values.length > 0 ? filter : void 0;
2866
+ if (!isObject(filter))
2867
+ return filter;
2868
+ const values = Object.fromEntries(
2869
+ Object.entries(filter).reduce((acc, [key, value]) => {
2870
+ if (!isDefined(value))
2871
+ return acc;
2872
+ if (Array.isArray(value)) {
2873
+ const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
2874
+ if (clean.length === 0)
2875
+ return acc;
2876
+ return [...acc, [key, clean]];
2877
+ }
2878
+ if (isObject(value)) {
2879
+ const clean = cleanFilter(value);
2880
+ if (!isDefined(clean))
2881
+ return acc;
2882
+ return [...acc, [key, clean]];
2883
+ }
2884
+ return [...acc, [key, value]];
2885
+ }, [])
2886
+ );
2887
+ return Object.keys(values).length > 0 ? values : void 0;
1438
2888
  }
1439
2889
 
2890
+ var __defProp$5 = Object.defineProperty;
2891
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2892
+ var __publicField$5 = (obj, key, value) => {
2893
+ __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
2894
+ return value;
2895
+ };
1440
2896
  var __accessCheck$6 = (obj, member, msg) => {
1441
2897
  if (!member.has(obj))
1442
2898
  throw TypeError("Cannot " + msg);
@@ -1459,22 +2915,58 @@ var _query, _page;
1459
2915
  class Page {
1460
2916
  constructor(query, meta, records = []) {
1461
2917
  __privateAdd$6(this, _query, void 0);
2918
+ /**
2919
+ * Page metadata, required to retrieve additional records.
2920
+ */
2921
+ __publicField$5(this, "meta");
2922
+ /**
2923
+ * The set of results for this page.
2924
+ */
2925
+ __publicField$5(this, "records");
1462
2926
  __privateSet$6(this, _query, query);
1463
2927
  this.meta = meta;
1464
2928
  this.records = new RecordArray(this, records);
1465
2929
  }
2930
+ /**
2931
+ * Retrieves the next page of results.
2932
+ * @param size Maximum number of results to be retrieved.
2933
+ * @param offset Number of results to skip when retrieving the results.
2934
+ * @returns The next page or results.
2935
+ */
1466
2936
  async nextPage(size, offset) {
1467
2937
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
1468
2938
  }
2939
+ /**
2940
+ * Retrieves the previous page of results.
2941
+ * @param size Maximum number of results to be retrieved.
2942
+ * @param offset Number of results to skip when retrieving the results.
2943
+ * @returns The previous page or results.
2944
+ */
1469
2945
  async previousPage(size, offset) {
1470
2946
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
1471
2947
  }
1472
- async firstPage(size, offset) {
1473
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
1474
- }
1475
- async lastPage(size, offset) {
1476
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
1477
- }
2948
+ /**
2949
+ * Retrieves the start page of results.
2950
+ * @param size Maximum number of results to be retrieved.
2951
+ * @param offset Number of results to skip when retrieving the results.
2952
+ * @returns The start page or results.
2953
+ */
2954
+ async startPage(size, offset) {
2955
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
2956
+ }
2957
+ /**
2958
+ * Retrieves the end page of results.
2959
+ * @param size Maximum number of results to be retrieved.
2960
+ * @param offset Number of results to skip when retrieving the results.
2961
+ * @returns The end page or results.
2962
+ */
2963
+ async endPage(size, offset) {
2964
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
2965
+ }
2966
+ /**
2967
+ * Shortcut method to check if there will be additional results if the next page of results is retrieved.
2968
+ * @returns Whether or not there will be additional results in the next page of results.
2969
+ */
1478
2970
  hasNextPage() {
1479
2971
  return this.meta.page.more;
1480
2972
  }
@@ -1485,9 +2977,9 @@ const PAGINATION_DEFAULT_SIZE = 20;
1485
2977
  const PAGINATION_MAX_OFFSET = 800;
1486
2978
  const PAGINATION_DEFAULT_OFFSET = 0;
1487
2979
  function isCursorPaginationOptions(options) {
1488
- return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
2980
+ return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
1489
2981
  }
1490
- const _RecordArray = class extends Array {
2982
+ const _RecordArray = class _RecordArray extends Array {
1491
2983
  constructor(...args) {
1492
2984
  super(..._RecordArray.parseConstructorParams(...args));
1493
2985
  __privateAdd$6(this, _page, void 0);
@@ -1506,32 +2998,67 @@ const _RecordArray = class extends Array {
1506
2998
  toArray() {
1507
2999
  return new Array(...this);
1508
3000
  }
3001
+ toSerializable() {
3002
+ return JSON.parse(this.toString());
3003
+ }
3004
+ toString() {
3005
+ return JSON.stringify(this.toArray());
3006
+ }
1509
3007
  map(callbackfn, thisArg) {
1510
3008
  return this.toArray().map(callbackfn, thisArg);
1511
3009
  }
3010
+ /**
3011
+ * Retrieve next page of records
3012
+ *
3013
+ * @returns A new array of objects
3014
+ */
1512
3015
  async nextPage(size, offset) {
1513
3016
  const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
1514
3017
  return new _RecordArray(newPage);
1515
3018
  }
3019
+ /**
3020
+ * Retrieve previous page of records
3021
+ *
3022
+ * @returns A new array of objects
3023
+ */
1516
3024
  async previousPage(size, offset) {
1517
3025
  const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
1518
3026
  return new _RecordArray(newPage);
1519
3027
  }
1520
- async firstPage(size, offset) {
1521
- const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
3028
+ /**
3029
+ * Retrieve start page of records
3030
+ *
3031
+ * @returns A new array of objects
3032
+ */
3033
+ async startPage(size, offset) {
3034
+ const newPage = await __privateGet$6(this, _page).startPage(size, offset);
1522
3035
  return new _RecordArray(newPage);
1523
3036
  }
1524
- async lastPage(size, offset) {
1525
- const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
3037
+ /**
3038
+ * Retrieve end page of records
3039
+ *
3040
+ * @returns A new array of objects
3041
+ */
3042
+ async endPage(size, offset) {
3043
+ const newPage = await __privateGet$6(this, _page).endPage(size, offset);
1526
3044
  return new _RecordArray(newPage);
1527
3045
  }
3046
+ /**
3047
+ * @returns Boolean indicating if there is a next page
3048
+ */
1528
3049
  hasNextPage() {
1529
3050
  return __privateGet$6(this, _page).meta.page.more;
1530
3051
  }
1531
3052
  };
1532
- let RecordArray = _RecordArray;
1533
3053
  _page = new WeakMap();
3054
+ let RecordArray = _RecordArray;
1534
3055
 
3056
+ var __defProp$4 = Object.defineProperty;
3057
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3058
+ var __publicField$4 = (obj, key, value) => {
3059
+ __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
3060
+ return value;
3061
+ };
1535
3062
  var __accessCheck$5 = (obj, member, msg) => {
1536
3063
  if (!member.has(obj))
1537
3064
  throw TypeError("Cannot " + msg);
@@ -1555,14 +3082,15 @@ var __privateMethod$3 = (obj, member, method) => {
1555
3082
  return method;
1556
3083
  };
1557
3084
  var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
1558
- const _Query = class {
3085
+ const _Query = class _Query {
1559
3086
  constructor(repository, table, data, rawParent) {
1560
3087
  __privateAdd$5(this, _cleanFilterConstraint);
1561
3088
  __privateAdd$5(this, _table$1, void 0);
1562
3089
  __privateAdd$5(this, _repository, void 0);
1563
3090
  __privateAdd$5(this, _data, { filter: {} });
1564
- this.meta = { page: { cursor: "start", more: true } };
1565
- this.records = new RecordArray(this, []);
3091
+ // Implements pagination
3092
+ __publicField$4(this, "meta", { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } });
3093
+ __publicField$4(this, "records", new RecordArray(this, []));
1566
3094
  __privateSet$5(this, _table$1, table);
1567
3095
  if (repository) {
1568
3096
  __privateSet$5(this, _repository, repository);
@@ -1577,8 +3105,10 @@ const _Query = class {
1577
3105
  __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
1578
3106
  __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
1579
3107
  __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
3108
+ __privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
1580
3109
  __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
1581
3110
  __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
3111
+ __privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
1582
3112
  this.any = this.any.bind(this);
1583
3113
  this.all = this.all.bind(this);
1584
3114
  this.not = this.not.bind(this);
@@ -1596,18 +3126,38 @@ const _Query = class {
1596
3126
  const key = JSON.stringify({ columns, filter, sort, pagination });
1597
3127
  return toBase64(key);
1598
3128
  }
3129
+ /**
3130
+ * Builds a new query object representing a logical OR between the given subqueries.
3131
+ * @param queries An array of subqueries.
3132
+ * @returns A new Query object.
3133
+ */
1599
3134
  any(...queries) {
1600
3135
  const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
1601
3136
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
1602
3137
  }
3138
+ /**
3139
+ * Builds a new query object representing a logical AND between the given subqueries.
3140
+ * @param queries An array of subqueries.
3141
+ * @returns A new Query object.
3142
+ */
1603
3143
  all(...queries) {
1604
3144
  const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
1605
3145
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1606
3146
  }
3147
+ /**
3148
+ * Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
3149
+ * @param queries An array of subqueries.
3150
+ * @returns A new Query object.
3151
+ */
1607
3152
  not(...queries) {
1608
3153
  const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
1609
3154
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
1610
3155
  }
3156
+ /**
3157
+ * Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
3158
+ * @param queries An array of subqueries.
3159
+ * @returns A new Query object.
3160
+ */
1611
3161
  none(...queries) {
1612
3162
  const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
1613
3163
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
@@ -1630,6 +3180,11 @@ const _Query = class {
1630
3180
  const sort = [...originalSort, { column, direction }];
1631
3181
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
1632
3182
  }
3183
+ /**
3184
+ * Builds a new query specifying the set of columns to be returned in the query response.
3185
+ * @param columns Array of column names to be returned by the query.
3186
+ * @returns A new Query object.
3187
+ */
1633
3188
  select(columns) {
1634
3189
  return new _Query(
1635
3190
  __privateGet$5(this, _repository),
@@ -1642,6 +3197,12 @@ const _Query = class {
1642
3197
  const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
1643
3198
  return __privateGet$5(this, _repository).query(query);
1644
3199
  }
3200
+ /**
3201
+ * Get results in an iterator
3202
+ *
3203
+ * @async
3204
+ * @returns Async interable of results
3205
+ */
1645
3206
  async *[Symbol.asyncIterator]() {
1646
3207
  for await (const [record] of this.getIterator({ batchSize: 1 })) {
1647
3208
  yield record;
@@ -1702,26 +3263,53 @@ const _Query = class {
1702
3263
  );
1703
3264
  return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
1704
3265
  }
3266
+ /**
3267
+ * Builds a new query object adding a cache TTL in milliseconds.
3268
+ * @param ttl The cache TTL in milliseconds.
3269
+ * @returns A new Query object.
3270
+ */
1705
3271
  cache(ttl) {
1706
3272
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1707
3273
  }
3274
+ /**
3275
+ * Retrieve next page of records
3276
+ *
3277
+ * @returns A new page object.
3278
+ */
1708
3279
  nextPage(size, offset) {
1709
- return this.firstPage(size, offset);
3280
+ return this.startPage(size, offset);
1710
3281
  }
3282
+ /**
3283
+ * Retrieve previous page of records
3284
+ *
3285
+ * @returns A new page object
3286
+ */
1711
3287
  previousPage(size, offset) {
1712
- return this.firstPage(size, offset);
1713
- }
1714
- firstPage(size, offset) {
3288
+ return this.startPage(size, offset);
3289
+ }
3290
+ /**
3291
+ * Retrieve start page of records
3292
+ *
3293
+ * @returns A new page object
3294
+ */
3295
+ startPage(size, offset) {
1715
3296
  return this.getPaginated({ pagination: { size, offset } });
1716
3297
  }
1717
- lastPage(size, offset) {
3298
+ /**
3299
+ * Retrieve last page of records
3300
+ *
3301
+ * @returns A new page object
3302
+ */
3303
+ endPage(size, offset) {
1718
3304
  return this.getPaginated({ pagination: { size, offset, before: "end" } });
1719
3305
  }
3306
+ /**
3307
+ * @returns Boolean indicating if there is a next page
3308
+ */
1720
3309
  hasNextPage() {
1721
3310
  return this.meta.page.more;
1722
3311
  }
1723
3312
  };
1724
- let Query = _Query;
1725
3313
  _table$1 = new WeakMap();
1726
3314
  _repository = new WeakMap();
1727
3315
  _data = new WeakMap();
@@ -1736,13 +3324,30 @@ cleanFilterConstraint_fn = function(column, value) {
1736
3324
  }
1737
3325
  return value;
1738
3326
  };
3327
+ let Query = _Query;
1739
3328
  function cleanParent(data, parent) {
1740
3329
  if (isCursorPaginationOptions(data.pagination)) {
1741
- return { ...parent, sorting: void 0, filter: void 0 };
3330
+ return { ...parent, sort: void 0, filter: void 0 };
1742
3331
  }
1743
3332
  return parent;
1744
3333
  }
1745
3334
 
3335
+ const RecordColumnTypes = [
3336
+ "bool",
3337
+ "int",
3338
+ "float",
3339
+ "string",
3340
+ "text",
3341
+ "email",
3342
+ "multiple",
3343
+ "link",
3344
+ "object",
3345
+ "datetime",
3346
+ "vector",
3347
+ "file[]",
3348
+ "file",
3349
+ "json"
3350
+ ];
1746
3351
  function isIdentifiable(x) {
1747
3352
  return isObject(x) && isString(x?.id);
1748
3353
  }
@@ -1756,7 +3361,11 @@ function isSortFilterString(value) {
1756
3361
  return isString(value);
1757
3362
  }
1758
3363
  function isSortFilterBase(filter) {
1759
- return isObject(filter) && Object.values(filter).every((value) => value === "asc" || value === "desc");
3364
+ return isObject(filter) && Object.entries(filter).every(([key, value]) => {
3365
+ if (key === "*")
3366
+ return value === "random";
3367
+ return value === "asc" || value === "desc";
3368
+ });
1760
3369
  }
1761
3370
  function isSortFilterObject(filter) {
1762
3371
  return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
@@ -1797,7 +3406,8 @@ var __privateMethod$2 = (obj, member, method) => {
1797
3406
  __accessCheck$4(obj, member, "access private method");
1798
3407
  return method;
1799
3408
  };
1800
- 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;
3409
+ 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, _transformObjectToApi, transformObjectToApi_fn;
3410
+ const BULK_OPERATION_MAX_SIZE = 1e3;
1801
3411
  class Repository extends Query {
1802
3412
  }
1803
3413
  class RestRepository extends Query {
@@ -1809,13 +3419,16 @@ class RestRepository extends Query {
1809
3419
  );
1810
3420
  __privateAdd$4(this, _insertRecordWithoutId);
1811
3421
  __privateAdd$4(this, _insertRecordWithId);
1812
- __privateAdd$4(this, _bulkInsertTableRecords);
3422
+ __privateAdd$4(this, _insertRecords);
1813
3423
  __privateAdd$4(this, _updateRecordWithID);
3424
+ __privateAdd$4(this, _updateRecords);
1814
3425
  __privateAdd$4(this, _upsertRecordWithID);
1815
3426
  __privateAdd$4(this, _deleteRecord);
3427
+ __privateAdd$4(this, _deleteRecords);
1816
3428
  __privateAdd$4(this, _setCacheQuery);
1817
3429
  __privateAdd$4(this, _getCacheQuery);
1818
3430
  __privateAdd$4(this, _getSchemaTables$1);
3431
+ __privateAdd$4(this, _transformObjectToApi);
1819
3432
  __privateAdd$4(this, _table, void 0);
1820
3433
  __privateAdd$4(this, _getFetchProps, void 0);
1821
3434
  __privateAdd$4(this, _db, void 0);
@@ -1826,10 +3439,7 @@ class RestRepository extends Query {
1826
3439
  __privateSet$4(this, _db, options.db);
1827
3440
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1828
3441
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
1829
- __privateSet$4(this, _getFetchProps, async () => {
1830
- const props = await options.pluginOptions.getFetchProps();
1831
- return { ...props, sessionID: generateUUID() };
1832
- });
3442
+ __privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
1833
3443
  const trace = options.pluginOptions.trace ?? defaultTrace;
1834
3444
  __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
1835
3445
  return trace(name, fn, {
@@ -1840,25 +3450,28 @@ class RestRepository extends Query {
1840
3450
  });
1841
3451
  });
1842
3452
  }
1843
- async create(a, b, c) {
3453
+ async create(a, b, c, d) {
1844
3454
  return __privateGet$4(this, _trace).call(this, "create", async () => {
3455
+ const ifVersion = parseIfVersion(b, c, d);
1845
3456
  if (Array.isArray(a)) {
1846
3457
  if (a.length === 0)
1847
3458
  return [];
1848
- const columns = isStringArray(b) ? b : void 0;
1849
- return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
3459
+ const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
3460
+ const columns = isStringArray(b) ? b : ["*"];
3461
+ const result = await this.read(ids, columns);
3462
+ return result;
1850
3463
  }
1851
3464
  if (isString(a) && isObject(b)) {
1852
3465
  if (a === "")
1853
3466
  throw new Error("The id can't be empty");
1854
3467
  const columns = isStringArray(c) ? c : void 0;
1855
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
3468
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
1856
3469
  }
1857
3470
  if (isObject(a) && isString(a.id)) {
1858
3471
  if (a.id === "")
1859
3472
  throw new Error("The id can't be empty");
1860
3473
  const columns = isStringArray(b) ? b : void 0;
1861
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
3474
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
1862
3475
  }
1863
3476
  if (isObject(a)) {
1864
3477
  const columns = isStringArray(b) ? b : void 0;
@@ -1883,17 +3496,17 @@ class RestRepository extends Query {
1883
3496
  }
1884
3497
  const id = extractId(a);
1885
3498
  if (id) {
1886
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1887
3499
  try {
1888
3500
  const response = await getRecord({
1889
3501
  pathParams: {
1890
3502
  workspace: "{workspaceId}",
1891
3503
  dbBranchName: "{dbBranch}",
3504
+ region: "{region}",
1892
3505
  tableName: __privateGet$4(this, _table),
1893
3506
  recordId: id
1894
3507
  },
1895
3508
  queryParams: { columns },
1896
- ...fetchProps
3509
+ ...__privateGet$4(this, _getFetchProps).call(this)
1897
3510
  });
1898
3511
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1899
3512
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
@@ -1926,31 +3539,42 @@ class RestRepository extends Query {
1926
3539
  return result;
1927
3540
  });
1928
3541
  }
1929
- async update(a, b, c) {
3542
+ async update(a, b, c, d) {
1930
3543
  return __privateGet$4(this, _trace).call(this, "update", async () => {
3544
+ const ifVersion = parseIfVersion(b, c, d);
1931
3545
  if (Array.isArray(a)) {
1932
3546
  if (a.length === 0)
1933
3547
  return [];
1934
- if (a.length > 100) {
1935
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1936
- }
3548
+ const existing = await this.read(a, ["id"]);
3549
+ const updates = a.filter((_item, index) => existing[index] !== null);
3550
+ await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
3551
+ ifVersion,
3552
+ upsert: false
3553
+ });
1937
3554
  const columns = isStringArray(b) ? b : ["*"];
1938
- return Promise.all(a.map((object) => this.update(object, columns)));
1939
- }
1940
- if (isString(a) && isObject(b)) {
1941
- const columns = isStringArray(c) ? c : void 0;
1942
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
3555
+ const result = await this.read(a, columns);
3556
+ return result;
1943
3557
  }
1944
- if (isObject(a) && isString(a.id)) {
1945
- const columns = isStringArray(b) ? b : void 0;
1946
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
3558
+ try {
3559
+ if (isString(a) && isObject(b)) {
3560
+ const columns = isStringArray(c) ? c : void 0;
3561
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
3562
+ }
3563
+ if (isObject(a) && isString(a.id)) {
3564
+ const columns = isStringArray(b) ? b : void 0;
3565
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3566
+ }
3567
+ } catch (error) {
3568
+ if (error.status === 422)
3569
+ return null;
3570
+ throw error;
1947
3571
  }
1948
3572
  throw new Error("Invalid arguments for update method");
1949
3573
  });
1950
3574
  }
1951
- async updateOrThrow(a, b, c) {
3575
+ async updateOrThrow(a, b, c, d) {
1952
3576
  return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1953
- const result = await this.update(a, b, c);
3577
+ const result = await this.update(a, b, c, d);
1954
3578
  if (Array.isArray(result)) {
1955
3579
  const missingIds = compact(
1956
3580
  a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
@@ -1967,37 +3591,89 @@ class RestRepository extends Query {
1967
3591
  return result;
1968
3592
  });
1969
3593
  }
1970
- async createOrUpdate(a, b, c) {
3594
+ async createOrUpdate(a, b, c, d) {
1971
3595
  return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
3596
+ const ifVersion = parseIfVersion(b, c, d);
1972
3597
  if (Array.isArray(a)) {
1973
3598
  if (a.length === 0)
1974
3599
  return [];
1975
- if (a.length > 100) {
1976
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1977
- }
3600
+ await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
3601
+ ifVersion,
3602
+ upsert: true
3603
+ });
1978
3604
  const columns = isStringArray(b) ? b : ["*"];
1979
- return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
3605
+ const result = await this.read(a, columns);
3606
+ return result;
1980
3607
  }
1981
3608
  if (isString(a) && isObject(b)) {
3609
+ if (a === "")
3610
+ throw new Error("The id can't be empty");
1982
3611
  const columns = isStringArray(c) ? c : void 0;
1983
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
3612
+ return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1984
3613
  }
1985
3614
  if (isObject(a) && isString(a.id)) {
3615
+ if (a.id === "")
3616
+ throw new Error("The id can't be empty");
1986
3617
  const columns = isStringArray(c) ? c : void 0;
1987
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
3618
+ return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3619
+ }
3620
+ if (!isDefined(a) && isObject(b)) {
3621
+ return await this.create(b, c);
3622
+ }
3623
+ if (isObject(a) && !isDefined(a.id)) {
3624
+ return await this.create(a, b);
1988
3625
  }
1989
3626
  throw new Error("Invalid arguments for createOrUpdate method");
1990
3627
  });
1991
3628
  }
3629
+ async createOrReplace(a, b, c, d) {
3630
+ return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
3631
+ const ifVersion = parseIfVersion(b, c, d);
3632
+ if (Array.isArray(a)) {
3633
+ if (a.length === 0)
3634
+ return [];
3635
+ const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
3636
+ const columns = isStringArray(b) ? b : ["*"];
3637
+ const result = await this.read(ids, columns);
3638
+ return result;
3639
+ }
3640
+ if (isString(a) && isObject(b)) {
3641
+ if (a === "")
3642
+ throw new Error("The id can't be empty");
3643
+ const columns = isStringArray(c) ? c : void 0;
3644
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
3645
+ }
3646
+ if (isObject(a) && isString(a.id)) {
3647
+ if (a.id === "")
3648
+ throw new Error("The id can't be empty");
3649
+ const columns = isStringArray(c) ? c : void 0;
3650
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
3651
+ }
3652
+ if (!isDefined(a) && isObject(b)) {
3653
+ return await this.create(b, c);
3654
+ }
3655
+ if (isObject(a) && !isDefined(a.id)) {
3656
+ return await this.create(a, b);
3657
+ }
3658
+ throw new Error("Invalid arguments for createOrReplace method");
3659
+ });
3660
+ }
1992
3661
  async delete(a, b) {
1993
3662
  return __privateGet$4(this, _trace).call(this, "delete", async () => {
1994
3663
  if (Array.isArray(a)) {
1995
3664
  if (a.length === 0)
1996
3665
  return [];
1997
- if (a.length > 100) {
1998
- console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1999
- }
2000
- return Promise.all(a.map((id) => this.delete(id, b)));
3666
+ const ids = a.map((o) => {
3667
+ if (isString(o))
3668
+ return o;
3669
+ if (isString(o.id))
3670
+ return o.id;
3671
+ throw new Error("Invalid arguments for delete method");
3672
+ });
3673
+ const columns = isStringArray(b) ? b : ["*"];
3674
+ const result = await this.read(a, columns);
3675
+ await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
3676
+ return result;
2001
3677
  }
2002
3678
  if (isString(a)) {
2003
3679
  return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
@@ -2028,18 +3704,46 @@ class RestRepository extends Query {
2028
3704
  }
2029
3705
  async search(query, options = {}) {
2030
3706
  return __privateGet$4(this, _trace).call(this, "search", async () => {
2031
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2032
3707
  const { records } = await searchTable({
2033
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
3708
+ pathParams: {
3709
+ workspace: "{workspaceId}",
3710
+ dbBranchName: "{dbBranch}",
3711
+ region: "{region}",
3712
+ tableName: __privateGet$4(this, _table)
3713
+ },
2034
3714
  body: {
2035
3715
  query,
2036
3716
  fuzziness: options.fuzziness,
2037
3717
  prefix: options.prefix,
2038
3718
  highlight: options.highlight,
2039
3719
  filter: options.filter,
2040
- boosters: options.boosters
3720
+ boosters: options.boosters,
3721
+ page: options.page,
3722
+ target: options.target
3723
+ },
3724
+ ...__privateGet$4(this, _getFetchProps).call(this)
3725
+ });
3726
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3727
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3728
+ });
3729
+ }
3730
+ async vectorSearch(column, query, options) {
3731
+ return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
3732
+ const { records } = await vectorSearchTable({
3733
+ pathParams: {
3734
+ workspace: "{workspaceId}",
3735
+ dbBranchName: "{dbBranch}",
3736
+ region: "{region}",
3737
+ tableName: __privateGet$4(this, _table)
2041
3738
  },
2042
- ...fetchProps
3739
+ body: {
3740
+ column,
3741
+ queryVector: query,
3742
+ similarityFunction: options?.similarityFunction,
3743
+ size: options?.size,
3744
+ filter: options?.filter
3745
+ },
3746
+ ...__privateGet$4(this, _getFetchProps).call(this)
2043
3747
  });
2044
3748
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2045
3749
  return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
@@ -2047,11 +3751,15 @@ class RestRepository extends Query {
2047
3751
  }
2048
3752
  async aggregate(aggs, filter) {
2049
3753
  return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
2050
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2051
3754
  const result = await aggregateTable({
2052
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
3755
+ pathParams: {
3756
+ workspace: "{workspaceId}",
3757
+ dbBranchName: "{dbBranch}",
3758
+ region: "{region}",
3759
+ tableName: __privateGet$4(this, _table)
3760
+ },
2053
3761
  body: { aggs, filter },
2054
- ...fetchProps
3762
+ ...__privateGet$4(this, _getFetchProps).call(this)
2055
3763
  });
2056
3764
  return result;
2057
3765
  });
@@ -2062,16 +3770,22 @@ class RestRepository extends Query {
2062
3770
  if (cacheQuery)
2063
3771
  return new Page(query, cacheQuery.meta, cacheQuery.records);
2064
3772
  const data = query.getQueryOptions();
2065
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2066
3773
  const { meta, records: objects } = await queryTable({
2067
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
3774
+ pathParams: {
3775
+ workspace: "{workspaceId}",
3776
+ dbBranchName: "{dbBranch}",
3777
+ region: "{region}",
3778
+ tableName: __privateGet$4(this, _table)
3779
+ },
2068
3780
  body: {
2069
3781
  filter: cleanFilter(data.filter),
2070
3782
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2071
3783
  page: data.pagination,
2072
- columns: data.columns ?? ["*"]
3784
+ columns: data.columns ?? ["*"],
3785
+ consistency: data.consistency
2073
3786
  },
2074
- ...fetchProps
3787
+ fetchOptions: data.fetchOptions,
3788
+ ...__privateGet$4(this, _getFetchProps).call(this)
2075
3789
  });
2076
3790
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2077
3791
  const records = objects.map(
@@ -2084,21 +3798,60 @@ class RestRepository extends Query {
2084
3798
  async summarizeTable(query, summaries, summariesFilter) {
2085
3799
  return __privateGet$4(this, _trace).call(this, "summarize", async () => {
2086
3800
  const data = query.getQueryOptions();
2087
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2088
3801
  const result = await summarizeTable({
2089
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
3802
+ pathParams: {
3803
+ workspace: "{workspaceId}",
3804
+ dbBranchName: "{dbBranch}",
3805
+ region: "{region}",
3806
+ tableName: __privateGet$4(this, _table)
3807
+ },
2090
3808
  body: {
2091
3809
  filter: cleanFilter(data.filter),
2092
3810
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2093
3811
  columns: data.columns,
3812
+ consistency: data.consistency,
3813
+ page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
2094
3814
  summaries,
2095
3815
  summariesFilter
2096
3816
  },
2097
- ...fetchProps
3817
+ ...__privateGet$4(this, _getFetchProps).call(this)
2098
3818
  });
2099
3819
  return result;
2100
3820
  });
2101
3821
  }
3822
+ ask(question, options) {
3823
+ const questionParam = options?.sessionId ? { message: question } : { question };
3824
+ const params = {
3825
+ pathParams: {
3826
+ workspace: "{workspaceId}",
3827
+ dbBranchName: "{dbBranch}",
3828
+ region: "{region}",
3829
+ tableName: __privateGet$4(this, _table),
3830
+ sessionId: options?.sessionId
3831
+ },
3832
+ body: {
3833
+ ...questionParam,
3834
+ rules: options?.rules,
3835
+ searchType: options?.searchType,
3836
+ search: options?.searchType === "keyword" ? options?.search : void 0,
3837
+ vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
3838
+ },
3839
+ ...__privateGet$4(this, _getFetchProps).call(this)
3840
+ };
3841
+ if (options?.onMessage) {
3842
+ fetchSSERequest({
3843
+ endpoint: "dataPlane",
3844
+ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
3845
+ method: "POST",
3846
+ onMessage: (message) => {
3847
+ options.onMessage?.({ answer: message.text, records: message.records });
3848
+ },
3849
+ ...params
3850
+ });
3851
+ } else {
3852
+ return askTableSession(params);
3853
+ }
3854
+ }
2102
3855
  }
2103
3856
  _table = new WeakMap();
2104
3857
  _getFetchProps = new WeakMap();
@@ -2108,65 +3861,86 @@ _schemaTables$2 = new WeakMap();
2108
3861
  _trace = new WeakMap();
2109
3862
  _insertRecordWithoutId = new WeakSet();
2110
3863
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
2111
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2112
- const record = transformObjectLinks(object);
3864
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
2113
3865
  const response = await insertRecord({
2114
3866
  pathParams: {
2115
3867
  workspace: "{workspaceId}",
2116
3868
  dbBranchName: "{dbBranch}",
3869
+ region: "{region}",
2117
3870
  tableName: __privateGet$4(this, _table)
2118
3871
  },
2119
3872
  queryParams: { columns },
2120
3873
  body: record,
2121
- ...fetchProps
3874
+ ...__privateGet$4(this, _getFetchProps).call(this)
2122
3875
  });
2123
3876
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2124
3877
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2125
3878
  };
2126
3879
  _insertRecordWithId = new WeakSet();
2127
- insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
2128
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2129
- const record = transformObjectLinks(object);
3880
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
3881
+ if (!recordId)
3882
+ return null;
3883
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
2130
3884
  const response = await insertRecordWithID({
2131
3885
  pathParams: {
2132
3886
  workspace: "{workspaceId}",
2133
3887
  dbBranchName: "{dbBranch}",
3888
+ region: "{region}",
2134
3889
  tableName: __privateGet$4(this, _table),
2135
3890
  recordId
2136
3891
  },
2137
3892
  body: record,
2138
- queryParams: { createOnly: true, columns },
2139
- ...fetchProps
3893
+ queryParams: { createOnly, columns, ifVersion },
3894
+ ...__privateGet$4(this, _getFetchProps).call(this)
2140
3895
  });
2141
3896
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2142
3897
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2143
3898
  };
2144
- _bulkInsertTableRecords = new WeakSet();
2145
- bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
2146
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2147
- const records = objects.map((object) => transformObjectLinks(object));
2148
- const response = await bulkInsertTableRecords({
2149
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2150
- queryParams: { columns },
2151
- body: { records },
2152
- ...fetchProps
3899
+ _insertRecords = new WeakSet();
3900
+ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
3901
+ const operations = await promiseMap(objects, async (object) => {
3902
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3903
+ return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
2153
3904
  });
2154
- if (!isResponseWithRecords(response)) {
2155
- throw new Error("Request included columns but server didn't include them");
3905
+ const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
3906
+ const ids = [];
3907
+ for (const operations2 of chunkedOperations) {
3908
+ const { results } = await branchTransaction({
3909
+ pathParams: {
3910
+ workspace: "{workspaceId}",
3911
+ dbBranchName: "{dbBranch}",
3912
+ region: "{region}"
3913
+ },
3914
+ body: { operations: operations2 },
3915
+ ...__privateGet$4(this, _getFetchProps).call(this)
3916
+ });
3917
+ for (const result of results) {
3918
+ if (result.operation === "insert") {
3919
+ ids.push(result.id);
3920
+ } else {
3921
+ ids.push(null);
3922
+ }
3923
+ }
2156
3924
  }
2157
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2158
- return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
3925
+ return ids;
2159
3926
  };
2160
3927
  _updateRecordWithID = new WeakSet();
2161
- updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2162
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2163
- const record = transformObjectLinks(object);
3928
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
3929
+ if (!recordId)
3930
+ return null;
3931
+ const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
2164
3932
  try {
2165
3933
  const response = await updateRecordWithID({
2166
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2167
- queryParams: { columns },
3934
+ pathParams: {
3935
+ workspace: "{workspaceId}",
3936
+ dbBranchName: "{dbBranch}",
3937
+ region: "{region}",
3938
+ tableName: __privateGet$4(this, _table),
3939
+ recordId
3940
+ },
3941
+ queryParams: { columns, ifVersion },
2168
3942
  body: record,
2169
- ...fetchProps
3943
+ ...__privateGet$4(this, _getFetchProps).call(this)
2170
3944
  });
2171
3945
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2172
3946
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
@@ -2177,26 +3951,68 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2177
3951
  throw e;
2178
3952
  }
2179
3953
  };
3954
+ _updateRecords = new WeakSet();
3955
+ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
3956
+ const operations = await promiseMap(objects, async ({ id, ...object }) => {
3957
+ const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3958
+ return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
3959
+ });
3960
+ const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
3961
+ const ids = [];
3962
+ for (const operations2 of chunkedOperations) {
3963
+ const { results } = await branchTransaction({
3964
+ pathParams: {
3965
+ workspace: "{workspaceId}",
3966
+ dbBranchName: "{dbBranch}",
3967
+ region: "{region}"
3968
+ },
3969
+ body: { operations: operations2 },
3970
+ ...__privateGet$4(this, _getFetchProps).call(this)
3971
+ });
3972
+ for (const result of results) {
3973
+ if (result.operation === "update") {
3974
+ ids.push(result.id);
3975
+ } else {
3976
+ ids.push(null);
3977
+ }
3978
+ }
3979
+ }
3980
+ return ids;
3981
+ };
2180
3982
  _upsertRecordWithID = new WeakSet();
2181
- upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2182
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
3983
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
3984
+ if (!recordId)
3985
+ return null;
2183
3986
  const response = await upsertRecordWithID({
2184
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2185
- queryParams: { columns },
3987
+ pathParams: {
3988
+ workspace: "{workspaceId}",
3989
+ dbBranchName: "{dbBranch}",
3990
+ region: "{region}",
3991
+ tableName: __privateGet$4(this, _table),
3992
+ recordId
3993
+ },
3994
+ queryParams: { columns, ifVersion },
2186
3995
  body: object,
2187
- ...fetchProps
3996
+ ...__privateGet$4(this, _getFetchProps).call(this)
2188
3997
  });
2189
3998
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2190
3999
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2191
4000
  };
2192
4001
  _deleteRecord = new WeakSet();
2193
4002
  deleteRecord_fn = async function(recordId, columns = ["*"]) {
2194
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
4003
+ if (!recordId)
4004
+ return null;
2195
4005
  try {
2196
4006
  const response = await deleteRecord({
2197
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
4007
+ pathParams: {
4008
+ workspace: "{workspaceId}",
4009
+ dbBranchName: "{dbBranch}",
4010
+ region: "{region}",
4011
+ tableName: __privateGet$4(this, _table),
4012
+ recordId
4013
+ },
2198
4014
  queryParams: { columns },
2199
- ...fetchProps
4015
+ ...__privateGet$4(this, _getFetchProps).call(this)
2200
4016
  });
2201
4017
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2202
4018
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
@@ -2207,17 +4023,36 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
2207
4023
  throw e;
2208
4024
  }
2209
4025
  };
4026
+ _deleteRecords = new WeakSet();
4027
+ deleteRecords_fn = async function(recordIds) {
4028
+ const chunkedOperations = chunk(
4029
+ compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
4030
+ BULK_OPERATION_MAX_SIZE
4031
+ );
4032
+ for (const operations of chunkedOperations) {
4033
+ await branchTransaction({
4034
+ pathParams: {
4035
+ workspace: "{workspaceId}",
4036
+ dbBranchName: "{dbBranch}",
4037
+ region: "{region}"
4038
+ },
4039
+ body: { operations },
4040
+ ...__privateGet$4(this, _getFetchProps).call(this)
4041
+ });
4042
+ }
4043
+ };
2210
4044
  _setCacheQuery = new WeakSet();
2211
4045
  setCacheQuery_fn = async function(query, meta, records) {
2212
- await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
4046
+ await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
2213
4047
  };
2214
4048
  _getCacheQuery = new WeakSet();
2215
4049
  getCacheQuery_fn = async function(query) {
2216
4050
  const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
2217
- const result = await __privateGet$4(this, _cache).get(key);
4051
+ const result = await __privateGet$4(this, _cache)?.get(key);
2218
4052
  if (!result)
2219
4053
  return null;
2220
- const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
4054
+ const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
4055
+ const { cache: ttl = defaultTTL } = query.getQueryOptions();
2221
4056
  if (ttl < 0)
2222
4057
  return null;
2223
4058
  const hasExpired = result.date.getTime() + ttl < Date.now();
@@ -2227,15 +4062,46 @@ _getSchemaTables$1 = new WeakSet();
2227
4062
  getSchemaTables_fn$1 = async function() {
2228
4063
  if (__privateGet$4(this, _schemaTables$2))
2229
4064
  return __privateGet$4(this, _schemaTables$2);
2230
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2231
4065
  const { schema } = await getBranchDetails({
2232
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2233
- ...fetchProps
4066
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4067
+ ...__privateGet$4(this, _getFetchProps).call(this)
2234
4068
  });
2235
4069
  __privateSet$4(this, _schemaTables$2, schema.tables);
2236
4070
  return schema.tables;
2237
4071
  };
2238
- const transformObjectLinks = (object) => {
4072
+ _transformObjectToApi = new WeakSet();
4073
+ transformObjectToApi_fn = async function(object) {
4074
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
4075
+ const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
4076
+ if (!schema)
4077
+ throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
4078
+ const result = {};
4079
+ for (const [key, value] of Object.entries(object)) {
4080
+ if (key === "xata")
4081
+ continue;
4082
+ const type = schema.columns.find((column) => column.name === key)?.type;
4083
+ switch (type) {
4084
+ case "link": {
4085
+ result[key] = isIdentifiable(value) ? value.id : value;
4086
+ break;
4087
+ }
4088
+ case "datetime": {
4089
+ result[key] = value instanceof Date ? value.toISOString() : value;
4090
+ break;
4091
+ }
4092
+ case `file`:
4093
+ result[key] = await parseInputFileEntry(value);
4094
+ break;
4095
+ case "file[]":
4096
+ result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
4097
+ break;
4098
+ default:
4099
+ result[key] = value;
4100
+ }
4101
+ }
4102
+ return result;
4103
+ };
4104
+ const removeLinksFromObject = (object) => {
2239
4105
  return Object.entries(object).reduce((acc, [key, value]) => {
2240
4106
  if (key === "xata")
2241
4107
  return acc;
@@ -2243,23 +4109,23 @@ const transformObjectLinks = (object) => {
2243
4109
  }, {});
2244
4110
  };
2245
4111
  const initObject = (db, schemaTables, table, object, selectedColumns) => {
2246
- const result = {};
4112
+ const data = {};
2247
4113
  const { xata, ...rest } = object ?? {};
2248
- Object.assign(result, rest);
4114
+ Object.assign(data, rest);
2249
4115
  const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
2250
4116
  if (!columns)
2251
4117
  console.error(`Table ${table} not found in schema`);
2252
4118
  for (const column of columns ?? []) {
2253
4119
  if (!isValidColumn(selectedColumns, column))
2254
4120
  continue;
2255
- const value = result[column.name];
4121
+ const value = data[column.name];
2256
4122
  switch (column.type) {
2257
4123
  case "datetime": {
2258
- const date = value !== void 0 ? new Date(value) : void 0;
2259
- if (date && isNaN(date.getTime())) {
4124
+ const date = value !== void 0 ? new Date(value) : null;
4125
+ if (date !== null && isNaN(date.getTime())) {
2260
4126
  console.error(`Failed to parse date ${value} for field ${column.name}`);
2261
- } else if (date) {
2262
- result[column.name] = date;
4127
+ } else {
4128
+ data[column.name] = date;
2263
4129
  }
2264
4130
  break;
2265
4131
  }
@@ -2278,41 +4144,61 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2278
4144
  }
2279
4145
  return acc;
2280
4146
  }, []);
2281
- result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
4147
+ data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2282
4148
  } else {
2283
- result[column.name] = null;
4149
+ data[column.name] = null;
2284
4150
  }
2285
4151
  break;
2286
4152
  }
4153
+ case "file":
4154
+ data[column.name] = isDefined(value) ? new XataFile(value) : null;
4155
+ break;
4156
+ case "file[]":
4157
+ data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
4158
+ break;
2287
4159
  default:
2288
- result[column.name] = value ?? null;
4160
+ data[column.name] = value ?? null;
2289
4161
  if (column.notNull === true && value === null) {
2290
4162
  console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2291
4163
  }
2292
4164
  break;
2293
4165
  }
2294
4166
  }
2295
- result.read = function(columns2) {
2296
- return db[table].read(result["id"], columns2);
4167
+ const record = { ...data };
4168
+ const serializable = { xata, ...removeLinksFromObject(data) };
4169
+ const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
4170
+ record.read = function(columns2) {
4171
+ return db[table].read(record["id"], columns2);
4172
+ };
4173
+ record.update = function(data2, b, c) {
4174
+ const columns2 = isStringArray(b) ? b : ["*"];
4175
+ const ifVersion = parseIfVersion(b, c);
4176
+ return db[table].update(record["id"], data2, columns2, { ifVersion });
2297
4177
  };
2298
- result.update = function(data, columns2) {
2299
- return db[table].update(result["id"], data, columns2);
4178
+ record.replace = function(data2, b, c) {
4179
+ const columns2 = isStringArray(b) ? b : ["*"];
4180
+ const ifVersion = parseIfVersion(b, c);
4181
+ return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
2300
4182
  };
2301
- result.delete = function() {
2302
- return db[table].delete(result["id"]);
4183
+ record.delete = function() {
4184
+ return db[table].delete(record["id"]);
2303
4185
  };
2304
- result.getMetadata = function() {
2305
- return xata;
4186
+ record.xata = Object.freeze(metadata);
4187
+ record.getMetadata = function() {
4188
+ return record.xata;
2306
4189
  };
2307
- for (const prop of ["read", "update", "delete", "getMetadata"]) {
2308
- Object.defineProperty(result, prop, { enumerable: false });
4190
+ record.toSerializable = function() {
4191
+ return JSON.parse(JSON.stringify(serializable));
4192
+ };
4193
+ record.toString = function() {
4194
+ return JSON.stringify(serializable);
4195
+ };
4196
+ for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
4197
+ Object.defineProperty(record, prop, { enumerable: false });
2309
4198
  }
2310
- Object.freeze(result);
2311
- return result;
4199
+ Object.freeze(record);
4200
+ return record;
2312
4201
  };
2313
- function isResponseWithRecords(value) {
2314
- return isObject(value) && Array.isArray(value.records);
2315
- }
2316
4202
  function extractId(value) {
2317
4203
  if (isString(value))
2318
4204
  return value;
@@ -2323,13 +4209,23 @@ function extractId(value) {
2323
4209
  function isValidColumn(columns, column) {
2324
4210
  if (columns.includes("*"))
2325
4211
  return true;
2326
- if (column.type === "link") {
2327
- const linkColumns = columns.filter((item) => item.startsWith(column.name));
2328
- return linkColumns.length > 0;
4212
+ return columns.filter((item) => item.startsWith(column.name)).length > 0;
4213
+ }
4214
+ function parseIfVersion(...args) {
4215
+ for (const arg of args) {
4216
+ if (isObject(arg) && isNumber(arg.ifVersion)) {
4217
+ return arg.ifVersion;
4218
+ }
2329
4219
  }
2330
- return columns.includes(column.name);
4220
+ return void 0;
2331
4221
  }
2332
4222
 
4223
+ var __defProp$3 = Object.defineProperty;
4224
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4225
+ var __publicField$3 = (obj, key, value) => {
4226
+ __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
4227
+ return value;
4228
+ };
2333
4229
  var __accessCheck$3 = (obj, member, msg) => {
2334
4230
  if (!member.has(obj))
2335
4231
  throw TypeError("Cannot " + msg);
@@ -2352,6 +4248,8 @@ var _map;
2352
4248
  class SimpleCache {
2353
4249
  constructor(options = {}) {
2354
4250
  __privateAdd$3(this, _map, void 0);
4251
+ __publicField$3(this, "capacity");
4252
+ __publicField$3(this, "defaultQueryTTL");
2355
4253
  __privateSet$3(this, _map, /* @__PURE__ */ new Map());
2356
4254
  this.capacity = options.max ?? 500;
2357
4255
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
@@ -2487,19 +4385,19 @@ class SearchPlugin extends XataPlugin {
2487
4385
  __privateAdd$1(this, _schemaTables, void 0);
2488
4386
  __privateSet$1(this, _schemaTables, schemaTables);
2489
4387
  }
2490
- build({ getFetchProps }) {
4388
+ build(pluginOptions) {
2491
4389
  return {
2492
4390
  all: async (query, options = {}) => {
2493
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
2494
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
4391
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4392
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
2495
4393
  return records.map((record) => {
2496
4394
  const { table = "orphan" } = record.xata;
2497
4395
  return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
2498
4396
  });
2499
4397
  },
2500
4398
  byTable: async (query, options = {}) => {
2501
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
2502
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
4399
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4400
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
2503
4401
  return records.reduce((acc, record) => {
2504
4402
  const { table = "orphan" } = record.xata;
2505
4403
  const items = acc[table] ?? [];
@@ -2512,111 +4410,121 @@ class SearchPlugin extends XataPlugin {
2512
4410
  }
2513
4411
  _schemaTables = new WeakMap();
2514
4412
  _search = new WeakSet();
2515
- search_fn = async function(query, options, getFetchProps) {
2516
- const fetchProps = await getFetchProps();
2517
- const { tables, fuzziness, highlight, prefix } = options ?? {};
4413
+ search_fn = async function(query, options, pluginOptions) {
4414
+ const { tables, fuzziness, highlight, prefix, page } = options ?? {};
2518
4415
  const { records } = await searchBranch({
2519
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2520
- body: { tables, query, fuzziness, prefix, highlight },
2521
- ...fetchProps
4416
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4417
+ // @ts-ignore https://github.com/xataio/client-ts/issues/313
4418
+ body: { tables, query, fuzziness, prefix, highlight, page },
4419
+ ...pluginOptions
2522
4420
  });
2523
4421
  return records;
2524
4422
  };
2525
4423
  _getSchemaTables = new WeakSet();
2526
- getSchemaTables_fn = async function(getFetchProps) {
4424
+ getSchemaTables_fn = async function(pluginOptions) {
2527
4425
  if (__privateGet$1(this, _schemaTables))
2528
4426
  return __privateGet$1(this, _schemaTables);
2529
- const fetchProps = await getFetchProps();
2530
4427
  const { schema } = await getBranchDetails({
2531
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2532
- ...fetchProps
4428
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4429
+ ...pluginOptions
2533
4430
  });
2534
4431
  __privateSet$1(this, _schemaTables, schema.tables);
2535
4432
  return schema.tables;
2536
4433
  };
2537
4434
 
2538
- const isBranchStrategyBuilder = (strategy) => {
2539
- return typeof strategy === "function";
2540
- };
2541
-
2542
- async function getCurrentBranchName(options) {
2543
- const { branch, envBranch } = getEnvironment();
2544
- if (branch) {
2545
- const details = await getDatabaseBranch(branch, options);
2546
- if (details)
2547
- return branch;
2548
- console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
2549
- }
2550
- const gitBranch = envBranch || await getGitBranch();
2551
- return resolveXataBranch(gitBranch, options);
2552
- }
2553
- async function getCurrentBranchDetails(options) {
2554
- const branch = await getCurrentBranchName(options);
2555
- return getDatabaseBranch(branch, options);
2556
- }
2557
- async function resolveXataBranch(gitBranch, options) {
2558
- const databaseURL = options?.databaseURL || getDatabaseURL();
2559
- const apiKey = options?.apiKey || getAPIKey();
2560
- if (!databaseURL)
2561
- throw new Error(
2562
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2563
- );
2564
- if (!apiKey)
2565
- throw new Error(
2566
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2567
- );
2568
- const [protocol, , host, , dbName] = databaseURL.split("/");
2569
- const [workspace] = host.split(".");
2570
- const { fallbackBranch } = getEnvironment();
2571
- const { branch } = await resolveBranch({
2572
- apiKey,
2573
- apiUrl: databaseURL,
2574
- fetchImpl: getFetchImplementation(options?.fetchImpl),
2575
- workspacesApiUrl: `${protocol}//${host}`,
2576
- pathParams: { dbName, workspace },
2577
- queryParams: { gitBranch, fallbackBranch },
2578
- trace: defaultTrace
2579
- });
2580
- return branch;
4435
+ function escapeElement(elementRepresentation) {
4436
+ const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
4437
+ return '"' + escaped + '"';
2581
4438
  }
2582
- async function getDatabaseBranch(branch, options) {
2583
- const databaseURL = options?.databaseURL || getDatabaseURL();
2584
- const apiKey = options?.apiKey || getAPIKey();
2585
- if (!databaseURL)
2586
- throw new Error(
2587
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2588
- );
2589
- if (!apiKey)
2590
- throw new Error(
2591
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2592
- );
2593
- const [protocol, , host, , database] = databaseURL.split("/");
2594
- const [workspace] = host.split(".");
2595
- const dbBranchName = `${database}:${branch}`;
2596
- try {
2597
- return await getBranchDetails({
2598
- apiKey,
2599
- apiUrl: databaseURL,
2600
- fetchImpl: getFetchImplementation(options?.fetchImpl),
2601
- workspacesApiUrl: `${protocol}//${host}`,
2602
- pathParams: { dbBranchName, workspace },
2603
- trace: defaultTrace
2604
- });
2605
- } catch (err) {
2606
- if (isObject(err) && err.status === 404)
2607
- return null;
2608
- throw err;
4439
+ function arrayString(val) {
4440
+ let result = "{";
4441
+ for (let i = 0; i < val.length; i++) {
4442
+ if (i > 0) {
4443
+ result = result + ",";
4444
+ }
4445
+ if (val[i] === null || typeof val[i] === "undefined") {
4446
+ result = result + "NULL";
4447
+ } else if (Array.isArray(val[i])) {
4448
+ result = result + arrayString(val[i]);
4449
+ } else if (val[i] instanceof Buffer) {
4450
+ result += "\\\\x" + val[i].toString("hex");
4451
+ } else {
4452
+ result += escapeElement(prepareValue(val[i]));
4453
+ }
2609
4454
  }
4455
+ result = result + "}";
4456
+ return result;
2610
4457
  }
2611
- function getDatabaseURL() {
4458
+ function prepareValue(value) {
4459
+ if (!isDefined(value))
4460
+ return null;
4461
+ if (value instanceof Date) {
4462
+ return value.toISOString();
4463
+ }
4464
+ if (Array.isArray(value)) {
4465
+ return arrayString(value);
4466
+ }
4467
+ if (isObject(value)) {
4468
+ return JSON.stringify(value);
4469
+ }
2612
4470
  try {
2613
- const { databaseURL } = getEnvironment();
2614
- return databaseURL;
2615
- } catch (err) {
2616
- return void 0;
4471
+ return value.toString();
4472
+ } catch (e) {
4473
+ return value;
4474
+ }
4475
+ }
4476
+ function prepareParams(param1, param2) {
4477
+ if (isString(param1)) {
4478
+ return { statement: param1, params: param2?.map((value) => prepareValue(value)) };
4479
+ }
4480
+ if (isStringArray(param1)) {
4481
+ const statement = param1.reduce((acc, curr, index) => {
4482
+ return acc + curr + (index < (param2?.length ?? 0) ? "$" + (index + 1) : "");
4483
+ }, "");
4484
+ return { statement, params: param2?.map((value) => prepareValue(value)) };
4485
+ }
4486
+ if (isObject(param1)) {
4487
+ const { statement, params, consistency } = param1;
4488
+ return { statement, params: params?.map((value) => prepareValue(value)), consistency };
4489
+ }
4490
+ throw new Error("Invalid query");
4491
+ }
4492
+
4493
+ class SQLPlugin extends XataPlugin {
4494
+ build(pluginOptions) {
4495
+ return async (param1, ...param2) => {
4496
+ const { statement, params, consistency } = prepareParams(param1, param2);
4497
+ const { records, warning } = await sqlQuery({
4498
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4499
+ body: { statement, params, consistency },
4500
+ ...pluginOptions
4501
+ });
4502
+ return { records, warning };
4503
+ };
2617
4504
  }
2618
4505
  }
2619
4506
 
4507
+ class TransactionPlugin extends XataPlugin {
4508
+ build(pluginOptions) {
4509
+ return {
4510
+ run: async (operations) => {
4511
+ const response = await branchTransaction({
4512
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4513
+ body: { operations },
4514
+ ...pluginOptions
4515
+ });
4516
+ return response;
4517
+ }
4518
+ };
4519
+ }
4520
+ }
4521
+
4522
+ var __defProp$2 = Object.defineProperty;
4523
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4524
+ var __publicField$2 = (obj, key, value) => {
4525
+ __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
4526
+ return value;
4527
+ };
2620
4528
  var __accessCheck = (obj, member, msg) => {
2621
4529
  if (!member.has(obj))
2622
4530
  throw TypeError("Cannot " + msg);
@@ -2640,106 +4548,141 @@ var __privateMethod = (obj, member, method) => {
2640
4548
  return method;
2641
4549
  };
2642
4550
  const buildClient = (plugins) => {
2643
- var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
4551
+ var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
2644
4552
  return _a = class {
2645
4553
  constructor(options = {}, schemaTables) {
2646
4554
  __privateAdd(this, _parseOptions);
2647
4555
  __privateAdd(this, _getFetchProps);
2648
- __privateAdd(this, _evaluateBranch);
2649
- __privateAdd(this, _branch, void 0);
2650
4556
  __privateAdd(this, _options, void 0);
4557
+ __publicField$2(this, "db");
4558
+ __publicField$2(this, "search");
4559
+ __publicField$2(this, "transactions");
4560
+ __publicField$2(this, "sql");
4561
+ __publicField$2(this, "files");
2651
4562
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
2652
4563
  __privateSet(this, _options, safeOptions);
2653
4564
  const pluginOptions = {
2654
- getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
4565
+ ...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
2655
4566
  cache: safeOptions.cache,
2656
- trace: safeOptions.trace
4567
+ host: safeOptions.host
2657
4568
  };
2658
4569
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
2659
4570
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
4571
+ const transactions = new TransactionPlugin().build(pluginOptions);
4572
+ const sql = new SQLPlugin().build(pluginOptions);
4573
+ const files = new FilesPlugin().build(pluginOptions);
2660
4574
  this.db = db;
2661
4575
  this.search = search;
4576
+ this.transactions = transactions;
4577
+ this.sql = sql;
4578
+ this.files = files;
2662
4579
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
2663
4580
  if (namespace === void 0)
2664
4581
  continue;
2665
- const result = namespace.build(pluginOptions);
2666
- if (result instanceof Promise) {
2667
- void result.then((namespace2) => {
2668
- this[key] = namespace2;
2669
- });
2670
- } else {
2671
- this[key] = result;
2672
- }
4582
+ this[key] = namespace.build(pluginOptions);
2673
4583
  }
2674
4584
  }
2675
4585
  async getConfig() {
2676
4586
  const databaseURL = __privateGet(this, _options).databaseURL;
2677
- const branch = await __privateGet(this, _options).branch();
4587
+ const branch = __privateGet(this, _options).branch;
2678
4588
  return { databaseURL, branch };
2679
4589
  }
2680
- }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
4590
+ }, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
4591
+ const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
4592
+ const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
4593
+ if (isBrowser && !enableBrowser) {
4594
+ throw new Error(
4595
+ "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."
4596
+ );
4597
+ }
2681
4598
  const fetch = getFetchImplementation(options?.fetch);
2682
4599
  const databaseURL = options?.databaseURL || getDatabaseURL();
2683
4600
  const apiKey = options?.apiKey || getAPIKey();
2684
4601
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
2685
4602
  const trace = options?.trace ?? defaultTrace;
2686
- const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
4603
+ const clientName = options?.clientName;
4604
+ const host = options?.host ?? "production";
4605
+ const xataAgentExtra = options?.xataAgentExtra;
2687
4606
  if (!apiKey) {
2688
4607
  throw new Error("Option apiKey is required");
2689
4608
  }
2690
4609
  if (!databaseURL) {
2691
4610
  throw new Error("Option databaseURL is required");
2692
4611
  }
2693
- return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID() };
2694
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
4612
+ const envBranch = getBranch();
4613
+ const previewBranch = getPreviewBranch();
4614
+ const branch = options?.branch || previewBranch || envBranch || "main";
4615
+ if (!!previewBranch && branch !== previewBranch) {
4616
+ console.warn(
4617
+ `Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
4618
+ );
4619
+ } else if (!!envBranch && branch !== envBranch) {
4620
+ console.warn(
4621
+ `Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
4622
+ );
4623
+ } else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
4624
+ console.warn(
4625
+ `Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
4626
+ );
4627
+ } else if (!previewBranch && !envBranch && options?.branch === void 0) {
4628
+ console.warn(
4629
+ `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.`
4630
+ );
4631
+ }
4632
+ return {
4633
+ fetch,
4634
+ databaseURL,
4635
+ apiKey,
4636
+ branch,
4637
+ cache,
4638
+ trace,
4639
+ host,
4640
+ clientID: generateUUID(),
4641
+ enableBrowser,
4642
+ clientName,
4643
+ xataAgentExtra
4644
+ };
4645
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
2695
4646
  fetch,
2696
4647
  apiKey,
2697
4648
  databaseURL,
2698
4649
  branch,
2699
4650
  trace,
2700
- clientID
4651
+ clientID,
4652
+ clientName,
4653
+ xataAgentExtra
2701
4654
  }) {
2702
- const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2703
- if (!branchValue)
2704
- throw new Error("Unable to resolve branch value");
2705
4655
  return {
2706
- fetchImpl: fetch,
4656
+ fetch,
2707
4657
  apiKey,
2708
4658
  apiUrl: "",
4659
+ // Instead of using workspace and dbBranch, we inject a probably CNAME'd URL
2709
4660
  workspacesApiUrl: (path, params) => {
2710
4661
  const hasBranch = params.dbBranchName ?? params.branch;
2711
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
4662
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
2712
4663
  return databaseURL + newPath;
2713
4664
  },
2714
4665
  trace,
2715
- clientID
2716
- };
2717
- }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2718
- if (__privateGet(this, _branch))
2719
- return __privateGet(this, _branch);
2720
- if (param === void 0)
2721
- return void 0;
2722
- const strategies = Array.isArray(param) ? [...param] : [param];
2723
- const evaluateBranch = async (strategy) => {
2724
- return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
4666
+ clientID,
4667
+ clientName,
4668
+ xataAgentExtra
2725
4669
  };
2726
- for await (const strategy of strategies) {
2727
- const branch = await evaluateBranch(strategy);
2728
- if (branch) {
2729
- __privateSet(this, _branch, branch);
2730
- return branch;
2731
- }
2732
- }
2733
4670
  }, _a;
2734
4671
  };
2735
4672
  class BaseClient extends buildClient() {
2736
4673
  }
2737
4674
 
4675
+ var __defProp$1 = Object.defineProperty;
4676
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4677
+ var __publicField$1 = (obj, key, value) => {
4678
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
4679
+ return value;
4680
+ };
2738
4681
  const META = "__";
2739
4682
  const VALUE = "___";
2740
4683
  class Serializer {
2741
4684
  constructor() {
2742
- this.classes = {};
4685
+ __publicField$1(this, "classes", {});
2743
4686
  }
2744
4687
  add(clazz) {
2745
4688
  this.classes[clazz.name] = clazz;
@@ -2803,7 +4746,7 @@ const deserialize = (json) => {
2803
4746
  };
2804
4747
 
2805
4748
  function buildWorkerRunner(config) {
2806
- return function xataWorker(name, _worker) {
4749
+ return function xataWorker(name, worker) {
2807
4750
  return async (...args) => {
2808
4751
  const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
2809
4752
  const result = await fetch(url, {
@@ -2817,12 +4760,19 @@ function buildWorkerRunner(config) {
2817
4760
  };
2818
4761
  }
2819
4762
 
4763
+ var __defProp = Object.defineProperty;
4764
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4765
+ var __publicField = (obj, key, value) => {
4766
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4767
+ return value;
4768
+ };
2820
4769
  class XataError extends Error {
2821
4770
  constructor(message, status) {
2822
4771
  super(message);
4772
+ __publicField(this, "status");
2823
4773
  this.status = status;
2824
4774
  }
2825
4775
  }
2826
4776
 
2827
- export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, buildClient, buildWorkerRunner, bulkInsertTableRecords, cPCreateDatabase, cPDeleteDatabase, cPGetCPDatabaseMetadata, cPGetDatabaseList, cPUpdateCPDatabaseMetadata, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, pattern, previewBranchSchemaEdit, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
4777
+ export { BaseClient, FetcherError, FilesPlugin, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SQLPlugin, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteOAuthAccessToken, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteUserOAuthClient, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, ge, getAPIKey, getAuthorizationCode, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getUserOAuthAccessTokens, getUserOAuthClients, getWorkspace, getWorkspaceMembersList, getWorkspacesList, grantAuthorizationCode, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, transformImage, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateOAuthAccessToken, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
2828
4778
  //# sourceMappingURL=index.mjs.map