@xata.io/client 0.0.0-alpha.vf7fccd9 → 0.0.0-alpha.vf80d1a5

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,27 +1,8 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopNamespace(e) {
6
- if (e && e.__esModule) return e;
7
- var n = Object.create(null);
8
- if (e) {
9
- Object.keys(e).forEach(function (k) {
10
- if (k !== 'default') {
11
- var d = Object.getOwnPropertyDescriptor(e, k);
12
- Object.defineProperty(n, k, d.get ? d : {
13
- enumerable: true,
14
- get: function () { return e[k]; }
15
- });
16
- }
17
- });
18
- }
19
- n["default"] = e;
20
- return Object.freeze(n);
21
- }
22
-
23
- const defaultTrace = async (_name, fn, _options) => {
3
+ const defaultTrace = async (name, fn, _options) => {
24
4
  return await fn({
5
+ name,
25
6
  setAttributes: () => {
26
7
  return;
27
8
  }
@@ -60,6 +41,21 @@ function isString(value) {
60
41
  function isStringArray(value) {
61
42
  return isDefined(value) && Array.isArray(value) && value.every(isString);
62
43
  }
44
+ function isNumber(value) {
45
+ return isDefined(value) && typeof value === "number";
46
+ }
47
+ function parseNumber(value) {
48
+ if (isNumber(value)) {
49
+ return value;
50
+ }
51
+ if (isString(value)) {
52
+ const parsed = Number(value);
53
+ if (!Number.isNaN(parsed)) {
54
+ return parsed;
55
+ }
56
+ }
57
+ return void 0;
58
+ }
63
59
  function toBase64(value) {
64
60
  try {
65
61
  return btoa(value);
@@ -68,16 +64,39 @@ function toBase64(value) {
68
64
  return buf.from(value).toString("base64");
69
65
  }
70
66
  }
67
+ function deepMerge(a, b) {
68
+ const result = { ...a };
69
+ for (const [key, value] of Object.entries(b)) {
70
+ if (isObject(value) && isObject(result[key])) {
71
+ result[key] = deepMerge(result[key], value);
72
+ } else {
73
+ result[key] = value;
74
+ }
75
+ }
76
+ return result;
77
+ }
78
+ function chunk(array, chunkSize) {
79
+ const result = [];
80
+ for (let i = 0; i < array.length; i += chunkSize) {
81
+ result.push(array.slice(i, i + chunkSize));
82
+ }
83
+ return result;
84
+ }
85
+ async function timeout(ms) {
86
+ return new Promise((resolve) => setTimeout(resolve, ms));
87
+ }
71
88
 
72
89
  function getEnvironment() {
73
90
  try {
74
- if (isObject(process) && isObject(process.env)) {
91
+ if (isDefined(process) && isDefined(process.env)) {
75
92
  return {
76
93
  apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
77
94
  databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
78
95
  branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
79
- envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
80
- fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
96
+ deployPreview: process.env.XATA_PREVIEW,
97
+ deployPreviewBranch: process.env.XATA_PREVIEW_BRANCH,
98
+ vercelGitCommitRef: process.env.VERCEL_GIT_COMMIT_REF,
99
+ vercelGitRepoOwner: process.env.VERCEL_GIT_REPO_OWNER
81
100
  };
82
101
  }
83
102
  } catch (err) {
@@ -88,8 +107,10 @@ function getEnvironment() {
88
107
  apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
89
108
  databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
90
109
  branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
91
- envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
92
- fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
110
+ deployPreview: Deno.env.get("XATA_PREVIEW"),
111
+ deployPreviewBranch: Deno.env.get("XATA_PREVIEW_BRANCH"),
112
+ vercelGitCommitRef: Deno.env.get("VERCEL_GIT_COMMIT_REF"),
113
+ vercelGitRepoOwner: Deno.env.get("VERCEL_GIT_REPO_OWNER")
93
114
  };
94
115
  }
95
116
  } catch (err) {
@@ -98,10 +119,31 @@ function getEnvironment() {
98
119
  apiKey: getGlobalApiKey(),
99
120
  databaseURL: getGlobalDatabaseURL(),
100
121
  branch: getGlobalBranch(),
101
- envBranch: void 0,
102
- fallbackBranch: getGlobalFallbackBranch()
122
+ deployPreview: void 0,
123
+ deployPreviewBranch: void 0,
124
+ vercelGitCommitRef: void 0,
125
+ vercelGitRepoOwner: void 0
103
126
  };
104
127
  }
128
+ function getEnableBrowserVariable() {
129
+ try {
130
+ if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
131
+ return process.env.XATA_ENABLE_BROWSER === "true";
132
+ }
133
+ } catch (err) {
134
+ }
135
+ try {
136
+ if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
137
+ return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
138
+ }
139
+ } catch (err) {
140
+ }
141
+ try {
142
+ return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
143
+ } catch (err) {
144
+ return void 0;
145
+ }
146
+ }
105
147
  function getGlobalApiKey() {
106
148
  try {
107
149
  return XATA_API_KEY;
@@ -123,44 +165,76 @@ function getGlobalBranch() {
123
165
  return void 0;
124
166
  }
125
167
  }
126
- function getGlobalFallbackBranch() {
168
+ function getDatabaseURL() {
127
169
  try {
128
- return XATA_FALLBACK_BRANCH;
170
+ const { databaseURL } = getEnvironment();
171
+ return databaseURL;
129
172
  } catch (err) {
130
173
  return void 0;
131
174
  }
132
175
  }
133
- async function getGitBranch() {
134
- const cmd = ["git", "branch", "--show-current"];
135
- const fullCmd = cmd.join(" ");
136
- const nodeModule = ["child", "process"].join("_");
137
- const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
176
+ function getAPIKey() {
138
177
  try {
139
- if (typeof require === "function") {
140
- return require(nodeModule).execSync(fullCmd, execOptions).trim();
141
- }
142
- const { execSync } = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(nodeModule);
143
- return execSync(fullCmd, execOptions).toString().trim();
178
+ const { apiKey } = getEnvironment();
179
+ return apiKey;
144
180
  } catch (err) {
181
+ return void 0;
145
182
  }
183
+ }
184
+ function getBranch() {
146
185
  try {
147
- if (isObject(Deno)) {
148
- const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
149
- return new TextDecoder().decode(await process2.output()).trim();
150
- }
186
+ const { branch } = getEnvironment();
187
+ return branch ?? "main";
151
188
  } catch (err) {
189
+ return void 0;
152
190
  }
153
191
  }
154
-
155
- function getAPIKey() {
192
+ function buildPreviewBranchName({ org, branch }) {
193
+ return `preview-${org}-${branch}`;
194
+ }
195
+ function getPreviewBranch() {
156
196
  try {
157
- const { apiKey } = getEnvironment();
158
- return apiKey;
197
+ const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = getEnvironment();
198
+ if (deployPreviewBranch)
199
+ return deployPreviewBranch;
200
+ switch (deployPreview) {
201
+ case "vercel": {
202
+ if (!vercelGitCommitRef || !vercelGitRepoOwner) {
203
+ console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
204
+ return void 0;
205
+ }
206
+ return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
207
+ }
208
+ }
209
+ return void 0;
159
210
  } catch (err) {
160
211
  return void 0;
161
212
  }
162
213
  }
163
214
 
215
+ var __accessCheck$8 = (obj, member, msg) => {
216
+ if (!member.has(obj))
217
+ throw TypeError("Cannot " + msg);
218
+ };
219
+ var __privateGet$8 = (obj, member, getter) => {
220
+ __accessCheck$8(obj, member, "read from private field");
221
+ return getter ? getter.call(obj) : member.get(obj);
222
+ };
223
+ var __privateAdd$8 = (obj, member, value) => {
224
+ if (member.has(obj))
225
+ throw TypeError("Cannot add the same private member more than once");
226
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
227
+ };
228
+ var __privateSet$8 = (obj, member, value, setter) => {
229
+ __accessCheck$8(obj, member, "write to private field");
230
+ setter ? setter.call(obj, value) : member.set(obj, value);
231
+ return value;
232
+ };
233
+ var __privateMethod$4 = (obj, member, method) => {
234
+ __accessCheck$8(obj, member, "access private method");
235
+ return method;
236
+ };
237
+ var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
164
238
  function getFetchImplementation(userFetch) {
165
239
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
166
240
  const fetchImpl = userFetch ?? globalFetch;
@@ -171,8 +245,254 @@ function getFetchImplementation(userFetch) {
171
245
  }
172
246
  return fetchImpl;
173
247
  }
248
+ class ApiRequestPool {
249
+ constructor(concurrency = 10) {
250
+ __privateAdd$8(this, _enqueue);
251
+ __privateAdd$8(this, _fetch, void 0);
252
+ __privateAdd$8(this, _queue, void 0);
253
+ __privateAdd$8(this, _concurrency, void 0);
254
+ __privateSet$8(this, _queue, []);
255
+ __privateSet$8(this, _concurrency, concurrency);
256
+ this.running = 0;
257
+ this.started = 0;
258
+ }
259
+ setFetch(fetch2) {
260
+ __privateSet$8(this, _fetch, fetch2);
261
+ }
262
+ getFetch() {
263
+ if (!__privateGet$8(this, _fetch)) {
264
+ throw new Error("Fetch not set");
265
+ }
266
+ return __privateGet$8(this, _fetch);
267
+ }
268
+ request(url, options) {
269
+ const start = new Date();
270
+ const fetch2 = this.getFetch();
271
+ const runRequest = async (stalled = false) => {
272
+ const response = await fetch2(url, options);
273
+ if (response.status === 429) {
274
+ const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
275
+ await timeout(rateLimitReset * 1e3);
276
+ return await runRequest(true);
277
+ }
278
+ if (stalled) {
279
+ const stalledTime = new Date().getTime() - start.getTime();
280
+ console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
281
+ }
282
+ return response;
283
+ };
284
+ return __privateMethod$4(this, _enqueue, enqueue_fn).call(this, async () => {
285
+ return await runRequest();
286
+ });
287
+ }
288
+ }
289
+ _fetch = new WeakMap();
290
+ _queue = new WeakMap();
291
+ _concurrency = new WeakMap();
292
+ _enqueue = new WeakSet();
293
+ enqueue_fn = function(task) {
294
+ const promise = new Promise((resolve) => __privateGet$8(this, _queue).push(resolve)).finally(() => {
295
+ this.started--;
296
+ this.running++;
297
+ }).then(() => task()).finally(() => {
298
+ this.running--;
299
+ const next = __privateGet$8(this, _queue).shift();
300
+ if (next !== void 0) {
301
+ this.started++;
302
+ next();
303
+ }
304
+ });
305
+ if (this.running + this.started < __privateGet$8(this, _concurrency)) {
306
+ const next = __privateGet$8(this, _queue).shift();
307
+ if (next !== void 0) {
308
+ this.started++;
309
+ next();
310
+ }
311
+ }
312
+ return promise;
313
+ };
314
+
315
+ function generateUUID() {
316
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
317
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
318
+ return v.toString(16);
319
+ });
320
+ }
321
+
322
+ async function getBytes(stream, onChunk) {
323
+ const reader = stream.getReader();
324
+ let result;
325
+ while (!(result = await reader.read()).done) {
326
+ onChunk(result.value);
327
+ }
328
+ }
329
+ function getLines(onLine) {
330
+ let buffer;
331
+ let position;
332
+ let fieldLength;
333
+ let discardTrailingNewline = false;
334
+ return function onChunk(arr) {
335
+ if (buffer === void 0) {
336
+ buffer = arr;
337
+ position = 0;
338
+ fieldLength = -1;
339
+ } else {
340
+ buffer = concat(buffer, arr);
341
+ }
342
+ const bufLength = buffer.length;
343
+ let lineStart = 0;
344
+ while (position < bufLength) {
345
+ if (discardTrailingNewline) {
346
+ if (buffer[position] === 10 /* NewLine */) {
347
+ lineStart = ++position;
348
+ }
349
+ discardTrailingNewline = false;
350
+ }
351
+ let lineEnd = -1;
352
+ for (; position < bufLength && lineEnd === -1; ++position) {
353
+ switch (buffer[position]) {
354
+ case 58 /* Colon */:
355
+ if (fieldLength === -1) {
356
+ fieldLength = position - lineStart;
357
+ }
358
+ break;
359
+ case 13 /* CarriageReturn */:
360
+ discardTrailingNewline = true;
361
+ case 10 /* NewLine */:
362
+ lineEnd = position;
363
+ break;
364
+ }
365
+ }
366
+ if (lineEnd === -1) {
367
+ break;
368
+ }
369
+ onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
370
+ lineStart = position;
371
+ fieldLength = -1;
372
+ }
373
+ if (lineStart === bufLength) {
374
+ buffer = void 0;
375
+ } else if (lineStart !== 0) {
376
+ buffer = buffer.subarray(lineStart);
377
+ position -= lineStart;
378
+ }
379
+ };
380
+ }
381
+ function getMessages(onId, onRetry, onMessage) {
382
+ let message = newMessage();
383
+ const decoder = new TextDecoder();
384
+ return function onLine(line, fieldLength) {
385
+ if (line.length === 0) {
386
+ onMessage?.(message);
387
+ message = newMessage();
388
+ } else if (fieldLength > 0) {
389
+ const field = decoder.decode(line.subarray(0, fieldLength));
390
+ const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
391
+ const value = decoder.decode(line.subarray(valueOffset));
392
+ switch (field) {
393
+ case "data":
394
+ message.data = message.data ? message.data + "\n" + value : value;
395
+ break;
396
+ case "event":
397
+ message.event = value;
398
+ break;
399
+ case "id":
400
+ onId(message.id = value);
401
+ break;
402
+ case "retry":
403
+ const retry = parseInt(value, 10);
404
+ if (!isNaN(retry)) {
405
+ onRetry(message.retry = retry);
406
+ }
407
+ break;
408
+ }
409
+ }
410
+ };
411
+ }
412
+ function concat(a, b) {
413
+ const res = new Uint8Array(a.length + b.length);
414
+ res.set(a);
415
+ res.set(b, a.length);
416
+ return res;
417
+ }
418
+ function newMessage() {
419
+ return {
420
+ data: "",
421
+ event: "",
422
+ id: "",
423
+ retry: void 0
424
+ };
425
+ }
426
+ const EventStreamContentType = "text/event-stream";
427
+ const LastEventId = "last-event-id";
428
+ function fetchEventSource(input, {
429
+ signal: inputSignal,
430
+ headers: inputHeaders,
431
+ onopen: inputOnOpen,
432
+ onmessage,
433
+ onclose,
434
+ onerror,
435
+ fetch: inputFetch,
436
+ ...rest
437
+ }) {
438
+ return new Promise((resolve, reject) => {
439
+ const headers = { ...inputHeaders };
440
+ if (!headers.accept) {
441
+ headers.accept = EventStreamContentType;
442
+ }
443
+ let curRequestController;
444
+ function dispose() {
445
+ curRequestController.abort();
446
+ }
447
+ inputSignal?.addEventListener("abort", () => {
448
+ dispose();
449
+ resolve();
450
+ });
451
+ const fetchImpl = inputFetch ?? fetch;
452
+ const onopen = inputOnOpen ?? defaultOnOpen;
453
+ async function create() {
454
+ curRequestController = new AbortController();
455
+ try {
456
+ const response = await fetchImpl(input, {
457
+ ...rest,
458
+ headers,
459
+ signal: curRequestController.signal
460
+ });
461
+ await onopen(response);
462
+ await getBytes(
463
+ response.body,
464
+ getLines(
465
+ getMessages(
466
+ (id) => {
467
+ if (id) {
468
+ headers[LastEventId] = id;
469
+ } else {
470
+ delete headers[LastEventId];
471
+ }
472
+ },
473
+ (_retry) => {
474
+ },
475
+ onmessage
476
+ )
477
+ )
478
+ );
479
+ onclose?.();
480
+ dispose();
481
+ resolve();
482
+ } catch (err) {
483
+ }
484
+ }
485
+ create();
486
+ });
487
+ }
488
+ function defaultOnOpen(response) {
489
+ const contentType = response.headers?.get("content-type");
490
+ if (!contentType?.startsWith(EventStreamContentType)) {
491
+ throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
492
+ }
493
+ }
174
494
 
175
- const VERSION = "0.0.0-alpha.vf7fccd9";
495
+ const VERSION = "0.23.4";
176
496
 
177
497
  class ErrorWithCause extends Error {
178
498
  constructor(message, options) {
@@ -183,7 +503,7 @@ class FetcherError extends ErrorWithCause {
183
503
  constructor(status, data, requestId) {
184
504
  super(getMessage(data));
185
505
  this.status = status;
186
- this.errors = isBulkError(data) ? data.errors : void 0;
506
+ this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
187
507
  this.requestId = requestId;
188
508
  if (data instanceof Error) {
189
509
  this.stack = data.stack;
@@ -215,6 +535,7 @@ function getMessage(data) {
215
535
  }
216
536
  }
217
537
 
538
+ const pool = new ApiRequestPool();
218
539
  const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
219
540
  const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
220
541
  if (value === void 0 || value === null)
@@ -229,58 +550,79 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
229
550
  return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
230
551
  };
231
552
  function buildBaseUrl({
553
+ endpoint,
232
554
  path,
233
555
  workspacesApiUrl,
234
556
  apiUrl,
235
- pathParams
557
+ pathParams = {}
236
558
  }) {
237
- if (pathParams?.workspace === void 0)
238
- return `${apiUrl}${path}`;
239
- const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
240
- return url.replace("{workspaceId}", String(pathParams.workspace));
559
+ if (endpoint === "dataPlane") {
560
+ const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
561
+ const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
562
+ return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
563
+ }
564
+ return `${apiUrl}${path}`;
241
565
  }
242
566
  function hostHeader(url) {
243
567
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
244
568
  const { groups } = pattern.exec(url) ?? {};
245
569
  return groups?.host ? { Host: groups.host } : {};
246
570
  }
571
+ const defaultClientID = generateUUID();
247
572
  async function fetch$1({
248
573
  url: path,
249
574
  method,
250
575
  body,
251
- headers,
576
+ headers: customHeaders,
252
577
  pathParams,
253
578
  queryParams,
254
- fetchImpl,
579
+ fetch: fetch2,
255
580
  apiKey,
581
+ endpoint,
256
582
  apiUrl,
257
583
  workspacesApiUrl,
258
- trace
584
+ trace,
585
+ signal,
586
+ clientID,
587
+ sessionID,
588
+ clientName,
589
+ xataAgentExtra,
590
+ fetchOptions = {}
259
591
  }) {
260
- return trace(
592
+ pool.setFetch(fetch2);
593
+ return await trace(
261
594
  `${method.toUpperCase()} ${path}`,
262
595
  async ({ setAttributes }) => {
263
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
596
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
264
597
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
265
598
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
266
599
  setAttributes({
267
600
  [TraceAttributes.HTTP_URL]: url,
268
601
  [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
269
602
  });
270
- const response = await fetchImpl(url, {
603
+ const xataAgent = compact([
604
+ ["client", "TS_SDK"],
605
+ ["version", VERSION],
606
+ isDefined(clientName) ? ["service", clientName] : void 0,
607
+ ...Object.entries(xataAgentExtra ?? {})
608
+ ]).map(([key, value]) => `${key}=${value}`).join("; ");
609
+ const headers = {
610
+ "Accept-Encoding": "identity",
611
+ "Content-Type": "application/json",
612
+ "X-Xata-Client-ID": clientID ?? defaultClientID,
613
+ "X-Xata-Session-ID": sessionID ?? generateUUID(),
614
+ "X-Xata-Agent": xataAgent,
615
+ ...customHeaders,
616
+ ...hostHeader(fullUrl),
617
+ Authorization: `Bearer ${apiKey}`
618
+ };
619
+ const response = await pool.request(url, {
620
+ ...fetchOptions,
271
621
  method: method.toUpperCase(),
272
622
  body: body ? JSON.stringify(body) : void 0,
273
- headers: {
274
- "Content-Type": "application/json",
275
- "User-Agent": `Xata client-ts/${VERSION}`,
276
- ...headers,
277
- ...hostHeader(fullUrl),
278
- Authorization: `Bearer ${apiKey}`
279
- }
623
+ headers,
624
+ signal
280
625
  });
281
- if (response.status === 204) {
282
- return {};
283
- }
284
626
  const { host, protocol } = parseUrl(response.url);
285
627
  const requestId = response.headers?.get("x-request-id") ?? void 0;
286
628
  setAttributes({
@@ -290,6 +632,12 @@ async function fetch$1({
290
632
  [TraceAttributes.HTTP_HOST]: host,
291
633
  [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
292
634
  });
635
+ if (response.status === 204) {
636
+ return {};
637
+ }
638
+ if (response.status === 429) {
639
+ throw new FetcherError(response.status, "Rate limit exceeded", requestId);
640
+ }
293
641
  try {
294
642
  const jsonResponse = await response.json();
295
643
  if (response.ok) {
@@ -303,6 +651,59 @@ async function fetch$1({
303
651
  { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
304
652
  );
305
653
  }
654
+ function fetchSSERequest({
655
+ url: path,
656
+ method,
657
+ body,
658
+ headers: customHeaders,
659
+ pathParams,
660
+ queryParams,
661
+ fetch: fetch2,
662
+ apiKey,
663
+ endpoint,
664
+ apiUrl,
665
+ workspacesApiUrl,
666
+ onMessage,
667
+ onError,
668
+ onClose,
669
+ signal,
670
+ clientID,
671
+ sessionID,
672
+ clientName,
673
+ xataAgentExtra
674
+ }) {
675
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
676
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
677
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
678
+ void fetchEventSource(url, {
679
+ method,
680
+ body: JSON.stringify(body),
681
+ fetch: fetch2,
682
+ signal,
683
+ headers: {
684
+ "X-Xata-Client-ID": clientID ?? defaultClientID,
685
+ "X-Xata-Session-ID": sessionID ?? generateUUID(),
686
+ "X-Xata-Agent": compact([
687
+ ["client", "TS_SDK"],
688
+ ["version", VERSION],
689
+ isDefined(clientName) ? ["service", clientName] : void 0,
690
+ ...Object.entries(xataAgentExtra ?? {})
691
+ ]).map(([key, value]) => `${key}=${value}`).join("; "),
692
+ ...customHeaders,
693
+ Authorization: `Bearer ${apiKey}`,
694
+ "Content-Type": "application/json"
695
+ },
696
+ onmessage(ev) {
697
+ onMessage?.(JSON.parse(ev.data));
698
+ },
699
+ onerror(ev) {
700
+ onError?.(JSON.parse(ev.data));
701
+ },
702
+ onclose() {
703
+ onClose?.();
704
+ }
705
+ });
706
+ }
306
707
  function parseUrl(url) {
307
708
  try {
308
709
  const { host, protocol } = new URL(url);
@@ -312,290 +713,230 @@ function parseUrl(url) {
312
713
  }
313
714
  }
314
715
 
315
- const getUser = (variables) => fetch$1({ url: "/user", method: "get", ...variables });
316
- const updateUser = (variables) => fetch$1({ url: "/user", method: "put", ...variables });
317
- const deleteUser = (variables) => fetch$1({ url: "/user", method: "delete", ...variables });
318
- const getUserAPIKeys = (variables) => fetch$1({
319
- url: "/user/keys",
320
- method: "get",
321
- ...variables
322
- });
323
- const createUserAPIKey = (variables) => fetch$1({
324
- url: "/user/keys/{keyName}",
325
- method: "post",
326
- ...variables
327
- });
328
- const deleteUserAPIKey = (variables) => fetch$1({
329
- url: "/user/keys/{keyName}",
330
- method: "delete",
331
- ...variables
332
- });
333
- const createWorkspace = (variables) => fetch$1({
334
- url: "/workspaces",
335
- method: "post",
336
- ...variables
337
- });
338
- const getWorkspacesList = (variables) => fetch$1({
339
- url: "/workspaces",
340
- method: "get",
341
- ...variables
342
- });
343
- const getWorkspace = (variables) => fetch$1({
344
- url: "/workspaces/{workspaceId}",
716
+ const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
717
+
718
+ const getBranchList = (variables, signal) => dataPlaneFetch({
719
+ url: "/dbs/{dbName}",
345
720
  method: "get",
346
- ...variables
347
- });
348
- const updateWorkspace = (variables) => fetch$1({
349
- url: "/workspaces/{workspaceId}",
350
- method: "put",
351
- ...variables
721
+ ...variables,
722
+ signal
352
723
  });
353
- const deleteWorkspace = (variables) => fetch$1({
354
- url: "/workspaces/{workspaceId}",
355
- method: "delete",
356
- ...variables
357
- });
358
- const getWorkspaceMembersList = (variables) => fetch$1({
359
- url: "/workspaces/{workspaceId}/members",
724
+ const getBranchDetails = (variables, signal) => dataPlaneFetch({
725
+ url: "/db/{dbBranchName}",
360
726
  method: "get",
361
- ...variables
727
+ ...variables,
728
+ signal
362
729
  });
363
- const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
364
- const removeWorkspaceMember = (variables) => fetch$1({
365
- url: "/workspaces/{workspaceId}/members/{userId}",
366
- method: "delete",
367
- ...variables
368
- });
369
- const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
370
- const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
371
- const cancelWorkspaceMemberInvite = (variables) => fetch$1({
372
- url: "/workspaces/{workspaceId}/invites/{inviteId}",
730
+ const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
731
+ const deleteBranch = (variables, signal) => dataPlaneFetch({
732
+ url: "/db/{dbBranchName}",
373
733
  method: "delete",
374
- ...variables
734
+ ...variables,
735
+ signal
375
736
  });
376
- const resendWorkspaceMemberInvite = (variables) => fetch$1({
377
- url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
737
+ const copyBranch = (variables, signal) => dataPlaneFetch({
738
+ url: "/db/{dbBranchName}/copy",
378
739
  method: "post",
379
- ...variables
380
- });
381
- const acceptWorkspaceMemberInvite = (variables) => fetch$1({
382
- url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
383
- method: "post",
384
- ...variables
385
- });
386
- const getDatabaseList = (variables) => fetch$1({
387
- url: "/dbs",
388
- method: "get",
389
- ...variables
390
- });
391
- const getBranchList = (variables) => fetch$1({
392
- url: "/dbs/{dbName}",
393
- method: "get",
394
- ...variables
740
+ ...variables,
741
+ signal
395
742
  });
396
- const createDatabase = (variables) => fetch$1({
397
- url: "/dbs/{dbName}",
743
+ const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
744
+ url: "/db/{dbBranchName}/metadata",
398
745
  method: "put",
399
- ...variables
746
+ ...variables,
747
+ signal
400
748
  });
401
- const deleteDatabase = (variables) => fetch$1({
402
- url: "/dbs/{dbName}",
403
- method: "delete",
404
- ...variables
405
- });
406
- const getDatabaseMetadata = (variables) => fetch$1({
407
- url: "/dbs/{dbName}/metadata",
749
+ const getBranchMetadata = (variables, signal) => dataPlaneFetch({
750
+ url: "/db/{dbBranchName}/metadata",
408
751
  method: "get",
409
- ...variables
752
+ ...variables,
753
+ signal
410
754
  });
411
- const updateDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
412
- const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
413
- const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
414
- const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
415
- const resolveBranch = (variables) => fetch$1({
416
- url: "/dbs/{dbName}/resolveBranch",
755
+ const getBranchStats = (variables, signal) => dataPlaneFetch({
756
+ url: "/db/{dbBranchName}/stats",
417
757
  method: "get",
418
- ...variables
758
+ ...variables,
759
+ signal
419
760
  });
420
- const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
421
- const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
422
- const getMigrationRequest = (variables) => fetch$1({
761
+ const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
762
+ const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
763
+ const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
764
+ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
765
+ const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
766
+ const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
767
+ const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
768
+ const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
769
+ const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
770
+ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
423
771
  url: "/dbs/{dbName}/migrations/{mrNumber}",
424
772
  method: "get",
425
- ...variables
773
+ ...variables,
774
+ signal
426
775
  });
427
- const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
428
- const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
429
- const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
430
- const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
431
- const mergeMigrationRequest = (variables) => fetch$1({
776
+ const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
777
+ const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
778
+ const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
779
+ const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
780
+ const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
432
781
  url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
433
782
  method: "post",
434
- ...variables
435
- });
436
- const getBranchDetails = (variables) => fetch$1({
437
- url: "/db/{dbBranchName}",
438
- method: "get",
439
- ...variables
440
- });
441
- const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
442
- const deleteBranch = (variables) => fetch$1({
443
- url: "/db/{dbBranchName}",
444
- method: "delete",
445
- ...variables
446
- });
447
- const updateBranchMetadata = (variables) => fetch$1({
448
- url: "/db/{dbBranchName}/metadata",
449
- method: "put",
450
- ...variables
451
- });
452
- const getBranchMetadata = (variables) => fetch$1({
453
- url: "/db/{dbBranchName}/metadata",
454
- method: "get",
455
- ...variables
456
- });
457
- const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
458
- const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
459
- const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
460
- const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
461
- const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
462
- const updateBranchSchema = (variables) => fetch$1({
463
- url: "/db/{dbBranchName}/schema/update",
464
- method: "post",
465
- ...variables
783
+ ...variables,
784
+ signal
466
785
  });
467
- const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
468
- const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
469
- const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
470
- const getBranchStats = (variables) => fetch$1({
471
- url: "/db/{dbBranchName}/stats",
472
- method: "get",
473
- ...variables
474
- });
475
- const createTable = (variables) => fetch$1({
786
+ const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
787
+ const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
788
+ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
789
+ const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
790
+ const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
791
+ const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
792
+ const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
793
+ const createTable = (variables, signal) => dataPlaneFetch({
476
794
  url: "/db/{dbBranchName}/tables/{tableName}",
477
795
  method: "put",
478
- ...variables
796
+ ...variables,
797
+ signal
479
798
  });
480
- const deleteTable = (variables) => fetch$1({
799
+ const deleteTable = (variables, signal) => dataPlaneFetch({
481
800
  url: "/db/{dbBranchName}/tables/{tableName}",
482
801
  method: "delete",
483
- ...variables
484
- });
485
- const updateTable = (variables) => fetch$1({
486
- url: "/db/{dbBranchName}/tables/{tableName}",
487
- method: "patch",
488
- ...variables
802
+ ...variables,
803
+ signal
489
804
  });
490
- const getTableSchema = (variables) => fetch$1({
805
+ const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
806
+ const getTableSchema = (variables, signal) => dataPlaneFetch({
491
807
  url: "/db/{dbBranchName}/tables/{tableName}/schema",
492
808
  method: "get",
493
- ...variables
809
+ ...variables,
810
+ signal
494
811
  });
495
- const setTableSchema = (variables) => fetch$1({
496
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
497
- method: "put",
498
- ...variables
499
- });
500
- const getTableColumns = (variables) => fetch$1({
812
+ const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
813
+ const getTableColumns = (variables, signal) => dataPlaneFetch({
501
814
  url: "/db/{dbBranchName}/tables/{tableName}/columns",
502
815
  method: "get",
503
- ...variables
504
- });
505
- const addTableColumn = (variables) => fetch$1({
506
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
507
- method: "post",
508
- ...variables
816
+ ...variables,
817
+ signal
509
818
  });
510
- const getColumn = (variables) => fetch$1({
819
+ const addTableColumn = (variables, signal) => dataPlaneFetch(
820
+ { url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
821
+ );
822
+ const getColumn = (variables, signal) => dataPlaneFetch({
511
823
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
512
824
  method: "get",
513
- ...variables
825
+ ...variables,
826
+ signal
514
827
  });
515
- const deleteColumn = (variables) => fetch$1({
828
+ const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
829
+ const deleteColumn = (variables, signal) => dataPlaneFetch({
516
830
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
517
831
  method: "delete",
518
- ...variables
832
+ ...variables,
833
+ signal
519
834
  });
520
- const updateColumn = (variables) => fetch$1({
521
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
522
- method: "patch",
523
- ...variables
835
+ const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
836
+ const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
837
+ const getFileItem = (variables, signal) => dataPlaneFetch({
838
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
839
+ method: "get",
840
+ ...variables,
841
+ signal
524
842
  });
525
- const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
526
- const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
527
- const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
528
- const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
529
- const deleteRecord = (variables) => fetch$1({
530
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
843
+ const putFileItem = (variables, signal) => dataPlaneFetch({
844
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
845
+ method: "put",
846
+ ...variables,
847
+ signal
848
+ });
849
+ const deleteFileItem = (variables, signal) => dataPlaneFetch({
850
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
531
851
  method: "delete",
532
- ...variables
852
+ ...variables,
853
+ signal
854
+ });
855
+ const getFile = (variables, signal) => dataPlaneFetch({
856
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
857
+ method: "get",
858
+ ...variables,
859
+ signal
860
+ });
861
+ const putFile = (variables, signal) => dataPlaneFetch({
862
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
863
+ method: "put",
864
+ ...variables,
865
+ signal
533
866
  });
534
- const getRecord = (variables) => fetch$1({
867
+ const getRecord = (variables, signal) => dataPlaneFetch({
535
868
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
536
869
  method: "get",
537
- ...variables
870
+ ...variables,
871
+ signal
538
872
  });
539
- const bulkInsertTableRecords = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables });
540
- const queryTable = (variables) => fetch$1({
873
+ const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
874
+ const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
875
+ const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
876
+ const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
877
+ const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
878
+ const queryTable = (variables, signal) => dataPlaneFetch({
541
879
  url: "/db/{dbBranchName}/tables/{tableName}/query",
542
880
  method: "post",
543
- ...variables
881
+ ...variables,
882
+ signal
544
883
  });
545
- const searchTable = (variables) => fetch$1({
884
+ const searchBranch = (variables, signal) => dataPlaneFetch({
885
+ url: "/db/{dbBranchName}/search",
886
+ method: "post",
887
+ ...variables,
888
+ signal
889
+ });
890
+ const searchTable = (variables, signal) => dataPlaneFetch({
546
891
  url: "/db/{dbBranchName}/tables/{tableName}/search",
547
892
  method: "post",
548
- ...variables
893
+ ...variables,
894
+ signal
549
895
  });
550
- const searchBranch = (variables) => fetch$1({
551
- url: "/db/{dbBranchName}/search",
896
+ const sqlQuery = (variables, signal) => dataPlaneFetch({
897
+ url: "/db/{dbBranchName}/sql",
552
898
  method: "post",
553
- ...variables
899
+ ...variables,
900
+ signal
554
901
  });
555
- const summarizeTable = (variables) => fetch$1({
556
- url: "/db/{dbBranchName}/tables/{tableName}/summarize",
902
+ const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
903
+ const askTable = (variables, signal) => dataPlaneFetch({
904
+ url: "/db/{dbBranchName}/tables/{tableName}/ask",
557
905
  method: "post",
558
- ...variables
906
+ ...variables,
907
+ signal
559
908
  });
560
- const operationsByTag = {
561
- users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
562
- workspaces: {
563
- createWorkspace,
564
- getWorkspacesList,
565
- getWorkspace,
566
- updateWorkspace,
567
- deleteWorkspace,
568
- getWorkspaceMembersList,
569
- updateWorkspaceMemberRole,
570
- removeWorkspaceMember,
571
- inviteWorkspaceMember,
572
- updateWorkspaceMemberInvite,
573
- cancelWorkspaceMemberInvite,
574
- resendWorkspaceMemberInvite,
575
- acceptWorkspaceMemberInvite
576
- },
577
- database: {
578
- getDatabaseList,
579
- createDatabase,
580
- deleteDatabase,
581
- getDatabaseMetadata,
582
- updateDatabaseMetadata,
583
- getGitBranchesMapping,
584
- addGitBranchesEntry,
585
- removeGitBranchesEntry,
586
- resolveBranch
587
- },
909
+ const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
910
+ const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
911
+ const operationsByTag$2 = {
588
912
  branch: {
589
913
  getBranchList,
590
914
  getBranchDetails,
591
915
  createBranch,
592
916
  deleteBranch,
917
+ copyBranch,
593
918
  updateBranchMetadata,
594
919
  getBranchMetadata,
595
- getBranchStats
920
+ getBranchStats,
921
+ getGitBranchesMapping,
922
+ addGitBranchesEntry,
923
+ removeGitBranchesEntry,
924
+ resolveBranch
925
+ },
926
+ migrations: {
927
+ getBranchMigrationHistory,
928
+ getBranchMigrationPlan,
929
+ executeBranchMigrationPlan,
930
+ getBranchSchemaHistory,
931
+ compareBranchWithUserSchema,
932
+ compareBranchSchemas,
933
+ updateBranchSchema,
934
+ previewBranchSchemaEdit,
935
+ applyBranchSchemaEdit,
936
+ pushBranchMigrations
596
937
  },
597
938
  migrationRequests: {
598
- listMigrationRequests,
939
+ queryMigrationRequests,
599
940
  createMigrationRequest,
600
941
  getMigrationRequest,
601
942
  updateMigrationRequest,
@@ -604,17 +945,6 @@ const operationsByTag = {
604
945
  getMigrationRequestIsMerged,
605
946
  mergeMigrationRequest
606
947
  },
607
- branchSchema: {
608
- getBranchMigrationHistory,
609
- executeBranchMigrationPlan,
610
- getBranchMigrationPlan,
611
- compareBranchWithUserSchema,
612
- compareBranchSchemas,
613
- updateBranchSchema,
614
- previewBranchSchemaEdit,
615
- applyBranchSchemaEdit,
616
- getBranchSchemaHistory
617
- },
618
948
  table: {
619
949
  createTable,
620
950
  deleteTable,
@@ -624,24 +954,174 @@ const operationsByTag = {
624
954
  getTableColumns,
625
955
  addTableColumn,
626
956
  getColumn,
627
- deleteColumn,
628
- updateColumn
957
+ updateColumn,
958
+ deleteColumn
629
959
  },
630
960
  records: {
961
+ branchTransaction,
631
962
  insertRecord,
963
+ getRecord,
632
964
  insertRecordWithID,
633
965
  updateRecordWithID,
634
966
  upsertRecordWithID,
635
967
  deleteRecord,
636
- getRecord,
637
- bulkInsertTableRecords,
968
+ bulkInsertTableRecords
969
+ },
970
+ files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile },
971
+ searchAndFilter: {
638
972
  queryTable,
639
- searchTable,
640
973
  searchBranch,
641
- summarizeTable
974
+ searchTable,
975
+ sqlQuery,
976
+ vectorSearchTable,
977
+ askTable,
978
+ summarizeTable,
979
+ aggregateTable
980
+ }
981
+ };
982
+
983
+ const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
984
+
985
+ const getUser = (variables, signal) => controlPlaneFetch({
986
+ url: "/user",
987
+ method: "get",
988
+ ...variables,
989
+ signal
990
+ });
991
+ const updateUser = (variables, signal) => controlPlaneFetch({
992
+ url: "/user",
993
+ method: "put",
994
+ ...variables,
995
+ signal
996
+ });
997
+ const deleteUser = (variables, signal) => controlPlaneFetch({
998
+ url: "/user",
999
+ method: "delete",
1000
+ ...variables,
1001
+ signal
1002
+ });
1003
+ const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
1004
+ url: "/user/keys",
1005
+ method: "get",
1006
+ ...variables,
1007
+ signal
1008
+ });
1009
+ const createUserAPIKey = (variables, signal) => controlPlaneFetch({
1010
+ url: "/user/keys/{keyName}",
1011
+ method: "post",
1012
+ ...variables,
1013
+ signal
1014
+ });
1015
+ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
1016
+ url: "/user/keys/{keyName}",
1017
+ method: "delete",
1018
+ ...variables,
1019
+ signal
1020
+ });
1021
+ const getWorkspacesList = (variables, signal) => controlPlaneFetch({
1022
+ url: "/workspaces",
1023
+ method: "get",
1024
+ ...variables,
1025
+ signal
1026
+ });
1027
+ const createWorkspace = (variables, signal) => controlPlaneFetch({
1028
+ url: "/workspaces",
1029
+ method: "post",
1030
+ ...variables,
1031
+ signal
1032
+ });
1033
+ const getWorkspace = (variables, signal) => controlPlaneFetch({
1034
+ url: "/workspaces/{workspaceId}",
1035
+ method: "get",
1036
+ ...variables,
1037
+ signal
1038
+ });
1039
+ const updateWorkspace = (variables, signal) => controlPlaneFetch({
1040
+ url: "/workspaces/{workspaceId}",
1041
+ method: "put",
1042
+ ...variables,
1043
+ signal
1044
+ });
1045
+ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
1046
+ url: "/workspaces/{workspaceId}",
1047
+ method: "delete",
1048
+ ...variables,
1049
+ signal
1050
+ });
1051
+ const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
1052
+ const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
1053
+ const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
1054
+ url: "/workspaces/{workspaceId}/members/{userId}",
1055
+ method: "delete",
1056
+ ...variables,
1057
+ signal
1058
+ });
1059
+ const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
1060
+ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
1061
+ const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
1062
+ const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
1063
+ const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
1064
+ const getDatabaseList = (variables, signal) => controlPlaneFetch({
1065
+ url: "/workspaces/{workspaceId}/dbs",
1066
+ method: "get",
1067
+ ...variables,
1068
+ signal
1069
+ });
1070
+ const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
1071
+ const deleteDatabase = (variables, signal) => controlPlaneFetch({
1072
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
1073
+ method: "delete",
1074
+ ...variables,
1075
+ signal
1076
+ });
1077
+ const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
1078
+ const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
1079
+ const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
1080
+ const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
1081
+ const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
1082
+ const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
1083
+ const listRegions = (variables, signal) => controlPlaneFetch({
1084
+ url: "/workspaces/{workspaceId}/regions",
1085
+ method: "get",
1086
+ ...variables,
1087
+ signal
1088
+ });
1089
+ const operationsByTag$1 = {
1090
+ users: { getUser, updateUser, deleteUser },
1091
+ authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
1092
+ workspaces: {
1093
+ getWorkspacesList,
1094
+ createWorkspace,
1095
+ getWorkspace,
1096
+ updateWorkspace,
1097
+ deleteWorkspace,
1098
+ getWorkspaceMembersList,
1099
+ updateWorkspaceMemberRole,
1100
+ removeWorkspaceMember
1101
+ },
1102
+ invites: {
1103
+ inviteWorkspaceMember,
1104
+ updateWorkspaceMemberInvite,
1105
+ cancelWorkspaceMemberInvite,
1106
+ acceptWorkspaceMemberInvite,
1107
+ resendWorkspaceMemberInvite
1108
+ },
1109
+ databases: {
1110
+ getDatabaseList,
1111
+ createDatabase,
1112
+ deleteDatabase,
1113
+ getDatabaseMetadata,
1114
+ updateDatabaseMetadata,
1115
+ renameDatabase,
1116
+ getDatabaseGithubSettings,
1117
+ updateDatabaseGithubSettings,
1118
+ deleteDatabaseGithubSettings,
1119
+ listRegions
642
1120
  }
643
1121
  };
644
1122
 
1123
+ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
1124
+
645
1125
  function getHostUrl(provider, type) {
646
1126
  if (isHostProviderAlias(provider)) {
647
1127
  return providers[provider][type];
@@ -653,11 +1133,15 @@ function getHostUrl(provider, type) {
653
1133
  const providers = {
654
1134
  production: {
655
1135
  main: "https://api.xata.io",
656
- workspaces: "https://{workspaceId}.xata.sh"
1136
+ workspaces: "https://{workspaceId}.{region}.xata.sh"
657
1137
  },
658
1138
  staging: {
659
- main: "https://staging.xatabase.co",
660
- workspaces: "https://{workspaceId}.staging.xatabase.co"
1139
+ main: "https://api.staging-xata.dev",
1140
+ workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
1141
+ },
1142
+ dev: {
1143
+ main: "https://api.dev-xata.dev",
1144
+ workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
661
1145
  }
662
1146
  };
663
1147
  function isHostProviderAlias(alias) {
@@ -666,6 +1150,32 @@ function isHostProviderAlias(alias) {
666
1150
  function isHostProviderBuilder(builder) {
667
1151
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
668
1152
  }
1153
+ function parseProviderString(provider = "production") {
1154
+ if (isHostProviderAlias(provider)) {
1155
+ return provider;
1156
+ }
1157
+ const [main, workspaces] = provider.split(",");
1158
+ if (!main || !workspaces)
1159
+ return null;
1160
+ return { main, workspaces };
1161
+ }
1162
+ function buildProviderString(provider) {
1163
+ if (isHostProviderAlias(provider))
1164
+ return provider;
1165
+ return `${provider.main},${provider.workspaces}`;
1166
+ }
1167
+ function parseWorkspacesUrlParts(url) {
1168
+ if (!isString(url))
1169
+ return null;
1170
+ const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
1171
+ const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
1172
+ const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
1173
+ const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
1174
+ const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
1175
+ if (!match)
1176
+ return null;
1177
+ return { workspace: match[1], region: match[2] };
1178
+ }
669
1179
 
670
1180
  var __accessCheck$7 = (obj, member, msg) => {
671
1181
  if (!member.has(obj))
@@ -693,15 +1203,19 @@ class XataApiClient {
693
1203
  const provider = options.host ?? "production";
694
1204
  const apiKey = options.apiKey ?? getAPIKey();
695
1205
  const trace = options.trace ?? defaultTrace;
1206
+ const clientID = generateUUID();
696
1207
  if (!apiKey) {
697
1208
  throw new Error("Could not resolve a valid apiKey");
698
1209
  }
699
1210
  __privateSet$7(this, _extraProps, {
700
1211
  apiUrl: getHostUrl(provider, "main"),
701
1212
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
702
- fetchImpl: getFetchImplementation(options.fetch),
1213
+ fetch: getFetchImplementation(options.fetch),
703
1214
  apiKey,
704
- trace
1215
+ trace,
1216
+ clientName: options.clientName,
1217
+ xataAgentExtra: options.xataAgentExtra,
1218
+ clientID
705
1219
  });
706
1220
  }
707
1221
  get user() {
@@ -709,21 +1223,41 @@ class XataApiClient {
709
1223
  __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
710
1224
  return __privateGet$7(this, _namespaces).user;
711
1225
  }
1226
+ get authentication() {
1227
+ if (!__privateGet$7(this, _namespaces).authentication)
1228
+ __privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
1229
+ return __privateGet$7(this, _namespaces).authentication;
1230
+ }
712
1231
  get workspaces() {
713
1232
  if (!__privateGet$7(this, _namespaces).workspaces)
714
1233
  __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
715
1234
  return __privateGet$7(this, _namespaces).workspaces;
716
1235
  }
717
- get databases() {
718
- if (!__privateGet$7(this, _namespaces).databases)
719
- __privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
720
- return __privateGet$7(this, _namespaces).databases;
1236
+ get invites() {
1237
+ if (!__privateGet$7(this, _namespaces).invites)
1238
+ __privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
1239
+ return __privateGet$7(this, _namespaces).invites;
1240
+ }
1241
+ get database() {
1242
+ if (!__privateGet$7(this, _namespaces).database)
1243
+ __privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
1244
+ return __privateGet$7(this, _namespaces).database;
721
1245
  }
722
1246
  get branches() {
723
1247
  if (!__privateGet$7(this, _namespaces).branches)
724
1248
  __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
725
1249
  return __privateGet$7(this, _namespaces).branches;
726
1250
  }
1251
+ get migrations() {
1252
+ if (!__privateGet$7(this, _namespaces).migrations)
1253
+ __privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
1254
+ return __privateGet$7(this, _namespaces).migrations;
1255
+ }
1256
+ get migrationRequests() {
1257
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
1258
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
1259
+ return __privateGet$7(this, _namespaces).migrationRequests;
1260
+ }
727
1261
  get tables() {
728
1262
  if (!__privateGet$7(this, _namespaces).tables)
729
1263
  __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
@@ -734,15 +1268,15 @@ class XataApiClient {
734
1268
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
735
1269
  return __privateGet$7(this, _namespaces).records;
736
1270
  }
737
- get migrationRequests() {
738
- if (!__privateGet$7(this, _namespaces).migrationRequests)
739
- __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
740
- return __privateGet$7(this, _namespaces).migrationRequests;
1271
+ get files() {
1272
+ if (!__privateGet$7(this, _namespaces).files)
1273
+ __privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
1274
+ return __privateGet$7(this, _namespaces).files;
741
1275
  }
742
- get branchSchema() {
743
- if (!__privateGet$7(this, _namespaces).branchSchema)
744
- __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
745
- return __privateGet$7(this, _namespaces).branchSchema;
1276
+ get searchAndFilter() {
1277
+ if (!__privateGet$7(this, _namespaces).searchAndFilter)
1278
+ __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
1279
+ return __privateGet$7(this, _namespaces).searchAndFilter;
746
1280
  }
747
1281
  }
748
1282
  _extraProps = new WeakMap();
@@ -754,24 +1288,29 @@ class UserApi {
754
1288
  getUser() {
755
1289
  return operationsByTag.users.getUser({ ...this.extraProps });
756
1290
  }
757
- updateUser(user) {
1291
+ updateUser({ user }) {
758
1292
  return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
759
1293
  }
760
1294
  deleteUser() {
761
1295
  return operationsByTag.users.deleteUser({ ...this.extraProps });
762
1296
  }
1297
+ }
1298
+ class AuthenticationApi {
1299
+ constructor(extraProps) {
1300
+ this.extraProps = extraProps;
1301
+ }
763
1302
  getUserAPIKeys() {
764
- return operationsByTag.users.getUserAPIKeys({ ...this.extraProps });
1303
+ return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
765
1304
  }
766
- createUserAPIKey(keyName) {
767
- return operationsByTag.users.createUserAPIKey({
768
- pathParams: { keyName },
1305
+ createUserAPIKey({ name }) {
1306
+ return operationsByTag.authentication.createUserAPIKey({
1307
+ pathParams: { keyName: name },
769
1308
  ...this.extraProps
770
1309
  });
771
1310
  }
772
- deleteUserAPIKey(keyName) {
773
- return operationsByTag.users.deleteUserAPIKey({
774
- pathParams: { keyName },
1311
+ deleteUserAPIKey({ name }) {
1312
+ return operationsByTag.authentication.deleteUserAPIKey({
1313
+ pathParams: { keyName: name },
775
1314
  ...this.extraProps
776
1315
  });
777
1316
  }
@@ -780,492 +1319,1140 @@ class WorkspaceApi {
780
1319
  constructor(extraProps) {
781
1320
  this.extraProps = extraProps;
782
1321
  }
783
- createWorkspace(workspaceMeta) {
1322
+ getWorkspacesList() {
1323
+ return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
1324
+ }
1325
+ createWorkspace({ data }) {
784
1326
  return operationsByTag.workspaces.createWorkspace({
785
- body: workspaceMeta,
1327
+ body: data,
786
1328
  ...this.extraProps
787
1329
  });
788
1330
  }
789
- getWorkspacesList() {
790
- return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
791
- }
792
- getWorkspace(workspaceId) {
1331
+ getWorkspace({ workspace }) {
793
1332
  return operationsByTag.workspaces.getWorkspace({
794
- pathParams: { workspaceId },
1333
+ pathParams: { workspaceId: workspace },
795
1334
  ...this.extraProps
796
1335
  });
797
1336
  }
798
- updateWorkspace(workspaceId, workspaceMeta) {
1337
+ updateWorkspace({
1338
+ workspace,
1339
+ update
1340
+ }) {
799
1341
  return operationsByTag.workspaces.updateWorkspace({
800
- pathParams: { workspaceId },
801
- body: workspaceMeta,
1342
+ pathParams: { workspaceId: workspace },
1343
+ body: update,
802
1344
  ...this.extraProps
803
1345
  });
804
1346
  }
805
- deleteWorkspace(workspaceId) {
1347
+ deleteWorkspace({ workspace }) {
806
1348
  return operationsByTag.workspaces.deleteWorkspace({
807
- pathParams: { workspaceId },
1349
+ pathParams: { workspaceId: workspace },
808
1350
  ...this.extraProps
809
1351
  });
810
1352
  }
811
- getWorkspaceMembersList(workspaceId) {
1353
+ getWorkspaceMembersList({ workspace }) {
812
1354
  return operationsByTag.workspaces.getWorkspaceMembersList({
813
- pathParams: { workspaceId },
1355
+ pathParams: { workspaceId: workspace },
814
1356
  ...this.extraProps
815
1357
  });
816
1358
  }
817
- updateWorkspaceMemberRole(workspaceId, userId, role) {
1359
+ updateWorkspaceMemberRole({
1360
+ workspace,
1361
+ user,
1362
+ role
1363
+ }) {
818
1364
  return operationsByTag.workspaces.updateWorkspaceMemberRole({
819
- pathParams: { workspaceId, userId },
1365
+ pathParams: { workspaceId: workspace, userId: user },
820
1366
  body: { role },
821
1367
  ...this.extraProps
822
1368
  });
823
1369
  }
824
- removeWorkspaceMember(workspaceId, userId) {
1370
+ removeWorkspaceMember({
1371
+ workspace,
1372
+ user
1373
+ }) {
825
1374
  return operationsByTag.workspaces.removeWorkspaceMember({
826
- pathParams: { workspaceId, userId },
1375
+ pathParams: { workspaceId: workspace, userId: user },
827
1376
  ...this.extraProps
828
1377
  });
829
1378
  }
830
- inviteWorkspaceMember(workspaceId, email, role) {
831
- return operationsByTag.workspaces.inviteWorkspaceMember({
832
- pathParams: { workspaceId },
1379
+ }
1380
+ class InvitesApi {
1381
+ constructor(extraProps) {
1382
+ this.extraProps = extraProps;
1383
+ }
1384
+ inviteWorkspaceMember({
1385
+ workspace,
1386
+ email,
1387
+ role
1388
+ }) {
1389
+ return operationsByTag.invites.inviteWorkspaceMember({
1390
+ pathParams: { workspaceId: workspace },
833
1391
  body: { email, role },
834
1392
  ...this.extraProps
835
1393
  });
836
1394
  }
837
- updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
838
- return operationsByTag.workspaces.updateWorkspaceMemberInvite({
839
- pathParams: { workspaceId, inviteId },
1395
+ updateWorkspaceMemberInvite({
1396
+ workspace,
1397
+ invite,
1398
+ role
1399
+ }) {
1400
+ return operationsByTag.invites.updateWorkspaceMemberInvite({
1401
+ pathParams: { workspaceId: workspace, inviteId: invite },
840
1402
  body: { role },
841
1403
  ...this.extraProps
842
1404
  });
843
1405
  }
844
- cancelWorkspaceMemberInvite(workspaceId, inviteId) {
845
- return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
846
- pathParams: { workspaceId, inviteId },
1406
+ cancelWorkspaceMemberInvite({
1407
+ workspace,
1408
+ invite
1409
+ }) {
1410
+ return operationsByTag.invites.cancelWorkspaceMemberInvite({
1411
+ pathParams: { workspaceId: workspace, inviteId: invite },
847
1412
  ...this.extraProps
848
1413
  });
849
1414
  }
850
- resendWorkspaceMemberInvite(workspaceId, inviteId) {
851
- return operationsByTag.workspaces.resendWorkspaceMemberInvite({
852
- pathParams: { workspaceId, inviteId },
1415
+ acceptWorkspaceMemberInvite({
1416
+ workspace,
1417
+ key
1418
+ }) {
1419
+ return operationsByTag.invites.acceptWorkspaceMemberInvite({
1420
+ pathParams: { workspaceId: workspace, inviteKey: key },
853
1421
  ...this.extraProps
854
1422
  });
855
1423
  }
856
- acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
857
- return operationsByTag.workspaces.acceptWorkspaceMemberInvite({
858
- pathParams: { workspaceId, inviteKey },
1424
+ resendWorkspaceMemberInvite({
1425
+ workspace,
1426
+ invite
1427
+ }) {
1428
+ return operationsByTag.invites.resendWorkspaceMemberInvite({
1429
+ pathParams: { workspaceId: workspace, inviteId: invite },
859
1430
  ...this.extraProps
860
1431
  });
861
1432
  }
862
1433
  }
863
- class DatabaseApi {
1434
+ class BranchApi {
864
1435
  constructor(extraProps) {
865
1436
  this.extraProps = extraProps;
866
1437
  }
867
- getDatabaseList(workspace) {
868
- return operationsByTag.database.getDatabaseList({
869
- pathParams: { workspace },
1438
+ getBranchList({
1439
+ workspace,
1440
+ region,
1441
+ database
1442
+ }) {
1443
+ return operationsByTag.branch.getBranchList({
1444
+ pathParams: { workspace, region, dbName: database },
1445
+ ...this.extraProps
1446
+ });
1447
+ }
1448
+ getBranchDetails({
1449
+ workspace,
1450
+ region,
1451
+ database,
1452
+ branch
1453
+ }) {
1454
+ return operationsByTag.branch.getBranchDetails({
1455
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1456
+ ...this.extraProps
1457
+ });
1458
+ }
1459
+ createBranch({
1460
+ workspace,
1461
+ region,
1462
+ database,
1463
+ branch,
1464
+ from,
1465
+ metadata
1466
+ }) {
1467
+ return operationsByTag.branch.createBranch({
1468
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1469
+ body: { from, metadata },
1470
+ ...this.extraProps
1471
+ });
1472
+ }
1473
+ deleteBranch({
1474
+ workspace,
1475
+ region,
1476
+ database,
1477
+ branch
1478
+ }) {
1479
+ return operationsByTag.branch.deleteBranch({
1480
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
870
1481
  ...this.extraProps
871
1482
  });
872
1483
  }
873
- createDatabase(workspace, dbName, options = {}) {
874
- return operationsByTag.database.createDatabase({
875
- pathParams: { workspace, dbName },
876
- body: options,
1484
+ copyBranch({
1485
+ workspace,
1486
+ region,
1487
+ database,
1488
+ branch,
1489
+ destinationBranch,
1490
+ limit
1491
+ }) {
1492
+ return operationsByTag.branch.copyBranch({
1493
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1494
+ body: { destinationBranch, limit },
877
1495
  ...this.extraProps
878
1496
  });
879
1497
  }
880
- deleteDatabase(workspace, dbName) {
881
- return operationsByTag.database.deleteDatabase({
882
- pathParams: { workspace, dbName },
1498
+ updateBranchMetadata({
1499
+ workspace,
1500
+ region,
1501
+ database,
1502
+ branch,
1503
+ metadata
1504
+ }) {
1505
+ return operationsByTag.branch.updateBranchMetadata({
1506
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1507
+ body: metadata,
883
1508
  ...this.extraProps
884
1509
  });
885
1510
  }
886
- getDatabaseMetadata(workspace, dbName) {
887
- return operationsByTag.database.getDatabaseMetadata({
888
- pathParams: { workspace, dbName },
1511
+ getBranchMetadata({
1512
+ workspace,
1513
+ region,
1514
+ database,
1515
+ branch
1516
+ }) {
1517
+ return operationsByTag.branch.getBranchMetadata({
1518
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
889
1519
  ...this.extraProps
890
1520
  });
891
1521
  }
892
- updateDatabaseMetadata(workspace, dbName, options = {}) {
893
- return operationsByTag.database.updateDatabaseMetadata({
894
- pathParams: { workspace, dbName },
895
- body: options,
1522
+ getBranchStats({
1523
+ workspace,
1524
+ region,
1525
+ database,
1526
+ branch
1527
+ }) {
1528
+ return operationsByTag.branch.getBranchStats({
1529
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
896
1530
  ...this.extraProps
897
1531
  });
898
1532
  }
899
- getGitBranchesMapping(workspace, dbName) {
900
- return operationsByTag.database.getGitBranchesMapping({
901
- pathParams: { workspace, dbName },
1533
+ getGitBranchesMapping({
1534
+ workspace,
1535
+ region,
1536
+ database
1537
+ }) {
1538
+ return operationsByTag.branch.getGitBranchesMapping({
1539
+ pathParams: { workspace, region, dbName: database },
902
1540
  ...this.extraProps
903
1541
  });
904
1542
  }
905
- addGitBranchesEntry(workspace, dbName, body) {
906
- return operationsByTag.database.addGitBranchesEntry({
907
- pathParams: { workspace, dbName },
908
- body,
1543
+ addGitBranchesEntry({
1544
+ workspace,
1545
+ region,
1546
+ database,
1547
+ gitBranch,
1548
+ xataBranch
1549
+ }) {
1550
+ return operationsByTag.branch.addGitBranchesEntry({
1551
+ pathParams: { workspace, region, dbName: database },
1552
+ body: { gitBranch, xataBranch },
909
1553
  ...this.extraProps
910
1554
  });
911
1555
  }
912
- removeGitBranchesEntry(workspace, dbName, gitBranch) {
913
- return operationsByTag.database.removeGitBranchesEntry({
914
- pathParams: { workspace, dbName },
1556
+ removeGitBranchesEntry({
1557
+ workspace,
1558
+ region,
1559
+ database,
1560
+ gitBranch
1561
+ }) {
1562
+ return operationsByTag.branch.removeGitBranchesEntry({
1563
+ pathParams: { workspace, region, dbName: database },
915
1564
  queryParams: { gitBranch },
916
1565
  ...this.extraProps
917
1566
  });
918
1567
  }
919
- resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
920
- return operationsByTag.database.resolveBranch({
921
- pathParams: { workspace, dbName },
1568
+ resolveBranch({
1569
+ workspace,
1570
+ region,
1571
+ database,
1572
+ gitBranch,
1573
+ fallbackBranch
1574
+ }) {
1575
+ return operationsByTag.branch.resolveBranch({
1576
+ pathParams: { workspace, region, dbName: database },
922
1577
  queryParams: { gitBranch, fallbackBranch },
923
1578
  ...this.extraProps
924
1579
  });
925
1580
  }
926
1581
  }
927
- class BranchApi {
1582
+ class TableApi {
928
1583
  constructor(extraProps) {
929
1584
  this.extraProps = extraProps;
930
1585
  }
931
- getBranchList(workspace, dbName) {
932
- return operationsByTag.branch.getBranchList({
933
- pathParams: { workspace, dbName },
1586
+ createTable({
1587
+ workspace,
1588
+ region,
1589
+ database,
1590
+ branch,
1591
+ table
1592
+ }) {
1593
+ return operationsByTag.table.createTable({
1594
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
934
1595
  ...this.extraProps
935
1596
  });
936
1597
  }
937
- getBranchDetails(workspace, database, branch) {
938
- return operationsByTag.branch.getBranchDetails({
939
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1598
+ deleteTable({
1599
+ workspace,
1600
+ region,
1601
+ database,
1602
+ branch,
1603
+ table
1604
+ }) {
1605
+ return operationsByTag.table.deleteTable({
1606
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
940
1607
  ...this.extraProps
941
1608
  });
942
1609
  }
943
- createBranch(workspace, database, branch, from, options = {}) {
944
- return operationsByTag.branch.createBranch({
945
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
946
- queryParams: isString(from) ? { from } : void 0,
947
- body: options,
1610
+ updateTable({
1611
+ workspace,
1612
+ region,
1613
+ database,
1614
+ branch,
1615
+ table,
1616
+ update
1617
+ }) {
1618
+ return operationsByTag.table.updateTable({
1619
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1620
+ body: update,
948
1621
  ...this.extraProps
949
1622
  });
950
1623
  }
951
- deleteBranch(workspace, database, branch) {
952
- return operationsByTag.branch.deleteBranch({
953
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1624
+ getTableSchema({
1625
+ workspace,
1626
+ region,
1627
+ database,
1628
+ branch,
1629
+ table
1630
+ }) {
1631
+ return operationsByTag.table.getTableSchema({
1632
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
954
1633
  ...this.extraProps
955
1634
  });
956
1635
  }
957
- updateBranchMetadata(workspace, database, branch, metadata = {}) {
958
- return operationsByTag.branch.updateBranchMetadata({
959
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
960
- body: metadata,
1636
+ setTableSchema({
1637
+ workspace,
1638
+ region,
1639
+ database,
1640
+ branch,
1641
+ table,
1642
+ schema
1643
+ }) {
1644
+ return operationsByTag.table.setTableSchema({
1645
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1646
+ body: schema,
961
1647
  ...this.extraProps
962
1648
  });
963
1649
  }
964
- getBranchMetadata(workspace, database, branch) {
965
- return operationsByTag.branch.getBranchMetadata({
966
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1650
+ getTableColumns({
1651
+ workspace,
1652
+ region,
1653
+ database,
1654
+ branch,
1655
+ table
1656
+ }) {
1657
+ return operationsByTag.table.getTableColumns({
1658
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
967
1659
  ...this.extraProps
968
1660
  });
969
1661
  }
970
- getBranchStats(workspace, database, branch) {
971
- return operationsByTag.branch.getBranchStats({
972
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1662
+ addTableColumn({
1663
+ workspace,
1664
+ region,
1665
+ database,
1666
+ branch,
1667
+ table,
1668
+ column
1669
+ }) {
1670
+ return operationsByTag.table.addTableColumn({
1671
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1672
+ body: column,
1673
+ ...this.extraProps
1674
+ });
1675
+ }
1676
+ getColumn({
1677
+ workspace,
1678
+ region,
1679
+ database,
1680
+ branch,
1681
+ table,
1682
+ column
1683
+ }) {
1684
+ return operationsByTag.table.getColumn({
1685
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1686
+ ...this.extraProps
1687
+ });
1688
+ }
1689
+ updateColumn({
1690
+ workspace,
1691
+ region,
1692
+ database,
1693
+ branch,
1694
+ table,
1695
+ column,
1696
+ update
1697
+ }) {
1698
+ return operationsByTag.table.updateColumn({
1699
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1700
+ body: update,
1701
+ ...this.extraProps
1702
+ });
1703
+ }
1704
+ deleteColumn({
1705
+ workspace,
1706
+ region,
1707
+ database,
1708
+ branch,
1709
+ table,
1710
+ column
1711
+ }) {
1712
+ return operationsByTag.table.deleteColumn({
1713
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
973
1714
  ...this.extraProps
974
1715
  });
975
1716
  }
976
1717
  }
977
- class TableApi {
1718
+ class RecordsApi {
978
1719
  constructor(extraProps) {
979
1720
  this.extraProps = extraProps;
980
1721
  }
981
- createTable(workspace, database, branch, tableName) {
982
- return operationsByTag.table.createTable({
983
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1722
+ insertRecord({
1723
+ workspace,
1724
+ region,
1725
+ database,
1726
+ branch,
1727
+ table,
1728
+ record,
1729
+ columns
1730
+ }) {
1731
+ return operationsByTag.records.insertRecord({
1732
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1733
+ queryParams: { columns },
1734
+ body: record,
1735
+ ...this.extraProps
1736
+ });
1737
+ }
1738
+ getRecord({
1739
+ workspace,
1740
+ region,
1741
+ database,
1742
+ branch,
1743
+ table,
1744
+ id,
1745
+ columns
1746
+ }) {
1747
+ return operationsByTag.records.getRecord({
1748
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1749
+ queryParams: { columns },
1750
+ ...this.extraProps
1751
+ });
1752
+ }
1753
+ insertRecordWithID({
1754
+ workspace,
1755
+ region,
1756
+ database,
1757
+ branch,
1758
+ table,
1759
+ id,
1760
+ record,
1761
+ columns,
1762
+ createOnly,
1763
+ ifVersion
1764
+ }) {
1765
+ return operationsByTag.records.insertRecordWithID({
1766
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1767
+ queryParams: { columns, createOnly, ifVersion },
1768
+ body: record,
1769
+ ...this.extraProps
1770
+ });
1771
+ }
1772
+ updateRecordWithID({
1773
+ workspace,
1774
+ region,
1775
+ database,
1776
+ branch,
1777
+ table,
1778
+ id,
1779
+ record,
1780
+ columns,
1781
+ ifVersion
1782
+ }) {
1783
+ return operationsByTag.records.updateRecordWithID({
1784
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1785
+ queryParams: { columns, ifVersion },
1786
+ body: record,
1787
+ ...this.extraProps
1788
+ });
1789
+ }
1790
+ upsertRecordWithID({
1791
+ workspace,
1792
+ region,
1793
+ database,
1794
+ branch,
1795
+ table,
1796
+ id,
1797
+ record,
1798
+ columns,
1799
+ ifVersion
1800
+ }) {
1801
+ return operationsByTag.records.upsertRecordWithID({
1802
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1803
+ queryParams: { columns, ifVersion },
1804
+ body: record,
1805
+ ...this.extraProps
1806
+ });
1807
+ }
1808
+ deleteRecord({
1809
+ workspace,
1810
+ region,
1811
+ database,
1812
+ branch,
1813
+ table,
1814
+ id,
1815
+ columns
1816
+ }) {
1817
+ return operationsByTag.records.deleteRecord({
1818
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1819
+ queryParams: { columns },
1820
+ ...this.extraProps
1821
+ });
1822
+ }
1823
+ bulkInsertTableRecords({
1824
+ workspace,
1825
+ region,
1826
+ database,
1827
+ branch,
1828
+ table,
1829
+ records,
1830
+ columns
1831
+ }) {
1832
+ return operationsByTag.records.bulkInsertTableRecords({
1833
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1834
+ queryParams: { columns },
1835
+ body: { records },
1836
+ ...this.extraProps
1837
+ });
1838
+ }
1839
+ branchTransaction({
1840
+ workspace,
1841
+ region,
1842
+ database,
1843
+ branch,
1844
+ operations
1845
+ }) {
1846
+ return operationsByTag.records.branchTransaction({
1847
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1848
+ body: { operations },
1849
+ ...this.extraProps
1850
+ });
1851
+ }
1852
+ }
1853
+ class FilesApi {
1854
+ constructor(extraProps) {
1855
+ this.extraProps = extraProps;
1856
+ }
1857
+ getFileItem({
1858
+ workspace,
1859
+ region,
1860
+ database,
1861
+ branch,
1862
+ table,
1863
+ record,
1864
+ column,
1865
+ fileId
1866
+ }) {
1867
+ return operationsByTag.files.getFileItem({
1868
+ pathParams: {
1869
+ workspace,
1870
+ region,
1871
+ dbBranchName: `${database}:${branch}`,
1872
+ tableName: table,
1873
+ recordId: record,
1874
+ columnName: column,
1875
+ fileId
1876
+ },
1877
+ ...this.extraProps
1878
+ });
1879
+ }
1880
+ putFileItem({
1881
+ workspace,
1882
+ region,
1883
+ database,
1884
+ branch,
1885
+ table,
1886
+ record,
1887
+ column,
1888
+ fileId,
1889
+ file
1890
+ }) {
1891
+ return operationsByTag.files.putFileItem({
1892
+ pathParams: {
1893
+ workspace,
1894
+ region,
1895
+ dbBranchName: `${database}:${branch}`,
1896
+ tableName: table,
1897
+ recordId: record,
1898
+ columnName: column,
1899
+ fileId
1900
+ },
1901
+ body: file,
1902
+ ...this.extraProps
1903
+ });
1904
+ }
1905
+ deleteFileItem({
1906
+ workspace,
1907
+ region,
1908
+ database,
1909
+ branch,
1910
+ table,
1911
+ record,
1912
+ column,
1913
+ fileId
1914
+ }) {
1915
+ return operationsByTag.files.deleteFileItem({
1916
+ pathParams: {
1917
+ workspace,
1918
+ region,
1919
+ dbBranchName: `${database}:${branch}`,
1920
+ tableName: table,
1921
+ recordId: record,
1922
+ columnName: column,
1923
+ fileId
1924
+ },
984
1925
  ...this.extraProps
985
1926
  });
986
1927
  }
987
- deleteTable(workspace, database, branch, tableName) {
988
- return operationsByTag.table.deleteTable({
989
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1928
+ getFile({
1929
+ workspace,
1930
+ region,
1931
+ database,
1932
+ branch,
1933
+ table,
1934
+ record,
1935
+ column
1936
+ }) {
1937
+ return operationsByTag.files.getFile({
1938
+ pathParams: {
1939
+ workspace,
1940
+ region,
1941
+ dbBranchName: `${database}:${branch}`,
1942
+ tableName: table,
1943
+ recordId: record,
1944
+ columnName: column
1945
+ },
990
1946
  ...this.extraProps
991
1947
  });
992
1948
  }
993
- updateTable(workspace, database, branch, tableName, options) {
994
- return operationsByTag.table.updateTable({
995
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
996
- body: options,
1949
+ putFile({
1950
+ workspace,
1951
+ region,
1952
+ database,
1953
+ branch,
1954
+ table,
1955
+ record,
1956
+ column,
1957
+ file
1958
+ }) {
1959
+ return operationsByTag.files.putFile({
1960
+ pathParams: {
1961
+ workspace,
1962
+ region,
1963
+ dbBranchName: `${database}:${branch}`,
1964
+ tableName: table,
1965
+ recordId: record,
1966
+ columnName: column
1967
+ },
1968
+ body: file,
997
1969
  ...this.extraProps
998
1970
  });
999
1971
  }
1000
- getTableSchema(workspace, database, branch, tableName) {
1001
- return operationsByTag.table.getTableSchema({
1002
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1972
+ }
1973
+ class SearchAndFilterApi {
1974
+ constructor(extraProps) {
1975
+ this.extraProps = extraProps;
1976
+ }
1977
+ queryTable({
1978
+ workspace,
1979
+ region,
1980
+ database,
1981
+ branch,
1982
+ table,
1983
+ filter,
1984
+ sort,
1985
+ page,
1986
+ columns,
1987
+ consistency
1988
+ }) {
1989
+ return operationsByTag.searchAndFilter.queryTable({
1990
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1991
+ body: { filter, sort, page, columns, consistency },
1003
1992
  ...this.extraProps
1004
1993
  });
1005
1994
  }
1006
- setTableSchema(workspace, database, branch, tableName, options) {
1007
- return operationsByTag.table.setTableSchema({
1008
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1009
- body: options,
1995
+ searchTable({
1996
+ workspace,
1997
+ region,
1998
+ database,
1999
+ branch,
2000
+ table,
2001
+ query,
2002
+ fuzziness,
2003
+ target,
2004
+ prefix,
2005
+ filter,
2006
+ highlight,
2007
+ boosters
2008
+ }) {
2009
+ return operationsByTag.searchAndFilter.searchTable({
2010
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2011
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
1010
2012
  ...this.extraProps
1011
2013
  });
1012
2014
  }
1013
- getTableColumns(workspace, database, branch, tableName) {
1014
- return operationsByTag.table.getTableColumns({
1015
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
2015
+ searchBranch({
2016
+ workspace,
2017
+ region,
2018
+ database,
2019
+ branch,
2020
+ tables,
2021
+ query,
2022
+ fuzziness,
2023
+ prefix,
2024
+ highlight
2025
+ }) {
2026
+ return operationsByTag.searchAndFilter.searchBranch({
2027
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2028
+ body: { tables, query, fuzziness, prefix, highlight },
1016
2029
  ...this.extraProps
1017
2030
  });
1018
2031
  }
1019
- addTableColumn(workspace, database, branch, tableName, column) {
1020
- return operationsByTag.table.addTableColumn({
1021
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1022
- body: column,
2032
+ vectorSearchTable({
2033
+ workspace,
2034
+ region,
2035
+ database,
2036
+ branch,
2037
+ table,
2038
+ queryVector,
2039
+ column,
2040
+ similarityFunction,
2041
+ size,
2042
+ filter
2043
+ }) {
2044
+ return operationsByTag.searchAndFilter.vectorSearchTable({
2045
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2046
+ body: { queryVector, column, similarityFunction, size, filter },
1023
2047
  ...this.extraProps
1024
2048
  });
1025
2049
  }
1026
- getColumn(workspace, database, branch, tableName, columnName) {
1027
- return operationsByTag.table.getColumn({
1028
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
2050
+ askTable({
2051
+ workspace,
2052
+ region,
2053
+ database,
2054
+ branch,
2055
+ table,
2056
+ options
2057
+ }) {
2058
+ return operationsByTag.searchAndFilter.askTable({
2059
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2060
+ body: { ...options },
1029
2061
  ...this.extraProps
1030
2062
  });
1031
2063
  }
1032
- deleteColumn(workspace, database, branch, tableName, columnName) {
1033
- return operationsByTag.table.deleteColumn({
1034
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
2064
+ summarizeTable({
2065
+ workspace,
2066
+ region,
2067
+ database,
2068
+ branch,
2069
+ table,
2070
+ filter,
2071
+ columns,
2072
+ summaries,
2073
+ sort,
2074
+ summariesFilter,
2075
+ page,
2076
+ consistency
2077
+ }) {
2078
+ return operationsByTag.searchAndFilter.summarizeTable({
2079
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2080
+ body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
1035
2081
  ...this.extraProps
1036
2082
  });
1037
2083
  }
1038
- updateColumn(workspace, database, branch, tableName, columnName, options) {
1039
- return operationsByTag.table.updateColumn({
1040
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1041
- body: options,
2084
+ aggregateTable({
2085
+ workspace,
2086
+ region,
2087
+ database,
2088
+ branch,
2089
+ table,
2090
+ filter,
2091
+ aggs
2092
+ }) {
2093
+ return operationsByTag.searchAndFilter.aggregateTable({
2094
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
2095
+ body: { filter, aggs },
1042
2096
  ...this.extraProps
1043
2097
  });
1044
2098
  }
1045
2099
  }
1046
- class RecordsApi {
2100
+ class MigrationRequestsApi {
1047
2101
  constructor(extraProps) {
1048
2102
  this.extraProps = extraProps;
1049
2103
  }
1050
- insertRecord(workspace, database, branch, tableName, record, options = {}) {
1051
- return operationsByTag.records.insertRecord({
1052
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1053
- queryParams: options,
1054
- body: record,
2104
+ queryMigrationRequests({
2105
+ workspace,
2106
+ region,
2107
+ database,
2108
+ filter,
2109
+ sort,
2110
+ page,
2111
+ columns
2112
+ }) {
2113
+ return operationsByTag.migrationRequests.queryMigrationRequests({
2114
+ pathParams: { workspace, region, dbName: database },
2115
+ body: { filter, sort, page, columns },
1055
2116
  ...this.extraProps
1056
2117
  });
1057
2118
  }
1058
- insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1059
- return operationsByTag.records.insertRecordWithID({
1060
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1061
- queryParams: options,
1062
- body: record,
2119
+ createMigrationRequest({
2120
+ workspace,
2121
+ region,
2122
+ database,
2123
+ migration
2124
+ }) {
2125
+ return operationsByTag.migrationRequests.createMigrationRequest({
2126
+ pathParams: { workspace, region, dbName: database },
2127
+ body: migration,
1063
2128
  ...this.extraProps
1064
2129
  });
1065
2130
  }
1066
- updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1067
- return operationsByTag.records.updateRecordWithID({
1068
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1069
- queryParams: options,
1070
- body: record,
2131
+ getMigrationRequest({
2132
+ workspace,
2133
+ region,
2134
+ database,
2135
+ migrationRequest
2136
+ }) {
2137
+ return operationsByTag.migrationRequests.getMigrationRequest({
2138
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1071
2139
  ...this.extraProps
1072
2140
  });
1073
2141
  }
1074
- upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1075
- return operationsByTag.records.upsertRecordWithID({
1076
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1077
- queryParams: options,
1078
- body: record,
2142
+ updateMigrationRequest({
2143
+ workspace,
2144
+ region,
2145
+ database,
2146
+ migrationRequest,
2147
+ update
2148
+ }) {
2149
+ return operationsByTag.migrationRequests.updateMigrationRequest({
2150
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
2151
+ body: update,
1079
2152
  ...this.extraProps
1080
2153
  });
1081
2154
  }
1082
- deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
1083
- return operationsByTag.records.deleteRecord({
1084
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1085
- queryParams: options,
2155
+ listMigrationRequestsCommits({
2156
+ workspace,
2157
+ region,
2158
+ database,
2159
+ migrationRequest,
2160
+ page
2161
+ }) {
2162
+ return operationsByTag.migrationRequests.listMigrationRequestsCommits({
2163
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
2164
+ body: { page },
1086
2165
  ...this.extraProps
1087
2166
  });
1088
2167
  }
1089
- getRecord(workspace, database, branch, tableName, recordId, options = {}) {
1090
- return operationsByTag.records.getRecord({
1091
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1092
- queryParams: options,
2168
+ compareMigrationRequest({
2169
+ workspace,
2170
+ region,
2171
+ database,
2172
+ migrationRequest
2173
+ }) {
2174
+ return operationsByTag.migrationRequests.compareMigrationRequest({
2175
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1093
2176
  ...this.extraProps
1094
2177
  });
1095
2178
  }
1096
- bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
1097
- return operationsByTag.records.bulkInsertTableRecords({
1098
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1099
- queryParams: options,
1100
- body: { records },
2179
+ getMigrationRequestIsMerged({
2180
+ workspace,
2181
+ region,
2182
+ database,
2183
+ migrationRequest
2184
+ }) {
2185
+ return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
2186
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1101
2187
  ...this.extraProps
1102
2188
  });
1103
2189
  }
1104
- queryTable(workspace, database, branch, tableName, query) {
1105
- return operationsByTag.records.queryTable({
1106
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1107
- body: query,
2190
+ mergeMigrationRequest({
2191
+ workspace,
2192
+ region,
2193
+ database,
2194
+ migrationRequest
2195
+ }) {
2196
+ return operationsByTag.migrationRequests.mergeMigrationRequest({
2197
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1108
2198
  ...this.extraProps
1109
2199
  });
1110
2200
  }
1111
- searchTable(workspace, database, branch, tableName, query) {
1112
- return operationsByTag.records.searchTable({
1113
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1114
- body: query,
1115
- ...this.extraProps
1116
- });
2201
+ }
2202
+ class MigrationsApi {
2203
+ constructor(extraProps) {
2204
+ this.extraProps = extraProps;
1117
2205
  }
1118
- searchBranch(workspace, database, branch, query) {
1119
- return operationsByTag.records.searchBranch({
1120
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1121
- body: query,
2206
+ getBranchMigrationHistory({
2207
+ workspace,
2208
+ region,
2209
+ database,
2210
+ branch,
2211
+ limit,
2212
+ startFrom
2213
+ }) {
2214
+ return operationsByTag.migrations.getBranchMigrationHistory({
2215
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2216
+ body: { limit, startFrom },
1122
2217
  ...this.extraProps
1123
2218
  });
1124
2219
  }
1125
- summarizeTable(workspace, database, branch, tableName, query) {
1126
- return operationsByTag.records.summarizeTable({
1127
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1128
- body: query,
2220
+ getBranchMigrationPlan({
2221
+ workspace,
2222
+ region,
2223
+ database,
2224
+ branch,
2225
+ schema
2226
+ }) {
2227
+ return operationsByTag.migrations.getBranchMigrationPlan({
2228
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2229
+ body: schema,
1129
2230
  ...this.extraProps
1130
2231
  });
1131
2232
  }
1132
- }
1133
- class MigrationRequestsApi {
1134
- constructor(extraProps) {
1135
- this.extraProps = extraProps;
1136
- }
1137
- listMigrationRequests(workspace, database, options = {}) {
1138
- return operationsByTag.migrationRequests.listMigrationRequests({
1139
- pathParams: { workspace, dbName: database },
1140
- body: options,
2233
+ executeBranchMigrationPlan({
2234
+ workspace,
2235
+ region,
2236
+ database,
2237
+ branch,
2238
+ plan
2239
+ }) {
2240
+ return operationsByTag.migrations.executeBranchMigrationPlan({
2241
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2242
+ body: plan,
1141
2243
  ...this.extraProps
1142
2244
  });
1143
2245
  }
1144
- createMigrationRequest(workspace, database, options) {
1145
- return operationsByTag.migrationRequests.createMigrationRequest({
1146
- pathParams: { workspace, dbName: database },
1147
- body: options,
2246
+ getBranchSchemaHistory({
2247
+ workspace,
2248
+ region,
2249
+ database,
2250
+ branch,
2251
+ page
2252
+ }) {
2253
+ return operationsByTag.migrations.getBranchSchemaHistory({
2254
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2255
+ body: { page },
1148
2256
  ...this.extraProps
1149
2257
  });
1150
2258
  }
1151
- getMigrationRequest(workspace, database, migrationRequest) {
1152
- return operationsByTag.migrationRequests.getMigrationRequest({
1153
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
2259
+ compareBranchWithUserSchema({
2260
+ workspace,
2261
+ region,
2262
+ database,
2263
+ branch,
2264
+ schema,
2265
+ schemaOperations,
2266
+ branchOperations
2267
+ }) {
2268
+ return operationsByTag.migrations.compareBranchWithUserSchema({
2269
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2270
+ body: { schema, schemaOperations, branchOperations },
1154
2271
  ...this.extraProps
1155
2272
  });
1156
2273
  }
1157
- updateMigrationRequest(workspace, database, migrationRequest, options) {
1158
- return operationsByTag.migrationRequests.updateMigrationRequest({
1159
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1160
- body: options,
2274
+ compareBranchSchemas({
2275
+ workspace,
2276
+ region,
2277
+ database,
2278
+ branch,
2279
+ compare,
2280
+ sourceBranchOperations,
2281
+ targetBranchOperations
2282
+ }) {
2283
+ return operationsByTag.migrations.compareBranchSchemas({
2284
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
2285
+ body: { sourceBranchOperations, targetBranchOperations },
1161
2286
  ...this.extraProps
1162
2287
  });
1163
2288
  }
1164
- listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1165
- return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1166
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1167
- body: options,
2289
+ updateBranchSchema({
2290
+ workspace,
2291
+ region,
2292
+ database,
2293
+ branch,
2294
+ migration
2295
+ }) {
2296
+ return operationsByTag.migrations.updateBranchSchema({
2297
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2298
+ body: migration,
1168
2299
  ...this.extraProps
1169
2300
  });
1170
2301
  }
1171
- compareMigrationRequest(workspace, database, migrationRequest) {
1172
- return operationsByTag.migrationRequests.compareMigrationRequest({
1173
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
2302
+ previewBranchSchemaEdit({
2303
+ workspace,
2304
+ region,
2305
+ database,
2306
+ branch,
2307
+ data
2308
+ }) {
2309
+ return operationsByTag.migrations.previewBranchSchemaEdit({
2310
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2311
+ body: data,
1174
2312
  ...this.extraProps
1175
2313
  });
1176
2314
  }
1177
- getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1178
- return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1179
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
2315
+ applyBranchSchemaEdit({
2316
+ workspace,
2317
+ region,
2318
+ database,
2319
+ branch,
2320
+ edits
2321
+ }) {
2322
+ return operationsByTag.migrations.applyBranchSchemaEdit({
2323
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2324
+ body: { edits },
1180
2325
  ...this.extraProps
1181
2326
  });
1182
2327
  }
1183
- mergeMigrationRequest(workspace, database, migrationRequest) {
1184
- return operationsByTag.migrationRequests.mergeMigrationRequest({
1185
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
2328
+ pushBranchMigrations({
2329
+ workspace,
2330
+ region,
2331
+ database,
2332
+ branch,
2333
+ migrations
2334
+ }) {
2335
+ return operationsByTag.migrations.pushBranchMigrations({
2336
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2337
+ body: { migrations },
1186
2338
  ...this.extraProps
1187
2339
  });
1188
2340
  }
1189
2341
  }
1190
- class BranchSchemaApi {
2342
+ class DatabaseApi {
1191
2343
  constructor(extraProps) {
1192
2344
  this.extraProps = extraProps;
1193
2345
  }
1194
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
1195
- return operationsByTag.branchSchema.getBranchMigrationHistory({
1196
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1197
- body: options,
2346
+ getDatabaseList({ workspace }) {
2347
+ return operationsByTag.databases.getDatabaseList({
2348
+ pathParams: { workspaceId: workspace },
1198
2349
  ...this.extraProps
1199
2350
  });
1200
2351
  }
1201
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1202
- return operationsByTag.branchSchema.executeBranchMigrationPlan({
1203
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1204
- body: migrationPlan,
2352
+ createDatabase({
2353
+ workspace,
2354
+ database,
2355
+ data
2356
+ }) {
2357
+ return operationsByTag.databases.createDatabase({
2358
+ pathParams: { workspaceId: workspace, dbName: database },
2359
+ body: data,
1205
2360
  ...this.extraProps
1206
2361
  });
1207
2362
  }
1208
- getBranchMigrationPlan(workspace, database, branch, schema) {
1209
- return operationsByTag.branchSchema.getBranchMigrationPlan({
1210
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1211
- body: schema,
2363
+ deleteDatabase({
2364
+ workspace,
2365
+ database
2366
+ }) {
2367
+ return operationsByTag.databases.deleteDatabase({
2368
+ pathParams: { workspaceId: workspace, dbName: database },
1212
2369
  ...this.extraProps
1213
2370
  });
1214
2371
  }
1215
- compareBranchWithUserSchema(workspace, database, branch, schema) {
1216
- return operationsByTag.branchSchema.compareBranchWithUserSchema({
1217
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1218
- body: { schema },
2372
+ getDatabaseMetadata({
2373
+ workspace,
2374
+ database
2375
+ }) {
2376
+ return operationsByTag.databases.getDatabaseMetadata({
2377
+ pathParams: { workspaceId: workspace, dbName: database },
1219
2378
  ...this.extraProps
1220
2379
  });
1221
2380
  }
1222
- compareBranchSchemas(workspace, database, branch, branchName, schema) {
1223
- return operationsByTag.branchSchema.compareBranchSchemas({
1224
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1225
- body: { schema },
2381
+ updateDatabaseMetadata({
2382
+ workspace,
2383
+ database,
2384
+ metadata
2385
+ }) {
2386
+ return operationsByTag.databases.updateDatabaseMetadata({
2387
+ pathParams: { workspaceId: workspace, dbName: database },
2388
+ body: metadata,
1226
2389
  ...this.extraProps
1227
2390
  });
1228
2391
  }
1229
- updateBranchSchema(workspace, database, branch, migration) {
1230
- return operationsByTag.branchSchema.updateBranchSchema({
1231
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1232
- body: migration,
2392
+ renameDatabase({
2393
+ workspace,
2394
+ database,
2395
+ newName
2396
+ }) {
2397
+ return operationsByTag.databases.renameDatabase({
2398
+ pathParams: { workspaceId: workspace, dbName: database },
2399
+ body: { newName },
1233
2400
  ...this.extraProps
1234
2401
  });
1235
2402
  }
1236
- previewBranchSchemaEdit(workspace, database, branch, migration) {
1237
- return operationsByTag.branchSchema.previewBranchSchemaEdit({
1238
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1239
- body: migration,
2403
+ getDatabaseGithubSettings({
2404
+ workspace,
2405
+ database
2406
+ }) {
2407
+ return operationsByTag.databases.getDatabaseGithubSettings({
2408
+ pathParams: { workspaceId: workspace, dbName: database },
1240
2409
  ...this.extraProps
1241
2410
  });
1242
2411
  }
1243
- applyBranchSchemaEdit(workspace, database, branch, edits) {
1244
- return operationsByTag.branchSchema.applyBranchSchemaEdit({
1245
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1246
- body: { edits },
2412
+ updateDatabaseGithubSettings({
2413
+ workspace,
2414
+ database,
2415
+ settings
2416
+ }) {
2417
+ return operationsByTag.databases.updateDatabaseGithubSettings({
2418
+ pathParams: { workspaceId: workspace, dbName: database },
2419
+ body: settings,
2420
+ ...this.extraProps
2421
+ });
2422
+ }
2423
+ deleteDatabaseGithubSettings({
2424
+ workspace,
2425
+ database
2426
+ }) {
2427
+ return operationsByTag.databases.deleteDatabaseGithubSettings({
2428
+ pathParams: { workspaceId: workspace, dbName: database },
1247
2429
  ...this.extraProps
1248
2430
  });
1249
2431
  }
1250
- getBranchSchemaHistory(workspace, database, branch, options = {}) {
1251
- return operationsByTag.branchSchema.getBranchSchemaHistory({
1252
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1253
- body: options,
2432
+ listRegions({ workspace }) {
2433
+ return operationsByTag.databases.listRegions({
2434
+ pathParams: { workspaceId: workspace },
1254
2435
  ...this.extraProps
1255
2436
  });
1256
2437
  }
1257
2438
  }
1258
2439
 
1259
2440
  class XataApiPlugin {
1260
- async build(options) {
1261
- const { fetchImpl, apiKey } = await options.getFetchProps();
1262
- return new XataApiClient({ fetch: fetchImpl, apiKey });
2441
+ build(options) {
2442
+ return new XataApiClient(options);
1263
2443
  }
1264
2444
  }
1265
2445
 
1266
2446
  class XataPlugin {
1267
2447
  }
1268
2448
 
2449
+ function cleanFilter(filter) {
2450
+ if (!filter)
2451
+ return void 0;
2452
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2453
+ return values.length > 0 ? filter : void 0;
2454
+ }
2455
+
1269
2456
  var __accessCheck$6 = (obj, member, msg) => {
1270
2457
  if (!member.has(obj))
1271
2458
  throw TypeError("Cannot " + msg);
@@ -1298,11 +2485,11 @@ class Page {
1298
2485
  async previousPage(size, offset) {
1299
2486
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
1300
2487
  }
1301
- async firstPage(size, offset) {
1302
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
2488
+ async startPage(size, offset) {
2489
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
1303
2490
  }
1304
- async lastPage(size, offset) {
1305
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
2491
+ async endPage(size, offset) {
2492
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
1306
2493
  }
1307
2494
  hasNextPage() {
1308
2495
  return this.meta.page.more;
@@ -1314,7 +2501,7 @@ const PAGINATION_DEFAULT_SIZE = 20;
1314
2501
  const PAGINATION_MAX_OFFSET = 800;
1315
2502
  const PAGINATION_DEFAULT_OFFSET = 0;
1316
2503
  function isCursorPaginationOptions(options) {
1317
- return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
2504
+ return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
1318
2505
  }
1319
2506
  const _RecordArray = class extends Array {
1320
2507
  constructor(...args) {
@@ -1335,6 +2522,12 @@ const _RecordArray = class extends Array {
1335
2522
  toArray() {
1336
2523
  return new Array(...this);
1337
2524
  }
2525
+ toSerializable() {
2526
+ return JSON.parse(this.toString());
2527
+ }
2528
+ toString() {
2529
+ return JSON.stringify(this.toArray());
2530
+ }
1338
2531
  map(callbackfn, thisArg) {
1339
2532
  return this.toArray().map(callbackfn, thisArg);
1340
2533
  }
@@ -1346,12 +2539,12 @@ const _RecordArray = class extends Array {
1346
2539
  const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
1347
2540
  return new _RecordArray(newPage);
1348
2541
  }
1349
- async firstPage(size, offset) {
1350
- const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
2542
+ async startPage(size, offset) {
2543
+ const newPage = await __privateGet$6(this, _page).startPage(size, offset);
1351
2544
  return new _RecordArray(newPage);
1352
2545
  }
1353
- async lastPage(size, offset) {
1354
- const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
2546
+ async endPage(size, offset) {
2547
+ const newPage = await __privateGet$6(this, _page).endPage(size, offset);
1355
2548
  return new _RecordArray(newPage);
1356
2549
  }
1357
2550
  hasNextPage() {
@@ -1379,9 +2572,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
1379
2572
  setter ? setter.call(obj, value) : member.set(obj, value);
1380
2573
  return value;
1381
2574
  };
1382
- var _table$1, _repository, _data;
2575
+ var __privateMethod$3 = (obj, member, method) => {
2576
+ __accessCheck$5(obj, member, "access private method");
2577
+ return method;
2578
+ };
2579
+ var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
1383
2580
  const _Query = class {
1384
2581
  constructor(repository, table, data, rawParent) {
2582
+ __privateAdd$5(this, _cleanFilterConstraint);
1385
2583
  __privateAdd$5(this, _table$1, void 0);
1386
2584
  __privateAdd$5(this, _repository, void 0);
1387
2585
  __privateAdd$5(this, _data, { filter: {} });
@@ -1400,9 +2598,11 @@ const _Query = class {
1400
2598
  __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
1401
2599
  __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
1402
2600
  __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
1403
- __privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
2601
+ __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
2602
+ __privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
1404
2603
  __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
1405
2604
  __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
2605
+ __privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
1406
2606
  this.any = this.any.bind(this);
1407
2607
  this.all = this.all.bind(this);
1408
2608
  this.not = this.not.bind(this);
@@ -1439,26 +2639,16 @@ const _Query = class {
1439
2639
  filter(a, b) {
1440
2640
  if (arguments.length === 1) {
1441
2641
  const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
1442
- [column]: this.cleanFilterConstraint(column, constraint)
2642
+ [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
1443
2643
  }));
1444
2644
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1445
2645
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1446
2646
  } else {
1447
- const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.cleanFilterConstraint(a, b) }] : void 0;
2647
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
1448
2648
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1449
2649
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1450
2650
  }
1451
2651
  }
1452
- cleanFilterConstraint(column, value) {
1453
- const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
1454
- if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
1455
- return { $includes: value };
1456
- }
1457
- if (columnType === "link" && isObject(value) && isString(value.id)) {
1458
- return value.id;
1459
- }
1460
- return value;
1461
- }
1462
2652
  sort(column, direction = "asc") {
1463
2653
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1464
2654
  const sort = [...originalSort, { column, direction }];
@@ -1526,19 +2716,29 @@ const _Query = class {
1526
2716
  throw new Error("No results found.");
1527
2717
  return records[0];
1528
2718
  }
2719
+ async summarize(params = {}) {
2720
+ const { summaries, summariesFilter, ...options } = params;
2721
+ const query = new _Query(
2722
+ __privateGet$5(this, _repository),
2723
+ __privateGet$5(this, _table$1),
2724
+ options,
2725
+ __privateGet$5(this, _data)
2726
+ );
2727
+ return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
2728
+ }
1529
2729
  cache(ttl) {
1530
2730
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1531
2731
  }
1532
2732
  nextPage(size, offset) {
1533
- return this.firstPage(size, offset);
2733
+ return this.startPage(size, offset);
1534
2734
  }
1535
2735
  previousPage(size, offset) {
1536
- return this.firstPage(size, offset);
2736
+ return this.startPage(size, offset);
1537
2737
  }
1538
- firstPage(size, offset) {
2738
+ startPage(size, offset) {
1539
2739
  return this.getPaginated({ pagination: { size, offset } });
1540
2740
  }
1541
- lastPage(size, offset) {
2741
+ endPage(size, offset) {
1542
2742
  return this.getPaginated({ pagination: { size, offset, before: "end" } });
1543
2743
  }
1544
2744
  hasNextPage() {
@@ -1549,9 +2749,20 @@ let Query = _Query;
1549
2749
  _table$1 = new WeakMap();
1550
2750
  _repository = new WeakMap();
1551
2751
  _data = new WeakMap();
2752
+ _cleanFilterConstraint = new WeakSet();
2753
+ cleanFilterConstraint_fn = function(column, value) {
2754
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
2755
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
2756
+ return { $includes: value };
2757
+ }
2758
+ if (columnType === "link" && isObject(value) && isString(value.id)) {
2759
+ return value.id;
2760
+ }
2761
+ return value;
2762
+ };
1552
2763
  function cleanParent(data, parent) {
1553
2764
  if (isCursorPaginationOptions(data.pagination)) {
1554
- return { ...parent, sorting: void 0, filter: void 0 };
2765
+ return { ...parent, sort: void 0, filter: void 0 };
1555
2766
  }
1556
2767
  return parent;
1557
2768
  }
@@ -1569,7 +2780,11 @@ function isSortFilterString(value) {
1569
2780
  return isString(value);
1570
2781
  }
1571
2782
  function isSortFilterBase(filter) {
1572
- return isObject(filter) && Object.values(filter).every((value) => value === "asc" || value === "desc");
2783
+ return isObject(filter) && Object.entries(filter).every(([key, value]) => {
2784
+ if (key === "*")
2785
+ return value === "random";
2786
+ return value === "asc" || value === "desc";
2787
+ });
1573
2788
  }
1574
2789
  function isSortFilterObject(filter) {
1575
2790
  return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
@@ -1610,7 +2825,8 @@ var __privateMethod$2 = (obj, member, method) => {
1610
2825
  __accessCheck$4(obj, member, "access private method");
1611
2826
  return method;
1612
2827
  };
1613
- var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
2828
+ 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;
2829
+ const BULK_OPERATION_MAX_SIZE = 1e3;
1614
2830
  class Repository extends Query {
1615
2831
  }
1616
2832
  class RestRepository extends Query {
@@ -1622,10 +2838,12 @@ class RestRepository extends Query {
1622
2838
  );
1623
2839
  __privateAdd$4(this, _insertRecordWithoutId);
1624
2840
  __privateAdd$4(this, _insertRecordWithId);
1625
- __privateAdd$4(this, _bulkInsertTableRecords);
2841
+ __privateAdd$4(this, _insertRecords);
1626
2842
  __privateAdd$4(this, _updateRecordWithID);
2843
+ __privateAdd$4(this, _updateRecords);
1627
2844
  __privateAdd$4(this, _upsertRecordWithID);
1628
2845
  __privateAdd$4(this, _deleteRecord);
2846
+ __privateAdd$4(this, _deleteRecords);
1629
2847
  __privateAdd$4(this, _setCacheQuery);
1630
2848
  __privateAdd$4(this, _getCacheQuery);
1631
2849
  __privateAdd$4(this, _getSchemaTables$1);
@@ -1636,10 +2854,10 @@ class RestRepository extends Query {
1636
2854
  __privateAdd$4(this, _schemaTables$2, void 0);
1637
2855
  __privateAdd$4(this, _trace, void 0);
1638
2856
  __privateSet$4(this, _table, options.table);
1639
- __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1640
2857
  __privateSet$4(this, _db, options.db);
1641
2858
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1642
2859
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
2860
+ __privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
1643
2861
  const trace = options.pluginOptions.trace ?? defaultTrace;
1644
2862
  __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
1645
2863
  return trace(name, fn, {
@@ -1650,25 +2868,28 @@ class RestRepository extends Query {
1650
2868
  });
1651
2869
  });
1652
2870
  }
1653
- async create(a, b, c) {
2871
+ async create(a, b, c, d) {
1654
2872
  return __privateGet$4(this, _trace).call(this, "create", async () => {
2873
+ const ifVersion = parseIfVersion(b, c, d);
1655
2874
  if (Array.isArray(a)) {
1656
2875
  if (a.length === 0)
1657
2876
  return [];
1658
- const columns = isStringArray(b) ? b : void 0;
1659
- return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
2877
+ const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
2878
+ const columns = isStringArray(b) ? b : ["*"];
2879
+ const result = await this.read(ids, columns);
2880
+ return result;
1660
2881
  }
1661
2882
  if (isString(a) && isObject(b)) {
1662
2883
  if (a === "")
1663
2884
  throw new Error("The id can't be empty");
1664
2885
  const columns = isStringArray(c) ? c : void 0;
1665
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
2886
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
1666
2887
  }
1667
2888
  if (isObject(a) && isString(a.id)) {
1668
2889
  if (a.id === "")
1669
2890
  throw new Error("The id can't be empty");
1670
2891
  const columns = isStringArray(b) ? b : void 0;
1671
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2892
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
1672
2893
  }
1673
2894
  if (isObject(a)) {
1674
2895
  const columns = isStringArray(b) ? b : void 0;
@@ -1693,20 +2914,20 @@ class RestRepository extends Query {
1693
2914
  }
1694
2915
  const id = extractId(a);
1695
2916
  if (id) {
1696
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1697
2917
  try {
1698
2918
  const response = await getRecord({
1699
2919
  pathParams: {
1700
2920
  workspace: "{workspaceId}",
1701
2921
  dbBranchName: "{dbBranch}",
2922
+ region: "{region}",
1702
2923
  tableName: __privateGet$4(this, _table),
1703
2924
  recordId: id
1704
2925
  },
1705
2926
  queryParams: { columns },
1706
- ...fetchProps
2927
+ ...__privateGet$4(this, _getFetchProps).call(this)
1707
2928
  });
1708
2929
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1709
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2930
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1710
2931
  } catch (e) {
1711
2932
  if (isObject(e) && e.status === 404) {
1712
2933
  return null;
@@ -1736,31 +2957,42 @@ class RestRepository extends Query {
1736
2957
  return result;
1737
2958
  });
1738
2959
  }
1739
- async update(a, b, c) {
2960
+ async update(a, b, c, d) {
1740
2961
  return __privateGet$4(this, _trace).call(this, "update", async () => {
2962
+ const ifVersion = parseIfVersion(b, c, d);
1741
2963
  if (Array.isArray(a)) {
1742
2964
  if (a.length === 0)
1743
2965
  return [];
1744
- if (a.length > 100) {
1745
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1746
- }
2966
+ const existing = await this.read(a, ["id"]);
2967
+ const updates = a.filter((_item, index) => existing[index] !== null);
2968
+ await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
2969
+ ifVersion,
2970
+ upsert: false
2971
+ });
1747
2972
  const columns = isStringArray(b) ? b : ["*"];
1748
- return Promise.all(a.map((object) => this.update(object, columns)));
1749
- }
1750
- if (isString(a) && isObject(b)) {
1751
- const columns = isStringArray(c) ? c : void 0;
1752
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
2973
+ const result = await this.read(a, columns);
2974
+ return result;
1753
2975
  }
1754
- if (isObject(a) && isString(a.id)) {
1755
- const columns = isStringArray(b) ? b : void 0;
1756
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2976
+ try {
2977
+ if (isString(a) && isObject(b)) {
2978
+ const columns = isStringArray(c) ? c : void 0;
2979
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2980
+ }
2981
+ if (isObject(a) && isString(a.id)) {
2982
+ const columns = isStringArray(b) ? b : void 0;
2983
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2984
+ }
2985
+ } catch (error) {
2986
+ if (error.status === 422)
2987
+ return null;
2988
+ throw error;
1757
2989
  }
1758
2990
  throw new Error("Invalid arguments for update method");
1759
2991
  });
1760
2992
  }
1761
- async updateOrThrow(a, b, c) {
2993
+ async updateOrThrow(a, b, c, d) {
1762
2994
  return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1763
- const result = await this.update(a, b, c);
2995
+ const result = await this.update(a, b, c, d);
1764
2996
  if (Array.isArray(result)) {
1765
2997
  const missingIds = compact(
1766
2998
  a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
@@ -1777,37 +3009,69 @@ class RestRepository extends Query {
1777
3009
  return result;
1778
3010
  });
1779
3011
  }
1780
- async createOrUpdate(a, b, c) {
3012
+ async createOrUpdate(a, b, c, d) {
1781
3013
  return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
3014
+ const ifVersion = parseIfVersion(b, c, d);
1782
3015
  if (Array.isArray(a)) {
1783
3016
  if (a.length === 0)
1784
3017
  return [];
1785
- if (a.length > 100) {
1786
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1787
- }
3018
+ await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
3019
+ ifVersion,
3020
+ upsert: true
3021
+ });
1788
3022
  const columns = isStringArray(b) ? b : ["*"];
1789
- return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
3023
+ const result = await this.read(a, columns);
3024
+ return result;
1790
3025
  }
1791
3026
  if (isString(a) && isObject(b)) {
1792
3027
  const columns = isStringArray(c) ? c : void 0;
1793
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
3028
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1794
3029
  }
1795
3030
  if (isObject(a) && isString(a.id)) {
1796
3031
  const columns = isStringArray(c) ? c : void 0;
1797
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
3032
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
1798
3033
  }
1799
3034
  throw new Error("Invalid arguments for createOrUpdate method");
1800
3035
  });
1801
3036
  }
3037
+ async createOrReplace(a, b, c, d) {
3038
+ return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
3039
+ const ifVersion = parseIfVersion(b, c, d);
3040
+ if (Array.isArray(a)) {
3041
+ if (a.length === 0)
3042
+ return [];
3043
+ const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
3044
+ const columns = isStringArray(b) ? b : ["*"];
3045
+ const result = await this.read(ids, columns);
3046
+ return result;
3047
+ }
3048
+ if (isString(a) && isObject(b)) {
3049
+ const columns = isStringArray(c) ? c : void 0;
3050
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
3051
+ }
3052
+ if (isObject(a) && isString(a.id)) {
3053
+ const columns = isStringArray(c) ? c : void 0;
3054
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
3055
+ }
3056
+ throw new Error("Invalid arguments for createOrReplace method");
3057
+ });
3058
+ }
1802
3059
  async delete(a, b) {
1803
3060
  return __privateGet$4(this, _trace).call(this, "delete", async () => {
1804
3061
  if (Array.isArray(a)) {
1805
3062
  if (a.length === 0)
1806
3063
  return [];
1807
- if (a.length > 100) {
1808
- console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1809
- }
1810
- return Promise.all(a.map((id) => this.delete(id, b)));
3064
+ const ids = a.map((o) => {
3065
+ if (isString(o))
3066
+ return o;
3067
+ if (isString(o.id))
3068
+ return o.id;
3069
+ throw new Error("Invalid arguments for delete method");
3070
+ });
3071
+ const columns = isStringArray(b) ? b : ["*"];
3072
+ const result = await this.read(a, columns);
3073
+ await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
3074
+ return result;
1811
3075
  }
1812
3076
  if (isString(a)) {
1813
3077
  return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
@@ -1838,21 +3102,64 @@ class RestRepository extends Query {
1838
3102
  }
1839
3103
  async search(query, options = {}) {
1840
3104
  return __privateGet$4(this, _trace).call(this, "search", async () => {
1841
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1842
3105
  const { records } = await searchTable({
1843
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
3106
+ pathParams: {
3107
+ workspace: "{workspaceId}",
3108
+ dbBranchName: "{dbBranch}",
3109
+ region: "{region}",
3110
+ tableName: __privateGet$4(this, _table)
3111
+ },
1844
3112
  body: {
1845
3113
  query,
1846
3114
  fuzziness: options.fuzziness,
1847
3115
  prefix: options.prefix,
1848
3116
  highlight: options.highlight,
1849
3117
  filter: options.filter,
1850
- boosters: options.boosters
3118
+ boosters: options.boosters,
3119
+ page: options.page,
3120
+ target: options.target
3121
+ },
3122
+ ...__privateGet$4(this, _getFetchProps).call(this)
3123
+ });
3124
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3125
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3126
+ });
3127
+ }
3128
+ async vectorSearch(column, query, options) {
3129
+ return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
3130
+ const { records } = await vectorSearchTable({
3131
+ pathParams: {
3132
+ workspace: "{workspaceId}",
3133
+ dbBranchName: "{dbBranch}",
3134
+ region: "{region}",
3135
+ tableName: __privateGet$4(this, _table)
3136
+ },
3137
+ body: {
3138
+ column,
3139
+ queryVector: query,
3140
+ similarityFunction: options?.similarityFunction,
3141
+ size: options?.size,
3142
+ filter: options?.filter
1851
3143
  },
1852
- ...fetchProps
3144
+ ...__privateGet$4(this, _getFetchProps).call(this)
1853
3145
  });
1854
3146
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1855
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
3147
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3148
+ });
3149
+ }
3150
+ async aggregate(aggs, filter) {
3151
+ return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
3152
+ const result = await aggregateTable({
3153
+ pathParams: {
3154
+ workspace: "{workspaceId}",
3155
+ dbBranchName: "{dbBranch}",
3156
+ region: "{region}",
3157
+ tableName: __privateGet$4(this, _table)
3158
+ },
3159
+ body: { aggs, filter },
3160
+ ...__privateGet$4(this, _getFetchProps).call(this)
3161
+ });
3162
+ return result;
1856
3163
  });
1857
3164
  }
1858
3165
  async query(query) {
@@ -1861,24 +3168,83 @@ class RestRepository extends Query {
1861
3168
  if (cacheQuery)
1862
3169
  return new Page(query, cacheQuery.meta, cacheQuery.records);
1863
3170
  const data = query.getQueryOptions();
1864
- const body = {
1865
- filter: cleanFilter(data.filter),
1866
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1867
- page: data.pagination,
1868
- columns: data.columns
1869
- };
1870
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1871
3171
  const { meta, records: objects } = await queryTable({
1872
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1873
- body,
1874
- ...fetchProps
3172
+ pathParams: {
3173
+ workspace: "{workspaceId}",
3174
+ dbBranchName: "{dbBranch}",
3175
+ region: "{region}",
3176
+ tableName: __privateGet$4(this, _table)
3177
+ },
3178
+ body: {
3179
+ filter: cleanFilter(data.filter),
3180
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
3181
+ page: data.pagination,
3182
+ columns: data.columns ?? ["*"],
3183
+ consistency: data.consistency
3184
+ },
3185
+ fetchOptions: data.fetchOptions,
3186
+ ...__privateGet$4(this, _getFetchProps).call(this)
1875
3187
  });
1876
3188
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1877
- const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
3189
+ const records = objects.map(
3190
+ (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
3191
+ );
1878
3192
  await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1879
3193
  return new Page(query, meta, records);
1880
3194
  });
1881
3195
  }
3196
+ async summarizeTable(query, summaries, summariesFilter) {
3197
+ return __privateGet$4(this, _trace).call(this, "summarize", async () => {
3198
+ const data = query.getQueryOptions();
3199
+ const result = await summarizeTable({
3200
+ pathParams: {
3201
+ workspace: "{workspaceId}",
3202
+ dbBranchName: "{dbBranch}",
3203
+ region: "{region}",
3204
+ tableName: __privateGet$4(this, _table)
3205
+ },
3206
+ body: {
3207
+ filter: cleanFilter(data.filter),
3208
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
3209
+ columns: data.columns,
3210
+ consistency: data.consistency,
3211
+ page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
3212
+ summaries,
3213
+ summariesFilter
3214
+ },
3215
+ ...__privateGet$4(this, _getFetchProps).call(this)
3216
+ });
3217
+ return result;
3218
+ });
3219
+ }
3220
+ ask(question, options) {
3221
+ const params = {
3222
+ pathParams: {
3223
+ workspace: "{workspaceId}",
3224
+ dbBranchName: "{dbBranch}",
3225
+ region: "{region}",
3226
+ tableName: __privateGet$4(this, _table)
3227
+ },
3228
+ body: {
3229
+ question,
3230
+ ...options
3231
+ },
3232
+ ...__privateGet$4(this, _getFetchProps).call(this)
3233
+ };
3234
+ if (options?.onMessage) {
3235
+ fetchSSERequest({
3236
+ endpoint: "dataPlane",
3237
+ url: "/db/{dbBranchName}/tables/{tableName}/ask",
3238
+ method: "POST",
3239
+ onMessage: (message) => {
3240
+ options.onMessage?.({ answer: message.text, records: message.records });
3241
+ },
3242
+ ...params
3243
+ });
3244
+ } else {
3245
+ return askTable(params);
3246
+ }
3247
+ }
1882
3248
  }
1883
3249
  _table = new WeakMap();
1884
3250
  _getFetchProps = new WeakMap();
@@ -1888,68 +3254,86 @@ _schemaTables$2 = new WeakMap();
1888
3254
  _trace = new WeakMap();
1889
3255
  _insertRecordWithoutId = new WeakSet();
1890
3256
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1891
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1892
3257
  const record = transformObjectLinks(object);
1893
3258
  const response = await insertRecord({
1894
3259
  pathParams: {
1895
3260
  workspace: "{workspaceId}",
1896
3261
  dbBranchName: "{dbBranch}",
3262
+ region: "{region}",
1897
3263
  tableName: __privateGet$4(this, _table)
1898
3264
  },
1899
3265
  queryParams: { columns },
1900
3266
  body: record,
1901
- ...fetchProps
3267
+ ...__privateGet$4(this, _getFetchProps).call(this)
1902
3268
  });
1903
3269
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1904
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
3270
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1905
3271
  };
1906
3272
  _insertRecordWithId = new WeakSet();
1907
- insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
1908
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
3273
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
1909
3274
  const record = transformObjectLinks(object);
1910
3275
  const response = await insertRecordWithID({
1911
3276
  pathParams: {
1912
3277
  workspace: "{workspaceId}",
1913
3278
  dbBranchName: "{dbBranch}",
3279
+ region: "{region}",
1914
3280
  tableName: __privateGet$4(this, _table),
1915
3281
  recordId
1916
3282
  },
1917
3283
  body: record,
1918
- queryParams: { createOnly: true, columns },
1919
- ...fetchProps
3284
+ queryParams: { createOnly, columns, ifVersion },
3285
+ ...__privateGet$4(this, _getFetchProps).call(this)
1920
3286
  });
1921
3287
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1922
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1923
- };
1924
- _bulkInsertTableRecords = new WeakSet();
1925
- bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1926
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1927
- const records = objects.map((object) => transformObjectLinks(object));
1928
- const response = await bulkInsertTableRecords({
1929
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1930
- queryParams: { columns },
1931
- body: { records },
1932
- ...fetchProps
1933
- });
1934
- if (!isResponseWithRecords(response)) {
1935
- throw new Error("Request included columns but server didn't include them");
3288
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
3289
+ };
3290
+ _insertRecords = new WeakSet();
3291
+ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
3292
+ const chunkedOperations = chunk(
3293
+ objects.map((object) => ({
3294
+ insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
3295
+ })),
3296
+ BULK_OPERATION_MAX_SIZE
3297
+ );
3298
+ const ids = [];
3299
+ for (const operations of chunkedOperations) {
3300
+ const { results } = await branchTransaction({
3301
+ pathParams: {
3302
+ workspace: "{workspaceId}",
3303
+ dbBranchName: "{dbBranch}",
3304
+ region: "{region}"
3305
+ },
3306
+ body: { operations },
3307
+ ...__privateGet$4(this, _getFetchProps).call(this)
3308
+ });
3309
+ for (const result of results) {
3310
+ if (result.operation === "insert") {
3311
+ ids.push(result.id);
3312
+ } else {
3313
+ ids.push(null);
3314
+ }
3315
+ }
1936
3316
  }
1937
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1938
- return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
3317
+ return ids;
1939
3318
  };
1940
3319
  _updateRecordWithID = new WeakSet();
1941
- updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1942
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1943
- const record = transformObjectLinks(object);
3320
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
3321
+ const { id: _id, ...record } = transformObjectLinks(object);
1944
3322
  try {
1945
3323
  const response = await updateRecordWithID({
1946
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1947
- queryParams: { columns },
3324
+ pathParams: {
3325
+ workspace: "{workspaceId}",
3326
+ dbBranchName: "{dbBranch}",
3327
+ region: "{region}",
3328
+ tableName: __privateGet$4(this, _table),
3329
+ recordId
3330
+ },
3331
+ queryParams: { columns, ifVersion },
1948
3332
  body: record,
1949
- ...fetchProps
3333
+ ...__privateGet$4(this, _getFetchProps).call(this)
1950
3334
  });
1951
3335
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1952
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
3336
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1953
3337
  } catch (e) {
1954
3338
  if (isObject(e) && e.status === 404) {
1955
3339
  return null;
@@ -1957,29 +3341,68 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1957
3341
  throw e;
1958
3342
  }
1959
3343
  };
3344
+ _updateRecords = new WeakSet();
3345
+ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
3346
+ const chunkedOperations = chunk(
3347
+ objects.map(({ id, ...object }) => ({
3348
+ update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
3349
+ })),
3350
+ BULK_OPERATION_MAX_SIZE
3351
+ );
3352
+ const ids = [];
3353
+ for (const operations of chunkedOperations) {
3354
+ const { results } = await branchTransaction({
3355
+ pathParams: {
3356
+ workspace: "{workspaceId}",
3357
+ dbBranchName: "{dbBranch}",
3358
+ region: "{region}"
3359
+ },
3360
+ body: { operations },
3361
+ ...__privateGet$4(this, _getFetchProps).call(this)
3362
+ });
3363
+ for (const result of results) {
3364
+ if (result.operation === "update") {
3365
+ ids.push(result.id);
3366
+ } else {
3367
+ ids.push(null);
3368
+ }
3369
+ }
3370
+ }
3371
+ return ids;
3372
+ };
1960
3373
  _upsertRecordWithID = new WeakSet();
1961
- upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1962
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
3374
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
1963
3375
  const response = await upsertRecordWithID({
1964
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1965
- queryParams: { columns },
3376
+ pathParams: {
3377
+ workspace: "{workspaceId}",
3378
+ dbBranchName: "{dbBranch}",
3379
+ region: "{region}",
3380
+ tableName: __privateGet$4(this, _table),
3381
+ recordId
3382
+ },
3383
+ queryParams: { columns, ifVersion },
1966
3384
  body: object,
1967
- ...fetchProps
3385
+ ...__privateGet$4(this, _getFetchProps).call(this)
1968
3386
  });
1969
3387
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1970
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
3388
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1971
3389
  };
1972
3390
  _deleteRecord = new WeakSet();
1973
3391
  deleteRecord_fn = async function(recordId, columns = ["*"]) {
1974
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1975
3392
  try {
1976
3393
  const response = await deleteRecord({
1977
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
3394
+ pathParams: {
3395
+ workspace: "{workspaceId}",
3396
+ dbBranchName: "{dbBranch}",
3397
+ region: "{region}",
3398
+ tableName: __privateGet$4(this, _table),
3399
+ recordId
3400
+ },
1978
3401
  queryParams: { columns },
1979
- ...fetchProps
3402
+ ...__privateGet$4(this, _getFetchProps).call(this)
1980
3403
  });
1981
3404
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1982
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
3405
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1983
3406
  } catch (e) {
1984
3407
  if (isObject(e) && e.status === 404) {
1985
3408
  return null;
@@ -1987,17 +3410,36 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1987
3410
  throw e;
1988
3411
  }
1989
3412
  };
3413
+ _deleteRecords = new WeakSet();
3414
+ deleteRecords_fn = async function(recordIds) {
3415
+ const chunkedOperations = chunk(
3416
+ recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
3417
+ BULK_OPERATION_MAX_SIZE
3418
+ );
3419
+ for (const operations of chunkedOperations) {
3420
+ await branchTransaction({
3421
+ pathParams: {
3422
+ workspace: "{workspaceId}",
3423
+ dbBranchName: "{dbBranch}",
3424
+ region: "{region}"
3425
+ },
3426
+ body: { operations },
3427
+ ...__privateGet$4(this, _getFetchProps).call(this)
3428
+ });
3429
+ }
3430
+ };
1990
3431
  _setCacheQuery = new WeakSet();
1991
3432
  setCacheQuery_fn = async function(query, meta, records) {
1992
- await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
3433
+ await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
1993
3434
  };
1994
3435
  _getCacheQuery = new WeakSet();
1995
3436
  getCacheQuery_fn = async function(query) {
1996
3437
  const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
1997
- const result = await __privateGet$4(this, _cache).get(key);
3438
+ const result = await __privateGet$4(this, _cache)?.get(key);
1998
3439
  if (!result)
1999
3440
  return null;
2000
- const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
3441
+ const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
3442
+ const { cache: ttl = defaultTTL } = query.getQueryOptions();
2001
3443
  if (ttl < 0)
2002
3444
  return null;
2003
3445
  const hasExpired = result.date.getTime() + ttl < Date.now();
@@ -2007,10 +3449,9 @@ _getSchemaTables$1 = new WeakSet();
2007
3449
  getSchemaTables_fn$1 = async function() {
2008
3450
  if (__privateGet$4(this, _schemaTables$2))
2009
3451
  return __privateGet$4(this, _schemaTables$2);
2010
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2011
3452
  const { schema } = await getBranchDetails({
2012
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2013
- ...fetchProps
3453
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3454
+ ...__privateGet$4(this, _getFetchProps).call(this)
2014
3455
  });
2015
3456
  __privateSet$4(this, _schemaTables$2, schema.tables);
2016
3457
  return schema.tables;
@@ -2022,22 +3463,24 @@ const transformObjectLinks = (object) => {
2022
3463
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
2023
3464
  }, {});
2024
3465
  };
2025
- const initObject = (db, schemaTables, table, object) => {
2026
- const result = {};
3466
+ const initObject = (db, schemaTables, table, object, selectedColumns) => {
3467
+ const data = {};
2027
3468
  const { xata, ...rest } = object ?? {};
2028
- Object.assign(result, rest);
3469
+ Object.assign(data, rest);
2029
3470
  const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
2030
3471
  if (!columns)
2031
3472
  console.error(`Table ${table} not found in schema`);
2032
3473
  for (const column of columns ?? []) {
2033
- const value = result[column.name];
3474
+ if (!isValidColumn(selectedColumns, column))
3475
+ continue;
3476
+ const value = data[column.name];
2034
3477
  switch (column.type) {
2035
3478
  case "datetime": {
2036
- const date = value !== void 0 ? new Date(value) : void 0;
2037
- if (date && isNaN(date.getTime())) {
3479
+ const date = value !== void 0 ? new Date(value) : null;
3480
+ if (date !== null && isNaN(date.getTime())) {
2038
3481
  console.error(`Failed to parse date ${value} for field ${column.name}`);
2039
- } else if (date) {
2040
- result[column.name] = date;
3482
+ } else {
3483
+ data[column.name] = date;
2041
3484
  }
2042
3485
  break;
2043
3486
  }
@@ -2046,41 +3489,62 @@ const initObject = (db, schemaTables, table, object) => {
2046
3489
  if (!linkTable) {
2047
3490
  console.error(`Failed to parse link for field ${column.name}`);
2048
3491
  } else if (isObject(value)) {
2049
- result[column.name] = initObject(db, schemaTables, linkTable, value);
3492
+ const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
3493
+ if (item === column.name) {
3494
+ return [...acc, "*"];
3495
+ }
3496
+ if (item.startsWith(`${column.name}.`)) {
3497
+ const [, ...path] = item.split(".");
3498
+ return [...acc, path.join(".")];
3499
+ }
3500
+ return acc;
3501
+ }, []);
3502
+ data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2050
3503
  } else {
2051
- result[column.name] = null;
3504
+ data[column.name] = null;
2052
3505
  }
2053
3506
  break;
2054
3507
  }
2055
3508
  default:
2056
- result[column.name] = value ?? null;
3509
+ data[column.name] = value ?? null;
2057
3510
  if (column.notNull === true && value === null) {
2058
3511
  console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2059
3512
  }
2060
3513
  break;
2061
3514
  }
2062
3515
  }
2063
- result.read = function(columns2) {
2064
- return db[table].read(result["id"], columns2);
3516
+ const record = { ...data };
3517
+ record.read = function(columns2) {
3518
+ return db[table].read(record["id"], columns2);
2065
3519
  };
2066
- result.update = function(data, columns2) {
2067
- return db[table].update(result["id"], data, columns2);
3520
+ record.update = function(data2, b, c) {
3521
+ const columns2 = isStringArray(b) ? b : ["*"];
3522
+ const ifVersion = parseIfVersion(b, c);
3523
+ return db[table].update(record["id"], data2, columns2, { ifVersion });
2068
3524
  };
2069
- result.delete = function() {
2070
- return db[table].delete(result["id"]);
3525
+ record.replace = function(data2, b, c) {
3526
+ const columns2 = isStringArray(b) ? b : ["*"];
3527
+ const ifVersion = parseIfVersion(b, c);
3528
+ return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
2071
3529
  };
2072
- result.getMetadata = function() {
3530
+ record.delete = function() {
3531
+ return db[table].delete(record["id"]);
3532
+ };
3533
+ record.getMetadata = function() {
2073
3534
  return xata;
2074
3535
  };
2075
- for (const prop of ["read", "update", "delete", "getMetadata"]) {
2076
- Object.defineProperty(result, prop, { enumerable: false });
3536
+ record.toSerializable = function() {
3537
+ return JSON.parse(JSON.stringify(transformObjectLinks(data)));
3538
+ };
3539
+ record.toString = function() {
3540
+ return JSON.stringify(transformObjectLinks(data));
3541
+ };
3542
+ for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
3543
+ Object.defineProperty(record, prop, { enumerable: false });
2077
3544
  }
2078
- Object.freeze(result);
2079
- return result;
3545
+ Object.freeze(record);
3546
+ return record;
2080
3547
  };
2081
- function isResponseWithRecords(value) {
2082
- return isObject(value) && Array.isArray(value.records);
2083
- }
2084
3548
  function extractId(value) {
2085
3549
  if (isString(value))
2086
3550
  return value;
@@ -2088,11 +3552,22 @@ function extractId(value) {
2088
3552
  return value.id;
2089
3553
  return void 0;
2090
3554
  }
2091
- function cleanFilter(filter) {
2092
- if (!filter)
2093
- return void 0;
2094
- const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2095
- return values.length > 0 ? filter : void 0;
3555
+ function isValidColumn(columns, column) {
3556
+ if (columns.includes("*"))
3557
+ return true;
3558
+ if (column.type === "link") {
3559
+ const linkColumns = columns.filter((item) => item.startsWith(column.name));
3560
+ return linkColumns.length > 0;
3561
+ }
3562
+ return columns.includes(column.name);
3563
+ }
3564
+ function parseIfVersion(...args) {
3565
+ for (const arg of args) {
3566
+ if (isObject(arg) && isNumber(arg.ifVersion)) {
3567
+ return arg.ifVersion;
3568
+ }
3569
+ }
3570
+ return void 0;
2096
3571
  }
2097
3572
 
2098
3573
  var __accessCheck$3 = (obj, member, msg) => {
@@ -2252,23 +3727,23 @@ class SearchPlugin extends XataPlugin {
2252
3727
  __privateAdd$1(this, _schemaTables, void 0);
2253
3728
  __privateSet$1(this, _schemaTables, schemaTables);
2254
3729
  }
2255
- build({ getFetchProps }) {
3730
+ build(pluginOptions) {
2256
3731
  return {
2257
3732
  all: async (query, options = {}) => {
2258
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
2259
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
3733
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
3734
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
2260
3735
  return records.map((record) => {
2261
3736
  const { table = "orphan" } = record.xata;
2262
- return { table, record: initObject(this.db, schemaTables, table, record) };
3737
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
2263
3738
  });
2264
3739
  },
2265
3740
  byTable: async (query, options = {}) => {
2266
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
2267
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
3741
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
3742
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
2268
3743
  return records.reduce((acc, record) => {
2269
3744
  const { table = "orphan" } = record.xata;
2270
3745
  const items = acc[table] ?? [];
2271
- const item = initObject(this.db, schemaTables, table, record);
3746
+ const item = initObject(this.db, schemaTables, table, record, ["*"]);
2272
3747
  return { ...acc, [table]: [...items, item] };
2273
3748
  }, {});
2274
3749
  }
@@ -2277,108 +3752,39 @@ class SearchPlugin extends XataPlugin {
2277
3752
  }
2278
3753
  _schemaTables = new WeakMap();
2279
3754
  _search = new WeakSet();
2280
- search_fn = async function(query, options, getFetchProps) {
2281
- const fetchProps = await getFetchProps();
2282
- const { tables, fuzziness, highlight, prefix } = options ?? {};
3755
+ search_fn = async function(query, options, pluginOptions) {
3756
+ const { tables, fuzziness, highlight, prefix, page } = options ?? {};
2283
3757
  const { records } = await searchBranch({
2284
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2285
- body: { tables, query, fuzziness, prefix, highlight },
2286
- ...fetchProps
3758
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3759
+ body: { tables, query, fuzziness, prefix, highlight, page },
3760
+ ...pluginOptions
2287
3761
  });
2288
3762
  return records;
2289
3763
  };
2290
3764
  _getSchemaTables = new WeakSet();
2291
- getSchemaTables_fn = async function(getFetchProps) {
3765
+ getSchemaTables_fn = async function(pluginOptions) {
2292
3766
  if (__privateGet$1(this, _schemaTables))
2293
3767
  return __privateGet$1(this, _schemaTables);
2294
- const fetchProps = await getFetchProps();
2295
3768
  const { schema } = await getBranchDetails({
2296
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2297
- ...fetchProps
3769
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3770
+ ...pluginOptions
2298
3771
  });
2299
3772
  __privateSet$1(this, _schemaTables, schema.tables);
2300
3773
  return schema.tables;
2301
3774
  };
2302
3775
 
2303
- const isBranchStrategyBuilder = (strategy) => {
2304
- return typeof strategy === "function";
2305
- };
2306
-
2307
- async function getCurrentBranchName(options) {
2308
- const { branch, envBranch } = getEnvironment();
2309
- if (branch) {
2310
- const details = await getDatabaseBranch(branch, options);
2311
- if (details)
2312
- return branch;
2313
- console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
2314
- }
2315
- const gitBranch = envBranch || await getGitBranch();
2316
- return resolveXataBranch(gitBranch, options);
2317
- }
2318
- async function getCurrentBranchDetails(options) {
2319
- const branch = await getCurrentBranchName(options);
2320
- return getDatabaseBranch(branch, options);
2321
- }
2322
- async function resolveXataBranch(gitBranch, options) {
2323
- const databaseURL = options?.databaseURL || getDatabaseURL();
2324
- const apiKey = options?.apiKey || getAPIKey();
2325
- if (!databaseURL)
2326
- throw new Error(
2327
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2328
- );
2329
- if (!apiKey)
2330
- throw new Error(
2331
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2332
- );
2333
- const [protocol, , host, , dbName] = databaseURL.split("/");
2334
- const [workspace] = host.split(".");
2335
- const { fallbackBranch } = getEnvironment();
2336
- const { branch } = await resolveBranch({
2337
- apiKey,
2338
- apiUrl: databaseURL,
2339
- fetchImpl: getFetchImplementation(options?.fetchImpl),
2340
- workspacesApiUrl: `${protocol}//${host}`,
2341
- pathParams: { dbName, workspace },
2342
- queryParams: { gitBranch, fallbackBranch },
2343
- trace: defaultTrace
2344
- });
2345
- return branch;
2346
- }
2347
- async function getDatabaseBranch(branch, options) {
2348
- const databaseURL = options?.databaseURL || getDatabaseURL();
2349
- const apiKey = options?.apiKey || getAPIKey();
2350
- if (!databaseURL)
2351
- throw new Error(
2352
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2353
- );
2354
- if (!apiKey)
2355
- throw new Error(
2356
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2357
- );
2358
- const [protocol, , host, , database] = databaseURL.split("/");
2359
- const [workspace] = host.split(".");
2360
- const dbBranchName = `${database}:${branch}`;
2361
- try {
2362
- return await getBranchDetails({
2363
- apiKey,
2364
- apiUrl: databaseURL,
2365
- fetchImpl: getFetchImplementation(options?.fetchImpl),
2366
- workspacesApiUrl: `${protocol}//${host}`,
2367
- pathParams: { dbBranchName, workspace },
2368
- trace: defaultTrace
2369
- });
2370
- } catch (err) {
2371
- if (isObject(err) && err.status === 404)
2372
- return null;
2373
- throw err;
2374
- }
2375
- }
2376
- function getDatabaseURL() {
2377
- try {
2378
- const { databaseURL } = getEnvironment();
2379
- return databaseURL;
2380
- } catch (err) {
2381
- return void 0;
3776
+ class TransactionPlugin extends XataPlugin {
3777
+ build(pluginOptions) {
3778
+ return {
3779
+ run: async (operations) => {
3780
+ const response = await branchTransaction({
3781
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3782
+ body: { operations },
3783
+ ...pluginOptions
3784
+ });
3785
+ return response;
3786
+ }
3787
+ };
2382
3788
  }
2383
3789
  }
2384
3790
 
@@ -2405,88 +3811,115 @@ var __privateMethod = (obj, member, method) => {
2405
3811
  return method;
2406
3812
  };
2407
3813
  const buildClient = (plugins) => {
2408
- var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
3814
+ var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
2409
3815
  return _a = class {
2410
3816
  constructor(options = {}, schemaTables) {
2411
3817
  __privateAdd(this, _parseOptions);
2412
3818
  __privateAdd(this, _getFetchProps);
2413
- __privateAdd(this, _evaluateBranch);
2414
- __privateAdd(this, _branch, void 0);
2415
3819
  __privateAdd(this, _options, void 0);
2416
3820
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
2417
3821
  __privateSet(this, _options, safeOptions);
2418
3822
  const pluginOptions = {
2419
- getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
3823
+ ...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
2420
3824
  cache: safeOptions.cache,
2421
- trace: safeOptions.trace
3825
+ host: safeOptions.host
2422
3826
  };
2423
3827
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
2424
3828
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
3829
+ const transactions = new TransactionPlugin().build(pluginOptions);
2425
3830
  this.db = db;
2426
3831
  this.search = search;
3832
+ this.transactions = transactions;
2427
3833
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
2428
3834
  if (namespace === void 0)
2429
3835
  continue;
2430
- const result = namespace.build(pluginOptions);
2431
- if (result instanceof Promise) {
2432
- void result.then((namespace2) => {
2433
- this[key] = namespace2;
2434
- });
2435
- } else {
2436
- this[key] = result;
2437
- }
3836
+ this[key] = namespace.build(pluginOptions);
2438
3837
  }
2439
3838
  }
2440
3839
  async getConfig() {
2441
3840
  const databaseURL = __privateGet(this, _options).databaseURL;
2442
- const branch = await __privateGet(this, _options).branch();
3841
+ const branch = __privateGet(this, _options).branch;
2443
3842
  return { databaseURL, branch };
2444
3843
  }
2445
- }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
3844
+ }, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
3845
+ const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
3846
+ const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
3847
+ if (isBrowser && !enableBrowser) {
3848
+ throw new Error(
3849
+ "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."
3850
+ );
3851
+ }
2446
3852
  const fetch = getFetchImplementation(options?.fetch);
2447
3853
  const databaseURL = options?.databaseURL || getDatabaseURL();
2448
3854
  const apiKey = options?.apiKey || getAPIKey();
2449
3855
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
2450
3856
  const trace = options?.trace ?? defaultTrace;
2451
- const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
3857
+ const clientName = options?.clientName;
3858
+ const host = options?.host ?? "production";
3859
+ const xataAgentExtra = options?.xataAgentExtra;
2452
3860
  if (!apiKey) {
2453
3861
  throw new Error("Option apiKey is required");
2454
3862
  }
2455
3863
  if (!databaseURL) {
2456
3864
  throw new Error("Option databaseURL is required");
2457
3865
  }
2458
- return { fetch, databaseURL, apiKey, branch, cache, trace };
2459
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
2460
- const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2461
- if (!branchValue)
2462
- throw new Error("Unable to resolve branch value");
3866
+ const envBranch = getBranch();
3867
+ const previewBranch = getPreviewBranch();
3868
+ const branch = options?.branch || previewBranch || envBranch || "main";
3869
+ if (!!previewBranch && branch !== previewBranch) {
3870
+ console.warn(
3871
+ `Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
3872
+ );
3873
+ } else if (!!envBranch && branch !== envBranch) {
3874
+ console.warn(
3875
+ `Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
3876
+ );
3877
+ } else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
3878
+ console.warn(
3879
+ `Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
3880
+ );
3881
+ } else if (!previewBranch && !envBranch && options?.branch === void 0) {
3882
+ console.warn(
3883
+ `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.`
3884
+ );
3885
+ }
3886
+ return {
3887
+ fetch,
3888
+ databaseURL,
3889
+ apiKey,
3890
+ branch,
3891
+ cache,
3892
+ trace,
3893
+ host,
3894
+ clientID: generateUUID(),
3895
+ enableBrowser,
3896
+ clientName,
3897
+ xataAgentExtra
3898
+ };
3899
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
3900
+ fetch,
3901
+ apiKey,
3902
+ databaseURL,
3903
+ branch,
3904
+ trace,
3905
+ clientID,
3906
+ clientName,
3907
+ xataAgentExtra
3908
+ }) {
2463
3909
  return {
2464
- fetchImpl: fetch,
3910
+ fetch,
2465
3911
  apiKey,
2466
3912
  apiUrl: "",
2467
3913
  workspacesApiUrl: (path, params) => {
2468
3914
  const hasBranch = params.dbBranchName ?? params.branch;
2469
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
3915
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
2470
3916
  return databaseURL + newPath;
2471
3917
  },
2472
- trace
2473
- };
2474
- }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2475
- if (__privateGet(this, _branch))
2476
- return __privateGet(this, _branch);
2477
- if (param === void 0)
2478
- return void 0;
2479
- const strategies = Array.isArray(param) ? [...param] : [param];
2480
- const evaluateBranch = async (strategy) => {
2481
- return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
3918
+ trace,
3919
+ clientID,
3920
+ clientName,
3921
+ xataAgentExtra
2482
3922
  };
2483
- for await (const strategy of strategies) {
2484
- const branch = await evaluateBranch(strategy);
2485
- if (branch) {
2486
- __privateSet(this, _branch, branch);
2487
- return branch;
2488
- }
2489
- }
2490
3923
  }, _a;
2491
3924
  };
2492
3925
  class BaseClient extends buildClient() {
@@ -2560,7 +3993,7 @@ const deserialize = (json) => {
2560
3993
  };
2561
3994
 
2562
3995
  function buildWorkerRunner(config) {
2563
- return function xataWorker(name, _worker) {
3996
+ return function xataWorker(name, worker) {
2564
3997
  return async (...args) => {
2565
3998
  const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
2566
3999
  const result = await fetch(url, {
@@ -2582,6 +4015,7 @@ class XataError extends Error {
2582
4015
  }
2583
4016
 
2584
4017
  exports.BaseClient = BaseClient;
4018
+ exports.FetcherError = FetcherError;
2585
4019
  exports.Operations = operationsByTag;
2586
4020
  exports.PAGINATION_DEFAULT_OFFSET = PAGINATION_DEFAULT_OFFSET;
2587
4021
  exports.PAGINATION_DEFAULT_SIZE = PAGINATION_DEFAULT_SIZE;
@@ -2603,8 +4037,13 @@ exports.XataPlugin = XataPlugin;
2603
4037
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
2604
4038
  exports.addGitBranchesEntry = addGitBranchesEntry;
2605
4039
  exports.addTableColumn = addTableColumn;
4040
+ exports.aggregateTable = aggregateTable;
2606
4041
  exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
4042
+ exports.askTable = askTable;
4043
+ exports.branchTransaction = branchTransaction;
2607
4044
  exports.buildClient = buildClient;
4045
+ exports.buildPreviewBranchName = buildPreviewBranchName;
4046
+ exports.buildProviderString = buildProviderString;
2608
4047
  exports.buildWorkerRunner = buildWorkerRunner;
2609
4048
  exports.bulkInsertTableRecords = bulkInsertTableRecords;
2610
4049
  exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
@@ -2612,6 +4051,7 @@ exports.compareBranchSchemas = compareBranchSchemas;
2612
4051
  exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
2613
4052
  exports.compareMigrationRequest = compareMigrationRequest;
2614
4053
  exports.contains = contains;
4054
+ exports.copyBranch = copyBranch;
2615
4055
  exports.createBranch = createBranch;
2616
4056
  exports.createDatabase = createDatabase;
2617
4057
  exports.createMigrationRequest = createMigrationRequest;
@@ -2621,6 +4061,8 @@ exports.createWorkspace = createWorkspace;
2621
4061
  exports.deleteBranch = deleteBranch;
2622
4062
  exports.deleteColumn = deleteColumn;
2623
4063
  exports.deleteDatabase = deleteDatabase;
4064
+ exports.deleteDatabaseGithubSettings = deleteDatabaseGithubSettings;
4065
+ exports.deleteFileItem = deleteFileItem;
2624
4066
  exports.deleteRecord = deleteRecord;
2625
4067
  exports.deleteTable = deleteTable;
2626
4068
  exports.deleteUser = deleteUser;
@@ -2633,6 +4075,7 @@ exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
2633
4075
  exports.exists = exists;
2634
4076
  exports.ge = ge;
2635
4077
  exports.getAPIKey = getAPIKey;
4078
+ exports.getBranch = getBranch;
2636
4079
  exports.getBranchDetails = getBranchDetails;
2637
4080
  exports.getBranchList = getBranchList;
2638
4081
  exports.getBranchMetadata = getBranchMetadata;
@@ -2641,14 +4084,17 @@ exports.getBranchMigrationPlan = getBranchMigrationPlan;
2641
4084
  exports.getBranchSchemaHistory = getBranchSchemaHistory;
2642
4085
  exports.getBranchStats = getBranchStats;
2643
4086
  exports.getColumn = getColumn;
2644
- exports.getCurrentBranchDetails = getCurrentBranchDetails;
2645
- exports.getCurrentBranchName = getCurrentBranchName;
4087
+ exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
2646
4088
  exports.getDatabaseList = getDatabaseList;
2647
4089
  exports.getDatabaseMetadata = getDatabaseMetadata;
2648
4090
  exports.getDatabaseURL = getDatabaseURL;
4091
+ exports.getFile = getFile;
4092
+ exports.getFileItem = getFileItem;
2649
4093
  exports.getGitBranchesMapping = getGitBranchesMapping;
4094
+ exports.getHostUrl = getHostUrl;
2650
4095
  exports.getMigrationRequest = getMigrationRequest;
2651
4096
  exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
4097
+ exports.getPreviewBranch = getPreviewBranch;
2652
4098
  exports.getRecord = getRecord;
2653
4099
  exports.getTableColumns = getTableColumns;
2654
4100
  exports.getTableSchema = getTableSchema;
@@ -2671,6 +4117,8 @@ exports.insertRecordWithID = insertRecordWithID;
2671
4117
  exports.inviteWorkspaceMember = inviteWorkspaceMember;
2672
4118
  exports.is = is;
2673
4119
  exports.isCursorPaginationOptions = isCursorPaginationOptions;
4120
+ exports.isHostProviderAlias = isHostProviderAlias;
4121
+ exports.isHostProviderBuilder = isHostProviderBuilder;
2674
4122
  exports.isIdentifiable = isIdentifiable;
2675
4123
  exports.isNot = isNot;
2676
4124
  exports.isXataRecord = isXataRecord;
@@ -2678,29 +4126,38 @@ exports.le = le;
2678
4126
  exports.lessEquals = lessEquals;
2679
4127
  exports.lessThan = lessThan;
2680
4128
  exports.lessThanEquals = lessThanEquals;
2681
- exports.listMigrationRequests = listMigrationRequests;
2682
4129
  exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
4130
+ exports.listRegions = listRegions;
2683
4131
  exports.lt = lt;
2684
4132
  exports.lte = lte;
2685
4133
  exports.mergeMigrationRequest = mergeMigrationRequest;
2686
4134
  exports.notExists = notExists;
2687
4135
  exports.operationsByTag = operationsByTag;
4136
+ exports.parseProviderString = parseProviderString;
4137
+ exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
2688
4138
  exports.pattern = pattern;
2689
4139
  exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
4140
+ exports.pushBranchMigrations = pushBranchMigrations;
4141
+ exports.putFile = putFile;
4142
+ exports.putFileItem = putFileItem;
4143
+ exports.queryMigrationRequests = queryMigrationRequests;
2690
4144
  exports.queryTable = queryTable;
2691
4145
  exports.removeGitBranchesEntry = removeGitBranchesEntry;
2692
4146
  exports.removeWorkspaceMember = removeWorkspaceMember;
4147
+ exports.renameDatabase = renameDatabase;
2693
4148
  exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
2694
4149
  exports.resolveBranch = resolveBranch;
2695
4150
  exports.searchBranch = searchBranch;
2696
4151
  exports.searchTable = searchTable;
2697
4152
  exports.serialize = serialize;
2698
4153
  exports.setTableSchema = setTableSchema;
4154
+ exports.sqlQuery = sqlQuery;
2699
4155
  exports.startsWith = startsWith;
2700
4156
  exports.summarizeTable = summarizeTable;
2701
4157
  exports.updateBranchMetadata = updateBranchMetadata;
2702
4158
  exports.updateBranchSchema = updateBranchSchema;
2703
4159
  exports.updateColumn = updateColumn;
4160
+ exports.updateDatabaseGithubSettings = updateDatabaseGithubSettings;
2704
4161
  exports.updateDatabaseMetadata = updateDatabaseMetadata;
2705
4162
  exports.updateMigrationRequest = updateMigrationRequest;
2706
4163
  exports.updateRecordWithID = updateRecordWithID;
@@ -2710,4 +4167,5 @@ exports.updateWorkspace = updateWorkspace;
2710
4167
  exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
2711
4168
  exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
2712
4169
  exports.upsertRecordWithID = upsertRecordWithID;
4170
+ exports.vectorSearchTable = vectorSearchTable;
2713
4171
  //# sourceMappingURL=index.cjs.map