@xata.io/client 0.0.0-alpha.vf9f8ac6 → 0.0.0-alpha.vf9f8d99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,3 +1,26 @@
1
+ const defaultTrace = async (name, fn, _options) => {
2
+ return await fn({
3
+ name,
4
+ setAttributes: () => {
5
+ return;
6
+ }
7
+ });
8
+ };
9
+ const TraceAttributes = {
10
+ KIND: "xata.trace.kind",
11
+ VERSION: "xata.sdk.version",
12
+ TABLE: "xata.table",
13
+ HTTP_REQUEST_ID: "http.request_id",
14
+ HTTP_STATUS_CODE: "http.status_code",
15
+ HTTP_HOST: "http.host",
16
+ HTTP_SCHEME: "http.scheme",
17
+ HTTP_USER_AGENT: "http.user_agent",
18
+ HTTP_METHOD: "http.method",
19
+ HTTP_URL: "http.url",
20
+ HTTP_ROUTE: "http.route",
21
+ HTTP_TARGET: "http.target"
22
+ };
23
+
1
24
  function notEmpty(value) {
2
25
  return value !== null && value !== void 0;
3
26
  }
@@ -16,6 +39,21 @@ function isString(value) {
16
39
  function isStringArray(value) {
17
40
  return isDefined(value) && Array.isArray(value) && value.every(isString);
18
41
  }
42
+ function isNumber(value) {
43
+ return isDefined(value) && typeof value === "number";
44
+ }
45
+ function parseNumber(value) {
46
+ if (isNumber(value)) {
47
+ return value;
48
+ }
49
+ if (isString(value)) {
50
+ const parsed = Number(value);
51
+ if (!Number.isNaN(parsed)) {
52
+ return parsed;
53
+ }
54
+ }
55
+ return void 0;
56
+ }
19
57
  function toBase64(value) {
20
58
  try {
21
59
  return btoa(value);
@@ -24,10 +62,31 @@ function toBase64(value) {
24
62
  return buf.from(value).toString("base64");
25
63
  }
26
64
  }
65
+ function deepMerge(a, b) {
66
+ const result = { ...a };
67
+ for (const [key, value] of Object.entries(b)) {
68
+ if (isObject(value) && isObject(result[key])) {
69
+ result[key] = deepMerge(result[key], value);
70
+ } else {
71
+ result[key] = value;
72
+ }
73
+ }
74
+ return result;
75
+ }
76
+ function chunk(array, chunkSize) {
77
+ const result = [];
78
+ for (let i = 0; i < array.length; i += chunkSize) {
79
+ result.push(array.slice(i, i + chunkSize));
80
+ }
81
+ return result;
82
+ }
83
+ async function timeout(ms) {
84
+ return new Promise((resolve) => setTimeout(resolve, ms));
85
+ }
27
86
 
28
87
  function getEnvironment() {
29
88
  try {
30
- if (isObject(process) && isObject(process.env)) {
89
+ if (isDefined(process) && isDefined(process.env)) {
31
90
  return {
32
91
  apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
33
92
  databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
@@ -58,6 +117,25 @@ function getEnvironment() {
58
117
  fallbackBranch: getGlobalFallbackBranch()
59
118
  };
60
119
  }
120
+ function getEnableBrowserVariable() {
121
+ try {
122
+ if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
123
+ return process.env.XATA_ENABLE_BROWSER === "true";
124
+ }
125
+ } catch (err) {
126
+ }
127
+ try {
128
+ if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
129
+ return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
130
+ }
131
+ } catch (err) {
132
+ }
133
+ try {
134
+ return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
135
+ } catch (err) {
136
+ return void 0;
137
+ }
138
+ }
61
139
  function getGlobalApiKey() {
62
140
  try {
63
141
  return XATA_API_KEY;
@@ -86,25 +164,20 @@ function getGlobalFallbackBranch() {
86
164
  return void 0;
87
165
  }
88
166
  }
89
- async function getGitBranch() {
90
- const cmd = ["git", "branch", "--show-current"];
91
- const fullCmd = cmd.join(" ");
92
- const nodeModule = ["child", "process"].join("_");
93
- const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
167
+ function getDatabaseURL() {
94
168
  try {
95
- if (typeof require === "function") {
96
- return require(nodeModule).execSync(fullCmd, execOptions).trim();
97
- }
98
- const { execSync } = await import(nodeModule);
99
- return execSync(fullCmd, execOptions).toString().trim();
169
+ const { databaseURL } = getEnvironment();
170
+ return databaseURL;
100
171
  } catch (err) {
172
+ return void 0;
101
173
  }
174
+ }
175
+ function getBranch() {
102
176
  try {
103
- if (isObject(Deno)) {
104
- const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
105
- return new TextDecoder().decode(await process2.output()).trim();
106
- }
177
+ const { branch, envBranch } = getEnvironment();
178
+ return branch ?? envBranch;
107
179
  } catch (err) {
180
+ return void 0;
108
181
  }
109
182
  }
110
183
 
@@ -117,18 +190,114 @@ function getAPIKey() {
117
190
  }
118
191
  }
119
192
 
193
+ var __accessCheck$8 = (obj, member, msg) => {
194
+ if (!member.has(obj))
195
+ throw TypeError("Cannot " + msg);
196
+ };
197
+ var __privateGet$8 = (obj, member, getter) => {
198
+ __accessCheck$8(obj, member, "read from private field");
199
+ return getter ? getter.call(obj) : member.get(obj);
200
+ };
201
+ var __privateAdd$8 = (obj, member, value) => {
202
+ if (member.has(obj))
203
+ throw TypeError("Cannot add the same private member more than once");
204
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
205
+ };
206
+ var __privateSet$8 = (obj, member, value, setter) => {
207
+ __accessCheck$8(obj, member, "write to private field");
208
+ setter ? setter.call(obj, value) : member.set(obj, value);
209
+ return value;
210
+ };
211
+ var __privateMethod$4 = (obj, member, method) => {
212
+ __accessCheck$8(obj, member, "access private method");
213
+ return method;
214
+ };
215
+ var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
120
216
  function getFetchImplementation(userFetch) {
121
217
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
122
218
  const fetchImpl = userFetch ?? globalFetch;
123
219
  if (!fetchImpl) {
124
220
  throw new Error(
125
- `The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`
221
+ `Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
126
222
  );
127
223
  }
128
224
  return fetchImpl;
129
225
  }
226
+ class ApiRequestPool {
227
+ constructor(concurrency = 10) {
228
+ __privateAdd$8(this, _enqueue);
229
+ __privateAdd$8(this, _fetch, void 0);
230
+ __privateAdd$8(this, _queue, void 0);
231
+ __privateAdd$8(this, _concurrency, void 0);
232
+ __privateSet$8(this, _queue, []);
233
+ __privateSet$8(this, _concurrency, concurrency);
234
+ this.running = 0;
235
+ this.started = 0;
236
+ }
237
+ setFetch(fetch2) {
238
+ __privateSet$8(this, _fetch, fetch2);
239
+ }
240
+ getFetch() {
241
+ if (!__privateGet$8(this, _fetch)) {
242
+ throw new Error("Fetch not set");
243
+ }
244
+ return __privateGet$8(this, _fetch);
245
+ }
246
+ request(url, options) {
247
+ const start = new Date();
248
+ const fetch2 = this.getFetch();
249
+ const runRequest = async (stalled = false) => {
250
+ const response = await fetch2(url, options);
251
+ if (response.status === 429) {
252
+ const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
253
+ await timeout(rateLimitReset * 1e3);
254
+ return await runRequest(true);
255
+ }
256
+ if (stalled) {
257
+ const stalledTime = new Date().getTime() - start.getTime();
258
+ console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
259
+ }
260
+ return response;
261
+ };
262
+ return __privateMethod$4(this, _enqueue, enqueue_fn).call(this, async () => {
263
+ return await runRequest();
264
+ });
265
+ }
266
+ }
267
+ _fetch = new WeakMap();
268
+ _queue = new WeakMap();
269
+ _concurrency = new WeakMap();
270
+ _enqueue = new WeakSet();
271
+ enqueue_fn = function(task) {
272
+ const promise = new Promise((resolve) => __privateGet$8(this, _queue).push(resolve)).finally(() => {
273
+ this.started--;
274
+ this.running++;
275
+ }).then(() => task()).finally(() => {
276
+ this.running--;
277
+ const next = __privateGet$8(this, _queue).shift();
278
+ if (next !== void 0) {
279
+ this.started++;
280
+ next();
281
+ }
282
+ });
283
+ if (this.running + this.started < __privateGet$8(this, _concurrency)) {
284
+ const next = __privateGet$8(this, _queue).shift();
285
+ if (next !== void 0) {
286
+ this.started++;
287
+ next();
288
+ }
289
+ }
290
+ return promise;
291
+ };
292
+
293
+ function generateUUID() {
294
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
295
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
296
+ return v.toString(16);
297
+ });
298
+ }
130
299
 
131
- const VERSION = "0.0.0-alpha.vf9f8ac6";
300
+ const VERSION = "0.22.3";
132
301
 
133
302
  class ErrorWithCause extends Error {
134
303
  constructor(message, options) {
@@ -139,7 +308,7 @@ class FetcherError extends ErrorWithCause {
139
308
  constructor(status, data, requestId) {
140
309
  super(getMessage(data));
141
310
  this.status = status;
142
- this.errors = isBulkError(data) ? data.errors : void 0;
311
+ this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
143
312
  this.requestId = requestId;
144
313
  if (data instanceof Error) {
145
314
  this.stack = data.stack;
@@ -171,6 +340,7 @@ function getMessage(data) {
171
340
  }
172
341
  }
173
342
 
343
+ const pool = new ApiRequestPool();
174
344
  const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
175
345
  const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
176
346
  if (value === void 0 || value === null)
@@ -179,305 +349,275 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
179
349
  }, {});
180
350
  const query = new URLSearchParams(cleanQueryParams).toString();
181
351
  const queryString = query.length > 0 ? `?${query}` : "";
182
- return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
352
+ const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
353
+ return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
354
+ }, {});
355
+ return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
183
356
  };
184
357
  function buildBaseUrl({
358
+ endpoint,
185
359
  path,
186
360
  workspacesApiUrl,
187
361
  apiUrl,
188
- pathParams
362
+ pathParams = {}
189
363
  }) {
190
- if (!pathParams?.workspace)
191
- return `${apiUrl}${path}`;
192
- const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
193
- return url.replace("{workspaceId}", pathParams.workspace);
364
+ if (endpoint === "dataPlane") {
365
+ const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
366
+ const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
367
+ return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
368
+ }
369
+ return `${apiUrl}${path}`;
194
370
  }
195
371
  function hostHeader(url) {
196
372
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
197
373
  const { groups } = pattern.exec(url) ?? {};
198
374
  return groups?.host ? { Host: groups.host } : {};
199
375
  }
376
+ const defaultClientID = generateUUID();
200
377
  async function fetch$1({
201
378
  url: path,
202
379
  method,
203
380
  body,
204
- headers,
381
+ headers: customHeaders,
205
382
  pathParams,
206
383
  queryParams,
207
- fetchImpl,
384
+ fetch: fetch2,
208
385
  apiKey,
386
+ endpoint,
209
387
  apiUrl,
210
- workspacesApiUrl
388
+ workspacesApiUrl,
389
+ trace,
390
+ signal,
391
+ clientID,
392
+ sessionID,
393
+ clientName,
394
+ xataAgentExtra,
395
+ fetchOptions = {}
211
396
  }) {
212
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
213
- const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
214
- const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
215
- const response = await fetchImpl(url, {
216
- method: method.toUpperCase(),
217
- body: body ? JSON.stringify(body) : void 0,
218
- headers: {
219
- "Content-Type": "application/json",
220
- "User-Agent": `Xata client-ts/${VERSION}`,
221
- ...headers,
222
- ...hostHeader(fullUrl),
223
- Authorization: `Bearer ${apiKey}`
224
- }
225
- });
226
- if (response.status === 204) {
227
- return {};
228
- }
229
- const requestId = response.headers?.get("x-request-id") ?? void 0;
397
+ pool.setFetch(fetch2);
398
+ return await trace(
399
+ `${method.toUpperCase()} ${path}`,
400
+ async ({ setAttributes }) => {
401
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
402
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
403
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
404
+ setAttributes({
405
+ [TraceAttributes.HTTP_URL]: url,
406
+ [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
407
+ });
408
+ const xataAgent = compact([
409
+ ["client", "TS_SDK"],
410
+ ["version", VERSION],
411
+ isDefined(clientName) ? ["service", clientName] : void 0,
412
+ ...Object.entries(xataAgentExtra ?? {})
413
+ ]).map(([key, value]) => `${key}=${value}`).join("; ");
414
+ const headers = {
415
+ "Accept-Encoding": "identity",
416
+ "Content-Type": "application/json",
417
+ "X-Xata-Client-ID": clientID ?? defaultClientID,
418
+ "X-Xata-Session-ID": sessionID ?? generateUUID(),
419
+ "X-Xata-Agent": xataAgent,
420
+ ...customHeaders,
421
+ ...hostHeader(fullUrl),
422
+ Authorization: `Bearer ${apiKey}`
423
+ };
424
+ const response = await pool.request(url, {
425
+ ...fetchOptions,
426
+ method: method.toUpperCase(),
427
+ body: body ? JSON.stringify(body) : void 0,
428
+ headers,
429
+ signal
430
+ });
431
+ const { host, protocol } = parseUrl(response.url);
432
+ const requestId = response.headers?.get("x-request-id") ?? void 0;
433
+ setAttributes({
434
+ [TraceAttributes.KIND]: "http",
435
+ [TraceAttributes.HTTP_REQUEST_ID]: requestId,
436
+ [TraceAttributes.HTTP_STATUS_CODE]: response.status,
437
+ [TraceAttributes.HTTP_HOST]: host,
438
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
439
+ });
440
+ if (response.status === 204) {
441
+ return {};
442
+ }
443
+ if (response.status === 429) {
444
+ throw new FetcherError(response.status, "Rate limit exceeded", requestId);
445
+ }
446
+ try {
447
+ const jsonResponse = await response.json();
448
+ if (response.ok) {
449
+ return jsonResponse;
450
+ }
451
+ throw new FetcherError(response.status, jsonResponse, requestId);
452
+ } catch (error) {
453
+ throw new FetcherError(response.status, error, requestId);
454
+ }
455
+ },
456
+ { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
457
+ );
458
+ }
459
+ function parseUrl(url) {
230
460
  try {
231
- const jsonResponse = await response.json();
232
- if (response.ok) {
233
- return jsonResponse;
234
- }
235
- throw new FetcherError(response.status, jsonResponse, requestId);
461
+ const { host, protocol } = new URL(url);
462
+ return { host, protocol };
236
463
  } catch (error) {
237
- throw new FetcherError(response.status, error, requestId);
464
+ return {};
238
465
  }
239
466
  }
240
467
 
241
- const getUser = (variables) => fetch$1({ url: "/user", method: "get", ...variables });
242
- const updateUser = (variables) => fetch$1({ url: "/user", method: "put", ...variables });
243
- const deleteUser = (variables) => fetch$1({ url: "/user", method: "delete", ...variables });
244
- const getUserAPIKeys = (variables) => fetch$1({
245
- url: "/user/keys",
246
- method: "get",
247
- ...variables
248
- });
249
- const createUserAPIKey = (variables) => fetch$1({
250
- url: "/user/keys/{keyName}",
251
- method: "post",
252
- ...variables
253
- });
254
- const deleteUserAPIKey = (variables) => fetch$1({
255
- url: "/user/keys/{keyName}",
256
- method: "delete",
257
- ...variables
258
- });
259
- const createWorkspace = (variables) => fetch$1({
260
- url: "/workspaces",
261
- method: "post",
262
- ...variables
263
- });
264
- const getWorkspacesList = (variables) => fetch$1({
265
- url: "/workspaces",
266
- method: "get",
267
- ...variables
268
- });
269
- const getWorkspace = (variables) => fetch$1({
270
- url: "/workspaces/{workspaceId}",
271
- method: "get",
272
- ...variables
273
- });
274
- const updateWorkspace = (variables) => fetch$1({
275
- url: "/workspaces/{workspaceId}",
276
- method: "put",
277
- ...variables
278
- });
279
- const deleteWorkspace = (variables) => fetch$1({
280
- url: "/workspaces/{workspaceId}",
281
- method: "delete",
282
- ...variables
283
- });
284
- const getWorkspaceMembersList = (variables) => fetch$1({
285
- url: "/workspaces/{workspaceId}/members",
286
- method: "get",
287
- ...variables
288
- });
289
- const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
290
- const removeWorkspaceMember = (variables) => fetch$1({
291
- url: "/workspaces/{workspaceId}/members/{userId}",
292
- method: "delete",
293
- ...variables
294
- });
295
- const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
296
- const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
297
- const cancelWorkspaceMemberInvite = (variables) => fetch$1({
298
- url: "/workspaces/{workspaceId}/invites/{inviteId}",
299
- method: "delete",
300
- ...variables
301
- });
302
- const resendWorkspaceMemberInvite = (variables) => fetch$1({
303
- url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
304
- method: "post",
305
- ...variables
306
- });
307
- const acceptWorkspaceMemberInvite = (variables) => fetch$1({
308
- url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
309
- method: "post",
310
- ...variables
311
- });
312
- const getDatabaseList = (variables) => fetch$1({
313
- url: "/dbs",
314
- method: "get",
315
- ...variables
316
- });
317
- const getBranchList = (variables) => fetch$1({
468
+ const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
469
+
470
+ const getBranchList = (variables, signal) => dataPlaneFetch({
318
471
  url: "/dbs/{dbName}",
319
472
  method: "get",
320
- ...variables
321
- });
322
- const createDatabase = (variables) => fetch$1({
323
- url: "/dbs/{dbName}",
324
- method: "put",
325
- ...variables
326
- });
327
- const deleteDatabase = (variables) => fetch$1({
328
- url: "/dbs/{dbName}",
329
- method: "delete",
330
- ...variables
473
+ ...variables,
474
+ signal
331
475
  });
332
- const getDatabaseMetadata = (variables) => fetch$1({
333
- url: "/dbs/{dbName}/metadata",
334
- method: "get",
335
- ...variables
336
- });
337
- const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
338
- const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
339
- const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
340
- const resolveBranch = (variables) => fetch$1({
341
- url: "/dbs/{dbName}/resolveBranch",
342
- method: "get",
343
- ...variables
344
- });
345
- const getBranchDetails = (variables) => fetch$1({
476
+ const getBranchDetails = (variables, signal) => dataPlaneFetch({
346
477
  url: "/db/{dbBranchName}",
347
478
  method: "get",
348
- ...variables
479
+ ...variables,
480
+ signal
349
481
  });
350
- const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
351
- const deleteBranch = (variables) => fetch$1({
482
+ const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
483
+ const deleteBranch = (variables, signal) => dataPlaneFetch({
352
484
  url: "/db/{dbBranchName}",
353
485
  method: "delete",
354
- ...variables
486
+ ...variables,
487
+ signal
355
488
  });
356
- const updateBranchMetadata = (variables) => fetch$1({
489
+ const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
357
490
  url: "/db/{dbBranchName}/metadata",
358
491
  method: "put",
359
- ...variables
492
+ ...variables,
493
+ signal
360
494
  });
361
- const getBranchMetadata = (variables) => fetch$1({
495
+ const getBranchMetadata = (variables, signal) => dataPlaneFetch({
362
496
  url: "/db/{dbBranchName}/metadata",
363
497
  method: "get",
364
- ...variables
498
+ ...variables,
499
+ signal
365
500
  });
366
- const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
367
- const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
368
- const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
369
- const getBranchStats = (variables) => fetch$1({
501
+ const getBranchStats = (variables, signal) => dataPlaneFetch({
370
502
  url: "/db/{dbBranchName}/stats",
371
503
  method: "get",
372
- ...variables
504
+ ...variables,
505
+ signal
506
+ });
507
+ const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
508
+ const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
509
+ const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
510
+ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
511
+ const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
512
+ const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
513
+ const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
514
+ const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
515
+ const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
516
+ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
517
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
518
+ method: "get",
519
+ ...variables,
520
+ signal
373
521
  });
374
- const createTable = (variables) => fetch$1({
522
+ const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
523
+ const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
524
+ const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
525
+ const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
526
+ const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
527
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
528
+ method: "post",
529
+ ...variables,
530
+ signal
531
+ });
532
+ const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
533
+ const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
534
+ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
535
+ const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
536
+ const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
537
+ const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
538
+ const createTable = (variables, signal) => dataPlaneFetch({
375
539
  url: "/db/{dbBranchName}/tables/{tableName}",
376
540
  method: "put",
377
- ...variables
541
+ ...variables,
542
+ signal
378
543
  });
379
- const deleteTable = (variables) => fetch$1({
544
+ const deleteTable = (variables, signal) => dataPlaneFetch({
380
545
  url: "/db/{dbBranchName}/tables/{tableName}",
381
546
  method: "delete",
382
- ...variables
383
- });
384
- const updateTable = (variables) => fetch$1({
385
- url: "/db/{dbBranchName}/tables/{tableName}",
386
- method: "patch",
387
- ...variables
547
+ ...variables,
548
+ signal
388
549
  });
389
- const getTableSchema = (variables) => fetch$1({
550
+ const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
551
+ const getTableSchema = (variables, signal) => dataPlaneFetch({
390
552
  url: "/db/{dbBranchName}/tables/{tableName}/schema",
391
553
  method: "get",
392
- ...variables
393
- });
394
- const setTableSchema = (variables) => fetch$1({
395
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
396
- method: "put",
397
- ...variables
554
+ ...variables,
555
+ signal
398
556
  });
399
- const getTableColumns = (variables) => fetch$1({
557
+ const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
558
+ const getTableColumns = (variables, signal) => dataPlaneFetch({
400
559
  url: "/db/{dbBranchName}/tables/{tableName}/columns",
401
560
  method: "get",
402
- ...variables
403
- });
404
- const addTableColumn = (variables) => fetch$1({
405
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
406
- method: "post",
407
- ...variables
561
+ ...variables,
562
+ signal
408
563
  });
409
- const getColumn = (variables) => fetch$1({
564
+ const addTableColumn = (variables, signal) => dataPlaneFetch(
565
+ { url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
566
+ );
567
+ const getColumn = (variables, signal) => dataPlaneFetch({
410
568
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
411
569
  method: "get",
412
- ...variables
413
- });
414
- const deleteColumn = (variables) => fetch$1({
415
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
416
- method: "delete",
417
- ...variables
570
+ ...variables,
571
+ signal
418
572
  });
419
- const updateColumn = (variables) => fetch$1({
573
+ const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
574
+ const deleteColumn = (variables, signal) => dataPlaneFetch({
420
575
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
421
- method: "patch",
422
- ...variables
423
- });
424
- const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
425
- const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
426
- const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
427
- const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
428
- const deleteRecord = (variables) => fetch$1({
429
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
430
576
  method: "delete",
431
- ...variables
577
+ ...variables,
578
+ signal
432
579
  });
433
- const getRecord = (variables) => fetch$1({
580
+ const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
581
+ const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
582
+ const getRecord = (variables, signal) => dataPlaneFetch({
434
583
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
435
584
  method: "get",
436
- ...variables
585
+ ...variables,
586
+ signal
437
587
  });
438
- const bulkInsertTableRecords = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables });
439
- const queryTable = (variables) => fetch$1({
588
+ const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
589
+ const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
590
+ const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
591
+ const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
592
+ const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
593
+ const queryTable = (variables, signal) => dataPlaneFetch({
440
594
  url: "/db/{dbBranchName}/tables/{tableName}/query",
441
595
  method: "post",
442
- ...variables
596
+ ...variables,
597
+ signal
443
598
  });
444
- const searchTable = (variables) => fetch$1({
599
+ const searchBranch = (variables, signal) => dataPlaneFetch({
600
+ url: "/db/{dbBranchName}/search",
601
+ method: "post",
602
+ ...variables,
603
+ signal
604
+ });
605
+ const searchTable = (variables, signal) => dataPlaneFetch({
445
606
  url: "/db/{dbBranchName}/tables/{tableName}/search",
446
607
  method: "post",
447
- ...variables
608
+ ...variables,
609
+ signal
448
610
  });
449
- const searchBranch = (variables) => fetch$1({
450
- url: "/db/{dbBranchName}/search",
611
+ const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
612
+ const askTable = (variables, signal) => dataPlaneFetch({
613
+ url: "/db/{dbBranchName}/tables/{tableName}/ask",
451
614
  method: "post",
452
- ...variables
615
+ ...variables,
616
+ signal
453
617
  });
454
- const operationsByTag = {
455
- users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
456
- workspaces: {
457
- createWorkspace,
458
- getWorkspacesList,
459
- getWorkspace,
460
- updateWorkspace,
461
- deleteWorkspace,
462
- getWorkspaceMembersList,
463
- updateWorkspaceMemberRole,
464
- removeWorkspaceMember,
465
- inviteWorkspaceMember,
466
- updateWorkspaceMemberInvite,
467
- cancelWorkspaceMemberInvite,
468
- resendWorkspaceMemberInvite,
469
- acceptWorkspaceMemberInvite
470
- },
471
- database: {
472
- getDatabaseList,
473
- createDatabase,
474
- deleteDatabase,
475
- getDatabaseMetadata,
476
- getGitBranchesMapping,
477
- addGitBranchesEntry,
478
- removeGitBranchesEntry,
479
- resolveBranch
480
- },
618
+ const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
619
+ const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
620
+ const operationsByTag$2 = {
481
621
  branch: {
482
622
  getBranchList,
483
623
  getBranchDetails,
@@ -485,10 +625,32 @@ const operationsByTag = {
485
625
  deleteBranch,
486
626
  updateBranchMetadata,
487
627
  getBranchMetadata,
628
+ getBranchStats,
629
+ getGitBranchesMapping,
630
+ addGitBranchesEntry,
631
+ removeGitBranchesEntry,
632
+ resolveBranch
633
+ },
634
+ migrations: {
488
635
  getBranchMigrationHistory,
489
- executeBranchMigrationPlan,
490
636
  getBranchMigrationPlan,
491
- getBranchStats
637
+ executeBranchMigrationPlan,
638
+ getBranchSchemaHistory,
639
+ compareBranchWithUserSchema,
640
+ compareBranchSchemas,
641
+ updateBranchSchema,
642
+ previewBranchSchemaEdit,
643
+ applyBranchSchemaEdit
644
+ },
645
+ migrationRequests: {
646
+ queryMigrationRequests,
647
+ createMigrationRequest,
648
+ getMigrationRequest,
649
+ updateMigrationRequest,
650
+ listMigrationRequestsCommits,
651
+ compareMigrationRequest,
652
+ getMigrationRequestIsMerged,
653
+ mergeMigrationRequest
492
654
  },
493
655
  table: {
494
656
  createTable,
@@ -499,27 +661,174 @@ const operationsByTag = {
499
661
  getTableColumns,
500
662
  addTableColumn,
501
663
  getColumn,
502
- deleteColumn,
503
- updateColumn
664
+ updateColumn,
665
+ deleteColumn
504
666
  },
505
667
  records: {
668
+ branchTransaction,
506
669
  insertRecord,
670
+ getRecord,
507
671
  insertRecordWithID,
508
672
  updateRecordWithID,
509
673
  upsertRecordWithID,
510
674
  deleteRecord,
511
- getRecord,
512
- bulkInsertTableRecords,
675
+ bulkInsertTableRecords
676
+ },
677
+ searchAndFilter: {
513
678
  queryTable,
679
+ searchBranch,
514
680
  searchTable,
515
- searchBranch
681
+ vectorSearchTable,
682
+ askTable,
683
+ summarizeTable,
684
+ aggregateTable
516
685
  }
517
686
  };
518
687
 
688
+ const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
689
+
690
+ const getUser = (variables, signal) => controlPlaneFetch({
691
+ url: "/user",
692
+ method: "get",
693
+ ...variables,
694
+ signal
695
+ });
696
+ const updateUser = (variables, signal) => controlPlaneFetch({
697
+ url: "/user",
698
+ method: "put",
699
+ ...variables,
700
+ signal
701
+ });
702
+ const deleteUser = (variables, signal) => controlPlaneFetch({
703
+ url: "/user",
704
+ method: "delete",
705
+ ...variables,
706
+ signal
707
+ });
708
+ const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
709
+ url: "/user/keys",
710
+ method: "get",
711
+ ...variables,
712
+ signal
713
+ });
714
+ const createUserAPIKey = (variables, signal) => controlPlaneFetch({
715
+ url: "/user/keys/{keyName}",
716
+ method: "post",
717
+ ...variables,
718
+ signal
719
+ });
720
+ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
721
+ url: "/user/keys/{keyName}",
722
+ method: "delete",
723
+ ...variables,
724
+ signal
725
+ });
726
+ const getWorkspacesList = (variables, signal) => controlPlaneFetch({
727
+ url: "/workspaces",
728
+ method: "get",
729
+ ...variables,
730
+ signal
731
+ });
732
+ const createWorkspace = (variables, signal) => controlPlaneFetch({
733
+ url: "/workspaces",
734
+ method: "post",
735
+ ...variables,
736
+ signal
737
+ });
738
+ const getWorkspace = (variables, signal) => controlPlaneFetch({
739
+ url: "/workspaces/{workspaceId}",
740
+ method: "get",
741
+ ...variables,
742
+ signal
743
+ });
744
+ const updateWorkspace = (variables, signal) => controlPlaneFetch({
745
+ url: "/workspaces/{workspaceId}",
746
+ method: "put",
747
+ ...variables,
748
+ signal
749
+ });
750
+ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
751
+ url: "/workspaces/{workspaceId}",
752
+ method: "delete",
753
+ ...variables,
754
+ signal
755
+ });
756
+ const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
757
+ const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
758
+ const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
759
+ url: "/workspaces/{workspaceId}/members/{userId}",
760
+ method: "delete",
761
+ ...variables,
762
+ signal
763
+ });
764
+ const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
765
+ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
766
+ const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
767
+ const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
768
+ const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
769
+ const getDatabaseList = (variables, signal) => controlPlaneFetch({
770
+ url: "/workspaces/{workspaceId}/dbs",
771
+ method: "get",
772
+ ...variables,
773
+ signal
774
+ });
775
+ const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
776
+ const deleteDatabase = (variables, signal) => controlPlaneFetch({
777
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
778
+ method: "delete",
779
+ ...variables,
780
+ signal
781
+ });
782
+ const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
783
+ const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
784
+ const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
785
+ const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
786
+ const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
787
+ const listRegions = (variables, signal) => controlPlaneFetch({
788
+ url: "/workspaces/{workspaceId}/regions",
789
+ method: "get",
790
+ ...variables,
791
+ signal
792
+ });
793
+ const operationsByTag$1 = {
794
+ users: { getUser, updateUser, deleteUser },
795
+ authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
796
+ workspaces: {
797
+ getWorkspacesList,
798
+ createWorkspace,
799
+ getWorkspace,
800
+ updateWorkspace,
801
+ deleteWorkspace,
802
+ getWorkspaceMembersList,
803
+ updateWorkspaceMemberRole,
804
+ removeWorkspaceMember
805
+ },
806
+ invites: {
807
+ inviteWorkspaceMember,
808
+ updateWorkspaceMemberInvite,
809
+ cancelWorkspaceMemberInvite,
810
+ acceptWorkspaceMemberInvite,
811
+ resendWorkspaceMemberInvite
812
+ },
813
+ databases: {
814
+ getDatabaseList,
815
+ createDatabase,
816
+ deleteDatabase,
817
+ getDatabaseMetadata,
818
+ updateDatabaseMetadata,
819
+ getDatabaseGithubSettings,
820
+ updateDatabaseGithubSettings,
821
+ deleteDatabaseGithubSettings,
822
+ listRegions
823
+ }
824
+ };
825
+
826
+ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
827
+
519
828
  function getHostUrl(provider, type) {
520
- if (isValidAlias(provider)) {
829
+ if (isHostProviderAlias(provider)) {
521
830
  return providers[provider][type];
522
- } else if (isValidBuilder(provider)) {
831
+ } else if (isHostProviderBuilder(provider)) {
523
832
  return provider[type];
524
833
  }
525
834
  throw new Error("Invalid API provider");
@@ -527,19 +836,40 @@ function getHostUrl(provider, type) {
527
836
  const providers = {
528
837
  production: {
529
838
  main: "https://api.xata.io",
530
- workspaces: "https://{workspaceId}.xata.sh"
839
+ workspaces: "https://{workspaceId}.{region}.xata.sh"
531
840
  },
532
841
  staging: {
533
- main: "https://staging.xatabase.co",
534
- workspaces: "https://{workspaceId}.staging.xatabase.co"
842
+ main: "https://api.staging-xata.dev",
843
+ workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
535
844
  }
536
845
  };
537
- function isValidAlias(alias) {
846
+ function isHostProviderAlias(alias) {
538
847
  return isString(alias) && Object.keys(providers).includes(alias);
539
848
  }
540
- function isValidBuilder(builder) {
849
+ function isHostProviderBuilder(builder) {
541
850
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
542
851
  }
852
+ function parseProviderString(provider = "production") {
853
+ if (isHostProviderAlias(provider)) {
854
+ return provider;
855
+ }
856
+ const [main, workspaces] = provider.split(",");
857
+ if (!main || !workspaces)
858
+ return null;
859
+ return { main, workspaces };
860
+ }
861
+ function parseWorkspacesUrlParts(url) {
862
+ if (!isString(url))
863
+ return null;
864
+ const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
865
+ const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
866
+ const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
867
+ const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
868
+ const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
869
+ if (!match)
870
+ return null;
871
+ return { workspace: match[1], region: match[2] };
872
+ }
543
873
 
544
874
  var __accessCheck$7 = (obj, member, msg) => {
545
875
  if (!member.has(obj))
@@ -565,15 +895,21 @@ class XataApiClient {
565
895
  __privateAdd$7(this, _extraProps, void 0);
566
896
  __privateAdd$7(this, _namespaces, {});
567
897
  const provider = options.host ?? "production";
568
- const apiKey = options?.apiKey ?? getAPIKey();
898
+ const apiKey = options.apiKey ?? getAPIKey();
899
+ const trace = options.trace ?? defaultTrace;
900
+ const clientID = generateUUID();
569
901
  if (!apiKey) {
570
902
  throw new Error("Could not resolve a valid apiKey");
571
903
  }
572
904
  __privateSet$7(this, _extraProps, {
573
905
  apiUrl: getHostUrl(provider, "main"),
574
906
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
575
- fetchImpl: getFetchImplementation(options.fetch),
576
- apiKey
907
+ fetch: getFetchImplementation(options.fetch),
908
+ apiKey,
909
+ trace,
910
+ clientName: options.clientName,
911
+ xataAgentExtra: options.xataAgentExtra,
912
+ clientID
577
913
  });
578
914
  }
579
915
  get user() {
@@ -581,21 +917,41 @@ class XataApiClient {
581
917
  __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
582
918
  return __privateGet$7(this, _namespaces).user;
583
919
  }
920
+ get authentication() {
921
+ if (!__privateGet$7(this, _namespaces).authentication)
922
+ __privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
923
+ return __privateGet$7(this, _namespaces).authentication;
924
+ }
584
925
  get workspaces() {
585
926
  if (!__privateGet$7(this, _namespaces).workspaces)
586
927
  __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
587
928
  return __privateGet$7(this, _namespaces).workspaces;
588
929
  }
589
- get databases() {
590
- if (!__privateGet$7(this, _namespaces).databases)
591
- __privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
592
- return __privateGet$7(this, _namespaces).databases;
930
+ get invites() {
931
+ if (!__privateGet$7(this, _namespaces).invites)
932
+ __privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
933
+ return __privateGet$7(this, _namespaces).invites;
934
+ }
935
+ get database() {
936
+ if (!__privateGet$7(this, _namespaces).database)
937
+ __privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
938
+ return __privateGet$7(this, _namespaces).database;
593
939
  }
594
940
  get branches() {
595
941
  if (!__privateGet$7(this, _namespaces).branches)
596
942
  __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
597
943
  return __privateGet$7(this, _namespaces).branches;
598
944
  }
945
+ get migrations() {
946
+ if (!__privateGet$7(this, _namespaces).migrations)
947
+ __privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
948
+ return __privateGet$7(this, _namespaces).migrations;
949
+ }
950
+ get migrationRequests() {
951
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
952
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
953
+ return __privateGet$7(this, _namespaces).migrationRequests;
954
+ }
599
955
  get tables() {
600
956
  if (!__privateGet$7(this, _namespaces).tables)
601
957
  __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
@@ -606,6 +962,11 @@ class XataApiClient {
606
962
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
607
963
  return __privateGet$7(this, _namespaces).records;
608
964
  }
965
+ get searchAndFilter() {
966
+ if (!__privateGet$7(this, _namespaces).searchAndFilter)
967
+ __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
968
+ return __privateGet$7(this, _namespaces).searchAndFilter;
969
+ }
609
970
  }
610
971
  _extraProps = new WeakMap();
611
972
  _namespaces = new WeakMap();
@@ -616,24 +977,29 @@ class UserApi {
616
977
  getUser() {
617
978
  return operationsByTag.users.getUser({ ...this.extraProps });
618
979
  }
619
- updateUser(user) {
980
+ updateUser({ user }) {
620
981
  return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
621
982
  }
622
983
  deleteUser() {
623
984
  return operationsByTag.users.deleteUser({ ...this.extraProps });
624
985
  }
986
+ }
987
+ class AuthenticationApi {
988
+ constructor(extraProps) {
989
+ this.extraProps = extraProps;
990
+ }
625
991
  getUserAPIKeys() {
626
- return operationsByTag.users.getUserAPIKeys({ ...this.extraProps });
992
+ return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
627
993
  }
628
- createUserAPIKey(keyName) {
629
- return operationsByTag.users.createUserAPIKey({
630
- pathParams: { keyName },
994
+ createUserAPIKey({ name }) {
995
+ return operationsByTag.authentication.createUserAPIKey({
996
+ pathParams: { keyName: name },
631
997
  ...this.extraProps
632
998
  });
633
999
  }
634
- deleteUserAPIKey(keyName) {
635
- return operationsByTag.users.deleteUserAPIKey({
636
- pathParams: { keyName },
1000
+ deleteUserAPIKey({ name }) {
1001
+ return operationsByTag.authentication.deleteUserAPIKey({
1002
+ pathParams: { keyName: name },
637
1003
  ...this.extraProps
638
1004
  });
639
1005
  }
@@ -642,374 +1008,988 @@ class WorkspaceApi {
642
1008
  constructor(extraProps) {
643
1009
  this.extraProps = extraProps;
644
1010
  }
645
- createWorkspace(workspaceMeta) {
1011
+ getWorkspacesList() {
1012
+ return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
1013
+ }
1014
+ createWorkspace({ data }) {
646
1015
  return operationsByTag.workspaces.createWorkspace({
647
- body: workspaceMeta,
1016
+ body: data,
648
1017
  ...this.extraProps
649
1018
  });
650
1019
  }
651
- getWorkspacesList() {
652
- return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
653
- }
654
- getWorkspace(workspaceId) {
1020
+ getWorkspace({ workspace }) {
655
1021
  return operationsByTag.workspaces.getWorkspace({
656
- pathParams: { workspaceId },
1022
+ pathParams: { workspaceId: workspace },
657
1023
  ...this.extraProps
658
1024
  });
659
1025
  }
660
- updateWorkspace(workspaceId, workspaceMeta) {
1026
+ updateWorkspace({
1027
+ workspace,
1028
+ update
1029
+ }) {
661
1030
  return operationsByTag.workspaces.updateWorkspace({
662
- pathParams: { workspaceId },
663
- body: workspaceMeta,
1031
+ pathParams: { workspaceId: workspace },
1032
+ body: update,
664
1033
  ...this.extraProps
665
1034
  });
666
1035
  }
667
- deleteWorkspace(workspaceId) {
1036
+ deleteWorkspace({ workspace }) {
668
1037
  return operationsByTag.workspaces.deleteWorkspace({
669
- pathParams: { workspaceId },
1038
+ pathParams: { workspaceId: workspace },
670
1039
  ...this.extraProps
671
1040
  });
672
1041
  }
673
- getWorkspaceMembersList(workspaceId) {
1042
+ getWorkspaceMembersList({ workspace }) {
674
1043
  return operationsByTag.workspaces.getWorkspaceMembersList({
675
- pathParams: { workspaceId },
1044
+ pathParams: { workspaceId: workspace },
676
1045
  ...this.extraProps
677
1046
  });
678
1047
  }
679
- updateWorkspaceMemberRole(workspaceId, userId, role) {
1048
+ updateWorkspaceMemberRole({
1049
+ workspace,
1050
+ user,
1051
+ role
1052
+ }) {
680
1053
  return operationsByTag.workspaces.updateWorkspaceMemberRole({
681
- pathParams: { workspaceId, userId },
1054
+ pathParams: { workspaceId: workspace, userId: user },
682
1055
  body: { role },
683
1056
  ...this.extraProps
684
1057
  });
685
1058
  }
686
- removeWorkspaceMember(workspaceId, userId) {
1059
+ removeWorkspaceMember({
1060
+ workspace,
1061
+ user
1062
+ }) {
687
1063
  return operationsByTag.workspaces.removeWorkspaceMember({
688
- pathParams: { workspaceId, userId },
1064
+ pathParams: { workspaceId: workspace, userId: user },
689
1065
  ...this.extraProps
690
1066
  });
691
1067
  }
692
- inviteWorkspaceMember(workspaceId, email, role) {
693
- return operationsByTag.workspaces.inviteWorkspaceMember({
694
- pathParams: { workspaceId },
1068
+ }
1069
+ class InvitesApi {
1070
+ constructor(extraProps) {
1071
+ this.extraProps = extraProps;
1072
+ }
1073
+ inviteWorkspaceMember({
1074
+ workspace,
1075
+ email,
1076
+ role
1077
+ }) {
1078
+ return operationsByTag.invites.inviteWorkspaceMember({
1079
+ pathParams: { workspaceId: workspace },
695
1080
  body: { email, role },
696
1081
  ...this.extraProps
697
1082
  });
698
1083
  }
699
- updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
700
- return operationsByTag.workspaces.updateWorkspaceMemberInvite({
701
- pathParams: { workspaceId, inviteId },
1084
+ updateWorkspaceMemberInvite({
1085
+ workspace,
1086
+ invite,
1087
+ role
1088
+ }) {
1089
+ return operationsByTag.invites.updateWorkspaceMemberInvite({
1090
+ pathParams: { workspaceId: workspace, inviteId: invite },
702
1091
  body: { role },
703
1092
  ...this.extraProps
704
1093
  });
705
1094
  }
706
- cancelWorkspaceMemberInvite(workspaceId, inviteId) {
707
- return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
708
- pathParams: { workspaceId, inviteId },
1095
+ cancelWorkspaceMemberInvite({
1096
+ workspace,
1097
+ invite
1098
+ }) {
1099
+ return operationsByTag.invites.cancelWorkspaceMemberInvite({
1100
+ pathParams: { workspaceId: workspace, inviteId: invite },
709
1101
  ...this.extraProps
710
1102
  });
711
1103
  }
712
- resendWorkspaceMemberInvite(workspaceId, inviteId) {
713
- return operationsByTag.workspaces.resendWorkspaceMemberInvite({
714
- pathParams: { workspaceId, inviteId },
1104
+ acceptWorkspaceMemberInvite({
1105
+ workspace,
1106
+ key
1107
+ }) {
1108
+ return operationsByTag.invites.acceptWorkspaceMemberInvite({
1109
+ pathParams: { workspaceId: workspace, inviteKey: key },
715
1110
  ...this.extraProps
716
1111
  });
717
1112
  }
718
- acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
719
- return operationsByTag.workspaces.acceptWorkspaceMemberInvite({
720
- pathParams: { workspaceId, inviteKey },
1113
+ resendWorkspaceMemberInvite({
1114
+ workspace,
1115
+ invite
1116
+ }) {
1117
+ return operationsByTag.invites.resendWorkspaceMemberInvite({
1118
+ pathParams: { workspaceId: workspace, inviteId: invite },
721
1119
  ...this.extraProps
722
1120
  });
723
1121
  }
724
1122
  }
725
- class DatabaseApi {
1123
+ class BranchApi {
726
1124
  constructor(extraProps) {
727
1125
  this.extraProps = extraProps;
728
1126
  }
729
- getDatabaseList(workspace) {
730
- return operationsByTag.database.getDatabaseList({
731
- pathParams: { workspace },
1127
+ getBranchList({
1128
+ workspace,
1129
+ region,
1130
+ database
1131
+ }) {
1132
+ return operationsByTag.branch.getBranchList({
1133
+ pathParams: { workspace, region, dbName: database },
732
1134
  ...this.extraProps
733
1135
  });
734
1136
  }
735
- createDatabase(workspace, dbName, options = {}) {
736
- return operationsByTag.database.createDatabase({
737
- pathParams: { workspace, dbName },
738
- body: options,
1137
+ getBranchDetails({
1138
+ workspace,
1139
+ region,
1140
+ database,
1141
+ branch
1142
+ }) {
1143
+ return operationsByTag.branch.getBranchDetails({
1144
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
739
1145
  ...this.extraProps
740
1146
  });
741
1147
  }
742
- deleteDatabase(workspace, dbName) {
743
- return operationsByTag.database.deleteDatabase({
744
- pathParams: { workspace, dbName },
1148
+ createBranch({
1149
+ workspace,
1150
+ region,
1151
+ database,
1152
+ branch,
1153
+ from,
1154
+ metadata
1155
+ }) {
1156
+ return operationsByTag.branch.createBranch({
1157
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1158
+ body: { from, metadata },
745
1159
  ...this.extraProps
746
1160
  });
747
1161
  }
748
- getDatabaseMetadata(workspace, dbName) {
749
- return operationsByTag.database.getDatabaseMetadata({
750
- pathParams: { workspace, dbName },
1162
+ deleteBranch({
1163
+ workspace,
1164
+ region,
1165
+ database,
1166
+ branch
1167
+ }) {
1168
+ return operationsByTag.branch.deleteBranch({
1169
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
751
1170
  ...this.extraProps
752
1171
  });
753
1172
  }
754
- getGitBranchesMapping(workspace, dbName) {
755
- return operationsByTag.database.getGitBranchesMapping({
756
- pathParams: { workspace, dbName },
1173
+ updateBranchMetadata({
1174
+ workspace,
1175
+ region,
1176
+ database,
1177
+ branch,
1178
+ metadata
1179
+ }) {
1180
+ return operationsByTag.branch.updateBranchMetadata({
1181
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1182
+ body: metadata,
757
1183
  ...this.extraProps
758
1184
  });
759
1185
  }
760
- addGitBranchesEntry(workspace, dbName, body) {
761
- return operationsByTag.database.addGitBranchesEntry({
762
- pathParams: { workspace, dbName },
763
- body,
1186
+ getBranchMetadata({
1187
+ workspace,
1188
+ region,
1189
+ database,
1190
+ branch
1191
+ }) {
1192
+ return operationsByTag.branch.getBranchMetadata({
1193
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
764
1194
  ...this.extraProps
765
1195
  });
766
1196
  }
767
- removeGitBranchesEntry(workspace, dbName, gitBranch) {
768
- return operationsByTag.database.removeGitBranchesEntry({
769
- pathParams: { workspace, dbName },
1197
+ getBranchStats({
1198
+ workspace,
1199
+ region,
1200
+ database,
1201
+ branch
1202
+ }) {
1203
+ return operationsByTag.branch.getBranchStats({
1204
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1205
+ ...this.extraProps
1206
+ });
1207
+ }
1208
+ getGitBranchesMapping({
1209
+ workspace,
1210
+ region,
1211
+ database
1212
+ }) {
1213
+ return operationsByTag.branch.getGitBranchesMapping({
1214
+ pathParams: { workspace, region, dbName: database },
1215
+ ...this.extraProps
1216
+ });
1217
+ }
1218
+ addGitBranchesEntry({
1219
+ workspace,
1220
+ region,
1221
+ database,
1222
+ gitBranch,
1223
+ xataBranch
1224
+ }) {
1225
+ return operationsByTag.branch.addGitBranchesEntry({
1226
+ pathParams: { workspace, region, dbName: database },
1227
+ body: { gitBranch, xataBranch },
1228
+ ...this.extraProps
1229
+ });
1230
+ }
1231
+ removeGitBranchesEntry({
1232
+ workspace,
1233
+ region,
1234
+ database,
1235
+ gitBranch
1236
+ }) {
1237
+ return operationsByTag.branch.removeGitBranchesEntry({
1238
+ pathParams: { workspace, region, dbName: database },
770
1239
  queryParams: { gitBranch },
771
1240
  ...this.extraProps
772
1241
  });
773
1242
  }
774
- resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
775
- return operationsByTag.database.resolveBranch({
776
- pathParams: { workspace, dbName },
1243
+ resolveBranch({
1244
+ workspace,
1245
+ region,
1246
+ database,
1247
+ gitBranch,
1248
+ fallbackBranch
1249
+ }) {
1250
+ return operationsByTag.branch.resolveBranch({
1251
+ pathParams: { workspace, region, dbName: database },
777
1252
  queryParams: { gitBranch, fallbackBranch },
778
1253
  ...this.extraProps
779
1254
  });
780
1255
  }
781
1256
  }
782
- class BranchApi {
1257
+ class TableApi {
783
1258
  constructor(extraProps) {
784
1259
  this.extraProps = extraProps;
785
1260
  }
786
- getBranchList(workspace, dbName) {
787
- return operationsByTag.branch.getBranchList({
788
- pathParams: { workspace, dbName },
1261
+ createTable({
1262
+ workspace,
1263
+ region,
1264
+ database,
1265
+ branch,
1266
+ table
1267
+ }) {
1268
+ return operationsByTag.table.createTable({
1269
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1270
+ ...this.extraProps
1271
+ });
1272
+ }
1273
+ deleteTable({
1274
+ workspace,
1275
+ region,
1276
+ database,
1277
+ branch,
1278
+ table
1279
+ }) {
1280
+ return operationsByTag.table.deleteTable({
1281
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1282
+ ...this.extraProps
1283
+ });
1284
+ }
1285
+ updateTable({
1286
+ workspace,
1287
+ region,
1288
+ database,
1289
+ branch,
1290
+ table,
1291
+ update
1292
+ }) {
1293
+ return operationsByTag.table.updateTable({
1294
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1295
+ body: update,
1296
+ ...this.extraProps
1297
+ });
1298
+ }
1299
+ getTableSchema({
1300
+ workspace,
1301
+ region,
1302
+ database,
1303
+ branch,
1304
+ table
1305
+ }) {
1306
+ return operationsByTag.table.getTableSchema({
1307
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1308
+ ...this.extraProps
1309
+ });
1310
+ }
1311
+ setTableSchema({
1312
+ workspace,
1313
+ region,
1314
+ database,
1315
+ branch,
1316
+ table,
1317
+ schema
1318
+ }) {
1319
+ return operationsByTag.table.setTableSchema({
1320
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1321
+ body: schema,
1322
+ ...this.extraProps
1323
+ });
1324
+ }
1325
+ getTableColumns({
1326
+ workspace,
1327
+ region,
1328
+ database,
1329
+ branch,
1330
+ table
1331
+ }) {
1332
+ return operationsByTag.table.getTableColumns({
1333
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1334
+ ...this.extraProps
1335
+ });
1336
+ }
1337
+ addTableColumn({
1338
+ workspace,
1339
+ region,
1340
+ database,
1341
+ branch,
1342
+ table,
1343
+ column
1344
+ }) {
1345
+ return operationsByTag.table.addTableColumn({
1346
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1347
+ body: column,
1348
+ ...this.extraProps
1349
+ });
1350
+ }
1351
+ getColumn({
1352
+ workspace,
1353
+ region,
1354
+ database,
1355
+ branch,
1356
+ table,
1357
+ column
1358
+ }) {
1359
+ return operationsByTag.table.getColumn({
1360
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1361
+ ...this.extraProps
1362
+ });
1363
+ }
1364
+ updateColumn({
1365
+ workspace,
1366
+ region,
1367
+ database,
1368
+ branch,
1369
+ table,
1370
+ column,
1371
+ update
1372
+ }) {
1373
+ return operationsByTag.table.updateColumn({
1374
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1375
+ body: update,
1376
+ ...this.extraProps
1377
+ });
1378
+ }
1379
+ deleteColumn({
1380
+ workspace,
1381
+ region,
1382
+ database,
1383
+ branch,
1384
+ table,
1385
+ column
1386
+ }) {
1387
+ return operationsByTag.table.deleteColumn({
1388
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1389
+ ...this.extraProps
1390
+ });
1391
+ }
1392
+ }
1393
+ class RecordsApi {
1394
+ constructor(extraProps) {
1395
+ this.extraProps = extraProps;
1396
+ }
1397
+ insertRecord({
1398
+ workspace,
1399
+ region,
1400
+ database,
1401
+ branch,
1402
+ table,
1403
+ record,
1404
+ columns
1405
+ }) {
1406
+ return operationsByTag.records.insertRecord({
1407
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1408
+ queryParams: { columns },
1409
+ body: record,
1410
+ ...this.extraProps
1411
+ });
1412
+ }
1413
+ getRecord({
1414
+ workspace,
1415
+ region,
1416
+ database,
1417
+ branch,
1418
+ table,
1419
+ id,
1420
+ columns
1421
+ }) {
1422
+ return operationsByTag.records.getRecord({
1423
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1424
+ queryParams: { columns },
1425
+ ...this.extraProps
1426
+ });
1427
+ }
1428
+ insertRecordWithID({
1429
+ workspace,
1430
+ region,
1431
+ database,
1432
+ branch,
1433
+ table,
1434
+ id,
1435
+ record,
1436
+ columns,
1437
+ createOnly,
1438
+ ifVersion
1439
+ }) {
1440
+ return operationsByTag.records.insertRecordWithID({
1441
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1442
+ queryParams: { columns, createOnly, ifVersion },
1443
+ body: record,
1444
+ ...this.extraProps
1445
+ });
1446
+ }
1447
+ updateRecordWithID({
1448
+ workspace,
1449
+ region,
1450
+ database,
1451
+ branch,
1452
+ table,
1453
+ id,
1454
+ record,
1455
+ columns,
1456
+ ifVersion
1457
+ }) {
1458
+ return operationsByTag.records.updateRecordWithID({
1459
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1460
+ queryParams: { columns, ifVersion },
1461
+ body: record,
1462
+ ...this.extraProps
1463
+ });
1464
+ }
1465
+ upsertRecordWithID({
1466
+ workspace,
1467
+ region,
1468
+ database,
1469
+ branch,
1470
+ table,
1471
+ id,
1472
+ record,
1473
+ columns,
1474
+ ifVersion
1475
+ }) {
1476
+ return operationsByTag.records.upsertRecordWithID({
1477
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1478
+ queryParams: { columns, ifVersion },
1479
+ body: record,
1480
+ ...this.extraProps
1481
+ });
1482
+ }
1483
+ deleteRecord({
1484
+ workspace,
1485
+ region,
1486
+ database,
1487
+ branch,
1488
+ table,
1489
+ id,
1490
+ columns
1491
+ }) {
1492
+ return operationsByTag.records.deleteRecord({
1493
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1494
+ queryParams: { columns },
1495
+ ...this.extraProps
1496
+ });
1497
+ }
1498
+ bulkInsertTableRecords({
1499
+ workspace,
1500
+ region,
1501
+ database,
1502
+ branch,
1503
+ table,
1504
+ records,
1505
+ columns
1506
+ }) {
1507
+ return operationsByTag.records.bulkInsertTableRecords({
1508
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1509
+ queryParams: { columns },
1510
+ body: { records },
1511
+ ...this.extraProps
1512
+ });
1513
+ }
1514
+ branchTransaction({
1515
+ workspace,
1516
+ region,
1517
+ database,
1518
+ branch,
1519
+ operations
1520
+ }) {
1521
+ return operationsByTag.records.branchTransaction({
1522
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1523
+ body: { operations },
1524
+ ...this.extraProps
1525
+ });
1526
+ }
1527
+ }
1528
+ class SearchAndFilterApi {
1529
+ constructor(extraProps) {
1530
+ this.extraProps = extraProps;
1531
+ }
1532
+ queryTable({
1533
+ workspace,
1534
+ region,
1535
+ database,
1536
+ branch,
1537
+ table,
1538
+ filter,
1539
+ sort,
1540
+ page,
1541
+ columns,
1542
+ consistency
1543
+ }) {
1544
+ return operationsByTag.searchAndFilter.queryTable({
1545
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1546
+ body: { filter, sort, page, columns, consistency },
1547
+ ...this.extraProps
1548
+ });
1549
+ }
1550
+ searchTable({
1551
+ workspace,
1552
+ region,
1553
+ database,
1554
+ branch,
1555
+ table,
1556
+ query,
1557
+ fuzziness,
1558
+ target,
1559
+ prefix,
1560
+ filter,
1561
+ highlight,
1562
+ boosters
1563
+ }) {
1564
+ return operationsByTag.searchAndFilter.searchTable({
1565
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1566
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
1567
+ ...this.extraProps
1568
+ });
1569
+ }
1570
+ searchBranch({
1571
+ workspace,
1572
+ region,
1573
+ database,
1574
+ branch,
1575
+ tables,
1576
+ query,
1577
+ fuzziness,
1578
+ prefix,
1579
+ highlight
1580
+ }) {
1581
+ return operationsByTag.searchAndFilter.searchBranch({
1582
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1583
+ body: { tables, query, fuzziness, prefix, highlight },
1584
+ ...this.extraProps
1585
+ });
1586
+ }
1587
+ vectorSearchTable({
1588
+ workspace,
1589
+ region,
1590
+ database,
1591
+ branch,
1592
+ table,
1593
+ queryVector,
1594
+ column,
1595
+ similarityFunction,
1596
+ size,
1597
+ filter
1598
+ }) {
1599
+ return operationsByTag.searchAndFilter.vectorSearchTable({
1600
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1601
+ body: { queryVector, column, similarityFunction, size, filter },
1602
+ ...this.extraProps
1603
+ });
1604
+ }
1605
+ askTable({
1606
+ workspace,
1607
+ region,
1608
+ database,
1609
+ branch,
1610
+ table,
1611
+ question,
1612
+ fuzziness,
1613
+ target,
1614
+ prefix,
1615
+ filter,
1616
+ boosters,
1617
+ rules
1618
+ }) {
1619
+ return operationsByTag.searchAndFilter.askTable({
1620
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1621
+ body: { question, fuzziness, target, prefix, filter, boosters, rules },
1622
+ ...this.extraProps
1623
+ });
1624
+ }
1625
+ summarizeTable({
1626
+ workspace,
1627
+ region,
1628
+ database,
1629
+ branch,
1630
+ table,
1631
+ filter,
1632
+ columns,
1633
+ summaries,
1634
+ sort,
1635
+ summariesFilter,
1636
+ page,
1637
+ consistency
1638
+ }) {
1639
+ return operationsByTag.searchAndFilter.summarizeTable({
1640
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1641
+ body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
789
1642
  ...this.extraProps
790
1643
  });
791
1644
  }
792
- getBranchDetails(workspace, database, branch) {
793
- return operationsByTag.branch.getBranchDetails({
794
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1645
+ aggregateTable({
1646
+ workspace,
1647
+ region,
1648
+ database,
1649
+ branch,
1650
+ table,
1651
+ filter,
1652
+ aggs
1653
+ }) {
1654
+ return operationsByTag.searchAndFilter.aggregateTable({
1655
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1656
+ body: { filter, aggs },
795
1657
  ...this.extraProps
796
1658
  });
797
1659
  }
798
- createBranch(workspace, database, branch, from, options = {}) {
799
- return operationsByTag.branch.createBranch({
800
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
801
- queryParams: isString(from) ? { from } : void 0,
802
- body: options,
1660
+ }
1661
+ class MigrationRequestsApi {
1662
+ constructor(extraProps) {
1663
+ this.extraProps = extraProps;
1664
+ }
1665
+ queryMigrationRequests({
1666
+ workspace,
1667
+ region,
1668
+ database,
1669
+ filter,
1670
+ sort,
1671
+ page,
1672
+ columns
1673
+ }) {
1674
+ return operationsByTag.migrationRequests.queryMigrationRequests({
1675
+ pathParams: { workspace, region, dbName: database },
1676
+ body: { filter, sort, page, columns },
803
1677
  ...this.extraProps
804
1678
  });
805
1679
  }
806
- deleteBranch(workspace, database, branch) {
807
- return operationsByTag.branch.deleteBranch({
808
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1680
+ createMigrationRequest({
1681
+ workspace,
1682
+ region,
1683
+ database,
1684
+ migration
1685
+ }) {
1686
+ return operationsByTag.migrationRequests.createMigrationRequest({
1687
+ pathParams: { workspace, region, dbName: database },
1688
+ body: migration,
809
1689
  ...this.extraProps
810
1690
  });
811
1691
  }
812
- updateBranchMetadata(workspace, database, branch, metadata = {}) {
813
- return operationsByTag.branch.updateBranchMetadata({
814
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
815
- body: metadata,
1692
+ getMigrationRequest({
1693
+ workspace,
1694
+ region,
1695
+ database,
1696
+ migrationRequest
1697
+ }) {
1698
+ return operationsByTag.migrationRequests.getMigrationRequest({
1699
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
816
1700
  ...this.extraProps
817
1701
  });
818
1702
  }
819
- getBranchMetadata(workspace, database, branch) {
820
- return operationsByTag.branch.getBranchMetadata({
821
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1703
+ updateMigrationRequest({
1704
+ workspace,
1705
+ region,
1706
+ database,
1707
+ migrationRequest,
1708
+ update
1709
+ }) {
1710
+ return operationsByTag.migrationRequests.updateMigrationRequest({
1711
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1712
+ body: update,
822
1713
  ...this.extraProps
823
1714
  });
824
1715
  }
825
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
826
- return operationsByTag.branch.getBranchMigrationHistory({
827
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
828
- body: options,
1716
+ listMigrationRequestsCommits({
1717
+ workspace,
1718
+ region,
1719
+ database,
1720
+ migrationRequest,
1721
+ page
1722
+ }) {
1723
+ return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1724
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1725
+ body: { page },
829
1726
  ...this.extraProps
830
1727
  });
831
1728
  }
832
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
833
- return operationsByTag.branch.executeBranchMigrationPlan({
834
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
835
- body: migrationPlan,
1729
+ compareMigrationRequest({
1730
+ workspace,
1731
+ region,
1732
+ database,
1733
+ migrationRequest
1734
+ }) {
1735
+ return operationsByTag.migrationRequests.compareMigrationRequest({
1736
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
836
1737
  ...this.extraProps
837
1738
  });
838
1739
  }
839
- getBranchMigrationPlan(workspace, database, branch, schema) {
840
- return operationsByTag.branch.getBranchMigrationPlan({
841
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
842
- body: schema,
1740
+ getMigrationRequestIsMerged({
1741
+ workspace,
1742
+ region,
1743
+ database,
1744
+ migrationRequest
1745
+ }) {
1746
+ return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1747
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
843
1748
  ...this.extraProps
844
1749
  });
845
1750
  }
846
- getBranchStats(workspace, database, branch) {
847
- return operationsByTag.branch.getBranchStats({
848
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1751
+ mergeMigrationRequest({
1752
+ workspace,
1753
+ region,
1754
+ database,
1755
+ migrationRequest
1756
+ }) {
1757
+ return operationsByTag.migrationRequests.mergeMigrationRequest({
1758
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
849
1759
  ...this.extraProps
850
1760
  });
851
1761
  }
852
1762
  }
853
- class TableApi {
1763
+ class MigrationsApi {
854
1764
  constructor(extraProps) {
855
1765
  this.extraProps = extraProps;
856
1766
  }
857
- createTable(workspace, database, branch, tableName) {
858
- return operationsByTag.table.createTable({
859
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
860
- ...this.extraProps
861
- });
862
- }
863
- deleteTable(workspace, database, branch, tableName) {
864
- return operationsByTag.table.deleteTable({
865
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1767
+ getBranchMigrationHistory({
1768
+ workspace,
1769
+ region,
1770
+ database,
1771
+ branch,
1772
+ limit,
1773
+ startFrom
1774
+ }) {
1775
+ return operationsByTag.migrations.getBranchMigrationHistory({
1776
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1777
+ body: { limit, startFrom },
866
1778
  ...this.extraProps
867
1779
  });
868
1780
  }
869
- updateTable(workspace, database, branch, tableName, options) {
870
- return operationsByTag.table.updateTable({
871
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
872
- body: options,
1781
+ getBranchMigrationPlan({
1782
+ workspace,
1783
+ region,
1784
+ database,
1785
+ branch,
1786
+ schema
1787
+ }) {
1788
+ return operationsByTag.migrations.getBranchMigrationPlan({
1789
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1790
+ body: schema,
873
1791
  ...this.extraProps
874
1792
  });
875
1793
  }
876
- getTableSchema(workspace, database, branch, tableName) {
877
- return operationsByTag.table.getTableSchema({
878
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1794
+ executeBranchMigrationPlan({
1795
+ workspace,
1796
+ region,
1797
+ database,
1798
+ branch,
1799
+ plan
1800
+ }) {
1801
+ return operationsByTag.migrations.executeBranchMigrationPlan({
1802
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1803
+ body: plan,
879
1804
  ...this.extraProps
880
1805
  });
881
1806
  }
882
- setTableSchema(workspace, database, branch, tableName, options) {
883
- return operationsByTag.table.setTableSchema({
884
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
885
- body: options,
1807
+ getBranchSchemaHistory({
1808
+ workspace,
1809
+ region,
1810
+ database,
1811
+ branch,
1812
+ page
1813
+ }) {
1814
+ return operationsByTag.migrations.getBranchSchemaHistory({
1815
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1816
+ body: { page },
886
1817
  ...this.extraProps
887
1818
  });
888
1819
  }
889
- getTableColumns(workspace, database, branch, tableName) {
890
- return operationsByTag.table.getTableColumns({
891
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1820
+ compareBranchWithUserSchema({
1821
+ workspace,
1822
+ region,
1823
+ database,
1824
+ branch,
1825
+ schema,
1826
+ schemaOperations,
1827
+ branchOperations
1828
+ }) {
1829
+ return operationsByTag.migrations.compareBranchWithUserSchema({
1830
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1831
+ body: { schema, schemaOperations, branchOperations },
892
1832
  ...this.extraProps
893
1833
  });
894
1834
  }
895
- addTableColumn(workspace, database, branch, tableName, column) {
896
- return operationsByTag.table.addTableColumn({
897
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
898
- body: column,
1835
+ compareBranchSchemas({
1836
+ workspace,
1837
+ region,
1838
+ database,
1839
+ branch,
1840
+ compare,
1841
+ sourceBranchOperations,
1842
+ targetBranchOperations
1843
+ }) {
1844
+ return operationsByTag.migrations.compareBranchSchemas({
1845
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
1846
+ body: { sourceBranchOperations, targetBranchOperations },
899
1847
  ...this.extraProps
900
1848
  });
901
1849
  }
902
- getColumn(workspace, database, branch, tableName, columnName) {
903
- return operationsByTag.table.getColumn({
904
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1850
+ updateBranchSchema({
1851
+ workspace,
1852
+ region,
1853
+ database,
1854
+ branch,
1855
+ migration
1856
+ }) {
1857
+ return operationsByTag.migrations.updateBranchSchema({
1858
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1859
+ body: migration,
905
1860
  ...this.extraProps
906
1861
  });
907
1862
  }
908
- deleteColumn(workspace, database, branch, tableName, columnName) {
909
- return operationsByTag.table.deleteColumn({
910
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1863
+ previewBranchSchemaEdit({
1864
+ workspace,
1865
+ region,
1866
+ database,
1867
+ branch,
1868
+ data
1869
+ }) {
1870
+ return operationsByTag.migrations.previewBranchSchemaEdit({
1871
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1872
+ body: data,
911
1873
  ...this.extraProps
912
1874
  });
913
1875
  }
914
- updateColumn(workspace, database, branch, tableName, columnName, options) {
915
- return operationsByTag.table.updateColumn({
916
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
917
- body: options,
1876
+ applyBranchSchemaEdit({
1877
+ workspace,
1878
+ region,
1879
+ database,
1880
+ branch,
1881
+ edits
1882
+ }) {
1883
+ return operationsByTag.migrations.applyBranchSchemaEdit({
1884
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1885
+ body: { edits },
918
1886
  ...this.extraProps
919
1887
  });
920
1888
  }
921
1889
  }
922
- class RecordsApi {
1890
+ class DatabaseApi {
923
1891
  constructor(extraProps) {
924
1892
  this.extraProps = extraProps;
925
1893
  }
926
- insertRecord(workspace, database, branch, tableName, record, options = {}) {
927
- return operationsByTag.records.insertRecord({
928
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
929
- queryParams: options,
930
- body: record,
931
- ...this.extraProps
932
- });
933
- }
934
- insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
935
- return operationsByTag.records.insertRecordWithID({
936
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
937
- queryParams: options,
938
- body: record,
1894
+ getDatabaseList({ workspace }) {
1895
+ return operationsByTag.databases.getDatabaseList({
1896
+ pathParams: { workspaceId: workspace },
939
1897
  ...this.extraProps
940
1898
  });
941
1899
  }
942
- updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
943
- return operationsByTag.records.updateRecordWithID({
944
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
945
- queryParams: options,
946
- body: record,
1900
+ createDatabase({
1901
+ workspace,
1902
+ database,
1903
+ data
1904
+ }) {
1905
+ return operationsByTag.databases.createDatabase({
1906
+ pathParams: { workspaceId: workspace, dbName: database },
1907
+ body: data,
947
1908
  ...this.extraProps
948
1909
  });
949
1910
  }
950
- upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
951
- return operationsByTag.records.upsertRecordWithID({
952
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
953
- queryParams: options,
954
- body: record,
1911
+ deleteDatabase({
1912
+ workspace,
1913
+ database
1914
+ }) {
1915
+ return operationsByTag.databases.deleteDatabase({
1916
+ pathParams: { workspaceId: workspace, dbName: database },
955
1917
  ...this.extraProps
956
1918
  });
957
1919
  }
958
- deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
959
- return operationsByTag.records.deleteRecord({
960
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
961
- queryParams: options,
1920
+ getDatabaseMetadata({
1921
+ workspace,
1922
+ database
1923
+ }) {
1924
+ return operationsByTag.databases.getDatabaseMetadata({
1925
+ pathParams: { workspaceId: workspace, dbName: database },
962
1926
  ...this.extraProps
963
1927
  });
964
1928
  }
965
- getRecord(workspace, database, branch, tableName, recordId, options = {}) {
966
- return operationsByTag.records.getRecord({
967
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
968
- queryParams: options,
1929
+ updateDatabaseMetadata({
1930
+ workspace,
1931
+ database,
1932
+ metadata
1933
+ }) {
1934
+ return operationsByTag.databases.updateDatabaseMetadata({
1935
+ pathParams: { workspaceId: workspace, dbName: database },
1936
+ body: metadata,
969
1937
  ...this.extraProps
970
1938
  });
971
1939
  }
972
- bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
973
- return operationsByTag.records.bulkInsertTableRecords({
974
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
975
- queryParams: options,
976
- body: { records },
1940
+ getDatabaseGithubSettings({
1941
+ workspace,
1942
+ database
1943
+ }) {
1944
+ return operationsByTag.databases.getDatabaseGithubSettings({
1945
+ pathParams: { workspaceId: workspace, dbName: database },
977
1946
  ...this.extraProps
978
1947
  });
979
1948
  }
980
- queryTable(workspace, database, branch, tableName, query) {
981
- return operationsByTag.records.queryTable({
982
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
983
- body: query,
1949
+ updateDatabaseGithubSettings({
1950
+ workspace,
1951
+ database,
1952
+ settings
1953
+ }) {
1954
+ return operationsByTag.databases.updateDatabaseGithubSettings({
1955
+ pathParams: { workspaceId: workspace, dbName: database },
1956
+ body: settings,
984
1957
  ...this.extraProps
985
1958
  });
986
1959
  }
987
- searchTable(workspace, database, branch, tableName, query) {
988
- return operationsByTag.records.searchTable({
989
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
990
- body: query,
1960
+ deleteDatabaseGithubSettings({
1961
+ workspace,
1962
+ database
1963
+ }) {
1964
+ return operationsByTag.databases.deleteDatabaseGithubSettings({
1965
+ pathParams: { workspaceId: workspace, dbName: database },
991
1966
  ...this.extraProps
992
1967
  });
993
1968
  }
994
- searchBranch(workspace, database, branch, query) {
995
- return operationsByTag.records.searchBranch({
996
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
997
- body: query,
1969
+ listRegions({ workspace }) {
1970
+ return operationsByTag.databases.listRegions({
1971
+ pathParams: { workspaceId: workspace },
998
1972
  ...this.extraProps
999
1973
  });
1000
1974
  }
1001
1975
  }
1002
1976
 
1003
1977
  class XataApiPlugin {
1004
- async build(options) {
1005
- const { fetchImpl, apiKey } = await options.getFetchProps();
1006
- return new XataApiClient({ fetch: fetchImpl, apiKey });
1978
+ build(options) {
1979
+ return new XataApiClient(options);
1007
1980
  }
1008
1981
  }
1009
1982
 
1010
1983
  class XataPlugin {
1011
1984
  }
1012
1985
 
1986
+ function cleanFilter(filter) {
1987
+ if (!filter)
1988
+ return void 0;
1989
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
1990
+ return values.length > 0 ? filter : void 0;
1991
+ }
1992
+
1013
1993
  var __accessCheck$6 = (obj, member, msg) => {
1014
1994
  if (!member.has(obj))
1015
1995
  throw TypeError("Cannot " + msg);
@@ -1042,11 +2022,11 @@ class Page {
1042
2022
  async previousPage(size, offset) {
1043
2023
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
1044
2024
  }
1045
- async firstPage(size, offset) {
1046
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
2025
+ async startPage(size, offset) {
2026
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
1047
2027
  }
1048
- async lastPage(size, offset) {
1049
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
2028
+ async endPage(size, offset) {
2029
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
1050
2030
  }
1051
2031
  hasNextPage() {
1052
2032
  return this.meta.page.more;
@@ -1058,7 +2038,7 @@ const PAGINATION_DEFAULT_SIZE = 20;
1058
2038
  const PAGINATION_MAX_OFFSET = 800;
1059
2039
  const PAGINATION_DEFAULT_OFFSET = 0;
1060
2040
  function isCursorPaginationOptions(options) {
1061
- return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
2041
+ return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
1062
2042
  }
1063
2043
  const _RecordArray = class extends Array {
1064
2044
  constructor(...args) {
@@ -1079,6 +2059,12 @@ const _RecordArray = class extends Array {
1079
2059
  toArray() {
1080
2060
  return new Array(...this);
1081
2061
  }
2062
+ toSerializable() {
2063
+ return JSON.parse(this.toString());
2064
+ }
2065
+ toString() {
2066
+ return JSON.stringify(this.toArray());
2067
+ }
1082
2068
  map(callbackfn, thisArg) {
1083
2069
  return this.toArray().map(callbackfn, thisArg);
1084
2070
  }
@@ -1090,12 +2076,12 @@ const _RecordArray = class extends Array {
1090
2076
  const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
1091
2077
  return new _RecordArray(newPage);
1092
2078
  }
1093
- async firstPage(size, offset) {
1094
- const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
2079
+ async startPage(size, offset) {
2080
+ const newPage = await __privateGet$6(this, _page).startPage(size, offset);
1095
2081
  return new _RecordArray(newPage);
1096
2082
  }
1097
- async lastPage(size, offset) {
1098
- const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
2083
+ async endPage(size, offset) {
2084
+ const newPage = await __privateGet$6(this, _page).endPage(size, offset);
1099
2085
  return new _RecordArray(newPage);
1100
2086
  }
1101
2087
  hasNextPage() {
@@ -1123,9 +2109,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
1123
2109
  setter ? setter.call(obj, value) : member.set(obj, value);
1124
2110
  return value;
1125
2111
  };
1126
- var _table$1, _repository, _data;
2112
+ var __privateMethod$3 = (obj, member, method) => {
2113
+ __accessCheck$5(obj, member, "access private method");
2114
+ return method;
2115
+ };
2116
+ var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
1127
2117
  const _Query = class {
1128
2118
  constructor(repository, table, data, rawParent) {
2119
+ __privateAdd$5(this, _cleanFilterConstraint);
1129
2120
  __privateAdd$5(this, _table$1, void 0);
1130
2121
  __privateAdd$5(this, _repository, void 0);
1131
2122
  __privateAdd$5(this, _data, { filter: {} });
@@ -1144,9 +2135,11 @@ const _Query = class {
1144
2135
  __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
1145
2136
  __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
1146
2137
  __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
1147
- __privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
2138
+ __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
2139
+ __privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
1148
2140
  __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
1149
2141
  __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
2142
+ __privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
1150
2143
  this.any = this.any.bind(this);
1151
2144
  this.all = this.all.bind(this);
1152
2145
  this.not = this.not.bind(this);
@@ -1182,15 +2175,18 @@ const _Query = class {
1182
2175
  }
1183
2176
  filter(a, b) {
1184
2177
  if (arguments.length === 1) {
1185
- const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
2178
+ const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
2179
+ [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
2180
+ }));
1186
2181
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1187
2182
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1188
2183
  } else {
1189
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
2184
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
2185
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1190
2186
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1191
2187
  }
1192
2188
  }
1193
- sort(column, direction) {
2189
+ sort(column, direction = "asc") {
1194
2190
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1195
2191
  const sort = [...originalSort, { column, direction }];
1196
2192
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
@@ -1224,11 +2220,20 @@ const _Query = class {
1224
2220
  }
1225
2221
  }
1226
2222
  async getMany(options = {}) {
1227
- const page = await this.getPaginated(options);
2223
+ const { pagination = {}, ...rest } = options;
2224
+ const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
2225
+ const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
2226
+ let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
2227
+ const results = [...page.records];
2228
+ while (page.hasNextPage() && results.length < size) {
2229
+ page = await page.nextPage();
2230
+ results.push(...page.records);
2231
+ }
1228
2232
  if (page.hasNextPage() && options.pagination?.size === void 0) {
1229
2233
  console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
1230
2234
  }
1231
- return page.records;
2235
+ const array = new RecordArray(page, results.slice(0, size));
2236
+ return array;
1232
2237
  }
1233
2238
  async getAll(options = {}) {
1234
2239
  const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
@@ -1242,19 +2247,35 @@ const _Query = class {
1242
2247
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
1243
2248
  return records[0] ?? null;
1244
2249
  }
2250
+ async getFirstOrThrow(options = {}) {
2251
+ const records = await this.getMany({ ...options, pagination: { size: 1 } });
2252
+ if (records[0] === void 0)
2253
+ throw new Error("No results found.");
2254
+ return records[0];
2255
+ }
2256
+ async summarize(params = {}) {
2257
+ const { summaries, summariesFilter, ...options } = params;
2258
+ const query = new _Query(
2259
+ __privateGet$5(this, _repository),
2260
+ __privateGet$5(this, _table$1),
2261
+ options,
2262
+ __privateGet$5(this, _data)
2263
+ );
2264
+ return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
2265
+ }
1245
2266
  cache(ttl) {
1246
2267
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1247
2268
  }
1248
2269
  nextPage(size, offset) {
1249
- return this.firstPage(size, offset);
2270
+ return this.startPage(size, offset);
1250
2271
  }
1251
2272
  previousPage(size, offset) {
1252
- return this.firstPage(size, offset);
2273
+ return this.startPage(size, offset);
1253
2274
  }
1254
- firstPage(size, offset) {
2275
+ startPage(size, offset) {
1255
2276
  return this.getPaginated({ pagination: { size, offset } });
1256
2277
  }
1257
- lastPage(size, offset) {
2278
+ endPage(size, offset) {
1258
2279
  return this.getPaginated({ pagination: { size, offset, before: "end" } });
1259
2280
  }
1260
2281
  hasNextPage() {
@@ -1265,9 +2286,20 @@ let Query = _Query;
1265
2286
  _table$1 = new WeakMap();
1266
2287
  _repository = new WeakMap();
1267
2288
  _data = new WeakMap();
2289
+ _cleanFilterConstraint = new WeakSet();
2290
+ cleanFilterConstraint_fn = function(column, value) {
2291
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
2292
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
2293
+ return { $includes: value };
2294
+ }
2295
+ if (columnType === "link" && isObject(value) && isString(value.id)) {
2296
+ return value.id;
2297
+ }
2298
+ return value;
2299
+ };
1268
2300
  function cleanParent(data, parent) {
1269
2301
  if (isCursorPaginationOptions(data.pagination)) {
1270
- return { ...parent, sorting: void 0, filter: void 0 };
2302
+ return { ...parent, sort: void 0, filter: void 0 };
1271
2303
  }
1272
2304
  return parent;
1273
2305
  }
@@ -1326,18 +2358,25 @@ var __privateMethod$2 = (obj, member, method) => {
1326
2358
  __accessCheck$4(obj, member, "access private method");
1327
2359
  return method;
1328
2360
  };
1329
- var _table, _getFetchProps, _db, _cache, _schemaTables$2, _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;
2361
+ 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;
2362
+ const BULK_OPERATION_MAX_SIZE = 1e3;
1330
2363
  class Repository extends Query {
1331
2364
  }
1332
2365
  class RestRepository extends Query {
1333
2366
  constructor(options) {
1334
- super(null, options.table, {});
2367
+ super(
2368
+ null,
2369
+ { name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
2370
+ {}
2371
+ );
1335
2372
  __privateAdd$4(this, _insertRecordWithoutId);
1336
2373
  __privateAdd$4(this, _insertRecordWithId);
1337
- __privateAdd$4(this, _bulkInsertTableRecords);
2374
+ __privateAdd$4(this, _insertRecords);
1338
2375
  __privateAdd$4(this, _updateRecordWithID);
2376
+ __privateAdd$4(this, _updateRecords);
1339
2377
  __privateAdd$4(this, _upsertRecordWithID);
1340
2378
  __privateAdd$4(this, _deleteRecord);
2379
+ __privateAdd$4(this, _deleteRecords);
1341
2380
  __privateAdd$4(this, _setCacheQuery);
1342
2381
  __privateAdd$4(this, _getCacheQuery);
1343
2382
  __privateAdd$4(this, _getSchemaTables$1);
@@ -1346,168 +2385,370 @@ class RestRepository extends Query {
1346
2385
  __privateAdd$4(this, _db, void 0);
1347
2386
  __privateAdd$4(this, _cache, void 0);
1348
2387
  __privateAdd$4(this, _schemaTables$2, void 0);
2388
+ __privateAdd$4(this, _trace, void 0);
1349
2389
  __privateSet$4(this, _table, options.table);
1350
- __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1351
2390
  __privateSet$4(this, _db, options.db);
1352
2391
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1353
2392
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
2393
+ __privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
2394
+ const trace = options.pluginOptions.trace ?? defaultTrace;
2395
+ __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
2396
+ return trace(name, fn, {
2397
+ ...options2,
2398
+ [TraceAttributes.TABLE]: __privateGet$4(this, _table),
2399
+ [TraceAttributes.KIND]: "sdk-operation",
2400
+ [TraceAttributes.VERSION]: VERSION
2401
+ });
2402
+ });
1354
2403
  }
1355
- async create(a, b, c) {
1356
- if (Array.isArray(a)) {
1357
- if (a.length === 0)
1358
- return [];
1359
- const columns = isStringArray(b) ? b : void 0;
1360
- return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
1361
- }
1362
- if (isString(a) && isObject(b)) {
1363
- if (a === "")
1364
- throw new Error("The id can't be empty");
1365
- const columns = isStringArray(c) ? c : void 0;
1366
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
1367
- }
1368
- if (isObject(a) && isString(a.id)) {
1369
- if (a.id === "")
1370
- throw new Error("The id can't be empty");
1371
- const columns = isStringArray(b) ? b : void 0;
1372
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1373
- }
1374
- if (isObject(a)) {
1375
- const columns = isStringArray(b) ? b : void 0;
1376
- return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
1377
- }
1378
- throw new Error("Invalid arguments for create method");
2404
+ async create(a, b, c, d) {
2405
+ return __privateGet$4(this, _trace).call(this, "create", async () => {
2406
+ const ifVersion = parseIfVersion(b, c, d);
2407
+ if (Array.isArray(a)) {
2408
+ if (a.length === 0)
2409
+ return [];
2410
+ const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
2411
+ const columns = isStringArray(b) ? b : ["*"];
2412
+ const result = await this.read(ids, columns);
2413
+ return result;
2414
+ }
2415
+ if (isString(a) && isObject(b)) {
2416
+ if (a === "")
2417
+ throw new Error("The id can't be empty");
2418
+ const columns = isStringArray(c) ? c : void 0;
2419
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
2420
+ }
2421
+ if (isObject(a) && isString(a.id)) {
2422
+ if (a.id === "")
2423
+ throw new Error("The id can't be empty");
2424
+ const columns = isStringArray(b) ? b : void 0;
2425
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
2426
+ }
2427
+ if (isObject(a)) {
2428
+ const columns = isStringArray(b) ? b : void 0;
2429
+ return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
2430
+ }
2431
+ throw new Error("Invalid arguments for create method");
2432
+ });
1379
2433
  }
1380
2434
  async read(a, b) {
1381
- const columns = isStringArray(b) ? b : ["*"];
1382
- if (Array.isArray(a)) {
1383
- if (a.length === 0)
1384
- return [];
1385
- const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
1386
- const finalObjects = await this.getAll({ filter: { id: { $any: ids } }, columns });
1387
- const dictionary = finalObjects.reduce((acc, object) => {
1388
- acc[object.id] = object;
1389
- return acc;
1390
- }, {});
1391
- return ids.map((id2) => dictionary[id2] ?? null);
1392
- }
1393
- const id = isString(a) ? a : a.id;
1394
- if (isString(id)) {
1395
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1396
- try {
1397
- const response = await getRecord({
1398
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: id },
1399
- queryParams: { columns },
1400
- ...fetchProps
2435
+ return __privateGet$4(this, _trace).call(this, "read", async () => {
2436
+ const columns = isStringArray(b) ? b : ["*"];
2437
+ if (Array.isArray(a)) {
2438
+ if (a.length === 0)
2439
+ return [];
2440
+ const ids = a.map((item) => extractId(item));
2441
+ const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
2442
+ const dictionary = finalObjects.reduce((acc, object) => {
2443
+ acc[object.id] = object;
2444
+ return acc;
2445
+ }, {});
2446
+ return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
2447
+ }
2448
+ const id = extractId(a);
2449
+ if (id) {
2450
+ try {
2451
+ const response = await getRecord({
2452
+ pathParams: {
2453
+ workspace: "{workspaceId}",
2454
+ dbBranchName: "{dbBranch}",
2455
+ region: "{region}",
2456
+ tableName: __privateGet$4(this, _table),
2457
+ recordId: id
2458
+ },
2459
+ queryParams: { columns },
2460
+ ...__privateGet$4(this, _getFetchProps).call(this)
2461
+ });
2462
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2463
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2464
+ } catch (e) {
2465
+ if (isObject(e) && e.status === 404) {
2466
+ return null;
2467
+ }
2468
+ throw e;
2469
+ }
2470
+ }
2471
+ return null;
2472
+ });
2473
+ }
2474
+ async readOrThrow(a, b) {
2475
+ return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
2476
+ const result = await this.read(a, b);
2477
+ if (Array.isArray(result)) {
2478
+ const missingIds = compact(
2479
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
2480
+ );
2481
+ if (missingIds.length > 0) {
2482
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
2483
+ }
2484
+ return result;
2485
+ }
2486
+ if (result === null) {
2487
+ const id = extractId(a) ?? "unknown";
2488
+ throw new Error(`Record with id ${id} not found`);
2489
+ }
2490
+ return result;
2491
+ });
2492
+ }
2493
+ async update(a, b, c, d) {
2494
+ return __privateGet$4(this, _trace).call(this, "update", async () => {
2495
+ const ifVersion = parseIfVersion(b, c, d);
2496
+ if (Array.isArray(a)) {
2497
+ if (a.length === 0)
2498
+ return [];
2499
+ const existing = await this.read(a, ["id"]);
2500
+ const updates = a.filter((_item, index) => existing[index] !== null);
2501
+ await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
2502
+ ifVersion,
2503
+ upsert: false
1401
2504
  });
1402
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1403
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1404
- } catch (e) {
1405
- if (isObject(e) && e.status === 404) {
2505
+ const columns = isStringArray(b) ? b : ["*"];
2506
+ const result = await this.read(a, columns);
2507
+ return result;
2508
+ }
2509
+ try {
2510
+ if (isString(a) && isObject(b)) {
2511
+ const columns = isStringArray(c) ? c : void 0;
2512
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2513
+ }
2514
+ if (isObject(a) && isString(a.id)) {
2515
+ const columns = isStringArray(b) ? b : void 0;
2516
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2517
+ }
2518
+ } catch (error) {
2519
+ if (error.status === 422)
1406
2520
  return null;
2521
+ throw error;
2522
+ }
2523
+ throw new Error("Invalid arguments for update method");
2524
+ });
2525
+ }
2526
+ async updateOrThrow(a, b, c, d) {
2527
+ return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
2528
+ const result = await this.update(a, b, c, d);
2529
+ if (Array.isArray(result)) {
2530
+ const missingIds = compact(
2531
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
2532
+ );
2533
+ if (missingIds.length > 0) {
2534
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1407
2535
  }
1408
- throw e;
2536
+ return result;
1409
2537
  }
1410
- }
1411
- return null;
2538
+ if (result === null) {
2539
+ const id = extractId(a) ?? "unknown";
2540
+ throw new Error(`Record with id ${id} not found`);
2541
+ }
2542
+ return result;
2543
+ });
1412
2544
  }
1413
- async update(a, b, c) {
1414
- if (Array.isArray(a)) {
1415
- if (a.length === 0)
1416
- return [];
1417
- if (a.length > 100) {
1418
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
2545
+ async createOrUpdate(a, b, c, d) {
2546
+ return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
2547
+ const ifVersion = parseIfVersion(b, c, d);
2548
+ if (Array.isArray(a)) {
2549
+ if (a.length === 0)
2550
+ return [];
2551
+ await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
2552
+ ifVersion,
2553
+ upsert: true
2554
+ });
2555
+ const columns = isStringArray(b) ? b : ["*"];
2556
+ const result = await this.read(a, columns);
2557
+ return result;
1419
2558
  }
1420
- const columns = isStringArray(b) ? b : ["*"];
1421
- return Promise.all(a.map((object) => this.update(object, columns)));
1422
- }
1423
- if (isString(a) && isObject(b)) {
1424
- const columns = isStringArray(c) ? c : void 0;
1425
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
1426
- }
1427
- if (isObject(a) && isString(a.id)) {
1428
- const columns = isStringArray(b) ? b : void 0;
1429
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1430
- }
1431
- throw new Error("Invalid arguments for update method");
1432
- }
1433
- async createOrUpdate(a, b, c) {
1434
- if (Array.isArray(a)) {
1435
- if (a.length === 0)
1436
- return [];
1437
- if (a.length > 100) {
1438
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
2559
+ if (isString(a) && isObject(b)) {
2560
+ const columns = isStringArray(c) ? c : void 0;
2561
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1439
2562
  }
1440
- const columns = isStringArray(b) ? b : ["*"];
1441
- return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
1442
- }
1443
- if (isString(a) && isObject(b)) {
1444
- const columns = isStringArray(c) ? c : void 0;
1445
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
1446
- }
1447
- if (isObject(a) && isString(a.id)) {
1448
- const columns = isStringArray(c) ? c : void 0;
1449
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1450
- }
1451
- throw new Error("Invalid arguments for createOrUpdate method");
1452
- }
1453
- async delete(a) {
1454
- if (Array.isArray(a)) {
1455
- if (a.length === 0)
1456
- return;
1457
- if (a.length > 100) {
1458
- console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
2563
+ if (isObject(a) && isString(a.id)) {
2564
+ const columns = isStringArray(c) ? c : void 0;
2565
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
1459
2566
  }
1460
- await Promise.all(a.map((id) => this.delete(id)));
1461
- return;
1462
- }
1463
- if (isString(a)) {
1464
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
1465
- return;
1466
- }
1467
- if (isObject(a) && isString(a.id)) {
1468
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
1469
- return;
1470
- }
1471
- throw new Error("Invalid arguments for delete method");
2567
+ throw new Error("Invalid arguments for createOrUpdate method");
2568
+ });
2569
+ }
2570
+ async createOrReplace(a, b, c, d) {
2571
+ return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
2572
+ const ifVersion = parseIfVersion(b, c, d);
2573
+ if (Array.isArray(a)) {
2574
+ if (a.length === 0)
2575
+ return [];
2576
+ const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
2577
+ const columns = isStringArray(b) ? b : ["*"];
2578
+ const result = await this.read(ids, columns);
2579
+ return result;
2580
+ }
2581
+ if (isString(a) && isObject(b)) {
2582
+ const columns = isStringArray(c) ? c : void 0;
2583
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
2584
+ }
2585
+ if (isObject(a) && isString(a.id)) {
2586
+ const columns = isStringArray(c) ? c : void 0;
2587
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
2588
+ }
2589
+ throw new Error("Invalid arguments for createOrReplace method");
2590
+ });
2591
+ }
2592
+ async delete(a, b) {
2593
+ return __privateGet$4(this, _trace).call(this, "delete", async () => {
2594
+ if (Array.isArray(a)) {
2595
+ if (a.length === 0)
2596
+ return [];
2597
+ const ids = a.map((o) => {
2598
+ if (isString(o))
2599
+ return o;
2600
+ if (isString(o.id))
2601
+ return o.id;
2602
+ throw new Error("Invalid arguments for delete method");
2603
+ });
2604
+ const columns = isStringArray(b) ? b : ["*"];
2605
+ const result = await this.read(a, columns);
2606
+ await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
2607
+ return result;
2608
+ }
2609
+ if (isString(a)) {
2610
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
2611
+ }
2612
+ if (isObject(a) && isString(a.id)) {
2613
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
2614
+ }
2615
+ throw new Error("Invalid arguments for delete method");
2616
+ });
2617
+ }
2618
+ async deleteOrThrow(a, b) {
2619
+ return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
2620
+ const result = await this.delete(a, b);
2621
+ if (Array.isArray(result)) {
2622
+ const missingIds = compact(
2623
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
2624
+ );
2625
+ if (missingIds.length > 0) {
2626
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
2627
+ }
2628
+ return result;
2629
+ } else if (result === null) {
2630
+ const id = extractId(a) ?? "unknown";
2631
+ throw new Error(`Record with id ${id} not found`);
2632
+ }
2633
+ return result;
2634
+ });
1472
2635
  }
1473
2636
  async search(query, options = {}) {
1474
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1475
- const { records } = await searchTable({
1476
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1477
- body: {
1478
- query,
1479
- fuzziness: options.fuzziness,
1480
- prefix: options.prefix,
1481
- highlight: options.highlight,
1482
- filter: options.filter,
1483
- boosters: options.boosters
1484
- },
1485
- ...fetchProps
2637
+ return __privateGet$4(this, _trace).call(this, "search", async () => {
2638
+ const { records } = await searchTable({
2639
+ pathParams: {
2640
+ workspace: "{workspaceId}",
2641
+ dbBranchName: "{dbBranch}",
2642
+ region: "{region}",
2643
+ tableName: __privateGet$4(this, _table)
2644
+ },
2645
+ body: {
2646
+ query,
2647
+ fuzziness: options.fuzziness,
2648
+ prefix: options.prefix,
2649
+ highlight: options.highlight,
2650
+ filter: options.filter,
2651
+ boosters: options.boosters,
2652
+ page: options.page,
2653
+ target: options.target
2654
+ },
2655
+ ...__privateGet$4(this, _getFetchProps).call(this)
2656
+ });
2657
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2658
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
2659
+ });
2660
+ }
2661
+ async vectorSearch(column, query, options) {
2662
+ return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
2663
+ const { records } = await vectorSearchTable({
2664
+ pathParams: {
2665
+ workspace: "{workspaceId}",
2666
+ dbBranchName: "{dbBranch}",
2667
+ region: "{region}",
2668
+ tableName: __privateGet$4(this, _table)
2669
+ },
2670
+ body: {
2671
+ column,
2672
+ queryVector: query,
2673
+ similarityFunction: options?.similarityFunction,
2674
+ size: options?.size,
2675
+ filter: options?.filter
2676
+ },
2677
+ ...__privateGet$4(this, _getFetchProps).call(this)
2678
+ });
2679
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2680
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
2681
+ });
2682
+ }
2683
+ async aggregate(aggs, filter) {
2684
+ return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
2685
+ const result = await aggregateTable({
2686
+ pathParams: {
2687
+ workspace: "{workspaceId}",
2688
+ dbBranchName: "{dbBranch}",
2689
+ region: "{region}",
2690
+ tableName: __privateGet$4(this, _table)
2691
+ },
2692
+ body: { aggs, filter },
2693
+ ...__privateGet$4(this, _getFetchProps).call(this)
2694
+ });
2695
+ return result;
1486
2696
  });
1487
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1488
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
1489
2697
  }
1490
2698
  async query(query) {
1491
- const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1492
- if (cacheQuery)
1493
- return new Page(query, cacheQuery.meta, cacheQuery.records);
1494
- const data = query.getQueryOptions();
1495
- const body = {
1496
- filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1497
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1498
- page: data.pagination,
1499
- columns: data.columns
1500
- };
1501
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1502
- const { meta, records: objects } = await queryTable({
1503
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1504
- body,
1505
- ...fetchProps
2699
+ return __privateGet$4(this, _trace).call(this, "query", async () => {
2700
+ const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
2701
+ if (cacheQuery)
2702
+ return new Page(query, cacheQuery.meta, cacheQuery.records);
2703
+ const data = query.getQueryOptions();
2704
+ const { meta, records: objects } = await queryTable({
2705
+ pathParams: {
2706
+ workspace: "{workspaceId}",
2707
+ dbBranchName: "{dbBranch}",
2708
+ region: "{region}",
2709
+ tableName: __privateGet$4(this, _table)
2710
+ },
2711
+ body: {
2712
+ filter: cleanFilter(data.filter),
2713
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2714
+ page: data.pagination,
2715
+ columns: data.columns ?? ["*"],
2716
+ consistency: data.consistency
2717
+ },
2718
+ fetchOptions: data.fetchOptions,
2719
+ ...__privateGet$4(this, _getFetchProps).call(this)
2720
+ });
2721
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2722
+ const records = objects.map(
2723
+ (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
2724
+ );
2725
+ await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
2726
+ return new Page(query, meta, records);
2727
+ });
2728
+ }
2729
+ async summarizeTable(query, summaries, summariesFilter) {
2730
+ return __privateGet$4(this, _trace).call(this, "summarize", async () => {
2731
+ const data = query.getQueryOptions();
2732
+ const result = await summarizeTable({
2733
+ pathParams: {
2734
+ workspace: "{workspaceId}",
2735
+ dbBranchName: "{dbBranch}",
2736
+ region: "{region}",
2737
+ tableName: __privateGet$4(this, _table)
2738
+ },
2739
+ body: {
2740
+ filter: cleanFilter(data.filter),
2741
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2742
+ columns: data.columns,
2743
+ consistency: data.consistency,
2744
+ page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
2745
+ summaries,
2746
+ summariesFilter
2747
+ },
2748
+ ...__privateGet$4(this, _getFetchProps).call(this)
2749
+ });
2750
+ return result;
1506
2751
  });
1507
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1508
- const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
1509
- await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1510
- return new Page(query, meta, records);
1511
2752
  }
1512
2753
  }
1513
2754
  _table = new WeakMap();
@@ -1515,89 +2756,182 @@ _getFetchProps = new WeakMap();
1515
2756
  _db = new WeakMap();
1516
2757
  _cache = new WeakMap();
1517
2758
  _schemaTables$2 = new WeakMap();
2759
+ _trace = new WeakMap();
1518
2760
  _insertRecordWithoutId = new WeakSet();
1519
2761
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1520
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1521
2762
  const record = transformObjectLinks(object);
1522
2763
  const response = await insertRecord({
1523
2764
  pathParams: {
1524
2765
  workspace: "{workspaceId}",
1525
2766
  dbBranchName: "{dbBranch}",
2767
+ region: "{region}",
1526
2768
  tableName: __privateGet$4(this, _table)
1527
2769
  },
1528
2770
  queryParams: { columns },
1529
2771
  body: record,
1530
- ...fetchProps
2772
+ ...__privateGet$4(this, _getFetchProps).call(this)
1531
2773
  });
1532
2774
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1533
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2775
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1534
2776
  };
1535
2777
  _insertRecordWithId = new WeakSet();
1536
- insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
1537
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2778
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
1538
2779
  const record = transformObjectLinks(object);
1539
2780
  const response = await insertRecordWithID({
1540
2781
  pathParams: {
1541
2782
  workspace: "{workspaceId}",
1542
2783
  dbBranchName: "{dbBranch}",
2784
+ region: "{region}",
1543
2785
  tableName: __privateGet$4(this, _table),
1544
2786
  recordId
1545
2787
  },
1546
2788
  body: record,
1547
- queryParams: { createOnly: true, columns },
1548
- ...fetchProps
2789
+ queryParams: { createOnly, columns, ifVersion },
2790
+ ...__privateGet$4(this, _getFetchProps).call(this)
1549
2791
  });
1550
2792
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1551
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1552
- };
1553
- _bulkInsertTableRecords = new WeakSet();
1554
- bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1555
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1556
- const records = objects.map((object) => transformObjectLinks(object));
1557
- const response = await bulkInsertTableRecords({
1558
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1559
- queryParams: { columns },
1560
- body: { records },
1561
- ...fetchProps
1562
- });
1563
- if (!isResponseWithRecords(response)) {
1564
- throw new Error("Request included columns but server didn't include them");
2793
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2794
+ };
2795
+ _insertRecords = new WeakSet();
2796
+ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
2797
+ const chunkedOperations = chunk(
2798
+ objects.map((object) => ({
2799
+ insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
2800
+ })),
2801
+ BULK_OPERATION_MAX_SIZE
2802
+ );
2803
+ const ids = [];
2804
+ for (const operations of chunkedOperations) {
2805
+ const { results } = await branchTransaction({
2806
+ pathParams: {
2807
+ workspace: "{workspaceId}",
2808
+ dbBranchName: "{dbBranch}",
2809
+ region: "{region}"
2810
+ },
2811
+ body: { operations },
2812
+ ...__privateGet$4(this, _getFetchProps).call(this)
2813
+ });
2814
+ for (const result of results) {
2815
+ if (result.operation === "insert") {
2816
+ ids.push(result.id);
2817
+ } else {
2818
+ ids.push(null);
2819
+ }
2820
+ }
1565
2821
  }
1566
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1567
- return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
2822
+ return ids;
1568
2823
  };
1569
2824
  _updateRecordWithID = new WeakSet();
1570
- updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1571
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1572
- const record = transformObjectLinks(object);
1573
- const response = await updateRecordWithID({
1574
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1575
- queryParams: { columns },
1576
- body: record,
1577
- ...fetchProps
1578
- });
1579
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1580
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2825
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
2826
+ const { id: _id, ...record } = transformObjectLinks(object);
2827
+ try {
2828
+ const response = await updateRecordWithID({
2829
+ pathParams: {
2830
+ workspace: "{workspaceId}",
2831
+ dbBranchName: "{dbBranch}",
2832
+ region: "{region}",
2833
+ tableName: __privateGet$4(this, _table),
2834
+ recordId
2835
+ },
2836
+ queryParams: { columns, ifVersion },
2837
+ body: record,
2838
+ ...__privateGet$4(this, _getFetchProps).call(this)
2839
+ });
2840
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2841
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2842
+ } catch (e) {
2843
+ if (isObject(e) && e.status === 404) {
2844
+ return null;
2845
+ }
2846
+ throw e;
2847
+ }
2848
+ };
2849
+ _updateRecords = new WeakSet();
2850
+ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
2851
+ const chunkedOperations = chunk(
2852
+ objects.map(({ id, ...object }) => ({
2853
+ update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
2854
+ })),
2855
+ BULK_OPERATION_MAX_SIZE
2856
+ );
2857
+ const ids = [];
2858
+ for (const operations of chunkedOperations) {
2859
+ const { results } = await branchTransaction({
2860
+ pathParams: {
2861
+ workspace: "{workspaceId}",
2862
+ dbBranchName: "{dbBranch}",
2863
+ region: "{region}"
2864
+ },
2865
+ body: { operations },
2866
+ ...__privateGet$4(this, _getFetchProps).call(this)
2867
+ });
2868
+ for (const result of results) {
2869
+ if (result.operation === "update") {
2870
+ ids.push(result.id);
2871
+ } else {
2872
+ ids.push(null);
2873
+ }
2874
+ }
2875
+ }
2876
+ return ids;
1581
2877
  };
1582
2878
  _upsertRecordWithID = new WeakSet();
1583
- upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1584
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2879
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
1585
2880
  const response = await upsertRecordWithID({
1586
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1587
- queryParams: { columns },
2881
+ pathParams: {
2882
+ workspace: "{workspaceId}",
2883
+ dbBranchName: "{dbBranch}",
2884
+ region: "{region}",
2885
+ tableName: __privateGet$4(this, _table),
2886
+ recordId
2887
+ },
2888
+ queryParams: { columns, ifVersion },
1588
2889
  body: object,
1589
- ...fetchProps
2890
+ ...__privateGet$4(this, _getFetchProps).call(this)
1590
2891
  });
1591
2892
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1592
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2893
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1593
2894
  };
1594
2895
  _deleteRecord = new WeakSet();
1595
- deleteRecord_fn = async function(recordId) {
1596
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1597
- await deleteRecord({
1598
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1599
- ...fetchProps
1600
- });
2896
+ deleteRecord_fn = async function(recordId, columns = ["*"]) {
2897
+ try {
2898
+ const response = await deleteRecord({
2899
+ pathParams: {
2900
+ workspace: "{workspaceId}",
2901
+ dbBranchName: "{dbBranch}",
2902
+ region: "{region}",
2903
+ tableName: __privateGet$4(this, _table),
2904
+ recordId
2905
+ },
2906
+ queryParams: { columns },
2907
+ ...__privateGet$4(this, _getFetchProps).call(this)
2908
+ });
2909
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2910
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2911
+ } catch (e) {
2912
+ if (isObject(e) && e.status === 404) {
2913
+ return null;
2914
+ }
2915
+ throw e;
2916
+ }
2917
+ };
2918
+ _deleteRecords = new WeakSet();
2919
+ deleteRecords_fn = async function(recordIds) {
2920
+ const chunkedOperations = chunk(
2921
+ recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
2922
+ BULK_OPERATION_MAX_SIZE
2923
+ );
2924
+ for (const operations of chunkedOperations) {
2925
+ await branchTransaction({
2926
+ pathParams: {
2927
+ workspace: "{workspaceId}",
2928
+ dbBranchName: "{dbBranch}",
2929
+ region: "{region}"
2930
+ },
2931
+ body: { operations },
2932
+ ...__privateGet$4(this, _getFetchProps).call(this)
2933
+ });
2934
+ }
1601
2935
  };
1602
2936
  _setCacheQuery = new WeakSet();
1603
2937
  setCacheQuery_fn = async function(query, meta, records) {
@@ -1619,10 +2953,9 @@ _getSchemaTables$1 = new WeakSet();
1619
2953
  getSchemaTables_fn$1 = async function() {
1620
2954
  if (__privateGet$4(this, _schemaTables$2))
1621
2955
  return __privateGet$4(this, _schemaTables$2);
1622
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1623
2956
  const { schema } = await getBranchDetails({
1624
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1625
- ...fetchProps
2957
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2958
+ ...__privateGet$4(this, _getFetchProps).call(this)
1626
2959
  });
1627
2960
  __privateSet$4(this, _schemaTables$2, schema.tables);
1628
2961
  return schema.tables;
@@ -1634,22 +2967,24 @@ const transformObjectLinks = (object) => {
1634
2967
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
1635
2968
  }, {});
1636
2969
  };
1637
- const initObject = (db, schemaTables, table, object) => {
1638
- const result = {};
2970
+ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2971
+ const data = {};
1639
2972
  const { xata, ...rest } = object ?? {};
1640
- Object.assign(result, rest);
2973
+ Object.assign(data, rest);
1641
2974
  const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
1642
2975
  if (!columns)
1643
2976
  console.error(`Table ${table} not found in schema`);
1644
2977
  for (const column of columns ?? []) {
1645
- const value = result[column.name];
2978
+ if (!isValidColumn(selectedColumns, column))
2979
+ continue;
2980
+ const value = data[column.name];
1646
2981
  switch (column.type) {
1647
2982
  case "datetime": {
1648
- const date = value !== void 0 ? new Date(value) : void 0;
1649
- if (date && isNaN(date.getTime())) {
2983
+ const date = value !== void 0 ? new Date(value) : null;
2984
+ if (date !== null && isNaN(date.getTime())) {
1650
2985
  console.error(`Failed to parse date ${value} for field ${column.name}`);
1651
- } else if (date) {
1652
- result[column.name] = date;
2986
+ } else {
2987
+ data[column.name] = date;
1653
2988
  }
1654
2989
  break;
1655
2990
  }
@@ -1658,32 +2993,85 @@ const initObject = (db, schemaTables, table, object) => {
1658
2993
  if (!linkTable) {
1659
2994
  console.error(`Failed to parse link for field ${column.name}`);
1660
2995
  } else if (isObject(value)) {
1661
- result[column.name] = initObject(db, schemaTables, linkTable, value);
2996
+ const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
2997
+ if (item === column.name) {
2998
+ return [...acc, "*"];
2999
+ }
3000
+ if (item.startsWith(`${column.name}.`)) {
3001
+ const [, ...path] = item.split(".");
3002
+ return [...acc, path.join(".")];
3003
+ }
3004
+ return acc;
3005
+ }, []);
3006
+ data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
3007
+ } else {
3008
+ data[column.name] = null;
1662
3009
  }
1663
3010
  break;
1664
3011
  }
3012
+ default:
3013
+ data[column.name] = value ?? null;
3014
+ if (column.notNull === true && value === null) {
3015
+ console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
3016
+ }
3017
+ break;
1665
3018
  }
1666
3019
  }
1667
- result.read = function(columns2) {
1668
- return db[table].read(result["id"], columns2);
3020
+ const record = { ...data };
3021
+ record.read = function(columns2) {
3022
+ return db[table].read(record["id"], columns2);
1669
3023
  };
1670
- result.update = function(data, columns2) {
1671
- return db[table].update(result["id"], data, columns2);
3024
+ record.update = function(data2, b, c) {
3025
+ const columns2 = isStringArray(b) ? b : ["*"];
3026
+ const ifVersion = parseIfVersion(b, c);
3027
+ return db[table].update(record["id"], data2, columns2, { ifVersion });
1672
3028
  };
1673
- result.delete = function() {
1674
- return db[table].delete(result["id"]);
3029
+ record.replace = function(data2, b, c) {
3030
+ const columns2 = isStringArray(b) ? b : ["*"];
3031
+ const ifVersion = parseIfVersion(b, c);
3032
+ return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
1675
3033
  };
1676
- result.getMetadata = function() {
3034
+ record.delete = function() {
3035
+ return db[table].delete(record["id"]);
3036
+ };
3037
+ record.getMetadata = function() {
1677
3038
  return xata;
1678
3039
  };
1679
- for (const prop of ["read", "update", "delete", "getMetadata"]) {
1680
- Object.defineProperty(result, prop, { enumerable: false });
3040
+ record.toSerializable = function() {
3041
+ return JSON.parse(JSON.stringify(transformObjectLinks(data)));
3042
+ };
3043
+ record.toString = function() {
3044
+ return JSON.stringify(transformObjectLinks(data));
3045
+ };
3046
+ for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
3047
+ Object.defineProperty(record, prop, { enumerable: false });
1681
3048
  }
1682
- Object.freeze(result);
1683
- return result;
3049
+ Object.freeze(record);
3050
+ return record;
1684
3051
  };
1685
- function isResponseWithRecords(value) {
1686
- return isObject(value) && Array.isArray(value.records);
3052
+ function extractId(value) {
3053
+ if (isString(value))
3054
+ return value;
3055
+ if (isObject(value) && isString(value.id))
3056
+ return value.id;
3057
+ return void 0;
3058
+ }
3059
+ function isValidColumn(columns, column) {
3060
+ if (columns.includes("*"))
3061
+ return true;
3062
+ if (column.type === "link") {
3063
+ const linkColumns = columns.filter((item) => item.startsWith(column.name));
3064
+ return linkColumns.length > 0;
3065
+ }
3066
+ return columns.includes(column.name);
3067
+ }
3068
+ function parseIfVersion(...args) {
3069
+ for (const arg of args) {
3070
+ if (isObject(arg) && isNumber(arg.ifVersion)) {
3071
+ return arg.ifVersion;
3072
+ }
3073
+ }
3074
+ return void 0;
1687
3075
  }
1688
3076
 
1689
3077
  var __accessCheck$3 = (obj, member, msg) => {
@@ -1735,18 +3123,25 @@ class SimpleCache {
1735
3123
  }
1736
3124
  _map = new WeakMap();
1737
3125
 
1738
- const gt = (value) => ({ $gt: value });
1739
- const ge = (value) => ({ $ge: value });
1740
- const gte = (value) => ({ $ge: value });
1741
- const lt = (value) => ({ $lt: value });
1742
- const lte = (value) => ({ $le: value });
1743
- const le = (value) => ({ $le: value });
3126
+ const greaterThan = (value) => ({ $gt: value });
3127
+ const gt = greaterThan;
3128
+ const greaterThanEquals = (value) => ({ $ge: value });
3129
+ const greaterEquals = greaterThanEquals;
3130
+ const gte = greaterThanEquals;
3131
+ const ge = greaterThanEquals;
3132
+ const lessThan = (value) => ({ $lt: value });
3133
+ const lt = lessThan;
3134
+ const lessThanEquals = (value) => ({ $le: value });
3135
+ const lessEquals = lessThanEquals;
3136
+ const lte = lessThanEquals;
3137
+ const le = lessThanEquals;
1744
3138
  const exists = (column) => ({ $exists: column });
1745
3139
  const notExists = (column) => ({ $notExists: column });
1746
3140
  const startsWith = (value) => ({ $startsWith: value });
1747
3141
  const endsWith = (value) => ({ $endsWith: value });
1748
3142
  const pattern = (value) => ({ $pattern: value });
1749
3143
  const is = (value) => ({ $is: value });
3144
+ const equals = is;
1750
3145
  const isNot = (value) => ({ $isNot: value });
1751
3146
  const contains = (value) => ({ $contains: value });
1752
3147
  const includes = (value) => ({ $includes: value });
@@ -1836,23 +3231,23 @@ class SearchPlugin extends XataPlugin {
1836
3231
  __privateAdd$1(this, _schemaTables, void 0);
1837
3232
  __privateSet$1(this, _schemaTables, schemaTables);
1838
3233
  }
1839
- build({ getFetchProps }) {
3234
+ build(pluginOptions) {
1840
3235
  return {
1841
3236
  all: async (query, options = {}) => {
1842
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
1843
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
3237
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
3238
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
1844
3239
  return records.map((record) => {
1845
3240
  const { table = "orphan" } = record.xata;
1846
- return { table, record: initObject(this.db, schemaTables, table, record) };
3241
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
1847
3242
  });
1848
3243
  },
1849
3244
  byTable: async (query, options = {}) => {
1850
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
1851
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
3245
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
3246
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
1852
3247
  return records.reduce((acc, record) => {
1853
3248
  const { table = "orphan" } = record.xata;
1854
3249
  const items = acc[table] ?? [];
1855
- const item = initObject(this.db, schemaTables, table, record);
3250
+ const item = initObject(this.db, schemaTables, table, record, ["*"]);
1856
3251
  return { ...acc, [table]: [...items, item] };
1857
3252
  }, {});
1858
3253
  }
@@ -1861,106 +3256,39 @@ class SearchPlugin extends XataPlugin {
1861
3256
  }
1862
3257
  _schemaTables = new WeakMap();
1863
3258
  _search = new WeakSet();
1864
- search_fn = async function(query, options, getFetchProps) {
1865
- const fetchProps = await getFetchProps();
1866
- const { tables, fuzziness, highlight, prefix } = options ?? {};
3259
+ search_fn = async function(query, options, pluginOptions) {
3260
+ const { tables, fuzziness, highlight, prefix, page } = options ?? {};
1867
3261
  const { records } = await searchBranch({
1868
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1869
- body: { tables, query, fuzziness, prefix, highlight },
1870
- ...fetchProps
3262
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3263
+ body: { tables, query, fuzziness, prefix, highlight, page },
3264
+ ...pluginOptions
1871
3265
  });
1872
3266
  return records;
1873
3267
  };
1874
3268
  _getSchemaTables = new WeakSet();
1875
- getSchemaTables_fn = async function(getFetchProps) {
3269
+ getSchemaTables_fn = async function(pluginOptions) {
1876
3270
  if (__privateGet$1(this, _schemaTables))
1877
3271
  return __privateGet$1(this, _schemaTables);
1878
- const fetchProps = await getFetchProps();
1879
3272
  const { schema } = await getBranchDetails({
1880
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1881
- ...fetchProps
3273
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3274
+ ...pluginOptions
1882
3275
  });
1883
3276
  __privateSet$1(this, _schemaTables, schema.tables);
1884
3277
  return schema.tables;
1885
3278
  };
1886
3279
 
1887
- const isBranchStrategyBuilder = (strategy) => {
1888
- return typeof strategy === "function";
1889
- };
1890
-
1891
- async function getCurrentBranchName(options) {
1892
- const { branch, envBranch } = getEnvironment();
1893
- if (branch) {
1894
- const details = await getDatabaseBranch(branch, options);
1895
- if (details)
1896
- return branch;
1897
- console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
1898
- }
1899
- const gitBranch = envBranch || await getGitBranch();
1900
- return resolveXataBranch(gitBranch, options);
1901
- }
1902
- async function getCurrentBranchDetails(options) {
1903
- const branch = await getCurrentBranchName(options);
1904
- return getDatabaseBranch(branch, options);
1905
- }
1906
- async function resolveXataBranch(gitBranch, options) {
1907
- const databaseURL = options?.databaseURL || getDatabaseURL();
1908
- const apiKey = options?.apiKey || getAPIKey();
1909
- if (!databaseURL)
1910
- throw new Error(
1911
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
1912
- );
1913
- if (!apiKey)
1914
- throw new Error(
1915
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
1916
- );
1917
- const [protocol, , host, , dbName] = databaseURL.split("/");
1918
- const [workspace] = host.split(".");
1919
- const { fallbackBranch } = getEnvironment();
1920
- const { branch } = await resolveBranch({
1921
- apiKey,
1922
- apiUrl: databaseURL,
1923
- fetchImpl: getFetchImplementation(options?.fetchImpl),
1924
- workspacesApiUrl: `${protocol}//${host}`,
1925
- pathParams: { dbName, workspace },
1926
- queryParams: { gitBranch, fallbackBranch }
1927
- });
1928
- return branch;
1929
- }
1930
- async function getDatabaseBranch(branch, options) {
1931
- const databaseURL = options?.databaseURL || getDatabaseURL();
1932
- const apiKey = options?.apiKey || getAPIKey();
1933
- if (!databaseURL)
1934
- throw new Error(
1935
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
1936
- );
1937
- if (!apiKey)
1938
- throw new Error(
1939
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
1940
- );
1941
- const [protocol, , host, , database] = databaseURL.split("/");
1942
- const [workspace] = host.split(".");
1943
- const dbBranchName = `${database}:${branch}`;
1944
- try {
1945
- return await getBranchDetails({
1946
- apiKey,
1947
- apiUrl: databaseURL,
1948
- fetchImpl: getFetchImplementation(options?.fetchImpl),
1949
- workspacesApiUrl: `${protocol}//${host}`,
1950
- pathParams: { dbBranchName, workspace }
1951
- });
1952
- } catch (err) {
1953
- if (isObject(err) && err.status === 404)
1954
- return null;
1955
- throw err;
1956
- }
1957
- }
1958
- function getDatabaseURL() {
1959
- try {
1960
- const { databaseURL } = getEnvironment();
1961
- return databaseURL;
1962
- } catch (err) {
1963
- return void 0;
3280
+ class TransactionPlugin extends XataPlugin {
3281
+ build(pluginOptions) {
3282
+ return {
3283
+ run: async (operations) => {
3284
+ const response = await branchTransaction({
3285
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3286
+ body: { operations },
3287
+ ...pluginOptions
3288
+ });
3289
+ return response;
3290
+ }
3291
+ };
1964
3292
  }
1965
3293
  }
1966
3294
 
@@ -1987,24 +3315,24 @@ var __privateMethod = (obj, member, method) => {
1987
3315
  return method;
1988
3316
  };
1989
3317
  const buildClient = (plugins) => {
1990
- var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
3318
+ var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
1991
3319
  return _a = class {
1992
3320
  constructor(options = {}, schemaTables) {
1993
3321
  __privateAdd(this, _parseOptions);
1994
3322
  __privateAdd(this, _getFetchProps);
1995
- __privateAdd(this, _evaluateBranch);
1996
- __privateAdd(this, _branch, void 0);
1997
3323
  __privateAdd(this, _options, void 0);
1998
3324
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
1999
3325
  __privateSet(this, _options, safeOptions);
2000
3326
  const pluginOptions = {
2001
- getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
3327
+ ...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
2002
3328
  cache: safeOptions.cache
2003
3329
  };
2004
3330
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
2005
3331
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
3332
+ const transactions = new TransactionPlugin().build(pluginOptions);
2006
3333
  this.db = db;
2007
3334
  this.search = search;
3335
+ this.transactions = transactions;
2008
3336
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
2009
3337
  if (namespace === void 0)
2010
3338
  continue;
@@ -2020,49 +3348,69 @@ const buildClient = (plugins) => {
2020
3348
  }
2021
3349
  async getConfig() {
2022
3350
  const databaseURL = __privateGet(this, _options).databaseURL;
2023
- const branch = await __privateGet(this, _options).branch();
3351
+ const branch = __privateGet(this, _options).branch;
2024
3352
  return { databaseURL, branch };
2025
3353
  }
2026
- }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
3354
+ }, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
3355
+ const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
3356
+ const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
3357
+ if (isBrowser && !enableBrowser) {
3358
+ throw new Error(
3359
+ "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."
3360
+ );
3361
+ }
2027
3362
  const fetch = getFetchImplementation(options?.fetch);
2028
3363
  const databaseURL = options?.databaseURL || getDatabaseURL();
3364
+ const branch = options?.branch || getBranch() || "main";
2029
3365
  const apiKey = options?.apiKey || getAPIKey();
2030
3366
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
2031
- const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
2032
- if (!databaseURL || !apiKey) {
2033
- throw new Error("Options databaseURL and apiKey are required");
3367
+ const trace = options?.trace ?? defaultTrace;
3368
+ const clientName = options?.clientName;
3369
+ const host = options?.host ?? "production";
3370
+ const xataAgentExtra = options?.xataAgentExtra;
3371
+ if (!apiKey) {
3372
+ throw new Error("Option apiKey is required");
2034
3373
  }
2035
- return { fetch, databaseURL, apiKey, branch, cache };
2036
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch }) {
2037
- const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2038
- if (!branchValue)
2039
- throw new Error("Unable to resolve branch value");
3374
+ if (!databaseURL) {
3375
+ throw new Error("Option databaseURL is required");
3376
+ }
3377
+ return {
3378
+ fetch,
3379
+ databaseURL,
3380
+ apiKey,
3381
+ branch,
3382
+ cache,
3383
+ trace,
3384
+ host,
3385
+ clientID: generateUUID(),
3386
+ enableBrowser,
3387
+ clientName,
3388
+ xataAgentExtra
3389
+ };
3390
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
3391
+ fetch,
3392
+ apiKey,
3393
+ databaseURL,
3394
+ branch,
3395
+ trace,
3396
+ clientID,
3397
+ clientName,
3398
+ xataAgentExtra
3399
+ }) {
2040
3400
  return {
2041
- fetchImpl: fetch,
3401
+ fetch,
2042
3402
  apiKey,
2043
3403
  apiUrl: "",
2044
3404
  workspacesApiUrl: (path, params) => {
2045
3405
  const hasBranch = params.dbBranchName ?? params.branch;
2046
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
3406
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
2047
3407
  return databaseURL + newPath;
2048
- }
2049
- };
2050
- }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2051
- if (__privateGet(this, _branch))
2052
- return __privateGet(this, _branch);
2053
- if (param === void 0)
2054
- return void 0;
2055
- const strategies = Array.isArray(param) ? [...param] : [param];
2056
- const evaluateBranch = async (strategy) => {
2057
- return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
3408
+ },
3409
+ trace,
3410
+ clientID,
3411
+ clientName,
3412
+ xataAgentExtra
2058
3413
  };
2059
- for await (const strategy of strategies) {
2060
- const branch = await evaluateBranch(strategy);
2061
- if (branch) {
2062
- __privateSet(this, _branch, branch);
2063
- return branch;
2064
- }
2065
- }
2066
3414
  }, _a;
2067
3415
  };
2068
3416
  class BaseClient extends buildClient() {
@@ -2136,7 +3484,7 @@ const deserialize = (json) => {
2136
3484
  };
2137
3485
 
2138
3486
  function buildWorkerRunner(config) {
2139
- return function xataWorker(name, _worker) {
3487
+ return function xataWorker(name, worker) {
2140
3488
  return async (...args) => {
2141
3489
  const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
2142
3490
  const result = await fetch(url, {
@@ -2157,5 +3505,5 @@ class XataError extends Error {
2157
3505
  }
2158
3506
  }
2159
3507
 
2160
- export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
3508
+ export { BaseClient, FetcherError, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, askTable, branchTransaction, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
2161
3509
  //# sourceMappingURL=index.mjs.map