@xata.io/client 0.0.0-alpha.vfafe7e2 → 0.0.0-alpha.vfb070a9

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
@@ -18,7 +18,8 @@ const TraceAttributes = {
18
18
  HTTP_METHOD: "http.method",
19
19
  HTTP_URL: "http.url",
20
20
  HTTP_ROUTE: "http.route",
21
- HTTP_TARGET: "http.target"
21
+ HTTP_TARGET: "http.target",
22
+ CLOUDFLARE_RAY_ID: "cf.ray"
22
23
  };
23
24
 
24
25
  function notEmpty(value) {
@@ -27,8 +28,18 @@ function notEmpty(value) {
27
28
  function compact(arr) {
28
29
  return arr.filter(notEmpty);
29
30
  }
31
+ function compactObject(obj) {
32
+ return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
33
+ }
34
+ function isBlob(value) {
35
+ try {
36
+ return value instanceof Blob;
37
+ } catch (error) {
38
+ return false;
39
+ }
40
+ }
30
41
  function isObject(value) {
31
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
42
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !isBlob(value);
32
43
  }
33
44
  function isDefined(value) {
34
45
  return value !== null && value !== void 0;
@@ -83,6 +94,27 @@ function chunk(array, chunkSize) {
83
94
  async function timeout(ms) {
84
95
  return new Promise((resolve) => setTimeout(resolve, ms));
85
96
  }
97
+ function timeoutWithCancel(ms) {
98
+ let timeoutId;
99
+ const promise = new Promise((resolve) => {
100
+ timeoutId = setTimeout(() => {
101
+ resolve();
102
+ }, ms);
103
+ });
104
+ return {
105
+ cancel: () => clearTimeout(timeoutId),
106
+ promise
107
+ };
108
+ }
109
+ function promiseMap(inputValues, mapper) {
110
+ const reducer = (acc$, inputValue) => acc$.then(
111
+ (acc) => mapper(inputValue).then((result) => {
112
+ acc.push(result);
113
+ return acc;
114
+ })
115
+ );
116
+ return inputValues.reduce(reducer, Promise.resolve([]));
117
+ }
86
118
 
87
119
  function getEnvironment() {
88
120
  try {
@@ -91,8 +123,10 @@ function getEnvironment() {
91
123
  apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
92
124
  databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
93
125
  branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
94
- envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
95
- fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
126
+ deployPreview: process.env.XATA_PREVIEW,
127
+ deployPreviewBranch: process.env.XATA_PREVIEW_BRANCH,
128
+ vercelGitCommitRef: process.env.VERCEL_GIT_COMMIT_REF,
129
+ vercelGitRepoOwner: process.env.VERCEL_GIT_REPO_OWNER
96
130
  };
97
131
  }
98
132
  } catch (err) {
@@ -103,8 +137,10 @@ function getEnvironment() {
103
137
  apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
104
138
  databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
105
139
  branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
106
- envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
107
- fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
140
+ deployPreview: Deno.env.get("XATA_PREVIEW"),
141
+ deployPreviewBranch: Deno.env.get("XATA_PREVIEW_BRANCH"),
142
+ vercelGitCommitRef: Deno.env.get("VERCEL_GIT_COMMIT_REF"),
143
+ vercelGitRepoOwner: Deno.env.get("VERCEL_GIT_REPO_OWNER")
108
144
  };
109
145
  }
110
146
  } catch (err) {
@@ -113,8 +149,10 @@ function getEnvironment() {
113
149
  apiKey: getGlobalApiKey(),
114
150
  databaseURL: getGlobalDatabaseURL(),
115
151
  branch: getGlobalBranch(),
116
- envBranch: void 0,
117
- fallbackBranch: getGlobalFallbackBranch()
152
+ deployPreview: void 0,
153
+ deployPreviewBranch: void 0,
154
+ vercelGitCommitRef: void 0,
155
+ vercelGitRepoOwner: void 0
118
156
  };
119
157
  }
120
158
  function getEnableBrowserVariable() {
@@ -157,45 +195,59 @@ function getGlobalBranch() {
157
195
  return void 0;
158
196
  }
159
197
  }
160
- function getGlobalFallbackBranch() {
198
+ function getDatabaseURL() {
161
199
  try {
162
- return XATA_FALLBACK_BRANCH;
200
+ const { databaseURL } = getEnvironment();
201
+ return databaseURL;
163
202
  } catch (err) {
164
203
  return void 0;
165
204
  }
166
205
  }
167
- async function getGitBranch() {
168
- const cmd = ["git", "branch", "--show-current"];
169
- const fullCmd = cmd.join(" ");
170
- const nodeModule = ["child", "process"].join("_");
171
- const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
206
+ function getAPIKey() {
172
207
  try {
173
- const req = eval("require");
174
- if (typeof req === "function") {
175
- return req(nodeModule).execSync(fullCmd, execOptions).trim();
176
- }
177
- const { execSync } = await import(nodeModule);
178
- return execSync(fullCmd, execOptions).toString().trim();
208
+ const { apiKey } = getEnvironment();
209
+ return apiKey;
179
210
  } catch (err) {
211
+ return void 0;
180
212
  }
213
+ }
214
+ function getBranch() {
181
215
  try {
182
- if (isObject(Deno)) {
183
- const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
184
- return new TextDecoder().decode(await process2.output()).trim();
185
- }
216
+ const { branch } = getEnvironment();
217
+ return branch;
186
218
  } catch (err) {
219
+ return void 0;
187
220
  }
188
221
  }
189
-
190
- function getAPIKey() {
222
+ function buildPreviewBranchName({ org, branch }) {
223
+ return `preview-${org}-${branch}`;
224
+ }
225
+ function getPreviewBranch() {
191
226
  try {
192
- const { apiKey } = getEnvironment();
193
- return apiKey;
227
+ const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = getEnvironment();
228
+ if (deployPreviewBranch)
229
+ return deployPreviewBranch;
230
+ switch (deployPreview) {
231
+ case "vercel": {
232
+ if (!vercelGitCommitRef || !vercelGitRepoOwner) {
233
+ console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
234
+ return void 0;
235
+ }
236
+ return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
237
+ }
238
+ }
239
+ return void 0;
194
240
  } catch (err) {
195
241
  return void 0;
196
242
  }
197
243
  }
198
244
 
245
+ var __defProp$8 = Object.defineProperty;
246
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
247
+ var __publicField$8 = (obj, key, value) => {
248
+ __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
249
+ return value;
250
+ };
199
251
  var __accessCheck$8 = (obj, member, msg) => {
200
252
  if (!member.has(obj))
201
253
  throw TypeError("Cannot " + msg);
@@ -219,13 +271,13 @@ var __privateMethod$4 = (obj, member, method) => {
219
271
  return method;
220
272
  };
221
273
  var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
274
+ const REQUEST_TIMEOUT = 5 * 60 * 1e3;
222
275
  function getFetchImplementation(userFetch) {
223
276
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
224
- const fetchImpl = userFetch ?? globalFetch;
277
+ const globalThisFetch = typeof globalThis !== "undefined" ? globalThis.fetch : void 0;
278
+ const fetchImpl = userFetch ?? globalFetch ?? globalThisFetch;
225
279
  if (!fetchImpl) {
226
- throw new Error(
227
- `Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
228
- );
280
+ throw new Error(`Couldn't find a global \`fetch\`. Pass a fetch implementation explicitly.`);
229
281
  }
230
282
  return fetchImpl;
231
283
  }
@@ -235,6 +287,8 @@ class ApiRequestPool {
235
287
  __privateAdd$8(this, _fetch, void 0);
236
288
  __privateAdd$8(this, _queue, void 0);
237
289
  __privateAdd$8(this, _concurrency, void 0);
290
+ __publicField$8(this, "running");
291
+ __publicField$8(this, "started");
238
292
  __privateSet$8(this, _queue, []);
239
293
  __privateSet$8(this, _concurrency, concurrency);
240
294
  this.running = 0;
@@ -250,18 +304,22 @@ class ApiRequestPool {
250
304
  return __privateGet$8(this, _fetch);
251
305
  }
252
306
  request(url, options) {
253
- const start = new Date();
254
- const fetch2 = this.getFetch();
307
+ const start = /* @__PURE__ */ new Date();
308
+ const fetchImpl = this.getFetch();
255
309
  const runRequest = async (stalled = false) => {
256
- const response = await fetch2(url, options);
310
+ const { promise, cancel } = timeoutWithCancel(REQUEST_TIMEOUT);
311
+ const response = await Promise.race([fetchImpl(url, options), promise.then(() => null)]).finally(cancel);
312
+ if (!response) {
313
+ throw new Error("Request timed out");
314
+ }
257
315
  if (response.status === 429) {
258
316
  const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
259
317
  await timeout(rateLimitReset * 1e3);
260
318
  return await runRequest(true);
261
319
  }
262
320
  if (stalled) {
263
- const stalledTime = new Date().getTime() - start.getTime();
264
- console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
321
+ const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
322
+ console.warn(`A request to Xata hit branch rate limits, was retried and stalled for ${stalledTime}ms`);
265
323
  }
266
324
  return response;
267
325
  };
@@ -303,16 +361,199 @@ function generateUUID() {
303
361
  });
304
362
  }
305
363
 
306
- const VERSION = "0.0.0-alpha.vfafe7e2";
364
+ async function getBytes(stream, onChunk) {
365
+ const reader = stream.getReader();
366
+ let result;
367
+ while (!(result = await reader.read()).done) {
368
+ onChunk(result.value);
369
+ }
370
+ }
371
+ function getLines(onLine) {
372
+ let buffer;
373
+ let position;
374
+ let fieldLength;
375
+ let discardTrailingNewline = false;
376
+ return function onChunk(arr) {
377
+ if (buffer === void 0) {
378
+ buffer = arr;
379
+ position = 0;
380
+ fieldLength = -1;
381
+ } else {
382
+ buffer = concat(buffer, arr);
383
+ }
384
+ const bufLength = buffer.length;
385
+ let lineStart = 0;
386
+ while (position < bufLength) {
387
+ if (discardTrailingNewline) {
388
+ if (buffer[position] === 10 /* NewLine */) {
389
+ lineStart = ++position;
390
+ }
391
+ discardTrailingNewline = false;
392
+ }
393
+ let lineEnd = -1;
394
+ for (; position < bufLength && lineEnd === -1; ++position) {
395
+ switch (buffer[position]) {
396
+ case 58 /* Colon */:
397
+ if (fieldLength === -1) {
398
+ fieldLength = position - lineStart;
399
+ }
400
+ break;
401
+ case 13 /* CarriageReturn */:
402
+ discardTrailingNewline = true;
403
+ case 10 /* NewLine */:
404
+ lineEnd = position;
405
+ break;
406
+ }
407
+ }
408
+ if (lineEnd === -1) {
409
+ break;
410
+ }
411
+ onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
412
+ lineStart = position;
413
+ fieldLength = -1;
414
+ }
415
+ if (lineStart === bufLength) {
416
+ buffer = void 0;
417
+ } else if (lineStart !== 0) {
418
+ buffer = buffer.subarray(lineStart);
419
+ position -= lineStart;
420
+ }
421
+ };
422
+ }
423
+ function getMessages(onId, onRetry, onMessage) {
424
+ let message = newMessage();
425
+ const decoder = new TextDecoder();
426
+ return function onLine(line, fieldLength) {
427
+ if (line.length === 0) {
428
+ onMessage?.(message);
429
+ message = newMessage();
430
+ } else if (fieldLength > 0) {
431
+ const field = decoder.decode(line.subarray(0, fieldLength));
432
+ const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
433
+ const value = decoder.decode(line.subarray(valueOffset));
434
+ switch (field) {
435
+ case "data":
436
+ message.data = message.data ? message.data + "\n" + value : value;
437
+ break;
438
+ case "event":
439
+ message.event = value;
440
+ break;
441
+ case "id":
442
+ onId(message.id = value);
443
+ break;
444
+ case "retry":
445
+ const retry = parseInt(value, 10);
446
+ if (!isNaN(retry)) {
447
+ onRetry(message.retry = retry);
448
+ }
449
+ break;
450
+ }
451
+ }
452
+ };
453
+ }
454
+ function concat(a, b) {
455
+ const res = new Uint8Array(a.length + b.length);
456
+ res.set(a);
457
+ res.set(b, a.length);
458
+ return res;
459
+ }
460
+ function newMessage() {
461
+ return {
462
+ data: "",
463
+ event: "",
464
+ id: "",
465
+ retry: void 0
466
+ };
467
+ }
468
+ const EventStreamContentType = "text/event-stream";
469
+ const LastEventId = "last-event-id";
470
+ function fetchEventSource(input, {
471
+ signal: inputSignal,
472
+ headers: inputHeaders,
473
+ onopen: inputOnOpen,
474
+ onmessage,
475
+ onclose,
476
+ onerror,
477
+ fetch: inputFetch,
478
+ ...rest
479
+ }) {
480
+ return new Promise((resolve, reject) => {
481
+ const headers = { ...inputHeaders };
482
+ if (!headers.accept) {
483
+ headers.accept = EventStreamContentType;
484
+ }
485
+ let curRequestController;
486
+ function dispose() {
487
+ curRequestController.abort();
488
+ }
489
+ inputSignal?.addEventListener("abort", () => {
490
+ dispose();
491
+ resolve();
492
+ });
493
+ const fetchImpl = inputFetch ?? fetch;
494
+ const onopen = inputOnOpen ?? defaultOnOpen;
495
+ async function create() {
496
+ curRequestController = new AbortController();
497
+ try {
498
+ const response = await fetchImpl(input, {
499
+ ...rest,
500
+ headers,
501
+ signal: curRequestController.signal
502
+ });
503
+ await onopen(response);
504
+ await getBytes(
505
+ response.body,
506
+ getLines(
507
+ getMessages(
508
+ (id) => {
509
+ if (id) {
510
+ headers[LastEventId] = id;
511
+ } else {
512
+ delete headers[LastEventId];
513
+ }
514
+ },
515
+ (_retry) => {
516
+ },
517
+ onmessage
518
+ )
519
+ )
520
+ );
521
+ onclose?.();
522
+ dispose();
523
+ resolve();
524
+ } catch (err) {
525
+ }
526
+ }
527
+ create();
528
+ });
529
+ }
530
+ function defaultOnOpen(response) {
531
+ const contentType = response.headers?.get("content-type");
532
+ if (!contentType?.startsWith(EventStreamContentType)) {
533
+ throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
534
+ }
535
+ }
536
+
537
+ const VERSION = "0.26.5";
307
538
 
539
+ var __defProp$7 = Object.defineProperty;
540
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
541
+ var __publicField$7 = (obj, key, value) => {
542
+ __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
543
+ return value;
544
+ };
308
545
  class ErrorWithCause extends Error {
309
546
  constructor(message, options) {
310
547
  super(message, options);
548
+ __publicField$7(this, "cause");
311
549
  }
312
550
  }
313
551
  class FetcherError extends ErrorWithCause {
314
552
  constructor(status, data, requestId) {
315
553
  super(getMessage(data));
554
+ __publicField$7(this, "status");
555
+ __publicField$7(this, "requestId");
556
+ __publicField$7(this, "errors");
316
557
  this.status = status;
317
558
  this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
318
559
  this.requestId = requestId;
@@ -379,6 +620,18 @@ function hostHeader(url) {
379
620
  const { groups } = pattern.exec(url) ?? {};
380
621
  return groups?.host ? { Host: groups.host } : {};
381
622
  }
623
+ async function parseBody(body, headers) {
624
+ if (!isDefined(body))
625
+ return void 0;
626
+ if (isBlob(body) || typeof body.text === "function") {
627
+ return body;
628
+ }
629
+ const { "Content-Type": contentType } = headers ?? {};
630
+ if (String(contentType).toLowerCase() === "application/json" && isObject(body)) {
631
+ return JSON.stringify(body);
632
+ }
633
+ return body;
634
+ }
382
635
  const defaultClientID = generateUUID();
383
636
  async function fetch$1({
384
637
  url: path,
@@ -387,7 +640,7 @@ async function fetch$1({
387
640
  headers: customHeaders,
388
641
  pathParams,
389
642
  queryParams,
390
- fetchImpl,
643
+ fetch: fetch2,
391
644
  apiKey,
392
645
  endpoint,
393
646
  apiUrl,
@@ -397,12 +650,14 @@ async function fetch$1({
397
650
  clientID,
398
651
  sessionID,
399
652
  clientName,
400
- fetchOptions = {}
653
+ xataAgentExtra,
654
+ fetchOptions = {},
655
+ rawResponse = false
401
656
  }) {
402
- pool.setFetch(fetchImpl);
657
+ pool.setFetch(fetch2);
403
658
  return await trace(
404
659
  `${method.toUpperCase()} ${path}`,
405
- async ({ name, setAttributes }) => {
660
+ async ({ setAttributes }) => {
406
661
  const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
407
662
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
408
663
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
@@ -413,9 +668,10 @@ async function fetch$1({
413
668
  const xataAgent = compact([
414
669
  ["client", "TS_SDK"],
415
670
  ["version", VERSION],
416
- isDefined(clientName) ? ["service", clientName] : void 0
671
+ isDefined(clientName) ? ["service", clientName] : void 0,
672
+ ...Object.entries(xataAgentExtra ?? {})
417
673
  ]).map(([key, value]) => `${key}=${value}`).join("; ");
418
- const headers = {
674
+ const headers = compactObject({
419
675
  "Accept-Encoding": "identity",
420
676
  "Content-Type": "application/json",
421
677
  "X-Xata-Client-ID": clientID ?? defaultClientID,
@@ -424,11 +680,11 @@ async function fetch$1({
424
680
  ...customHeaders,
425
681
  ...hostHeader(fullUrl),
426
682
  Authorization: `Bearer ${apiKey}`
427
- };
683
+ });
428
684
  const response = await pool.request(url, {
429
685
  ...fetchOptions,
430
686
  method: method.toUpperCase(),
431
- body: body ? JSON.stringify(body) : void 0,
687
+ body: await parseBody(body, headers),
432
688
  headers,
433
689
  signal
434
690
  });
@@ -439,8 +695,12 @@ async function fetch$1({
439
695
  [TraceAttributes.HTTP_REQUEST_ID]: requestId,
440
696
  [TraceAttributes.HTTP_STATUS_CODE]: response.status,
441
697
  [TraceAttributes.HTTP_HOST]: host,
442
- [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
698
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", ""),
699
+ [TraceAttributes.CLOUDFLARE_RAY_ID]: response.headers?.get("cf-ray") ?? void 0
443
700
  });
701
+ const message = response.headers?.get("x-xata-message");
702
+ if (message)
703
+ console.warn(message);
444
704
  if (response.status === 204) {
445
705
  return {};
446
706
  }
@@ -448,7 +708,7 @@ async function fetch$1({
448
708
  throw new FetcherError(response.status, "Rate limit exceeded", requestId);
449
709
  }
450
710
  try {
451
- const jsonResponse = await response.json();
711
+ const jsonResponse = rawResponse ? await response.blob() : await response.json();
452
712
  if (response.ok) {
453
713
  return jsonResponse;
454
714
  }
@@ -460,6 +720,59 @@ async function fetch$1({
460
720
  { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
461
721
  );
462
722
  }
723
+ function fetchSSERequest({
724
+ url: path,
725
+ method,
726
+ body,
727
+ headers: customHeaders,
728
+ pathParams,
729
+ queryParams,
730
+ fetch: fetch2,
731
+ apiKey,
732
+ endpoint,
733
+ apiUrl,
734
+ workspacesApiUrl,
735
+ onMessage,
736
+ onError,
737
+ onClose,
738
+ signal,
739
+ clientID,
740
+ sessionID,
741
+ clientName,
742
+ xataAgentExtra
743
+ }) {
744
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
745
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
746
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
747
+ void fetchEventSource(url, {
748
+ method,
749
+ body: JSON.stringify(body),
750
+ fetch: fetch2,
751
+ signal,
752
+ headers: {
753
+ "X-Xata-Client-ID": clientID ?? defaultClientID,
754
+ "X-Xata-Session-ID": sessionID ?? generateUUID(),
755
+ "X-Xata-Agent": compact([
756
+ ["client", "TS_SDK"],
757
+ ["version", VERSION],
758
+ isDefined(clientName) ? ["service", clientName] : void 0,
759
+ ...Object.entries(xataAgentExtra ?? {})
760
+ ]).map(([key, value]) => `${key}=${value}`).join("; "),
761
+ ...customHeaders,
762
+ Authorization: `Bearer ${apiKey}`,
763
+ "Content-Type": "application/json"
764
+ },
765
+ onmessage(ev) {
766
+ onMessage?.(JSON.parse(ev.data));
767
+ },
768
+ onerror(ev) {
769
+ onError?.(JSON.parse(ev.data));
770
+ },
771
+ onclose() {
772
+ onClose?.();
773
+ }
774
+ });
775
+ }
463
776
  function parseUrl(url) {
464
777
  try {
465
778
  const { host, protocol } = new URL(url);
@@ -490,6 +803,12 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
490
803
  ...variables,
491
804
  signal
492
805
  });
806
+ const copyBranch = (variables, signal) => dataPlaneFetch({
807
+ url: "/db/{dbBranchName}/copy",
808
+ method: "post",
809
+ ...variables,
810
+ signal
811
+ });
493
812
  const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
494
813
  url: "/db/{dbBranchName}/metadata",
495
814
  method: "put",
@@ -515,7 +834,6 @@ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName
515
834
  const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
516
835
  const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
517
836
  const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
518
- const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
519
837
  const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
520
838
  const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
521
839
  const getMigrationRequest = (variables, signal) => dataPlaneFetch({
@@ -540,6 +858,7 @@ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{
540
858
  const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
541
859
  const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
542
860
  const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
861
+ const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
543
862
  const createTable = (variables, signal) => dataPlaneFetch({
544
863
  url: "/db/{dbBranchName}/tables/{tableName}",
545
864
  method: "put",
@@ -582,7 +901,44 @@ const deleteColumn = (variables, signal) => dataPlaneFetch({
582
901
  ...variables,
583
902
  signal
584
903
  });
904
+ const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
585
905
  const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
906
+ const getFileItem = (variables, signal) => dataPlaneFetch({
907
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
908
+ method: "get",
909
+ ...variables,
910
+ signal
911
+ });
912
+ const putFileItem = (variables, signal) => dataPlaneFetch({
913
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
914
+ method: "put",
915
+ ...variables,
916
+ signal
917
+ });
918
+ const deleteFileItem = (variables, signal) => dataPlaneFetch({
919
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
920
+ method: "delete",
921
+ ...variables,
922
+ signal
923
+ });
924
+ const getFile = (variables, signal) => dataPlaneFetch({
925
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
926
+ method: "get",
927
+ ...variables,
928
+ signal
929
+ });
930
+ const putFile = (variables, signal) => dataPlaneFetch({
931
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
932
+ method: "put",
933
+ ...variables,
934
+ signal
935
+ });
936
+ const deleteFile = (variables, signal) => dataPlaneFetch({
937
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
938
+ method: "delete",
939
+ ...variables,
940
+ signal
941
+ });
586
942
  const getRecord = (variables, signal) => dataPlaneFetch({
587
943
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
588
944
  method: "get",
@@ -612,14 +968,35 @@ const searchTable = (variables, signal) => dataPlaneFetch({
612
968
  ...variables,
613
969
  signal
614
970
  });
971
+ const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
972
+ const askTable = (variables, signal) => dataPlaneFetch({
973
+ url: "/db/{dbBranchName}/tables/{tableName}/ask",
974
+ method: "post",
975
+ ...variables,
976
+ signal
977
+ });
978
+ const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
615
979
  const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
616
980
  const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
981
+ const fileAccess = (variables, signal) => dataPlaneFetch({
982
+ url: "/file/{fileId}",
983
+ method: "get",
984
+ ...variables,
985
+ signal
986
+ });
987
+ const sqlQuery = (variables, signal) => dataPlaneFetch({
988
+ url: "/db/{dbBranchName}/sql",
989
+ method: "post",
990
+ ...variables,
991
+ signal
992
+ });
617
993
  const operationsByTag$2 = {
618
994
  branch: {
619
995
  getBranchList,
620
996
  getBranchDetails,
621
997
  createBranch,
622
998
  deleteBranch,
999
+ copyBranch,
623
1000
  updateBranchMetadata,
624
1001
  getBranchMetadata,
625
1002
  getBranchStats,
@@ -637,17 +1014,8 @@ const operationsByTag$2 = {
637
1014
  compareBranchSchemas,
638
1015
  updateBranchSchema,
639
1016
  previewBranchSchemaEdit,
640
- applyBranchSchemaEdit
641
- },
642
- records: {
643
- branchTransaction,
644
- insertRecord,
645
- getRecord,
646
- insertRecordWithID,
647
- updateRecordWithID,
648
- upsertRecordWithID,
649
- deleteRecord,
650
- bulkInsertTableRecords
1017
+ applyBranchSchemaEdit,
1018
+ pushBranchMigrations
651
1019
  },
652
1020
  migrationRequests: {
653
1021
  queryMigrationRequests,
@@ -671,11 +1039,34 @@ const operationsByTag$2 = {
671
1039
  updateColumn,
672
1040
  deleteColumn
673
1041
  },
674
- searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
1042
+ records: {
1043
+ branchTransaction,
1044
+ insertRecord,
1045
+ getRecord,
1046
+ insertRecordWithID,
1047
+ updateRecordWithID,
1048
+ upsertRecordWithID,
1049
+ deleteRecord,
1050
+ bulkInsertTableRecords
1051
+ },
1052
+ files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
1053
+ searchAndFilter: {
1054
+ queryTable,
1055
+ searchBranch,
1056
+ searchTable,
1057
+ vectorSearchTable,
1058
+ askTable,
1059
+ askTableSession,
1060
+ summarizeTable,
1061
+ aggregateTable
1062
+ },
1063
+ sql: { sqlQuery }
675
1064
  };
676
1065
 
677
1066
  const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
678
1067
 
1068
+ const getAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "get", ...variables, signal });
1069
+ const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
679
1070
  const getUser = (variables, signal) => controlPlaneFetch({
680
1071
  url: "/user",
681
1072
  method: "get",
@@ -712,6 +1103,31 @@ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
712
1103
  ...variables,
713
1104
  signal
714
1105
  });
1106
+ const getUserOAuthClients = (variables, signal) => controlPlaneFetch({
1107
+ url: "/user/oauth/clients",
1108
+ method: "get",
1109
+ ...variables,
1110
+ signal
1111
+ });
1112
+ const deleteUserOAuthClient = (variables, signal) => controlPlaneFetch({
1113
+ url: "/user/oauth/clients/{clientId}",
1114
+ method: "delete",
1115
+ ...variables,
1116
+ signal
1117
+ });
1118
+ const getUserOAuthAccessTokens = (variables, signal) => controlPlaneFetch({
1119
+ url: "/user/oauth/tokens",
1120
+ method: "get",
1121
+ ...variables,
1122
+ signal
1123
+ });
1124
+ const deleteOAuthAccessToken = (variables, signal) => controlPlaneFetch({
1125
+ url: "/user/oauth/tokens/{token}",
1126
+ method: "delete",
1127
+ ...variables,
1128
+ signal
1129
+ });
1130
+ const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({ url: "/user/oauth/tokens/{token}", method: "patch", ...variables, signal });
715
1131
  const getWorkspacesList = (variables, signal) => controlPlaneFetch({
716
1132
  url: "/workspaces",
717
1133
  method: "get",
@@ -770,6 +1186,10 @@ const deleteDatabase = (variables, signal) => controlPlaneFetch({
770
1186
  });
771
1187
  const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
772
1188
  const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
1189
+ const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
1190
+ const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
1191
+ const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
1192
+ const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
773
1193
  const listRegions = (variables, signal) => controlPlaneFetch({
774
1194
  url: "/workspaces/{workspaceId}/regions",
775
1195
  method: "get",
@@ -777,6 +1197,15 @@ const listRegions = (variables, signal) => controlPlaneFetch({
777
1197
  signal
778
1198
  });
779
1199
  const operationsByTag$1 = {
1200
+ oAuth: {
1201
+ getAuthorizationCode,
1202
+ grantAuthorizationCode,
1203
+ getUserOAuthClients,
1204
+ deleteUserOAuthClient,
1205
+ getUserOAuthAccessTokens,
1206
+ deleteOAuthAccessToken,
1207
+ updateOAuthAccessToken
1208
+ },
780
1209
  users: { getUser, updateUser, deleteUser },
781
1210
  authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
782
1211
  workspaces: {
@@ -802,6 +1231,10 @@ const operationsByTag$1 = {
802
1231
  deleteDatabase,
803
1232
  getDatabaseMetadata,
804
1233
  updateDatabaseMetadata,
1234
+ renameDatabase,
1235
+ getDatabaseGithubSettings,
1236
+ updateDatabaseGithubSettings,
1237
+ deleteDatabaseGithubSettings,
805
1238
  listRegions
806
1239
  }
807
1240
  };
@@ -822,8 +1255,12 @@ const providers = {
822
1255
  workspaces: "https://{workspaceId}.{region}.xata.sh"
823
1256
  },
824
1257
  staging: {
825
- main: "https://staging.xatabase.co",
826
- workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
1258
+ main: "https://api.staging-xata.dev",
1259
+ workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
1260
+ },
1261
+ dev: {
1262
+ main: "https://api.dev-xata.dev",
1263
+ workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
827
1264
  }
828
1265
  };
829
1266
  function isHostProviderAlias(alias) {
@@ -841,12 +1278,19 @@ function parseProviderString(provider = "production") {
841
1278
  return null;
842
1279
  return { main, workspaces };
843
1280
  }
1281
+ function buildProviderString(provider) {
1282
+ if (isHostProviderAlias(provider))
1283
+ return provider;
1284
+ return `${provider.main},${provider.workspaces}`;
1285
+ }
844
1286
  function parseWorkspacesUrlParts(url) {
845
1287
  if (!isString(url))
846
1288
  return null;
847
1289
  const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
848
- const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))\.xatabase\.co.*/;
849
- const match = url.match(regex) || url.match(regexStaging);
1290
+ const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
1291
+ const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
1292
+ const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
1293
+ const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
850
1294
  if (!match)
851
1295
  return null;
852
1296
  return { workspace: match[1], region: match[2] };
@@ -885,10 +1329,11 @@ class XataApiClient {
885
1329
  __privateSet$7(this, _extraProps, {
886
1330
  apiUrl: getHostUrl(provider, "main"),
887
1331
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
888
- fetchImpl: getFetchImplementation(options.fetch),
1332
+ fetch: getFetchImplementation(options.fetch),
889
1333
  apiKey,
890
1334
  trace,
891
1335
  clientName: options.clientName,
1336
+ xataAgentExtra: options.xataAgentExtra,
892
1337
  clientID
893
1338
  });
894
1339
  }
@@ -942,6 +1387,11 @@ class XataApiClient {
942
1387
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
943
1388
  return __privateGet$7(this, _namespaces).records;
944
1389
  }
1390
+ get files() {
1391
+ if (!__privateGet$7(this, _namespaces).files)
1392
+ __privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
1393
+ return __privateGet$7(this, _namespaces).files;
1394
+ }
945
1395
  get searchAndFilter() {
946
1396
  if (!__privateGet$7(this, _namespaces).searchAndFilter)
947
1397
  __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
@@ -1150,6 +1600,20 @@ class BranchApi {
1150
1600
  ...this.extraProps
1151
1601
  });
1152
1602
  }
1603
+ copyBranch({
1604
+ workspace,
1605
+ region,
1606
+ database,
1607
+ branch,
1608
+ destinationBranch,
1609
+ limit
1610
+ }) {
1611
+ return operationsByTag.branch.copyBranch({
1612
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1613
+ body: { destinationBranch, limit },
1614
+ ...this.extraProps
1615
+ });
1616
+ }
1153
1617
  updateBranchMetadata({
1154
1618
  workspace,
1155
1619
  region,
@@ -1505,82 +1969,287 @@ class RecordsApi {
1505
1969
  });
1506
1970
  }
1507
1971
  }
1508
- class SearchAndFilterApi {
1972
+ class FilesApi {
1509
1973
  constructor(extraProps) {
1510
1974
  this.extraProps = extraProps;
1511
1975
  }
1512
- queryTable({
1976
+ getFileItem({
1513
1977
  workspace,
1514
1978
  region,
1515
1979
  database,
1516
1980
  branch,
1517
1981
  table,
1518
- filter,
1519
- sort,
1520
- page,
1521
- columns,
1522
- consistency
1982
+ record,
1983
+ column,
1984
+ fileId
1523
1985
  }) {
1524
- return operationsByTag.searchAndFilter.queryTable({
1525
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1526
- body: { filter, sort, page, columns, consistency },
1986
+ return operationsByTag.files.getFileItem({
1987
+ pathParams: {
1988
+ workspace,
1989
+ region,
1990
+ dbBranchName: `${database}:${branch}`,
1991
+ tableName: table,
1992
+ recordId: record,
1993
+ columnName: column,
1994
+ fileId
1995
+ },
1527
1996
  ...this.extraProps
1528
1997
  });
1529
1998
  }
1530
- searchTable({
1999
+ putFileItem({
1531
2000
  workspace,
1532
2001
  region,
1533
2002
  database,
1534
2003
  branch,
1535
2004
  table,
1536
- query,
1537
- fuzziness,
1538
- target,
1539
- prefix,
1540
- filter,
1541
- highlight,
1542
- boosters
2005
+ record,
2006
+ column,
2007
+ fileId,
2008
+ file
1543
2009
  }) {
1544
- return operationsByTag.searchAndFilter.searchTable({
1545
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1546
- body: { query, fuzziness, target, prefix, filter, highlight, boosters },
2010
+ return operationsByTag.files.putFileItem({
2011
+ pathParams: {
2012
+ workspace,
2013
+ region,
2014
+ dbBranchName: `${database}:${branch}`,
2015
+ tableName: table,
2016
+ recordId: record,
2017
+ columnName: column,
2018
+ fileId
2019
+ },
2020
+ // @ts-ignore
2021
+ body: file,
1547
2022
  ...this.extraProps
1548
2023
  });
1549
2024
  }
1550
- searchBranch({
2025
+ deleteFileItem({
1551
2026
  workspace,
1552
2027
  region,
1553
2028
  database,
1554
2029
  branch,
1555
- tables,
1556
- query,
1557
- fuzziness,
1558
- prefix,
1559
- highlight
2030
+ table,
2031
+ record,
2032
+ column,
2033
+ fileId
1560
2034
  }) {
1561
- return operationsByTag.searchAndFilter.searchBranch({
1562
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1563
- body: { tables, query, fuzziness, prefix, highlight },
2035
+ return operationsByTag.files.deleteFileItem({
2036
+ pathParams: {
2037
+ workspace,
2038
+ region,
2039
+ dbBranchName: `${database}:${branch}`,
2040
+ tableName: table,
2041
+ recordId: record,
2042
+ columnName: column,
2043
+ fileId
2044
+ },
1564
2045
  ...this.extraProps
1565
2046
  });
1566
2047
  }
1567
- summarizeTable({
2048
+ getFile({
1568
2049
  workspace,
1569
2050
  region,
1570
2051
  database,
1571
2052
  branch,
1572
2053
  table,
1573
- filter,
1574
- columns,
1575
- summaries,
1576
- sort,
1577
- summariesFilter,
1578
- page,
1579
- consistency
2054
+ record,
2055
+ column
1580
2056
  }) {
1581
- return operationsByTag.searchAndFilter.summarizeTable({
1582
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1583
- body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
2057
+ return operationsByTag.files.getFile({
2058
+ pathParams: {
2059
+ workspace,
2060
+ region,
2061
+ dbBranchName: `${database}:${branch}`,
2062
+ tableName: table,
2063
+ recordId: record,
2064
+ columnName: column
2065
+ },
2066
+ ...this.extraProps
2067
+ });
2068
+ }
2069
+ putFile({
2070
+ workspace,
2071
+ region,
2072
+ database,
2073
+ branch,
2074
+ table,
2075
+ record,
2076
+ column,
2077
+ file
2078
+ }) {
2079
+ return operationsByTag.files.putFile({
2080
+ pathParams: {
2081
+ workspace,
2082
+ region,
2083
+ dbBranchName: `${database}:${branch}`,
2084
+ tableName: table,
2085
+ recordId: record,
2086
+ columnName: column
2087
+ },
2088
+ body: file,
2089
+ ...this.extraProps
2090
+ });
2091
+ }
2092
+ deleteFile({
2093
+ workspace,
2094
+ region,
2095
+ database,
2096
+ branch,
2097
+ table,
2098
+ record,
2099
+ column
2100
+ }) {
2101
+ return operationsByTag.files.deleteFile({
2102
+ pathParams: {
2103
+ workspace,
2104
+ region,
2105
+ dbBranchName: `${database}:${branch}`,
2106
+ tableName: table,
2107
+ recordId: record,
2108
+ columnName: column
2109
+ },
2110
+ ...this.extraProps
2111
+ });
2112
+ }
2113
+ fileAccess({
2114
+ workspace,
2115
+ region,
2116
+ fileId,
2117
+ verify
2118
+ }) {
2119
+ return operationsByTag.files.fileAccess({
2120
+ pathParams: {
2121
+ workspace,
2122
+ region,
2123
+ fileId
2124
+ },
2125
+ queryParams: { verify },
2126
+ ...this.extraProps
2127
+ });
2128
+ }
2129
+ }
2130
+ class SearchAndFilterApi {
2131
+ constructor(extraProps) {
2132
+ this.extraProps = extraProps;
2133
+ }
2134
+ queryTable({
2135
+ workspace,
2136
+ region,
2137
+ database,
2138
+ branch,
2139
+ table,
2140
+ filter,
2141
+ sort,
2142
+ page,
2143
+ columns,
2144
+ consistency
2145
+ }) {
2146
+ return operationsByTag.searchAndFilter.queryTable({
2147
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2148
+ body: { filter, sort, page, columns, consistency },
2149
+ ...this.extraProps
2150
+ });
2151
+ }
2152
+ searchTable({
2153
+ workspace,
2154
+ region,
2155
+ database,
2156
+ branch,
2157
+ table,
2158
+ query,
2159
+ fuzziness,
2160
+ target,
2161
+ prefix,
2162
+ filter,
2163
+ highlight,
2164
+ boosters
2165
+ }) {
2166
+ return operationsByTag.searchAndFilter.searchTable({
2167
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2168
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
2169
+ ...this.extraProps
2170
+ });
2171
+ }
2172
+ searchBranch({
2173
+ workspace,
2174
+ region,
2175
+ database,
2176
+ branch,
2177
+ tables,
2178
+ query,
2179
+ fuzziness,
2180
+ prefix,
2181
+ highlight
2182
+ }) {
2183
+ return operationsByTag.searchAndFilter.searchBranch({
2184
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2185
+ body: { tables, query, fuzziness, prefix, highlight },
2186
+ ...this.extraProps
2187
+ });
2188
+ }
2189
+ vectorSearchTable({
2190
+ workspace,
2191
+ region,
2192
+ database,
2193
+ branch,
2194
+ table,
2195
+ queryVector,
2196
+ column,
2197
+ similarityFunction,
2198
+ size,
2199
+ filter
2200
+ }) {
2201
+ return operationsByTag.searchAndFilter.vectorSearchTable({
2202
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2203
+ body: { queryVector, column, similarityFunction, size, filter },
2204
+ ...this.extraProps
2205
+ });
2206
+ }
2207
+ askTable({
2208
+ workspace,
2209
+ region,
2210
+ database,
2211
+ branch,
2212
+ table,
2213
+ options
2214
+ }) {
2215
+ return operationsByTag.searchAndFilter.askTable({
2216
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2217
+ body: { ...options },
2218
+ ...this.extraProps
2219
+ });
2220
+ }
2221
+ askTableSession({
2222
+ workspace,
2223
+ region,
2224
+ database,
2225
+ branch,
2226
+ table,
2227
+ sessionId,
2228
+ message
2229
+ }) {
2230
+ return operationsByTag.searchAndFilter.askTableSession({
2231
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
2232
+ body: { message },
2233
+ ...this.extraProps
2234
+ });
2235
+ }
2236
+ summarizeTable({
2237
+ workspace,
2238
+ region,
2239
+ database,
2240
+ branch,
2241
+ table,
2242
+ filter,
2243
+ columns,
2244
+ summaries,
2245
+ sort,
2246
+ summariesFilter,
2247
+ page,
2248
+ consistency
2249
+ }) {
2250
+ return operationsByTag.searchAndFilter.summarizeTable({
2251
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2252
+ body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
1584
2253
  ...this.extraProps
1585
2254
  });
1586
2255
  }
@@ -1764,11 +2433,13 @@ class MigrationsApi {
1764
2433
  region,
1765
2434
  database,
1766
2435
  branch,
1767
- schema
2436
+ schema,
2437
+ schemaOperations,
2438
+ branchOperations
1768
2439
  }) {
1769
2440
  return operationsByTag.migrations.compareBranchWithUserSchema({
1770
2441
  pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1771
- body: { schema },
2442
+ body: { schema, schemaOperations, branchOperations },
1772
2443
  ...this.extraProps
1773
2444
  });
1774
2445
  }
@@ -1778,11 +2449,12 @@ class MigrationsApi {
1778
2449
  database,
1779
2450
  branch,
1780
2451
  compare,
1781
- schema
2452
+ sourceBranchOperations,
2453
+ targetBranchOperations
1782
2454
  }) {
1783
2455
  return operationsByTag.migrations.compareBranchSchemas({
1784
2456
  pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
1785
- body: { schema },
2457
+ body: { sourceBranchOperations, targetBranchOperations },
1786
2458
  ...this.extraProps
1787
2459
  });
1788
2460
  }
@@ -1825,6 +2497,19 @@ class MigrationsApi {
1825
2497
  ...this.extraProps
1826
2498
  });
1827
2499
  }
2500
+ pushBranchMigrations({
2501
+ workspace,
2502
+ region,
2503
+ database,
2504
+ branch,
2505
+ migrations
2506
+ }) {
2507
+ return operationsByTag.migrations.pushBranchMigrations({
2508
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2509
+ body: { migrations },
2510
+ ...this.extraProps
2511
+ });
2512
+ }
1828
2513
  }
1829
2514
  class DatabaseApi {
1830
2515
  constructor(extraProps) {
@@ -1839,11 +2524,13 @@ class DatabaseApi {
1839
2524
  createDatabase({
1840
2525
  workspace,
1841
2526
  database,
1842
- data
2527
+ data,
2528
+ headers
1843
2529
  }) {
1844
2530
  return operationsByTag.databases.createDatabase({
1845
2531
  pathParams: { workspaceId: workspace, dbName: database },
1846
2532
  body: data,
2533
+ headers,
1847
2534
  ...this.extraProps
1848
2535
  });
1849
2536
  }
@@ -1876,6 +2563,46 @@ class DatabaseApi {
1876
2563
  ...this.extraProps
1877
2564
  });
1878
2565
  }
2566
+ renameDatabase({
2567
+ workspace,
2568
+ database,
2569
+ newName
2570
+ }) {
2571
+ return operationsByTag.databases.renameDatabase({
2572
+ pathParams: { workspaceId: workspace, dbName: database },
2573
+ body: { newName },
2574
+ ...this.extraProps
2575
+ });
2576
+ }
2577
+ getDatabaseGithubSettings({
2578
+ workspace,
2579
+ database
2580
+ }) {
2581
+ return operationsByTag.databases.getDatabaseGithubSettings({
2582
+ pathParams: { workspaceId: workspace, dbName: database },
2583
+ ...this.extraProps
2584
+ });
2585
+ }
2586
+ updateDatabaseGithubSettings({
2587
+ workspace,
2588
+ database,
2589
+ settings
2590
+ }) {
2591
+ return operationsByTag.databases.updateDatabaseGithubSettings({
2592
+ pathParams: { workspaceId: workspace, dbName: database },
2593
+ body: settings,
2594
+ ...this.extraProps
2595
+ });
2596
+ }
2597
+ deleteDatabaseGithubSettings({
2598
+ workspace,
2599
+ database
2600
+ }) {
2601
+ return operationsByTag.databases.deleteDatabaseGithubSettings({
2602
+ pathParams: { workspaceId: workspace, dbName: database },
2603
+ ...this.extraProps
2604
+ });
2605
+ }
1879
2606
  listRegions({ workspace }) {
1880
2607
  return operationsByTag.databases.listRegions({
1881
2608
  pathParams: { workspaceId: workspace },
@@ -1885,22 +2612,327 @@ class DatabaseApi {
1885
2612
  }
1886
2613
 
1887
2614
  class XataApiPlugin {
1888
- async build(options) {
1889
- const { fetchImpl, apiKey } = await options.getFetchProps();
1890
- return new XataApiClient({ fetch: fetchImpl, apiKey });
2615
+ build(options) {
2616
+ return new XataApiClient(options);
1891
2617
  }
1892
2618
  }
1893
2619
 
1894
2620
  class XataPlugin {
1895
2621
  }
1896
2622
 
2623
+ class FilesPlugin extends XataPlugin {
2624
+ build(pluginOptions) {
2625
+ return {
2626
+ download: async (location) => {
2627
+ const { table, record, column, fileId = "" } = location ?? {};
2628
+ return await getFileItem({
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
+ rawResponse: true
2640
+ });
2641
+ },
2642
+ upload: async (location, file) => {
2643
+ const { table, record, column, fileId = "" } = location ?? {};
2644
+ const contentType = getContentType(file);
2645
+ return await putFileItem({
2646
+ ...pluginOptions,
2647
+ pathParams: {
2648
+ workspace: "{workspaceId}",
2649
+ dbBranchName: "{dbBranch}",
2650
+ region: "{region}",
2651
+ tableName: table ?? "",
2652
+ recordId: record ?? "",
2653
+ columnName: column ?? "",
2654
+ fileId
2655
+ },
2656
+ body: file,
2657
+ headers: { "Content-Type": contentType }
2658
+ });
2659
+ },
2660
+ delete: async (location) => {
2661
+ const { table, record, column, fileId = "" } = location ?? {};
2662
+ return await deleteFileItem({
2663
+ pathParams: {
2664
+ workspace: "{workspaceId}",
2665
+ dbBranchName: "{dbBranch}",
2666
+ region: "{region}",
2667
+ tableName: table ?? "",
2668
+ recordId: record ?? "",
2669
+ columnName: column ?? "",
2670
+ fileId
2671
+ },
2672
+ ...pluginOptions
2673
+ });
2674
+ }
2675
+ };
2676
+ }
2677
+ }
2678
+ function getContentType(file) {
2679
+ if (typeof file === "string") {
2680
+ return "text/plain";
2681
+ }
2682
+ if (isBlob(file)) {
2683
+ return file.type;
2684
+ }
2685
+ try {
2686
+ return file.type;
2687
+ } catch (e) {
2688
+ }
2689
+ return "application/octet-stream";
2690
+ }
2691
+
2692
+ function buildTransformString(transformations) {
2693
+ return transformations.flatMap(
2694
+ (t) => Object.entries(t).map(([key, value]) => {
2695
+ if (key === "trim") {
2696
+ const { left = 0, top = 0, right = 0, bottom = 0 } = value;
2697
+ return `${key}=${[top, right, bottom, left].join(";")}`;
2698
+ }
2699
+ if (key === "gravity" && typeof value === "object") {
2700
+ const { x = 0.5, y = 0.5 } = value;
2701
+ return `${key}=${[x, y].join("x")}`;
2702
+ }
2703
+ return `${key}=${value}`;
2704
+ })
2705
+ ).join(",");
2706
+ }
2707
+ function transformImage(url, ...transformations) {
2708
+ if (!isDefined(url))
2709
+ return void 0;
2710
+ const newTransformations = buildTransformString(transformations);
2711
+ const { hostname, pathname, search } = new URL(url);
2712
+ const pathParts = pathname.split("/");
2713
+ const transformIndex = pathParts.findIndex((part) => part === "transform");
2714
+ const removedItems = transformIndex >= 0 ? pathParts.splice(transformIndex, 2) : [];
2715
+ const transform = `/transform/${[removedItems[1], newTransformations].filter(isDefined).join(",")}`;
2716
+ const path = pathParts.join("/");
2717
+ return `https://${hostname}${transform}${path}${search}`;
2718
+ }
2719
+
2720
+ var __defProp$6 = Object.defineProperty;
2721
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2722
+ var __publicField$6 = (obj, key, value) => {
2723
+ __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
2724
+ return value;
2725
+ };
2726
+ class XataFile {
2727
+ constructor(file) {
2728
+ /**
2729
+ * Identifier of the file.
2730
+ */
2731
+ __publicField$6(this, "id");
2732
+ /**
2733
+ * Name of the file.
2734
+ */
2735
+ __publicField$6(this, "name");
2736
+ /**
2737
+ * Media type of the file.
2738
+ */
2739
+ __publicField$6(this, "mediaType");
2740
+ /**
2741
+ * Base64 encoded content of the file.
2742
+ */
2743
+ __publicField$6(this, "base64Content");
2744
+ /**
2745
+ * Whether to enable public url for the file.
2746
+ */
2747
+ __publicField$6(this, "enablePublicUrl");
2748
+ /**
2749
+ * Timeout for the signed url.
2750
+ */
2751
+ __publicField$6(this, "signedUrlTimeout");
2752
+ /**
2753
+ * Size of the file.
2754
+ */
2755
+ __publicField$6(this, "size");
2756
+ /**
2757
+ * Version of the file.
2758
+ */
2759
+ __publicField$6(this, "version");
2760
+ /**
2761
+ * Url of the file.
2762
+ */
2763
+ __publicField$6(this, "url");
2764
+ /**
2765
+ * Signed url of the file.
2766
+ */
2767
+ __publicField$6(this, "signedUrl");
2768
+ /**
2769
+ * Attributes of the file.
2770
+ */
2771
+ __publicField$6(this, "attributes");
2772
+ this.id = file.id;
2773
+ this.name = file.name || "";
2774
+ this.mediaType = file.mediaType || "application/octet-stream";
2775
+ this.base64Content = file.base64Content;
2776
+ this.enablePublicUrl = file.enablePublicUrl ?? false;
2777
+ this.signedUrlTimeout = file.signedUrlTimeout ?? 300;
2778
+ this.size = file.size ?? 0;
2779
+ this.version = file.version ?? 1;
2780
+ this.url = file.url || "";
2781
+ this.signedUrl = file.signedUrl;
2782
+ this.attributes = file.attributes || {};
2783
+ }
2784
+ static fromBuffer(buffer, options = {}) {
2785
+ const base64Content = buffer.toString("base64");
2786
+ return new XataFile({ ...options, base64Content });
2787
+ }
2788
+ toBuffer() {
2789
+ if (!this.base64Content) {
2790
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2791
+ }
2792
+ return Buffer.from(this.base64Content, "base64");
2793
+ }
2794
+ static fromArrayBuffer(arrayBuffer, options = {}) {
2795
+ const uint8Array = new Uint8Array(arrayBuffer);
2796
+ return this.fromUint8Array(uint8Array, options);
2797
+ }
2798
+ toArrayBuffer() {
2799
+ if (!this.base64Content) {
2800
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2801
+ }
2802
+ const binary = atob(this.base64Content);
2803
+ return new ArrayBuffer(binary.length);
2804
+ }
2805
+ static fromUint8Array(uint8Array, options = {}) {
2806
+ let binary = "";
2807
+ for (let i = 0; i < uint8Array.byteLength; i++) {
2808
+ binary += String.fromCharCode(uint8Array[i]);
2809
+ }
2810
+ const base64Content = btoa(binary);
2811
+ return new XataFile({ ...options, base64Content });
2812
+ }
2813
+ toUint8Array() {
2814
+ if (!this.base64Content) {
2815
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2816
+ }
2817
+ const binary = atob(this.base64Content);
2818
+ const uint8Array = new Uint8Array(binary.length);
2819
+ for (let i = 0; i < binary.length; i++) {
2820
+ uint8Array[i] = binary.charCodeAt(i);
2821
+ }
2822
+ return uint8Array;
2823
+ }
2824
+ static async fromBlob(file, options = {}) {
2825
+ const name = options.name ?? file.name;
2826
+ const mediaType = file.type;
2827
+ const arrayBuffer = await file.arrayBuffer();
2828
+ return this.fromArrayBuffer(arrayBuffer, { ...options, name, mediaType });
2829
+ }
2830
+ toBlob() {
2831
+ if (!this.base64Content) {
2832
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2833
+ }
2834
+ const binary = atob(this.base64Content);
2835
+ const uint8Array = new Uint8Array(binary.length);
2836
+ for (let i = 0; i < binary.length; i++) {
2837
+ uint8Array[i] = binary.charCodeAt(i);
2838
+ }
2839
+ return new Blob([uint8Array], { type: this.mediaType });
2840
+ }
2841
+ static fromString(string, options = {}) {
2842
+ const base64Content = btoa(string);
2843
+ return new XataFile({ ...options, base64Content });
2844
+ }
2845
+ toString() {
2846
+ if (!this.base64Content) {
2847
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2848
+ }
2849
+ return atob(this.base64Content);
2850
+ }
2851
+ static fromBase64(base64Content, options = {}) {
2852
+ return new XataFile({ ...options, base64Content });
2853
+ }
2854
+ toBase64() {
2855
+ if (!this.base64Content) {
2856
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2857
+ }
2858
+ return this.base64Content;
2859
+ }
2860
+ transform(...options) {
2861
+ return {
2862
+ url: transformImage(this.url, ...options),
2863
+ signedUrl: transformImage(this.signedUrl, ...options),
2864
+ metadataUrl: transformImage(this.url, ...options, { format: "json" }),
2865
+ metadataSignedUrl: transformImage(this.signedUrl, ...options, { format: "json" })
2866
+ };
2867
+ }
2868
+ }
2869
+ const parseInputFileEntry = async (entry) => {
2870
+ if (!isDefined(entry))
2871
+ return null;
2872
+ const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
2873
+ return compactObject({
2874
+ id,
2875
+ // Name cannot be an empty string in our API
2876
+ name: name ? name : void 0,
2877
+ mediaType,
2878
+ base64Content,
2879
+ enablePublicUrl,
2880
+ signedUrlTimeout
2881
+ });
2882
+ };
2883
+
1897
2884
  function cleanFilter(filter) {
1898
- if (!filter)
2885
+ if (!isDefined(filter))
1899
2886
  return void 0;
1900
- const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
1901
- return values.length > 0 ? filter : void 0;
2887
+ if (!isObject(filter))
2888
+ return filter;
2889
+ const values = Object.fromEntries(
2890
+ Object.entries(filter).reduce((acc, [key, value]) => {
2891
+ if (!isDefined(value))
2892
+ return acc;
2893
+ if (Array.isArray(value)) {
2894
+ const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
2895
+ if (clean.length === 0)
2896
+ return acc;
2897
+ return [...acc, [key, clean]];
2898
+ }
2899
+ if (isObject(value)) {
2900
+ const clean = cleanFilter(value);
2901
+ if (!isDefined(clean))
2902
+ return acc;
2903
+ return [...acc, [key, clean]];
2904
+ }
2905
+ return [...acc, [key, value]];
2906
+ }, [])
2907
+ );
2908
+ return Object.keys(values).length > 0 ? values : void 0;
1902
2909
  }
1903
2910
 
2911
+ function stringifyJson(value) {
2912
+ if (!isDefined(value))
2913
+ return value;
2914
+ if (isString(value))
2915
+ return value;
2916
+ try {
2917
+ return JSON.stringify(value);
2918
+ } catch (e) {
2919
+ return value;
2920
+ }
2921
+ }
2922
+ function parseJson(value) {
2923
+ try {
2924
+ return JSON.parse(value);
2925
+ } catch (e) {
2926
+ return value;
2927
+ }
2928
+ }
2929
+
2930
+ var __defProp$5 = Object.defineProperty;
2931
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2932
+ var __publicField$5 = (obj, key, value) => {
2933
+ __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
2934
+ return value;
2935
+ };
1904
2936
  var __accessCheck$6 = (obj, member, msg) => {
1905
2937
  if (!member.has(obj))
1906
2938
  throw TypeError("Cannot " + msg);
@@ -1923,22 +2955,58 @@ var _query, _page;
1923
2955
  class Page {
1924
2956
  constructor(query, meta, records = []) {
1925
2957
  __privateAdd$6(this, _query, void 0);
2958
+ /**
2959
+ * Page metadata, required to retrieve additional records.
2960
+ */
2961
+ __publicField$5(this, "meta");
2962
+ /**
2963
+ * The set of results for this page.
2964
+ */
2965
+ __publicField$5(this, "records");
1926
2966
  __privateSet$6(this, _query, query);
1927
2967
  this.meta = meta;
1928
2968
  this.records = new RecordArray(this, records);
1929
2969
  }
2970
+ /**
2971
+ * Retrieves the next page of results.
2972
+ * @param size Maximum number of results to be retrieved.
2973
+ * @param offset Number of results to skip when retrieving the results.
2974
+ * @returns The next page or results.
2975
+ */
1930
2976
  async nextPage(size, offset) {
1931
2977
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
1932
2978
  }
2979
+ /**
2980
+ * Retrieves the previous page of results.
2981
+ * @param size Maximum number of results to be retrieved.
2982
+ * @param offset Number of results to skip when retrieving the results.
2983
+ * @returns The previous page or results.
2984
+ */
1933
2985
  async previousPage(size, offset) {
1934
2986
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
1935
2987
  }
2988
+ /**
2989
+ * Retrieves the start page of results.
2990
+ * @param size Maximum number of results to be retrieved.
2991
+ * @param offset Number of results to skip when retrieving the results.
2992
+ * @returns The start page or results.
2993
+ */
1936
2994
  async startPage(size, offset) {
1937
2995
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
1938
2996
  }
2997
+ /**
2998
+ * Retrieves the end page of results.
2999
+ * @param size Maximum number of results to be retrieved.
3000
+ * @param offset Number of results to skip when retrieving the results.
3001
+ * @returns The end page or results.
3002
+ */
1939
3003
  async endPage(size, offset) {
1940
3004
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
1941
3005
  }
3006
+ /**
3007
+ * Shortcut method to check if there will be additional results if the next page of results is retrieved.
3008
+ * @returns Whether or not there will be additional results in the next page of results.
3009
+ */
1942
3010
  hasNextPage() {
1943
3011
  return this.meta.page.more;
1944
3012
  }
@@ -1951,7 +3019,7 @@ const PAGINATION_DEFAULT_OFFSET = 0;
1951
3019
  function isCursorPaginationOptions(options) {
1952
3020
  return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
1953
3021
  }
1954
- const _RecordArray = class extends Array {
3022
+ const _RecordArray = class _RecordArray extends Array {
1955
3023
  constructor(...args) {
1956
3024
  super(..._RecordArray.parseConstructorParams(...args));
1957
3025
  __privateAdd$6(this, _page, void 0);
@@ -1970,32 +3038,67 @@ const _RecordArray = class extends Array {
1970
3038
  toArray() {
1971
3039
  return new Array(...this);
1972
3040
  }
3041
+ toSerializable() {
3042
+ return JSON.parse(this.toString());
3043
+ }
3044
+ toString() {
3045
+ return JSON.stringify(this.toArray());
3046
+ }
1973
3047
  map(callbackfn, thisArg) {
1974
3048
  return this.toArray().map(callbackfn, thisArg);
1975
3049
  }
3050
+ /**
3051
+ * Retrieve next page of records
3052
+ *
3053
+ * @returns A new array of objects
3054
+ */
1976
3055
  async nextPage(size, offset) {
1977
3056
  const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
1978
3057
  return new _RecordArray(newPage);
1979
3058
  }
3059
+ /**
3060
+ * Retrieve previous page of records
3061
+ *
3062
+ * @returns A new array of objects
3063
+ */
1980
3064
  async previousPage(size, offset) {
1981
3065
  const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
1982
3066
  return new _RecordArray(newPage);
1983
3067
  }
3068
+ /**
3069
+ * Retrieve start page of records
3070
+ *
3071
+ * @returns A new array of objects
3072
+ */
1984
3073
  async startPage(size, offset) {
1985
3074
  const newPage = await __privateGet$6(this, _page).startPage(size, offset);
1986
3075
  return new _RecordArray(newPage);
1987
3076
  }
3077
+ /**
3078
+ * Retrieve end page of records
3079
+ *
3080
+ * @returns A new array of objects
3081
+ */
1988
3082
  async endPage(size, offset) {
1989
3083
  const newPage = await __privateGet$6(this, _page).endPage(size, offset);
1990
3084
  return new _RecordArray(newPage);
1991
3085
  }
3086
+ /**
3087
+ * @returns Boolean indicating if there is a next page
3088
+ */
1992
3089
  hasNextPage() {
1993
3090
  return __privateGet$6(this, _page).meta.page.more;
1994
3091
  }
1995
3092
  };
1996
- let RecordArray = _RecordArray;
1997
3093
  _page = new WeakMap();
3094
+ let RecordArray = _RecordArray;
1998
3095
 
3096
+ var __defProp$4 = Object.defineProperty;
3097
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3098
+ var __publicField$4 = (obj, key, value) => {
3099
+ __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
3100
+ return value;
3101
+ };
1999
3102
  var __accessCheck$5 = (obj, member, msg) => {
2000
3103
  if (!member.has(obj))
2001
3104
  throw TypeError("Cannot " + msg);
@@ -2019,14 +3122,15 @@ var __privateMethod$3 = (obj, member, method) => {
2019
3122
  return method;
2020
3123
  };
2021
3124
  var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
2022
- const _Query = class {
3125
+ const _Query = class _Query {
2023
3126
  constructor(repository, table, data, rawParent) {
2024
3127
  __privateAdd$5(this, _cleanFilterConstraint);
2025
3128
  __privateAdd$5(this, _table$1, void 0);
2026
3129
  __privateAdd$5(this, _repository, void 0);
2027
3130
  __privateAdd$5(this, _data, { filter: {} });
2028
- this.meta = { page: { cursor: "start", more: true } };
2029
- this.records = new RecordArray(this, []);
3131
+ // Implements pagination
3132
+ __publicField$4(this, "meta", { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } });
3133
+ __publicField$4(this, "records", new RecordArray(this, []));
2030
3134
  __privateSet$5(this, _table$1, table);
2031
3135
  if (repository) {
2032
3136
  __privateSet$5(this, _repository, repository);
@@ -2062,18 +3166,38 @@ const _Query = class {
2062
3166
  const key = JSON.stringify({ columns, filter, sort, pagination });
2063
3167
  return toBase64(key);
2064
3168
  }
3169
+ /**
3170
+ * Builds a new query object representing a logical OR between the given subqueries.
3171
+ * @param queries An array of subqueries.
3172
+ * @returns A new Query object.
3173
+ */
2065
3174
  any(...queries) {
2066
3175
  const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
2067
3176
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
2068
3177
  }
3178
+ /**
3179
+ * Builds a new query object representing a logical AND between the given subqueries.
3180
+ * @param queries An array of subqueries.
3181
+ * @returns A new Query object.
3182
+ */
2069
3183
  all(...queries) {
2070
3184
  const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
2071
3185
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
2072
3186
  }
3187
+ /**
3188
+ * Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
3189
+ * @param queries An array of subqueries.
3190
+ * @returns A new Query object.
3191
+ */
2073
3192
  not(...queries) {
2074
3193
  const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
2075
3194
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
2076
3195
  }
3196
+ /**
3197
+ * Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
3198
+ * @param queries An array of subqueries.
3199
+ * @returns A new Query object.
3200
+ */
2077
3201
  none(...queries) {
2078
3202
  const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
2079
3203
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
@@ -2096,6 +3220,11 @@ const _Query = class {
2096
3220
  const sort = [...originalSort, { column, direction }];
2097
3221
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
2098
3222
  }
3223
+ /**
3224
+ * Builds a new query specifying the set of columns to be returned in the query response.
3225
+ * @param columns Array of column names to be returned by the query.
3226
+ * @returns A new Query object.
3227
+ */
2099
3228
  select(columns) {
2100
3229
  return new _Query(
2101
3230
  __privateGet$5(this, _repository),
@@ -2108,6 +3237,12 @@ const _Query = class {
2108
3237
  const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
2109
3238
  return __privateGet$5(this, _repository).query(query);
2110
3239
  }
3240
+ /**
3241
+ * Get results in an iterator
3242
+ *
3243
+ * @async
3244
+ * @returns Async interable of results
3245
+ */
2111
3246
  async *[Symbol.asyncIterator]() {
2112
3247
  for await (const [record] of this.getIterator({ batchSize: 1 })) {
2113
3248
  yield record;
@@ -2168,26 +3303,53 @@ const _Query = class {
2168
3303
  );
2169
3304
  return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
2170
3305
  }
3306
+ /**
3307
+ * Builds a new query object adding a cache TTL in milliseconds.
3308
+ * @param ttl The cache TTL in milliseconds.
3309
+ * @returns A new Query object.
3310
+ */
2171
3311
  cache(ttl) {
2172
3312
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
2173
3313
  }
3314
+ /**
3315
+ * Retrieve next page of records
3316
+ *
3317
+ * @returns A new page object.
3318
+ */
2174
3319
  nextPage(size, offset) {
2175
3320
  return this.startPage(size, offset);
2176
3321
  }
3322
+ /**
3323
+ * Retrieve previous page of records
3324
+ *
3325
+ * @returns A new page object
3326
+ */
2177
3327
  previousPage(size, offset) {
2178
3328
  return this.startPage(size, offset);
2179
3329
  }
3330
+ /**
3331
+ * Retrieve start page of records
3332
+ *
3333
+ * @returns A new page object
3334
+ */
2180
3335
  startPage(size, offset) {
2181
3336
  return this.getPaginated({ pagination: { size, offset } });
2182
3337
  }
3338
+ /**
3339
+ * Retrieve last page of records
3340
+ *
3341
+ * @returns A new page object
3342
+ */
2183
3343
  endPage(size, offset) {
2184
3344
  return this.getPaginated({ pagination: { size, offset, before: "end" } });
2185
3345
  }
3346
+ /**
3347
+ * @returns Boolean indicating if there is a next page
3348
+ */
2186
3349
  hasNextPage() {
2187
3350
  return this.meta.page.more;
2188
3351
  }
2189
3352
  };
2190
- let Query = _Query;
2191
3353
  _table$1 = new WeakMap();
2192
3354
  _repository = new WeakMap();
2193
3355
  _data = new WeakMap();
@@ -2202,6 +3364,7 @@ cleanFilterConstraint_fn = function(column, value) {
2202
3364
  }
2203
3365
  return value;
2204
3366
  };
3367
+ let Query = _Query;
2205
3368
  function cleanParent(data, parent) {
2206
3369
  if (isCursorPaginationOptions(data.pagination)) {
2207
3370
  return { ...parent, sort: void 0, filter: void 0 };
@@ -2209,6 +3372,22 @@ function cleanParent(data, parent) {
2209
3372
  return parent;
2210
3373
  }
2211
3374
 
3375
+ const RecordColumnTypes = [
3376
+ "bool",
3377
+ "int",
3378
+ "float",
3379
+ "string",
3380
+ "text",
3381
+ "email",
3382
+ "multiple",
3383
+ "link",
3384
+ "object",
3385
+ "datetime",
3386
+ "vector",
3387
+ "file[]",
3388
+ "file",
3389
+ "json"
3390
+ ];
2212
3391
  function isIdentifiable(x) {
2213
3392
  return isObject(x) && isString(x?.id);
2214
3393
  }
@@ -2218,11 +3397,33 @@ function isXataRecord(x) {
2218
3397
  return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
2219
3398
  }
2220
3399
 
3400
+ function isValidExpandedColumn(column) {
3401
+ return isObject(column) && isString(column.name);
3402
+ }
3403
+ function isValidSelectableColumns(columns) {
3404
+ if (!Array.isArray(columns)) {
3405
+ return false;
3406
+ }
3407
+ return columns.every((column) => {
3408
+ if (typeof column === "string") {
3409
+ return true;
3410
+ }
3411
+ if (typeof column === "object") {
3412
+ return isValidExpandedColumn(column);
3413
+ }
3414
+ return false;
3415
+ });
3416
+ }
3417
+
2221
3418
  function isSortFilterString(value) {
2222
3419
  return isString(value);
2223
3420
  }
2224
3421
  function isSortFilterBase(filter) {
2225
- return isObject(filter) && Object.values(filter).every((value) => value === "asc" || value === "desc");
3422
+ return isObject(filter) && Object.entries(filter).every(([key, value]) => {
3423
+ if (key === "*")
3424
+ return value === "random";
3425
+ return value === "asc" || value === "desc";
3426
+ });
2226
3427
  }
2227
3428
  function isSortFilterObject(filter) {
2228
3429
  return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
@@ -2263,7 +3464,7 @@ var __privateMethod$2 = (obj, member, method) => {
2263
3464
  __accessCheck$4(obj, member, "access private method");
2264
3465
  return method;
2265
3466
  };
2266
- 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;
3467
+ 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;
2267
3468
  const BULK_OPERATION_MAX_SIZE = 1e3;
2268
3469
  class Repository extends Query {
2269
3470
  }
@@ -2285,6 +3486,7 @@ class RestRepository extends Query {
2285
3486
  __privateAdd$4(this, _setCacheQuery);
2286
3487
  __privateAdd$4(this, _getCacheQuery);
2287
3488
  __privateAdd$4(this, _getSchemaTables$1);
3489
+ __privateAdd$4(this, _transformObjectToApi);
2288
3490
  __privateAdd$4(this, _table, void 0);
2289
3491
  __privateAdd$4(this, _getFetchProps, void 0);
2290
3492
  __privateAdd$4(this, _db, void 0);
@@ -2295,10 +3497,7 @@ class RestRepository extends Query {
2295
3497
  __privateSet$4(this, _db, options.db);
2296
3498
  __privateSet$4(this, _cache, options.pluginOptions.cache);
2297
3499
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
2298
- __privateSet$4(this, _getFetchProps, async () => {
2299
- const props = await options.pluginOptions.getFetchProps();
2300
- return { ...props, sessionID: generateUUID() };
2301
- });
3500
+ __privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
2302
3501
  const trace = options.pluginOptions.trace ?? defaultTrace;
2303
3502
  __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
2304
3503
  return trace(name, fn, {
@@ -2316,24 +3515,24 @@ class RestRepository extends Query {
2316
3515
  if (a.length === 0)
2317
3516
  return [];
2318
3517
  const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
2319
- const columns = isStringArray(b) ? b : ["*"];
3518
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2320
3519
  const result = await this.read(ids, columns);
2321
3520
  return result;
2322
3521
  }
2323
3522
  if (isString(a) && isObject(b)) {
2324
3523
  if (a === "")
2325
3524
  throw new Error("The id can't be empty");
2326
- const columns = isStringArray(c) ? c : void 0;
3525
+ const columns = isValidSelectableColumns(c) ? c : void 0;
2327
3526
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
2328
3527
  }
2329
3528
  if (isObject(a) && isString(a.id)) {
2330
3529
  if (a.id === "")
2331
3530
  throw new Error("The id can't be empty");
2332
- const columns = isStringArray(b) ? b : void 0;
3531
+ const columns = isValidSelectableColumns(b) ? b : void 0;
2333
3532
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
2334
3533
  }
2335
3534
  if (isObject(a)) {
2336
- const columns = isStringArray(b) ? b : void 0;
3535
+ const columns = isValidSelectableColumns(b) ? b : void 0;
2337
3536
  return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
2338
3537
  }
2339
3538
  throw new Error("Invalid arguments for create method");
@@ -2341,7 +3540,7 @@ class RestRepository extends Query {
2341
3540
  }
2342
3541
  async read(a, b) {
2343
3542
  return __privateGet$4(this, _trace).call(this, "read", async () => {
2344
- const columns = isStringArray(b) ? b : ["*"];
3543
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2345
3544
  if (Array.isArray(a)) {
2346
3545
  if (a.length === 0)
2347
3546
  return [];
@@ -2355,7 +3554,6 @@ class RestRepository extends Query {
2355
3554
  }
2356
3555
  const id = extractId(a);
2357
3556
  if (id) {
2358
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2359
3557
  try {
2360
3558
  const response = await getRecord({
2361
3559
  pathParams: {
@@ -2366,10 +3564,16 @@ class RestRepository extends Query {
2366
3564
  recordId: id
2367
3565
  },
2368
3566
  queryParams: { columns },
2369
- ...fetchProps
3567
+ ...__privateGet$4(this, _getFetchProps).call(this)
2370
3568
  });
2371
3569
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2372
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
3570
+ return initObject(
3571
+ __privateGet$4(this, _db),
3572
+ schemaTables,
3573
+ __privateGet$4(this, _table),
3574
+ response,
3575
+ columns
3576
+ );
2373
3577
  } catch (e) {
2374
3578
  if (isObject(e) && e.status === 404) {
2375
3579
  return null;
@@ -2411,17 +3615,17 @@ class RestRepository extends Query {
2411
3615
  ifVersion,
2412
3616
  upsert: false
2413
3617
  });
2414
- const columns = isStringArray(b) ? b : ["*"];
3618
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2415
3619
  const result = await this.read(a, columns);
2416
3620
  return result;
2417
3621
  }
2418
3622
  try {
2419
3623
  if (isString(a) && isObject(b)) {
2420
- const columns = isStringArray(c) ? c : void 0;
3624
+ const columns = isValidSelectableColumns(c) ? c : void 0;
2421
3625
  return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2422
3626
  }
2423
3627
  if (isObject(a) && isString(a.id)) {
2424
- const columns = isStringArray(b) ? b : void 0;
3628
+ const columns = isValidSelectableColumns(b) ? b : void 0;
2425
3629
  return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2426
3630
  }
2427
3631
  } catch (error) {
@@ -2461,17 +3665,27 @@ class RestRepository extends Query {
2461
3665
  ifVersion,
2462
3666
  upsert: true
2463
3667
  });
2464
- const columns = isStringArray(b) ? b : ["*"];
3668
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2465
3669
  const result = await this.read(a, columns);
2466
3670
  return result;
2467
3671
  }
2468
3672
  if (isString(a) && isObject(b)) {
2469
- const columns = isStringArray(c) ? c : void 0;
2470
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
3673
+ if (a === "")
3674
+ throw new Error("The id can't be empty");
3675
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3676
+ return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2471
3677
  }
2472
3678
  if (isObject(a) && isString(a.id)) {
2473
- const columns = isStringArray(c) ? c : void 0;
2474
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3679
+ if (a.id === "")
3680
+ throw new Error("The id can't be empty");
3681
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3682
+ return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3683
+ }
3684
+ if (!isDefined(a) && isObject(b)) {
3685
+ return await this.create(b, c);
3686
+ }
3687
+ if (isObject(a) && !isDefined(a.id)) {
3688
+ return await this.create(a, b);
2475
3689
  }
2476
3690
  throw new Error("Invalid arguments for createOrUpdate method");
2477
3691
  });
@@ -2483,17 +3697,27 @@ class RestRepository extends Query {
2483
3697
  if (a.length === 0)
2484
3698
  return [];
2485
3699
  const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
2486
- const columns = isStringArray(b) ? b : ["*"];
3700
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2487
3701
  const result = await this.read(ids, columns);
2488
3702
  return result;
2489
3703
  }
2490
3704
  if (isString(a) && isObject(b)) {
2491
- const columns = isStringArray(c) ? c : void 0;
2492
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
3705
+ if (a === "")
3706
+ throw new Error("The id can't be empty");
3707
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3708
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
2493
3709
  }
2494
3710
  if (isObject(a) && isString(a.id)) {
2495
- const columns = isStringArray(c) ? c : void 0;
2496
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
3711
+ if (a.id === "")
3712
+ throw new Error("The id can't be empty");
3713
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3714
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
3715
+ }
3716
+ if (!isDefined(a) && isObject(b)) {
3717
+ return await this.create(b, c);
3718
+ }
3719
+ if (isObject(a) && !isDefined(a.id)) {
3720
+ return await this.create(a, b);
2497
3721
  }
2498
3722
  throw new Error("Invalid arguments for createOrReplace method");
2499
3723
  });
@@ -2510,7 +3734,7 @@ class RestRepository extends Query {
2510
3734
  return o.id;
2511
3735
  throw new Error("Invalid arguments for delete method");
2512
3736
  });
2513
- const columns = isStringArray(b) ? b : ["*"];
3737
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2514
3738
  const result = await this.read(a, columns);
2515
3739
  await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
2516
3740
  return result;
@@ -2544,7 +3768,6 @@ class RestRepository extends Query {
2544
3768
  }
2545
3769
  async search(query, options = {}) {
2546
3770
  return __privateGet$4(this, _trace).call(this, "search", async () => {
2547
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2548
3771
  const { records } = await searchTable({
2549
3772
  pathParams: {
2550
3773
  workspace: "{workspaceId}",
@@ -2562,7 +3785,29 @@ class RestRepository extends Query {
2562
3785
  page: options.page,
2563
3786
  target: options.target
2564
3787
  },
2565
- ...fetchProps
3788
+ ...__privateGet$4(this, _getFetchProps).call(this)
3789
+ });
3790
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3791
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3792
+ });
3793
+ }
3794
+ async vectorSearch(column, query, options) {
3795
+ return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
3796
+ const { records } = await vectorSearchTable({
3797
+ pathParams: {
3798
+ workspace: "{workspaceId}",
3799
+ dbBranchName: "{dbBranch}",
3800
+ region: "{region}",
3801
+ tableName: __privateGet$4(this, _table)
3802
+ },
3803
+ body: {
3804
+ column,
3805
+ queryVector: query,
3806
+ similarityFunction: options?.similarityFunction,
3807
+ size: options?.size,
3808
+ filter: options?.filter
3809
+ },
3810
+ ...__privateGet$4(this, _getFetchProps).call(this)
2566
3811
  });
2567
3812
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2568
3813
  return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
@@ -2570,7 +3815,6 @@ class RestRepository extends Query {
2570
3815
  }
2571
3816
  async aggregate(aggs, filter) {
2572
3817
  return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
2573
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2574
3818
  const result = await aggregateTable({
2575
3819
  pathParams: {
2576
3820
  workspace: "{workspaceId}",
@@ -2579,7 +3823,7 @@ class RestRepository extends Query {
2579
3823
  tableName: __privateGet$4(this, _table)
2580
3824
  },
2581
3825
  body: { aggs, filter },
2582
- ...fetchProps
3826
+ ...__privateGet$4(this, _getFetchProps).call(this)
2583
3827
  });
2584
3828
  return result;
2585
3829
  });
@@ -2590,7 +3834,6 @@ class RestRepository extends Query {
2590
3834
  if (cacheQuery)
2591
3835
  return new Page(query, cacheQuery.meta, cacheQuery.records);
2592
3836
  const data = query.getQueryOptions();
2593
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2594
3837
  const { meta, records: objects } = await queryTable({
2595
3838
  pathParams: {
2596
3839
  workspace: "{workspaceId}",
@@ -2606,11 +3849,17 @@ class RestRepository extends Query {
2606
3849
  consistency: data.consistency
2607
3850
  },
2608
3851
  fetchOptions: data.fetchOptions,
2609
- ...fetchProps
3852
+ ...__privateGet$4(this, _getFetchProps).call(this)
2610
3853
  });
2611
3854
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2612
3855
  const records = objects.map(
2613
- (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
3856
+ (record) => initObject(
3857
+ __privateGet$4(this, _db),
3858
+ schemaTables,
3859
+ __privateGet$4(this, _table),
3860
+ record,
3861
+ data.columns ?? ["*"]
3862
+ )
2614
3863
  );
2615
3864
  await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
2616
3865
  return new Page(query, meta, records);
@@ -2619,7 +3868,6 @@ class RestRepository extends Query {
2619
3868
  async summarizeTable(query, summaries, summariesFilter) {
2620
3869
  return __privateGet$4(this, _trace).call(this, "summarize", async () => {
2621
3870
  const data = query.getQueryOptions();
2622
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2623
3871
  const result = await summarizeTable({
2624
3872
  pathParams: {
2625
3873
  workspace: "{workspaceId}",
@@ -2636,11 +3884,44 @@ class RestRepository extends Query {
2636
3884
  summaries,
2637
3885
  summariesFilter
2638
3886
  },
2639
- ...fetchProps
3887
+ ...__privateGet$4(this, _getFetchProps).call(this)
2640
3888
  });
2641
3889
  return result;
2642
3890
  });
2643
3891
  }
3892
+ ask(question, options) {
3893
+ const questionParam = options?.sessionId ? { message: question } : { question };
3894
+ const params = {
3895
+ pathParams: {
3896
+ workspace: "{workspaceId}",
3897
+ dbBranchName: "{dbBranch}",
3898
+ region: "{region}",
3899
+ tableName: __privateGet$4(this, _table),
3900
+ sessionId: options?.sessionId
3901
+ },
3902
+ body: {
3903
+ ...questionParam,
3904
+ rules: options?.rules,
3905
+ searchType: options?.searchType,
3906
+ search: options?.searchType === "keyword" ? options?.search : void 0,
3907
+ vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
3908
+ },
3909
+ ...__privateGet$4(this, _getFetchProps).call(this)
3910
+ };
3911
+ if (options?.onMessage) {
3912
+ fetchSSERequest({
3913
+ endpoint: "dataPlane",
3914
+ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
3915
+ method: "POST",
3916
+ onMessage: (message) => {
3917
+ options.onMessage?.({ answer: message.text, records: message.records });
3918
+ },
3919
+ ...params
3920
+ });
3921
+ } else {
3922
+ return askTableSession(params);
3923
+ }
3924
+ }
2644
3925
  }
2645
3926
  _table = new WeakMap();
2646
3927
  _getFetchProps = new WeakMap();
@@ -2650,8 +3931,7 @@ _schemaTables$2 = new WeakMap();
2650
3931
  _trace = new WeakMap();
2651
3932
  _insertRecordWithoutId = new WeakSet();
2652
3933
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
2653
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2654
- const record = transformObjectLinks(object);
3934
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
2655
3935
  const response = await insertRecord({
2656
3936
  pathParams: {
2657
3937
  workspace: "{workspaceId}",
@@ -2661,15 +3941,16 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
2661
3941
  },
2662
3942
  queryParams: { columns },
2663
3943
  body: record,
2664
- ...fetchProps
3944
+ ...__privateGet$4(this, _getFetchProps).call(this)
2665
3945
  });
2666
3946
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2667
3947
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2668
3948
  };
2669
3949
  _insertRecordWithId = new WeakSet();
2670
3950
  insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
2671
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2672
- const record = transformObjectLinks(object);
3951
+ if (!recordId)
3952
+ return null;
3953
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
2673
3954
  const response = await insertRecordWithID({
2674
3955
  pathParams: {
2675
3956
  workspace: "{workspaceId}",
@@ -2680,30 +3961,28 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
2680
3961
  },
2681
3962
  body: record,
2682
3963
  queryParams: { createOnly, columns, ifVersion },
2683
- ...fetchProps
3964
+ ...__privateGet$4(this, _getFetchProps).call(this)
2684
3965
  });
2685
3966
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2686
3967
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2687
3968
  };
2688
3969
  _insertRecords = new WeakSet();
2689
3970
  insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
2690
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2691
- const chunkedOperations = chunk(
2692
- objects.map((object) => ({
2693
- insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
2694
- })),
2695
- BULK_OPERATION_MAX_SIZE
2696
- );
3971
+ const operations = await promiseMap(objects, async (object) => {
3972
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3973
+ return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
3974
+ });
3975
+ const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
2697
3976
  const ids = [];
2698
- for (const operations of chunkedOperations) {
3977
+ for (const operations2 of chunkedOperations) {
2699
3978
  const { results } = await branchTransaction({
2700
3979
  pathParams: {
2701
3980
  workspace: "{workspaceId}",
2702
3981
  dbBranchName: "{dbBranch}",
2703
3982
  region: "{region}"
2704
3983
  },
2705
- body: { operations },
2706
- ...fetchProps
3984
+ body: { operations: operations2 },
3985
+ ...__privateGet$4(this, _getFetchProps).call(this)
2707
3986
  });
2708
3987
  for (const result of results) {
2709
3988
  if (result.operation === "insert") {
@@ -2717,8 +3996,9 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
2717
3996
  };
2718
3997
  _updateRecordWithID = new WeakSet();
2719
3998
  updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
2720
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2721
- const { id: _id, ...record } = transformObjectLinks(object);
3999
+ if (!recordId)
4000
+ return null;
4001
+ const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
2722
4002
  try {
2723
4003
  const response = await updateRecordWithID({
2724
4004
  pathParams: {
@@ -2730,7 +4010,7 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
2730
4010
  },
2731
4011
  queryParams: { columns, ifVersion },
2732
4012
  body: record,
2733
- ...fetchProps
4013
+ ...__privateGet$4(this, _getFetchProps).call(this)
2734
4014
  });
2735
4015
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2736
4016
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
@@ -2743,23 +4023,21 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
2743
4023
  };
2744
4024
  _updateRecords = new WeakSet();
2745
4025
  updateRecords_fn = async function(objects, { ifVersion, upsert }) {
2746
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2747
- const chunkedOperations = chunk(
2748
- objects.map(({ id, ...object }) => ({
2749
- update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
2750
- })),
2751
- BULK_OPERATION_MAX_SIZE
2752
- );
4026
+ const operations = await promiseMap(objects, async ({ id, ...object }) => {
4027
+ const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
4028
+ return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
4029
+ });
4030
+ const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
2753
4031
  const ids = [];
2754
- for (const operations of chunkedOperations) {
4032
+ for (const operations2 of chunkedOperations) {
2755
4033
  const { results } = await branchTransaction({
2756
4034
  pathParams: {
2757
4035
  workspace: "{workspaceId}",
2758
4036
  dbBranchName: "{dbBranch}",
2759
4037
  region: "{region}"
2760
4038
  },
2761
- body: { operations },
2762
- ...fetchProps
4039
+ body: { operations: operations2 },
4040
+ ...__privateGet$4(this, _getFetchProps).call(this)
2763
4041
  });
2764
4042
  for (const result of results) {
2765
4043
  if (result.operation === "update") {
@@ -2773,7 +4051,8 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
2773
4051
  };
2774
4052
  _upsertRecordWithID = new WeakSet();
2775
4053
  upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
2776
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
4054
+ if (!recordId)
4055
+ return null;
2777
4056
  const response = await upsertRecordWithID({
2778
4057
  pathParams: {
2779
4058
  workspace: "{workspaceId}",
@@ -2784,14 +4063,15 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
2784
4063
  },
2785
4064
  queryParams: { columns, ifVersion },
2786
4065
  body: object,
2787
- ...fetchProps
4066
+ ...__privateGet$4(this, _getFetchProps).call(this)
2788
4067
  });
2789
4068
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2790
4069
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2791
4070
  };
2792
4071
  _deleteRecord = new WeakSet();
2793
4072
  deleteRecord_fn = async function(recordId, columns = ["*"]) {
2794
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
4073
+ if (!recordId)
4074
+ return null;
2795
4075
  try {
2796
4076
  const response = await deleteRecord({
2797
4077
  pathParams: {
@@ -2802,7 +4082,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
2802
4082
  recordId
2803
4083
  },
2804
4084
  queryParams: { columns },
2805
- ...fetchProps
4085
+ ...__privateGet$4(this, _getFetchProps).call(this)
2806
4086
  });
2807
4087
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2808
4088
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
@@ -2815,9 +4095,8 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
2815
4095
  };
2816
4096
  _deleteRecords = new WeakSet();
2817
4097
  deleteRecords_fn = async function(recordIds) {
2818
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2819
4098
  const chunkedOperations = chunk(
2820
- recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
4099
+ compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
2821
4100
  BULK_OPERATION_MAX_SIZE
2822
4101
  );
2823
4102
  for (const operations of chunkedOperations) {
@@ -2828,21 +4107,22 @@ deleteRecords_fn = async function(recordIds) {
2828
4107
  region: "{region}"
2829
4108
  },
2830
4109
  body: { operations },
2831
- ...fetchProps
4110
+ ...__privateGet$4(this, _getFetchProps).call(this)
2832
4111
  });
2833
4112
  }
2834
4113
  };
2835
4114
  _setCacheQuery = new WeakSet();
2836
4115
  setCacheQuery_fn = async function(query, meta, records) {
2837
- await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
4116
+ await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
2838
4117
  };
2839
4118
  _getCacheQuery = new WeakSet();
2840
4119
  getCacheQuery_fn = async function(query) {
2841
4120
  const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
2842
- const result = await __privateGet$4(this, _cache).get(key);
4121
+ const result = await __privateGet$4(this, _cache)?.get(key);
2843
4122
  if (!result)
2844
4123
  return null;
2845
- const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
4124
+ const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
4125
+ const { cache: ttl = defaultTTL } = query.getQueryOptions();
2846
4126
  if (ttl < 0)
2847
4127
  return null;
2848
4128
  const hasExpired = result.date.getTime() + ttl < Date.now();
@@ -2852,15 +4132,49 @@ _getSchemaTables$1 = new WeakSet();
2852
4132
  getSchemaTables_fn$1 = async function() {
2853
4133
  if (__privateGet$4(this, _schemaTables$2))
2854
4134
  return __privateGet$4(this, _schemaTables$2);
2855
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2856
4135
  const { schema } = await getBranchDetails({
2857
4136
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2858
- ...fetchProps
4137
+ ...__privateGet$4(this, _getFetchProps).call(this)
2859
4138
  });
2860
4139
  __privateSet$4(this, _schemaTables$2, schema.tables);
2861
4140
  return schema.tables;
2862
4141
  };
2863
- const transformObjectLinks = (object) => {
4142
+ _transformObjectToApi = new WeakSet();
4143
+ transformObjectToApi_fn = async function(object) {
4144
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
4145
+ const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
4146
+ if (!schema)
4147
+ throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
4148
+ const result = {};
4149
+ for (const [key, value] of Object.entries(object)) {
4150
+ if (key === "xata")
4151
+ continue;
4152
+ const type = schema.columns.find((column) => column.name === key)?.type;
4153
+ switch (type) {
4154
+ case "link": {
4155
+ result[key] = isIdentifiable(value) ? value.id : value;
4156
+ break;
4157
+ }
4158
+ case "datetime": {
4159
+ result[key] = value instanceof Date ? value.toISOString() : value;
4160
+ break;
4161
+ }
4162
+ case `file`:
4163
+ result[key] = await parseInputFileEntry(value);
4164
+ break;
4165
+ case "file[]":
4166
+ result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
4167
+ break;
4168
+ case "json":
4169
+ result[key] = stringifyJson(value);
4170
+ break;
4171
+ default:
4172
+ result[key] = value;
4173
+ }
4174
+ }
4175
+ return result;
4176
+ };
4177
+ const removeLinksFromObject = (object) => {
2864
4178
  return Object.entries(object).reduce((acc, [key, value]) => {
2865
4179
  if (key === "xata")
2866
4180
  return acc;
@@ -2897,18 +4211,33 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2897
4211
  if (item === column.name) {
2898
4212
  return [...acc, "*"];
2899
4213
  }
2900
- if (item.startsWith(`${column.name}.`)) {
4214
+ if (isString(item) && item.startsWith(`${column.name}.`)) {
2901
4215
  const [, ...path] = item.split(".");
2902
4216
  return [...acc, path.join(".")];
2903
4217
  }
2904
4218
  return acc;
2905
4219
  }, []);
2906
- data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
4220
+ data[column.name] = initObject(
4221
+ db,
4222
+ schemaTables,
4223
+ linkTable,
4224
+ value,
4225
+ selectedLinkColumns
4226
+ );
2907
4227
  } else {
2908
4228
  data[column.name] = null;
2909
4229
  }
2910
4230
  break;
2911
4231
  }
4232
+ case "file":
4233
+ data[column.name] = isDefined(value) ? new XataFile(value) : null;
4234
+ break;
4235
+ case "file[]":
4236
+ data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
4237
+ break;
4238
+ case "json":
4239
+ data[column.name] = parseJson(value);
4240
+ break;
2912
4241
  default:
2913
4242
  data[column.name] = value ?? null;
2914
4243
  if (column.notNull === true && value === null) {
@@ -2918,29 +4247,35 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2918
4247
  }
2919
4248
  }
2920
4249
  const record = { ...data };
4250
+ const serializable = { xata, ...removeLinksFromObject(data) };
4251
+ const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
2921
4252
  record.read = function(columns2) {
2922
4253
  return db[table].read(record["id"], columns2);
2923
4254
  };
2924
4255
  record.update = function(data2, b, c) {
2925
- const columns2 = isStringArray(b) ? b : ["*"];
4256
+ const columns2 = isValidSelectableColumns(b) ? b : ["*"];
2926
4257
  const ifVersion = parseIfVersion(b, c);
2927
4258
  return db[table].update(record["id"], data2, columns2, { ifVersion });
2928
4259
  };
2929
4260
  record.replace = function(data2, b, c) {
2930
- const columns2 = isStringArray(b) ? b : ["*"];
4261
+ const columns2 = isValidSelectableColumns(b) ? b : ["*"];
2931
4262
  const ifVersion = parseIfVersion(b, c);
2932
4263
  return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
2933
4264
  };
2934
4265
  record.delete = function() {
2935
4266
  return db[table].delete(record["id"]);
2936
4267
  };
4268
+ record.xata = Object.freeze(metadata);
2937
4269
  record.getMetadata = function() {
2938
- return xata;
4270
+ return record.xata;
2939
4271
  };
2940
- record.toJSON = function() {
2941
- return JSON.parse(JSON.stringify(transformObjectLinks(data)));
4272
+ record.toSerializable = function() {
4273
+ return JSON.parse(JSON.stringify(serializable));
2942
4274
  };
2943
- for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
4275
+ record.toString = function() {
4276
+ return JSON.stringify(serializable);
4277
+ };
4278
+ for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
2944
4279
  Object.defineProperty(record, prop, { enumerable: false });
2945
4280
  }
2946
4281
  Object.freeze(record);
@@ -2956,11 +4291,7 @@ function extractId(value) {
2956
4291
  function isValidColumn(columns, column) {
2957
4292
  if (columns.includes("*"))
2958
4293
  return true;
2959
- if (column.type === "link") {
2960
- const linkColumns = columns.filter((item) => item.startsWith(column.name));
2961
- return linkColumns.length > 0;
2962
- }
2963
- return columns.includes(column.name);
4294
+ return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
2964
4295
  }
2965
4296
  function parseIfVersion(...args) {
2966
4297
  for (const arg of args) {
@@ -2971,6 +4302,12 @@ function parseIfVersion(...args) {
2971
4302
  return void 0;
2972
4303
  }
2973
4304
 
4305
+ var __defProp$3 = Object.defineProperty;
4306
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4307
+ var __publicField$3 = (obj, key, value) => {
4308
+ __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
4309
+ return value;
4310
+ };
2974
4311
  var __accessCheck$3 = (obj, member, msg) => {
2975
4312
  if (!member.has(obj))
2976
4313
  throw TypeError("Cannot " + msg);
@@ -2993,6 +4330,8 @@ var _map;
2993
4330
  class SimpleCache {
2994
4331
  constructor(options = {}) {
2995
4332
  __privateAdd$3(this, _map, void 0);
4333
+ __publicField$3(this, "capacity");
4334
+ __publicField$3(this, "defaultQueryTTL");
2996
4335
  __privateSet$3(this, _map, /* @__PURE__ */ new Map());
2997
4336
  this.capacity = options.max ?? 500;
2998
4337
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
@@ -3128,19 +4467,19 @@ class SearchPlugin extends XataPlugin {
3128
4467
  __privateAdd$1(this, _schemaTables, void 0);
3129
4468
  __privateSet$1(this, _schemaTables, schemaTables);
3130
4469
  }
3131
- build({ getFetchProps }) {
4470
+ build(pluginOptions) {
3132
4471
  return {
3133
4472
  all: async (query, options = {}) => {
3134
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
3135
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
4473
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4474
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
3136
4475
  return records.map((record) => {
3137
4476
  const { table = "orphan" } = record.xata;
3138
4477
  return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
3139
4478
  });
3140
4479
  },
3141
4480
  byTable: async (query, options = {}) => {
3142
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
3143
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
4481
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4482
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
3144
4483
  return records.reduce((acc, record) => {
3145
4484
  const { table = "orphan" } = record.xata;
3146
4485
  const items = acc[table] ?? [];
@@ -3153,38 +4492,108 @@ class SearchPlugin extends XataPlugin {
3153
4492
  }
3154
4493
  _schemaTables = new WeakMap();
3155
4494
  _search = new WeakSet();
3156
- search_fn = async function(query, options, getFetchProps) {
3157
- const fetchProps = await getFetchProps();
4495
+ search_fn = async function(query, options, pluginOptions) {
3158
4496
  const { tables, fuzziness, highlight, prefix, page } = options ?? {};
3159
4497
  const { records } = await searchBranch({
3160
4498
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4499
+ // @ts-ignore https://github.com/xataio/client-ts/issues/313
3161
4500
  body: { tables, query, fuzziness, prefix, highlight, page },
3162
- ...fetchProps
4501
+ ...pluginOptions
3163
4502
  });
3164
4503
  return records;
3165
4504
  };
3166
4505
  _getSchemaTables = new WeakSet();
3167
- getSchemaTables_fn = async function(getFetchProps) {
4506
+ getSchemaTables_fn = async function(pluginOptions) {
3168
4507
  if (__privateGet$1(this, _schemaTables))
3169
4508
  return __privateGet$1(this, _schemaTables);
3170
- const fetchProps = await getFetchProps();
3171
4509
  const { schema } = await getBranchDetails({
3172
4510
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3173
- ...fetchProps
4511
+ ...pluginOptions
3174
4512
  });
3175
4513
  __privateSet$1(this, _schemaTables, schema.tables);
3176
4514
  return schema.tables;
3177
4515
  };
3178
4516
 
4517
+ function escapeElement(elementRepresentation) {
4518
+ const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
4519
+ return '"' + escaped + '"';
4520
+ }
4521
+ function arrayString(val) {
4522
+ let result = "{";
4523
+ for (let i = 0; i < val.length; i++) {
4524
+ if (i > 0) {
4525
+ result = result + ",";
4526
+ }
4527
+ if (val[i] === null || typeof val[i] === "undefined") {
4528
+ result = result + "NULL";
4529
+ } else if (Array.isArray(val[i])) {
4530
+ result = result + arrayString(val[i]);
4531
+ } else if (val[i] instanceof Buffer) {
4532
+ result += "\\\\x" + val[i].toString("hex");
4533
+ } else {
4534
+ result += escapeElement(prepareValue(val[i]));
4535
+ }
4536
+ }
4537
+ result = result + "}";
4538
+ return result;
4539
+ }
4540
+ function prepareValue(value) {
4541
+ if (!isDefined(value))
4542
+ return null;
4543
+ if (value instanceof Date) {
4544
+ return value.toISOString();
4545
+ }
4546
+ if (Array.isArray(value)) {
4547
+ return arrayString(value);
4548
+ }
4549
+ if (isObject(value)) {
4550
+ return JSON.stringify(value);
4551
+ }
4552
+ try {
4553
+ return value.toString();
4554
+ } catch (e) {
4555
+ return value;
4556
+ }
4557
+ }
4558
+ function prepareParams(param1, param2) {
4559
+ if (isString(param1)) {
4560
+ return { statement: param1, params: param2?.map((value) => prepareValue(value)) };
4561
+ }
4562
+ if (isStringArray(param1)) {
4563
+ const statement = param1.reduce((acc, curr, index) => {
4564
+ return acc + curr + (index < (param2?.length ?? 0) ? "$" + (index + 1) : "");
4565
+ }, "");
4566
+ return { statement, params: param2?.map((value) => prepareValue(value)) };
4567
+ }
4568
+ if (isObject(param1)) {
4569
+ const { statement, params, consistency } = param1;
4570
+ return { statement, params: params?.map((value) => prepareValue(value)), consistency };
4571
+ }
4572
+ throw new Error("Invalid query");
4573
+ }
4574
+
4575
+ class SQLPlugin extends XataPlugin {
4576
+ build(pluginOptions) {
4577
+ return async (param1, ...param2) => {
4578
+ const { statement, params, consistency } = prepareParams(param1, param2);
4579
+ const { records, warning } = await sqlQuery({
4580
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4581
+ body: { statement, params, consistency },
4582
+ ...pluginOptions
4583
+ });
4584
+ return { records, warning };
4585
+ };
4586
+ }
4587
+ }
4588
+
3179
4589
  class TransactionPlugin extends XataPlugin {
3180
- build({ getFetchProps }) {
4590
+ build(pluginOptions) {
3181
4591
  return {
3182
4592
  run: async (operations) => {
3183
- const fetchProps = await getFetchProps();
3184
4593
  const response = await branchTransaction({
3185
4594
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3186
4595
  body: { operations },
3187
- ...fetchProps
4596
+ ...pluginOptions
3188
4597
  });
3189
4598
  return response;
3190
4599
  }
@@ -3192,90 +4601,12 @@ class TransactionPlugin extends XataPlugin {
3192
4601
  }
3193
4602
  }
3194
4603
 
3195
- const isBranchStrategyBuilder = (strategy) => {
3196
- return typeof strategy === "function";
4604
+ var __defProp$2 = Object.defineProperty;
4605
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4606
+ var __publicField$2 = (obj, key, value) => {
4607
+ __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
4608
+ return value;
3197
4609
  };
3198
-
3199
- async function getCurrentBranchName(options) {
3200
- const { branch, envBranch } = getEnvironment();
3201
- if (branch)
3202
- return branch;
3203
- const gitBranch = envBranch || await getGitBranch();
3204
- return resolveXataBranch(gitBranch, options);
3205
- }
3206
- async function getCurrentBranchDetails(options) {
3207
- const branch = await getCurrentBranchName(options);
3208
- return getDatabaseBranch(branch, options);
3209
- }
3210
- async function resolveXataBranch(gitBranch, options) {
3211
- const databaseURL = options?.databaseURL || getDatabaseURL();
3212
- const apiKey = options?.apiKey || getAPIKey();
3213
- if (!databaseURL)
3214
- throw new Error(
3215
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
3216
- );
3217
- if (!apiKey)
3218
- throw new Error(
3219
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
3220
- );
3221
- const [protocol, , host, , dbName] = databaseURL.split("/");
3222
- const urlParts = parseWorkspacesUrlParts(host);
3223
- if (!urlParts)
3224
- throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3225
- const { workspace, region } = urlParts;
3226
- const { fallbackBranch } = getEnvironment();
3227
- const { branch } = await resolveBranch({
3228
- apiKey,
3229
- apiUrl: databaseURL,
3230
- fetchImpl: getFetchImplementation(options?.fetchImpl),
3231
- workspacesApiUrl: `${protocol}//${host}`,
3232
- pathParams: { dbName, workspace, region },
3233
- queryParams: { gitBranch, fallbackBranch },
3234
- trace: defaultTrace,
3235
- clientName: options?.clientName
3236
- });
3237
- return branch;
3238
- }
3239
- async function getDatabaseBranch(branch, options) {
3240
- const databaseURL = options?.databaseURL || getDatabaseURL();
3241
- const apiKey = options?.apiKey || getAPIKey();
3242
- if (!databaseURL)
3243
- throw new Error(
3244
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
3245
- );
3246
- if (!apiKey)
3247
- throw new Error(
3248
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
3249
- );
3250
- const [protocol, , host, , database] = databaseURL.split("/");
3251
- const urlParts = parseWorkspacesUrlParts(host);
3252
- if (!urlParts)
3253
- throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3254
- const { workspace, region } = urlParts;
3255
- try {
3256
- return await getBranchDetails({
3257
- apiKey,
3258
- apiUrl: databaseURL,
3259
- fetchImpl: getFetchImplementation(options?.fetchImpl),
3260
- workspacesApiUrl: `${protocol}//${host}`,
3261
- pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
3262
- trace: defaultTrace
3263
- });
3264
- } catch (err) {
3265
- if (isObject(err) && err.status === 404)
3266
- return null;
3267
- throw err;
3268
- }
3269
- }
3270
- function getDatabaseURL() {
3271
- try {
3272
- const { databaseURL } = getEnvironment();
3273
- return databaseURL;
3274
- } catch (err) {
3275
- return void 0;
3276
- }
3277
- }
3278
-
3279
4610
  var __accessCheck = (obj, member, msg) => {
3280
4611
  if (!member.has(obj))
3281
4612
  throw TypeError("Cannot " + msg);
@@ -3299,48 +4630,48 @@ var __privateMethod = (obj, member, method) => {
3299
4630
  return method;
3300
4631
  };
3301
4632
  const buildClient = (plugins) => {
3302
- var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
4633
+ var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
3303
4634
  return _a = class {
3304
4635
  constructor(options = {}, schemaTables) {
3305
4636
  __privateAdd(this, _parseOptions);
3306
4637
  __privateAdd(this, _getFetchProps);
3307
- __privateAdd(this, _evaluateBranch);
3308
- __privateAdd(this, _branch, void 0);
3309
4638
  __privateAdd(this, _options, void 0);
4639
+ __publicField$2(this, "db");
4640
+ __publicField$2(this, "search");
4641
+ __publicField$2(this, "transactions");
4642
+ __publicField$2(this, "sql");
4643
+ __publicField$2(this, "files");
3310
4644
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
3311
4645
  __privateSet(this, _options, safeOptions);
3312
4646
  const pluginOptions = {
3313
- getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
4647
+ ...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
3314
4648
  cache: safeOptions.cache,
3315
- trace: safeOptions.trace
4649
+ host: safeOptions.host
3316
4650
  };
3317
4651
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
3318
4652
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
3319
4653
  const transactions = new TransactionPlugin().build(pluginOptions);
4654
+ const sql = new SQLPlugin().build(pluginOptions);
4655
+ const files = new FilesPlugin().build(pluginOptions);
3320
4656
  this.db = db;
3321
4657
  this.search = search;
3322
4658
  this.transactions = transactions;
4659
+ this.sql = sql;
4660
+ this.files = files;
3323
4661
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
3324
4662
  if (namespace === void 0)
3325
4663
  continue;
3326
- const result = namespace.build(pluginOptions);
3327
- if (result instanceof Promise) {
3328
- void result.then((namespace2) => {
3329
- this[key] = namespace2;
3330
- });
3331
- } else {
3332
- this[key] = result;
3333
- }
4664
+ this[key] = namespace.build(pluginOptions);
3334
4665
  }
3335
4666
  }
3336
4667
  async getConfig() {
3337
4668
  const databaseURL = __privateGet(this, _options).databaseURL;
3338
- const branch = await __privateGet(this, _options).branch();
4669
+ const branch = __privateGet(this, _options).branch;
3339
4670
  return { databaseURL, branch };
3340
4671
  }
3341
- }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
4672
+ }, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
3342
4673
  const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
3343
- const isBrowser = typeof window !== "undefined";
4674
+ const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
3344
4675
  if (isBrowser && !enableBrowser) {
3345
4676
  throw new Error(
3346
4677
  "You are trying to use Xata from the browser, which is potentially a non-secure environment. If you understand the security concerns, such as leaking your credentials, pass `enableBrowser: true` to the client options to remove this error."
@@ -3352,70 +4683,88 @@ const buildClient = (plugins) => {
3352
4683
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
3353
4684
  const trace = options?.trace ?? defaultTrace;
3354
4685
  const clientName = options?.clientName;
3355
- const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({
3356
- apiKey,
3357
- databaseURL,
3358
- fetchImpl: options?.fetch,
3359
- clientName: options?.clientName
3360
- });
4686
+ const host = options?.host ?? "production";
4687
+ const xataAgentExtra = options?.xataAgentExtra;
3361
4688
  if (!apiKey) {
3362
4689
  throw new Error("Option apiKey is required");
3363
4690
  }
3364
4691
  if (!databaseURL) {
3365
4692
  throw new Error("Option databaseURL is required");
3366
4693
  }
3367
- return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser, clientName };
3368
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
4694
+ const envBranch = getBranch();
4695
+ const previewBranch = getPreviewBranch();
4696
+ const branch = options?.branch || previewBranch || envBranch || "main";
4697
+ if (!!previewBranch && branch !== previewBranch) {
4698
+ console.warn(
4699
+ `Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
4700
+ );
4701
+ } else if (!!envBranch && branch !== envBranch) {
4702
+ console.warn(
4703
+ `Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
4704
+ );
4705
+ } else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
4706
+ console.warn(
4707
+ `Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
4708
+ );
4709
+ } else if (!previewBranch && !envBranch && options?.branch === void 0) {
4710
+ console.warn(
4711
+ `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.`
4712
+ );
4713
+ }
4714
+ return {
4715
+ fetch,
4716
+ databaseURL,
4717
+ apiKey,
4718
+ branch,
4719
+ cache,
4720
+ trace,
4721
+ host,
4722
+ clientID: generateUUID(),
4723
+ enableBrowser,
4724
+ clientName,
4725
+ xataAgentExtra
4726
+ };
4727
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
3369
4728
  fetch,
3370
4729
  apiKey,
3371
4730
  databaseURL,
3372
4731
  branch,
3373
4732
  trace,
3374
4733
  clientID,
3375
- clientName
4734
+ clientName,
4735
+ xataAgentExtra
3376
4736
  }) {
3377
- const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
3378
- if (!branchValue)
3379
- throw new Error("Unable to resolve branch value");
3380
4737
  return {
3381
- fetchImpl: fetch,
4738
+ fetch,
3382
4739
  apiKey,
3383
4740
  apiUrl: "",
4741
+ // Instead of using workspace and dbBranch, we inject a probably CNAME'd URL
3384
4742
  workspacesApiUrl: (path, params) => {
3385
4743
  const hasBranch = params.dbBranchName ?? params.branch;
3386
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
4744
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
3387
4745
  return databaseURL + newPath;
3388
4746
  },
3389
4747
  trace,
3390
4748
  clientID,
3391
- clientName
3392
- };
3393
- }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
3394
- if (__privateGet(this, _branch))
3395
- return __privateGet(this, _branch);
3396
- if (param === void 0)
3397
- return void 0;
3398
- const strategies = Array.isArray(param) ? [...param] : [param];
3399
- const evaluateBranch = async (strategy) => {
3400
- return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
4749
+ clientName,
4750
+ xataAgentExtra
3401
4751
  };
3402
- for await (const strategy of strategies) {
3403
- const branch = await evaluateBranch(strategy);
3404
- if (branch) {
3405
- __privateSet(this, _branch, branch);
3406
- return branch;
3407
- }
3408
- }
3409
4752
  }, _a;
3410
4753
  };
3411
4754
  class BaseClient extends buildClient() {
3412
4755
  }
3413
4756
 
4757
+ var __defProp$1 = Object.defineProperty;
4758
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4759
+ var __publicField$1 = (obj, key, value) => {
4760
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
4761
+ return value;
4762
+ };
3414
4763
  const META = "__";
3415
4764
  const VALUE = "___";
3416
4765
  class Serializer {
3417
4766
  constructor() {
3418
- this.classes = {};
4767
+ __publicField$1(this, "classes", {});
3419
4768
  }
3420
4769
  add(clazz) {
3421
4770
  this.classes[clazz.name] = clazz;
@@ -3493,12 +4842,19 @@ function buildWorkerRunner(config) {
3493
4842
  };
3494
4843
  }
3495
4844
 
4845
+ var __defProp = Object.defineProperty;
4846
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4847
+ var __publicField = (obj, key, value) => {
4848
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4849
+ return value;
4850
+ };
3496
4851
  class XataError extends Error {
3497
4852
  constructor(message, status) {
3498
4853
  super(message);
4854
+ __publicField(this, "status");
3499
4855
  this.status = status;
3500
4856
  }
3501
4857
  }
3502
4858
 
3503
- export { BaseClient, FetcherError, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, branchTransaction, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
4859
+ export { BaseClient, FetcherError, FilesPlugin, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SQLPlugin, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteOAuthAccessToken, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteUserOAuthClient, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, ge, getAPIKey, getAuthorizationCode, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getUserOAuthAccessTokens, getUserOAuthClients, getWorkspace, getWorkspaceMembersList, getWorkspacesList, grantAuthorizationCode, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isValidExpandedColumn, isValidSelectableColumns, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, transformImage, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateOAuthAccessToken, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
3504
4860
  //# sourceMappingURL=index.mjs.map