@xata.io/client 0.0.0-alpha.vf4e6746 → 0.0.0-alpha.vf54e954

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
- const defaultTrace = async (_name, fn, _options) => {
3
+ const defaultTrace = async (name, fn, _options) => {
4
4
  return await fn({
5
+ name,
5
6
  setAttributes: () => {
6
7
  return;
7
8
  }
@@ -28,8 +29,11 @@ function notEmpty(value) {
28
29
  function compact(arr) {
29
30
  return arr.filter(notEmpty);
30
31
  }
32
+ function compactObject(obj) {
33
+ return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
34
+ }
31
35
  function isObject(value) {
32
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
36
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date);
33
37
  }
34
38
  function isDefined(value) {
35
39
  return value !== null && value !== void 0;
@@ -84,6 +88,27 @@ function chunk(array, chunkSize) {
84
88
  async function timeout(ms) {
85
89
  return new Promise((resolve) => setTimeout(resolve, ms));
86
90
  }
91
+ function timeoutWithCancel(ms) {
92
+ let timeoutId;
93
+ const promise = new Promise((resolve) => {
94
+ timeoutId = setTimeout(() => {
95
+ resolve();
96
+ }, ms);
97
+ });
98
+ return {
99
+ cancel: () => clearTimeout(timeoutId),
100
+ promise
101
+ };
102
+ }
103
+ function promiseMap(inputValues, mapper) {
104
+ const reducer = (acc$, inputValue) => acc$.then(
105
+ (acc) => mapper(inputValue).then((result) => {
106
+ acc.push(result);
107
+ return acc;
108
+ })
109
+ );
110
+ return inputValues.reduce(reducer, Promise.resolve([]));
111
+ }
87
112
 
88
113
  function getEnvironment() {
89
114
  try {
@@ -92,8 +117,10 @@ function getEnvironment() {
92
117
  apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
93
118
  databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
94
119
  branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
95
- envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
96
- fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
120
+ deployPreview: process.env.XATA_PREVIEW,
121
+ deployPreviewBranch: process.env.XATA_PREVIEW_BRANCH,
122
+ vercelGitCommitRef: process.env.VERCEL_GIT_COMMIT_REF,
123
+ vercelGitRepoOwner: process.env.VERCEL_GIT_REPO_OWNER
97
124
  };
98
125
  }
99
126
  } catch (err) {
@@ -104,8 +131,10 @@ function getEnvironment() {
104
131
  apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
105
132
  databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
106
133
  branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
107
- envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
108
- fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
134
+ deployPreview: Deno.env.get("XATA_PREVIEW"),
135
+ deployPreviewBranch: Deno.env.get("XATA_PREVIEW_BRANCH"),
136
+ vercelGitCommitRef: Deno.env.get("VERCEL_GIT_COMMIT_REF"),
137
+ vercelGitRepoOwner: Deno.env.get("VERCEL_GIT_REPO_OWNER")
109
138
  };
110
139
  }
111
140
  } catch (err) {
@@ -114,8 +143,10 @@ function getEnvironment() {
114
143
  apiKey: getGlobalApiKey(),
115
144
  databaseURL: getGlobalDatabaseURL(),
116
145
  branch: getGlobalBranch(),
117
- envBranch: void 0,
118
- fallbackBranch: getGlobalFallbackBranch()
146
+ deployPreview: void 0,
147
+ deployPreviewBranch: void 0,
148
+ vercelGitCommitRef: void 0,
149
+ vercelGitRepoOwner: void 0
119
150
  };
120
151
  }
121
152
  function getEnableBrowserVariable() {
@@ -158,44 +189,59 @@ function getGlobalBranch() {
158
189
  return void 0;
159
190
  }
160
191
  }
161
- function getGlobalFallbackBranch() {
192
+ function getDatabaseURL() {
162
193
  try {
163
- return XATA_FALLBACK_BRANCH;
194
+ const { databaseURL } = getEnvironment();
195
+ return databaseURL;
164
196
  } catch (err) {
165
197
  return void 0;
166
198
  }
167
199
  }
168
- async function getGitBranch() {
169
- const cmd = ["git", "branch", "--show-current"];
170
- const fullCmd = cmd.join(" ");
171
- const nodeModule = ["child", "process"].join("_");
172
- const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
200
+ function getAPIKey() {
173
201
  try {
174
- if (typeof require === "function") {
175
- return require(nodeModule).execSync(fullCmd, execOptions).trim();
176
- }
177
- const { execSync } = await import(nodeModule);
178
- return execSync(fullCmd, execOptions).toString().trim();
202
+ const { apiKey } = getEnvironment();
203
+ return apiKey;
179
204
  } catch (err) {
205
+ return void 0;
180
206
  }
207
+ }
208
+ function getBranch() {
181
209
  try {
182
- if (isObject(Deno)) {
183
- const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
184
- return new TextDecoder().decode(await process2.output()).trim();
185
- }
210
+ const { branch } = getEnvironment();
211
+ return branch;
186
212
  } catch (err) {
213
+ return void 0;
187
214
  }
188
215
  }
189
-
190
- function getAPIKey() {
216
+ function buildPreviewBranchName({ org, branch }) {
217
+ return `preview-${org}-${branch}`;
218
+ }
219
+ function getPreviewBranch() {
191
220
  try {
192
- const { apiKey } = getEnvironment();
193
- return apiKey;
221
+ const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = getEnvironment();
222
+ if (deployPreviewBranch)
223
+ return deployPreviewBranch;
224
+ switch (deployPreview) {
225
+ case "vercel": {
226
+ if (!vercelGitCommitRef || !vercelGitRepoOwner) {
227
+ console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
228
+ return void 0;
229
+ }
230
+ return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
231
+ }
232
+ }
233
+ return void 0;
194
234
  } catch (err) {
195
235
  return void 0;
196
236
  }
197
237
  }
198
238
 
239
+ var __defProp$8 = Object.defineProperty;
240
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
241
+ var __publicField$8 = (obj, key, value) => {
242
+ __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
243
+ return value;
244
+ };
199
245
  var __accessCheck$8 = (obj, member, msg) => {
200
246
  if (!member.has(obj))
201
247
  throw TypeError("Cannot " + msg);
@@ -219,6 +265,7 @@ var __privateMethod$4 = (obj, member, method) => {
219
265
  return method;
220
266
  };
221
267
  var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
268
+ const REQUEST_TIMEOUT = 3e4;
222
269
  function getFetchImplementation(userFetch) {
223
270
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
224
271
  const fetchImpl = userFetch ?? globalFetch;
@@ -235,6 +282,8 @@ class ApiRequestPool {
235
282
  __privateAdd$8(this, _fetch, void 0);
236
283
  __privateAdd$8(this, _queue, void 0);
237
284
  __privateAdd$8(this, _concurrency, void 0);
285
+ __publicField$8(this, "running");
286
+ __publicField$8(this, "started");
238
287
  __privateSet$8(this, _queue, []);
239
288
  __privateSet$8(this, _concurrency, concurrency);
240
289
  this.running = 0;
@@ -250,18 +299,22 @@ class ApiRequestPool {
250
299
  return __privateGet$8(this, _fetch);
251
300
  }
252
301
  request(url, options) {
253
- const start = new Date();
254
- const fetch2 = this.getFetch();
302
+ const start = /* @__PURE__ */ new Date();
303
+ const fetchImpl = this.getFetch();
255
304
  const runRequest = async (stalled = false) => {
256
- const response = await fetch2(url, options);
305
+ const { promise, cancel } = timeoutWithCancel(REQUEST_TIMEOUT);
306
+ const response = await Promise.race([fetchImpl(url, options), promise.then(() => null)]).finally(cancel);
307
+ if (!response) {
308
+ throw new Error("Request timed out");
309
+ }
257
310
  if (response.status === 429) {
258
311
  const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
259
312
  await timeout(rateLimitReset * 1e3);
260
313
  return await runRequest(true);
261
314
  }
262
315
  if (stalled) {
263
- const stalledTime = new Date().getTime() - start.getTime();
264
- console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
316
+ const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
317
+ console.warn(`A request to Xata hit branch rate limits, was retried and stalled for ${stalledTime}ms`);
265
318
  }
266
319
  return response;
267
320
  };
@@ -296,18 +349,208 @@ enqueue_fn = function(task) {
296
349
  return promise;
297
350
  };
298
351
 
299
- const VERSION = "0.0.0-alpha.vf4e6746";
352
+ function generateUUID() {
353
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
354
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
355
+ return v.toString(16);
356
+ });
357
+ }
358
+
359
+ async function getBytes(stream, onChunk) {
360
+ const reader = stream.getReader();
361
+ let result;
362
+ while (!(result = await reader.read()).done) {
363
+ onChunk(result.value);
364
+ }
365
+ }
366
+ function getLines(onLine) {
367
+ let buffer;
368
+ let position;
369
+ let fieldLength;
370
+ let discardTrailingNewline = false;
371
+ return function onChunk(arr) {
372
+ if (buffer === void 0) {
373
+ buffer = arr;
374
+ position = 0;
375
+ fieldLength = -1;
376
+ } else {
377
+ buffer = concat(buffer, arr);
378
+ }
379
+ const bufLength = buffer.length;
380
+ let lineStart = 0;
381
+ while (position < bufLength) {
382
+ if (discardTrailingNewline) {
383
+ if (buffer[position] === 10 /* NewLine */) {
384
+ lineStart = ++position;
385
+ }
386
+ discardTrailingNewline = false;
387
+ }
388
+ let lineEnd = -1;
389
+ for (; position < bufLength && lineEnd === -1; ++position) {
390
+ switch (buffer[position]) {
391
+ case 58 /* Colon */:
392
+ if (fieldLength === -1) {
393
+ fieldLength = position - lineStart;
394
+ }
395
+ break;
396
+ case 13 /* CarriageReturn */:
397
+ discardTrailingNewline = true;
398
+ case 10 /* NewLine */:
399
+ lineEnd = position;
400
+ break;
401
+ }
402
+ }
403
+ if (lineEnd === -1) {
404
+ break;
405
+ }
406
+ onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
407
+ lineStart = position;
408
+ fieldLength = -1;
409
+ }
410
+ if (lineStart === bufLength) {
411
+ buffer = void 0;
412
+ } else if (lineStart !== 0) {
413
+ buffer = buffer.subarray(lineStart);
414
+ position -= lineStart;
415
+ }
416
+ };
417
+ }
418
+ function getMessages(onId, onRetry, onMessage) {
419
+ let message = newMessage();
420
+ const decoder = new TextDecoder();
421
+ return function onLine(line, fieldLength) {
422
+ if (line.length === 0) {
423
+ onMessage?.(message);
424
+ message = newMessage();
425
+ } else if (fieldLength > 0) {
426
+ const field = decoder.decode(line.subarray(0, fieldLength));
427
+ const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
428
+ const value = decoder.decode(line.subarray(valueOffset));
429
+ switch (field) {
430
+ case "data":
431
+ message.data = message.data ? message.data + "\n" + value : value;
432
+ break;
433
+ case "event":
434
+ message.event = value;
435
+ break;
436
+ case "id":
437
+ onId(message.id = value);
438
+ break;
439
+ case "retry":
440
+ const retry = parseInt(value, 10);
441
+ if (!isNaN(retry)) {
442
+ onRetry(message.retry = retry);
443
+ }
444
+ break;
445
+ }
446
+ }
447
+ };
448
+ }
449
+ function concat(a, b) {
450
+ const res = new Uint8Array(a.length + b.length);
451
+ res.set(a);
452
+ res.set(b, a.length);
453
+ return res;
454
+ }
455
+ function newMessage() {
456
+ return {
457
+ data: "",
458
+ event: "",
459
+ id: "",
460
+ retry: void 0
461
+ };
462
+ }
463
+ const EventStreamContentType = "text/event-stream";
464
+ const LastEventId = "last-event-id";
465
+ function fetchEventSource(input, {
466
+ signal: inputSignal,
467
+ headers: inputHeaders,
468
+ onopen: inputOnOpen,
469
+ onmessage,
470
+ onclose,
471
+ onerror,
472
+ fetch: inputFetch,
473
+ ...rest
474
+ }) {
475
+ return new Promise((resolve, reject) => {
476
+ const headers = { ...inputHeaders };
477
+ if (!headers.accept) {
478
+ headers.accept = EventStreamContentType;
479
+ }
480
+ let curRequestController;
481
+ function dispose() {
482
+ curRequestController.abort();
483
+ }
484
+ inputSignal?.addEventListener("abort", () => {
485
+ dispose();
486
+ resolve();
487
+ });
488
+ const fetchImpl = inputFetch ?? fetch;
489
+ const onopen = inputOnOpen ?? defaultOnOpen;
490
+ async function create() {
491
+ curRequestController = new AbortController();
492
+ try {
493
+ const response = await fetchImpl(input, {
494
+ ...rest,
495
+ headers,
496
+ signal: curRequestController.signal
497
+ });
498
+ await onopen(response);
499
+ await getBytes(
500
+ response.body,
501
+ getLines(
502
+ getMessages(
503
+ (id) => {
504
+ if (id) {
505
+ headers[LastEventId] = id;
506
+ } else {
507
+ delete headers[LastEventId];
508
+ }
509
+ },
510
+ (_retry) => {
511
+ },
512
+ onmessage
513
+ )
514
+ )
515
+ );
516
+ onclose?.();
517
+ dispose();
518
+ resolve();
519
+ } catch (err) {
520
+ }
521
+ }
522
+ create();
523
+ });
524
+ }
525
+ function defaultOnOpen(response) {
526
+ const contentType = response.headers?.get("content-type");
527
+ if (!contentType?.startsWith(EventStreamContentType)) {
528
+ throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
529
+ }
530
+ }
531
+
532
+ const VERSION = "0.26.0";
300
533
 
534
+ var __defProp$7 = Object.defineProperty;
535
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
536
+ var __publicField$7 = (obj, key, value) => {
537
+ __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
538
+ return value;
539
+ };
301
540
  class ErrorWithCause extends Error {
302
541
  constructor(message, options) {
303
542
  super(message, options);
543
+ __publicField$7(this, "cause");
304
544
  }
305
545
  }
306
546
  class FetcherError extends ErrorWithCause {
307
547
  constructor(status, data, requestId) {
308
548
  super(getMessage(data));
549
+ __publicField$7(this, "status");
550
+ __publicField$7(this, "requestId");
551
+ __publicField$7(this, "errors");
309
552
  this.status = status;
310
- this.errors = isBulkError(data) ? data.errors : void 0;
553
+ this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
311
554
  this.requestId = requestId;
312
555
  if (data instanceof Error) {
313
556
  this.stack = data.stack;
@@ -372,14 +615,24 @@ function hostHeader(url) {
372
615
  const { groups } = pattern.exec(url) ?? {};
373
616
  return groups?.host ? { Host: groups.host } : {};
374
617
  }
618
+ function parseBody(body, headers) {
619
+ if (!isDefined(body))
620
+ return void 0;
621
+ const { "Content-Type": contentType } = headers ?? {};
622
+ if (String(contentType).toLowerCase() === "application/json") {
623
+ return JSON.stringify(body);
624
+ }
625
+ return body;
626
+ }
627
+ const defaultClientID = generateUUID();
375
628
  async function fetch$1({
376
629
  url: path,
377
630
  method,
378
631
  body,
379
- headers,
632
+ headers: customHeaders,
380
633
  pathParams,
381
634
  queryParams,
382
- fetchImpl,
635
+ fetch: fetch2,
383
636
  apiKey,
384
637
  endpoint,
385
638
  apiUrl,
@@ -388,9 +641,12 @@ async function fetch$1({
388
641
  signal,
389
642
  clientID,
390
643
  sessionID,
391
- fetchOptions = {}
644
+ clientName,
645
+ xataAgentExtra,
646
+ fetchOptions = {},
647
+ rawResponse = false
392
648
  }) {
393
- pool.setFetch(fetchImpl);
649
+ pool.setFetch(fetch2);
394
650
  return await trace(
395
651
  `${method.toUpperCase()} ${path}`,
396
652
  async ({ setAttributes }) => {
@@ -401,19 +657,27 @@ async function fetch$1({
401
657
  [TraceAttributes.HTTP_URL]: url,
402
658
  [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
403
659
  });
660
+ const xataAgent = compact([
661
+ ["client", "TS_SDK"],
662
+ ["version", VERSION],
663
+ isDefined(clientName) ? ["service", clientName] : void 0,
664
+ ...Object.entries(xataAgentExtra ?? {})
665
+ ]).map(([key, value]) => `${key}=${value}`).join("; ");
666
+ const headers = compactObject({
667
+ "Accept-Encoding": "identity",
668
+ "Content-Type": "application/json",
669
+ "X-Xata-Client-ID": clientID ?? defaultClientID,
670
+ "X-Xata-Session-ID": sessionID ?? generateUUID(),
671
+ "X-Xata-Agent": xataAgent,
672
+ ...customHeaders,
673
+ ...hostHeader(fullUrl),
674
+ Authorization: `Bearer ${apiKey}`
675
+ });
404
676
  const response = await pool.request(url, {
405
677
  ...fetchOptions,
406
678
  method: method.toUpperCase(),
407
- body: body ? JSON.stringify(body) : void 0,
408
- headers: {
409
- "Content-Type": "application/json",
410
- "User-Agent": `Xata client-ts/${VERSION}`,
411
- "X-Xata-Client-ID": clientID ?? "",
412
- "X-Xata-Session-ID": sessionID ?? "",
413
- ...headers,
414
- ...hostHeader(fullUrl),
415
- Authorization: `Bearer ${apiKey}`
416
- },
679
+ body: parseBody(body, headers),
680
+ headers,
417
681
  signal
418
682
  });
419
683
  const { host, protocol } = parseUrl(response.url);
@@ -425,6 +689,9 @@ async function fetch$1({
425
689
  [TraceAttributes.HTTP_HOST]: host,
426
690
  [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
427
691
  });
692
+ const message = response.headers?.get("x-xata-message");
693
+ if (message)
694
+ console.warn(message);
428
695
  if (response.status === 204) {
429
696
  return {};
430
697
  }
@@ -432,7 +699,7 @@ async function fetch$1({
432
699
  throw new FetcherError(response.status, "Rate limit exceeded", requestId);
433
700
  }
434
701
  try {
435
- const jsonResponse = await response.json();
702
+ const jsonResponse = rawResponse ? await response.blob() : await response.json();
436
703
  if (response.ok) {
437
704
  return jsonResponse;
438
705
  }
@@ -444,6 +711,59 @@ async function fetch$1({
444
711
  { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
445
712
  );
446
713
  }
714
+ function fetchSSERequest({
715
+ url: path,
716
+ method,
717
+ body,
718
+ headers: customHeaders,
719
+ pathParams,
720
+ queryParams,
721
+ fetch: fetch2,
722
+ apiKey,
723
+ endpoint,
724
+ apiUrl,
725
+ workspacesApiUrl,
726
+ onMessage,
727
+ onError,
728
+ onClose,
729
+ signal,
730
+ clientID,
731
+ sessionID,
732
+ clientName,
733
+ xataAgentExtra
734
+ }) {
735
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
736
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
737
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
738
+ void fetchEventSource(url, {
739
+ method,
740
+ body: JSON.stringify(body),
741
+ fetch: fetch2,
742
+ signal,
743
+ headers: {
744
+ "X-Xata-Client-ID": clientID ?? defaultClientID,
745
+ "X-Xata-Session-ID": sessionID ?? generateUUID(),
746
+ "X-Xata-Agent": compact([
747
+ ["client", "TS_SDK"],
748
+ ["version", VERSION],
749
+ isDefined(clientName) ? ["service", clientName] : void 0,
750
+ ...Object.entries(xataAgentExtra ?? {})
751
+ ]).map(([key, value]) => `${key}=${value}`).join("; "),
752
+ ...customHeaders,
753
+ Authorization: `Bearer ${apiKey}`,
754
+ "Content-Type": "application/json"
755
+ },
756
+ onmessage(ev) {
757
+ onMessage?.(JSON.parse(ev.data));
758
+ },
759
+ onerror(ev) {
760
+ onError?.(JSON.parse(ev.data));
761
+ },
762
+ onclose() {
763
+ onClose?.();
764
+ }
765
+ });
766
+ }
447
767
  function parseUrl(url) {
448
768
  try {
449
769
  const { host, protocol } = new URL(url);
@@ -455,17 +775,12 @@ function parseUrl(url) {
455
775
 
456
776
  const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
457
777
 
458
- const dEPRECATEDgetDatabaseList = (variables, signal) => dataPlaneFetch({ url: "/dbs", method: "get", ...variables, signal });
459
778
  const getBranchList = (variables, signal) => dataPlaneFetch({
460
779
  url: "/dbs/{dbName}",
461
780
  method: "get",
462
781
  ...variables,
463
782
  signal
464
783
  });
465
- const dEPRECATEDcreateDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
466
- const dEPRECATEDdeleteDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "delete", ...variables, signal });
467
- const dEPRECATEDgetDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "get", ...variables, signal });
468
- const dEPRECATEDupdateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
469
784
  const getBranchDetails = (variables, signal) => dataPlaneFetch({
470
785
  url: "/db/{dbBranchName}",
471
786
  method: "get",
@@ -479,6 +794,12 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
479
794
  ...variables,
480
795
  signal
481
796
  });
797
+ const copyBranch = (variables, signal) => dataPlaneFetch({
798
+ url: "/db/{dbBranchName}/copy",
799
+ method: "post",
800
+ ...variables,
801
+ signal
802
+ });
482
803
  const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
483
804
  url: "/db/{dbBranchName}/metadata",
484
805
  method: "put",
@@ -504,7 +825,6 @@ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName
504
825
  const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
505
826
  const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
506
827
  const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
507
- const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
508
828
  const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
509
829
  const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
510
830
  const getMigrationRequest = (variables, signal) => dataPlaneFetch({
@@ -529,6 +849,7 @@ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{
529
849
  const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
530
850
  const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
531
851
  const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
852
+ const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
532
853
  const createTable = (variables, signal) => dataPlaneFetch({
533
854
  url: "/db/{dbBranchName}/tables/{tableName}",
534
855
  method: "put",
@@ -571,7 +892,44 @@ const deleteColumn = (variables, signal) => dataPlaneFetch({
571
892
  ...variables,
572
893
  signal
573
894
  });
895
+ const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
574
896
  const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
897
+ const getFileItem = (variables, signal) => dataPlaneFetch({
898
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
899
+ method: "get",
900
+ ...variables,
901
+ signal
902
+ });
903
+ const putFileItem = (variables, signal) => dataPlaneFetch({
904
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
905
+ method: "put",
906
+ ...variables,
907
+ signal
908
+ });
909
+ const deleteFileItem = (variables, signal) => dataPlaneFetch({
910
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
911
+ method: "delete",
912
+ ...variables,
913
+ signal
914
+ });
915
+ const getFile = (variables, signal) => dataPlaneFetch({
916
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
917
+ method: "get",
918
+ ...variables,
919
+ signal
920
+ });
921
+ const putFile = (variables, signal) => dataPlaneFetch({
922
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
923
+ method: "put",
924
+ ...variables,
925
+ signal
926
+ });
927
+ const deleteFile = (variables, signal) => dataPlaneFetch({
928
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
929
+ method: "delete",
930
+ ...variables,
931
+ signal
932
+ });
575
933
  const getRecord = (variables, signal) => dataPlaneFetch({
576
934
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
577
935
  method: "get",
@@ -601,21 +959,35 @@ const searchTable = (variables, signal) => dataPlaneFetch({
601
959
  ...variables,
602
960
  signal
603
961
  });
962
+ const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
963
+ const askTable = (variables, signal) => dataPlaneFetch({
964
+ url: "/db/{dbBranchName}/tables/{tableName}/ask",
965
+ method: "post",
966
+ ...variables,
967
+ signal
968
+ });
969
+ const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
604
970
  const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
605
971
  const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
972
+ const fileAccess = (variables, signal) => dataPlaneFetch({
973
+ url: "/file/{fileId}",
974
+ method: "get",
975
+ ...variables,
976
+ signal
977
+ });
978
+ const sqlQuery = (variables, signal) => dataPlaneFetch({
979
+ url: "/db/{dbBranchName}/sql",
980
+ method: "post",
981
+ ...variables,
982
+ signal
983
+ });
606
984
  const operationsByTag$2 = {
607
- database: {
608
- dEPRECATEDgetDatabaseList,
609
- dEPRECATEDcreateDatabase,
610
- dEPRECATEDdeleteDatabase,
611
- dEPRECATEDgetDatabaseMetadata,
612
- dEPRECATEDupdateDatabaseMetadata
613
- },
614
985
  branch: {
615
986
  getBranchList,
616
987
  getBranchDetails,
617
988
  createBranch,
618
989
  deleteBranch,
990
+ copyBranch,
619
991
  updateBranchMetadata,
620
992
  getBranchMetadata,
621
993
  getBranchStats,
@@ -633,17 +1005,8 @@ const operationsByTag$2 = {
633
1005
  compareBranchSchemas,
634
1006
  updateBranchSchema,
635
1007
  previewBranchSchemaEdit,
636
- applyBranchSchemaEdit
637
- },
638
- records: {
639
- branchTransaction,
640
- insertRecord,
641
- getRecord,
642
- insertRecordWithID,
643
- updateRecordWithID,
644
- upsertRecordWithID,
645
- deleteRecord,
646
- bulkInsertTableRecords
1008
+ applyBranchSchemaEdit,
1009
+ pushBranchMigrations
647
1010
  },
648
1011
  migrationRequests: {
649
1012
  queryMigrationRequests,
@@ -667,11 +1030,34 @@ const operationsByTag$2 = {
667
1030
  updateColumn,
668
1031
  deleteColumn
669
1032
  },
670
- searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
1033
+ records: {
1034
+ branchTransaction,
1035
+ insertRecord,
1036
+ getRecord,
1037
+ insertRecordWithID,
1038
+ updateRecordWithID,
1039
+ upsertRecordWithID,
1040
+ deleteRecord,
1041
+ bulkInsertTableRecords
1042
+ },
1043
+ files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
1044
+ searchAndFilter: {
1045
+ queryTable,
1046
+ searchBranch,
1047
+ searchTable,
1048
+ vectorSearchTable,
1049
+ askTable,
1050
+ askTableSession,
1051
+ summarizeTable,
1052
+ aggregateTable
1053
+ },
1054
+ sql: { sqlQuery }
671
1055
  };
672
1056
 
673
1057
  const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
674
1058
 
1059
+ const getAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "get", ...variables, signal });
1060
+ const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
675
1061
  const getUser = (variables, signal) => controlPlaneFetch({
676
1062
  url: "/user",
677
1063
  method: "get",
@@ -708,6 +1094,31 @@ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
708
1094
  ...variables,
709
1095
  signal
710
1096
  });
1097
+ const getUserOAuthClients = (variables, signal) => controlPlaneFetch({
1098
+ url: "/user/oauth/clients",
1099
+ method: "get",
1100
+ ...variables,
1101
+ signal
1102
+ });
1103
+ const deleteUserOAuthClient = (variables, signal) => controlPlaneFetch({
1104
+ url: "/user/oauth/clients/{clientId}",
1105
+ method: "delete",
1106
+ ...variables,
1107
+ signal
1108
+ });
1109
+ const getUserOAuthAccessTokens = (variables, signal) => controlPlaneFetch({
1110
+ url: "/user/oauth/tokens",
1111
+ method: "get",
1112
+ ...variables,
1113
+ signal
1114
+ });
1115
+ const deleteOAuthAccessToken = (variables, signal) => controlPlaneFetch({
1116
+ url: "/user/oauth/tokens/{token}",
1117
+ method: "delete",
1118
+ ...variables,
1119
+ signal
1120
+ });
1121
+ const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({ url: "/user/oauth/tokens/{token}", method: "patch", ...variables, signal });
711
1122
  const getWorkspacesList = (variables, signal) => controlPlaneFetch({
712
1123
  url: "/workspaces",
713
1124
  method: "get",
@@ -766,6 +1177,10 @@ const deleteDatabase = (variables, signal) => controlPlaneFetch({
766
1177
  });
767
1178
  const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
768
1179
  const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
1180
+ const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
1181
+ const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
1182
+ const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
1183
+ const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
769
1184
  const listRegions = (variables, signal) => controlPlaneFetch({
770
1185
  url: "/workspaces/{workspaceId}/regions",
771
1186
  method: "get",
@@ -773,6 +1188,15 @@ const listRegions = (variables, signal) => controlPlaneFetch({
773
1188
  signal
774
1189
  });
775
1190
  const operationsByTag$1 = {
1191
+ oAuth: {
1192
+ getAuthorizationCode,
1193
+ grantAuthorizationCode,
1194
+ getUserOAuthClients,
1195
+ deleteUserOAuthClient,
1196
+ getUserOAuthAccessTokens,
1197
+ deleteOAuthAccessToken,
1198
+ updateOAuthAccessToken
1199
+ },
776
1200
  users: { getUser, updateUser, deleteUser },
777
1201
  authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
778
1202
  workspaces: {
@@ -798,6 +1222,10 @@ const operationsByTag$1 = {
798
1222
  deleteDatabase,
799
1223
  getDatabaseMetadata,
800
1224
  updateDatabaseMetadata,
1225
+ renameDatabase,
1226
+ getDatabaseGithubSettings,
1227
+ updateDatabaseGithubSettings,
1228
+ deleteDatabaseGithubSettings,
801
1229
  listRegions
802
1230
  }
803
1231
  };
@@ -818,8 +1246,12 @@ const providers = {
818
1246
  workspaces: "https://{workspaceId}.{region}.xata.sh"
819
1247
  },
820
1248
  staging: {
821
- main: "https://staging.xatabase.co",
822
- workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
1249
+ main: "https://api.staging-xata.dev",
1250
+ workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
1251
+ },
1252
+ dev: {
1253
+ main: "https://api.dev-xata.dev",
1254
+ workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
823
1255
  }
824
1256
  };
825
1257
  function isHostProviderAlias(alias) {
@@ -837,15 +1269,22 @@ function parseProviderString(provider = "production") {
837
1269
  return null;
838
1270
  return { main, workspaces };
839
1271
  }
1272
+ function buildProviderString(provider) {
1273
+ if (isHostProviderAlias(provider))
1274
+ return provider;
1275
+ return `${provider.main},${provider.workspaces}`;
1276
+ }
840
1277
  function parseWorkspacesUrlParts(url) {
841
1278
  if (!isString(url))
842
1279
  return null;
843
- const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
844
- const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
845
- const match = url.match(regex) || url.match(regexStaging);
1280
+ const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
1281
+ const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
1282
+ const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
1283
+ const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
1284
+ const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
846
1285
  if (!match)
847
1286
  return null;
848
- return { workspace: match[1], region: match[2] ?? "eu-west-1" };
1287
+ return { workspace: match[1], region: match[2] };
849
1288
  }
850
1289
 
851
1290
  var __accessCheck$7 = (obj, member, msg) => {
@@ -874,15 +1313,19 @@ class XataApiClient {
874
1313
  const provider = options.host ?? "production";
875
1314
  const apiKey = options.apiKey ?? getAPIKey();
876
1315
  const trace = options.trace ?? defaultTrace;
1316
+ const clientID = generateUUID();
877
1317
  if (!apiKey) {
878
1318
  throw new Error("Could not resolve a valid apiKey");
879
1319
  }
880
1320
  __privateSet$7(this, _extraProps, {
881
1321
  apiUrl: getHostUrl(provider, "main"),
882
1322
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
883
- fetchImpl: getFetchImplementation(options.fetch),
1323
+ fetch: getFetchImplementation(options.fetch),
884
1324
  apiKey,
885
- trace
1325
+ trace,
1326
+ clientName: options.clientName,
1327
+ xataAgentExtra: options.xataAgentExtra,
1328
+ clientID
886
1329
  });
887
1330
  }
888
1331
  get user() {
@@ -935,6 +1378,11 @@ class XataApiClient {
935
1378
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
936
1379
  return __privateGet$7(this, _namespaces).records;
937
1380
  }
1381
+ get files() {
1382
+ if (!__privateGet$7(this, _namespaces).files)
1383
+ __privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
1384
+ return __privateGet$7(this, _namespaces).files;
1385
+ }
938
1386
  get searchAndFilter() {
939
1387
  if (!__privateGet$7(this, _namespaces).searchAndFilter)
940
1388
  __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
@@ -1143,6 +1591,20 @@ class BranchApi {
1143
1591
  ...this.extraProps
1144
1592
  });
1145
1593
  }
1594
+ copyBranch({
1595
+ workspace,
1596
+ region,
1597
+ database,
1598
+ branch,
1599
+ destinationBranch,
1600
+ limit
1601
+ }) {
1602
+ return operationsByTag.branch.copyBranch({
1603
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1604
+ body: { destinationBranch, limit },
1605
+ ...this.extraProps
1606
+ });
1607
+ }
1146
1608
  updateBranchMetadata({
1147
1609
  workspace,
1148
1610
  region,
@@ -1498,83 +1960,288 @@ class RecordsApi {
1498
1960
  });
1499
1961
  }
1500
1962
  }
1501
- class SearchAndFilterApi {
1963
+ class FilesApi {
1502
1964
  constructor(extraProps) {
1503
1965
  this.extraProps = extraProps;
1504
1966
  }
1505
- queryTable({
1967
+ getFileItem({
1506
1968
  workspace,
1507
1969
  region,
1508
1970
  database,
1509
1971
  branch,
1510
1972
  table,
1511
- filter,
1512
- sort,
1513
- page,
1514
- columns,
1515
- consistency
1973
+ record,
1974
+ column,
1975
+ fileId
1516
1976
  }) {
1517
- return operationsByTag.searchAndFilter.queryTable({
1518
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1519
- body: { filter, sort, page, columns, consistency },
1977
+ return operationsByTag.files.getFileItem({
1978
+ pathParams: {
1979
+ workspace,
1980
+ region,
1981
+ dbBranchName: `${database}:${branch}`,
1982
+ tableName: table,
1983
+ recordId: record,
1984
+ columnName: column,
1985
+ fileId
1986
+ },
1520
1987
  ...this.extraProps
1521
1988
  });
1522
1989
  }
1523
- searchTable({
1990
+ putFileItem({
1524
1991
  workspace,
1525
1992
  region,
1526
1993
  database,
1527
1994
  branch,
1528
1995
  table,
1529
- query,
1530
- fuzziness,
1531
- target,
1532
- prefix,
1533
- filter,
1534
- highlight,
1535
- boosters
1996
+ record,
1997
+ column,
1998
+ fileId,
1999
+ file
1536
2000
  }) {
1537
- return operationsByTag.searchAndFilter.searchTable({
1538
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1539
- body: { query, fuzziness, target, prefix, filter, highlight, boosters },
2001
+ return operationsByTag.files.putFileItem({
2002
+ pathParams: {
2003
+ workspace,
2004
+ region,
2005
+ dbBranchName: `${database}:${branch}`,
2006
+ tableName: table,
2007
+ recordId: record,
2008
+ columnName: column,
2009
+ fileId
2010
+ },
2011
+ // @ts-ignore
2012
+ body: file,
1540
2013
  ...this.extraProps
1541
2014
  });
1542
2015
  }
1543
- searchBranch({
2016
+ deleteFileItem({
1544
2017
  workspace,
1545
2018
  region,
1546
2019
  database,
1547
2020
  branch,
1548
- tables,
1549
- query,
1550
- fuzziness,
1551
- prefix,
1552
- highlight
2021
+ table,
2022
+ record,
2023
+ column,
2024
+ fileId
1553
2025
  }) {
1554
- return operationsByTag.searchAndFilter.searchBranch({
1555
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1556
- body: { tables, query, fuzziness, prefix, highlight },
2026
+ return operationsByTag.files.deleteFileItem({
2027
+ pathParams: {
2028
+ workspace,
2029
+ region,
2030
+ dbBranchName: `${database}:${branch}`,
2031
+ tableName: table,
2032
+ recordId: record,
2033
+ columnName: column,
2034
+ fileId
2035
+ },
1557
2036
  ...this.extraProps
1558
2037
  });
1559
2038
  }
1560
- summarizeTable({
2039
+ getFile({
1561
2040
  workspace,
1562
2041
  region,
1563
2042
  database,
1564
2043
  branch,
1565
2044
  table,
1566
- filter,
1567
- columns,
1568
- summaries,
1569
- sort,
1570
- summariesFilter,
1571
- page,
1572
- consistency
2045
+ record,
2046
+ column
1573
2047
  }) {
1574
- return operationsByTag.searchAndFilter.summarizeTable({
1575
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1576
- body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
1577
- ...this.extraProps
2048
+ return operationsByTag.files.getFile({
2049
+ pathParams: {
2050
+ workspace,
2051
+ region,
2052
+ dbBranchName: `${database}:${branch}`,
2053
+ tableName: table,
2054
+ recordId: record,
2055
+ columnName: column
2056
+ },
2057
+ ...this.extraProps
2058
+ });
2059
+ }
2060
+ putFile({
2061
+ workspace,
2062
+ region,
2063
+ database,
2064
+ branch,
2065
+ table,
2066
+ record,
2067
+ column,
2068
+ file
2069
+ }) {
2070
+ return operationsByTag.files.putFile({
2071
+ pathParams: {
2072
+ workspace,
2073
+ region,
2074
+ dbBranchName: `${database}:${branch}`,
2075
+ tableName: table,
2076
+ recordId: record,
2077
+ columnName: column
2078
+ },
2079
+ body: file,
2080
+ ...this.extraProps
2081
+ });
2082
+ }
2083
+ deleteFile({
2084
+ workspace,
2085
+ region,
2086
+ database,
2087
+ branch,
2088
+ table,
2089
+ record,
2090
+ column
2091
+ }) {
2092
+ return operationsByTag.files.deleteFile({
2093
+ pathParams: {
2094
+ workspace,
2095
+ region,
2096
+ dbBranchName: `${database}:${branch}`,
2097
+ tableName: table,
2098
+ recordId: record,
2099
+ columnName: column
2100
+ },
2101
+ ...this.extraProps
2102
+ });
2103
+ }
2104
+ fileAccess({
2105
+ workspace,
2106
+ region,
2107
+ fileId,
2108
+ verify
2109
+ }) {
2110
+ return operationsByTag.files.fileAccess({
2111
+ pathParams: {
2112
+ workspace,
2113
+ region,
2114
+ fileId
2115
+ },
2116
+ queryParams: { verify },
2117
+ ...this.extraProps
2118
+ });
2119
+ }
2120
+ }
2121
+ class SearchAndFilterApi {
2122
+ constructor(extraProps) {
2123
+ this.extraProps = extraProps;
2124
+ }
2125
+ queryTable({
2126
+ workspace,
2127
+ region,
2128
+ database,
2129
+ branch,
2130
+ table,
2131
+ filter,
2132
+ sort,
2133
+ page,
2134
+ columns,
2135
+ consistency
2136
+ }) {
2137
+ return operationsByTag.searchAndFilter.queryTable({
2138
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2139
+ body: { filter, sort, page, columns, consistency },
2140
+ ...this.extraProps
2141
+ });
2142
+ }
2143
+ searchTable({
2144
+ workspace,
2145
+ region,
2146
+ database,
2147
+ branch,
2148
+ table,
2149
+ query,
2150
+ fuzziness,
2151
+ target,
2152
+ prefix,
2153
+ filter,
2154
+ highlight,
2155
+ boosters
2156
+ }) {
2157
+ return operationsByTag.searchAndFilter.searchTable({
2158
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2159
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
2160
+ ...this.extraProps
2161
+ });
2162
+ }
2163
+ searchBranch({
2164
+ workspace,
2165
+ region,
2166
+ database,
2167
+ branch,
2168
+ tables,
2169
+ query,
2170
+ fuzziness,
2171
+ prefix,
2172
+ highlight
2173
+ }) {
2174
+ return operationsByTag.searchAndFilter.searchBranch({
2175
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2176
+ body: { tables, query, fuzziness, prefix, highlight },
2177
+ ...this.extraProps
2178
+ });
2179
+ }
2180
+ vectorSearchTable({
2181
+ workspace,
2182
+ region,
2183
+ database,
2184
+ branch,
2185
+ table,
2186
+ queryVector,
2187
+ column,
2188
+ similarityFunction,
2189
+ size,
2190
+ filter
2191
+ }) {
2192
+ return operationsByTag.searchAndFilter.vectorSearchTable({
2193
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2194
+ body: { queryVector, column, similarityFunction, size, filter },
2195
+ ...this.extraProps
2196
+ });
2197
+ }
2198
+ askTable({
2199
+ workspace,
2200
+ region,
2201
+ database,
2202
+ branch,
2203
+ table,
2204
+ options
2205
+ }) {
2206
+ return operationsByTag.searchAndFilter.askTable({
2207
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2208
+ body: { ...options },
2209
+ ...this.extraProps
2210
+ });
2211
+ }
2212
+ askTableSession({
2213
+ workspace,
2214
+ region,
2215
+ database,
2216
+ branch,
2217
+ table,
2218
+ sessionId,
2219
+ message
2220
+ }) {
2221
+ return operationsByTag.searchAndFilter.askTableSession({
2222
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
2223
+ body: { message },
2224
+ ...this.extraProps
2225
+ });
2226
+ }
2227
+ summarizeTable({
2228
+ workspace,
2229
+ region,
2230
+ database,
2231
+ branch,
2232
+ table,
2233
+ filter,
2234
+ columns,
2235
+ summaries,
2236
+ sort,
2237
+ summariesFilter,
2238
+ page,
2239
+ consistency
2240
+ }) {
2241
+ return operationsByTag.searchAndFilter.summarizeTable({
2242
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2243
+ body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
2244
+ ...this.extraProps
1578
2245
  });
1579
2246
  }
1580
2247
  aggregateTable({
@@ -1757,11 +2424,13 @@ class MigrationsApi {
1757
2424
  region,
1758
2425
  database,
1759
2426
  branch,
1760
- schema
2427
+ schema,
2428
+ schemaOperations,
2429
+ branchOperations
1761
2430
  }) {
1762
2431
  return operationsByTag.migrations.compareBranchWithUserSchema({
1763
2432
  pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1764
- body: { schema },
2433
+ body: { schema, schemaOperations, branchOperations },
1765
2434
  ...this.extraProps
1766
2435
  });
1767
2436
  }
@@ -1771,11 +2440,12 @@ class MigrationsApi {
1771
2440
  database,
1772
2441
  branch,
1773
2442
  compare,
1774
- schema
2443
+ sourceBranchOperations,
2444
+ targetBranchOperations
1775
2445
  }) {
1776
2446
  return operationsByTag.migrations.compareBranchSchemas({
1777
2447
  pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
1778
- body: { schema },
2448
+ body: { sourceBranchOperations, targetBranchOperations },
1779
2449
  ...this.extraProps
1780
2450
  });
1781
2451
  }
@@ -1818,6 +2488,19 @@ class MigrationsApi {
1818
2488
  ...this.extraProps
1819
2489
  });
1820
2490
  }
2491
+ pushBranchMigrations({
2492
+ workspace,
2493
+ region,
2494
+ database,
2495
+ branch,
2496
+ migrations
2497
+ }) {
2498
+ return operationsByTag.migrations.pushBranchMigrations({
2499
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2500
+ body: { migrations },
2501
+ ...this.extraProps
2502
+ });
2503
+ }
1821
2504
  }
1822
2505
  class DatabaseApi {
1823
2506
  constructor(extraProps) {
@@ -1832,11 +2515,13 @@ class DatabaseApi {
1832
2515
  createDatabase({
1833
2516
  workspace,
1834
2517
  database,
1835
- data
2518
+ data,
2519
+ headers
1836
2520
  }) {
1837
2521
  return operationsByTag.databases.createDatabase({
1838
2522
  pathParams: { workspaceId: workspace, dbName: database },
1839
2523
  body: data,
2524
+ headers,
1840
2525
  ...this.extraProps
1841
2526
  });
1842
2527
  }
@@ -1869,6 +2554,46 @@ class DatabaseApi {
1869
2554
  ...this.extraProps
1870
2555
  });
1871
2556
  }
2557
+ renameDatabase({
2558
+ workspace,
2559
+ database,
2560
+ newName
2561
+ }) {
2562
+ return operationsByTag.databases.renameDatabase({
2563
+ pathParams: { workspaceId: workspace, dbName: database },
2564
+ body: { newName },
2565
+ ...this.extraProps
2566
+ });
2567
+ }
2568
+ getDatabaseGithubSettings({
2569
+ workspace,
2570
+ database
2571
+ }) {
2572
+ return operationsByTag.databases.getDatabaseGithubSettings({
2573
+ pathParams: { workspaceId: workspace, dbName: database },
2574
+ ...this.extraProps
2575
+ });
2576
+ }
2577
+ updateDatabaseGithubSettings({
2578
+ workspace,
2579
+ database,
2580
+ settings
2581
+ }) {
2582
+ return operationsByTag.databases.updateDatabaseGithubSettings({
2583
+ pathParams: { workspaceId: workspace, dbName: database },
2584
+ body: settings,
2585
+ ...this.extraProps
2586
+ });
2587
+ }
2588
+ deleteDatabaseGithubSettings({
2589
+ workspace,
2590
+ database
2591
+ }) {
2592
+ return operationsByTag.databases.deleteDatabaseGithubSettings({
2593
+ pathParams: { workspaceId: workspace, dbName: database },
2594
+ ...this.extraProps
2595
+ });
2596
+ }
1872
2597
  listRegions({ workspace }) {
1873
2598
  return operationsByTag.databases.listRegions({
1874
2599
  pathParams: { workspaceId: workspace },
@@ -1878,29 +2603,269 @@ class DatabaseApi {
1878
2603
  }
1879
2604
 
1880
2605
  class XataApiPlugin {
1881
- async build(options) {
1882
- const { fetchImpl, apiKey } = await options.getFetchProps();
1883
- return new XataApiClient({ fetch: fetchImpl, apiKey });
2606
+ build(options) {
2607
+ return new XataApiClient(options);
1884
2608
  }
1885
2609
  }
1886
2610
 
1887
2611
  class XataPlugin {
1888
2612
  }
1889
2613
 
1890
- function generateUUID() {
1891
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
1892
- const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
1893
- return v.toString(16);
1894
- });
2614
+ class FilesPlugin extends XataPlugin {
2615
+ build(pluginOptions) {
2616
+ return {
2617
+ download: async (location) => {
2618
+ const { table, record, column, fileId = "" } = location ?? {};
2619
+ return await getFileItem({
2620
+ pathParams: {
2621
+ workspace: "{workspaceId}",
2622
+ dbBranchName: "{dbBranch}",
2623
+ region: "{region}",
2624
+ tableName: table ?? "",
2625
+ recordId: record ?? "",
2626
+ columnName: column ?? "",
2627
+ fileId
2628
+ },
2629
+ ...pluginOptions,
2630
+ rawResponse: true
2631
+ });
2632
+ },
2633
+ upload: async (location, file) => {
2634
+ const { table, record, column, fileId = "" } = location ?? {};
2635
+ return await putFileItem({
2636
+ pathParams: {
2637
+ workspace: "{workspaceId}",
2638
+ dbBranchName: "{dbBranch}",
2639
+ region: "{region}",
2640
+ tableName: table ?? "",
2641
+ recordId: record ?? "",
2642
+ columnName: column ?? "",
2643
+ fileId
2644
+ },
2645
+ body: file,
2646
+ ...pluginOptions
2647
+ });
2648
+ },
2649
+ delete: async (location) => {
2650
+ const { table, record, column, fileId = "" } = location ?? {};
2651
+ return await deleteFileItem({
2652
+ pathParams: {
2653
+ workspace: "{workspaceId}",
2654
+ dbBranchName: "{dbBranch}",
2655
+ region: "{region}",
2656
+ tableName: table ?? "",
2657
+ recordId: record ?? "",
2658
+ columnName: column ?? "",
2659
+ fileId
2660
+ },
2661
+ ...pluginOptions
2662
+ });
2663
+ }
2664
+ };
2665
+ }
2666
+ }
2667
+
2668
+ function buildTransformString(transformations) {
2669
+ return transformations.flatMap(
2670
+ (t) => Object.entries(t).map(([key, value]) => {
2671
+ if (key === "trim") {
2672
+ const { left = 0, top = 0, right = 0, bottom = 0 } = value;
2673
+ return `${key}=${[top, right, bottom, left].join(";")}`;
2674
+ }
2675
+ if (key === "gravity" && typeof value === "object") {
2676
+ const { x = 0.5, y = 0.5 } = value;
2677
+ return `${key}=${[x, y].join("x")}`;
2678
+ }
2679
+ return `${key}=${value}`;
2680
+ })
2681
+ ).join(",");
2682
+ }
2683
+ function transformImage(url, ...transformations) {
2684
+ if (!isDefined(url))
2685
+ return void 0;
2686
+ const transformationsString = buildTransformString(transformations);
2687
+ const { hostname, pathname, search } = new URL(url);
2688
+ return `https://${hostname}/transform/${transformationsString}${pathname}${search}`;
1895
2689
  }
1896
2690
 
2691
+ var __defProp$6 = Object.defineProperty;
2692
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2693
+ var __publicField$6 = (obj, key, value) => {
2694
+ __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
2695
+ return value;
2696
+ };
2697
+ class XataFile {
2698
+ constructor(file) {
2699
+ /**
2700
+ * Name of this file.
2701
+ */
2702
+ __publicField$6(this, "name");
2703
+ /**
2704
+ * Media type of this file.
2705
+ */
2706
+ __publicField$6(this, "mediaType");
2707
+ /**
2708
+ * Base64 encoded content of this file.
2709
+ */
2710
+ __publicField$6(this, "base64Content");
2711
+ /**
2712
+ * Whether to enable public url for this file.
2713
+ */
2714
+ __publicField$6(this, "enablePublicUrl");
2715
+ /**
2716
+ * Timeout for the signed url.
2717
+ */
2718
+ __publicField$6(this, "signedUrlTimeout");
2719
+ /**
2720
+ * Size of this file.
2721
+ */
2722
+ __publicField$6(this, "size");
2723
+ /**
2724
+ * Version of this file.
2725
+ */
2726
+ __publicField$6(this, "version");
2727
+ /**
2728
+ * Url of this file.
2729
+ */
2730
+ __publicField$6(this, "url");
2731
+ /**
2732
+ * Signed url of this file.
2733
+ */
2734
+ __publicField$6(this, "signedUrl");
2735
+ /**
2736
+ * Attributes of this file.
2737
+ */
2738
+ __publicField$6(this, "attributes");
2739
+ this.name = file.name || "";
2740
+ this.mediaType = file.mediaType || "application/octet-stream";
2741
+ this.base64Content = file.base64Content;
2742
+ this.enablePublicUrl = file.enablePublicUrl ?? false;
2743
+ this.signedUrlTimeout = file.signedUrlTimeout ?? 300;
2744
+ this.size = file.size ?? 0;
2745
+ this.version = file.version ?? 1;
2746
+ this.url = file.url || "";
2747
+ this.signedUrl = file.signedUrl;
2748
+ this.attributes = file.attributes || {};
2749
+ }
2750
+ static fromBuffer(buffer, options = {}) {
2751
+ const base64Content = buffer.toString("base64");
2752
+ return new XataFile({ ...options, base64Content });
2753
+ }
2754
+ toBuffer() {
2755
+ if (!this.base64Content) {
2756
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2757
+ }
2758
+ return Buffer.from(this.base64Content, "base64");
2759
+ }
2760
+ static fromArrayBuffer(arrayBuffer, options = {}) {
2761
+ const uint8Array = new Uint8Array(arrayBuffer);
2762
+ return this.fromUint8Array(uint8Array, options);
2763
+ }
2764
+ toArrayBuffer() {
2765
+ if (!this.base64Content) {
2766
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2767
+ }
2768
+ const binary = atob(this.base64Content);
2769
+ return new ArrayBuffer(binary.length);
2770
+ }
2771
+ static fromUint8Array(uint8Array, options = {}) {
2772
+ let binary = "";
2773
+ for (let i = 0; i < uint8Array.byteLength; i++) {
2774
+ binary += String.fromCharCode(uint8Array[i]);
2775
+ }
2776
+ const base64Content = btoa(binary);
2777
+ return new XataFile({ ...options, base64Content });
2778
+ }
2779
+ toUint8Array() {
2780
+ if (!this.base64Content) {
2781
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2782
+ }
2783
+ const binary = atob(this.base64Content);
2784
+ const uint8Array = new Uint8Array(binary.length);
2785
+ for (let i = 0; i < binary.length; i++) {
2786
+ uint8Array[i] = binary.charCodeAt(i);
2787
+ }
2788
+ return uint8Array;
2789
+ }
2790
+ static async fromBlob(file, options = {}) {
2791
+ const name = options.name ?? file.name;
2792
+ const mediaType = file.type;
2793
+ const arrayBuffer = await file.arrayBuffer();
2794
+ return this.fromArrayBuffer(arrayBuffer, { ...options, name, mediaType });
2795
+ }
2796
+ toBlob() {
2797
+ if (!this.base64Content) {
2798
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2799
+ }
2800
+ const arrayBuffer = this.toArrayBuffer();
2801
+ return new Blob([arrayBuffer], { type: this.mediaType });
2802
+ }
2803
+ static fromString(string, options = {}) {
2804
+ const base64Content = btoa(string);
2805
+ return new XataFile({ ...options, base64Content });
2806
+ }
2807
+ toString() {
2808
+ if (!this.base64Content) {
2809
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2810
+ }
2811
+ return atob(this.base64Content);
2812
+ }
2813
+ static fromBase64(base64Content, options = {}) {
2814
+ return new XataFile({ ...options, base64Content });
2815
+ }
2816
+ toBase64() {
2817
+ if (!this.base64Content) {
2818
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2819
+ }
2820
+ return this.base64Content;
2821
+ }
2822
+ transform(...options) {
2823
+ return {
2824
+ url: transformImage(this.url, ...options),
2825
+ signedUrl: transformImage(this.signedUrl, ...options)
2826
+ };
2827
+ }
2828
+ }
2829
+ const parseInputFileEntry = async (entry) => {
2830
+ if (!isDefined(entry))
2831
+ return null;
2832
+ const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
2833
+ return compactObject({ id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout });
2834
+ };
2835
+
1897
2836
  function cleanFilter(filter) {
1898
- if (!filter)
2837
+ if (!isDefined(filter))
1899
2838
  return void 0;
1900
- const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
1901
- return values.length > 0 ? filter : void 0;
2839
+ if (!isObject(filter))
2840
+ return filter;
2841
+ const values = Object.fromEntries(
2842
+ Object.entries(filter).reduce((acc, [key, value]) => {
2843
+ if (!isDefined(value))
2844
+ return acc;
2845
+ if (Array.isArray(value)) {
2846
+ const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
2847
+ if (clean.length === 0)
2848
+ return acc;
2849
+ return [...acc, [key, clean]];
2850
+ }
2851
+ if (isObject(value)) {
2852
+ const clean = cleanFilter(value);
2853
+ if (!isDefined(clean))
2854
+ return acc;
2855
+ return [...acc, [key, clean]];
2856
+ }
2857
+ return [...acc, [key, value]];
2858
+ }, [])
2859
+ );
2860
+ return Object.keys(values).length > 0 ? values : void 0;
1902
2861
  }
1903
2862
 
2863
+ var __defProp$5 = Object.defineProperty;
2864
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2865
+ var __publicField$5 = (obj, key, value) => {
2866
+ __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
2867
+ return value;
2868
+ };
1904
2869
  var __accessCheck$6 = (obj, member, msg) => {
1905
2870
  if (!member.has(obj))
1906
2871
  throw TypeError("Cannot " + msg);
@@ -1923,22 +2888,58 @@ var _query, _page;
1923
2888
  class Page {
1924
2889
  constructor(query, meta, records = []) {
1925
2890
  __privateAdd$6(this, _query, void 0);
2891
+ /**
2892
+ * Page metadata, required to retrieve additional records.
2893
+ */
2894
+ __publicField$5(this, "meta");
2895
+ /**
2896
+ * The set of results for this page.
2897
+ */
2898
+ __publicField$5(this, "records");
1926
2899
  __privateSet$6(this, _query, query);
1927
2900
  this.meta = meta;
1928
2901
  this.records = new RecordArray(this, records);
1929
2902
  }
2903
+ /**
2904
+ * Retrieves the next page of results.
2905
+ * @param size Maximum number of results to be retrieved.
2906
+ * @param offset Number of results to skip when retrieving the results.
2907
+ * @returns The next page or results.
2908
+ */
1930
2909
  async nextPage(size, offset) {
1931
2910
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
1932
2911
  }
2912
+ /**
2913
+ * Retrieves the previous page of results.
2914
+ * @param size Maximum number of results to be retrieved.
2915
+ * @param offset Number of results to skip when retrieving the results.
2916
+ * @returns The previous page or results.
2917
+ */
1933
2918
  async previousPage(size, offset) {
1934
2919
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
1935
2920
  }
2921
+ /**
2922
+ * Retrieves the start page of results.
2923
+ * @param size Maximum number of results to be retrieved.
2924
+ * @param offset Number of results to skip when retrieving the results.
2925
+ * @returns The start page or results.
2926
+ */
1936
2927
  async startPage(size, offset) {
1937
2928
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
1938
2929
  }
2930
+ /**
2931
+ * Retrieves the end page of results.
2932
+ * @param size Maximum number of results to be retrieved.
2933
+ * @param offset Number of results to skip when retrieving the results.
2934
+ * @returns The end page or results.
2935
+ */
1939
2936
  async endPage(size, offset) {
1940
2937
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
1941
2938
  }
2939
+ /**
2940
+ * Shortcut method to check if there will be additional results if the next page of results is retrieved.
2941
+ * @returns Whether or not there will be additional results in the next page of results.
2942
+ */
1942
2943
  hasNextPage() {
1943
2944
  return this.meta.page.more;
1944
2945
  }
@@ -1951,7 +2952,7 @@ const PAGINATION_DEFAULT_OFFSET = 0;
1951
2952
  function isCursorPaginationOptions(options) {
1952
2953
  return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
1953
2954
  }
1954
- const _RecordArray = class extends Array {
2955
+ const _RecordArray = class _RecordArray extends Array {
1955
2956
  constructor(...args) {
1956
2957
  super(..._RecordArray.parseConstructorParams(...args));
1957
2958
  __privateAdd$6(this, _page, void 0);
@@ -1970,32 +2971,67 @@ const _RecordArray = class extends Array {
1970
2971
  toArray() {
1971
2972
  return new Array(...this);
1972
2973
  }
2974
+ toSerializable() {
2975
+ return JSON.parse(this.toString());
2976
+ }
2977
+ toString() {
2978
+ return JSON.stringify(this.toArray());
2979
+ }
1973
2980
  map(callbackfn, thisArg) {
1974
2981
  return this.toArray().map(callbackfn, thisArg);
1975
2982
  }
2983
+ /**
2984
+ * Retrieve next page of records
2985
+ *
2986
+ * @returns A new array of objects
2987
+ */
1976
2988
  async nextPage(size, offset) {
1977
2989
  const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
1978
2990
  return new _RecordArray(newPage);
1979
2991
  }
2992
+ /**
2993
+ * Retrieve previous page of records
2994
+ *
2995
+ * @returns A new array of objects
2996
+ */
1980
2997
  async previousPage(size, offset) {
1981
2998
  const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
1982
2999
  return new _RecordArray(newPage);
1983
3000
  }
3001
+ /**
3002
+ * Retrieve start page of records
3003
+ *
3004
+ * @returns A new array of objects
3005
+ */
1984
3006
  async startPage(size, offset) {
1985
3007
  const newPage = await __privateGet$6(this, _page).startPage(size, offset);
1986
3008
  return new _RecordArray(newPage);
1987
3009
  }
3010
+ /**
3011
+ * Retrieve end page of records
3012
+ *
3013
+ * @returns A new array of objects
3014
+ */
1988
3015
  async endPage(size, offset) {
1989
3016
  const newPage = await __privateGet$6(this, _page).endPage(size, offset);
1990
3017
  return new _RecordArray(newPage);
1991
3018
  }
3019
+ /**
3020
+ * @returns Boolean indicating if there is a next page
3021
+ */
1992
3022
  hasNextPage() {
1993
3023
  return __privateGet$6(this, _page).meta.page.more;
1994
3024
  }
1995
3025
  };
1996
- let RecordArray = _RecordArray;
1997
3026
  _page = new WeakMap();
3027
+ let RecordArray = _RecordArray;
1998
3028
 
3029
+ var __defProp$4 = Object.defineProperty;
3030
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3031
+ var __publicField$4 = (obj, key, value) => {
3032
+ __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
3033
+ return value;
3034
+ };
1999
3035
  var __accessCheck$5 = (obj, member, msg) => {
2000
3036
  if (!member.has(obj))
2001
3037
  throw TypeError("Cannot " + msg);
@@ -2019,14 +3055,15 @@ var __privateMethod$3 = (obj, member, method) => {
2019
3055
  return method;
2020
3056
  };
2021
3057
  var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
2022
- const _Query = class {
3058
+ const _Query = class _Query {
2023
3059
  constructor(repository, table, data, rawParent) {
2024
3060
  __privateAdd$5(this, _cleanFilterConstraint);
2025
3061
  __privateAdd$5(this, _table$1, void 0);
2026
3062
  __privateAdd$5(this, _repository, void 0);
2027
3063
  __privateAdd$5(this, _data, { filter: {} });
2028
- this.meta = { page: { cursor: "start", more: true } };
2029
- this.records = new RecordArray(this, []);
3064
+ // Implements pagination
3065
+ __publicField$4(this, "meta", { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } });
3066
+ __publicField$4(this, "records", new RecordArray(this, []));
2030
3067
  __privateSet$5(this, _table$1, table);
2031
3068
  if (repository) {
2032
3069
  __privateSet$5(this, _repository, repository);
@@ -2041,6 +3078,7 @@ const _Query = class {
2041
3078
  __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
2042
3079
  __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
2043
3080
  __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
3081
+ __privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
2044
3082
  __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
2045
3083
  __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
2046
3084
  __privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
@@ -2061,18 +3099,38 @@ const _Query = class {
2061
3099
  const key = JSON.stringify({ columns, filter, sort, pagination });
2062
3100
  return toBase64(key);
2063
3101
  }
3102
+ /**
3103
+ * Builds a new query object representing a logical OR between the given subqueries.
3104
+ * @param queries An array of subqueries.
3105
+ * @returns A new Query object.
3106
+ */
2064
3107
  any(...queries) {
2065
3108
  const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
2066
3109
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
2067
3110
  }
3111
+ /**
3112
+ * Builds a new query object representing a logical AND between the given subqueries.
3113
+ * @param queries An array of subqueries.
3114
+ * @returns A new Query object.
3115
+ */
2068
3116
  all(...queries) {
2069
3117
  const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
2070
3118
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
2071
3119
  }
3120
+ /**
3121
+ * Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
3122
+ * @param queries An array of subqueries.
3123
+ * @returns A new Query object.
3124
+ */
2072
3125
  not(...queries) {
2073
3126
  const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
2074
3127
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
2075
3128
  }
3129
+ /**
3130
+ * Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
3131
+ * @param queries An array of subqueries.
3132
+ * @returns A new Query object.
3133
+ */
2076
3134
  none(...queries) {
2077
3135
  const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
2078
3136
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
@@ -2095,6 +3153,11 @@ const _Query = class {
2095
3153
  const sort = [...originalSort, { column, direction }];
2096
3154
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
2097
3155
  }
3156
+ /**
3157
+ * Builds a new query specifying the set of columns to be returned in the query response.
3158
+ * @param columns Array of column names to be returned by the query.
3159
+ * @returns A new Query object.
3160
+ */
2098
3161
  select(columns) {
2099
3162
  return new _Query(
2100
3163
  __privateGet$5(this, _repository),
@@ -2107,6 +3170,12 @@ const _Query = class {
2107
3170
  const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
2108
3171
  return __privateGet$5(this, _repository).query(query);
2109
3172
  }
3173
+ /**
3174
+ * Get results in an iterator
3175
+ *
3176
+ * @async
3177
+ * @returns Async interable of results
3178
+ */
2110
3179
  async *[Symbol.asyncIterator]() {
2111
3180
  for await (const [record] of this.getIterator({ batchSize: 1 })) {
2112
3181
  yield record;
@@ -2167,26 +3236,53 @@ const _Query = class {
2167
3236
  );
2168
3237
  return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
2169
3238
  }
3239
+ /**
3240
+ * Builds a new query object adding a cache TTL in milliseconds.
3241
+ * @param ttl The cache TTL in milliseconds.
3242
+ * @returns A new Query object.
3243
+ */
2170
3244
  cache(ttl) {
2171
3245
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
2172
3246
  }
3247
+ /**
3248
+ * Retrieve next page of records
3249
+ *
3250
+ * @returns A new page object.
3251
+ */
2173
3252
  nextPage(size, offset) {
2174
3253
  return this.startPage(size, offset);
2175
3254
  }
3255
+ /**
3256
+ * Retrieve previous page of records
3257
+ *
3258
+ * @returns A new page object
3259
+ */
2176
3260
  previousPage(size, offset) {
2177
3261
  return this.startPage(size, offset);
2178
3262
  }
3263
+ /**
3264
+ * Retrieve start page of records
3265
+ *
3266
+ * @returns A new page object
3267
+ */
2179
3268
  startPage(size, offset) {
2180
3269
  return this.getPaginated({ pagination: { size, offset } });
2181
3270
  }
3271
+ /**
3272
+ * Retrieve last page of records
3273
+ *
3274
+ * @returns A new page object
3275
+ */
2182
3276
  endPage(size, offset) {
2183
3277
  return this.getPaginated({ pagination: { size, offset, before: "end" } });
2184
3278
  }
3279
+ /**
3280
+ * @returns Boolean indicating if there is a next page
3281
+ */
2185
3282
  hasNextPage() {
2186
3283
  return this.meta.page.more;
2187
3284
  }
2188
3285
  };
2189
- let Query = _Query;
2190
3286
  _table$1 = new WeakMap();
2191
3287
  _repository = new WeakMap();
2192
3288
  _data = new WeakMap();
@@ -2201,6 +3297,7 @@ cleanFilterConstraint_fn = function(column, value) {
2201
3297
  }
2202
3298
  return value;
2203
3299
  };
3300
+ let Query = _Query;
2204
3301
  function cleanParent(data, parent) {
2205
3302
  if (isCursorPaginationOptions(data.pagination)) {
2206
3303
  return { ...parent, sort: void 0, filter: void 0 };
@@ -2208,6 +3305,22 @@ function cleanParent(data, parent) {
2208
3305
  return parent;
2209
3306
  }
2210
3307
 
3308
+ const RecordColumnTypes = [
3309
+ "bool",
3310
+ "int",
3311
+ "float",
3312
+ "string",
3313
+ "text",
3314
+ "email",
3315
+ "multiple",
3316
+ "link",
3317
+ "object",
3318
+ "datetime",
3319
+ "vector",
3320
+ "file[]",
3321
+ "file",
3322
+ "json"
3323
+ ];
2211
3324
  function isIdentifiable(x) {
2212
3325
  return isObject(x) && isString(x?.id);
2213
3326
  }
@@ -2221,7 +3334,11 @@ function isSortFilterString(value) {
2221
3334
  return isString(value);
2222
3335
  }
2223
3336
  function isSortFilterBase(filter) {
2224
- return isObject(filter) && Object.values(filter).every((value) => value === "asc" || value === "desc");
3337
+ return isObject(filter) && Object.entries(filter).every(([key, value]) => {
3338
+ if (key === "*")
3339
+ return value === "random";
3340
+ return value === "asc" || value === "desc";
3341
+ });
2225
3342
  }
2226
3343
  function isSortFilterObject(filter) {
2227
3344
  return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
@@ -2262,7 +3379,7 @@ var __privateMethod$2 = (obj, member, method) => {
2262
3379
  __accessCheck$4(obj, member, "access private method");
2263
3380
  return method;
2264
3381
  };
2265
- 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;
3382
+ 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;
2266
3383
  const BULK_OPERATION_MAX_SIZE = 1e3;
2267
3384
  class Repository extends Query {
2268
3385
  }
@@ -2284,6 +3401,7 @@ class RestRepository extends Query {
2284
3401
  __privateAdd$4(this, _setCacheQuery);
2285
3402
  __privateAdd$4(this, _getCacheQuery);
2286
3403
  __privateAdd$4(this, _getSchemaTables$1);
3404
+ __privateAdd$4(this, _transformObjectToApi);
2287
3405
  __privateAdd$4(this, _table, void 0);
2288
3406
  __privateAdd$4(this, _getFetchProps, void 0);
2289
3407
  __privateAdd$4(this, _db, void 0);
@@ -2294,10 +3412,7 @@ class RestRepository extends Query {
2294
3412
  __privateSet$4(this, _db, options.db);
2295
3413
  __privateSet$4(this, _cache, options.pluginOptions.cache);
2296
3414
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
2297
- __privateSet$4(this, _getFetchProps, async () => {
2298
- const props = await options.pluginOptions.getFetchProps();
2299
- return { ...props, sessionID: generateUUID() };
2300
- });
3415
+ __privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
2301
3416
  const trace = options.pluginOptions.trace ?? defaultTrace;
2302
3417
  __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
2303
3418
  return trace(name, fn, {
@@ -2354,7 +3469,6 @@ class RestRepository extends Query {
2354
3469
  }
2355
3470
  const id = extractId(a);
2356
3471
  if (id) {
2357
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2358
3472
  try {
2359
3473
  const response = await getRecord({
2360
3474
  pathParams: {
@@ -2365,7 +3479,7 @@ class RestRepository extends Query {
2365
3479
  recordId: id
2366
3480
  },
2367
3481
  queryParams: { columns },
2368
- ...fetchProps
3482
+ ...__privateGet$4(this, _getFetchProps).call(this)
2369
3483
  });
2370
3484
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2371
3485
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
@@ -2414,13 +3528,19 @@ class RestRepository extends Query {
2414
3528
  const result = await this.read(a, columns);
2415
3529
  return result;
2416
3530
  }
2417
- if (isString(a) && isObject(b)) {
2418
- const columns = isStringArray(c) ? c : void 0;
2419
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2420
- }
2421
- if (isObject(a) && isString(a.id)) {
2422
- const columns = isStringArray(b) ? b : void 0;
2423
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3531
+ try {
3532
+ if (isString(a) && isObject(b)) {
3533
+ const columns = isStringArray(c) ? c : void 0;
3534
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
3535
+ }
3536
+ if (isObject(a) && isString(a.id)) {
3537
+ const columns = isStringArray(b) ? b : void 0;
3538
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3539
+ }
3540
+ } catch (error) {
3541
+ if (error.status === 422)
3542
+ return null;
3543
+ throw error;
2424
3544
  }
2425
3545
  throw new Error("Invalid arguments for update method");
2426
3546
  });
@@ -2459,12 +3579,22 @@ class RestRepository extends Query {
2459
3579
  return result;
2460
3580
  }
2461
3581
  if (isString(a) && isObject(b)) {
3582
+ if (a === "")
3583
+ throw new Error("The id can't be empty");
2462
3584
  const columns = isStringArray(c) ? c : void 0;
2463
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
3585
+ return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2464
3586
  }
2465
3587
  if (isObject(a) && isString(a.id)) {
3588
+ if (a.id === "")
3589
+ throw new Error("The id can't be empty");
2466
3590
  const columns = isStringArray(c) ? c : void 0;
2467
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3591
+ return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3592
+ }
3593
+ if (!isDefined(a) && isObject(b)) {
3594
+ return await this.create(b, c);
3595
+ }
3596
+ if (isObject(a) && !isDefined(a.id)) {
3597
+ return await this.create(a, b);
2468
3598
  }
2469
3599
  throw new Error("Invalid arguments for createOrUpdate method");
2470
3600
  });
@@ -2481,12 +3611,22 @@ class RestRepository extends Query {
2481
3611
  return result;
2482
3612
  }
2483
3613
  if (isString(a) && isObject(b)) {
3614
+ if (a === "")
3615
+ throw new Error("The id can't be empty");
2484
3616
  const columns = isStringArray(c) ? c : void 0;
2485
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
3617
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
2486
3618
  }
2487
3619
  if (isObject(a) && isString(a.id)) {
3620
+ if (a.id === "")
3621
+ throw new Error("The id can't be empty");
2488
3622
  const columns = isStringArray(c) ? c : void 0;
2489
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
3623
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
3624
+ }
3625
+ if (!isDefined(a) && isObject(b)) {
3626
+ return await this.create(b, c);
3627
+ }
3628
+ if (isObject(a) && !isDefined(a.id)) {
3629
+ return await this.create(a, b);
2490
3630
  }
2491
3631
  throw new Error("Invalid arguments for createOrReplace method");
2492
3632
  });
@@ -2537,7 +3677,6 @@ class RestRepository extends Query {
2537
3677
  }
2538
3678
  async search(query, options = {}) {
2539
3679
  return __privateGet$4(this, _trace).call(this, "search", async () => {
2540
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2541
3680
  const { records } = await searchTable({
2542
3681
  pathParams: {
2543
3682
  workspace: "{workspaceId}",
@@ -2551,9 +3690,33 @@ class RestRepository extends Query {
2551
3690
  prefix: options.prefix,
2552
3691
  highlight: options.highlight,
2553
3692
  filter: options.filter,
2554
- boosters: options.boosters
3693
+ boosters: options.boosters,
3694
+ page: options.page,
3695
+ target: options.target
2555
3696
  },
2556
- ...fetchProps
3697
+ ...__privateGet$4(this, _getFetchProps).call(this)
3698
+ });
3699
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3700
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3701
+ });
3702
+ }
3703
+ async vectorSearch(column, query, options) {
3704
+ return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
3705
+ const { records } = await vectorSearchTable({
3706
+ pathParams: {
3707
+ workspace: "{workspaceId}",
3708
+ dbBranchName: "{dbBranch}",
3709
+ region: "{region}",
3710
+ tableName: __privateGet$4(this, _table)
3711
+ },
3712
+ body: {
3713
+ column,
3714
+ queryVector: query,
3715
+ similarityFunction: options?.similarityFunction,
3716
+ size: options?.size,
3717
+ filter: options?.filter
3718
+ },
3719
+ ...__privateGet$4(this, _getFetchProps).call(this)
2557
3720
  });
2558
3721
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2559
3722
  return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
@@ -2561,7 +3724,6 @@ class RestRepository extends Query {
2561
3724
  }
2562
3725
  async aggregate(aggs, filter) {
2563
3726
  return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
2564
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2565
3727
  const result = await aggregateTable({
2566
3728
  pathParams: {
2567
3729
  workspace: "{workspaceId}",
@@ -2570,7 +3732,7 @@ class RestRepository extends Query {
2570
3732
  tableName: __privateGet$4(this, _table)
2571
3733
  },
2572
3734
  body: { aggs, filter },
2573
- ...fetchProps
3735
+ ...__privateGet$4(this, _getFetchProps).call(this)
2574
3736
  });
2575
3737
  return result;
2576
3738
  });
@@ -2581,7 +3743,6 @@ class RestRepository extends Query {
2581
3743
  if (cacheQuery)
2582
3744
  return new Page(query, cacheQuery.meta, cacheQuery.records);
2583
3745
  const data = query.getQueryOptions();
2584
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2585
3746
  const { meta, records: objects } = await queryTable({
2586
3747
  pathParams: {
2587
3748
  workspace: "{workspaceId}",
@@ -2593,10 +3754,11 @@ class RestRepository extends Query {
2593
3754
  filter: cleanFilter(data.filter),
2594
3755
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2595
3756
  page: data.pagination,
2596
- columns: data.columns ?? ["*"]
3757
+ columns: data.columns ?? ["*"],
3758
+ consistency: data.consistency
2597
3759
  },
2598
3760
  fetchOptions: data.fetchOptions,
2599
- ...fetchProps
3761
+ ...__privateGet$4(this, _getFetchProps).call(this)
2600
3762
  });
2601
3763
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2602
3764
  const records = objects.map(
@@ -2609,7 +3771,6 @@ class RestRepository extends Query {
2609
3771
  async summarizeTable(query, summaries, summariesFilter) {
2610
3772
  return __privateGet$4(this, _trace).call(this, "summarize", async () => {
2611
3773
  const data = query.getQueryOptions();
2612
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2613
3774
  const result = await summarizeTable({
2614
3775
  pathParams: {
2615
3776
  workspace: "{workspaceId}",
@@ -2621,15 +3782,49 @@ class RestRepository extends Query {
2621
3782
  filter: cleanFilter(data.filter),
2622
3783
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2623
3784
  columns: data.columns,
3785
+ consistency: data.consistency,
2624
3786
  page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
2625
3787
  summaries,
2626
3788
  summariesFilter
2627
3789
  },
2628
- ...fetchProps
3790
+ ...__privateGet$4(this, _getFetchProps).call(this)
2629
3791
  });
2630
3792
  return result;
2631
3793
  });
2632
3794
  }
3795
+ ask(question, options) {
3796
+ const questionParam = options?.sessionId ? { message: question } : { question };
3797
+ const params = {
3798
+ pathParams: {
3799
+ workspace: "{workspaceId}",
3800
+ dbBranchName: "{dbBranch}",
3801
+ region: "{region}",
3802
+ tableName: __privateGet$4(this, _table),
3803
+ sessionId: options?.sessionId
3804
+ },
3805
+ body: {
3806
+ ...questionParam,
3807
+ rules: options?.rules,
3808
+ searchType: options?.searchType,
3809
+ search: options?.searchType === "keyword" ? options?.search : void 0,
3810
+ vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
3811
+ },
3812
+ ...__privateGet$4(this, _getFetchProps).call(this)
3813
+ };
3814
+ if (options?.onMessage) {
3815
+ fetchSSERequest({
3816
+ endpoint: "dataPlane",
3817
+ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
3818
+ method: "POST",
3819
+ onMessage: (message) => {
3820
+ options.onMessage?.({ answer: message.text, records: message.records });
3821
+ },
3822
+ ...params
3823
+ });
3824
+ } else {
3825
+ return askTableSession(params);
3826
+ }
3827
+ }
2633
3828
  }
2634
3829
  _table = new WeakMap();
2635
3830
  _getFetchProps = new WeakMap();
@@ -2639,8 +3834,7 @@ _schemaTables$2 = new WeakMap();
2639
3834
  _trace = new WeakMap();
2640
3835
  _insertRecordWithoutId = new WeakSet();
2641
3836
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
2642
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2643
- const record = transformObjectLinks(object);
3837
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
2644
3838
  const response = await insertRecord({
2645
3839
  pathParams: {
2646
3840
  workspace: "{workspaceId}",
@@ -2650,15 +3844,16 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
2650
3844
  },
2651
3845
  queryParams: { columns },
2652
3846
  body: record,
2653
- ...fetchProps
3847
+ ...__privateGet$4(this, _getFetchProps).call(this)
2654
3848
  });
2655
3849
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2656
3850
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2657
3851
  };
2658
3852
  _insertRecordWithId = new WeakSet();
2659
3853
  insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
2660
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2661
- const record = transformObjectLinks(object);
3854
+ if (!recordId)
3855
+ return null;
3856
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
2662
3857
  const response = await insertRecordWithID({
2663
3858
  pathParams: {
2664
3859
  workspace: "{workspaceId}",
@@ -2669,30 +3864,28 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
2669
3864
  },
2670
3865
  body: record,
2671
3866
  queryParams: { createOnly, columns, ifVersion },
2672
- ...fetchProps
3867
+ ...__privateGet$4(this, _getFetchProps).call(this)
2673
3868
  });
2674
3869
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2675
3870
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2676
3871
  };
2677
3872
  _insertRecords = new WeakSet();
2678
3873
  insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
2679
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2680
- const chunkedOperations = chunk(
2681
- objects.map((object) => ({
2682
- insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
2683
- })),
2684
- BULK_OPERATION_MAX_SIZE
2685
- );
3874
+ const operations = await promiseMap(objects, async (object) => {
3875
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3876
+ return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
3877
+ });
3878
+ const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
2686
3879
  const ids = [];
2687
- for (const operations of chunkedOperations) {
3880
+ for (const operations2 of chunkedOperations) {
2688
3881
  const { results } = await branchTransaction({
2689
3882
  pathParams: {
2690
3883
  workspace: "{workspaceId}",
2691
3884
  dbBranchName: "{dbBranch}",
2692
3885
  region: "{region}"
2693
3886
  },
2694
- body: { operations },
2695
- ...fetchProps
3887
+ body: { operations: operations2 },
3888
+ ...__privateGet$4(this, _getFetchProps).call(this)
2696
3889
  });
2697
3890
  for (const result of results) {
2698
3891
  if (result.operation === "insert") {
@@ -2706,8 +3899,9 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
2706
3899
  };
2707
3900
  _updateRecordWithID = new WeakSet();
2708
3901
  updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
2709
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2710
- const { id: _id, ...record } = transformObjectLinks(object);
3902
+ if (!recordId)
3903
+ return null;
3904
+ const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
2711
3905
  try {
2712
3906
  const response = await updateRecordWithID({
2713
3907
  pathParams: {
@@ -2719,7 +3913,7 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
2719
3913
  },
2720
3914
  queryParams: { columns, ifVersion },
2721
3915
  body: record,
2722
- ...fetchProps
3916
+ ...__privateGet$4(this, _getFetchProps).call(this)
2723
3917
  });
2724
3918
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2725
3919
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
@@ -2732,23 +3926,21 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
2732
3926
  };
2733
3927
  _updateRecords = new WeakSet();
2734
3928
  updateRecords_fn = async function(objects, { ifVersion, upsert }) {
2735
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2736
- const chunkedOperations = chunk(
2737
- objects.map(({ id, ...object }) => ({
2738
- update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
2739
- })),
2740
- BULK_OPERATION_MAX_SIZE
2741
- );
3929
+ const operations = await promiseMap(objects, async ({ id, ...object }) => {
3930
+ const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3931
+ return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
3932
+ });
3933
+ const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
2742
3934
  const ids = [];
2743
- for (const operations of chunkedOperations) {
3935
+ for (const operations2 of chunkedOperations) {
2744
3936
  const { results } = await branchTransaction({
2745
3937
  pathParams: {
2746
3938
  workspace: "{workspaceId}",
2747
3939
  dbBranchName: "{dbBranch}",
2748
3940
  region: "{region}"
2749
3941
  },
2750
- body: { operations },
2751
- ...fetchProps
3942
+ body: { operations: operations2 },
3943
+ ...__privateGet$4(this, _getFetchProps).call(this)
2752
3944
  });
2753
3945
  for (const result of results) {
2754
3946
  if (result.operation === "update") {
@@ -2762,7 +3954,8 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
2762
3954
  };
2763
3955
  _upsertRecordWithID = new WeakSet();
2764
3956
  upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
2765
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
3957
+ if (!recordId)
3958
+ return null;
2766
3959
  const response = await upsertRecordWithID({
2767
3960
  pathParams: {
2768
3961
  workspace: "{workspaceId}",
@@ -2773,14 +3966,15 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
2773
3966
  },
2774
3967
  queryParams: { columns, ifVersion },
2775
3968
  body: object,
2776
- ...fetchProps
3969
+ ...__privateGet$4(this, _getFetchProps).call(this)
2777
3970
  });
2778
3971
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2779
3972
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2780
3973
  };
2781
3974
  _deleteRecord = new WeakSet();
2782
3975
  deleteRecord_fn = async function(recordId, columns = ["*"]) {
2783
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
3976
+ if (!recordId)
3977
+ return null;
2784
3978
  try {
2785
3979
  const response = await deleteRecord({
2786
3980
  pathParams: {
@@ -2791,7 +3985,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
2791
3985
  recordId
2792
3986
  },
2793
3987
  queryParams: { columns },
2794
- ...fetchProps
3988
+ ...__privateGet$4(this, _getFetchProps).call(this)
2795
3989
  });
2796
3990
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2797
3991
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
@@ -2804,9 +3998,8 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
2804
3998
  };
2805
3999
  _deleteRecords = new WeakSet();
2806
4000
  deleteRecords_fn = async function(recordIds) {
2807
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2808
4001
  const chunkedOperations = chunk(
2809
- recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
4002
+ compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
2810
4003
  BULK_OPERATION_MAX_SIZE
2811
4004
  );
2812
4005
  for (const operations of chunkedOperations) {
@@ -2817,21 +4010,22 @@ deleteRecords_fn = async function(recordIds) {
2817
4010
  region: "{region}"
2818
4011
  },
2819
4012
  body: { operations },
2820
- ...fetchProps
4013
+ ...__privateGet$4(this, _getFetchProps).call(this)
2821
4014
  });
2822
4015
  }
2823
4016
  };
2824
4017
  _setCacheQuery = new WeakSet();
2825
4018
  setCacheQuery_fn = async function(query, meta, records) {
2826
- await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
4019
+ await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
2827
4020
  };
2828
4021
  _getCacheQuery = new WeakSet();
2829
4022
  getCacheQuery_fn = async function(query) {
2830
4023
  const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
2831
- const result = await __privateGet$4(this, _cache).get(key);
4024
+ const result = await __privateGet$4(this, _cache)?.get(key);
2832
4025
  if (!result)
2833
4026
  return null;
2834
- const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
4027
+ const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
4028
+ const { cache: ttl = defaultTTL } = query.getQueryOptions();
2835
4029
  if (ttl < 0)
2836
4030
  return null;
2837
4031
  const hasExpired = result.date.getTime() + ttl < Date.now();
@@ -2841,15 +4035,46 @@ _getSchemaTables$1 = new WeakSet();
2841
4035
  getSchemaTables_fn$1 = async function() {
2842
4036
  if (__privateGet$4(this, _schemaTables$2))
2843
4037
  return __privateGet$4(this, _schemaTables$2);
2844
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2845
4038
  const { schema } = await getBranchDetails({
2846
4039
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2847
- ...fetchProps
4040
+ ...__privateGet$4(this, _getFetchProps).call(this)
2848
4041
  });
2849
4042
  __privateSet$4(this, _schemaTables$2, schema.tables);
2850
4043
  return schema.tables;
2851
4044
  };
2852
- const transformObjectLinks = (object) => {
4045
+ _transformObjectToApi = new WeakSet();
4046
+ transformObjectToApi_fn = async function(object) {
4047
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
4048
+ const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
4049
+ if (!schema)
4050
+ throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
4051
+ const result = {};
4052
+ for (const [key, value] of Object.entries(object)) {
4053
+ if (key === "xata")
4054
+ continue;
4055
+ const type = schema.columns.find((column) => column.name === key)?.type;
4056
+ switch (type) {
4057
+ case "link": {
4058
+ result[key] = isIdentifiable(value) ? value.id : value;
4059
+ break;
4060
+ }
4061
+ case "datetime": {
4062
+ result[key] = value instanceof Date ? value.toISOString() : value;
4063
+ break;
4064
+ }
4065
+ case `file`:
4066
+ result[key] = await parseInputFileEntry(value);
4067
+ break;
4068
+ case "file[]":
4069
+ result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
4070
+ break;
4071
+ default:
4072
+ result[key] = value;
4073
+ }
4074
+ }
4075
+ return result;
4076
+ };
4077
+ const removeLinksFromObject = (object) => {
2853
4078
  return Object.entries(object).reduce((acc, [key, value]) => {
2854
4079
  if (key === "xata")
2855
4080
  return acc;
@@ -2857,23 +4082,23 @@ const transformObjectLinks = (object) => {
2857
4082
  }, {});
2858
4083
  };
2859
4084
  const initObject = (db, schemaTables, table, object, selectedColumns) => {
2860
- const result = {};
4085
+ const data = {};
2861
4086
  const { xata, ...rest } = object ?? {};
2862
- Object.assign(result, rest);
4087
+ Object.assign(data, rest);
2863
4088
  const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
2864
4089
  if (!columns)
2865
4090
  console.error(`Table ${table} not found in schema`);
2866
4091
  for (const column of columns ?? []) {
2867
4092
  if (!isValidColumn(selectedColumns, column))
2868
4093
  continue;
2869
- const value = result[column.name];
4094
+ const value = data[column.name];
2870
4095
  switch (column.type) {
2871
4096
  case "datetime": {
2872
4097
  const date = value !== void 0 ? new Date(value) : null;
2873
4098
  if (date !== null && isNaN(date.getTime())) {
2874
4099
  console.error(`Failed to parse date ${value} for field ${column.name}`);
2875
4100
  } else {
2876
- result[column.name] = date;
4101
+ data[column.name] = date;
2877
4102
  }
2878
4103
  break;
2879
4104
  }
@@ -2892,44 +4117,60 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2892
4117
  }
2893
4118
  return acc;
2894
4119
  }, []);
2895
- result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
4120
+ data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2896
4121
  } else {
2897
- result[column.name] = null;
4122
+ data[column.name] = null;
2898
4123
  }
2899
4124
  break;
2900
4125
  }
4126
+ case "file":
4127
+ data[column.name] = isDefined(value) ? new XataFile(value) : null;
4128
+ break;
4129
+ case "file[]":
4130
+ data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
4131
+ break;
2901
4132
  default:
2902
- result[column.name] = value ?? null;
4133
+ data[column.name] = value ?? null;
2903
4134
  if (column.notNull === true && value === null) {
2904
4135
  console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2905
4136
  }
2906
4137
  break;
2907
4138
  }
2908
4139
  }
2909
- result.read = function(columns2) {
2910
- return db[table].read(result["id"], columns2);
4140
+ const record = { ...data };
4141
+ const serializable = { xata, ...removeLinksFromObject(data) };
4142
+ const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
4143
+ record.read = function(columns2) {
4144
+ return db[table].read(record["id"], columns2);
2911
4145
  };
2912
- result.update = function(data, b, c) {
4146
+ record.update = function(data2, b, c) {
2913
4147
  const columns2 = isStringArray(b) ? b : ["*"];
2914
4148
  const ifVersion = parseIfVersion(b, c);
2915
- return db[table].update(result["id"], data, columns2, { ifVersion });
4149
+ return db[table].update(record["id"], data2, columns2, { ifVersion });
2916
4150
  };
2917
- result.replace = function(data, b, c) {
4151
+ record.replace = function(data2, b, c) {
2918
4152
  const columns2 = isStringArray(b) ? b : ["*"];
2919
4153
  const ifVersion = parseIfVersion(b, c);
2920
- return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
4154
+ return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
4155
+ };
4156
+ record.delete = function() {
4157
+ return db[table].delete(record["id"]);
4158
+ };
4159
+ record.xata = Object.freeze(metadata);
4160
+ record.getMetadata = function() {
4161
+ return record.xata;
2921
4162
  };
2922
- result.delete = function() {
2923
- return db[table].delete(result["id"]);
4163
+ record.toSerializable = function() {
4164
+ return JSON.parse(JSON.stringify(serializable));
2924
4165
  };
2925
- result.getMetadata = function() {
2926
- return xata;
4166
+ record.toString = function() {
4167
+ return JSON.stringify(serializable);
2927
4168
  };
2928
- for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
2929
- Object.defineProperty(result, prop, { enumerable: false });
4169
+ for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
4170
+ Object.defineProperty(record, prop, { enumerable: false });
2930
4171
  }
2931
- Object.freeze(result);
2932
- return result;
4172
+ Object.freeze(record);
4173
+ return record;
2933
4174
  };
2934
4175
  function extractId(value) {
2935
4176
  if (isString(value))
@@ -2941,11 +4182,7 @@ function extractId(value) {
2941
4182
  function isValidColumn(columns, column) {
2942
4183
  if (columns.includes("*"))
2943
4184
  return true;
2944
- if (column.type === "link") {
2945
- const linkColumns = columns.filter((item) => item.startsWith(column.name));
2946
- return linkColumns.length > 0;
2947
- }
2948
- return columns.includes(column.name);
4185
+ return columns.filter((item) => item.startsWith(column.name)).length > 0;
2949
4186
  }
2950
4187
  function parseIfVersion(...args) {
2951
4188
  for (const arg of args) {
@@ -2956,6 +4193,12 @@ function parseIfVersion(...args) {
2956
4193
  return void 0;
2957
4194
  }
2958
4195
 
4196
+ var __defProp$3 = Object.defineProperty;
4197
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4198
+ var __publicField$3 = (obj, key, value) => {
4199
+ __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
4200
+ return value;
4201
+ };
2959
4202
  var __accessCheck$3 = (obj, member, msg) => {
2960
4203
  if (!member.has(obj))
2961
4204
  throw TypeError("Cannot " + msg);
@@ -2978,6 +4221,8 @@ var _map;
2978
4221
  class SimpleCache {
2979
4222
  constructor(options = {}) {
2980
4223
  __privateAdd$3(this, _map, void 0);
4224
+ __publicField$3(this, "capacity");
4225
+ __publicField$3(this, "defaultQueryTTL");
2981
4226
  __privateSet$3(this, _map, /* @__PURE__ */ new Map());
2982
4227
  this.capacity = options.max ?? 500;
2983
4228
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
@@ -3113,19 +4358,19 @@ class SearchPlugin extends XataPlugin {
3113
4358
  __privateAdd$1(this, _schemaTables, void 0);
3114
4359
  __privateSet$1(this, _schemaTables, schemaTables);
3115
4360
  }
3116
- build({ getFetchProps }) {
4361
+ build(pluginOptions) {
3117
4362
  return {
3118
4363
  all: async (query, options = {}) => {
3119
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
3120
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
4364
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4365
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
3121
4366
  return records.map((record) => {
3122
4367
  const { table = "orphan" } = record.xata;
3123
4368
  return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
3124
4369
  });
3125
4370
  },
3126
4371
  byTable: async (query, options = {}) => {
3127
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
3128
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
4372
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4373
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
3129
4374
  return records.reduce((acc, record) => {
3130
4375
  const { table = "orphan" } = record.xata;
3131
4376
  const items = acc[table] ?? [];
@@ -3138,38 +4383,108 @@ class SearchPlugin extends XataPlugin {
3138
4383
  }
3139
4384
  _schemaTables = new WeakMap();
3140
4385
  _search = new WeakSet();
3141
- search_fn = async function(query, options, getFetchProps) {
3142
- const fetchProps = await getFetchProps();
3143
- const { tables, fuzziness, highlight, prefix } = options ?? {};
4386
+ search_fn = async function(query, options, pluginOptions) {
4387
+ const { tables, fuzziness, highlight, prefix, page } = options ?? {};
3144
4388
  const { records } = await searchBranch({
3145
4389
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3146
- body: { tables, query, fuzziness, prefix, highlight },
3147
- ...fetchProps
4390
+ // @ts-ignore https://github.com/xataio/client-ts/issues/313
4391
+ body: { tables, query, fuzziness, prefix, highlight, page },
4392
+ ...pluginOptions
3148
4393
  });
3149
4394
  return records;
3150
4395
  };
3151
4396
  _getSchemaTables = new WeakSet();
3152
- getSchemaTables_fn = async function(getFetchProps) {
4397
+ getSchemaTables_fn = async function(pluginOptions) {
3153
4398
  if (__privateGet$1(this, _schemaTables))
3154
4399
  return __privateGet$1(this, _schemaTables);
3155
- const fetchProps = await getFetchProps();
3156
4400
  const { schema } = await getBranchDetails({
3157
4401
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3158
- ...fetchProps
4402
+ ...pluginOptions
3159
4403
  });
3160
4404
  __privateSet$1(this, _schemaTables, schema.tables);
3161
4405
  return schema.tables;
3162
4406
  };
3163
4407
 
4408
+ function escapeElement(elementRepresentation) {
4409
+ const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
4410
+ return '"' + escaped + '"';
4411
+ }
4412
+ function arrayString(val) {
4413
+ let result = "{";
4414
+ for (let i = 0; i < val.length; i++) {
4415
+ if (i > 0) {
4416
+ result = result + ",";
4417
+ }
4418
+ if (val[i] === null || typeof val[i] === "undefined") {
4419
+ result = result + "NULL";
4420
+ } else if (Array.isArray(val[i])) {
4421
+ result = result + arrayString(val[i]);
4422
+ } else if (val[i] instanceof Buffer) {
4423
+ result += "\\\\x" + val[i].toString("hex");
4424
+ } else {
4425
+ result += escapeElement(prepareValue(val[i]));
4426
+ }
4427
+ }
4428
+ result = result + "}";
4429
+ return result;
4430
+ }
4431
+ function prepareValue(value) {
4432
+ if (!isDefined(value))
4433
+ return null;
4434
+ if (value instanceof Date) {
4435
+ return value.toISOString();
4436
+ }
4437
+ if (Array.isArray(value)) {
4438
+ return arrayString(value);
4439
+ }
4440
+ if (isObject(value)) {
4441
+ return JSON.stringify(value);
4442
+ }
4443
+ try {
4444
+ return value.toString();
4445
+ } catch (e) {
4446
+ return value;
4447
+ }
4448
+ }
4449
+ function prepareParams(param1, param2) {
4450
+ if (isString(param1)) {
4451
+ return { statement: param1, params: param2?.map((value) => prepareValue(value)) };
4452
+ }
4453
+ if (isStringArray(param1)) {
4454
+ const statement = param1.reduce((acc, curr, index) => {
4455
+ return acc + curr + (index < (param2?.length ?? 0) ? "$" + (index + 1) : "");
4456
+ }, "");
4457
+ return { statement, params: param2?.map((value) => prepareValue(value)) };
4458
+ }
4459
+ if (isObject(param1)) {
4460
+ const { statement, params, consistency } = param1;
4461
+ return { statement, params: params?.map((value) => prepareValue(value)), consistency };
4462
+ }
4463
+ throw new Error("Invalid query");
4464
+ }
4465
+
4466
+ class SQLPlugin extends XataPlugin {
4467
+ build(pluginOptions) {
4468
+ return async (param1, ...param2) => {
4469
+ const { statement, params, consistency } = prepareParams(param1, param2);
4470
+ const { records, warning } = await sqlQuery({
4471
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4472
+ body: { statement, params, consistency },
4473
+ ...pluginOptions
4474
+ });
4475
+ return { records, warning };
4476
+ };
4477
+ }
4478
+ }
4479
+
3164
4480
  class TransactionPlugin extends XataPlugin {
3165
- build({ getFetchProps }) {
4481
+ build(pluginOptions) {
3166
4482
  return {
3167
4483
  run: async (operations) => {
3168
- const fetchProps = await getFetchProps();
3169
4484
  const response = await branchTransaction({
3170
4485
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3171
4486
  body: { operations },
3172
- ...fetchProps
4487
+ ...pluginOptions
3173
4488
  });
3174
4489
  return response;
3175
4490
  }
@@ -3177,93 +4492,12 @@ class TransactionPlugin extends XataPlugin {
3177
4492
  }
3178
4493
  }
3179
4494
 
3180
- const isBranchStrategyBuilder = (strategy) => {
3181
- return typeof strategy === "function";
4495
+ var __defProp$2 = Object.defineProperty;
4496
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4497
+ var __publicField$2 = (obj, key, value) => {
4498
+ __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
4499
+ return value;
3182
4500
  };
3183
-
3184
- async function getCurrentBranchName(options) {
3185
- const { branch, envBranch } = getEnvironment();
3186
- if (branch) {
3187
- const details = await getDatabaseBranch(branch, options);
3188
- if (details)
3189
- return branch;
3190
- console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
3191
- }
3192
- const gitBranch = envBranch || await getGitBranch();
3193
- return resolveXataBranch(gitBranch, options);
3194
- }
3195
- async function getCurrentBranchDetails(options) {
3196
- const branch = await getCurrentBranchName(options);
3197
- return getDatabaseBranch(branch, options);
3198
- }
3199
- async function resolveXataBranch(gitBranch, options) {
3200
- const databaseURL = options?.databaseURL || getDatabaseURL();
3201
- const apiKey = options?.apiKey || getAPIKey();
3202
- if (!databaseURL)
3203
- throw new Error(
3204
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
3205
- );
3206
- if (!apiKey)
3207
- throw new Error(
3208
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
3209
- );
3210
- const [protocol, , host, , dbName] = databaseURL.split("/");
3211
- const urlParts = parseWorkspacesUrlParts(host);
3212
- if (!urlParts)
3213
- throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3214
- const { workspace, region } = urlParts;
3215
- const { fallbackBranch } = getEnvironment();
3216
- const { branch } = await resolveBranch({
3217
- apiKey,
3218
- apiUrl: databaseURL,
3219
- fetchImpl: getFetchImplementation(options?.fetchImpl),
3220
- workspacesApiUrl: `${protocol}//${host}`,
3221
- pathParams: { dbName, workspace, region },
3222
- queryParams: { gitBranch, fallbackBranch },
3223
- trace: defaultTrace
3224
- });
3225
- return branch;
3226
- }
3227
- async function getDatabaseBranch(branch, options) {
3228
- const databaseURL = options?.databaseURL || getDatabaseURL();
3229
- const apiKey = options?.apiKey || getAPIKey();
3230
- if (!databaseURL)
3231
- throw new Error(
3232
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
3233
- );
3234
- if (!apiKey)
3235
- throw new Error(
3236
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
3237
- );
3238
- const [protocol, , host, , database] = databaseURL.split("/");
3239
- const urlParts = parseWorkspacesUrlParts(host);
3240
- if (!urlParts)
3241
- throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3242
- const { workspace, region } = urlParts;
3243
- try {
3244
- return await getBranchDetails({
3245
- apiKey,
3246
- apiUrl: databaseURL,
3247
- fetchImpl: getFetchImplementation(options?.fetchImpl),
3248
- workspacesApiUrl: `${protocol}//${host}`,
3249
- pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
3250
- trace: defaultTrace
3251
- });
3252
- } catch (err) {
3253
- if (isObject(err) && err.status === 404)
3254
- return null;
3255
- throw err;
3256
- }
3257
- }
3258
- function getDatabaseURL() {
3259
- try {
3260
- const { databaseURL } = getEnvironment();
3261
- return databaseURL;
3262
- } catch (err) {
3263
- return void 0;
3264
- }
3265
- }
3266
-
3267
4501
  var __accessCheck = (obj, member, msg) => {
3268
4502
  if (!member.has(obj))
3269
4503
  throw TypeError("Cannot " + msg);
@@ -3287,48 +4521,48 @@ var __privateMethod = (obj, member, method) => {
3287
4521
  return method;
3288
4522
  };
3289
4523
  const buildClient = (plugins) => {
3290
- var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
4524
+ var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
3291
4525
  return _a = class {
3292
4526
  constructor(options = {}, schemaTables) {
3293
4527
  __privateAdd(this, _parseOptions);
3294
4528
  __privateAdd(this, _getFetchProps);
3295
- __privateAdd(this, _evaluateBranch);
3296
- __privateAdd(this, _branch, void 0);
3297
4529
  __privateAdd(this, _options, void 0);
4530
+ __publicField$2(this, "db");
4531
+ __publicField$2(this, "search");
4532
+ __publicField$2(this, "transactions");
4533
+ __publicField$2(this, "sql");
4534
+ __publicField$2(this, "files");
3298
4535
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
3299
4536
  __privateSet(this, _options, safeOptions);
3300
4537
  const pluginOptions = {
3301
- getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
4538
+ ...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
3302
4539
  cache: safeOptions.cache,
3303
- trace: safeOptions.trace
4540
+ host: safeOptions.host
3304
4541
  };
3305
4542
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
3306
4543
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
3307
4544
  const transactions = new TransactionPlugin().build(pluginOptions);
4545
+ const sql = new SQLPlugin().build(pluginOptions);
4546
+ const files = new FilesPlugin().build(pluginOptions);
3308
4547
  this.db = db;
3309
4548
  this.search = search;
3310
4549
  this.transactions = transactions;
4550
+ this.sql = sql;
4551
+ this.files = files;
3311
4552
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
3312
4553
  if (namespace === void 0)
3313
4554
  continue;
3314
- const result = namespace.build(pluginOptions);
3315
- if (result instanceof Promise) {
3316
- void result.then((namespace2) => {
3317
- this[key] = namespace2;
3318
- });
3319
- } else {
3320
- this[key] = result;
3321
- }
4555
+ this[key] = namespace.build(pluginOptions);
3322
4556
  }
3323
4557
  }
3324
4558
  async getConfig() {
3325
4559
  const databaseURL = __privateGet(this, _options).databaseURL;
3326
- const branch = await __privateGet(this, _options).branch();
4560
+ const branch = __privateGet(this, _options).branch;
3327
4561
  return { databaseURL, branch };
3328
4562
  }
3329
- }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
4563
+ }, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
3330
4564
  const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
3331
- const isBrowser = typeof window !== "undefined";
4565
+ const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
3332
4566
  if (isBrowser && !enableBrowser) {
3333
4567
  throw new Error(
3334
4568
  "You are trying to use Xata from the browser, which is potentially a non-secure environment. If you understand the security concerns, such as leaking your credentials, pass `enableBrowser: true` to the client options to remove this error."
@@ -3339,56 +4573,89 @@ const buildClient = (plugins) => {
3339
4573
  const apiKey = options?.apiKey || getAPIKey();
3340
4574
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
3341
4575
  const trace = options?.trace ?? defaultTrace;
3342
- const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
4576
+ const clientName = options?.clientName;
4577
+ const host = options?.host ?? "production";
4578
+ const xataAgentExtra = options?.xataAgentExtra;
3343
4579
  if (!apiKey) {
3344
4580
  throw new Error("Option apiKey is required");
3345
4581
  }
3346
4582
  if (!databaseURL) {
3347
4583
  throw new Error("Option databaseURL is required");
3348
4584
  }
3349
- return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser };
3350
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
3351
- const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
3352
- if (!branchValue)
3353
- throw new Error("Unable to resolve branch value");
4585
+ const envBranch = getBranch();
4586
+ const previewBranch = getPreviewBranch();
4587
+ const branch = options?.branch || previewBranch || envBranch || "main";
4588
+ if (!!previewBranch && branch !== previewBranch) {
4589
+ console.warn(
4590
+ `Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
4591
+ );
4592
+ } else if (!!envBranch && branch !== envBranch) {
4593
+ console.warn(
4594
+ `Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
4595
+ );
4596
+ } else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
4597
+ console.warn(
4598
+ `Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
4599
+ );
4600
+ } else if (!previewBranch && !envBranch && options?.branch === void 0) {
4601
+ console.warn(
4602
+ `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.`
4603
+ );
4604
+ }
4605
+ return {
4606
+ fetch,
4607
+ databaseURL,
4608
+ apiKey,
4609
+ branch,
4610
+ cache,
4611
+ trace,
4612
+ host,
4613
+ clientID: generateUUID(),
4614
+ enableBrowser,
4615
+ clientName,
4616
+ xataAgentExtra
4617
+ };
4618
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
4619
+ fetch,
4620
+ apiKey,
4621
+ databaseURL,
4622
+ branch,
4623
+ trace,
4624
+ clientID,
4625
+ clientName,
4626
+ xataAgentExtra
4627
+ }) {
3354
4628
  return {
3355
- fetchImpl: fetch,
4629
+ fetch,
3356
4630
  apiKey,
3357
4631
  apiUrl: "",
4632
+ // Instead of using workspace and dbBranch, we inject a probably CNAME'd URL
3358
4633
  workspacesApiUrl: (path, params) => {
3359
4634
  const hasBranch = params.dbBranchName ?? params.branch;
3360
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
4635
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
3361
4636
  return databaseURL + newPath;
3362
4637
  },
3363
4638
  trace,
3364
- clientID
3365
- };
3366
- }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
3367
- if (__privateGet(this, _branch))
3368
- return __privateGet(this, _branch);
3369
- if (param === void 0)
3370
- return void 0;
3371
- const strategies = Array.isArray(param) ? [...param] : [param];
3372
- const evaluateBranch = async (strategy) => {
3373
- return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
4639
+ clientID,
4640
+ clientName,
4641
+ xataAgentExtra
3374
4642
  };
3375
- for await (const strategy of strategies) {
3376
- const branch = await evaluateBranch(strategy);
3377
- if (branch) {
3378
- __privateSet(this, _branch, branch);
3379
- return branch;
3380
- }
3381
- }
3382
4643
  }, _a;
3383
4644
  };
3384
4645
  class BaseClient extends buildClient() {
3385
4646
  }
3386
4647
 
4648
+ var __defProp$1 = Object.defineProperty;
4649
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4650
+ var __publicField$1 = (obj, key, value) => {
4651
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
4652
+ return value;
4653
+ };
3387
4654
  const META = "__";
3388
4655
  const VALUE = "___";
3389
4656
  class Serializer {
3390
4657
  constructor() {
3391
- this.classes = {};
4658
+ __publicField$1(this, "classes", {});
3392
4659
  }
3393
4660
  add(clazz) {
3394
4661
  this.classes[clazz.name] = clazz;
@@ -3452,7 +4719,7 @@ const deserialize = (json) => {
3452
4719
  };
3453
4720
 
3454
4721
  function buildWorkerRunner(config) {
3455
- return function xataWorker(name, _worker) {
4722
+ return function xataWorker(name, worker) {
3456
4723
  return async (...args) => {
3457
4724
  const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
3458
4725
  const result = await fetch(url, {
@@ -3466,14 +4733,23 @@ function buildWorkerRunner(config) {
3466
4733
  };
3467
4734
  }
3468
4735
 
4736
+ var __defProp = Object.defineProperty;
4737
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4738
+ var __publicField = (obj, key, value) => {
4739
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4740
+ return value;
4741
+ };
3469
4742
  class XataError extends Error {
3470
4743
  constructor(message, status) {
3471
4744
  super(message);
4745
+ __publicField(this, "status");
3472
4746
  this.status = status;
3473
4747
  }
3474
4748
  }
3475
4749
 
3476
4750
  exports.BaseClient = BaseClient;
4751
+ exports.FetcherError = FetcherError;
4752
+ exports.FilesPlugin = FilesPlugin;
3477
4753
  exports.Operations = operationsByTag;
3478
4754
  exports.PAGINATION_DEFAULT_OFFSET = PAGINATION_DEFAULT_OFFSET;
3479
4755
  exports.PAGINATION_DEFAULT_SIZE = PAGINATION_DEFAULT_SIZE;
@@ -3482,8 +4758,10 @@ exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
3482
4758
  exports.Page = Page;
3483
4759
  exports.Query = Query;
3484
4760
  exports.RecordArray = RecordArray;
4761
+ exports.RecordColumnTypes = RecordColumnTypes;
3485
4762
  exports.Repository = Repository;
3486
4763
  exports.RestRepository = RestRepository;
4764
+ exports.SQLPlugin = SQLPlugin;
3487
4765
  exports.SchemaPlugin = SchemaPlugin;
3488
4766
  exports.SearchPlugin = SearchPlugin;
3489
4767
  exports.Serializer = Serializer;
@@ -3491,14 +4769,19 @@ exports.SimpleCache = SimpleCache;
3491
4769
  exports.XataApiClient = XataApiClient;
3492
4770
  exports.XataApiPlugin = XataApiPlugin;
3493
4771
  exports.XataError = XataError;
4772
+ exports.XataFile = XataFile;
3494
4773
  exports.XataPlugin = XataPlugin;
3495
4774
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
3496
4775
  exports.addGitBranchesEntry = addGitBranchesEntry;
3497
4776
  exports.addTableColumn = addTableColumn;
3498
4777
  exports.aggregateTable = aggregateTable;
3499
4778
  exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
4779
+ exports.askTable = askTable;
4780
+ exports.askTableSession = askTableSession;
3500
4781
  exports.branchTransaction = branchTransaction;
3501
4782
  exports.buildClient = buildClient;
4783
+ exports.buildPreviewBranchName = buildPreviewBranchName;
4784
+ exports.buildProviderString = buildProviderString;
3502
4785
  exports.buildWorkerRunner = buildWorkerRunner;
3503
4786
  exports.bulkInsertTableRecords = bulkInsertTableRecords;
3504
4787
  exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
@@ -3506,32 +4789,36 @@ exports.compareBranchSchemas = compareBranchSchemas;
3506
4789
  exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
3507
4790
  exports.compareMigrationRequest = compareMigrationRequest;
3508
4791
  exports.contains = contains;
4792
+ exports.copyBranch = copyBranch;
3509
4793
  exports.createBranch = createBranch;
3510
4794
  exports.createDatabase = createDatabase;
3511
4795
  exports.createMigrationRequest = createMigrationRequest;
3512
4796
  exports.createTable = createTable;
3513
4797
  exports.createUserAPIKey = createUserAPIKey;
3514
4798
  exports.createWorkspace = createWorkspace;
3515
- exports.dEPRECATEDcreateDatabase = dEPRECATEDcreateDatabase;
3516
- exports.dEPRECATEDdeleteDatabase = dEPRECATEDdeleteDatabase;
3517
- exports.dEPRECATEDgetDatabaseList = dEPRECATEDgetDatabaseList;
3518
- exports.dEPRECATEDgetDatabaseMetadata = dEPRECATEDgetDatabaseMetadata;
3519
- exports.dEPRECATEDupdateDatabaseMetadata = dEPRECATEDupdateDatabaseMetadata;
3520
4799
  exports.deleteBranch = deleteBranch;
3521
4800
  exports.deleteColumn = deleteColumn;
3522
4801
  exports.deleteDatabase = deleteDatabase;
4802
+ exports.deleteDatabaseGithubSettings = deleteDatabaseGithubSettings;
4803
+ exports.deleteFile = deleteFile;
4804
+ exports.deleteFileItem = deleteFileItem;
4805
+ exports.deleteOAuthAccessToken = deleteOAuthAccessToken;
3523
4806
  exports.deleteRecord = deleteRecord;
3524
4807
  exports.deleteTable = deleteTable;
3525
4808
  exports.deleteUser = deleteUser;
3526
4809
  exports.deleteUserAPIKey = deleteUserAPIKey;
4810
+ exports.deleteUserOAuthClient = deleteUserOAuthClient;
3527
4811
  exports.deleteWorkspace = deleteWorkspace;
3528
4812
  exports.deserialize = deserialize;
3529
4813
  exports.endsWith = endsWith;
3530
4814
  exports.equals = equals;
3531
4815
  exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
3532
4816
  exports.exists = exists;
4817
+ exports.fileAccess = fileAccess;
3533
4818
  exports.ge = ge;
3534
4819
  exports.getAPIKey = getAPIKey;
4820
+ exports.getAuthorizationCode = getAuthorizationCode;
4821
+ exports.getBranch = getBranch;
3535
4822
  exports.getBranchDetails = getBranchDetails;
3536
4823
  exports.getBranchList = getBranchList;
3537
4824
  exports.getBranchMetadata = getBranchMetadata;
@@ -3540,23 +4827,28 @@ exports.getBranchMigrationPlan = getBranchMigrationPlan;
3540
4827
  exports.getBranchSchemaHistory = getBranchSchemaHistory;
3541
4828
  exports.getBranchStats = getBranchStats;
3542
4829
  exports.getColumn = getColumn;
3543
- exports.getCurrentBranchDetails = getCurrentBranchDetails;
3544
- exports.getCurrentBranchName = getCurrentBranchName;
4830
+ exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
3545
4831
  exports.getDatabaseList = getDatabaseList;
3546
4832
  exports.getDatabaseMetadata = getDatabaseMetadata;
3547
4833
  exports.getDatabaseURL = getDatabaseURL;
4834
+ exports.getFile = getFile;
4835
+ exports.getFileItem = getFileItem;
3548
4836
  exports.getGitBranchesMapping = getGitBranchesMapping;
3549
4837
  exports.getHostUrl = getHostUrl;
3550
4838
  exports.getMigrationRequest = getMigrationRequest;
3551
4839
  exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
4840
+ exports.getPreviewBranch = getPreviewBranch;
3552
4841
  exports.getRecord = getRecord;
3553
4842
  exports.getTableColumns = getTableColumns;
3554
4843
  exports.getTableSchema = getTableSchema;
3555
4844
  exports.getUser = getUser;
3556
4845
  exports.getUserAPIKeys = getUserAPIKeys;
4846
+ exports.getUserOAuthAccessTokens = getUserOAuthAccessTokens;
4847
+ exports.getUserOAuthClients = getUserOAuthClients;
3557
4848
  exports.getWorkspace = getWorkspace;
3558
4849
  exports.getWorkspaceMembersList = getWorkspaceMembersList;
3559
4850
  exports.getWorkspacesList = getWorkspacesList;
4851
+ exports.grantAuthorizationCode = grantAuthorizationCode;
3560
4852
  exports.greaterEquals = greaterEquals;
3561
4853
  exports.greaterThan = greaterThan;
3562
4854
  exports.greaterThanEquals = greaterThanEquals;
@@ -3591,23 +4883,31 @@ exports.parseProviderString = parseProviderString;
3591
4883
  exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
3592
4884
  exports.pattern = pattern;
3593
4885
  exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
4886
+ exports.pushBranchMigrations = pushBranchMigrations;
4887
+ exports.putFile = putFile;
4888
+ exports.putFileItem = putFileItem;
3594
4889
  exports.queryMigrationRequests = queryMigrationRequests;
3595
4890
  exports.queryTable = queryTable;
3596
4891
  exports.removeGitBranchesEntry = removeGitBranchesEntry;
3597
4892
  exports.removeWorkspaceMember = removeWorkspaceMember;
4893
+ exports.renameDatabase = renameDatabase;
3598
4894
  exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
3599
4895
  exports.resolveBranch = resolveBranch;
3600
4896
  exports.searchBranch = searchBranch;
3601
4897
  exports.searchTable = searchTable;
3602
4898
  exports.serialize = serialize;
3603
4899
  exports.setTableSchema = setTableSchema;
4900
+ exports.sqlQuery = sqlQuery;
3604
4901
  exports.startsWith = startsWith;
3605
4902
  exports.summarizeTable = summarizeTable;
4903
+ exports.transformImage = transformImage;
3606
4904
  exports.updateBranchMetadata = updateBranchMetadata;
3607
4905
  exports.updateBranchSchema = updateBranchSchema;
3608
4906
  exports.updateColumn = updateColumn;
4907
+ exports.updateDatabaseGithubSettings = updateDatabaseGithubSettings;
3609
4908
  exports.updateDatabaseMetadata = updateDatabaseMetadata;
3610
4909
  exports.updateMigrationRequest = updateMigrationRequest;
4910
+ exports.updateOAuthAccessToken = updateOAuthAccessToken;
3611
4911
  exports.updateRecordWithID = updateRecordWithID;
3612
4912
  exports.updateTable = updateTable;
3613
4913
  exports.updateUser = updateUser;
@@ -3615,4 +4915,5 @@ exports.updateWorkspace = updateWorkspace;
3615
4915
  exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
3616
4916
  exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
3617
4917
  exports.upsertRecordWithID = upsertRecordWithID;
4918
+ exports.vectorSearchTable = vectorSearchTable;
3618
4919
  //# sourceMappingURL=index.cjs.map