@xata.io/client 0.0.0-alpha.vf8b33c9 → 0.0.0-alpha.vf8f3b02

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -38,6 +38,9 @@ function isString(value) {
38
38
  function isStringArray(value) {
39
39
  return isDefined(value) && Array.isArray(value) && value.every(isString);
40
40
  }
41
+ function isNumber(value) {
42
+ return isDefined(value) && typeof value === "number";
43
+ }
41
44
  function toBase64(value) {
42
45
  try {
43
46
  return btoa(value);
@@ -46,6 +49,17 @@ function toBase64(value) {
46
49
  return buf.from(value).toString("base64");
47
50
  }
48
51
  }
52
+ function deepMerge(a, b) {
53
+ const result = { ...a };
54
+ for (const [key, value] of Object.entries(b)) {
55
+ if (isObject(value) && isObject(result[key])) {
56
+ result[key] = deepMerge(result[key], value);
57
+ } else {
58
+ result[key] = value;
59
+ }
60
+ }
61
+ return result;
62
+ }
49
63
 
50
64
  function getEnvironment() {
51
65
  try {
@@ -80,6 +94,25 @@ function getEnvironment() {
80
94
  fallbackBranch: getGlobalFallbackBranch()
81
95
  };
82
96
  }
97
+ function getEnableBrowserVariable() {
98
+ try {
99
+ if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
100
+ return process.env.XATA_ENABLE_BROWSER === "true";
101
+ }
102
+ } catch (err) {
103
+ }
104
+ try {
105
+ if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
106
+ return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
107
+ }
108
+ } catch (err) {
109
+ }
110
+ try {
111
+ return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
112
+ } catch (err) {
113
+ return void 0;
114
+ }
115
+ }
83
116
  function getGlobalApiKey() {
84
117
  try {
85
118
  return XATA_API_KEY;
@@ -150,7 +183,7 @@ function getFetchImplementation(userFetch) {
150
183
  return fetchImpl;
151
184
  }
152
185
 
153
- const VERSION = "0.0.0-alpha.vf8b33c9";
186
+ const VERSION = "0.0.0-alpha.vf8f3b02";
154
187
 
155
188
  class ErrorWithCause extends Error {
156
189
  constructor(message, options) {
@@ -207,15 +240,18 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
207
240
  return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
208
241
  };
209
242
  function buildBaseUrl({
243
+ endpoint,
210
244
  path,
211
245
  workspacesApiUrl,
212
246
  apiUrl,
213
- pathParams
247
+ pathParams = {}
214
248
  }) {
215
- if (pathParams?.workspace === void 0)
216
- return `${apiUrl}${path}`;
217
- const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
218
- return url.replace("{workspaceId}", String(pathParams.workspace));
249
+ if (endpoint === "dataPlane") {
250
+ const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
251
+ const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
252
+ return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
253
+ }
254
+ return `${apiUrl}${path}`;
219
255
  }
220
256
  function hostHeader(url) {
221
257
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
@@ -231,14 +267,19 @@ async function fetch$1({
231
267
  queryParams,
232
268
  fetchImpl,
233
269
  apiKey,
270
+ endpoint,
234
271
  apiUrl,
235
272
  workspacesApiUrl,
236
- trace
273
+ trace,
274
+ signal,
275
+ clientID,
276
+ sessionID,
277
+ fetchOptions = {}
237
278
  }) {
238
279
  return trace(
239
280
  `${method.toUpperCase()} ${path}`,
240
281
  async ({ setAttributes }) => {
241
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
282
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
242
283
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
243
284
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
244
285
  setAttributes({
@@ -246,15 +287,19 @@ async function fetch$1({
246
287
  [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
247
288
  });
248
289
  const response = await fetchImpl(url, {
290
+ ...fetchOptions,
249
291
  method: method.toUpperCase(),
250
292
  body: body ? JSON.stringify(body) : void 0,
251
293
  headers: {
252
294
  "Content-Type": "application/json",
253
295
  "User-Agent": `Xata client-ts/${VERSION}`,
296
+ "X-Xata-Client-ID": clientID ?? "",
297
+ "X-Xata-Session-ID": sessionID ?? "",
254
298
  ...headers,
255
299
  ...hostHeader(fullUrl),
256
300
  Authorization: `Bearer ${apiKey}`
257
- }
301
+ },
302
+ signal
258
303
  });
259
304
  if (response.status === 204) {
260
305
  return {};
@@ -290,273 +335,163 @@ function parseUrl(url) {
290
335
  }
291
336
  }
292
337
 
293
- const getUser = (variables) => fetch$1({ url: "/user", method: "get", ...variables });
294
- const updateUser = (variables) => fetch$1({ url: "/user", method: "put", ...variables });
295
- const deleteUser = (variables) => fetch$1({ url: "/user", method: "delete", ...variables });
296
- const getUserAPIKeys = (variables) => fetch$1({
297
- url: "/user/keys",
298
- method: "get",
299
- ...variables
300
- });
301
- const createUserAPIKey = (variables) => fetch$1({
302
- url: "/user/keys/{keyName}",
303
- method: "post",
304
- ...variables
305
- });
306
- const deleteUserAPIKey = (variables) => fetch$1({
307
- url: "/user/keys/{keyName}",
308
- method: "delete",
309
- ...variables
310
- });
311
- const createWorkspace = (variables) => fetch$1({
312
- url: "/workspaces",
313
- method: "post",
314
- ...variables
315
- });
316
- const getWorkspacesList = (variables) => fetch$1({
317
- url: "/workspaces",
318
- method: "get",
319
- ...variables
320
- });
321
- const getWorkspace = (variables) => fetch$1({
322
- url: "/workspaces/{workspaceId}",
323
- method: "get",
324
- ...variables
325
- });
326
- const updateWorkspace = (variables) => fetch$1({
327
- url: "/workspaces/{workspaceId}",
328
- method: "put",
329
- ...variables
330
- });
331
- const deleteWorkspace = (variables) => fetch$1({
332
- url: "/workspaces/{workspaceId}",
333
- method: "delete",
334
- ...variables
335
- });
336
- const getWorkspaceMembersList = (variables) => fetch$1({
337
- url: "/workspaces/{workspaceId}/members",
338
- method: "get",
339
- ...variables
340
- });
341
- const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
342
- const removeWorkspaceMember = (variables) => fetch$1({
343
- url: "/workspaces/{workspaceId}/members/{userId}",
344
- method: "delete",
345
- ...variables
346
- });
347
- const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
348
- const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
349
- const cancelWorkspaceMemberInvite = (variables) => fetch$1({
350
- url: "/workspaces/{workspaceId}/invites/{inviteId}",
351
- method: "delete",
352
- ...variables
353
- });
354
- const resendWorkspaceMemberInvite = (variables) => fetch$1({
355
- url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
356
- method: "post",
357
- ...variables
358
- });
359
- const acceptWorkspaceMemberInvite = (variables) => fetch$1({
360
- url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
361
- method: "post",
362
- ...variables
363
- });
364
- const getDatabaseList = (variables) => fetch$1({
365
- url: "/dbs",
366
- method: "get",
367
- ...variables
368
- });
369
- const getBranchList = (variables) => fetch$1({
370
- url: "/dbs/{dbName}",
371
- method: "get",
372
- ...variables
373
- });
374
- const createDatabase = (variables) => fetch$1({
375
- url: "/dbs/{dbName}",
376
- method: "put",
377
- ...variables
378
- });
379
- const deleteDatabase = (variables) => fetch$1({
338
+ const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
339
+
340
+ const dEPRECATEDgetDatabaseList = (variables, signal) => dataPlaneFetch({ url: "/dbs", method: "get", ...variables, signal });
341
+ const getBranchList = (variables, signal) => dataPlaneFetch({
380
342
  url: "/dbs/{dbName}",
381
- method: "delete",
382
- ...variables
383
- });
384
- const getDatabaseMetadata = (variables) => fetch$1({
385
- url: "/dbs/{dbName}/metadata",
386
- method: "get",
387
- ...variables
388
- });
389
- const updateDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
390
- const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
391
- const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
392
- const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
393
- const resolveBranch = (variables) => fetch$1({
394
- url: "/dbs/{dbName}/resolveBranch",
395
- method: "get",
396
- ...variables
397
- });
398
- const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
399
- const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
400
- const getMigrationRequest = (variables) => fetch$1({
401
- url: "/dbs/{dbName}/migrations/{mrNumber}",
402
343
  method: "get",
403
- ...variables
404
- });
405
- const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
406
- const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
407
- const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
408
- const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
409
- const mergeMigrationRequest = (variables) => fetch$1({
410
- url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
411
- method: "post",
412
- ...variables
344
+ ...variables,
345
+ signal
413
346
  });
414
- const getBranchDetails = (variables) => fetch$1({
347
+ const dEPRECATEDcreateDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
348
+ const dEPRECATEDdeleteDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "delete", ...variables, signal });
349
+ const dEPRECATEDgetDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "get", ...variables, signal });
350
+ const dEPRECATEDupdateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
351
+ const getBranchDetails = (variables, signal) => dataPlaneFetch({
415
352
  url: "/db/{dbBranchName}",
416
353
  method: "get",
417
- ...variables
354
+ ...variables,
355
+ signal
418
356
  });
419
- const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
420
- const deleteBranch = (variables) => fetch$1({
357
+ const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
358
+ const deleteBranch = (variables, signal) => dataPlaneFetch({
421
359
  url: "/db/{dbBranchName}",
422
360
  method: "delete",
423
- ...variables
361
+ ...variables,
362
+ signal
424
363
  });
425
- const updateBranchMetadata = (variables) => fetch$1({
364
+ const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
426
365
  url: "/db/{dbBranchName}/metadata",
427
366
  method: "put",
428
- ...variables
367
+ ...variables,
368
+ signal
429
369
  });
430
- const getBranchMetadata = (variables) => fetch$1({
370
+ const getBranchMetadata = (variables, signal) => dataPlaneFetch({
431
371
  url: "/db/{dbBranchName}/metadata",
432
372
  method: "get",
433
- ...variables
373
+ ...variables,
374
+ signal
434
375
  });
435
- const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
436
- const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
437
- const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
438
- const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
439
- const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
440
- const updateBranchSchema = (variables) => fetch$1({
441
- url: "/db/{dbBranchName}/schema/update",
442
- method: "post",
443
- ...variables
444
- });
445
- const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
446
- const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
447
- const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
448
- const getBranchStats = (variables) => fetch$1({
376
+ const getBranchStats = (variables, signal) => dataPlaneFetch({
449
377
  url: "/db/{dbBranchName}/stats",
450
378
  method: "get",
451
- ...variables
379
+ ...variables,
380
+ signal
452
381
  });
453
- const createTable = (variables) => fetch$1({
382
+ const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
383
+ const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
384
+ const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
385
+ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
386
+ const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
387
+ const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
388
+ const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
389
+ const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
390
+ const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
391
+ const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
392
+ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
393
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
394
+ method: "get",
395
+ ...variables,
396
+ signal
397
+ });
398
+ const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
399
+ const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
400
+ const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
401
+ const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
402
+ const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
403
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
404
+ method: "post",
405
+ ...variables,
406
+ signal
407
+ });
408
+ const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
409
+ const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
410
+ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
411
+ const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
412
+ const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
413
+ const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
414
+ const createTable = (variables, signal) => dataPlaneFetch({
454
415
  url: "/db/{dbBranchName}/tables/{tableName}",
455
416
  method: "put",
456
- ...variables
417
+ ...variables,
418
+ signal
457
419
  });
458
- const deleteTable = (variables) => fetch$1({
420
+ const deleteTable = (variables, signal) => dataPlaneFetch({
459
421
  url: "/db/{dbBranchName}/tables/{tableName}",
460
422
  method: "delete",
461
- ...variables
462
- });
463
- const updateTable = (variables) => fetch$1({
464
- url: "/db/{dbBranchName}/tables/{tableName}",
465
- method: "patch",
466
- ...variables
423
+ ...variables,
424
+ signal
467
425
  });
468
- const getTableSchema = (variables) => fetch$1({
426
+ const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
427
+ const getTableSchema = (variables, signal) => dataPlaneFetch({
469
428
  url: "/db/{dbBranchName}/tables/{tableName}/schema",
470
429
  method: "get",
471
- ...variables
430
+ ...variables,
431
+ signal
472
432
  });
473
- const setTableSchema = (variables) => fetch$1({
474
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
475
- method: "put",
476
- ...variables
477
- });
478
- const getTableColumns = (variables) => fetch$1({
433
+ const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
434
+ const getTableColumns = (variables, signal) => dataPlaneFetch({
479
435
  url: "/db/{dbBranchName}/tables/{tableName}/columns",
480
436
  method: "get",
481
- ...variables
482
- });
483
- const addTableColumn = (variables) => fetch$1({
484
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
485
- method: "post",
486
- ...variables
437
+ ...variables,
438
+ signal
487
439
  });
488
- const getColumn = (variables) => fetch$1({
440
+ const addTableColumn = (variables, signal) => dataPlaneFetch(
441
+ { url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
442
+ );
443
+ const getColumn = (variables, signal) => dataPlaneFetch({
489
444
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
490
445
  method: "get",
491
- ...variables
446
+ ...variables,
447
+ signal
492
448
  });
493
- const deleteColumn = (variables) => fetch$1({
449
+ const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
450
+ const deleteColumn = (variables, signal) => dataPlaneFetch({
494
451
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
495
452
  method: "delete",
496
- ...variables
497
- });
498
- const updateColumn = (variables) => fetch$1({
499
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
500
- method: "patch",
501
- ...variables
502
- });
503
- const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
504
- const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
505
- const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
506
- const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
507
- const deleteRecord = (variables) => fetch$1({
508
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
509
- method: "delete",
510
- ...variables
453
+ ...variables,
454
+ signal
511
455
  });
512
- const getRecord = (variables) => fetch$1({
456
+ const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
457
+ const getRecord = (variables, signal) => dataPlaneFetch({
513
458
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
514
459
  method: "get",
515
- ...variables
460
+ ...variables,
461
+ signal
516
462
  });
517
- const bulkInsertTableRecords = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables });
518
- const queryTable = (variables) => fetch$1({
463
+ const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
464
+ const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
465
+ const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
466
+ const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
467
+ const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
468
+ const queryTable = (variables, signal) => dataPlaneFetch({
519
469
  url: "/db/{dbBranchName}/tables/{tableName}/query",
520
470
  method: "post",
521
- ...variables
471
+ ...variables,
472
+ signal
522
473
  });
523
- const searchTable = (variables) => fetch$1({
524
- url: "/db/{dbBranchName}/tables/{tableName}/search",
474
+ const searchBranch = (variables, signal) => dataPlaneFetch({
475
+ url: "/db/{dbBranchName}/search",
525
476
  method: "post",
526
- ...variables
477
+ ...variables,
478
+ signal
527
479
  });
528
- const searchBranch = (variables) => fetch$1({
529
- url: "/db/{dbBranchName}/search",
480
+ const searchTable = (variables, signal) => dataPlaneFetch({
481
+ url: "/db/{dbBranchName}/tables/{tableName}/search",
530
482
  method: "post",
531
- ...variables
483
+ ...variables,
484
+ signal
532
485
  });
533
- const operationsByTag = {
534
- users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
535
- workspaces: {
536
- createWorkspace,
537
- getWorkspacesList,
538
- getWorkspace,
539
- updateWorkspace,
540
- deleteWorkspace,
541
- getWorkspaceMembersList,
542
- updateWorkspaceMemberRole,
543
- removeWorkspaceMember,
544
- inviteWorkspaceMember,
545
- updateWorkspaceMemberInvite,
546
- cancelWorkspaceMemberInvite,
547
- resendWorkspaceMemberInvite,
548
- acceptWorkspaceMemberInvite
549
- },
486
+ const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
487
+ const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
488
+ const operationsByTag$2 = {
550
489
  database: {
551
- getDatabaseList,
552
- createDatabase,
553
- deleteDatabase,
554
- getDatabaseMetadata,
555
- updateDatabaseMetadata,
556
- getGitBranchesMapping,
557
- addGitBranchesEntry,
558
- removeGitBranchesEntry,
559
- resolveBranch
490
+ dEPRECATEDgetDatabaseList,
491
+ dEPRECATEDcreateDatabase,
492
+ dEPRECATEDdeleteDatabase,
493
+ dEPRECATEDgetDatabaseMetadata,
494
+ dEPRECATEDupdateDatabaseMetadata
560
495
  },
561
496
  branch: {
562
497
  getBranchList,
@@ -565,10 +500,35 @@ const operationsByTag = {
565
500
  deleteBranch,
566
501
  updateBranchMetadata,
567
502
  getBranchMetadata,
568
- getBranchStats
503
+ getBranchStats,
504
+ getGitBranchesMapping,
505
+ addGitBranchesEntry,
506
+ removeGitBranchesEntry,
507
+ resolveBranch
508
+ },
509
+ migrations: {
510
+ getBranchMigrationHistory,
511
+ getBranchMigrationPlan,
512
+ executeBranchMigrationPlan,
513
+ getBranchSchemaHistory,
514
+ compareBranchWithUserSchema,
515
+ compareBranchSchemas,
516
+ updateBranchSchema,
517
+ previewBranchSchemaEdit,
518
+ applyBranchSchemaEdit
519
+ },
520
+ records: {
521
+ branchTransaction,
522
+ insertRecord,
523
+ getRecord,
524
+ insertRecordWithID,
525
+ updateRecordWithID,
526
+ upsertRecordWithID,
527
+ deleteRecord,
528
+ bulkInsertTableRecords
569
529
  },
570
530
  migrationRequests: {
571
- listMigrationRequests,
531
+ queryMigrationRequests,
572
532
  createMigrationRequest,
573
533
  getMigrationRequest,
574
534
  updateMigrationRequest,
@@ -577,17 +537,6 @@ const operationsByTag = {
577
537
  getMigrationRequestIsMerged,
578
538
  mergeMigrationRequest
579
539
  },
580
- branchSchema: {
581
- getBranchMigrationHistory,
582
- executeBranchMigrationPlan,
583
- getBranchMigrationPlan,
584
- compareBranchWithUserSchema,
585
- compareBranchSchemas,
586
- updateBranchSchema,
587
- previewBranchSchemaEdit,
588
- applyBranchSchemaEdit,
589
- getBranchSchemaHistory
590
- },
591
540
  table: {
592
541
  createTable,
593
542
  deleteTable,
@@ -597,23 +546,146 @@ const operationsByTag = {
597
546
  getTableColumns,
598
547
  addTableColumn,
599
548
  getColumn,
600
- deleteColumn,
601
- updateColumn
549
+ updateColumn,
550
+ deleteColumn
602
551
  },
603
- records: {
604
- insertRecord,
605
- insertRecordWithID,
606
- updateRecordWithID,
607
- upsertRecordWithID,
608
- deleteRecord,
609
- getRecord,
610
- bulkInsertTableRecords,
611
- queryTable,
612
- searchTable,
613
- searchBranch
552
+ searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
553
+ };
554
+
555
+ const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
556
+
557
+ const getUser = (variables, signal) => controlPlaneFetch({
558
+ url: "/user",
559
+ method: "get",
560
+ ...variables,
561
+ signal
562
+ });
563
+ const updateUser = (variables, signal) => controlPlaneFetch({
564
+ url: "/user",
565
+ method: "put",
566
+ ...variables,
567
+ signal
568
+ });
569
+ const deleteUser = (variables, signal) => controlPlaneFetch({
570
+ url: "/user",
571
+ method: "delete",
572
+ ...variables,
573
+ signal
574
+ });
575
+ const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
576
+ url: "/user/keys",
577
+ method: "get",
578
+ ...variables,
579
+ signal
580
+ });
581
+ const createUserAPIKey = (variables, signal) => controlPlaneFetch({
582
+ url: "/user/keys/{keyName}",
583
+ method: "post",
584
+ ...variables,
585
+ signal
586
+ });
587
+ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
588
+ url: "/user/keys/{keyName}",
589
+ method: "delete",
590
+ ...variables,
591
+ signal
592
+ });
593
+ const getWorkspacesList = (variables, signal) => controlPlaneFetch({
594
+ url: "/workspaces",
595
+ method: "get",
596
+ ...variables,
597
+ signal
598
+ });
599
+ const createWorkspace = (variables, signal) => controlPlaneFetch({
600
+ url: "/workspaces",
601
+ method: "post",
602
+ ...variables,
603
+ signal
604
+ });
605
+ const getWorkspace = (variables, signal) => controlPlaneFetch({
606
+ url: "/workspaces/{workspaceId}",
607
+ method: "get",
608
+ ...variables,
609
+ signal
610
+ });
611
+ const updateWorkspace = (variables, signal) => controlPlaneFetch({
612
+ url: "/workspaces/{workspaceId}",
613
+ method: "put",
614
+ ...variables,
615
+ signal
616
+ });
617
+ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
618
+ url: "/workspaces/{workspaceId}",
619
+ method: "delete",
620
+ ...variables,
621
+ signal
622
+ });
623
+ const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
624
+ const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
625
+ const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
626
+ url: "/workspaces/{workspaceId}/members/{userId}",
627
+ method: "delete",
628
+ ...variables,
629
+ signal
630
+ });
631
+ const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
632
+ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
633
+ const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
634
+ const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
635
+ const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
636
+ const getDatabaseList = (variables, signal) => controlPlaneFetch({
637
+ url: "/workspaces/{workspaceId}/dbs",
638
+ method: "get",
639
+ ...variables,
640
+ signal
641
+ });
642
+ const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
643
+ const deleteDatabase = (variables, signal) => controlPlaneFetch({
644
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
645
+ method: "delete",
646
+ ...variables,
647
+ signal
648
+ });
649
+ const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
650
+ const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
651
+ const listRegions = (variables, signal) => controlPlaneFetch({
652
+ url: "/workspaces/{workspaceId}/regions",
653
+ method: "get",
654
+ ...variables,
655
+ signal
656
+ });
657
+ const operationsByTag$1 = {
658
+ users: { getUser, updateUser, deleteUser },
659
+ authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
660
+ workspaces: {
661
+ getWorkspacesList,
662
+ createWorkspace,
663
+ getWorkspace,
664
+ updateWorkspace,
665
+ deleteWorkspace,
666
+ getWorkspaceMembersList,
667
+ updateWorkspaceMemberRole,
668
+ removeWorkspaceMember
669
+ },
670
+ invites: {
671
+ inviteWorkspaceMember,
672
+ updateWorkspaceMemberInvite,
673
+ cancelWorkspaceMemberInvite,
674
+ acceptWorkspaceMemberInvite,
675
+ resendWorkspaceMemberInvite
676
+ },
677
+ databases: {
678
+ getDatabaseList,
679
+ createDatabase,
680
+ deleteDatabase,
681
+ getDatabaseMetadata,
682
+ updateDatabaseMetadata,
683
+ listRegions
614
684
  }
615
685
  };
616
686
 
687
+ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
688
+
617
689
  function getHostUrl(provider, type) {
618
690
  if (isHostProviderAlias(provider)) {
619
691
  return providers[provider][type];
@@ -625,11 +697,11 @@ function getHostUrl(provider, type) {
625
697
  const providers = {
626
698
  production: {
627
699
  main: "https://api.xata.io",
628
- workspaces: "https://{workspaceId}.xata.sh"
700
+ workspaces: "https://{workspaceId}.{region}.xata.sh"
629
701
  },
630
702
  staging: {
631
703
  main: "https://staging.xatabase.co",
632
- workspaces: "https://{workspaceId}.staging.xatabase.co"
704
+ workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
633
705
  }
634
706
  };
635
707
  function isHostProviderAlias(alias) {
@@ -638,6 +710,25 @@ function isHostProviderAlias(alias) {
638
710
  function isHostProviderBuilder(builder) {
639
711
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
640
712
  }
713
+ function parseProviderString(provider = "production") {
714
+ if (isHostProviderAlias(provider)) {
715
+ return provider;
716
+ }
717
+ const [main, workspaces] = provider.split(",");
718
+ if (!main || !workspaces)
719
+ return null;
720
+ return { main, workspaces };
721
+ }
722
+ function parseWorkspacesUrlParts(url) {
723
+ if (!isString(url))
724
+ return null;
725
+ const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
726
+ const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
727
+ const match = url.match(regex) || url.match(regexStaging);
728
+ if (!match)
729
+ return null;
730
+ return { workspace: match[1], region: match[2] ?? "eu-west-1" };
731
+ }
641
732
 
642
733
  var __accessCheck$7 = (obj, member, msg) => {
643
734
  if (!member.has(obj))
@@ -681,21 +772,41 @@ class XataApiClient {
681
772
  __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
682
773
  return __privateGet$7(this, _namespaces).user;
683
774
  }
775
+ get authentication() {
776
+ if (!__privateGet$7(this, _namespaces).authentication)
777
+ __privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
778
+ return __privateGet$7(this, _namespaces).authentication;
779
+ }
684
780
  get workspaces() {
685
781
  if (!__privateGet$7(this, _namespaces).workspaces)
686
782
  __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
687
783
  return __privateGet$7(this, _namespaces).workspaces;
688
784
  }
689
- get databases() {
690
- if (!__privateGet$7(this, _namespaces).databases)
691
- __privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
692
- return __privateGet$7(this, _namespaces).databases;
785
+ get invites() {
786
+ if (!__privateGet$7(this, _namespaces).invites)
787
+ __privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
788
+ return __privateGet$7(this, _namespaces).invites;
789
+ }
790
+ get database() {
791
+ if (!__privateGet$7(this, _namespaces).database)
792
+ __privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
793
+ return __privateGet$7(this, _namespaces).database;
693
794
  }
694
795
  get branches() {
695
796
  if (!__privateGet$7(this, _namespaces).branches)
696
797
  __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
697
798
  return __privateGet$7(this, _namespaces).branches;
698
799
  }
800
+ get migrations() {
801
+ if (!__privateGet$7(this, _namespaces).migrations)
802
+ __privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
803
+ return __privateGet$7(this, _namespaces).migrations;
804
+ }
805
+ get migrationRequests() {
806
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
807
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
808
+ return __privateGet$7(this, _namespaces).migrationRequests;
809
+ }
699
810
  get tables() {
700
811
  if (!__privateGet$7(this, _namespaces).tables)
701
812
  __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
@@ -706,15 +817,10 @@ class XataApiClient {
706
817
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
707
818
  return __privateGet$7(this, _namespaces).records;
708
819
  }
709
- get migrationRequests() {
710
- if (!__privateGet$7(this, _namespaces).migrationRequests)
711
- __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
712
- return __privateGet$7(this, _namespaces).migrationRequests;
713
- }
714
- get branchSchema() {
715
- if (!__privateGet$7(this, _namespaces).branchSchema)
716
- __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
717
- return __privateGet$7(this, _namespaces).branchSchema;
820
+ get searchAndFilter() {
821
+ if (!__privateGet$7(this, _namespaces).searchAndFilter)
822
+ __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
823
+ return __privateGet$7(this, _namespaces).searchAndFilter;
718
824
  }
719
825
  }
720
826
  _extraProps = new WeakMap();
@@ -726,24 +832,29 @@ class UserApi {
726
832
  getUser() {
727
833
  return operationsByTag.users.getUser({ ...this.extraProps });
728
834
  }
729
- updateUser(user) {
835
+ updateUser({ user }) {
730
836
  return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
731
837
  }
732
838
  deleteUser() {
733
839
  return operationsByTag.users.deleteUser({ ...this.extraProps });
734
840
  }
841
+ }
842
+ class AuthenticationApi {
843
+ constructor(extraProps) {
844
+ this.extraProps = extraProps;
845
+ }
735
846
  getUserAPIKeys() {
736
- return operationsByTag.users.getUserAPIKeys({ ...this.extraProps });
847
+ return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
737
848
  }
738
- createUserAPIKey(keyName) {
739
- return operationsByTag.users.createUserAPIKey({
740
- pathParams: { keyName },
849
+ createUserAPIKey({ name }) {
850
+ return operationsByTag.authentication.createUserAPIKey({
851
+ pathParams: { keyName: name },
741
852
  ...this.extraProps
742
853
  });
743
854
  }
744
- deleteUserAPIKey(keyName) {
745
- return operationsByTag.users.deleteUserAPIKey({
746
- pathParams: { keyName },
855
+ deleteUserAPIKey({ name }) {
856
+ return operationsByTag.authentication.deleteUserAPIKey({
857
+ pathParams: { keyName: name },
747
858
  ...this.extraProps
748
859
  });
749
860
  }
@@ -752,196 +863,248 @@ class WorkspaceApi {
752
863
  constructor(extraProps) {
753
864
  this.extraProps = extraProps;
754
865
  }
755
- createWorkspace(workspaceMeta) {
866
+ getWorkspacesList() {
867
+ return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
868
+ }
869
+ createWorkspace({ data }) {
756
870
  return operationsByTag.workspaces.createWorkspace({
757
- body: workspaceMeta,
871
+ body: data,
758
872
  ...this.extraProps
759
873
  });
760
874
  }
761
- getWorkspacesList() {
762
- return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
763
- }
764
- getWorkspace(workspaceId) {
875
+ getWorkspace({ workspace }) {
765
876
  return operationsByTag.workspaces.getWorkspace({
766
- pathParams: { workspaceId },
877
+ pathParams: { workspaceId: workspace },
767
878
  ...this.extraProps
768
879
  });
769
880
  }
770
- updateWorkspace(workspaceId, workspaceMeta) {
881
+ updateWorkspace({
882
+ workspace,
883
+ update
884
+ }) {
771
885
  return operationsByTag.workspaces.updateWorkspace({
772
- pathParams: { workspaceId },
773
- body: workspaceMeta,
886
+ pathParams: { workspaceId: workspace },
887
+ body: update,
774
888
  ...this.extraProps
775
889
  });
776
890
  }
777
- deleteWorkspace(workspaceId) {
891
+ deleteWorkspace({ workspace }) {
778
892
  return operationsByTag.workspaces.deleteWorkspace({
779
- pathParams: { workspaceId },
893
+ pathParams: { workspaceId: workspace },
780
894
  ...this.extraProps
781
895
  });
782
896
  }
783
- getWorkspaceMembersList(workspaceId) {
897
+ getWorkspaceMembersList({ workspace }) {
784
898
  return operationsByTag.workspaces.getWorkspaceMembersList({
785
- pathParams: { workspaceId },
899
+ pathParams: { workspaceId: workspace },
786
900
  ...this.extraProps
787
901
  });
788
902
  }
789
- updateWorkspaceMemberRole(workspaceId, userId, role) {
903
+ updateWorkspaceMemberRole({
904
+ workspace,
905
+ user,
906
+ role
907
+ }) {
790
908
  return operationsByTag.workspaces.updateWorkspaceMemberRole({
791
- pathParams: { workspaceId, userId },
909
+ pathParams: { workspaceId: workspace, userId: user },
792
910
  body: { role },
793
911
  ...this.extraProps
794
912
  });
795
913
  }
796
- removeWorkspaceMember(workspaceId, userId) {
914
+ removeWorkspaceMember({
915
+ workspace,
916
+ user
917
+ }) {
797
918
  return operationsByTag.workspaces.removeWorkspaceMember({
798
- pathParams: { workspaceId, userId },
919
+ pathParams: { workspaceId: workspace, userId: user },
799
920
  ...this.extraProps
800
921
  });
801
922
  }
802
- inviteWorkspaceMember(workspaceId, email, role) {
803
- return operationsByTag.workspaces.inviteWorkspaceMember({
804
- pathParams: { workspaceId },
923
+ }
924
+ class InvitesApi {
925
+ constructor(extraProps) {
926
+ this.extraProps = extraProps;
927
+ }
928
+ inviteWorkspaceMember({
929
+ workspace,
930
+ email,
931
+ role
932
+ }) {
933
+ return operationsByTag.invites.inviteWorkspaceMember({
934
+ pathParams: { workspaceId: workspace },
805
935
  body: { email, role },
806
936
  ...this.extraProps
807
937
  });
808
938
  }
809
- updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
810
- return operationsByTag.workspaces.updateWorkspaceMemberInvite({
811
- pathParams: { workspaceId, inviteId },
939
+ updateWorkspaceMemberInvite({
940
+ workspace,
941
+ invite,
942
+ role
943
+ }) {
944
+ return operationsByTag.invites.updateWorkspaceMemberInvite({
945
+ pathParams: { workspaceId: workspace, inviteId: invite },
812
946
  body: { role },
813
947
  ...this.extraProps
814
948
  });
815
949
  }
816
- cancelWorkspaceMemberInvite(workspaceId, inviteId) {
817
- return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
818
- pathParams: { workspaceId, inviteId },
950
+ cancelWorkspaceMemberInvite({
951
+ workspace,
952
+ invite
953
+ }) {
954
+ return operationsByTag.invites.cancelWorkspaceMemberInvite({
955
+ pathParams: { workspaceId: workspace, inviteId: invite },
819
956
  ...this.extraProps
820
957
  });
821
958
  }
822
- resendWorkspaceMemberInvite(workspaceId, inviteId) {
823
- return operationsByTag.workspaces.resendWorkspaceMemberInvite({
824
- pathParams: { workspaceId, inviteId },
959
+ acceptWorkspaceMemberInvite({
960
+ workspace,
961
+ key
962
+ }) {
963
+ return operationsByTag.invites.acceptWorkspaceMemberInvite({
964
+ pathParams: { workspaceId: workspace, inviteKey: key },
825
965
  ...this.extraProps
826
966
  });
827
967
  }
828
- acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
829
- return operationsByTag.workspaces.acceptWorkspaceMemberInvite({
830
- pathParams: { workspaceId, inviteKey },
968
+ resendWorkspaceMemberInvite({
969
+ workspace,
970
+ invite
971
+ }) {
972
+ return operationsByTag.invites.resendWorkspaceMemberInvite({
973
+ pathParams: { workspaceId: workspace, inviteId: invite },
831
974
  ...this.extraProps
832
975
  });
833
976
  }
834
977
  }
835
- class DatabaseApi {
978
+ class BranchApi {
836
979
  constructor(extraProps) {
837
980
  this.extraProps = extraProps;
838
981
  }
839
- getDatabaseList(workspace) {
840
- return operationsByTag.database.getDatabaseList({
841
- pathParams: { workspace },
842
- ...this.extraProps
843
- });
844
- }
845
- createDatabase(workspace, dbName, options = {}) {
846
- return operationsByTag.database.createDatabase({
847
- pathParams: { workspace, dbName },
848
- body: options,
849
- ...this.extraProps
850
- });
851
- }
852
- deleteDatabase(workspace, dbName) {
853
- return operationsByTag.database.deleteDatabase({
854
- pathParams: { workspace, dbName },
855
- ...this.extraProps
856
- });
857
- }
858
- getDatabaseMetadata(workspace, dbName) {
859
- return operationsByTag.database.getDatabaseMetadata({
860
- pathParams: { workspace, dbName },
861
- ...this.extraProps
862
- });
863
- }
864
- updateDatabaseMetadata(workspace, dbName, options = {}) {
865
- return operationsByTag.database.updateDatabaseMetadata({
866
- pathParams: { workspace, dbName },
867
- body: options,
868
- ...this.extraProps
869
- });
870
- }
871
- getGitBranchesMapping(workspace, dbName) {
872
- return operationsByTag.database.getGitBranchesMapping({
873
- pathParams: { workspace, dbName },
982
+ getBranchList({
983
+ workspace,
984
+ region,
985
+ database
986
+ }) {
987
+ return operationsByTag.branch.getBranchList({
988
+ pathParams: { workspace, region, dbName: database },
874
989
  ...this.extraProps
875
990
  });
876
991
  }
877
- addGitBranchesEntry(workspace, dbName, body) {
878
- return operationsByTag.database.addGitBranchesEntry({
879
- pathParams: { workspace, dbName },
880
- body,
992
+ getBranchDetails({
993
+ workspace,
994
+ region,
995
+ database,
996
+ branch
997
+ }) {
998
+ return operationsByTag.branch.getBranchDetails({
999
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
881
1000
  ...this.extraProps
882
1001
  });
883
1002
  }
884
- removeGitBranchesEntry(workspace, dbName, gitBranch) {
885
- return operationsByTag.database.removeGitBranchesEntry({
886
- pathParams: { workspace, dbName },
887
- queryParams: { gitBranch },
1003
+ createBranch({
1004
+ workspace,
1005
+ region,
1006
+ database,
1007
+ branch,
1008
+ from,
1009
+ metadata
1010
+ }) {
1011
+ return operationsByTag.branch.createBranch({
1012
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1013
+ body: { from, metadata },
888
1014
  ...this.extraProps
889
1015
  });
890
1016
  }
891
- resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
892
- return operationsByTag.database.resolveBranch({
893
- pathParams: { workspace, dbName },
894
- queryParams: { gitBranch, fallbackBranch },
1017
+ deleteBranch({
1018
+ workspace,
1019
+ region,
1020
+ database,
1021
+ branch
1022
+ }) {
1023
+ return operationsByTag.branch.deleteBranch({
1024
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
895
1025
  ...this.extraProps
896
1026
  });
897
1027
  }
898
- }
899
- class BranchApi {
900
- constructor(extraProps) {
901
- this.extraProps = extraProps;
902
- }
903
- getBranchList(workspace, dbName) {
904
- return operationsByTag.branch.getBranchList({
905
- pathParams: { workspace, dbName },
1028
+ updateBranchMetadata({
1029
+ workspace,
1030
+ region,
1031
+ database,
1032
+ branch,
1033
+ metadata
1034
+ }) {
1035
+ return operationsByTag.branch.updateBranchMetadata({
1036
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1037
+ body: metadata,
906
1038
  ...this.extraProps
907
1039
  });
908
1040
  }
909
- getBranchDetails(workspace, database, branch) {
910
- return operationsByTag.branch.getBranchDetails({
911
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1041
+ getBranchMetadata({
1042
+ workspace,
1043
+ region,
1044
+ database,
1045
+ branch
1046
+ }) {
1047
+ return operationsByTag.branch.getBranchMetadata({
1048
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
912
1049
  ...this.extraProps
913
1050
  });
914
1051
  }
915
- createBranch(workspace, database, branch, from, options = {}) {
916
- return operationsByTag.branch.createBranch({
917
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
918
- queryParams: isString(from) ? { from } : void 0,
919
- body: options,
1052
+ getBranchStats({
1053
+ workspace,
1054
+ region,
1055
+ database,
1056
+ branch
1057
+ }) {
1058
+ return operationsByTag.branch.getBranchStats({
1059
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
920
1060
  ...this.extraProps
921
1061
  });
922
1062
  }
923
- deleteBranch(workspace, database, branch) {
924
- return operationsByTag.branch.deleteBranch({
925
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1063
+ getGitBranchesMapping({
1064
+ workspace,
1065
+ region,
1066
+ database
1067
+ }) {
1068
+ return operationsByTag.branch.getGitBranchesMapping({
1069
+ pathParams: { workspace, region, dbName: database },
926
1070
  ...this.extraProps
927
1071
  });
928
1072
  }
929
- updateBranchMetadata(workspace, database, branch, metadata = {}) {
930
- return operationsByTag.branch.updateBranchMetadata({
931
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
932
- body: metadata,
1073
+ addGitBranchesEntry({
1074
+ workspace,
1075
+ region,
1076
+ database,
1077
+ gitBranch,
1078
+ xataBranch
1079
+ }) {
1080
+ return operationsByTag.branch.addGitBranchesEntry({
1081
+ pathParams: { workspace, region, dbName: database },
1082
+ body: { gitBranch, xataBranch },
933
1083
  ...this.extraProps
934
1084
  });
935
1085
  }
936
- getBranchMetadata(workspace, database, branch) {
937
- return operationsByTag.branch.getBranchMetadata({
938
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1086
+ removeGitBranchesEntry({
1087
+ workspace,
1088
+ region,
1089
+ database,
1090
+ gitBranch
1091
+ }) {
1092
+ return operationsByTag.branch.removeGitBranchesEntry({
1093
+ pathParams: { workspace, region, dbName: database },
1094
+ queryParams: { gitBranch },
939
1095
  ...this.extraProps
940
1096
  });
941
1097
  }
942
- getBranchStats(workspace, database, branch) {
943
- return operationsByTag.branch.getBranchStats({
944
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1098
+ resolveBranch({
1099
+ workspace,
1100
+ region,
1101
+ database,
1102
+ gitBranch,
1103
+ fallbackBranch
1104
+ }) {
1105
+ return operationsByTag.branch.resolveBranch({
1106
+ pathParams: { workspace, region, dbName: database },
1107
+ queryParams: { gitBranch, fallbackBranch },
945
1108
  ...this.extraProps
946
1109
  });
947
1110
  }
@@ -950,67 +1113,134 @@ class TableApi {
950
1113
  constructor(extraProps) {
951
1114
  this.extraProps = extraProps;
952
1115
  }
953
- createTable(workspace, database, branch, tableName) {
1116
+ createTable({
1117
+ workspace,
1118
+ region,
1119
+ database,
1120
+ branch,
1121
+ table
1122
+ }) {
954
1123
  return operationsByTag.table.createTable({
955
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1124
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
956
1125
  ...this.extraProps
957
1126
  });
958
1127
  }
959
- deleteTable(workspace, database, branch, tableName) {
1128
+ deleteTable({
1129
+ workspace,
1130
+ region,
1131
+ database,
1132
+ branch,
1133
+ table
1134
+ }) {
960
1135
  return operationsByTag.table.deleteTable({
961
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1136
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
962
1137
  ...this.extraProps
963
1138
  });
964
1139
  }
965
- updateTable(workspace, database, branch, tableName, options) {
1140
+ updateTable({
1141
+ workspace,
1142
+ region,
1143
+ database,
1144
+ branch,
1145
+ table,
1146
+ update
1147
+ }) {
966
1148
  return operationsByTag.table.updateTable({
967
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
968
- body: options,
1149
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1150
+ body: update,
969
1151
  ...this.extraProps
970
1152
  });
971
1153
  }
972
- getTableSchema(workspace, database, branch, tableName) {
1154
+ getTableSchema({
1155
+ workspace,
1156
+ region,
1157
+ database,
1158
+ branch,
1159
+ table
1160
+ }) {
973
1161
  return operationsByTag.table.getTableSchema({
974
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1162
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
975
1163
  ...this.extraProps
976
1164
  });
977
1165
  }
978
- setTableSchema(workspace, database, branch, tableName, options) {
1166
+ setTableSchema({
1167
+ workspace,
1168
+ region,
1169
+ database,
1170
+ branch,
1171
+ table,
1172
+ schema
1173
+ }) {
979
1174
  return operationsByTag.table.setTableSchema({
980
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
981
- body: options,
1175
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1176
+ body: schema,
982
1177
  ...this.extraProps
983
1178
  });
984
1179
  }
985
- getTableColumns(workspace, database, branch, tableName) {
1180
+ getTableColumns({
1181
+ workspace,
1182
+ region,
1183
+ database,
1184
+ branch,
1185
+ table
1186
+ }) {
986
1187
  return operationsByTag.table.getTableColumns({
987
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1188
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
988
1189
  ...this.extraProps
989
1190
  });
990
1191
  }
991
- addTableColumn(workspace, database, branch, tableName, column) {
1192
+ addTableColumn({
1193
+ workspace,
1194
+ region,
1195
+ database,
1196
+ branch,
1197
+ table,
1198
+ column
1199
+ }) {
992
1200
  return operationsByTag.table.addTableColumn({
993
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1201
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
994
1202
  body: column,
995
1203
  ...this.extraProps
996
1204
  });
997
1205
  }
998
- getColumn(workspace, database, branch, tableName, columnName) {
1206
+ getColumn({
1207
+ workspace,
1208
+ region,
1209
+ database,
1210
+ branch,
1211
+ table,
1212
+ column
1213
+ }) {
999
1214
  return operationsByTag.table.getColumn({
1000
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1215
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1001
1216
  ...this.extraProps
1002
1217
  });
1003
1218
  }
1004
- deleteColumn(workspace, database, branch, tableName, columnName) {
1005
- return operationsByTag.table.deleteColumn({
1006
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1219
+ updateColumn({
1220
+ workspace,
1221
+ region,
1222
+ database,
1223
+ branch,
1224
+ table,
1225
+ column,
1226
+ update
1227
+ }) {
1228
+ return operationsByTag.table.updateColumn({
1229
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1230
+ body: update,
1007
1231
  ...this.extraProps
1008
1232
  });
1009
1233
  }
1010
- updateColumn(workspace, database, branch, tableName, columnName, options) {
1011
- return operationsByTag.table.updateColumn({
1012
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1013
- body: options,
1234
+ deleteColumn({
1235
+ workspace,
1236
+ region,
1237
+ database,
1238
+ branch,
1239
+ table,
1240
+ column
1241
+ }) {
1242
+ return operationsByTag.table.deleteColumn({
1243
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1014
1244
  ...this.extraProps
1015
1245
  });
1016
1246
  }
@@ -1019,78 +1249,215 @@ class RecordsApi {
1019
1249
  constructor(extraProps) {
1020
1250
  this.extraProps = extraProps;
1021
1251
  }
1022
- insertRecord(workspace, database, branch, tableName, record, options = {}) {
1252
+ insertRecord({
1253
+ workspace,
1254
+ region,
1255
+ database,
1256
+ branch,
1257
+ table,
1258
+ record,
1259
+ columns
1260
+ }) {
1023
1261
  return operationsByTag.records.insertRecord({
1024
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1025
- queryParams: options,
1262
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1263
+ queryParams: { columns },
1026
1264
  body: record,
1027
1265
  ...this.extraProps
1028
1266
  });
1029
1267
  }
1030
- insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1268
+ getRecord({
1269
+ workspace,
1270
+ region,
1271
+ database,
1272
+ branch,
1273
+ table,
1274
+ id,
1275
+ columns
1276
+ }) {
1277
+ return operationsByTag.records.getRecord({
1278
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1279
+ queryParams: { columns },
1280
+ ...this.extraProps
1281
+ });
1282
+ }
1283
+ insertRecordWithID({
1284
+ workspace,
1285
+ region,
1286
+ database,
1287
+ branch,
1288
+ table,
1289
+ id,
1290
+ record,
1291
+ columns,
1292
+ createOnly,
1293
+ ifVersion
1294
+ }) {
1031
1295
  return operationsByTag.records.insertRecordWithID({
1032
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1033
- queryParams: options,
1296
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1297
+ queryParams: { columns, createOnly, ifVersion },
1034
1298
  body: record,
1035
1299
  ...this.extraProps
1036
1300
  });
1037
1301
  }
1038
- updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1302
+ updateRecordWithID({
1303
+ workspace,
1304
+ region,
1305
+ database,
1306
+ branch,
1307
+ table,
1308
+ id,
1309
+ record,
1310
+ columns,
1311
+ ifVersion
1312
+ }) {
1039
1313
  return operationsByTag.records.updateRecordWithID({
1040
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1041
- queryParams: options,
1314
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1315
+ queryParams: { columns, ifVersion },
1042
1316
  body: record,
1043
1317
  ...this.extraProps
1044
1318
  });
1045
1319
  }
1046
- upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1320
+ upsertRecordWithID({
1321
+ workspace,
1322
+ region,
1323
+ database,
1324
+ branch,
1325
+ table,
1326
+ id,
1327
+ record,
1328
+ columns,
1329
+ ifVersion
1330
+ }) {
1047
1331
  return operationsByTag.records.upsertRecordWithID({
1048
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1049
- queryParams: options,
1332
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1333
+ queryParams: { columns, ifVersion },
1050
1334
  body: record,
1051
1335
  ...this.extraProps
1052
1336
  });
1053
1337
  }
1054
- deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
1338
+ deleteRecord({
1339
+ workspace,
1340
+ region,
1341
+ database,
1342
+ branch,
1343
+ table,
1344
+ id,
1345
+ columns
1346
+ }) {
1055
1347
  return operationsByTag.records.deleteRecord({
1056
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1057
- queryParams: options,
1058
- ...this.extraProps
1059
- });
1060
- }
1061
- getRecord(workspace, database, branch, tableName, recordId, options = {}) {
1062
- return operationsByTag.records.getRecord({
1063
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1064
- queryParams: options,
1348
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1349
+ queryParams: { columns },
1065
1350
  ...this.extraProps
1066
1351
  });
1067
1352
  }
1068
- bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
1353
+ bulkInsertTableRecords({
1354
+ workspace,
1355
+ region,
1356
+ database,
1357
+ branch,
1358
+ table,
1359
+ records,
1360
+ columns
1361
+ }) {
1069
1362
  return operationsByTag.records.bulkInsertTableRecords({
1070
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1071
- queryParams: options,
1363
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1364
+ queryParams: { columns },
1072
1365
  body: { records },
1073
1366
  ...this.extraProps
1074
1367
  });
1075
1368
  }
1076
- queryTable(workspace, database, branch, tableName, query) {
1077
- return operationsByTag.records.queryTable({
1078
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1079
- body: query,
1080
- ...this.extraProps
1081
- });
1082
- }
1083
- searchTable(workspace, database, branch, tableName, query) {
1084
- return operationsByTag.records.searchTable({
1085
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1086
- body: query,
1087
- ...this.extraProps
1088
- });
1369
+ }
1370
+ class SearchAndFilterApi {
1371
+ constructor(extraProps) {
1372
+ this.extraProps = extraProps;
1089
1373
  }
1090
- searchBranch(workspace, database, branch, query) {
1091
- return operationsByTag.records.searchBranch({
1092
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1093
- body: query,
1374
+ queryTable({
1375
+ workspace,
1376
+ region,
1377
+ database,
1378
+ branch,
1379
+ table,
1380
+ filter,
1381
+ sort,
1382
+ page,
1383
+ columns,
1384
+ consistency
1385
+ }) {
1386
+ return operationsByTag.searchAndFilter.queryTable({
1387
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1388
+ body: { filter, sort, page, columns, consistency },
1389
+ ...this.extraProps
1390
+ });
1391
+ }
1392
+ searchTable({
1393
+ workspace,
1394
+ region,
1395
+ database,
1396
+ branch,
1397
+ table,
1398
+ query,
1399
+ fuzziness,
1400
+ target,
1401
+ prefix,
1402
+ filter,
1403
+ highlight,
1404
+ boosters
1405
+ }) {
1406
+ return operationsByTag.searchAndFilter.searchTable({
1407
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1408
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
1409
+ ...this.extraProps
1410
+ });
1411
+ }
1412
+ searchBranch({
1413
+ workspace,
1414
+ region,
1415
+ database,
1416
+ branch,
1417
+ tables,
1418
+ query,
1419
+ fuzziness,
1420
+ prefix,
1421
+ highlight
1422
+ }) {
1423
+ return operationsByTag.searchAndFilter.searchBranch({
1424
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1425
+ body: { tables, query, fuzziness, prefix, highlight },
1426
+ ...this.extraProps
1427
+ });
1428
+ }
1429
+ summarizeTable({
1430
+ workspace,
1431
+ region,
1432
+ database,
1433
+ branch,
1434
+ table,
1435
+ filter,
1436
+ columns,
1437
+ summaries,
1438
+ sort,
1439
+ summariesFilter,
1440
+ page,
1441
+ consistency
1442
+ }) {
1443
+ return operationsByTag.searchAndFilter.summarizeTable({
1444
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1445
+ body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
1446
+ ...this.extraProps
1447
+ });
1448
+ }
1449
+ aggregateTable({
1450
+ workspace,
1451
+ region,
1452
+ database,
1453
+ branch,
1454
+ table,
1455
+ filter,
1456
+ aggs
1457
+ }) {
1458
+ return operationsByTag.searchAndFilter.aggregateTable({
1459
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1460
+ body: { filter, aggs },
1094
1461
  ...this.extraProps
1095
1462
  });
1096
1463
  }
@@ -1099,123 +1466,281 @@ class MigrationRequestsApi {
1099
1466
  constructor(extraProps) {
1100
1467
  this.extraProps = extraProps;
1101
1468
  }
1102
- listMigrationRequests(workspace, database, options = {}) {
1103
- return operationsByTag.migrationRequests.listMigrationRequests({
1104
- pathParams: { workspace, dbName: database },
1105
- body: options,
1106
- ...this.extraProps
1107
- });
1108
- }
1109
- createMigrationRequest(workspace, database, options) {
1469
+ queryMigrationRequests({
1470
+ workspace,
1471
+ region,
1472
+ database,
1473
+ filter,
1474
+ sort,
1475
+ page,
1476
+ columns
1477
+ }) {
1478
+ return operationsByTag.migrationRequests.queryMigrationRequests({
1479
+ pathParams: { workspace, region, dbName: database },
1480
+ body: { filter, sort, page, columns },
1481
+ ...this.extraProps
1482
+ });
1483
+ }
1484
+ createMigrationRequest({
1485
+ workspace,
1486
+ region,
1487
+ database,
1488
+ migration
1489
+ }) {
1110
1490
  return operationsByTag.migrationRequests.createMigrationRequest({
1111
- pathParams: { workspace, dbName: database },
1112
- body: options,
1491
+ pathParams: { workspace, region, dbName: database },
1492
+ body: migration,
1113
1493
  ...this.extraProps
1114
1494
  });
1115
1495
  }
1116
- getMigrationRequest(workspace, database, migrationRequest) {
1496
+ getMigrationRequest({
1497
+ workspace,
1498
+ region,
1499
+ database,
1500
+ migrationRequest
1501
+ }) {
1117
1502
  return operationsByTag.migrationRequests.getMigrationRequest({
1118
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1503
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1119
1504
  ...this.extraProps
1120
1505
  });
1121
1506
  }
1122
- updateMigrationRequest(workspace, database, migrationRequest, options) {
1507
+ updateMigrationRequest({
1508
+ workspace,
1509
+ region,
1510
+ database,
1511
+ migrationRequest,
1512
+ update
1513
+ }) {
1123
1514
  return operationsByTag.migrationRequests.updateMigrationRequest({
1124
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1125
- body: options,
1515
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1516
+ body: update,
1126
1517
  ...this.extraProps
1127
1518
  });
1128
1519
  }
1129
- listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1520
+ listMigrationRequestsCommits({
1521
+ workspace,
1522
+ region,
1523
+ database,
1524
+ migrationRequest,
1525
+ page
1526
+ }) {
1130
1527
  return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1131
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1132
- body: options,
1528
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1529
+ body: { page },
1133
1530
  ...this.extraProps
1134
1531
  });
1135
1532
  }
1136
- compareMigrationRequest(workspace, database, migrationRequest) {
1533
+ compareMigrationRequest({
1534
+ workspace,
1535
+ region,
1536
+ database,
1537
+ migrationRequest
1538
+ }) {
1137
1539
  return operationsByTag.migrationRequests.compareMigrationRequest({
1138
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1540
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1139
1541
  ...this.extraProps
1140
1542
  });
1141
1543
  }
1142
- getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1544
+ getMigrationRequestIsMerged({
1545
+ workspace,
1546
+ region,
1547
+ database,
1548
+ migrationRequest
1549
+ }) {
1143
1550
  return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1144
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1551
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1145
1552
  ...this.extraProps
1146
1553
  });
1147
1554
  }
1148
- mergeMigrationRequest(workspace, database, migrationRequest) {
1555
+ mergeMigrationRequest({
1556
+ workspace,
1557
+ region,
1558
+ database,
1559
+ migrationRequest
1560
+ }) {
1149
1561
  return operationsByTag.migrationRequests.mergeMigrationRequest({
1150
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1562
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1151
1563
  ...this.extraProps
1152
1564
  });
1153
1565
  }
1154
1566
  }
1155
- class BranchSchemaApi {
1567
+ class MigrationsApi {
1156
1568
  constructor(extraProps) {
1157
1569
  this.extraProps = extraProps;
1158
1570
  }
1159
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
1160
- return operationsByTag.branchSchema.getBranchMigrationHistory({
1161
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1162
- body: options,
1571
+ getBranchMigrationHistory({
1572
+ workspace,
1573
+ region,
1574
+ database,
1575
+ branch,
1576
+ limit,
1577
+ startFrom
1578
+ }) {
1579
+ return operationsByTag.migrations.getBranchMigrationHistory({
1580
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1581
+ body: { limit, startFrom },
1582
+ ...this.extraProps
1583
+ });
1584
+ }
1585
+ getBranchMigrationPlan({
1586
+ workspace,
1587
+ region,
1588
+ database,
1589
+ branch,
1590
+ schema
1591
+ }) {
1592
+ return operationsByTag.migrations.getBranchMigrationPlan({
1593
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1594
+ body: schema,
1163
1595
  ...this.extraProps
1164
1596
  });
1165
1597
  }
1166
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1167
- return operationsByTag.branchSchema.executeBranchMigrationPlan({
1168
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1169
- body: migrationPlan,
1598
+ executeBranchMigrationPlan({
1599
+ workspace,
1600
+ region,
1601
+ database,
1602
+ branch,
1603
+ plan
1604
+ }) {
1605
+ return operationsByTag.migrations.executeBranchMigrationPlan({
1606
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1607
+ body: plan,
1170
1608
  ...this.extraProps
1171
1609
  });
1172
1610
  }
1173
- getBranchMigrationPlan(workspace, database, branch, schema) {
1174
- return operationsByTag.branchSchema.getBranchMigrationPlan({
1175
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1176
- body: schema,
1611
+ getBranchSchemaHistory({
1612
+ workspace,
1613
+ region,
1614
+ database,
1615
+ branch,
1616
+ page
1617
+ }) {
1618
+ return operationsByTag.migrations.getBranchSchemaHistory({
1619
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1620
+ body: { page },
1177
1621
  ...this.extraProps
1178
1622
  });
1179
1623
  }
1180
- compareBranchWithUserSchema(workspace, database, branch, schema) {
1181
- return operationsByTag.branchSchema.compareBranchWithUserSchema({
1182
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1624
+ compareBranchWithUserSchema({
1625
+ workspace,
1626
+ region,
1627
+ database,
1628
+ branch,
1629
+ schema
1630
+ }) {
1631
+ return operationsByTag.migrations.compareBranchWithUserSchema({
1632
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1183
1633
  body: { schema },
1184
1634
  ...this.extraProps
1185
1635
  });
1186
1636
  }
1187
- compareBranchSchemas(workspace, database, branch, branchName, schema) {
1188
- return operationsByTag.branchSchema.compareBranchSchemas({
1189
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1637
+ compareBranchSchemas({
1638
+ workspace,
1639
+ region,
1640
+ database,
1641
+ branch,
1642
+ compare,
1643
+ schema
1644
+ }) {
1645
+ return operationsByTag.migrations.compareBranchSchemas({
1646
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
1190
1647
  body: { schema },
1191
1648
  ...this.extraProps
1192
1649
  });
1193
1650
  }
1194
- updateBranchSchema(workspace, database, branch, migration) {
1195
- return operationsByTag.branchSchema.updateBranchSchema({
1196
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1651
+ updateBranchSchema({
1652
+ workspace,
1653
+ region,
1654
+ database,
1655
+ branch,
1656
+ migration
1657
+ }) {
1658
+ return operationsByTag.migrations.updateBranchSchema({
1659
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1197
1660
  body: migration,
1198
1661
  ...this.extraProps
1199
1662
  });
1200
1663
  }
1201
- previewBranchSchemaEdit(workspace, database, branch, migration) {
1202
- return operationsByTag.branchSchema.previewBranchSchemaEdit({
1203
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1204
- body: migration,
1664
+ previewBranchSchemaEdit({
1665
+ workspace,
1666
+ region,
1667
+ database,
1668
+ branch,
1669
+ data
1670
+ }) {
1671
+ return operationsByTag.migrations.previewBranchSchemaEdit({
1672
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1673
+ body: data,
1205
1674
  ...this.extraProps
1206
1675
  });
1207
1676
  }
1208
- applyBranchSchemaEdit(workspace, database, branch, edits) {
1209
- return operationsByTag.branchSchema.applyBranchSchemaEdit({
1210
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1677
+ applyBranchSchemaEdit({
1678
+ workspace,
1679
+ region,
1680
+ database,
1681
+ branch,
1682
+ edits
1683
+ }) {
1684
+ return operationsByTag.migrations.applyBranchSchemaEdit({
1685
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1211
1686
  body: { edits },
1212
1687
  ...this.extraProps
1213
1688
  });
1214
1689
  }
1215
- getBranchSchemaHistory(workspace, database, branch, options = {}) {
1216
- return operationsByTag.branchSchema.getBranchSchemaHistory({
1217
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1218
- body: options,
1690
+ }
1691
+ class DatabaseApi {
1692
+ constructor(extraProps) {
1693
+ this.extraProps = extraProps;
1694
+ }
1695
+ getDatabaseList({ workspace }) {
1696
+ return operationsByTag.databases.getDatabaseList({
1697
+ pathParams: { workspaceId: workspace },
1698
+ ...this.extraProps
1699
+ });
1700
+ }
1701
+ createDatabase({
1702
+ workspace,
1703
+ database,
1704
+ data
1705
+ }) {
1706
+ return operationsByTag.databases.createDatabase({
1707
+ pathParams: { workspaceId: workspace, dbName: database },
1708
+ body: data,
1709
+ ...this.extraProps
1710
+ });
1711
+ }
1712
+ deleteDatabase({
1713
+ workspace,
1714
+ database
1715
+ }) {
1716
+ return operationsByTag.databases.deleteDatabase({
1717
+ pathParams: { workspaceId: workspace, dbName: database },
1718
+ ...this.extraProps
1719
+ });
1720
+ }
1721
+ getDatabaseMetadata({
1722
+ workspace,
1723
+ database
1724
+ }) {
1725
+ return operationsByTag.databases.getDatabaseMetadata({
1726
+ pathParams: { workspaceId: workspace, dbName: database },
1727
+ ...this.extraProps
1728
+ });
1729
+ }
1730
+ updateDatabaseMetadata({
1731
+ workspace,
1732
+ database,
1733
+ metadata
1734
+ }) {
1735
+ return operationsByTag.databases.updateDatabaseMetadata({
1736
+ pathParams: { workspaceId: workspace, dbName: database },
1737
+ body: metadata,
1738
+ ...this.extraProps
1739
+ });
1740
+ }
1741
+ listRegions({ workspace }) {
1742
+ return operationsByTag.databases.listRegions({
1743
+ pathParams: { workspaceId: workspace },
1219
1744
  ...this.extraProps
1220
1745
  });
1221
1746
  }
@@ -1231,6 +1756,20 @@ class XataApiPlugin {
1231
1756
  class XataPlugin {
1232
1757
  }
1233
1758
 
1759
+ function generateUUID() {
1760
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
1761
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
1762
+ return v.toString(16);
1763
+ });
1764
+ }
1765
+
1766
+ function cleanFilter(filter) {
1767
+ if (!filter)
1768
+ return void 0;
1769
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
1770
+ return values.length > 0 ? filter : void 0;
1771
+ }
1772
+
1234
1773
  var __accessCheck$6 = (obj, member, msg) => {
1235
1774
  if (!member.has(obj))
1236
1775
  throw TypeError("Cannot " + msg);
@@ -1263,11 +1802,11 @@ class Page {
1263
1802
  async previousPage(size, offset) {
1264
1803
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
1265
1804
  }
1266
- async firstPage(size, offset) {
1267
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
1805
+ async startPage(size, offset) {
1806
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
1268
1807
  }
1269
- async lastPage(size, offset) {
1270
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
1808
+ async endPage(size, offset) {
1809
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
1271
1810
  }
1272
1811
  hasNextPage() {
1273
1812
  return this.meta.page.more;
@@ -1279,7 +1818,7 @@ const PAGINATION_DEFAULT_SIZE = 20;
1279
1818
  const PAGINATION_MAX_OFFSET = 800;
1280
1819
  const PAGINATION_DEFAULT_OFFSET = 0;
1281
1820
  function isCursorPaginationOptions(options) {
1282
- return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
1821
+ return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
1283
1822
  }
1284
1823
  const _RecordArray = class extends Array {
1285
1824
  constructor(...args) {
@@ -1311,12 +1850,12 @@ const _RecordArray = class extends Array {
1311
1850
  const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
1312
1851
  return new _RecordArray(newPage);
1313
1852
  }
1314
- async firstPage(size, offset) {
1315
- const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
1853
+ async startPage(size, offset) {
1854
+ const newPage = await __privateGet$6(this, _page).startPage(size, offset);
1316
1855
  return new _RecordArray(newPage);
1317
1856
  }
1318
- async lastPage(size, offset) {
1319
- const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
1857
+ async endPage(size, offset) {
1858
+ const newPage = await __privateGet$6(this, _page).endPage(size, offset);
1320
1859
  return new _RecordArray(newPage);
1321
1860
  }
1322
1861
  hasNextPage() {
@@ -1344,9 +1883,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
1344
1883
  setter ? setter.call(obj, value) : member.set(obj, value);
1345
1884
  return value;
1346
1885
  };
1347
- var _table$1, _repository, _data;
1886
+ var __privateMethod$3 = (obj, member, method) => {
1887
+ __accessCheck$5(obj, member, "access private method");
1888
+ return method;
1889
+ };
1890
+ var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
1348
1891
  const _Query = class {
1349
1892
  constructor(repository, table, data, rawParent) {
1893
+ __privateAdd$5(this, _cleanFilterConstraint);
1350
1894
  __privateAdd$5(this, _table$1, void 0);
1351
1895
  __privateAdd$5(this, _repository, void 0);
1352
1896
  __privateAdd$5(this, _data, { filter: {} });
@@ -1365,9 +1909,10 @@ const _Query = class {
1365
1909
  __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
1366
1910
  __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
1367
1911
  __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
1368
- __privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
1912
+ __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
1369
1913
  __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
1370
1914
  __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
1915
+ __privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
1371
1916
  this.any = this.any.bind(this);
1372
1917
  this.all = this.all.bind(this);
1373
1918
  this.not = this.not.bind(this);
@@ -1403,22 +1948,17 @@ const _Query = class {
1403
1948
  }
1404
1949
  filter(a, b) {
1405
1950
  if (arguments.length === 1) {
1406
- const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({ [column]: constraint }));
1951
+ const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
1952
+ [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
1953
+ }));
1407
1954
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1408
1955
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1409
1956
  } else {
1410
- const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.defaultFilter(a, b) }] : void 0;
1957
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
1411
1958
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1412
1959
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1413
1960
  }
1414
1961
  }
1415
- defaultFilter(column, value) {
1416
- const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
1417
- if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
1418
- return { $includes: value };
1419
- }
1420
- return value;
1421
- }
1422
1962
  sort(column, direction = "asc") {
1423
1963
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1424
1964
  const sort = [...originalSort, { column, direction }];
@@ -1486,19 +2026,29 @@ const _Query = class {
1486
2026
  throw new Error("No results found.");
1487
2027
  return records[0];
1488
2028
  }
2029
+ async summarize(params = {}) {
2030
+ const { summaries, summariesFilter, ...options } = params;
2031
+ const query = new _Query(
2032
+ __privateGet$5(this, _repository),
2033
+ __privateGet$5(this, _table$1),
2034
+ options,
2035
+ __privateGet$5(this, _data)
2036
+ );
2037
+ return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
2038
+ }
1489
2039
  cache(ttl) {
1490
2040
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1491
2041
  }
1492
2042
  nextPage(size, offset) {
1493
- return this.firstPage(size, offset);
2043
+ return this.startPage(size, offset);
1494
2044
  }
1495
2045
  previousPage(size, offset) {
1496
- return this.firstPage(size, offset);
2046
+ return this.startPage(size, offset);
1497
2047
  }
1498
- firstPage(size, offset) {
2048
+ startPage(size, offset) {
1499
2049
  return this.getPaginated({ pagination: { size, offset } });
1500
2050
  }
1501
- lastPage(size, offset) {
2051
+ endPage(size, offset) {
1502
2052
  return this.getPaginated({ pagination: { size, offset, before: "end" } });
1503
2053
  }
1504
2054
  hasNextPage() {
@@ -1509,9 +2059,20 @@ let Query = _Query;
1509
2059
  _table$1 = new WeakMap();
1510
2060
  _repository = new WeakMap();
1511
2061
  _data = new WeakMap();
2062
+ _cleanFilterConstraint = new WeakSet();
2063
+ cleanFilterConstraint_fn = function(column, value) {
2064
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
2065
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
2066
+ return { $includes: value };
2067
+ }
2068
+ if (columnType === "link" && isObject(value) && isString(value.id)) {
2069
+ return value.id;
2070
+ }
2071
+ return value;
2072
+ };
1512
2073
  function cleanParent(data, parent) {
1513
2074
  if (isCursorPaginationOptions(data.pagination)) {
1514
- return { ...parent, sorting: void 0, filter: void 0 };
2075
+ return { ...parent, sort: void 0, filter: void 0 };
1515
2076
  }
1516
2077
  return parent;
1517
2078
  }
@@ -1596,10 +2157,13 @@ class RestRepository extends Query {
1596
2157
  __privateAdd$4(this, _schemaTables$2, void 0);
1597
2158
  __privateAdd$4(this, _trace, void 0);
1598
2159
  __privateSet$4(this, _table, options.table);
1599
- __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1600
2160
  __privateSet$4(this, _db, options.db);
1601
2161
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1602
2162
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
2163
+ __privateSet$4(this, _getFetchProps, async () => {
2164
+ const props = await options.pluginOptions.getFetchProps();
2165
+ return { ...props, sessionID: generateUUID() };
2166
+ });
1603
2167
  const trace = options.pluginOptions.trace ?? defaultTrace;
1604
2168
  __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
1605
2169
  return trace(name, fn, {
@@ -1610,8 +2174,9 @@ class RestRepository extends Query {
1610
2174
  });
1611
2175
  });
1612
2176
  }
1613
- async create(a, b, c) {
2177
+ async create(a, b, c, d) {
1614
2178
  return __privateGet$4(this, _trace).call(this, "create", async () => {
2179
+ const ifVersion = parseIfVersion(b, c, d);
1615
2180
  if (Array.isArray(a)) {
1616
2181
  if (a.length === 0)
1617
2182
  return [];
@@ -1622,13 +2187,13 @@ class RestRepository extends Query {
1622
2187
  if (a === "")
1623
2188
  throw new Error("The id can't be empty");
1624
2189
  const columns = isStringArray(c) ? c : void 0;
1625
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
2190
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
1626
2191
  }
1627
2192
  if (isObject(a) && isString(a.id)) {
1628
2193
  if (a.id === "")
1629
2194
  throw new Error("The id can't be empty");
1630
2195
  const columns = isStringArray(b) ? b : void 0;
1631
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2196
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
1632
2197
  }
1633
2198
  if (isObject(a)) {
1634
2199
  const columns = isStringArray(b) ? b : void 0;
@@ -1659,6 +2224,7 @@ class RestRepository extends Query {
1659
2224
  pathParams: {
1660
2225
  workspace: "{workspaceId}",
1661
2226
  dbBranchName: "{dbBranch}",
2227
+ region: "{region}",
1662
2228
  tableName: __privateGet$4(this, _table),
1663
2229
  recordId: id
1664
2230
  },
@@ -1666,7 +2232,7 @@ class RestRepository extends Query {
1666
2232
  ...fetchProps
1667
2233
  });
1668
2234
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1669
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2235
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1670
2236
  } catch (e) {
1671
2237
  if (isObject(e) && e.status === 404) {
1672
2238
  return null;
@@ -1696,8 +2262,9 @@ class RestRepository extends Query {
1696
2262
  return result;
1697
2263
  });
1698
2264
  }
1699
- async update(a, b, c) {
2265
+ async update(a, b, c, d) {
1700
2266
  return __privateGet$4(this, _trace).call(this, "update", async () => {
2267
+ const ifVersion = parseIfVersion(b, c, d);
1701
2268
  if (Array.isArray(a)) {
1702
2269
  if (a.length === 0)
1703
2270
  return [];
@@ -1709,18 +2276,18 @@ class RestRepository extends Query {
1709
2276
  }
1710
2277
  if (isString(a) && isObject(b)) {
1711
2278
  const columns = isStringArray(c) ? c : void 0;
1712
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
2279
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1713
2280
  }
1714
2281
  if (isObject(a) && isString(a.id)) {
1715
2282
  const columns = isStringArray(b) ? b : void 0;
1716
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2283
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
1717
2284
  }
1718
2285
  throw new Error("Invalid arguments for update method");
1719
2286
  });
1720
2287
  }
1721
- async updateOrThrow(a, b, c) {
2288
+ async updateOrThrow(a, b, c, d) {
1722
2289
  return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1723
- const result = await this.update(a, b, c);
2290
+ const result = await this.update(a, b, c, d);
1724
2291
  if (Array.isArray(result)) {
1725
2292
  const missingIds = compact(
1726
2293
  a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
@@ -1737,8 +2304,9 @@ class RestRepository extends Query {
1737
2304
  return result;
1738
2305
  });
1739
2306
  }
1740
- async createOrUpdate(a, b, c) {
2307
+ async createOrUpdate(a, b, c, d) {
1741
2308
  return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
2309
+ const ifVersion = parseIfVersion(b, c, d);
1742
2310
  if (Array.isArray(a)) {
1743
2311
  if (a.length === 0)
1744
2312
  return [];
@@ -1750,15 +2318,35 @@ class RestRepository extends Query {
1750
2318
  }
1751
2319
  if (isString(a) && isObject(b)) {
1752
2320
  const columns = isStringArray(c) ? c : void 0;
1753
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
2321
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1754
2322
  }
1755
2323
  if (isObject(a) && isString(a.id)) {
1756
2324
  const columns = isStringArray(c) ? c : void 0;
1757
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2325
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
1758
2326
  }
1759
2327
  throw new Error("Invalid arguments for createOrUpdate method");
1760
2328
  });
1761
2329
  }
2330
+ async createOrReplace(a, b, c, d) {
2331
+ return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
2332
+ const ifVersion = parseIfVersion(b, c, d);
2333
+ if (Array.isArray(a)) {
2334
+ if (a.length === 0)
2335
+ return [];
2336
+ const columns = isStringArray(b) ? b : ["*"];
2337
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
2338
+ }
2339
+ if (isString(a) && isObject(b)) {
2340
+ const columns = isStringArray(c) ? c : void 0;
2341
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
2342
+ }
2343
+ if (isObject(a) && isString(a.id)) {
2344
+ const columns = isStringArray(c) ? c : void 0;
2345
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
2346
+ }
2347
+ throw new Error("Invalid arguments for createOrReplace method");
2348
+ });
2349
+ }
1762
2350
  async delete(a, b) {
1763
2351
  return __privateGet$4(this, _trace).call(this, "delete", async () => {
1764
2352
  if (Array.isArray(a)) {
@@ -1800,7 +2388,12 @@ class RestRepository extends Query {
1800
2388
  return __privateGet$4(this, _trace).call(this, "search", async () => {
1801
2389
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1802
2390
  const { records } = await searchTable({
1803
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2391
+ pathParams: {
2392
+ workspace: "{workspaceId}",
2393
+ dbBranchName: "{dbBranch}",
2394
+ region: "{region}",
2395
+ tableName: __privateGet$4(this, _table)
2396
+ },
1804
2397
  body: {
1805
2398
  query,
1806
2399
  fuzziness: options.fuzziness,
@@ -1812,7 +2405,23 @@ class RestRepository extends Query {
1812
2405
  ...fetchProps
1813
2406
  });
1814
2407
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1815
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
2408
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
2409
+ });
2410
+ }
2411
+ async aggregate(aggs, filter) {
2412
+ return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
2413
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2414
+ const result = await aggregateTable({
2415
+ pathParams: {
2416
+ workspace: "{workspaceId}",
2417
+ dbBranchName: "{dbBranch}",
2418
+ region: "{region}",
2419
+ tableName: __privateGet$4(this, _table)
2420
+ },
2421
+ body: { aggs, filter },
2422
+ ...fetchProps
2423
+ });
2424
+ return result;
1816
2425
  });
1817
2426
  }
1818
2427
  async query(query) {
@@ -1821,24 +2430,55 @@ class RestRepository extends Query {
1821
2430
  if (cacheQuery)
1822
2431
  return new Page(query, cacheQuery.meta, cacheQuery.records);
1823
2432
  const data = query.getQueryOptions();
1824
- const body = {
1825
- filter: cleanFilter(data.filter),
1826
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1827
- page: data.pagination,
1828
- columns: data.columns
1829
- };
1830
2433
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1831
2434
  const { meta, records: objects } = await queryTable({
1832
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1833
- body,
2435
+ pathParams: {
2436
+ workspace: "{workspaceId}",
2437
+ dbBranchName: "{dbBranch}",
2438
+ region: "{region}",
2439
+ tableName: __privateGet$4(this, _table)
2440
+ },
2441
+ body: {
2442
+ filter: cleanFilter(data.filter),
2443
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2444
+ page: data.pagination,
2445
+ columns: data.columns ?? ["*"]
2446
+ },
2447
+ fetchOptions: data.fetchOptions,
1834
2448
  ...fetchProps
1835
2449
  });
1836
2450
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1837
- const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
2451
+ const records = objects.map(
2452
+ (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
2453
+ );
1838
2454
  await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1839
2455
  return new Page(query, meta, records);
1840
2456
  });
1841
2457
  }
2458
+ async summarizeTable(query, summaries, summariesFilter) {
2459
+ return __privateGet$4(this, _trace).call(this, "summarize", async () => {
2460
+ const data = query.getQueryOptions();
2461
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2462
+ const result = await summarizeTable({
2463
+ pathParams: {
2464
+ workspace: "{workspaceId}",
2465
+ dbBranchName: "{dbBranch}",
2466
+ region: "{region}",
2467
+ tableName: __privateGet$4(this, _table)
2468
+ },
2469
+ body: {
2470
+ filter: cleanFilter(data.filter),
2471
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2472
+ columns: data.columns,
2473
+ page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
2474
+ summaries,
2475
+ summariesFilter
2476
+ },
2477
+ ...fetchProps
2478
+ });
2479
+ return result;
2480
+ });
2481
+ }
1842
2482
  }
1843
2483
  _table = new WeakMap();
1844
2484
  _getFetchProps = new WeakMap();
@@ -1854,6 +2494,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1854
2494
  pathParams: {
1855
2495
  workspace: "{workspaceId}",
1856
2496
  dbBranchName: "{dbBranch}",
2497
+ region: "{region}",
1857
2498
  tableName: __privateGet$4(this, _table)
1858
2499
  },
1859
2500
  queryParams: { columns },
@@ -1861,32 +2502,38 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1861
2502
  ...fetchProps
1862
2503
  });
1863
2504
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1864
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2505
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1865
2506
  };
1866
2507
  _insertRecordWithId = new WeakSet();
1867
- insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
2508
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
1868
2509
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1869
2510
  const record = transformObjectLinks(object);
1870
2511
  const response = await insertRecordWithID({
1871
2512
  pathParams: {
1872
2513
  workspace: "{workspaceId}",
1873
2514
  dbBranchName: "{dbBranch}",
2515
+ region: "{region}",
1874
2516
  tableName: __privateGet$4(this, _table),
1875
2517
  recordId
1876
2518
  },
1877
2519
  body: record,
1878
- queryParams: { createOnly: true, columns },
2520
+ queryParams: { createOnly, columns, ifVersion },
1879
2521
  ...fetchProps
1880
2522
  });
1881
2523
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1882
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2524
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1883
2525
  };
1884
2526
  _bulkInsertTableRecords = new WeakSet();
1885
2527
  bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1886
2528
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1887
2529
  const records = objects.map((object) => transformObjectLinks(object));
1888
2530
  const response = await bulkInsertTableRecords({
1889
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2531
+ pathParams: {
2532
+ workspace: "{workspaceId}",
2533
+ dbBranchName: "{dbBranch}",
2534
+ region: "{region}",
2535
+ tableName: __privateGet$4(this, _table)
2536
+ },
1890
2537
  queryParams: { columns },
1891
2538
  body: { records },
1892
2539
  ...fetchProps
@@ -1895,21 +2542,27 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1895
2542
  throw new Error("Request included columns but server didn't include them");
1896
2543
  }
1897
2544
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1898
- return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
2545
+ return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
1899
2546
  };
1900
2547
  _updateRecordWithID = new WeakSet();
1901
- updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2548
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
1902
2549
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1903
2550
  const record = transformObjectLinks(object);
1904
2551
  try {
1905
2552
  const response = await updateRecordWithID({
1906
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1907
- queryParams: { columns },
2553
+ pathParams: {
2554
+ workspace: "{workspaceId}",
2555
+ dbBranchName: "{dbBranch}",
2556
+ region: "{region}",
2557
+ tableName: __privateGet$4(this, _table),
2558
+ recordId
2559
+ },
2560
+ queryParams: { columns, ifVersion },
1908
2561
  body: record,
1909
2562
  ...fetchProps
1910
2563
  });
1911
2564
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1912
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2565
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1913
2566
  } catch (e) {
1914
2567
  if (isObject(e) && e.status === 404) {
1915
2568
  return null;
@@ -1918,28 +2571,40 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1918
2571
  }
1919
2572
  };
1920
2573
  _upsertRecordWithID = new WeakSet();
1921
- upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2574
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
1922
2575
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1923
2576
  const response = await upsertRecordWithID({
1924
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1925
- queryParams: { columns },
2577
+ pathParams: {
2578
+ workspace: "{workspaceId}",
2579
+ dbBranchName: "{dbBranch}",
2580
+ region: "{region}",
2581
+ tableName: __privateGet$4(this, _table),
2582
+ recordId
2583
+ },
2584
+ queryParams: { columns, ifVersion },
1926
2585
  body: object,
1927
2586
  ...fetchProps
1928
2587
  });
1929
2588
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1930
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2589
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1931
2590
  };
1932
2591
  _deleteRecord = new WeakSet();
1933
2592
  deleteRecord_fn = async function(recordId, columns = ["*"]) {
1934
2593
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1935
2594
  try {
1936
2595
  const response = await deleteRecord({
1937
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2596
+ pathParams: {
2597
+ workspace: "{workspaceId}",
2598
+ dbBranchName: "{dbBranch}",
2599
+ region: "{region}",
2600
+ tableName: __privateGet$4(this, _table),
2601
+ recordId
2602
+ },
1938
2603
  queryParams: { columns },
1939
2604
  ...fetchProps
1940
2605
  });
1941
2606
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1942
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2607
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1943
2608
  } catch (e) {
1944
2609
  if (isObject(e) && e.status === 404) {
1945
2610
  return null;
@@ -1969,7 +2634,7 @@ getSchemaTables_fn$1 = async function() {
1969
2634
  return __privateGet$4(this, _schemaTables$2);
1970
2635
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1971
2636
  const { schema } = await getBranchDetails({
1972
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2637
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
1973
2638
  ...fetchProps
1974
2639
  });
1975
2640
  __privateSet$4(this, _schemaTables$2, schema.tables);
@@ -1982,7 +2647,7 @@ const transformObjectLinks = (object) => {
1982
2647
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
1983
2648
  }, {});
1984
2649
  };
1985
- const initObject = (db, schemaTables, table, object) => {
2650
+ const initObject = (db, schemaTables, table, object, selectedColumns) => {
1986
2651
  const result = {};
1987
2652
  const { xata, ...rest } = object ?? {};
1988
2653
  Object.assign(result, rest);
@@ -1990,6 +2655,8 @@ const initObject = (db, schemaTables, table, object) => {
1990
2655
  if (!columns)
1991
2656
  console.error(`Table ${table} not found in schema`);
1992
2657
  for (const column of columns ?? []) {
2658
+ if (!isValidColumn(selectedColumns, column))
2659
+ continue;
1993
2660
  const value = result[column.name];
1994
2661
  switch (column.type) {
1995
2662
  case "datetime": {
@@ -2006,7 +2673,17 @@ const initObject = (db, schemaTables, table, object) => {
2006
2673
  if (!linkTable) {
2007
2674
  console.error(`Failed to parse link for field ${column.name}`);
2008
2675
  } else if (isObject(value)) {
2009
- result[column.name] = initObject(db, schemaTables, linkTable, value);
2676
+ const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
2677
+ if (item === column.name) {
2678
+ return [...acc, "*"];
2679
+ }
2680
+ if (item.startsWith(`${column.name}.`)) {
2681
+ const [, ...path] = item.split(".");
2682
+ return [...acc, path.join(".")];
2683
+ }
2684
+ return acc;
2685
+ }, []);
2686
+ result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2010
2687
  } else {
2011
2688
  result[column.name] = null;
2012
2689
  }
@@ -2023,8 +2700,15 @@ const initObject = (db, schemaTables, table, object) => {
2023
2700
  result.read = function(columns2) {
2024
2701
  return db[table].read(result["id"], columns2);
2025
2702
  };
2026
- result.update = function(data, columns2) {
2027
- return db[table].update(result["id"], data, columns2);
2703
+ result.update = function(data, b, c) {
2704
+ const columns2 = isStringArray(b) ? b : ["*"];
2705
+ const ifVersion = parseIfVersion(b, c);
2706
+ return db[table].update(result["id"], data, columns2, { ifVersion });
2707
+ };
2708
+ result.replace = function(data, b, c) {
2709
+ const columns2 = isStringArray(b) ? b : ["*"];
2710
+ const ifVersion = parseIfVersion(b, c);
2711
+ return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
2028
2712
  };
2029
2713
  result.delete = function() {
2030
2714
  return db[table].delete(result["id"]);
@@ -2032,7 +2716,7 @@ const initObject = (db, schemaTables, table, object) => {
2032
2716
  result.getMetadata = function() {
2033
2717
  return xata;
2034
2718
  };
2035
- for (const prop of ["read", "update", "delete", "getMetadata"]) {
2719
+ for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
2036
2720
  Object.defineProperty(result, prop, { enumerable: false });
2037
2721
  }
2038
2722
  Object.freeze(result);
@@ -2048,11 +2732,22 @@ function extractId(value) {
2048
2732
  return value.id;
2049
2733
  return void 0;
2050
2734
  }
2051
- function cleanFilter(filter) {
2052
- if (!filter)
2053
- return void 0;
2054
- const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2055
- return values.length > 0 ? filter : void 0;
2735
+ function isValidColumn(columns, column) {
2736
+ if (columns.includes("*"))
2737
+ return true;
2738
+ if (column.type === "link") {
2739
+ const linkColumns = columns.filter((item) => item.startsWith(column.name));
2740
+ return linkColumns.length > 0;
2741
+ }
2742
+ return columns.includes(column.name);
2743
+ }
2744
+ function parseIfVersion(...args) {
2745
+ for (const arg of args) {
2746
+ if (isObject(arg) && isNumber(arg.ifVersion)) {
2747
+ return arg.ifVersion;
2748
+ }
2749
+ }
2750
+ return void 0;
2056
2751
  }
2057
2752
 
2058
2753
  var __accessCheck$3 = (obj, member, msg) => {
@@ -2219,7 +2914,7 @@ class SearchPlugin extends XataPlugin {
2219
2914
  const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
2220
2915
  return records.map((record) => {
2221
2916
  const { table = "orphan" } = record.xata;
2222
- return { table, record: initObject(this.db, schemaTables, table, record) };
2917
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
2223
2918
  });
2224
2919
  },
2225
2920
  byTable: async (query, options = {}) => {
@@ -2228,7 +2923,7 @@ class SearchPlugin extends XataPlugin {
2228
2923
  return records.reduce((acc, record) => {
2229
2924
  const { table = "orphan" } = record.xata;
2230
2925
  const items = acc[table] ?? [];
2231
- const item = initObject(this.db, schemaTables, table, record);
2926
+ const item = initObject(this.db, schemaTables, table, record, ["*"]);
2232
2927
  return { ...acc, [table]: [...items, item] };
2233
2928
  }, {});
2234
2929
  }
@@ -2241,7 +2936,7 @@ search_fn = async function(query, options, getFetchProps) {
2241
2936
  const fetchProps = await getFetchProps();
2242
2937
  const { tables, fuzziness, highlight, prefix } = options ?? {};
2243
2938
  const { records } = await searchBranch({
2244
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2939
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2245
2940
  body: { tables, query, fuzziness, prefix, highlight },
2246
2941
  ...fetchProps
2247
2942
  });
@@ -2253,7 +2948,7 @@ getSchemaTables_fn = async function(getFetchProps) {
2253
2948
  return __privateGet$1(this, _schemaTables);
2254
2949
  const fetchProps = await getFetchProps();
2255
2950
  const { schema } = await getBranchDetails({
2256
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2951
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2257
2952
  ...fetchProps
2258
2953
  });
2259
2954
  __privateSet$1(this, _schemaTables, schema.tables);
@@ -2291,14 +2986,17 @@ async function resolveXataBranch(gitBranch, options) {
2291
2986
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2292
2987
  );
2293
2988
  const [protocol, , host, , dbName] = databaseURL.split("/");
2294
- const [workspace] = host.split(".");
2989
+ const urlParts = parseWorkspacesUrlParts(host);
2990
+ if (!urlParts)
2991
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
2992
+ const { workspace, region } = urlParts;
2295
2993
  const { fallbackBranch } = getEnvironment();
2296
2994
  const { branch } = await resolveBranch({
2297
2995
  apiKey,
2298
2996
  apiUrl: databaseURL,
2299
2997
  fetchImpl: getFetchImplementation(options?.fetchImpl),
2300
2998
  workspacesApiUrl: `${protocol}//${host}`,
2301
- pathParams: { dbName, workspace },
2999
+ pathParams: { dbName, workspace, region },
2302
3000
  queryParams: { gitBranch, fallbackBranch },
2303
3001
  trace: defaultTrace
2304
3002
  });
@@ -2316,15 +3014,17 @@ async function getDatabaseBranch(branch, options) {
2316
3014
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2317
3015
  );
2318
3016
  const [protocol, , host, , database] = databaseURL.split("/");
2319
- const [workspace] = host.split(".");
2320
- const dbBranchName = `${database}:${branch}`;
3017
+ const urlParts = parseWorkspacesUrlParts(host);
3018
+ if (!urlParts)
3019
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3020
+ const { workspace, region } = urlParts;
2321
3021
  try {
2322
3022
  return await getBranchDetails({
2323
3023
  apiKey,
2324
3024
  apiUrl: databaseURL,
2325
3025
  fetchImpl: getFetchImplementation(options?.fetchImpl),
2326
3026
  workspacesApiUrl: `${protocol}//${host}`,
2327
- pathParams: { dbBranchName, workspace },
3027
+ pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
2328
3028
  trace: defaultTrace
2329
3029
  });
2330
3030
  } catch (err) {
@@ -2403,6 +3103,13 @@ const buildClient = (plugins) => {
2403
3103
  return { databaseURL, branch };
2404
3104
  }
2405
3105
  }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
3106
+ const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
3107
+ const isBrowser = typeof window !== "undefined";
3108
+ if (isBrowser && !enableBrowser) {
3109
+ throw new Error(
3110
+ "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."
3111
+ );
3112
+ }
2406
3113
  const fetch = getFetchImplementation(options?.fetch);
2407
3114
  const databaseURL = options?.databaseURL || getDatabaseURL();
2408
3115
  const apiKey = options?.apiKey || getAPIKey();
@@ -2415,8 +3122,8 @@ const buildClient = (plugins) => {
2415
3122
  if (!databaseURL) {
2416
3123
  throw new Error("Option databaseURL is required");
2417
3124
  }
2418
- return { fetch, databaseURL, apiKey, branch, cache, trace };
2419
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
3125
+ return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser };
3126
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
2420
3127
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2421
3128
  if (!branchValue)
2422
3129
  throw new Error("Unable to resolve branch value");
@@ -2429,7 +3136,8 @@ const buildClient = (plugins) => {
2429
3136
  const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
2430
3137
  return databaseURL + newPath;
2431
3138
  },
2432
- trace
3139
+ trace,
3140
+ clientID
2433
3141
  };
2434
3142
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2435
3143
  if (__privateGet(this, _branch))
@@ -2541,5 +3249,5 @@ class XataError extends Error {
2541
3249
  }
2542
3250
  }
2543
3251
 
2544
- export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, applyBranchSchemaEdit, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequests, listMigrationRequestsCommits, lt, lte, mergeMigrationRequest, notExists, operationsByTag, pattern, previewBranchSchemaEdit, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
3252
+ export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, branchTransaction, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, dEPRECATEDcreateDatabase, dEPRECATEDdeleteDatabase, dEPRECATEDgetDatabaseList, dEPRECATEDgetDatabaseMetadata, dEPRECATEDupdateDatabaseMetadata, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
2545
3253
  //# sourceMappingURL=index.mjs.map