@xata.io/client 0.0.0-alpha.vfc5c289 → 0.0.0-alpha.vfcd664d

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