@xata.io/client 0.0.0-alpha.vf61048f → 0.0.0-alpha.vf63fddb

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,11 @@ 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
+ }
30
34
  function isObject(value) {
31
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
35
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof Blob);
32
36
  }
33
37
  function isDefined(value) {
34
38
  return value !== null && value !== void 0;
@@ -83,6 +87,27 @@ function chunk(array, chunkSize) {
83
87
  async function timeout(ms) {
84
88
  return new Promise((resolve) => setTimeout(resolve, ms));
85
89
  }
90
+ function timeoutWithCancel(ms) {
91
+ let timeoutId;
92
+ const promise = new Promise((resolve) => {
93
+ timeoutId = setTimeout(() => {
94
+ resolve();
95
+ }, ms);
96
+ });
97
+ return {
98
+ cancel: () => clearTimeout(timeoutId),
99
+ promise
100
+ };
101
+ }
102
+ function promiseMap(inputValues, mapper) {
103
+ const reducer = (acc$, inputValue) => acc$.then(
104
+ (acc) => mapper(inputValue).then((result) => {
105
+ acc.push(result);
106
+ return acc;
107
+ })
108
+ );
109
+ return inputValues.reduce(reducer, Promise.resolve([]));
110
+ }
86
111
 
87
112
  function getEnvironment() {
88
113
  try {
@@ -91,8 +116,10 @@ function getEnvironment() {
91
116
  apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
92
117
  databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
93
118
  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()
119
+ deployPreview: process.env.XATA_PREVIEW,
120
+ deployPreviewBranch: process.env.XATA_PREVIEW_BRANCH,
121
+ vercelGitCommitRef: process.env.VERCEL_GIT_COMMIT_REF,
122
+ vercelGitRepoOwner: process.env.VERCEL_GIT_REPO_OWNER
96
123
  };
97
124
  }
98
125
  } catch (err) {
@@ -103,8 +130,10 @@ function getEnvironment() {
103
130
  apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
104
131
  databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
105
132
  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()
133
+ deployPreview: Deno.env.get("XATA_PREVIEW"),
134
+ deployPreviewBranch: Deno.env.get("XATA_PREVIEW_BRANCH"),
135
+ vercelGitCommitRef: Deno.env.get("VERCEL_GIT_COMMIT_REF"),
136
+ vercelGitRepoOwner: Deno.env.get("VERCEL_GIT_REPO_OWNER")
108
137
  };
109
138
  }
110
139
  } catch (err) {
@@ -113,8 +142,10 @@ function getEnvironment() {
113
142
  apiKey: getGlobalApiKey(),
114
143
  databaseURL: getGlobalDatabaseURL(),
115
144
  branch: getGlobalBranch(),
116
- envBranch: void 0,
117
- fallbackBranch: getGlobalFallbackBranch()
145
+ deployPreview: void 0,
146
+ deployPreviewBranch: void 0,
147
+ vercelGitCommitRef: void 0,
148
+ vercelGitRepoOwner: void 0
118
149
  };
119
150
  }
120
151
  function getEnableBrowserVariable() {
@@ -157,41 +188,59 @@ function getGlobalBranch() {
157
188
  return void 0;
158
189
  }
159
190
  }
160
- function getGlobalFallbackBranch() {
191
+ function getDatabaseURL() {
161
192
  try {
162
- return XATA_FALLBACK_BRANCH;
193
+ const { databaseURL } = getEnvironment();
194
+ return databaseURL;
163
195
  } catch (err) {
164
196
  return void 0;
165
197
  }
166
198
  }
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"] };
199
+ function getAPIKey() {
172
200
  try {
173
- const { execSync } = await import(nodeModule);
174
- return execSync(fullCmd, execOptions).toString().trim();
201
+ const { apiKey } = getEnvironment();
202
+ return apiKey;
175
203
  } catch (err) {
204
+ return void 0;
176
205
  }
206
+ }
207
+ function getBranch() {
177
208
  try {
178
- if (isObject(Deno)) {
179
- const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
180
- return new TextDecoder().decode(await process2.output()).trim();
181
- }
209
+ const { branch } = getEnvironment();
210
+ return branch;
182
211
  } catch (err) {
212
+ return void 0;
183
213
  }
184
214
  }
185
-
186
- function getAPIKey() {
215
+ function buildPreviewBranchName({ org, branch }) {
216
+ return `preview-${org}-${branch}`;
217
+ }
218
+ function getPreviewBranch() {
187
219
  try {
188
- const { apiKey } = getEnvironment();
189
- return apiKey;
220
+ const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = getEnvironment();
221
+ if (deployPreviewBranch)
222
+ return deployPreviewBranch;
223
+ switch (deployPreview) {
224
+ case "vercel": {
225
+ if (!vercelGitCommitRef || !vercelGitRepoOwner) {
226
+ console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
227
+ return void 0;
228
+ }
229
+ return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
230
+ }
231
+ }
232
+ return void 0;
190
233
  } catch (err) {
191
234
  return void 0;
192
235
  }
193
236
  }
194
237
 
238
+ var __defProp$8 = Object.defineProperty;
239
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
240
+ var __publicField$8 = (obj, key, value) => {
241
+ __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
242
+ return value;
243
+ };
195
244
  var __accessCheck$8 = (obj, member, msg) => {
196
245
  if (!member.has(obj))
197
246
  throw TypeError("Cannot " + msg);
@@ -215,6 +264,7 @@ var __privateMethod$4 = (obj, member, method) => {
215
264
  return method;
216
265
  };
217
266
  var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
267
+ const REQUEST_TIMEOUT = 3e4;
218
268
  function getFetchImplementation(userFetch) {
219
269
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
220
270
  const fetchImpl = userFetch ?? globalFetch;
@@ -231,6 +281,8 @@ class ApiRequestPool {
231
281
  __privateAdd$8(this, _fetch, void 0);
232
282
  __privateAdd$8(this, _queue, void 0);
233
283
  __privateAdd$8(this, _concurrency, void 0);
284
+ __publicField$8(this, "running");
285
+ __publicField$8(this, "started");
234
286
  __privateSet$8(this, _queue, []);
235
287
  __privateSet$8(this, _concurrency, concurrency);
236
288
  this.running = 0;
@@ -246,18 +298,22 @@ class ApiRequestPool {
246
298
  return __privateGet$8(this, _fetch);
247
299
  }
248
300
  request(url, options) {
249
- const start = new Date();
250
- const fetch2 = this.getFetch();
301
+ const start = /* @__PURE__ */ new Date();
302
+ const fetchImpl = this.getFetch();
251
303
  const runRequest = async (stalled = false) => {
252
- const response = await fetch2(url, options);
304
+ const { promise, cancel } = timeoutWithCancel(REQUEST_TIMEOUT);
305
+ const response = await Promise.race([fetchImpl(url, options), promise.then(() => null)]).finally(cancel);
306
+ if (!response) {
307
+ throw new Error("Request timed out");
308
+ }
253
309
  if (response.status === 429) {
254
310
  const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
255
311
  await timeout(rateLimitReset * 1e3);
256
312
  return await runRequest(true);
257
313
  }
258
314
  if (stalled) {
259
- const stalledTime = new Date().getTime() - start.getTime();
260
- console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
315
+ const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
316
+ console.warn(`A request to Xata hit branch rate limits, was retried and stalled for ${stalledTime}ms`);
261
317
  }
262
318
  return response;
263
319
  };
@@ -299,16 +355,199 @@ function generateUUID() {
299
355
  });
300
356
  }
301
357
 
302
- const VERSION = "0.21.6";
358
+ async function getBytes(stream, onChunk) {
359
+ const reader = stream.getReader();
360
+ let result;
361
+ while (!(result = await reader.read()).done) {
362
+ onChunk(result.value);
363
+ }
364
+ }
365
+ function getLines(onLine) {
366
+ let buffer;
367
+ let position;
368
+ let fieldLength;
369
+ let discardTrailingNewline = false;
370
+ return function onChunk(arr) {
371
+ if (buffer === void 0) {
372
+ buffer = arr;
373
+ position = 0;
374
+ fieldLength = -1;
375
+ } else {
376
+ buffer = concat(buffer, arr);
377
+ }
378
+ const bufLength = buffer.length;
379
+ let lineStart = 0;
380
+ while (position < bufLength) {
381
+ if (discardTrailingNewline) {
382
+ if (buffer[position] === 10 /* NewLine */) {
383
+ lineStart = ++position;
384
+ }
385
+ discardTrailingNewline = false;
386
+ }
387
+ let lineEnd = -1;
388
+ for (; position < bufLength && lineEnd === -1; ++position) {
389
+ switch (buffer[position]) {
390
+ case 58 /* Colon */:
391
+ if (fieldLength === -1) {
392
+ fieldLength = position - lineStart;
393
+ }
394
+ break;
395
+ case 13 /* CarriageReturn */:
396
+ discardTrailingNewline = true;
397
+ case 10 /* NewLine */:
398
+ lineEnd = position;
399
+ break;
400
+ }
401
+ }
402
+ if (lineEnd === -1) {
403
+ break;
404
+ }
405
+ onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
406
+ lineStart = position;
407
+ fieldLength = -1;
408
+ }
409
+ if (lineStart === bufLength) {
410
+ buffer = void 0;
411
+ } else if (lineStart !== 0) {
412
+ buffer = buffer.subarray(lineStart);
413
+ position -= lineStart;
414
+ }
415
+ };
416
+ }
417
+ function getMessages(onId, onRetry, onMessage) {
418
+ let message = newMessage();
419
+ const decoder = new TextDecoder();
420
+ return function onLine(line, fieldLength) {
421
+ if (line.length === 0) {
422
+ onMessage?.(message);
423
+ message = newMessage();
424
+ } else if (fieldLength > 0) {
425
+ const field = decoder.decode(line.subarray(0, fieldLength));
426
+ const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
427
+ const value = decoder.decode(line.subarray(valueOffset));
428
+ switch (field) {
429
+ case "data":
430
+ message.data = message.data ? message.data + "\n" + value : value;
431
+ break;
432
+ case "event":
433
+ message.event = value;
434
+ break;
435
+ case "id":
436
+ onId(message.id = value);
437
+ break;
438
+ case "retry":
439
+ const retry = parseInt(value, 10);
440
+ if (!isNaN(retry)) {
441
+ onRetry(message.retry = retry);
442
+ }
443
+ break;
444
+ }
445
+ }
446
+ };
447
+ }
448
+ function concat(a, b) {
449
+ const res = new Uint8Array(a.length + b.length);
450
+ res.set(a);
451
+ res.set(b, a.length);
452
+ return res;
453
+ }
454
+ function newMessage() {
455
+ return {
456
+ data: "",
457
+ event: "",
458
+ id: "",
459
+ retry: void 0
460
+ };
461
+ }
462
+ const EventStreamContentType = "text/event-stream";
463
+ const LastEventId = "last-event-id";
464
+ function fetchEventSource(input, {
465
+ signal: inputSignal,
466
+ headers: inputHeaders,
467
+ onopen: inputOnOpen,
468
+ onmessage,
469
+ onclose,
470
+ onerror,
471
+ fetch: inputFetch,
472
+ ...rest
473
+ }) {
474
+ return new Promise((resolve, reject) => {
475
+ const headers = { ...inputHeaders };
476
+ if (!headers.accept) {
477
+ headers.accept = EventStreamContentType;
478
+ }
479
+ let curRequestController;
480
+ function dispose() {
481
+ curRequestController.abort();
482
+ }
483
+ inputSignal?.addEventListener("abort", () => {
484
+ dispose();
485
+ resolve();
486
+ });
487
+ const fetchImpl = inputFetch ?? fetch;
488
+ const onopen = inputOnOpen ?? defaultOnOpen;
489
+ async function create() {
490
+ curRequestController = new AbortController();
491
+ try {
492
+ const response = await fetchImpl(input, {
493
+ ...rest,
494
+ headers,
495
+ signal: curRequestController.signal
496
+ });
497
+ await onopen(response);
498
+ await getBytes(
499
+ response.body,
500
+ getLines(
501
+ getMessages(
502
+ (id) => {
503
+ if (id) {
504
+ headers[LastEventId] = id;
505
+ } else {
506
+ delete headers[LastEventId];
507
+ }
508
+ },
509
+ (_retry) => {
510
+ },
511
+ onmessage
512
+ )
513
+ )
514
+ );
515
+ onclose?.();
516
+ dispose();
517
+ resolve();
518
+ } catch (err) {
519
+ }
520
+ }
521
+ create();
522
+ });
523
+ }
524
+ function defaultOnOpen(response) {
525
+ const contentType = response.headers?.get("content-type");
526
+ if (!contentType?.startsWith(EventStreamContentType)) {
527
+ throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
528
+ }
529
+ }
530
+
531
+ const VERSION = "0.26.4";
303
532
 
533
+ var __defProp$7 = Object.defineProperty;
534
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
535
+ var __publicField$7 = (obj, key, value) => {
536
+ __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
537
+ return value;
538
+ };
304
539
  class ErrorWithCause extends Error {
305
540
  constructor(message, options) {
306
541
  super(message, options);
542
+ __publicField$7(this, "cause");
307
543
  }
308
544
  }
309
545
  class FetcherError extends ErrorWithCause {
310
546
  constructor(status, data, requestId) {
311
547
  super(getMessage(data));
548
+ __publicField$7(this, "status");
549
+ __publicField$7(this, "requestId");
550
+ __publicField$7(this, "errors");
312
551
  this.status = status;
313
552
  this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
314
553
  this.requestId = requestId;
@@ -375,6 +614,18 @@ function hostHeader(url) {
375
614
  const { groups } = pattern.exec(url) ?? {};
376
615
  return groups?.host ? { Host: groups.host } : {};
377
616
  }
617
+ async function parseBody(body, headers) {
618
+ if (!isDefined(body))
619
+ return void 0;
620
+ if (body instanceof Blob || typeof body.text === "function") {
621
+ return body;
622
+ }
623
+ const { "Content-Type": contentType } = headers ?? {};
624
+ if (String(contentType).toLowerCase() === "application/json" && isObject(body)) {
625
+ return JSON.stringify(body);
626
+ }
627
+ return body;
628
+ }
378
629
  const defaultClientID = generateUUID();
379
630
  async function fetch$1({
380
631
  url: path,
@@ -383,7 +634,7 @@ async function fetch$1({
383
634
  headers: customHeaders,
384
635
  pathParams,
385
636
  queryParams,
386
- fetchImpl,
637
+ fetch: fetch2,
387
638
  apiKey,
388
639
  endpoint,
389
640
  apiUrl,
@@ -393,9 +644,11 @@ async function fetch$1({
393
644
  clientID,
394
645
  sessionID,
395
646
  clientName,
396
- fetchOptions = {}
647
+ xataAgentExtra,
648
+ fetchOptions = {},
649
+ rawResponse = false
397
650
  }) {
398
- pool.setFetch(fetchImpl);
651
+ pool.setFetch(fetch2);
399
652
  return await trace(
400
653
  `${method.toUpperCase()} ${path}`,
401
654
  async ({ setAttributes }) => {
@@ -409,9 +662,10 @@ async function fetch$1({
409
662
  const xataAgent = compact([
410
663
  ["client", "TS_SDK"],
411
664
  ["version", VERSION],
412
- isDefined(clientName) ? ["service", clientName] : void 0
665
+ isDefined(clientName) ? ["service", clientName] : void 0,
666
+ ...Object.entries(xataAgentExtra ?? {})
413
667
  ]).map(([key, value]) => `${key}=${value}`).join("; ");
414
- const headers = {
668
+ const headers = compactObject({
415
669
  "Accept-Encoding": "identity",
416
670
  "Content-Type": "application/json",
417
671
  "X-Xata-Client-ID": clientID ?? defaultClientID,
@@ -420,11 +674,11 @@ async function fetch$1({
420
674
  ...customHeaders,
421
675
  ...hostHeader(fullUrl),
422
676
  Authorization: `Bearer ${apiKey}`
423
- };
677
+ });
424
678
  const response = await pool.request(url, {
425
679
  ...fetchOptions,
426
680
  method: method.toUpperCase(),
427
- body: body ? JSON.stringify(body) : void 0,
681
+ body: await parseBody(body, headers),
428
682
  headers,
429
683
  signal
430
684
  });
@@ -435,8 +689,12 @@ async function fetch$1({
435
689
  [TraceAttributes.HTTP_REQUEST_ID]: requestId,
436
690
  [TraceAttributes.HTTP_STATUS_CODE]: response.status,
437
691
  [TraceAttributes.HTTP_HOST]: host,
438
- [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
692
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", ""),
693
+ [TraceAttributes.CLOUDFLARE_RAY_ID]: response.headers?.get("cf-ray") ?? void 0
439
694
  });
695
+ const message = response.headers?.get("x-xata-message");
696
+ if (message)
697
+ console.warn(message);
440
698
  if (response.status === 204) {
441
699
  return {};
442
700
  }
@@ -444,7 +702,7 @@ async function fetch$1({
444
702
  throw new FetcherError(response.status, "Rate limit exceeded", requestId);
445
703
  }
446
704
  try {
447
- const jsonResponse = await response.json();
705
+ const jsonResponse = rawResponse ? await response.blob() : await response.json();
448
706
  if (response.ok) {
449
707
  return jsonResponse;
450
708
  }
@@ -456,6 +714,59 @@ async function fetch$1({
456
714
  { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
457
715
  );
458
716
  }
717
+ function fetchSSERequest({
718
+ url: path,
719
+ method,
720
+ body,
721
+ headers: customHeaders,
722
+ pathParams,
723
+ queryParams,
724
+ fetch: fetch2,
725
+ apiKey,
726
+ endpoint,
727
+ apiUrl,
728
+ workspacesApiUrl,
729
+ onMessage,
730
+ onError,
731
+ onClose,
732
+ signal,
733
+ clientID,
734
+ sessionID,
735
+ clientName,
736
+ xataAgentExtra
737
+ }) {
738
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
739
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
740
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
741
+ void fetchEventSource(url, {
742
+ method,
743
+ body: JSON.stringify(body),
744
+ fetch: fetch2,
745
+ signal,
746
+ headers: {
747
+ "X-Xata-Client-ID": clientID ?? defaultClientID,
748
+ "X-Xata-Session-ID": sessionID ?? generateUUID(),
749
+ "X-Xata-Agent": compact([
750
+ ["client", "TS_SDK"],
751
+ ["version", VERSION],
752
+ isDefined(clientName) ? ["service", clientName] : void 0,
753
+ ...Object.entries(xataAgentExtra ?? {})
754
+ ]).map(([key, value]) => `${key}=${value}`).join("; "),
755
+ ...customHeaders,
756
+ Authorization: `Bearer ${apiKey}`,
757
+ "Content-Type": "application/json"
758
+ },
759
+ onmessage(ev) {
760
+ onMessage?.(JSON.parse(ev.data));
761
+ },
762
+ onerror(ev) {
763
+ onError?.(JSON.parse(ev.data));
764
+ },
765
+ onclose() {
766
+ onClose?.();
767
+ }
768
+ });
769
+ }
459
770
  function parseUrl(url) {
460
771
  try {
461
772
  const { host, protocol } = new URL(url);
@@ -486,6 +797,12 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
486
797
  ...variables,
487
798
  signal
488
799
  });
800
+ const copyBranch = (variables, signal) => dataPlaneFetch({
801
+ url: "/db/{dbBranchName}/copy",
802
+ method: "post",
803
+ ...variables,
804
+ signal
805
+ });
489
806
  const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
490
807
  url: "/db/{dbBranchName}/metadata",
491
808
  method: "put",
@@ -535,6 +852,7 @@ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{
535
852
  const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
536
853
  const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
537
854
  const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
855
+ const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
538
856
  const createTable = (variables, signal) => dataPlaneFetch({
539
857
  url: "/db/{dbBranchName}/tables/{tableName}",
540
858
  method: "put",
@@ -579,6 +897,42 @@ const deleteColumn = (variables, signal) => dataPlaneFetch({
579
897
  });
580
898
  const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
581
899
  const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
900
+ const getFileItem = (variables, signal) => dataPlaneFetch({
901
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
902
+ method: "get",
903
+ ...variables,
904
+ signal
905
+ });
906
+ const putFileItem = (variables, signal) => dataPlaneFetch({
907
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
908
+ method: "put",
909
+ ...variables,
910
+ signal
911
+ });
912
+ const deleteFileItem = (variables, signal) => dataPlaneFetch({
913
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
914
+ method: "delete",
915
+ ...variables,
916
+ signal
917
+ });
918
+ const getFile = (variables, signal) => dataPlaneFetch({
919
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
920
+ method: "get",
921
+ ...variables,
922
+ signal
923
+ });
924
+ const putFile = (variables, signal) => dataPlaneFetch({
925
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
926
+ method: "put",
927
+ ...variables,
928
+ signal
929
+ });
930
+ const deleteFile = (variables, signal) => dataPlaneFetch({
931
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
932
+ method: "delete",
933
+ ...variables,
934
+ signal
935
+ });
582
936
  const getRecord = (variables, signal) => dataPlaneFetch({
583
937
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
584
938
  method: "get",
@@ -608,14 +962,35 @@ const searchTable = (variables, signal) => dataPlaneFetch({
608
962
  ...variables,
609
963
  signal
610
964
  });
965
+ const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
966
+ const askTable = (variables, signal) => dataPlaneFetch({
967
+ url: "/db/{dbBranchName}/tables/{tableName}/ask",
968
+ method: "post",
969
+ ...variables,
970
+ signal
971
+ });
972
+ const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
611
973
  const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
612
974
  const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
975
+ const fileAccess = (variables, signal) => dataPlaneFetch({
976
+ url: "/file/{fileId}",
977
+ method: "get",
978
+ ...variables,
979
+ signal
980
+ });
981
+ const sqlQuery = (variables, signal) => dataPlaneFetch({
982
+ url: "/db/{dbBranchName}/sql",
983
+ method: "post",
984
+ ...variables,
985
+ signal
986
+ });
613
987
  const operationsByTag$2 = {
614
988
  branch: {
615
989
  getBranchList,
616
990
  getBranchDetails,
617
991
  createBranch,
618
992
  deleteBranch,
993
+ copyBranch,
619
994
  updateBranchMetadata,
620
995
  getBranchMetadata,
621
996
  getBranchStats,
@@ -633,7 +1008,8 @@ const operationsByTag$2 = {
633
1008
  compareBranchSchemas,
634
1009
  updateBranchSchema,
635
1010
  previewBranchSchemaEdit,
636
- applyBranchSchemaEdit
1011
+ applyBranchSchemaEdit,
1012
+ pushBranchMigrations
637
1013
  },
638
1014
  migrationRequests: {
639
1015
  queryMigrationRequests,
@@ -667,11 +1043,24 @@ const operationsByTag$2 = {
667
1043
  deleteRecord,
668
1044
  bulkInsertTableRecords
669
1045
  },
670
- searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
1046
+ files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
1047
+ searchAndFilter: {
1048
+ queryTable,
1049
+ searchBranch,
1050
+ searchTable,
1051
+ vectorSearchTable,
1052
+ askTable,
1053
+ askTableSession,
1054
+ summarizeTable,
1055
+ aggregateTable
1056
+ },
1057
+ sql: { sqlQuery }
671
1058
  };
672
1059
 
673
1060
  const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
674
1061
 
1062
+ const getAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "get", ...variables, signal });
1063
+ const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
675
1064
  const getUser = (variables, signal) => controlPlaneFetch({
676
1065
  url: "/user",
677
1066
  method: "get",
@@ -708,6 +1097,31 @@ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
708
1097
  ...variables,
709
1098
  signal
710
1099
  });
1100
+ const getUserOAuthClients = (variables, signal) => controlPlaneFetch({
1101
+ url: "/user/oauth/clients",
1102
+ method: "get",
1103
+ ...variables,
1104
+ signal
1105
+ });
1106
+ const deleteUserOAuthClient = (variables, signal) => controlPlaneFetch({
1107
+ url: "/user/oauth/clients/{clientId}",
1108
+ method: "delete",
1109
+ ...variables,
1110
+ signal
1111
+ });
1112
+ const getUserOAuthAccessTokens = (variables, signal) => controlPlaneFetch({
1113
+ url: "/user/oauth/tokens",
1114
+ method: "get",
1115
+ ...variables,
1116
+ signal
1117
+ });
1118
+ const deleteOAuthAccessToken = (variables, signal) => controlPlaneFetch({
1119
+ url: "/user/oauth/tokens/{token}",
1120
+ method: "delete",
1121
+ ...variables,
1122
+ signal
1123
+ });
1124
+ const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({ url: "/user/oauth/tokens/{token}", method: "patch", ...variables, signal });
711
1125
  const getWorkspacesList = (variables, signal) => controlPlaneFetch({
712
1126
  url: "/workspaces",
713
1127
  method: "get",
@@ -766,6 +1180,10 @@ const deleteDatabase = (variables, signal) => controlPlaneFetch({
766
1180
  });
767
1181
  const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
768
1182
  const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
1183
+ const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
1184
+ const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
1185
+ const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
1186
+ const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
769
1187
  const listRegions = (variables, signal) => controlPlaneFetch({
770
1188
  url: "/workspaces/{workspaceId}/regions",
771
1189
  method: "get",
@@ -773,6 +1191,15 @@ const listRegions = (variables, signal) => controlPlaneFetch({
773
1191
  signal
774
1192
  });
775
1193
  const operationsByTag$1 = {
1194
+ oAuth: {
1195
+ getAuthorizationCode,
1196
+ grantAuthorizationCode,
1197
+ getUserOAuthClients,
1198
+ deleteUserOAuthClient,
1199
+ getUserOAuthAccessTokens,
1200
+ deleteOAuthAccessToken,
1201
+ updateOAuthAccessToken
1202
+ },
776
1203
  users: { getUser, updateUser, deleteUser },
777
1204
  authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
778
1205
  workspaces: {
@@ -798,6 +1225,10 @@ const operationsByTag$1 = {
798
1225
  deleteDatabase,
799
1226
  getDatabaseMetadata,
800
1227
  updateDatabaseMetadata,
1228
+ renameDatabase,
1229
+ getDatabaseGithubSettings,
1230
+ updateDatabaseGithubSettings,
1231
+ deleteDatabaseGithubSettings,
801
1232
  listRegions
802
1233
  }
803
1234
  };
@@ -818,8 +1249,12 @@ const providers = {
818
1249
  workspaces: "https://{workspaceId}.{region}.xata.sh"
819
1250
  },
820
1251
  staging: {
821
- main: "https://staging.xatabase.co",
822
- workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
1252
+ main: "https://api.staging-xata.dev",
1253
+ workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
1254
+ },
1255
+ dev: {
1256
+ main: "https://api.dev-xata.dev",
1257
+ workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
823
1258
  }
824
1259
  };
825
1260
  function isHostProviderAlias(alias) {
@@ -837,12 +1272,19 @@ function parseProviderString(provider = "production") {
837
1272
  return null;
838
1273
  return { main, workspaces };
839
1274
  }
1275
+ function buildProviderString(provider) {
1276
+ if (isHostProviderAlias(provider))
1277
+ return provider;
1278
+ return `${provider.main},${provider.workspaces}`;
1279
+ }
840
1280
  function parseWorkspacesUrlParts(url) {
841
1281
  if (!isString(url))
842
1282
  return null;
843
1283
  const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
844
- const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))\.xatabase\.co.*/;
845
- const match = url.match(regex) || url.match(regexStaging);
1284
+ const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
1285
+ const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
1286
+ const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
1287
+ const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
846
1288
  if (!match)
847
1289
  return null;
848
1290
  return { workspace: match[1], region: match[2] };
@@ -881,10 +1323,11 @@ class XataApiClient {
881
1323
  __privateSet$7(this, _extraProps, {
882
1324
  apiUrl: getHostUrl(provider, "main"),
883
1325
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
884
- fetchImpl: getFetchImplementation(options.fetch),
1326
+ fetch: getFetchImplementation(options.fetch),
885
1327
  apiKey,
886
1328
  trace,
887
1329
  clientName: options.clientName,
1330
+ xataAgentExtra: options.xataAgentExtra,
888
1331
  clientID
889
1332
  });
890
1333
  }
@@ -938,6 +1381,11 @@ class XataApiClient {
938
1381
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
939
1382
  return __privateGet$7(this, _namespaces).records;
940
1383
  }
1384
+ get files() {
1385
+ if (!__privateGet$7(this, _namespaces).files)
1386
+ __privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
1387
+ return __privateGet$7(this, _namespaces).files;
1388
+ }
941
1389
  get searchAndFilter() {
942
1390
  if (!__privateGet$7(this, _namespaces).searchAndFilter)
943
1391
  __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
@@ -1146,6 +1594,20 @@ class BranchApi {
1146
1594
  ...this.extraProps
1147
1595
  });
1148
1596
  }
1597
+ copyBranch({
1598
+ workspace,
1599
+ region,
1600
+ database,
1601
+ branch,
1602
+ destinationBranch,
1603
+ limit
1604
+ }) {
1605
+ return operationsByTag.branch.copyBranch({
1606
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1607
+ body: { destinationBranch, limit },
1608
+ ...this.extraProps
1609
+ });
1610
+ }
1149
1611
  updateBranchMetadata({
1150
1612
  workspace,
1151
1613
  region,
@@ -1501,116 +1963,321 @@ class RecordsApi {
1501
1963
  });
1502
1964
  }
1503
1965
  }
1504
- class SearchAndFilterApi {
1966
+ class FilesApi {
1505
1967
  constructor(extraProps) {
1506
1968
  this.extraProps = extraProps;
1507
1969
  }
1508
- queryTable({
1970
+ getFileItem({
1509
1971
  workspace,
1510
1972
  region,
1511
1973
  database,
1512
1974
  branch,
1513
1975
  table,
1514
- filter,
1515
- sort,
1516
- page,
1517
- columns,
1518
- consistency
1976
+ record,
1977
+ column,
1978
+ fileId
1519
1979
  }) {
1520
- return operationsByTag.searchAndFilter.queryTable({
1521
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1522
- body: { filter, sort, page, columns, consistency },
1980
+ return operationsByTag.files.getFileItem({
1981
+ pathParams: {
1982
+ workspace,
1983
+ region,
1984
+ dbBranchName: `${database}:${branch}`,
1985
+ tableName: table,
1986
+ recordId: record,
1987
+ columnName: column,
1988
+ fileId
1989
+ },
1523
1990
  ...this.extraProps
1524
1991
  });
1525
1992
  }
1526
- searchTable({
1993
+ putFileItem({
1527
1994
  workspace,
1528
1995
  region,
1529
1996
  database,
1530
1997
  branch,
1531
1998
  table,
1532
- query,
1533
- fuzziness,
1534
- target,
1535
- prefix,
1536
- filter,
1537
- highlight,
1538
- boosters
1999
+ record,
2000
+ column,
2001
+ fileId,
2002
+ file
1539
2003
  }) {
1540
- return operationsByTag.searchAndFilter.searchTable({
1541
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1542
- body: { query, fuzziness, target, prefix, filter, highlight, boosters },
2004
+ return operationsByTag.files.putFileItem({
2005
+ pathParams: {
2006
+ workspace,
2007
+ region,
2008
+ dbBranchName: `${database}:${branch}`,
2009
+ tableName: table,
2010
+ recordId: record,
2011
+ columnName: column,
2012
+ fileId
2013
+ },
2014
+ // @ts-ignore
2015
+ body: file,
1543
2016
  ...this.extraProps
1544
2017
  });
1545
2018
  }
1546
- searchBranch({
2019
+ deleteFileItem({
1547
2020
  workspace,
1548
2021
  region,
1549
2022
  database,
1550
2023
  branch,
1551
- tables,
1552
- query,
1553
- fuzziness,
1554
- prefix,
1555
- highlight
2024
+ table,
2025
+ record,
2026
+ column,
2027
+ fileId
1556
2028
  }) {
1557
- return operationsByTag.searchAndFilter.searchBranch({
1558
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1559
- body: { tables, query, fuzziness, prefix, highlight },
2029
+ return operationsByTag.files.deleteFileItem({
2030
+ pathParams: {
2031
+ workspace,
2032
+ region,
2033
+ dbBranchName: `${database}:${branch}`,
2034
+ tableName: table,
2035
+ recordId: record,
2036
+ columnName: column,
2037
+ fileId
2038
+ },
1560
2039
  ...this.extraProps
1561
2040
  });
1562
2041
  }
1563
- summarizeTable({
2042
+ getFile({
1564
2043
  workspace,
1565
2044
  region,
1566
2045
  database,
1567
2046
  branch,
1568
2047
  table,
1569
- filter,
1570
- columns,
1571
- summaries,
1572
- sort,
1573
- summariesFilter,
1574
- page,
1575
- consistency
2048
+ record,
2049
+ column
1576
2050
  }) {
1577
- return operationsByTag.searchAndFilter.summarizeTable({
1578
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1579
- body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
2051
+ return operationsByTag.files.getFile({
2052
+ pathParams: {
2053
+ workspace,
2054
+ region,
2055
+ dbBranchName: `${database}:${branch}`,
2056
+ tableName: table,
2057
+ recordId: record,
2058
+ columnName: column
2059
+ },
1580
2060
  ...this.extraProps
1581
2061
  });
1582
2062
  }
1583
- aggregateTable({
2063
+ putFile({
1584
2064
  workspace,
1585
2065
  region,
1586
2066
  database,
1587
2067
  branch,
1588
2068
  table,
1589
- filter,
1590
- aggs
2069
+ record,
2070
+ column,
2071
+ file
1591
2072
  }) {
1592
- return operationsByTag.searchAndFilter.aggregateTable({
1593
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1594
- body: { filter, aggs },
2073
+ return operationsByTag.files.putFile({
2074
+ pathParams: {
2075
+ workspace,
2076
+ region,
2077
+ dbBranchName: `${database}:${branch}`,
2078
+ tableName: table,
2079
+ recordId: record,
2080
+ columnName: column
2081
+ },
2082
+ body: file,
1595
2083
  ...this.extraProps
1596
2084
  });
1597
2085
  }
1598
- }
1599
- class MigrationRequestsApi {
1600
- constructor(extraProps) {
1601
- this.extraProps = extraProps;
1602
- }
1603
- queryMigrationRequests({
2086
+ deleteFile({
1604
2087
  workspace,
1605
2088
  region,
1606
2089
  database,
1607
- filter,
1608
- sort,
1609
- page,
1610
- columns
2090
+ branch,
2091
+ table,
2092
+ record,
2093
+ column
1611
2094
  }) {
1612
- return operationsByTag.migrationRequests.queryMigrationRequests({
1613
- pathParams: { workspace, region, dbName: database },
2095
+ return operationsByTag.files.deleteFile({
2096
+ pathParams: {
2097
+ workspace,
2098
+ region,
2099
+ dbBranchName: `${database}:${branch}`,
2100
+ tableName: table,
2101
+ recordId: record,
2102
+ columnName: column
2103
+ },
2104
+ ...this.extraProps
2105
+ });
2106
+ }
2107
+ fileAccess({
2108
+ workspace,
2109
+ region,
2110
+ fileId,
2111
+ verify
2112
+ }) {
2113
+ return operationsByTag.files.fileAccess({
2114
+ pathParams: {
2115
+ workspace,
2116
+ region,
2117
+ fileId
2118
+ },
2119
+ queryParams: { verify },
2120
+ ...this.extraProps
2121
+ });
2122
+ }
2123
+ }
2124
+ class SearchAndFilterApi {
2125
+ constructor(extraProps) {
2126
+ this.extraProps = extraProps;
2127
+ }
2128
+ queryTable({
2129
+ workspace,
2130
+ region,
2131
+ database,
2132
+ branch,
2133
+ table,
2134
+ filter,
2135
+ sort,
2136
+ page,
2137
+ columns,
2138
+ consistency
2139
+ }) {
2140
+ return operationsByTag.searchAndFilter.queryTable({
2141
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2142
+ body: { filter, sort, page, columns, consistency },
2143
+ ...this.extraProps
2144
+ });
2145
+ }
2146
+ searchTable({
2147
+ workspace,
2148
+ region,
2149
+ database,
2150
+ branch,
2151
+ table,
2152
+ query,
2153
+ fuzziness,
2154
+ target,
2155
+ prefix,
2156
+ filter,
2157
+ highlight,
2158
+ boosters
2159
+ }) {
2160
+ return operationsByTag.searchAndFilter.searchTable({
2161
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2162
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
2163
+ ...this.extraProps
2164
+ });
2165
+ }
2166
+ searchBranch({
2167
+ workspace,
2168
+ region,
2169
+ database,
2170
+ branch,
2171
+ tables,
2172
+ query,
2173
+ fuzziness,
2174
+ prefix,
2175
+ highlight
2176
+ }) {
2177
+ return operationsByTag.searchAndFilter.searchBranch({
2178
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2179
+ body: { tables, query, fuzziness, prefix, highlight },
2180
+ ...this.extraProps
2181
+ });
2182
+ }
2183
+ vectorSearchTable({
2184
+ workspace,
2185
+ region,
2186
+ database,
2187
+ branch,
2188
+ table,
2189
+ queryVector,
2190
+ column,
2191
+ similarityFunction,
2192
+ size,
2193
+ filter
2194
+ }) {
2195
+ return operationsByTag.searchAndFilter.vectorSearchTable({
2196
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2197
+ body: { queryVector, column, similarityFunction, size, filter },
2198
+ ...this.extraProps
2199
+ });
2200
+ }
2201
+ askTable({
2202
+ workspace,
2203
+ region,
2204
+ database,
2205
+ branch,
2206
+ table,
2207
+ options
2208
+ }) {
2209
+ return operationsByTag.searchAndFilter.askTable({
2210
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2211
+ body: { ...options },
2212
+ ...this.extraProps
2213
+ });
2214
+ }
2215
+ askTableSession({
2216
+ workspace,
2217
+ region,
2218
+ database,
2219
+ branch,
2220
+ table,
2221
+ sessionId,
2222
+ message
2223
+ }) {
2224
+ return operationsByTag.searchAndFilter.askTableSession({
2225
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
2226
+ body: { message },
2227
+ ...this.extraProps
2228
+ });
2229
+ }
2230
+ summarizeTable({
2231
+ workspace,
2232
+ region,
2233
+ database,
2234
+ branch,
2235
+ table,
2236
+ filter,
2237
+ columns,
2238
+ summaries,
2239
+ sort,
2240
+ summariesFilter,
2241
+ page,
2242
+ consistency
2243
+ }) {
2244
+ return operationsByTag.searchAndFilter.summarizeTable({
2245
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2246
+ body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
2247
+ ...this.extraProps
2248
+ });
2249
+ }
2250
+ aggregateTable({
2251
+ workspace,
2252
+ region,
2253
+ database,
2254
+ branch,
2255
+ table,
2256
+ filter,
2257
+ aggs
2258
+ }) {
2259
+ return operationsByTag.searchAndFilter.aggregateTable({
2260
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2261
+ body: { filter, aggs },
2262
+ ...this.extraProps
2263
+ });
2264
+ }
2265
+ }
2266
+ class MigrationRequestsApi {
2267
+ constructor(extraProps) {
2268
+ this.extraProps = extraProps;
2269
+ }
2270
+ queryMigrationRequests({
2271
+ workspace,
2272
+ region,
2273
+ database,
2274
+ filter,
2275
+ sort,
2276
+ page,
2277
+ columns
2278
+ }) {
2279
+ return operationsByTag.migrationRequests.queryMigrationRequests({
2280
+ pathParams: { workspace, region, dbName: database },
1614
2281
  body: { filter, sort, page, columns },
1615
2282
  ...this.extraProps
1616
2283
  });
@@ -1760,11 +2427,13 @@ class MigrationsApi {
1760
2427
  region,
1761
2428
  database,
1762
2429
  branch,
1763
- schema
2430
+ schema,
2431
+ schemaOperations,
2432
+ branchOperations
1764
2433
  }) {
1765
2434
  return operationsByTag.migrations.compareBranchWithUserSchema({
1766
2435
  pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1767
- body: { schema },
2436
+ body: { schema, schemaOperations, branchOperations },
1768
2437
  ...this.extraProps
1769
2438
  });
1770
2439
  }
@@ -1774,11 +2443,12 @@ class MigrationsApi {
1774
2443
  database,
1775
2444
  branch,
1776
2445
  compare,
1777
- schema
2446
+ sourceBranchOperations,
2447
+ targetBranchOperations
1778
2448
  }) {
1779
2449
  return operationsByTag.migrations.compareBranchSchemas({
1780
2450
  pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
1781
- body: { schema },
2451
+ body: { sourceBranchOperations, targetBranchOperations },
1782
2452
  ...this.extraProps
1783
2453
  });
1784
2454
  }
@@ -1821,6 +2491,19 @@ class MigrationsApi {
1821
2491
  ...this.extraProps
1822
2492
  });
1823
2493
  }
2494
+ pushBranchMigrations({
2495
+ workspace,
2496
+ region,
2497
+ database,
2498
+ branch,
2499
+ migrations
2500
+ }) {
2501
+ return operationsByTag.migrations.pushBranchMigrations({
2502
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2503
+ body: { migrations },
2504
+ ...this.extraProps
2505
+ });
2506
+ }
1824
2507
  }
1825
2508
  class DatabaseApi {
1826
2509
  constructor(extraProps) {
@@ -1835,11 +2518,13 @@ class DatabaseApi {
1835
2518
  createDatabase({
1836
2519
  workspace,
1837
2520
  database,
1838
- data
2521
+ data,
2522
+ headers
1839
2523
  }) {
1840
2524
  return operationsByTag.databases.createDatabase({
1841
2525
  pathParams: { workspaceId: workspace, dbName: database },
1842
2526
  body: data,
2527
+ headers,
1843
2528
  ...this.extraProps
1844
2529
  });
1845
2530
  }
@@ -1872,6 +2557,46 @@ class DatabaseApi {
1872
2557
  ...this.extraProps
1873
2558
  });
1874
2559
  }
2560
+ renameDatabase({
2561
+ workspace,
2562
+ database,
2563
+ newName
2564
+ }) {
2565
+ return operationsByTag.databases.renameDatabase({
2566
+ pathParams: { workspaceId: workspace, dbName: database },
2567
+ body: { newName },
2568
+ ...this.extraProps
2569
+ });
2570
+ }
2571
+ getDatabaseGithubSettings({
2572
+ workspace,
2573
+ database
2574
+ }) {
2575
+ return operationsByTag.databases.getDatabaseGithubSettings({
2576
+ pathParams: { workspaceId: workspace, dbName: database },
2577
+ ...this.extraProps
2578
+ });
2579
+ }
2580
+ updateDatabaseGithubSettings({
2581
+ workspace,
2582
+ database,
2583
+ settings
2584
+ }) {
2585
+ return operationsByTag.databases.updateDatabaseGithubSettings({
2586
+ pathParams: { workspaceId: workspace, dbName: database },
2587
+ body: settings,
2588
+ ...this.extraProps
2589
+ });
2590
+ }
2591
+ deleteDatabaseGithubSettings({
2592
+ workspace,
2593
+ database
2594
+ }) {
2595
+ return operationsByTag.databases.deleteDatabaseGithubSettings({
2596
+ pathParams: { workspaceId: workspace, dbName: database },
2597
+ ...this.extraProps
2598
+ });
2599
+ }
1875
2600
  listRegions({ workspace }) {
1876
2601
  return operationsByTag.databases.listRegions({
1877
2602
  pathParams: { workspaceId: workspace },
@@ -1881,22 +2606,319 @@ class DatabaseApi {
1881
2606
  }
1882
2607
 
1883
2608
  class XataApiPlugin {
1884
- async build(options) {
1885
- const { fetchImpl, apiKey } = await options.getFetchProps();
1886
- return new XataApiClient({ fetch: fetchImpl, apiKey });
2609
+ build(options) {
2610
+ return new XataApiClient(options);
1887
2611
  }
1888
2612
  }
1889
2613
 
1890
2614
  class XataPlugin {
1891
2615
  }
1892
2616
 
2617
+ class FilesPlugin extends XataPlugin {
2618
+ build(pluginOptions) {
2619
+ return {
2620
+ download: async (location) => {
2621
+ const { table, record, column, fileId = "" } = location ?? {};
2622
+ return await getFileItem({
2623
+ pathParams: {
2624
+ workspace: "{workspaceId}",
2625
+ dbBranchName: "{dbBranch}",
2626
+ region: "{region}",
2627
+ tableName: table ?? "",
2628
+ recordId: record ?? "",
2629
+ columnName: column ?? "",
2630
+ fileId
2631
+ },
2632
+ ...pluginOptions,
2633
+ rawResponse: true
2634
+ });
2635
+ },
2636
+ upload: async (location, file) => {
2637
+ const { table, record, column, fileId = "" } = location ?? {};
2638
+ const contentType = getContentType(file);
2639
+ return await putFileItem({
2640
+ ...pluginOptions,
2641
+ pathParams: {
2642
+ workspace: "{workspaceId}",
2643
+ dbBranchName: "{dbBranch}",
2644
+ region: "{region}",
2645
+ tableName: table ?? "",
2646
+ recordId: record ?? "",
2647
+ columnName: column ?? "",
2648
+ fileId
2649
+ },
2650
+ body: file,
2651
+ headers: { "Content-Type": contentType }
2652
+ });
2653
+ },
2654
+ delete: async (location) => {
2655
+ const { table, record, column, fileId = "" } = location ?? {};
2656
+ return await deleteFileItem({
2657
+ pathParams: {
2658
+ workspace: "{workspaceId}",
2659
+ dbBranchName: "{dbBranch}",
2660
+ region: "{region}",
2661
+ tableName: table ?? "",
2662
+ recordId: record ?? "",
2663
+ columnName: column ?? "",
2664
+ fileId
2665
+ },
2666
+ ...pluginOptions
2667
+ });
2668
+ }
2669
+ };
2670
+ }
2671
+ }
2672
+ function getContentType(file) {
2673
+ if (typeof file === "string") {
2674
+ return "text/plain";
2675
+ }
2676
+ if (file instanceof Blob) {
2677
+ return file.type;
2678
+ }
2679
+ try {
2680
+ return file.type;
2681
+ } catch (e) {
2682
+ }
2683
+ return "application/octet-stream";
2684
+ }
2685
+
2686
+ function buildTransformString(transformations) {
2687
+ return transformations.flatMap(
2688
+ (t) => Object.entries(t).map(([key, value]) => {
2689
+ if (key === "trim") {
2690
+ const { left = 0, top = 0, right = 0, bottom = 0 } = value;
2691
+ return `${key}=${[top, right, bottom, left].join(";")}`;
2692
+ }
2693
+ if (key === "gravity" && typeof value === "object") {
2694
+ const { x = 0.5, y = 0.5 } = value;
2695
+ return `${key}=${[x, y].join("x")}`;
2696
+ }
2697
+ return `${key}=${value}`;
2698
+ })
2699
+ ).join(",");
2700
+ }
2701
+ function transformImage(url, ...transformations) {
2702
+ if (!isDefined(url))
2703
+ return void 0;
2704
+ const newTransformations = buildTransformString(transformations);
2705
+ const { hostname, pathname, search } = new URL(url);
2706
+ const pathParts = pathname.split("/");
2707
+ const transformIndex = pathParts.findIndex((part) => part === "transform");
2708
+ const removedItems = transformIndex >= 0 ? pathParts.splice(transformIndex, 2) : [];
2709
+ const transform = `/transform/${[removedItems[1], newTransformations].filter(isDefined).join(",")}`;
2710
+ const path = pathParts.join("/");
2711
+ return `https://${hostname}${transform}${path}${search}`;
2712
+ }
2713
+
2714
+ var __defProp$6 = Object.defineProperty;
2715
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2716
+ var __publicField$6 = (obj, key, value) => {
2717
+ __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
2718
+ return value;
2719
+ };
2720
+ class XataFile {
2721
+ constructor(file) {
2722
+ /**
2723
+ * Identifier of the file.
2724
+ */
2725
+ __publicField$6(this, "id");
2726
+ /**
2727
+ * Name of the file.
2728
+ */
2729
+ __publicField$6(this, "name");
2730
+ /**
2731
+ * Media type of the file.
2732
+ */
2733
+ __publicField$6(this, "mediaType");
2734
+ /**
2735
+ * Base64 encoded content of the file.
2736
+ */
2737
+ __publicField$6(this, "base64Content");
2738
+ /**
2739
+ * Whether to enable public url for the file.
2740
+ */
2741
+ __publicField$6(this, "enablePublicUrl");
2742
+ /**
2743
+ * Timeout for the signed url.
2744
+ */
2745
+ __publicField$6(this, "signedUrlTimeout");
2746
+ /**
2747
+ * Size of the file.
2748
+ */
2749
+ __publicField$6(this, "size");
2750
+ /**
2751
+ * Version of the file.
2752
+ */
2753
+ __publicField$6(this, "version");
2754
+ /**
2755
+ * Url of the file.
2756
+ */
2757
+ __publicField$6(this, "url");
2758
+ /**
2759
+ * Signed url of the file.
2760
+ */
2761
+ __publicField$6(this, "signedUrl");
2762
+ /**
2763
+ * Attributes of the file.
2764
+ */
2765
+ __publicField$6(this, "attributes");
2766
+ this.id = file.id;
2767
+ this.name = file.name || "";
2768
+ this.mediaType = file.mediaType || "application/octet-stream";
2769
+ this.base64Content = file.base64Content;
2770
+ this.enablePublicUrl = file.enablePublicUrl ?? false;
2771
+ this.signedUrlTimeout = file.signedUrlTimeout ?? 300;
2772
+ this.size = file.size ?? 0;
2773
+ this.version = file.version ?? 1;
2774
+ this.url = file.url || "";
2775
+ this.signedUrl = file.signedUrl;
2776
+ this.attributes = file.attributes || {};
2777
+ }
2778
+ static fromBuffer(buffer, options = {}) {
2779
+ const base64Content = buffer.toString("base64");
2780
+ return new XataFile({ ...options, base64Content });
2781
+ }
2782
+ toBuffer() {
2783
+ if (!this.base64Content) {
2784
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2785
+ }
2786
+ return Buffer.from(this.base64Content, "base64");
2787
+ }
2788
+ static fromArrayBuffer(arrayBuffer, options = {}) {
2789
+ const uint8Array = new Uint8Array(arrayBuffer);
2790
+ return this.fromUint8Array(uint8Array, options);
2791
+ }
2792
+ toArrayBuffer() {
2793
+ if (!this.base64Content) {
2794
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2795
+ }
2796
+ const binary = atob(this.base64Content);
2797
+ return new ArrayBuffer(binary.length);
2798
+ }
2799
+ static fromUint8Array(uint8Array, options = {}) {
2800
+ let binary = "";
2801
+ for (let i = 0; i < uint8Array.byteLength; i++) {
2802
+ binary += String.fromCharCode(uint8Array[i]);
2803
+ }
2804
+ const base64Content = btoa(binary);
2805
+ return new XataFile({ ...options, base64Content });
2806
+ }
2807
+ toUint8Array() {
2808
+ if (!this.base64Content) {
2809
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2810
+ }
2811
+ const binary = atob(this.base64Content);
2812
+ const uint8Array = new Uint8Array(binary.length);
2813
+ for (let i = 0; i < binary.length; i++) {
2814
+ uint8Array[i] = binary.charCodeAt(i);
2815
+ }
2816
+ return uint8Array;
2817
+ }
2818
+ static async fromBlob(file, options = {}) {
2819
+ const name = options.name ?? file.name;
2820
+ const mediaType = file.type;
2821
+ const arrayBuffer = await file.arrayBuffer();
2822
+ return this.fromArrayBuffer(arrayBuffer, { ...options, name, mediaType });
2823
+ }
2824
+ toBlob() {
2825
+ if (!this.base64Content) {
2826
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2827
+ }
2828
+ const binary = atob(this.base64Content);
2829
+ const uint8Array = new Uint8Array(binary.length);
2830
+ for (let i = 0; i < binary.length; i++) {
2831
+ uint8Array[i] = binary.charCodeAt(i);
2832
+ }
2833
+ return new Blob([uint8Array], { type: this.mediaType });
2834
+ }
2835
+ static fromString(string, options = {}) {
2836
+ const base64Content = btoa(string);
2837
+ return new XataFile({ ...options, base64Content });
2838
+ }
2839
+ toString() {
2840
+ if (!this.base64Content) {
2841
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2842
+ }
2843
+ return atob(this.base64Content);
2844
+ }
2845
+ static fromBase64(base64Content, options = {}) {
2846
+ return new XataFile({ ...options, base64Content });
2847
+ }
2848
+ toBase64() {
2849
+ if (!this.base64Content) {
2850
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2851
+ }
2852
+ return this.base64Content;
2853
+ }
2854
+ transform(...options) {
2855
+ return {
2856
+ url: transformImage(this.url, ...options),
2857
+ signedUrl: transformImage(this.signedUrl, ...options),
2858
+ metadataUrl: transformImage(this.url, ...options, { format: "json" }),
2859
+ metadataSignedUrl: transformImage(this.signedUrl, ...options, { format: "json" })
2860
+ };
2861
+ }
2862
+ }
2863
+ const parseInputFileEntry = async (entry) => {
2864
+ if (!isDefined(entry))
2865
+ return null;
2866
+ const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
2867
+ return compactObject({ id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout });
2868
+ };
2869
+
1893
2870
  function cleanFilter(filter) {
1894
- if (!filter)
2871
+ if (!isDefined(filter))
1895
2872
  return void 0;
1896
- const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
1897
- return values.length > 0 ? filter : void 0;
2873
+ if (!isObject(filter))
2874
+ return filter;
2875
+ const values = Object.fromEntries(
2876
+ Object.entries(filter).reduce((acc, [key, value]) => {
2877
+ if (!isDefined(value))
2878
+ return acc;
2879
+ if (Array.isArray(value)) {
2880
+ const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
2881
+ if (clean.length === 0)
2882
+ return acc;
2883
+ return [...acc, [key, clean]];
2884
+ }
2885
+ if (isObject(value)) {
2886
+ const clean = cleanFilter(value);
2887
+ if (!isDefined(clean))
2888
+ return acc;
2889
+ return [...acc, [key, clean]];
2890
+ }
2891
+ return [...acc, [key, value]];
2892
+ }, [])
2893
+ );
2894
+ return Object.keys(values).length > 0 ? values : void 0;
2895
+ }
2896
+
2897
+ function stringifyJson(value) {
2898
+ if (!isDefined(value))
2899
+ return value;
2900
+ if (isString(value))
2901
+ return value;
2902
+ try {
2903
+ return JSON.stringify(value);
2904
+ } catch (e) {
2905
+ return value;
2906
+ }
2907
+ }
2908
+ function parseJson(value) {
2909
+ try {
2910
+ return JSON.parse(value);
2911
+ } catch (e) {
2912
+ return value;
2913
+ }
1898
2914
  }
1899
2915
 
2916
+ var __defProp$5 = Object.defineProperty;
2917
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2918
+ var __publicField$5 = (obj, key, value) => {
2919
+ __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
2920
+ return value;
2921
+ };
1900
2922
  var __accessCheck$6 = (obj, member, msg) => {
1901
2923
  if (!member.has(obj))
1902
2924
  throw TypeError("Cannot " + msg);
@@ -1919,22 +2941,58 @@ var _query, _page;
1919
2941
  class Page {
1920
2942
  constructor(query, meta, records = []) {
1921
2943
  __privateAdd$6(this, _query, void 0);
2944
+ /**
2945
+ * Page metadata, required to retrieve additional records.
2946
+ */
2947
+ __publicField$5(this, "meta");
2948
+ /**
2949
+ * The set of results for this page.
2950
+ */
2951
+ __publicField$5(this, "records");
1922
2952
  __privateSet$6(this, _query, query);
1923
2953
  this.meta = meta;
1924
2954
  this.records = new RecordArray(this, records);
1925
2955
  }
2956
+ /**
2957
+ * Retrieves the next page of results.
2958
+ * @param size Maximum number of results to be retrieved.
2959
+ * @param offset Number of results to skip when retrieving the results.
2960
+ * @returns The next page or results.
2961
+ */
1926
2962
  async nextPage(size, offset) {
1927
2963
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
1928
2964
  }
2965
+ /**
2966
+ * Retrieves the previous page of results.
2967
+ * @param size Maximum number of results to be retrieved.
2968
+ * @param offset Number of results to skip when retrieving the results.
2969
+ * @returns The previous page or results.
2970
+ */
1929
2971
  async previousPage(size, offset) {
1930
2972
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
1931
2973
  }
2974
+ /**
2975
+ * Retrieves the start page of results.
2976
+ * @param size Maximum number of results to be retrieved.
2977
+ * @param offset Number of results to skip when retrieving the results.
2978
+ * @returns The start page or results.
2979
+ */
1932
2980
  async startPage(size, offset) {
1933
2981
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
1934
2982
  }
2983
+ /**
2984
+ * Retrieves the end page of results.
2985
+ * @param size Maximum number of results to be retrieved.
2986
+ * @param offset Number of results to skip when retrieving the results.
2987
+ * @returns The end page or results.
2988
+ */
1935
2989
  async endPage(size, offset) {
1936
2990
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
1937
2991
  }
2992
+ /**
2993
+ * Shortcut method to check if there will be additional results if the next page of results is retrieved.
2994
+ * @returns Whether or not there will be additional results in the next page of results.
2995
+ */
1938
2996
  hasNextPage() {
1939
2997
  return this.meta.page.more;
1940
2998
  }
@@ -1947,7 +3005,7 @@ const PAGINATION_DEFAULT_OFFSET = 0;
1947
3005
  function isCursorPaginationOptions(options) {
1948
3006
  return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
1949
3007
  }
1950
- const _RecordArray = class extends Array {
3008
+ const _RecordArray = class _RecordArray extends Array {
1951
3009
  constructor(...args) {
1952
3010
  super(..._RecordArray.parseConstructorParams(...args));
1953
3011
  __privateAdd$6(this, _page, void 0);
@@ -1975,29 +3033,58 @@ const _RecordArray = class extends Array {
1975
3033
  map(callbackfn, thisArg) {
1976
3034
  return this.toArray().map(callbackfn, thisArg);
1977
3035
  }
3036
+ /**
3037
+ * Retrieve next page of records
3038
+ *
3039
+ * @returns A new array of objects
3040
+ */
1978
3041
  async nextPage(size, offset) {
1979
3042
  const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
1980
3043
  return new _RecordArray(newPage);
1981
3044
  }
3045
+ /**
3046
+ * Retrieve previous page of records
3047
+ *
3048
+ * @returns A new array of objects
3049
+ */
1982
3050
  async previousPage(size, offset) {
1983
3051
  const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
1984
3052
  return new _RecordArray(newPage);
1985
3053
  }
3054
+ /**
3055
+ * Retrieve start page of records
3056
+ *
3057
+ * @returns A new array of objects
3058
+ */
1986
3059
  async startPage(size, offset) {
1987
3060
  const newPage = await __privateGet$6(this, _page).startPage(size, offset);
1988
3061
  return new _RecordArray(newPage);
1989
3062
  }
3063
+ /**
3064
+ * Retrieve end page of records
3065
+ *
3066
+ * @returns A new array of objects
3067
+ */
1990
3068
  async endPage(size, offset) {
1991
3069
  const newPage = await __privateGet$6(this, _page).endPage(size, offset);
1992
3070
  return new _RecordArray(newPage);
1993
3071
  }
3072
+ /**
3073
+ * @returns Boolean indicating if there is a next page
3074
+ */
1994
3075
  hasNextPage() {
1995
3076
  return __privateGet$6(this, _page).meta.page.more;
1996
3077
  }
1997
3078
  };
1998
- let RecordArray = _RecordArray;
1999
3079
  _page = new WeakMap();
3080
+ let RecordArray = _RecordArray;
2000
3081
 
3082
+ var __defProp$4 = Object.defineProperty;
3083
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3084
+ var __publicField$4 = (obj, key, value) => {
3085
+ __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
3086
+ return value;
3087
+ };
2001
3088
  var __accessCheck$5 = (obj, member, msg) => {
2002
3089
  if (!member.has(obj))
2003
3090
  throw TypeError("Cannot " + msg);
@@ -2021,14 +3108,15 @@ var __privateMethod$3 = (obj, member, method) => {
2021
3108
  return method;
2022
3109
  };
2023
3110
  var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
2024
- const _Query = class {
3111
+ const _Query = class _Query {
2025
3112
  constructor(repository, table, data, rawParent) {
2026
3113
  __privateAdd$5(this, _cleanFilterConstraint);
2027
3114
  __privateAdd$5(this, _table$1, void 0);
2028
3115
  __privateAdd$5(this, _repository, void 0);
2029
3116
  __privateAdd$5(this, _data, { filter: {} });
2030
- this.meta = { page: { cursor: "start", more: true } };
2031
- this.records = new RecordArray(this, []);
3117
+ // Implements pagination
3118
+ __publicField$4(this, "meta", { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } });
3119
+ __publicField$4(this, "records", new RecordArray(this, []));
2032
3120
  __privateSet$5(this, _table$1, table);
2033
3121
  if (repository) {
2034
3122
  __privateSet$5(this, _repository, repository);
@@ -2064,18 +3152,38 @@ const _Query = class {
2064
3152
  const key = JSON.stringify({ columns, filter, sort, pagination });
2065
3153
  return toBase64(key);
2066
3154
  }
3155
+ /**
3156
+ * Builds a new query object representing a logical OR between the given subqueries.
3157
+ * @param queries An array of subqueries.
3158
+ * @returns A new Query object.
3159
+ */
2067
3160
  any(...queries) {
2068
3161
  const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
2069
3162
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
2070
3163
  }
3164
+ /**
3165
+ * Builds a new query object representing a logical AND between the given subqueries.
3166
+ * @param queries An array of subqueries.
3167
+ * @returns A new Query object.
3168
+ */
2071
3169
  all(...queries) {
2072
3170
  const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
2073
3171
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
2074
3172
  }
3173
+ /**
3174
+ * Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
3175
+ * @param queries An array of subqueries.
3176
+ * @returns A new Query object.
3177
+ */
2075
3178
  not(...queries) {
2076
3179
  const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
2077
3180
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
2078
3181
  }
3182
+ /**
3183
+ * Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
3184
+ * @param queries An array of subqueries.
3185
+ * @returns A new Query object.
3186
+ */
2079
3187
  none(...queries) {
2080
3188
  const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
2081
3189
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
@@ -2098,6 +3206,11 @@ const _Query = class {
2098
3206
  const sort = [...originalSort, { column, direction }];
2099
3207
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
2100
3208
  }
3209
+ /**
3210
+ * Builds a new query specifying the set of columns to be returned in the query response.
3211
+ * @param columns Array of column names to be returned by the query.
3212
+ * @returns A new Query object.
3213
+ */
2101
3214
  select(columns) {
2102
3215
  return new _Query(
2103
3216
  __privateGet$5(this, _repository),
@@ -2110,6 +3223,12 @@ const _Query = class {
2110
3223
  const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
2111
3224
  return __privateGet$5(this, _repository).query(query);
2112
3225
  }
3226
+ /**
3227
+ * Get results in an iterator
3228
+ *
3229
+ * @async
3230
+ * @returns Async interable of results
3231
+ */
2113
3232
  async *[Symbol.asyncIterator]() {
2114
3233
  for await (const [record] of this.getIterator({ batchSize: 1 })) {
2115
3234
  yield record;
@@ -2170,26 +3289,53 @@ const _Query = class {
2170
3289
  );
2171
3290
  return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
2172
3291
  }
3292
+ /**
3293
+ * Builds a new query object adding a cache TTL in milliseconds.
3294
+ * @param ttl The cache TTL in milliseconds.
3295
+ * @returns A new Query object.
3296
+ */
2173
3297
  cache(ttl) {
2174
3298
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
2175
3299
  }
3300
+ /**
3301
+ * Retrieve next page of records
3302
+ *
3303
+ * @returns A new page object.
3304
+ */
2176
3305
  nextPage(size, offset) {
2177
3306
  return this.startPage(size, offset);
2178
3307
  }
3308
+ /**
3309
+ * Retrieve previous page of records
3310
+ *
3311
+ * @returns A new page object
3312
+ */
2179
3313
  previousPage(size, offset) {
2180
3314
  return this.startPage(size, offset);
2181
3315
  }
3316
+ /**
3317
+ * Retrieve start page of records
3318
+ *
3319
+ * @returns A new page object
3320
+ */
2182
3321
  startPage(size, offset) {
2183
3322
  return this.getPaginated({ pagination: { size, offset } });
2184
3323
  }
3324
+ /**
3325
+ * Retrieve last page of records
3326
+ *
3327
+ * @returns A new page object
3328
+ */
2185
3329
  endPage(size, offset) {
2186
3330
  return this.getPaginated({ pagination: { size, offset, before: "end" } });
2187
3331
  }
3332
+ /**
3333
+ * @returns Boolean indicating if there is a next page
3334
+ */
2188
3335
  hasNextPage() {
2189
3336
  return this.meta.page.more;
2190
3337
  }
2191
3338
  };
2192
- let Query = _Query;
2193
3339
  _table$1 = new WeakMap();
2194
3340
  _repository = new WeakMap();
2195
3341
  _data = new WeakMap();
@@ -2204,6 +3350,7 @@ cleanFilterConstraint_fn = function(column, value) {
2204
3350
  }
2205
3351
  return value;
2206
3352
  };
3353
+ let Query = _Query;
2207
3354
  function cleanParent(data, parent) {
2208
3355
  if (isCursorPaginationOptions(data.pagination)) {
2209
3356
  return { ...parent, sort: void 0, filter: void 0 };
@@ -2211,6 +3358,22 @@ function cleanParent(data, parent) {
2211
3358
  return parent;
2212
3359
  }
2213
3360
 
3361
+ const RecordColumnTypes = [
3362
+ "bool",
3363
+ "int",
3364
+ "float",
3365
+ "string",
3366
+ "text",
3367
+ "email",
3368
+ "multiple",
3369
+ "link",
3370
+ "object",
3371
+ "datetime",
3372
+ "vector",
3373
+ "file[]",
3374
+ "file",
3375
+ "json"
3376
+ ];
2214
3377
  function isIdentifiable(x) {
2215
3378
  return isObject(x) && isString(x?.id);
2216
3379
  }
@@ -2220,11 +3383,33 @@ function isXataRecord(x) {
2220
3383
  return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
2221
3384
  }
2222
3385
 
3386
+ function isValidExpandedColumn(column) {
3387
+ return isObject(column) && isString(column.name);
3388
+ }
3389
+ function isValidSelectableColumns(columns) {
3390
+ if (!Array.isArray(columns)) {
3391
+ return false;
3392
+ }
3393
+ return columns.every((column) => {
3394
+ if (typeof column === "string") {
3395
+ return true;
3396
+ }
3397
+ if (typeof column === "object") {
3398
+ return isValidExpandedColumn(column);
3399
+ }
3400
+ return false;
3401
+ });
3402
+ }
3403
+
2223
3404
  function isSortFilterString(value) {
2224
3405
  return isString(value);
2225
3406
  }
2226
3407
  function isSortFilterBase(filter) {
2227
- return isObject(filter) && Object.values(filter).every((value) => value === "asc" || value === "desc");
3408
+ return isObject(filter) && Object.entries(filter).every(([key, value]) => {
3409
+ if (key === "*")
3410
+ return value === "random";
3411
+ return value === "asc" || value === "desc";
3412
+ });
2228
3413
  }
2229
3414
  function isSortFilterObject(filter) {
2230
3415
  return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
@@ -2265,7 +3450,7 @@ var __privateMethod$2 = (obj, member, method) => {
2265
3450
  __accessCheck$4(obj, member, "access private method");
2266
3451
  return method;
2267
3452
  };
2268
- 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;
3453
+ 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;
2269
3454
  const BULK_OPERATION_MAX_SIZE = 1e3;
2270
3455
  class Repository extends Query {
2271
3456
  }
@@ -2287,6 +3472,7 @@ class RestRepository extends Query {
2287
3472
  __privateAdd$4(this, _setCacheQuery);
2288
3473
  __privateAdd$4(this, _getCacheQuery);
2289
3474
  __privateAdd$4(this, _getSchemaTables$1);
3475
+ __privateAdd$4(this, _transformObjectToApi);
2290
3476
  __privateAdd$4(this, _table, void 0);
2291
3477
  __privateAdd$4(this, _getFetchProps, void 0);
2292
3478
  __privateAdd$4(this, _db, void 0);
@@ -2297,10 +3483,7 @@ class RestRepository extends Query {
2297
3483
  __privateSet$4(this, _db, options.db);
2298
3484
  __privateSet$4(this, _cache, options.pluginOptions.cache);
2299
3485
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
2300
- __privateSet$4(this, _getFetchProps, async () => {
2301
- const props = await options.pluginOptions.getFetchProps();
2302
- return { ...props, sessionID: generateUUID() };
2303
- });
3486
+ __privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
2304
3487
  const trace = options.pluginOptions.trace ?? defaultTrace;
2305
3488
  __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
2306
3489
  return trace(name, fn, {
@@ -2318,24 +3501,24 @@ class RestRepository extends Query {
2318
3501
  if (a.length === 0)
2319
3502
  return [];
2320
3503
  const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
2321
- const columns = isStringArray(b) ? b : ["*"];
3504
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2322
3505
  const result = await this.read(ids, columns);
2323
3506
  return result;
2324
3507
  }
2325
3508
  if (isString(a) && isObject(b)) {
2326
3509
  if (a === "")
2327
3510
  throw new Error("The id can't be empty");
2328
- const columns = isStringArray(c) ? c : void 0;
3511
+ const columns = isValidSelectableColumns(c) ? c : void 0;
2329
3512
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
2330
3513
  }
2331
3514
  if (isObject(a) && isString(a.id)) {
2332
3515
  if (a.id === "")
2333
3516
  throw new Error("The id can't be empty");
2334
- const columns = isStringArray(b) ? b : void 0;
3517
+ const columns = isValidSelectableColumns(b) ? b : void 0;
2335
3518
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
2336
3519
  }
2337
3520
  if (isObject(a)) {
2338
- const columns = isStringArray(b) ? b : void 0;
3521
+ const columns = isValidSelectableColumns(b) ? b : void 0;
2339
3522
  return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
2340
3523
  }
2341
3524
  throw new Error("Invalid arguments for create method");
@@ -2343,7 +3526,7 @@ class RestRepository extends Query {
2343
3526
  }
2344
3527
  async read(a, b) {
2345
3528
  return __privateGet$4(this, _trace).call(this, "read", async () => {
2346
- const columns = isStringArray(b) ? b : ["*"];
3529
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2347
3530
  if (Array.isArray(a)) {
2348
3531
  if (a.length === 0)
2349
3532
  return [];
@@ -2357,7 +3540,6 @@ class RestRepository extends Query {
2357
3540
  }
2358
3541
  const id = extractId(a);
2359
3542
  if (id) {
2360
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2361
3543
  try {
2362
3544
  const response = await getRecord({
2363
3545
  pathParams: {
@@ -2368,10 +3550,16 @@ class RestRepository extends Query {
2368
3550
  recordId: id
2369
3551
  },
2370
3552
  queryParams: { columns },
2371
- ...fetchProps
3553
+ ...__privateGet$4(this, _getFetchProps).call(this)
2372
3554
  });
2373
3555
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2374
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
3556
+ return initObject(
3557
+ __privateGet$4(this, _db),
3558
+ schemaTables,
3559
+ __privateGet$4(this, _table),
3560
+ response,
3561
+ columns
3562
+ );
2375
3563
  } catch (e) {
2376
3564
  if (isObject(e) && e.status === 404) {
2377
3565
  return null;
@@ -2413,17 +3601,17 @@ class RestRepository extends Query {
2413
3601
  ifVersion,
2414
3602
  upsert: false
2415
3603
  });
2416
- const columns = isStringArray(b) ? b : ["*"];
3604
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2417
3605
  const result = await this.read(a, columns);
2418
3606
  return result;
2419
3607
  }
2420
3608
  try {
2421
3609
  if (isString(a) && isObject(b)) {
2422
- const columns = isStringArray(c) ? c : void 0;
3610
+ const columns = isValidSelectableColumns(c) ? c : void 0;
2423
3611
  return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2424
3612
  }
2425
3613
  if (isObject(a) && isString(a.id)) {
2426
- const columns = isStringArray(b) ? b : void 0;
3614
+ const columns = isValidSelectableColumns(b) ? b : void 0;
2427
3615
  return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2428
3616
  }
2429
3617
  } catch (error) {
@@ -2463,17 +3651,27 @@ class RestRepository extends Query {
2463
3651
  ifVersion,
2464
3652
  upsert: true
2465
3653
  });
2466
- const columns = isStringArray(b) ? b : ["*"];
3654
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2467
3655
  const result = await this.read(a, columns);
2468
3656
  return result;
2469
3657
  }
2470
3658
  if (isString(a) && isObject(b)) {
2471
- const columns = isStringArray(c) ? c : void 0;
2472
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
3659
+ if (a === "")
3660
+ throw new Error("The id can't be empty");
3661
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3662
+ return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2473
3663
  }
2474
3664
  if (isObject(a) && isString(a.id)) {
2475
- const columns = isStringArray(c) ? c : void 0;
2476
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3665
+ if (a.id === "")
3666
+ throw new Error("The id can't be empty");
3667
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3668
+ return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3669
+ }
3670
+ if (!isDefined(a) && isObject(b)) {
3671
+ return await this.create(b, c);
3672
+ }
3673
+ if (isObject(a) && !isDefined(a.id)) {
3674
+ return await this.create(a, b);
2477
3675
  }
2478
3676
  throw new Error("Invalid arguments for createOrUpdate method");
2479
3677
  });
@@ -2485,17 +3683,27 @@ class RestRepository extends Query {
2485
3683
  if (a.length === 0)
2486
3684
  return [];
2487
3685
  const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
2488
- const columns = isStringArray(b) ? b : ["*"];
3686
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2489
3687
  const result = await this.read(ids, columns);
2490
3688
  return result;
2491
3689
  }
2492
3690
  if (isString(a) && isObject(b)) {
2493
- const columns = isStringArray(c) ? c : void 0;
2494
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
3691
+ if (a === "")
3692
+ throw new Error("The id can't be empty");
3693
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3694
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
2495
3695
  }
2496
3696
  if (isObject(a) && isString(a.id)) {
2497
- const columns = isStringArray(c) ? c : void 0;
2498
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
3697
+ if (a.id === "")
3698
+ throw new Error("The id can't be empty");
3699
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3700
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
3701
+ }
3702
+ if (!isDefined(a) && isObject(b)) {
3703
+ return await this.create(b, c);
3704
+ }
3705
+ if (isObject(a) && !isDefined(a.id)) {
3706
+ return await this.create(a, b);
2499
3707
  }
2500
3708
  throw new Error("Invalid arguments for createOrReplace method");
2501
3709
  });
@@ -2512,7 +3720,7 @@ class RestRepository extends Query {
2512
3720
  return o.id;
2513
3721
  throw new Error("Invalid arguments for delete method");
2514
3722
  });
2515
- const columns = isStringArray(b) ? b : ["*"];
3723
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2516
3724
  const result = await this.read(a, columns);
2517
3725
  await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
2518
3726
  return result;
@@ -2546,7 +3754,6 @@ class RestRepository extends Query {
2546
3754
  }
2547
3755
  async search(query, options = {}) {
2548
3756
  return __privateGet$4(this, _trace).call(this, "search", async () => {
2549
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2550
3757
  const { records } = await searchTable({
2551
3758
  pathParams: {
2552
3759
  workspace: "{workspaceId}",
@@ -2564,7 +3771,29 @@ class RestRepository extends Query {
2564
3771
  page: options.page,
2565
3772
  target: options.target
2566
3773
  },
2567
- ...fetchProps
3774
+ ...__privateGet$4(this, _getFetchProps).call(this)
3775
+ });
3776
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3777
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3778
+ });
3779
+ }
3780
+ async vectorSearch(column, query, options) {
3781
+ return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
3782
+ const { records } = await vectorSearchTable({
3783
+ pathParams: {
3784
+ workspace: "{workspaceId}",
3785
+ dbBranchName: "{dbBranch}",
3786
+ region: "{region}",
3787
+ tableName: __privateGet$4(this, _table)
3788
+ },
3789
+ body: {
3790
+ column,
3791
+ queryVector: query,
3792
+ similarityFunction: options?.similarityFunction,
3793
+ size: options?.size,
3794
+ filter: options?.filter
3795
+ },
3796
+ ...__privateGet$4(this, _getFetchProps).call(this)
2568
3797
  });
2569
3798
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2570
3799
  return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
@@ -2572,7 +3801,6 @@ class RestRepository extends Query {
2572
3801
  }
2573
3802
  async aggregate(aggs, filter) {
2574
3803
  return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
2575
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2576
3804
  const result = await aggregateTable({
2577
3805
  pathParams: {
2578
3806
  workspace: "{workspaceId}",
@@ -2581,7 +3809,7 @@ class RestRepository extends Query {
2581
3809
  tableName: __privateGet$4(this, _table)
2582
3810
  },
2583
3811
  body: { aggs, filter },
2584
- ...fetchProps
3812
+ ...__privateGet$4(this, _getFetchProps).call(this)
2585
3813
  });
2586
3814
  return result;
2587
3815
  });
@@ -2592,7 +3820,6 @@ class RestRepository extends Query {
2592
3820
  if (cacheQuery)
2593
3821
  return new Page(query, cacheQuery.meta, cacheQuery.records);
2594
3822
  const data = query.getQueryOptions();
2595
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2596
3823
  const { meta, records: objects } = await queryTable({
2597
3824
  pathParams: {
2598
3825
  workspace: "{workspaceId}",
@@ -2608,11 +3835,17 @@ class RestRepository extends Query {
2608
3835
  consistency: data.consistency
2609
3836
  },
2610
3837
  fetchOptions: data.fetchOptions,
2611
- ...fetchProps
3838
+ ...__privateGet$4(this, _getFetchProps).call(this)
2612
3839
  });
2613
3840
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2614
3841
  const records = objects.map(
2615
- (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
3842
+ (record) => initObject(
3843
+ __privateGet$4(this, _db),
3844
+ schemaTables,
3845
+ __privateGet$4(this, _table),
3846
+ record,
3847
+ data.columns ?? ["*"]
3848
+ )
2616
3849
  );
2617
3850
  await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
2618
3851
  return new Page(query, meta, records);
@@ -2621,7 +3854,6 @@ class RestRepository extends Query {
2621
3854
  async summarizeTable(query, summaries, summariesFilter) {
2622
3855
  return __privateGet$4(this, _trace).call(this, "summarize", async () => {
2623
3856
  const data = query.getQueryOptions();
2624
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2625
3857
  const result = await summarizeTable({
2626
3858
  pathParams: {
2627
3859
  workspace: "{workspaceId}",
@@ -2638,11 +3870,44 @@ class RestRepository extends Query {
2638
3870
  summaries,
2639
3871
  summariesFilter
2640
3872
  },
2641
- ...fetchProps
3873
+ ...__privateGet$4(this, _getFetchProps).call(this)
2642
3874
  });
2643
3875
  return result;
2644
3876
  });
2645
3877
  }
3878
+ ask(question, options) {
3879
+ const questionParam = options?.sessionId ? { message: question } : { question };
3880
+ const params = {
3881
+ pathParams: {
3882
+ workspace: "{workspaceId}",
3883
+ dbBranchName: "{dbBranch}",
3884
+ region: "{region}",
3885
+ tableName: __privateGet$4(this, _table),
3886
+ sessionId: options?.sessionId
3887
+ },
3888
+ body: {
3889
+ ...questionParam,
3890
+ rules: options?.rules,
3891
+ searchType: options?.searchType,
3892
+ search: options?.searchType === "keyword" ? options?.search : void 0,
3893
+ vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
3894
+ },
3895
+ ...__privateGet$4(this, _getFetchProps).call(this)
3896
+ };
3897
+ if (options?.onMessage) {
3898
+ fetchSSERequest({
3899
+ endpoint: "dataPlane",
3900
+ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
3901
+ method: "POST",
3902
+ onMessage: (message) => {
3903
+ options.onMessage?.({ answer: message.text, records: message.records });
3904
+ },
3905
+ ...params
3906
+ });
3907
+ } else {
3908
+ return askTableSession(params);
3909
+ }
3910
+ }
2646
3911
  }
2647
3912
  _table = new WeakMap();
2648
3913
  _getFetchProps = new WeakMap();
@@ -2652,8 +3917,7 @@ _schemaTables$2 = new WeakMap();
2652
3917
  _trace = new WeakMap();
2653
3918
  _insertRecordWithoutId = new WeakSet();
2654
3919
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
2655
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2656
- const record = transformObjectLinks(object);
3920
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
2657
3921
  const response = await insertRecord({
2658
3922
  pathParams: {
2659
3923
  workspace: "{workspaceId}",
@@ -2663,15 +3927,16 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
2663
3927
  },
2664
3928
  queryParams: { columns },
2665
3929
  body: record,
2666
- ...fetchProps
3930
+ ...__privateGet$4(this, _getFetchProps).call(this)
2667
3931
  });
2668
3932
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2669
3933
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2670
3934
  };
2671
3935
  _insertRecordWithId = new WeakSet();
2672
3936
  insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
2673
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2674
- const record = transformObjectLinks(object);
3937
+ if (!recordId)
3938
+ return null;
3939
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
2675
3940
  const response = await insertRecordWithID({
2676
3941
  pathParams: {
2677
3942
  workspace: "{workspaceId}",
@@ -2682,30 +3947,28 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
2682
3947
  },
2683
3948
  body: record,
2684
3949
  queryParams: { createOnly, columns, ifVersion },
2685
- ...fetchProps
3950
+ ...__privateGet$4(this, _getFetchProps).call(this)
2686
3951
  });
2687
3952
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2688
3953
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2689
3954
  };
2690
3955
  _insertRecords = new WeakSet();
2691
3956
  insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
2692
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2693
- const chunkedOperations = chunk(
2694
- objects.map((object) => ({
2695
- insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
2696
- })),
2697
- BULK_OPERATION_MAX_SIZE
2698
- );
3957
+ const operations = await promiseMap(objects, async (object) => {
3958
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3959
+ return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
3960
+ });
3961
+ const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
2699
3962
  const ids = [];
2700
- for (const operations of chunkedOperations) {
3963
+ for (const operations2 of chunkedOperations) {
2701
3964
  const { results } = await branchTransaction({
2702
3965
  pathParams: {
2703
3966
  workspace: "{workspaceId}",
2704
3967
  dbBranchName: "{dbBranch}",
2705
3968
  region: "{region}"
2706
3969
  },
2707
- body: { operations },
2708
- ...fetchProps
3970
+ body: { operations: operations2 },
3971
+ ...__privateGet$4(this, _getFetchProps).call(this)
2709
3972
  });
2710
3973
  for (const result of results) {
2711
3974
  if (result.operation === "insert") {
@@ -2719,8 +3982,9 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
2719
3982
  };
2720
3983
  _updateRecordWithID = new WeakSet();
2721
3984
  updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
2722
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2723
- const { id: _id, ...record } = transformObjectLinks(object);
3985
+ if (!recordId)
3986
+ return null;
3987
+ const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
2724
3988
  try {
2725
3989
  const response = await updateRecordWithID({
2726
3990
  pathParams: {
@@ -2732,7 +3996,7 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
2732
3996
  },
2733
3997
  queryParams: { columns, ifVersion },
2734
3998
  body: record,
2735
- ...fetchProps
3999
+ ...__privateGet$4(this, _getFetchProps).call(this)
2736
4000
  });
2737
4001
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2738
4002
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
@@ -2745,23 +4009,21 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
2745
4009
  };
2746
4010
  _updateRecords = new WeakSet();
2747
4011
  updateRecords_fn = async function(objects, { ifVersion, upsert }) {
2748
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2749
- const chunkedOperations = chunk(
2750
- objects.map(({ id, ...object }) => ({
2751
- update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
2752
- })),
2753
- BULK_OPERATION_MAX_SIZE
2754
- );
4012
+ const operations = await promiseMap(objects, async ({ id, ...object }) => {
4013
+ const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
4014
+ return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
4015
+ });
4016
+ const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
2755
4017
  const ids = [];
2756
- for (const operations of chunkedOperations) {
4018
+ for (const operations2 of chunkedOperations) {
2757
4019
  const { results } = await branchTransaction({
2758
4020
  pathParams: {
2759
4021
  workspace: "{workspaceId}",
2760
4022
  dbBranchName: "{dbBranch}",
2761
4023
  region: "{region}"
2762
4024
  },
2763
- body: { operations },
2764
- ...fetchProps
4025
+ body: { operations: operations2 },
4026
+ ...__privateGet$4(this, _getFetchProps).call(this)
2765
4027
  });
2766
4028
  for (const result of results) {
2767
4029
  if (result.operation === "update") {
@@ -2775,7 +4037,8 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
2775
4037
  };
2776
4038
  _upsertRecordWithID = new WeakSet();
2777
4039
  upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
2778
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
4040
+ if (!recordId)
4041
+ return null;
2779
4042
  const response = await upsertRecordWithID({
2780
4043
  pathParams: {
2781
4044
  workspace: "{workspaceId}",
@@ -2786,14 +4049,15 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
2786
4049
  },
2787
4050
  queryParams: { columns, ifVersion },
2788
4051
  body: object,
2789
- ...fetchProps
4052
+ ...__privateGet$4(this, _getFetchProps).call(this)
2790
4053
  });
2791
4054
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2792
4055
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2793
4056
  };
2794
4057
  _deleteRecord = new WeakSet();
2795
4058
  deleteRecord_fn = async function(recordId, columns = ["*"]) {
2796
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
4059
+ if (!recordId)
4060
+ return null;
2797
4061
  try {
2798
4062
  const response = await deleteRecord({
2799
4063
  pathParams: {
@@ -2804,7 +4068,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
2804
4068
  recordId
2805
4069
  },
2806
4070
  queryParams: { columns },
2807
- ...fetchProps
4071
+ ...__privateGet$4(this, _getFetchProps).call(this)
2808
4072
  });
2809
4073
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2810
4074
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
@@ -2817,9 +4081,8 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
2817
4081
  };
2818
4082
  _deleteRecords = new WeakSet();
2819
4083
  deleteRecords_fn = async function(recordIds) {
2820
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2821
4084
  const chunkedOperations = chunk(
2822
- recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
4085
+ compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
2823
4086
  BULK_OPERATION_MAX_SIZE
2824
4087
  );
2825
4088
  for (const operations of chunkedOperations) {
@@ -2830,21 +4093,22 @@ deleteRecords_fn = async function(recordIds) {
2830
4093
  region: "{region}"
2831
4094
  },
2832
4095
  body: { operations },
2833
- ...fetchProps
4096
+ ...__privateGet$4(this, _getFetchProps).call(this)
2834
4097
  });
2835
4098
  }
2836
4099
  };
2837
4100
  _setCacheQuery = new WeakSet();
2838
4101
  setCacheQuery_fn = async function(query, meta, records) {
2839
- await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
4102
+ await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
2840
4103
  };
2841
4104
  _getCacheQuery = new WeakSet();
2842
4105
  getCacheQuery_fn = async function(query) {
2843
4106
  const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
2844
- const result = await __privateGet$4(this, _cache).get(key);
4107
+ const result = await __privateGet$4(this, _cache)?.get(key);
2845
4108
  if (!result)
2846
4109
  return null;
2847
- const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
4110
+ const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
4111
+ const { cache: ttl = defaultTTL } = query.getQueryOptions();
2848
4112
  if (ttl < 0)
2849
4113
  return null;
2850
4114
  const hasExpired = result.date.getTime() + ttl < Date.now();
@@ -2854,15 +4118,49 @@ _getSchemaTables$1 = new WeakSet();
2854
4118
  getSchemaTables_fn$1 = async function() {
2855
4119
  if (__privateGet$4(this, _schemaTables$2))
2856
4120
  return __privateGet$4(this, _schemaTables$2);
2857
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2858
4121
  const { schema } = await getBranchDetails({
2859
4122
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2860
- ...fetchProps
4123
+ ...__privateGet$4(this, _getFetchProps).call(this)
2861
4124
  });
2862
4125
  __privateSet$4(this, _schemaTables$2, schema.tables);
2863
4126
  return schema.tables;
2864
4127
  };
2865
- const transformObjectLinks = (object) => {
4128
+ _transformObjectToApi = new WeakSet();
4129
+ transformObjectToApi_fn = async function(object) {
4130
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
4131
+ const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
4132
+ if (!schema)
4133
+ throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
4134
+ const result = {};
4135
+ for (const [key, value] of Object.entries(object)) {
4136
+ if (key === "xata")
4137
+ continue;
4138
+ const type = schema.columns.find((column) => column.name === key)?.type;
4139
+ switch (type) {
4140
+ case "link": {
4141
+ result[key] = isIdentifiable(value) ? value.id : value;
4142
+ break;
4143
+ }
4144
+ case "datetime": {
4145
+ result[key] = value instanceof Date ? value.toISOString() : value;
4146
+ break;
4147
+ }
4148
+ case `file`:
4149
+ result[key] = await parseInputFileEntry(value);
4150
+ break;
4151
+ case "file[]":
4152
+ result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
4153
+ break;
4154
+ case "json":
4155
+ result[key] = stringifyJson(value);
4156
+ break;
4157
+ default:
4158
+ result[key] = value;
4159
+ }
4160
+ }
4161
+ return result;
4162
+ };
4163
+ const removeLinksFromObject = (object) => {
2866
4164
  return Object.entries(object).reduce((acc, [key, value]) => {
2867
4165
  if (key === "xata")
2868
4166
  return acc;
@@ -2899,18 +4197,33 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2899
4197
  if (item === column.name) {
2900
4198
  return [...acc, "*"];
2901
4199
  }
2902
- if (item.startsWith(`${column.name}.`)) {
4200
+ if (isString(item) && item.startsWith(`${column.name}.`)) {
2903
4201
  const [, ...path] = item.split(".");
2904
4202
  return [...acc, path.join(".")];
2905
4203
  }
2906
4204
  return acc;
2907
4205
  }, []);
2908
- data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
4206
+ data[column.name] = initObject(
4207
+ db,
4208
+ schemaTables,
4209
+ linkTable,
4210
+ value,
4211
+ selectedLinkColumns
4212
+ );
2909
4213
  } else {
2910
4214
  data[column.name] = null;
2911
4215
  }
2912
4216
  break;
2913
4217
  }
4218
+ case "file":
4219
+ data[column.name] = isDefined(value) ? new XataFile(value) : null;
4220
+ break;
4221
+ case "file[]":
4222
+ data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
4223
+ break;
4224
+ case "json":
4225
+ data[column.name] = parseJson(value);
4226
+ break;
2914
4227
  default:
2915
4228
  data[column.name] = value ?? null;
2916
4229
  if (column.notNull === true && value === null) {
@@ -2920,30 +4233,33 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2920
4233
  }
2921
4234
  }
2922
4235
  const record = { ...data };
4236
+ const serializable = { xata, ...removeLinksFromObject(data) };
4237
+ const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
2923
4238
  record.read = function(columns2) {
2924
4239
  return db[table].read(record["id"], columns2);
2925
4240
  };
2926
4241
  record.update = function(data2, b, c) {
2927
- const columns2 = isStringArray(b) ? b : ["*"];
4242
+ const columns2 = isValidSelectableColumns(b) ? b : ["*"];
2928
4243
  const ifVersion = parseIfVersion(b, c);
2929
4244
  return db[table].update(record["id"], data2, columns2, { ifVersion });
2930
4245
  };
2931
4246
  record.replace = function(data2, b, c) {
2932
- const columns2 = isStringArray(b) ? b : ["*"];
4247
+ const columns2 = isValidSelectableColumns(b) ? b : ["*"];
2933
4248
  const ifVersion = parseIfVersion(b, c);
2934
4249
  return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
2935
4250
  };
2936
4251
  record.delete = function() {
2937
4252
  return db[table].delete(record["id"]);
2938
4253
  };
4254
+ record.xata = Object.freeze(metadata);
2939
4255
  record.getMetadata = function() {
2940
- return xata;
4256
+ return record.xata;
2941
4257
  };
2942
4258
  record.toSerializable = function() {
2943
- return JSON.parse(JSON.stringify(transformObjectLinks(data)));
4259
+ return JSON.parse(JSON.stringify(serializable));
2944
4260
  };
2945
4261
  record.toString = function() {
2946
- return JSON.stringify(transformObjectLinks(data));
4262
+ return JSON.stringify(serializable);
2947
4263
  };
2948
4264
  for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
2949
4265
  Object.defineProperty(record, prop, { enumerable: false });
@@ -2961,11 +4277,7 @@ function extractId(value) {
2961
4277
  function isValidColumn(columns, column) {
2962
4278
  if (columns.includes("*"))
2963
4279
  return true;
2964
- if (column.type === "link") {
2965
- const linkColumns = columns.filter((item) => item.startsWith(column.name));
2966
- return linkColumns.length > 0;
2967
- }
2968
- return columns.includes(column.name);
4280
+ return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
2969
4281
  }
2970
4282
  function parseIfVersion(...args) {
2971
4283
  for (const arg of args) {
@@ -2976,6 +4288,12 @@ function parseIfVersion(...args) {
2976
4288
  return void 0;
2977
4289
  }
2978
4290
 
4291
+ var __defProp$3 = Object.defineProperty;
4292
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4293
+ var __publicField$3 = (obj, key, value) => {
4294
+ __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
4295
+ return value;
4296
+ };
2979
4297
  var __accessCheck$3 = (obj, member, msg) => {
2980
4298
  if (!member.has(obj))
2981
4299
  throw TypeError("Cannot " + msg);
@@ -2998,6 +4316,8 @@ var _map;
2998
4316
  class SimpleCache {
2999
4317
  constructor(options = {}) {
3000
4318
  __privateAdd$3(this, _map, void 0);
4319
+ __publicField$3(this, "capacity");
4320
+ __publicField$3(this, "defaultQueryTTL");
3001
4321
  __privateSet$3(this, _map, /* @__PURE__ */ new Map());
3002
4322
  this.capacity = options.max ?? 500;
3003
4323
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
@@ -3133,19 +4453,19 @@ class SearchPlugin extends XataPlugin {
3133
4453
  __privateAdd$1(this, _schemaTables, void 0);
3134
4454
  __privateSet$1(this, _schemaTables, schemaTables);
3135
4455
  }
3136
- build({ getFetchProps }) {
4456
+ build(pluginOptions) {
3137
4457
  return {
3138
4458
  all: async (query, options = {}) => {
3139
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
3140
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
4459
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4460
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
3141
4461
  return records.map((record) => {
3142
4462
  const { table = "orphan" } = record.xata;
3143
4463
  return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
3144
4464
  });
3145
4465
  },
3146
4466
  byTable: async (query, options = {}) => {
3147
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
3148
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
4467
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4468
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
3149
4469
  return records.reduce((acc, record) => {
3150
4470
  const { table = "orphan" } = record.xata;
3151
4471
  const items = acc[table] ?? [];
@@ -3158,38 +4478,108 @@ class SearchPlugin extends XataPlugin {
3158
4478
  }
3159
4479
  _schemaTables = new WeakMap();
3160
4480
  _search = new WeakSet();
3161
- search_fn = async function(query, options, getFetchProps) {
3162
- const fetchProps = await getFetchProps();
4481
+ search_fn = async function(query, options, pluginOptions) {
3163
4482
  const { tables, fuzziness, highlight, prefix, page } = options ?? {};
3164
4483
  const { records } = await searchBranch({
3165
4484
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4485
+ // @ts-ignore https://github.com/xataio/client-ts/issues/313
3166
4486
  body: { tables, query, fuzziness, prefix, highlight, page },
3167
- ...fetchProps
4487
+ ...pluginOptions
3168
4488
  });
3169
4489
  return records;
3170
4490
  };
3171
4491
  _getSchemaTables = new WeakSet();
3172
- getSchemaTables_fn = async function(getFetchProps) {
4492
+ getSchemaTables_fn = async function(pluginOptions) {
3173
4493
  if (__privateGet$1(this, _schemaTables))
3174
4494
  return __privateGet$1(this, _schemaTables);
3175
- const fetchProps = await getFetchProps();
3176
4495
  const { schema } = await getBranchDetails({
3177
4496
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3178
- ...fetchProps
4497
+ ...pluginOptions
3179
4498
  });
3180
4499
  __privateSet$1(this, _schemaTables, schema.tables);
3181
4500
  return schema.tables;
3182
4501
  };
3183
4502
 
4503
+ function escapeElement(elementRepresentation) {
4504
+ const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
4505
+ return '"' + escaped + '"';
4506
+ }
4507
+ function arrayString(val) {
4508
+ let result = "{";
4509
+ for (let i = 0; i < val.length; i++) {
4510
+ if (i > 0) {
4511
+ result = result + ",";
4512
+ }
4513
+ if (val[i] === null || typeof val[i] === "undefined") {
4514
+ result = result + "NULL";
4515
+ } else if (Array.isArray(val[i])) {
4516
+ result = result + arrayString(val[i]);
4517
+ } else if (val[i] instanceof Buffer) {
4518
+ result += "\\\\x" + val[i].toString("hex");
4519
+ } else {
4520
+ result += escapeElement(prepareValue(val[i]));
4521
+ }
4522
+ }
4523
+ result = result + "}";
4524
+ return result;
4525
+ }
4526
+ function prepareValue(value) {
4527
+ if (!isDefined(value))
4528
+ return null;
4529
+ if (value instanceof Date) {
4530
+ return value.toISOString();
4531
+ }
4532
+ if (Array.isArray(value)) {
4533
+ return arrayString(value);
4534
+ }
4535
+ if (isObject(value)) {
4536
+ return JSON.stringify(value);
4537
+ }
4538
+ try {
4539
+ return value.toString();
4540
+ } catch (e) {
4541
+ return value;
4542
+ }
4543
+ }
4544
+ function prepareParams(param1, param2) {
4545
+ if (isString(param1)) {
4546
+ return { statement: param1, params: param2?.map((value) => prepareValue(value)) };
4547
+ }
4548
+ if (isStringArray(param1)) {
4549
+ const statement = param1.reduce((acc, curr, index) => {
4550
+ return acc + curr + (index < (param2?.length ?? 0) ? "$" + (index + 1) : "");
4551
+ }, "");
4552
+ return { statement, params: param2?.map((value) => prepareValue(value)) };
4553
+ }
4554
+ if (isObject(param1)) {
4555
+ const { statement, params, consistency } = param1;
4556
+ return { statement, params: params?.map((value) => prepareValue(value)), consistency };
4557
+ }
4558
+ throw new Error("Invalid query");
4559
+ }
4560
+
4561
+ class SQLPlugin extends XataPlugin {
4562
+ build(pluginOptions) {
4563
+ return async (param1, ...param2) => {
4564
+ const { statement, params, consistency } = prepareParams(param1, param2);
4565
+ const { records, warning } = await sqlQuery({
4566
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4567
+ body: { statement, params, consistency },
4568
+ ...pluginOptions
4569
+ });
4570
+ return { records, warning };
4571
+ };
4572
+ }
4573
+ }
4574
+
3184
4575
  class TransactionPlugin extends XataPlugin {
3185
- build({ getFetchProps }) {
4576
+ build(pluginOptions) {
3186
4577
  return {
3187
4578
  run: async (operations) => {
3188
- const fetchProps = await getFetchProps();
3189
4579
  const response = await branchTransaction({
3190
4580
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3191
4581
  body: { operations },
3192
- ...fetchProps
4582
+ ...pluginOptions
3193
4583
  });
3194
4584
  return response;
3195
4585
  }
@@ -3197,90 +4587,12 @@ class TransactionPlugin extends XataPlugin {
3197
4587
  }
3198
4588
  }
3199
4589
 
3200
- const isBranchStrategyBuilder = (strategy) => {
3201
- return typeof strategy === "function";
4590
+ var __defProp$2 = Object.defineProperty;
4591
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4592
+ var __publicField$2 = (obj, key, value) => {
4593
+ __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
4594
+ return value;
3202
4595
  };
3203
-
3204
- async function getCurrentBranchName(options) {
3205
- const { branch, envBranch } = getEnvironment();
3206
- if (branch)
3207
- return branch;
3208
- const gitBranch = envBranch || await getGitBranch();
3209
- return resolveXataBranch(gitBranch, options);
3210
- }
3211
- async function getCurrentBranchDetails(options) {
3212
- const branch = await getCurrentBranchName(options);
3213
- return getDatabaseBranch(branch, options);
3214
- }
3215
- async function resolveXataBranch(gitBranch, options) {
3216
- const databaseURL = options?.databaseURL || getDatabaseURL();
3217
- const apiKey = options?.apiKey || getAPIKey();
3218
- if (!databaseURL)
3219
- throw new Error(
3220
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
3221
- );
3222
- if (!apiKey)
3223
- throw new Error(
3224
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
3225
- );
3226
- const [protocol, , host, , dbName] = databaseURL.split("/");
3227
- const urlParts = parseWorkspacesUrlParts(host);
3228
- if (!urlParts)
3229
- throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3230
- const { workspace, region } = urlParts;
3231
- const { fallbackBranch } = getEnvironment();
3232
- const { branch } = await resolveBranch({
3233
- apiKey,
3234
- apiUrl: databaseURL,
3235
- fetchImpl: getFetchImplementation(options?.fetchImpl),
3236
- workspacesApiUrl: `${protocol}//${host}`,
3237
- pathParams: { dbName, workspace, region },
3238
- queryParams: { gitBranch, fallbackBranch },
3239
- trace: defaultTrace,
3240
- clientName: options?.clientName
3241
- });
3242
- return branch;
3243
- }
3244
- async function getDatabaseBranch(branch, options) {
3245
- const databaseURL = options?.databaseURL || getDatabaseURL();
3246
- const apiKey = options?.apiKey || getAPIKey();
3247
- if (!databaseURL)
3248
- throw new Error(
3249
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
3250
- );
3251
- if (!apiKey)
3252
- throw new Error(
3253
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
3254
- );
3255
- const [protocol, , host, , database] = databaseURL.split("/");
3256
- const urlParts = parseWorkspacesUrlParts(host);
3257
- if (!urlParts)
3258
- throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3259
- const { workspace, region } = urlParts;
3260
- try {
3261
- return await getBranchDetails({
3262
- apiKey,
3263
- apiUrl: databaseURL,
3264
- fetchImpl: getFetchImplementation(options?.fetchImpl),
3265
- workspacesApiUrl: `${protocol}//${host}`,
3266
- pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
3267
- trace: defaultTrace
3268
- });
3269
- } catch (err) {
3270
- if (isObject(err) && err.status === 404)
3271
- return null;
3272
- throw err;
3273
- }
3274
- }
3275
- function getDatabaseURL() {
3276
- try {
3277
- const { databaseURL } = getEnvironment();
3278
- return databaseURL;
3279
- } catch (err) {
3280
- return void 0;
3281
- }
3282
- }
3283
-
3284
4596
  var __accessCheck = (obj, member, msg) => {
3285
4597
  if (!member.has(obj))
3286
4598
  throw TypeError("Cannot " + msg);
@@ -3304,46 +4616,46 @@ var __privateMethod = (obj, member, method) => {
3304
4616
  return method;
3305
4617
  };
3306
4618
  const buildClient = (plugins) => {
3307
- var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
4619
+ var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
3308
4620
  return _a = class {
3309
4621
  constructor(options = {}, schemaTables) {
3310
4622
  __privateAdd(this, _parseOptions);
3311
4623
  __privateAdd(this, _getFetchProps);
3312
- __privateAdd(this, _evaluateBranch);
3313
- __privateAdd(this, _branch, void 0);
3314
4624
  __privateAdd(this, _options, void 0);
4625
+ __publicField$2(this, "db");
4626
+ __publicField$2(this, "search");
4627
+ __publicField$2(this, "transactions");
4628
+ __publicField$2(this, "sql");
4629
+ __publicField$2(this, "files");
3315
4630
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
3316
4631
  __privateSet(this, _options, safeOptions);
3317
4632
  const pluginOptions = {
3318
- getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
4633
+ ...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
3319
4634
  cache: safeOptions.cache,
3320
- trace: safeOptions.trace
4635
+ host: safeOptions.host
3321
4636
  };
3322
4637
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
3323
4638
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
3324
4639
  const transactions = new TransactionPlugin().build(pluginOptions);
4640
+ const sql = new SQLPlugin().build(pluginOptions);
4641
+ const files = new FilesPlugin().build(pluginOptions);
3325
4642
  this.db = db;
3326
4643
  this.search = search;
3327
4644
  this.transactions = transactions;
4645
+ this.sql = sql;
4646
+ this.files = files;
3328
4647
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
3329
4648
  if (namespace === void 0)
3330
4649
  continue;
3331
- const result = namespace.build(pluginOptions);
3332
- if (result instanceof Promise) {
3333
- void result.then((namespace2) => {
3334
- this[key] = namespace2;
3335
- });
3336
- } else {
3337
- this[key] = result;
3338
- }
4650
+ this[key] = namespace.build(pluginOptions);
3339
4651
  }
3340
4652
  }
3341
4653
  async getConfig() {
3342
4654
  const databaseURL = __privateGet(this, _options).databaseURL;
3343
- const branch = await __privateGet(this, _options).branch();
4655
+ const branch = __privateGet(this, _options).branch;
3344
4656
  return { databaseURL, branch };
3345
4657
  }
3346
- }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
4658
+ }, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
3347
4659
  const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
3348
4660
  const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
3349
4661
  if (isBrowser && !enableBrowser) {
@@ -3357,70 +4669,88 @@ const buildClient = (plugins) => {
3357
4669
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
3358
4670
  const trace = options?.trace ?? defaultTrace;
3359
4671
  const clientName = options?.clientName;
3360
- const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({
3361
- apiKey,
3362
- databaseURL,
3363
- fetchImpl: options?.fetch,
3364
- clientName: options?.clientName
3365
- });
4672
+ const host = options?.host ?? "production";
4673
+ const xataAgentExtra = options?.xataAgentExtra;
3366
4674
  if (!apiKey) {
3367
4675
  throw new Error("Option apiKey is required");
3368
4676
  }
3369
4677
  if (!databaseURL) {
3370
4678
  throw new Error("Option databaseURL is required");
3371
4679
  }
3372
- return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser, clientName };
3373
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
4680
+ const envBranch = getBranch();
4681
+ const previewBranch = getPreviewBranch();
4682
+ const branch = options?.branch || previewBranch || envBranch || "main";
4683
+ if (!!previewBranch && branch !== previewBranch) {
4684
+ console.warn(
4685
+ `Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
4686
+ );
4687
+ } else if (!!envBranch && branch !== envBranch) {
4688
+ console.warn(
4689
+ `Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
4690
+ );
4691
+ } else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
4692
+ console.warn(
4693
+ `Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
4694
+ );
4695
+ } else if (!previewBranch && !envBranch && options?.branch === void 0) {
4696
+ console.warn(
4697
+ `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.`
4698
+ );
4699
+ }
4700
+ return {
4701
+ fetch,
4702
+ databaseURL,
4703
+ apiKey,
4704
+ branch,
4705
+ cache,
4706
+ trace,
4707
+ host,
4708
+ clientID: generateUUID(),
4709
+ enableBrowser,
4710
+ clientName,
4711
+ xataAgentExtra
4712
+ };
4713
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
3374
4714
  fetch,
3375
4715
  apiKey,
3376
4716
  databaseURL,
3377
4717
  branch,
3378
4718
  trace,
3379
4719
  clientID,
3380
- clientName
4720
+ clientName,
4721
+ xataAgentExtra
3381
4722
  }) {
3382
- const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
3383
- if (!branchValue)
3384
- throw new Error("Unable to resolve branch value");
3385
4723
  return {
3386
- fetchImpl: fetch,
4724
+ fetch,
3387
4725
  apiKey,
3388
4726
  apiUrl: "",
4727
+ // Instead of using workspace and dbBranch, we inject a probably CNAME'd URL
3389
4728
  workspacesApiUrl: (path, params) => {
3390
4729
  const hasBranch = params.dbBranchName ?? params.branch;
3391
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
4730
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
3392
4731
  return databaseURL + newPath;
3393
4732
  },
3394
4733
  trace,
3395
4734
  clientID,
3396
- clientName
3397
- };
3398
- }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
3399
- if (__privateGet(this, _branch))
3400
- return __privateGet(this, _branch);
3401
- if (param === void 0)
3402
- return void 0;
3403
- const strategies = Array.isArray(param) ? [...param] : [param];
3404
- const evaluateBranch = async (strategy) => {
3405
- return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
4735
+ clientName,
4736
+ xataAgentExtra
3406
4737
  };
3407
- for await (const strategy of strategies) {
3408
- const branch = await evaluateBranch(strategy);
3409
- if (branch) {
3410
- __privateSet(this, _branch, branch);
3411
- return branch;
3412
- }
3413
- }
3414
4738
  }, _a;
3415
4739
  };
3416
4740
  class BaseClient extends buildClient() {
3417
4741
  }
3418
4742
 
4743
+ var __defProp$1 = Object.defineProperty;
4744
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4745
+ var __publicField$1 = (obj, key, value) => {
4746
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
4747
+ return value;
4748
+ };
3419
4749
  const META = "__";
3420
4750
  const VALUE = "___";
3421
4751
  class Serializer {
3422
4752
  constructor() {
3423
- this.classes = {};
4753
+ __publicField$1(this, "classes", {});
3424
4754
  }
3425
4755
  add(clazz) {
3426
4756
  this.classes[clazz.name] = clazz;
@@ -3498,12 +4828,19 @@ function buildWorkerRunner(config) {
3498
4828
  };
3499
4829
  }
3500
4830
 
4831
+ var __defProp = Object.defineProperty;
4832
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4833
+ var __publicField = (obj, key, value) => {
4834
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4835
+ return value;
4836
+ };
3501
4837
  class XataError extends Error {
3502
4838
  constructor(message, status) {
3503
4839
  super(message);
4840
+ __publicField(this, "status");
3504
4841
  this.status = status;
3505
4842
  }
3506
4843
  }
3507
4844
 
3508
- 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 };
4845
+ 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 };
3509
4846
  //# sourceMappingURL=index.mjs.map