@xata.io/client 0.0.0-alpha.vf603f80 → 0.0.0-alpha.vf672652

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