@xata.io/client 0.0.0-alpha.vf79e7d8 → 0.0.0-alpha.vf7ac0d1

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