@xata.io/client 0.18.5 → 0.19.0

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.18.5";
189
+ const VERSION = "0.19.0";
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,15 +270,18 @@ async function fetch$1({
253
270
  queryParams,
254
271
  fetchImpl,
255
272
  apiKey,
273
+ endpoint,
256
274
  apiUrl,
257
275
  workspacesApiUrl,
258
276
  trace,
259
- signal
277
+ signal,
278
+ clientID,
279
+ sessionID
260
280
  }) {
261
281
  return trace(
262
282
  `${method.toUpperCase()} ${path}`,
263
283
  async ({ setAttributes }) => {
264
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
284
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
265
285
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
266
286
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
267
287
  setAttributes({
@@ -274,6 +294,8 @@ async function fetch$1({
274
294
  headers: {
275
295
  "Content-Type": "application/json",
276
296
  "User-Agent": `Xata client-ts/${VERSION}`,
297
+ "X-Xata-Client-ID": clientID ?? "",
298
+ "X-Xata-Session-ID": sessionID ?? "",
277
299
  ...headers,
278
300
  ...hostHeader(fullUrl),
279
301
  Authorization: `Bearer ${apiKey}`
@@ -314,384 +336,359 @@ function parseUrl(url) {
314
336
  }
315
337
  }
316
338
 
317
- const getUser = (variables, signal) => fetch$1({ url: "/user", method: "get", ...variables, signal });
318
- const updateUser = (variables, signal) => fetch$1({
319
- url: "/user",
320
- method: "put",
321
- ...variables,
322
- signal
323
- });
324
- const deleteUser = (variables, signal) => fetch$1({ url: "/user", method: "delete", ...variables, signal });
325
- const getUserAPIKeys = (variables, signal) => fetch$1({
326
- url: "/user/keys",
339
+ const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
340
+
341
+ const getDatabaseList = (variables, signal) => dataPlaneFetch({
342
+ url: "/dbs",
327
343
  method: "get",
328
344
  ...variables,
329
345
  signal
330
346
  });
331
- const createUserAPIKey = (variables, signal) => fetch$1({
332
- url: "/user/keys/{keyName}",
333
- method: "post",
347
+ const getBranchList = (variables, signal) => dataPlaneFetch({
348
+ url: "/dbs/{dbName}",
349
+ method: "get",
334
350
  ...variables,
335
351
  signal
336
352
  });
337
- const deleteUserAPIKey = (variables, signal) => fetch$1({
338
- url: "/user/keys/{keyName}",
353
+ const createDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
354
+ const deleteDatabase = (variables, signal) => dataPlaneFetch({
355
+ url: "/dbs/{dbName}",
339
356
  method: "delete",
340
357
  ...variables,
341
358
  signal
342
359
  });
343
- const createWorkspace = (variables, signal) => fetch$1({
344
- url: "/workspaces",
345
- method: "post",
346
- ...variables,
347
- signal
348
- });
349
- const getWorkspacesList = (variables, signal) => fetch$1({
350
- url: "/workspaces",
351
- method: "get",
352
- ...variables,
353
- signal
354
- });
355
- const getWorkspace = (variables, signal) => fetch$1({
356
- url: "/workspaces/{workspaceId}",
360
+ const getDatabaseMetadata = (variables, signal) => dataPlaneFetch({
361
+ url: "/dbs/{dbName}/metadata",
357
362
  method: "get",
358
363
  ...variables,
359
364
  signal
360
365
  });
361
- const updateWorkspace = (variables, signal) => fetch$1({
362
- url: "/workspaces/{workspaceId}",
363
- method: "put",
364
- ...variables,
365
- signal
366
- });
367
- const deleteWorkspace = (variables, signal) => fetch$1({
368
- url: "/workspaces/{workspaceId}",
369
- method: "delete",
370
- ...variables,
371
- signal
372
- });
373
- const getWorkspaceMembersList = (variables, signal) => fetch$1({
374
- url: "/workspaces/{workspaceId}/members",
366
+ const updateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
367
+ const getBranchDetails = (variables, signal) => dataPlaneFetch({
368
+ url: "/db/{dbBranchName}",
375
369
  method: "get",
376
370
  ...variables,
377
371
  signal
378
372
  });
379
- const updateWorkspaceMemberRole = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
380
- const removeWorkspaceMember = (variables, signal) => fetch$1({
381
- url: "/workspaces/{workspaceId}/members/{userId}",
373
+ const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
374
+ const deleteBranch = (variables, signal) => dataPlaneFetch({
375
+ url: "/db/{dbBranchName}",
382
376
  method: "delete",
383
377
  ...variables,
384
378
  signal
385
379
  });
386
- const inviteWorkspaceMember = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
387
- const updateWorkspaceMemberInvite = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
388
- const cancelWorkspaceMemberInvite = (variables, signal) => fetch$1({
389
- url: "/workspaces/{workspaceId}/invites/{inviteId}",
390
- method: "delete",
380
+ const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
381
+ url: "/db/{dbBranchName}/metadata",
382
+ method: "put",
391
383
  ...variables,
392
384
  signal
393
385
  });
394
- const resendWorkspaceMemberInvite = (variables, signal) => fetch$1({
395
- url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
396
- method: "post",
386
+ const getBranchMetadata = (variables, signal) => dataPlaneFetch({
387
+ url: "/db/{dbBranchName}/metadata",
388
+ method: "get",
397
389
  ...variables,
398
390
  signal
399
391
  });
400
- const acceptWorkspaceMemberInvite = (variables, signal) => fetch$1({
401
- url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
402
- method: "post",
392
+ const getBranchStats = (variables, signal) => dataPlaneFetch({
393
+ url: "/db/{dbBranchName}/stats",
394
+ method: "get",
403
395
  ...variables,
404
396
  signal
405
397
  });
406
- const getDatabaseList = (variables, signal) => fetch$1({
407
- url: "/dbs",
398
+ const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
399
+ const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
400
+ const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
401
+ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
402
+ const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
403
+ const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
404
+ const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
405
+ const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
406
+ const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
407
+ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
408
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
408
409
  method: "get",
409
410
  ...variables,
410
411
  signal
411
412
  });
412
- const getBranchList = (variables, signal) => fetch$1({
413
- url: "/dbs/{dbName}",
414
- method: "get",
413
+ const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
414
+ const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
415
+ const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
416
+ const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
417
+ const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
418
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
419
+ method: "post",
415
420
  ...variables,
416
421
  signal
417
422
  });
418
- const createDatabase = (variables, signal) => fetch$1({
419
- url: "/dbs/{dbName}",
423
+ const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
424
+ const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
425
+ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
426
+ const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
427
+ const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
428
+ const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
429
+ const createTable = (variables, signal) => dataPlaneFetch({
430
+ url: "/db/{dbBranchName}/tables/{tableName}",
420
431
  method: "put",
421
432
  ...variables,
422
433
  signal
423
434
  });
424
- const deleteDatabase = (variables, signal) => fetch$1({
425
- url: "/dbs/{dbName}",
435
+ const deleteTable = (variables, signal) => dataPlaneFetch({
436
+ url: "/db/{dbBranchName}/tables/{tableName}",
426
437
  method: "delete",
427
438
  ...variables,
428
439
  signal
429
440
  });
430
- const getDatabaseMetadata = (variables, signal) => fetch$1({
431
- url: "/dbs/{dbName}/metadata",
441
+ const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
442
+ const getTableSchema = (variables, signal) => dataPlaneFetch({
443
+ url: "/db/{dbBranchName}/tables/{tableName}/schema",
432
444
  method: "get",
433
445
  ...variables,
434
446
  signal
435
447
  });
436
- const updateDatabaseMetadata = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
437
- const getGitBranchesMapping = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
438
- const addGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
439
- const removeGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
440
- const resolveBranch = (variables, signal) => fetch$1({
441
- url: "/dbs/{dbName}/resolveBranch",
448
+ const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
449
+ const getTableColumns = (variables, signal) => dataPlaneFetch({
450
+ url: "/db/{dbBranchName}/tables/{tableName}/columns",
442
451
  method: "get",
443
452
  ...variables,
444
453
  signal
445
454
  });
446
- const queryMigrationRequests = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
447
- const createMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
448
- const getMigrationRequest = (variables, signal) => fetch$1({
449
- url: "/dbs/{dbName}/migrations/{mrNumber}",
455
+ const addTableColumn = (variables, signal) => dataPlaneFetch(
456
+ { url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
457
+ );
458
+ const getColumn = (variables, signal) => dataPlaneFetch({
459
+ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
450
460
  method: "get",
451
461
  ...variables,
452
462
  signal
453
463
  });
454
- const updateMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
455
- const listMigrationRequestsCommits = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
456
- const compareMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
457
- const getMigrationRequestIsMerged = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
458
- const mergeMigrationRequest = (variables, signal) => fetch$1({
459
- url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
460
- method: "post",
464
+ const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
465
+ const deleteColumn = (variables, signal) => dataPlaneFetch({
466
+ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
467
+ method: "delete",
461
468
  ...variables,
462
469
  signal
463
470
  });
464
- const getBranchDetails = (variables, signal) => fetch$1({
465
- url: "/db/{dbBranchName}",
471
+ const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
472
+ const getRecord = (variables, signal) => dataPlaneFetch({
473
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
466
474
  method: "get",
467
475
  ...variables,
468
476
  signal
469
477
  });
470
- const createBranch = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
471
- const deleteBranch = (variables, signal) => fetch$1({
472
- url: "/db/{dbBranchName}",
473
- method: "delete",
474
- ...variables,
475
- signal
476
- });
477
- const updateBranchMetadata = (variables, signal) => fetch$1({
478
- url: "/db/{dbBranchName}/metadata",
479
- method: "put",
478
+ const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
479
+ const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
480
+ const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
481
+ const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
482
+ const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
483
+ const queryTable = (variables, signal) => dataPlaneFetch({
484
+ url: "/db/{dbBranchName}/tables/{tableName}/query",
485
+ method: "post",
480
486
  ...variables,
481
487
  signal
482
488
  });
483
- const getBranchMetadata = (variables, signal) => fetch$1({
484
- url: "/db/{dbBranchName}/metadata",
485
- method: "get",
489
+ const searchBranch = (variables, signal) => dataPlaneFetch({
490
+ url: "/db/{dbBranchName}/search",
491
+ method: "post",
486
492
  ...variables,
487
493
  signal
488
494
  });
489
- const getBranchMigrationHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
490
- const executeBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
491
- const getBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
492
- const compareBranchWithUserSchema = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
493
- const compareBranchSchemas = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
494
- const updateBranchSchema = (variables, signal) => fetch$1({
495
- url: "/db/{dbBranchName}/schema/update",
495
+ const searchTable = (variables, signal) => dataPlaneFetch({
496
+ url: "/db/{dbBranchName}/tables/{tableName}/search",
496
497
  method: "post",
497
498
  ...variables,
498
499
  signal
499
500
  });
500
- const previewBranchSchemaEdit = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
501
- const applyBranchSchemaEdit = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
502
- const getBranchSchemaHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
503
- const getBranchStats = (variables, signal) => fetch$1({
504
- url: "/db/{dbBranchName}/stats",
501
+ const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
502
+ const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
503
+ const operationsByTag$2 = {
504
+ database: { getDatabaseList, createDatabase, deleteDatabase, getDatabaseMetadata, updateDatabaseMetadata },
505
+ branch: {
506
+ getBranchList,
507
+ getBranchDetails,
508
+ createBranch,
509
+ deleteBranch,
510
+ updateBranchMetadata,
511
+ getBranchMetadata,
512
+ getBranchStats,
513
+ getGitBranchesMapping,
514
+ addGitBranchesEntry,
515
+ removeGitBranchesEntry,
516
+ resolveBranch
517
+ },
518
+ migrations: {
519
+ getBranchMigrationHistory,
520
+ getBranchMigrationPlan,
521
+ executeBranchMigrationPlan,
522
+ getBranchSchemaHistory,
523
+ compareBranchWithUserSchema,
524
+ compareBranchSchemas,
525
+ updateBranchSchema,
526
+ previewBranchSchemaEdit,
527
+ applyBranchSchemaEdit
528
+ },
529
+ migrationRequests: {
530
+ queryMigrationRequests,
531
+ createMigrationRequest,
532
+ getMigrationRequest,
533
+ updateMigrationRequest,
534
+ listMigrationRequestsCommits,
535
+ compareMigrationRequest,
536
+ getMigrationRequestIsMerged,
537
+ mergeMigrationRequest
538
+ },
539
+ table: {
540
+ createTable,
541
+ deleteTable,
542
+ updateTable,
543
+ getTableSchema,
544
+ setTableSchema,
545
+ getTableColumns,
546
+ addTableColumn,
547
+ getColumn,
548
+ updateColumn,
549
+ deleteColumn
550
+ },
551
+ records: {
552
+ insertRecord,
553
+ getRecord,
554
+ insertRecordWithID,
555
+ updateRecordWithID,
556
+ upsertRecordWithID,
557
+ deleteRecord,
558
+ bulkInsertTableRecords
559
+ },
560
+ searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
561
+ };
562
+
563
+ const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
564
+
565
+ const getUser = (variables, signal) => controlPlaneFetch({
566
+ url: "/user",
505
567
  method: "get",
506
568
  ...variables,
507
569
  signal
508
570
  });
509
- const createTable = (variables, signal) => fetch$1({
510
- url: "/db/{dbBranchName}/tables/{tableName}",
571
+ const updateUser = (variables, signal) => controlPlaneFetch({
572
+ url: "/user",
511
573
  method: "put",
512
574
  ...variables,
513
575
  signal
514
576
  });
515
- const deleteTable = (variables, signal) => fetch$1({
516
- url: "/db/{dbBranchName}/tables/{tableName}",
577
+ const deleteUser = (variables, signal) => controlPlaneFetch({
578
+ url: "/user",
517
579
  method: "delete",
518
580
  ...variables,
519
581
  signal
520
582
  });
521
- const updateTable = (variables, signal) => fetch$1({
522
- url: "/db/{dbBranchName}/tables/{tableName}",
523
- method: "patch",
583
+ const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
584
+ url: "/user/keys",
585
+ method: "get",
524
586
  ...variables,
525
587
  signal
526
588
  });
527
- const getTableSchema = (variables, signal) => fetch$1({
528
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
529
- method: "get",
589
+ const createUserAPIKey = (variables, signal) => controlPlaneFetch({
590
+ url: "/user/keys/{keyName}",
591
+ method: "post",
530
592
  ...variables,
531
593
  signal
532
594
  });
533
- const setTableSchema = (variables, signal) => fetch$1({
534
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
535
- method: "put",
595
+ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
596
+ url: "/user/keys/{keyName}",
597
+ method: "delete",
536
598
  ...variables,
537
599
  signal
538
600
  });
539
- const getTableColumns = (variables, signal) => fetch$1({
540
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
601
+ const getWorkspacesList = (variables, signal) => controlPlaneFetch({
602
+ url: "/workspaces",
541
603
  method: "get",
542
604
  ...variables,
543
605
  signal
544
606
  });
545
- const addTableColumn = (variables, signal) => fetch$1({
546
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
607
+ const createWorkspace = (variables, signal) => controlPlaneFetch({
608
+ url: "/workspaces",
547
609
  method: "post",
548
610
  ...variables,
549
611
  signal
550
612
  });
551
- const getColumn = (variables, signal) => fetch$1({
552
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
613
+ const getWorkspace = (variables, signal) => controlPlaneFetch({
614
+ url: "/workspaces/{workspaceId}",
553
615
  method: "get",
554
616
  ...variables,
555
617
  signal
556
618
  });
557
- const deleteColumn = (variables, signal) => fetch$1({
558
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
559
- method: "delete",
560
- ...variables,
561
- signal
562
- });
563
- const updateColumn = (variables, signal) => fetch$1({
564
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
565
- method: "patch",
619
+ const updateWorkspace = (variables, signal) => controlPlaneFetch({
620
+ url: "/workspaces/{workspaceId}",
621
+ method: "put",
566
622
  ...variables,
567
623
  signal
568
624
  });
569
- const insertRecord = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
570
- const insertRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
571
- const updateRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
572
- const upsertRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
573
- const deleteRecord = (variables, signal) => fetch$1({
574
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
625
+ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
626
+ url: "/workspaces/{workspaceId}",
575
627
  method: "delete",
576
628
  ...variables,
577
629
  signal
578
630
  });
579
- const getRecord = (variables, signal) => fetch$1({
580
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
581
- method: "get",
582
- ...variables,
583
- signal
584
- });
585
- const bulkInsertTableRecords = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
586
- const queryTable = (variables, signal) => fetch$1({
587
- url: "/db/{dbBranchName}/tables/{tableName}/query",
588
- method: "post",
589
- ...variables,
590
- signal
591
- });
592
- const searchTable = (variables, signal) => fetch$1({
593
- url: "/db/{dbBranchName}/tables/{tableName}/search",
594
- method: "post",
631
+ const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
632
+ const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
633
+ const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
634
+ url: "/workspaces/{workspaceId}/members/{userId}",
635
+ method: "delete",
595
636
  ...variables,
596
637
  signal
597
638
  });
598
- const searchBranch = (variables, signal) => fetch$1({
599
- url: "/db/{dbBranchName}/search",
600
- method: "post",
639
+ const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
640
+ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
641
+ const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
642
+ const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
643
+ const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
644
+ const cPGetDatabaseList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs", method: "get", ...variables, signal });
645
+ const cPCreateDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
646
+ const cPDeleteDatabase = (variables, signal) => controlPlaneFetch({
647
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
648
+ method: "delete",
601
649
  ...variables,
602
650
  signal
603
651
  });
604
- const summarizeTable = (variables, signal) => fetch$1({
605
- url: "/db/{dbBranchName}/tables/{tableName}/summarize",
606
- method: "post",
652
+ const cPGetCPDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
653
+ const cPUpdateCPDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
654
+ const listRegions = (variables, signal) => controlPlaneFetch({
655
+ url: "/workspaces/{workspaceId}/regions",
656
+ method: "get",
607
657
  ...variables,
608
658
  signal
609
659
  });
610
- const operationsByTag = {
611
- users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
660
+ const operationsByTag$1 = {
661
+ users: { getUser, updateUser, deleteUser },
662
+ authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
612
663
  workspaces: {
613
- createWorkspace,
614
664
  getWorkspacesList,
665
+ createWorkspace,
615
666
  getWorkspace,
616
667
  updateWorkspace,
617
668
  deleteWorkspace,
618
669
  getWorkspaceMembersList,
619
670
  updateWorkspaceMemberRole,
620
- removeWorkspaceMember,
671
+ removeWorkspaceMember
672
+ },
673
+ invites: {
621
674
  inviteWorkspaceMember,
622
675
  updateWorkspaceMemberInvite,
623
676
  cancelWorkspaceMemberInvite,
624
- resendWorkspaceMemberInvite,
625
- acceptWorkspaceMemberInvite
626
- },
627
- database: {
628
- getDatabaseList,
629
- createDatabase,
630
- deleteDatabase,
631
- getDatabaseMetadata,
632
- updateDatabaseMetadata,
633
- getGitBranchesMapping,
634
- addGitBranchesEntry,
635
- removeGitBranchesEntry,
636
- resolveBranch
637
- },
638
- branch: {
639
- getBranchList,
640
- getBranchDetails,
641
- createBranch,
642
- deleteBranch,
643
- updateBranchMetadata,
644
- getBranchMetadata,
645
- getBranchStats
646
- },
647
- migrationRequests: {
648
- queryMigrationRequests,
649
- createMigrationRequest,
650
- getMigrationRequest,
651
- updateMigrationRequest,
652
- listMigrationRequestsCommits,
653
- compareMigrationRequest,
654
- getMigrationRequestIsMerged,
655
- mergeMigrationRequest
656
- },
657
- branchSchema: {
658
- getBranchMigrationHistory,
659
- executeBranchMigrationPlan,
660
- getBranchMigrationPlan,
661
- compareBranchWithUserSchema,
662
- compareBranchSchemas,
663
- updateBranchSchema,
664
- previewBranchSchemaEdit,
665
- applyBranchSchemaEdit,
666
- getBranchSchemaHistory
677
+ acceptWorkspaceMemberInvite,
678
+ resendWorkspaceMemberInvite
667
679
  },
668
- table: {
669
- createTable,
670
- deleteTable,
671
- updateTable,
672
- getTableSchema,
673
- setTableSchema,
674
- getTableColumns,
675
- addTableColumn,
676
- getColumn,
677
- deleteColumn,
678
- updateColumn
679
- },
680
- records: {
681
- insertRecord,
682
- insertRecordWithID,
683
- updateRecordWithID,
684
- upsertRecordWithID,
685
- deleteRecord,
686
- getRecord,
687
- bulkInsertTableRecords,
688
- queryTable,
689
- searchTable,
690
- searchBranch,
691
- summarizeTable
680
+ databases: {
681
+ cPGetDatabaseList,
682
+ cPCreateDatabase,
683
+ cPDeleteDatabase,
684
+ cPGetCPDatabaseMetadata,
685
+ cPUpdateCPDatabaseMetadata,
686
+ listRegions
692
687
  }
693
688
  };
694
689
 
690
+ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
691
+
695
692
  function getHostUrl(provider, type) {
696
693
  if (isHostProviderAlias(provider)) {
697
694
  return providers[provider][type];
@@ -703,11 +700,11 @@ function getHostUrl(provider, type) {
703
700
  const providers = {
704
701
  production: {
705
702
  main: "https://api.xata.io",
706
- workspaces: "https://{workspaceId}.xata.sh"
703
+ workspaces: "https://{workspaceId}.{region}.xata.sh"
707
704
  },
708
705
  staging: {
709
706
  main: "https://staging.xatabase.co",
710
- workspaces: "https://{workspaceId}.staging.xatabase.co"
707
+ workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
711
708
  }
712
709
  };
713
710
  function isHostProviderAlias(alias) {
@@ -716,6 +713,25 @@ function isHostProviderAlias(alias) {
716
713
  function isHostProviderBuilder(builder) {
717
714
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
718
715
  }
716
+ function parseProviderString(provider = "production") {
717
+ if (isHostProviderAlias(provider)) {
718
+ return provider;
719
+ }
720
+ const [main, workspaces] = provider.split(",");
721
+ if (!main || !workspaces)
722
+ return null;
723
+ return { main, workspaces };
724
+ }
725
+ function parseWorkspacesUrlParts(url) {
726
+ if (!isString(url))
727
+ return null;
728
+ const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
729
+ const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
730
+ const match = url.match(regex) || url.match(regexStaging);
731
+ if (!match)
732
+ return null;
733
+ return { workspace: match[1], region: match[2] ?? "eu-west-1" };
734
+ }
719
735
 
720
736
  var __accessCheck$7 = (obj, member, msg) => {
721
737
  if (!member.has(obj))
@@ -759,21 +775,41 @@ class XataApiClient {
759
775
  __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
760
776
  return __privateGet$7(this, _namespaces).user;
761
777
  }
778
+ get authentication() {
779
+ if (!__privateGet$7(this, _namespaces).authentication)
780
+ __privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
781
+ return __privateGet$7(this, _namespaces).authentication;
782
+ }
762
783
  get workspaces() {
763
784
  if (!__privateGet$7(this, _namespaces).workspaces)
764
785
  __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
765
786
  return __privateGet$7(this, _namespaces).workspaces;
766
787
  }
767
- get databases() {
768
- if (!__privateGet$7(this, _namespaces).databases)
769
- __privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
770
- return __privateGet$7(this, _namespaces).databases;
788
+ get invites() {
789
+ if (!__privateGet$7(this, _namespaces).invites)
790
+ __privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
791
+ return __privateGet$7(this, _namespaces).invites;
792
+ }
793
+ get database() {
794
+ if (!__privateGet$7(this, _namespaces).database)
795
+ __privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
796
+ return __privateGet$7(this, _namespaces).database;
771
797
  }
772
798
  get branches() {
773
799
  if (!__privateGet$7(this, _namespaces).branches)
774
800
  __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
775
801
  return __privateGet$7(this, _namespaces).branches;
776
802
  }
803
+ get migrations() {
804
+ if (!__privateGet$7(this, _namespaces).migrations)
805
+ __privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
806
+ return __privateGet$7(this, _namespaces).migrations;
807
+ }
808
+ get migrationRequests() {
809
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
810
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
811
+ return __privateGet$7(this, _namespaces).migrationRequests;
812
+ }
777
813
  get tables() {
778
814
  if (!__privateGet$7(this, _namespaces).tables)
779
815
  __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
@@ -784,15 +820,10 @@ class XataApiClient {
784
820
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
785
821
  return __privateGet$7(this, _namespaces).records;
786
822
  }
787
- get migrationRequests() {
788
- if (!__privateGet$7(this, _namespaces).migrationRequests)
789
- __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
790
- return __privateGet$7(this, _namespaces).migrationRequests;
791
- }
792
- get branchSchema() {
793
- if (!__privateGet$7(this, _namespaces).branchSchema)
794
- __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
795
- return __privateGet$7(this, _namespaces).branchSchema;
823
+ get searchAndFilter() {
824
+ if (!__privateGet$7(this, _namespaces).searchAndFilter)
825
+ __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
826
+ return __privateGet$7(this, _namespaces).searchAndFilter;
796
827
  }
797
828
  }
798
829
  _extraProps = new WeakMap();
@@ -804,24 +835,29 @@ class UserApi {
804
835
  getUser() {
805
836
  return operationsByTag.users.getUser({ ...this.extraProps });
806
837
  }
807
- updateUser(user) {
838
+ updateUser({ user }) {
808
839
  return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
809
840
  }
810
841
  deleteUser() {
811
842
  return operationsByTag.users.deleteUser({ ...this.extraProps });
812
843
  }
844
+ }
845
+ class AuthenticationApi {
846
+ constructor(extraProps) {
847
+ this.extraProps = extraProps;
848
+ }
813
849
  getUserAPIKeys() {
814
- return operationsByTag.users.getUserAPIKeys({ ...this.extraProps });
850
+ return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
815
851
  }
816
- createUserAPIKey(keyName) {
817
- return operationsByTag.users.createUserAPIKey({
818
- pathParams: { keyName },
852
+ createUserAPIKey({ name }) {
853
+ return operationsByTag.authentication.createUserAPIKey({
854
+ pathParams: { keyName: name },
819
855
  ...this.extraProps
820
856
  });
821
857
  }
822
- deleteUserAPIKey(keyName) {
823
- return operationsByTag.users.deleteUserAPIKey({
824
- pathParams: { keyName },
858
+ deleteUserAPIKey({ name }) {
859
+ return operationsByTag.authentication.deleteUserAPIKey({
860
+ pathParams: { keyName: name },
825
861
  ...this.extraProps
826
862
  });
827
863
  }
@@ -830,196 +866,248 @@ class WorkspaceApi {
830
866
  constructor(extraProps) {
831
867
  this.extraProps = extraProps;
832
868
  }
833
- createWorkspace(workspaceMeta) {
869
+ getWorkspacesList() {
870
+ return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
871
+ }
872
+ createWorkspace({ data }) {
834
873
  return operationsByTag.workspaces.createWorkspace({
835
- body: workspaceMeta,
874
+ body: data,
836
875
  ...this.extraProps
837
876
  });
838
877
  }
839
- getWorkspacesList() {
840
- return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
841
- }
842
- getWorkspace(workspaceId) {
878
+ getWorkspace({ workspace }) {
843
879
  return operationsByTag.workspaces.getWorkspace({
844
- pathParams: { workspaceId },
880
+ pathParams: { workspaceId: workspace },
845
881
  ...this.extraProps
846
882
  });
847
883
  }
848
- updateWorkspace(workspaceId, workspaceMeta) {
884
+ updateWorkspace({
885
+ workspace,
886
+ update
887
+ }) {
849
888
  return operationsByTag.workspaces.updateWorkspace({
850
- pathParams: { workspaceId },
851
- body: workspaceMeta,
889
+ pathParams: { workspaceId: workspace },
890
+ body: update,
852
891
  ...this.extraProps
853
892
  });
854
893
  }
855
- deleteWorkspace(workspaceId) {
894
+ deleteWorkspace({ workspace }) {
856
895
  return operationsByTag.workspaces.deleteWorkspace({
857
- pathParams: { workspaceId },
896
+ pathParams: { workspaceId: workspace },
858
897
  ...this.extraProps
859
898
  });
860
899
  }
861
- getWorkspaceMembersList(workspaceId) {
900
+ getWorkspaceMembersList({ workspace }) {
862
901
  return operationsByTag.workspaces.getWorkspaceMembersList({
863
- pathParams: { workspaceId },
902
+ pathParams: { workspaceId: workspace },
864
903
  ...this.extraProps
865
904
  });
866
905
  }
867
- updateWorkspaceMemberRole(workspaceId, userId, role) {
906
+ updateWorkspaceMemberRole({
907
+ workspace,
908
+ user,
909
+ role
910
+ }) {
868
911
  return operationsByTag.workspaces.updateWorkspaceMemberRole({
869
- pathParams: { workspaceId, userId },
912
+ pathParams: { workspaceId: workspace, userId: user },
870
913
  body: { role },
871
914
  ...this.extraProps
872
915
  });
873
916
  }
874
- removeWorkspaceMember(workspaceId, userId) {
917
+ removeWorkspaceMember({
918
+ workspace,
919
+ user
920
+ }) {
875
921
  return operationsByTag.workspaces.removeWorkspaceMember({
876
- pathParams: { workspaceId, userId },
922
+ pathParams: { workspaceId: workspace, userId: user },
877
923
  ...this.extraProps
878
924
  });
879
925
  }
880
- inviteWorkspaceMember(workspaceId, email, role) {
881
- return operationsByTag.workspaces.inviteWorkspaceMember({
882
- pathParams: { workspaceId },
926
+ }
927
+ class InvitesApi {
928
+ constructor(extraProps) {
929
+ this.extraProps = extraProps;
930
+ }
931
+ inviteWorkspaceMember({
932
+ workspace,
933
+ email,
934
+ role
935
+ }) {
936
+ return operationsByTag.invites.inviteWorkspaceMember({
937
+ pathParams: { workspaceId: workspace },
883
938
  body: { email, role },
884
939
  ...this.extraProps
885
940
  });
886
941
  }
887
- updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
888
- return operationsByTag.workspaces.updateWorkspaceMemberInvite({
889
- pathParams: { workspaceId, inviteId },
942
+ updateWorkspaceMemberInvite({
943
+ workspace,
944
+ invite,
945
+ role
946
+ }) {
947
+ return operationsByTag.invites.updateWorkspaceMemberInvite({
948
+ pathParams: { workspaceId: workspace, inviteId: invite },
890
949
  body: { role },
891
950
  ...this.extraProps
892
951
  });
893
952
  }
894
- cancelWorkspaceMemberInvite(workspaceId, inviteId) {
895
- return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
896
- pathParams: { workspaceId, inviteId },
953
+ cancelWorkspaceMemberInvite({
954
+ workspace,
955
+ invite
956
+ }) {
957
+ return operationsByTag.invites.cancelWorkspaceMemberInvite({
958
+ pathParams: { workspaceId: workspace, inviteId: invite },
897
959
  ...this.extraProps
898
960
  });
899
961
  }
900
- resendWorkspaceMemberInvite(workspaceId, inviteId) {
901
- return operationsByTag.workspaces.resendWorkspaceMemberInvite({
902
- pathParams: { workspaceId, inviteId },
962
+ acceptWorkspaceMemberInvite({
963
+ workspace,
964
+ key
965
+ }) {
966
+ return operationsByTag.invites.acceptWorkspaceMemberInvite({
967
+ pathParams: { workspaceId: workspace, inviteKey: key },
903
968
  ...this.extraProps
904
969
  });
905
970
  }
906
- acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
907
- return operationsByTag.workspaces.acceptWorkspaceMemberInvite({
908
- pathParams: { workspaceId, inviteKey },
971
+ resendWorkspaceMemberInvite({
972
+ workspace,
973
+ invite
974
+ }) {
975
+ return operationsByTag.invites.resendWorkspaceMemberInvite({
976
+ pathParams: { workspaceId: workspace, inviteId: invite },
909
977
  ...this.extraProps
910
978
  });
911
979
  }
912
980
  }
913
- class DatabaseApi {
981
+ class BranchApi {
914
982
  constructor(extraProps) {
915
983
  this.extraProps = extraProps;
916
984
  }
917
- getDatabaseList(workspace) {
918
- return operationsByTag.database.getDatabaseList({
919
- pathParams: { workspace },
920
- ...this.extraProps
921
- });
922
- }
923
- createDatabase(workspace, dbName, options = {}) {
924
- return operationsByTag.database.createDatabase({
925
- pathParams: { workspace, dbName },
926
- body: options,
927
- ...this.extraProps
928
- });
929
- }
930
- deleteDatabase(workspace, dbName) {
931
- return operationsByTag.database.deleteDatabase({
932
- pathParams: { workspace, dbName },
933
- ...this.extraProps
934
- });
935
- }
936
- getDatabaseMetadata(workspace, dbName) {
937
- return operationsByTag.database.getDatabaseMetadata({
938
- pathParams: { workspace, dbName },
939
- ...this.extraProps
940
- });
941
- }
942
- updateDatabaseMetadata(workspace, dbName, options = {}) {
943
- return operationsByTag.database.updateDatabaseMetadata({
944
- pathParams: { workspace, dbName },
945
- body: options,
946
- ...this.extraProps
947
- });
948
- }
949
- getGitBranchesMapping(workspace, dbName) {
950
- return operationsByTag.database.getGitBranchesMapping({
951
- pathParams: { workspace, dbName },
985
+ getBranchList({
986
+ workspace,
987
+ region,
988
+ database
989
+ }) {
990
+ return operationsByTag.branch.getBranchList({
991
+ pathParams: { workspace, region, dbName: database },
952
992
  ...this.extraProps
953
993
  });
954
994
  }
955
- addGitBranchesEntry(workspace, dbName, body) {
956
- return operationsByTag.database.addGitBranchesEntry({
957
- pathParams: { workspace, dbName },
958
- body,
995
+ getBranchDetails({
996
+ workspace,
997
+ region,
998
+ database,
999
+ branch
1000
+ }) {
1001
+ return operationsByTag.branch.getBranchDetails({
1002
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
959
1003
  ...this.extraProps
960
1004
  });
961
1005
  }
962
- removeGitBranchesEntry(workspace, dbName, gitBranch) {
963
- return operationsByTag.database.removeGitBranchesEntry({
964
- pathParams: { workspace, dbName },
965
- queryParams: { gitBranch },
1006
+ createBranch({
1007
+ workspace,
1008
+ region,
1009
+ database,
1010
+ branch,
1011
+ from,
1012
+ metadata
1013
+ }) {
1014
+ return operationsByTag.branch.createBranch({
1015
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1016
+ body: { from, metadata },
966
1017
  ...this.extraProps
967
1018
  });
968
1019
  }
969
- resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
970
- return operationsByTag.database.resolveBranch({
971
- pathParams: { workspace, dbName },
972
- queryParams: { gitBranch, fallbackBranch },
1020
+ deleteBranch({
1021
+ workspace,
1022
+ region,
1023
+ database,
1024
+ branch
1025
+ }) {
1026
+ return operationsByTag.branch.deleteBranch({
1027
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
973
1028
  ...this.extraProps
974
1029
  });
975
1030
  }
976
- }
977
- class BranchApi {
978
- constructor(extraProps) {
979
- this.extraProps = extraProps;
980
- }
981
- getBranchList(workspace, dbName) {
982
- return operationsByTag.branch.getBranchList({
983
- pathParams: { workspace, dbName },
1031
+ updateBranchMetadata({
1032
+ workspace,
1033
+ region,
1034
+ database,
1035
+ branch,
1036
+ metadata
1037
+ }) {
1038
+ return operationsByTag.branch.updateBranchMetadata({
1039
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1040
+ body: metadata,
984
1041
  ...this.extraProps
985
1042
  });
986
1043
  }
987
- getBranchDetails(workspace, database, branch) {
988
- return operationsByTag.branch.getBranchDetails({
989
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1044
+ getBranchMetadata({
1045
+ workspace,
1046
+ region,
1047
+ database,
1048
+ branch
1049
+ }) {
1050
+ return operationsByTag.branch.getBranchMetadata({
1051
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
990
1052
  ...this.extraProps
991
1053
  });
992
1054
  }
993
- createBranch(workspace, database, branch, from, options = {}) {
994
- return operationsByTag.branch.createBranch({
995
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
996
- queryParams: isString(from) ? { from } : void 0,
997
- body: options,
1055
+ getBranchStats({
1056
+ workspace,
1057
+ region,
1058
+ database,
1059
+ branch
1060
+ }) {
1061
+ return operationsByTag.branch.getBranchStats({
1062
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
998
1063
  ...this.extraProps
999
1064
  });
1000
1065
  }
1001
- deleteBranch(workspace, database, branch) {
1002
- return operationsByTag.branch.deleteBranch({
1003
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1066
+ getGitBranchesMapping({
1067
+ workspace,
1068
+ region,
1069
+ database
1070
+ }) {
1071
+ return operationsByTag.branch.getGitBranchesMapping({
1072
+ pathParams: { workspace, region, dbName: database },
1004
1073
  ...this.extraProps
1005
1074
  });
1006
1075
  }
1007
- updateBranchMetadata(workspace, database, branch, metadata = {}) {
1008
- return operationsByTag.branch.updateBranchMetadata({
1009
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1010
- body: metadata,
1076
+ addGitBranchesEntry({
1077
+ workspace,
1078
+ region,
1079
+ database,
1080
+ gitBranch,
1081
+ xataBranch
1082
+ }) {
1083
+ return operationsByTag.branch.addGitBranchesEntry({
1084
+ pathParams: { workspace, region, dbName: database },
1085
+ body: { gitBranch, xataBranch },
1011
1086
  ...this.extraProps
1012
1087
  });
1013
1088
  }
1014
- getBranchMetadata(workspace, database, branch) {
1015
- return operationsByTag.branch.getBranchMetadata({
1016
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1089
+ removeGitBranchesEntry({
1090
+ workspace,
1091
+ region,
1092
+ database,
1093
+ gitBranch
1094
+ }) {
1095
+ return operationsByTag.branch.removeGitBranchesEntry({
1096
+ pathParams: { workspace, region, dbName: database },
1097
+ queryParams: { gitBranch },
1017
1098
  ...this.extraProps
1018
1099
  });
1019
1100
  }
1020
- getBranchStats(workspace, database, branch) {
1021
- return operationsByTag.branch.getBranchStats({
1022
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1101
+ resolveBranch({
1102
+ workspace,
1103
+ region,
1104
+ database,
1105
+ gitBranch,
1106
+ fallbackBranch
1107
+ }) {
1108
+ return operationsByTag.branch.resolveBranch({
1109
+ pathParams: { workspace, region, dbName: database },
1110
+ queryParams: { gitBranch, fallbackBranch },
1023
1111
  ...this.extraProps
1024
1112
  });
1025
1113
  }
@@ -1028,67 +1116,134 @@ class TableApi {
1028
1116
  constructor(extraProps) {
1029
1117
  this.extraProps = extraProps;
1030
1118
  }
1031
- createTable(workspace, database, branch, tableName) {
1119
+ createTable({
1120
+ workspace,
1121
+ region,
1122
+ database,
1123
+ branch,
1124
+ table
1125
+ }) {
1032
1126
  return operationsByTag.table.createTable({
1033
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1127
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1034
1128
  ...this.extraProps
1035
1129
  });
1036
1130
  }
1037
- deleteTable(workspace, database, branch, tableName) {
1131
+ deleteTable({
1132
+ workspace,
1133
+ region,
1134
+ database,
1135
+ branch,
1136
+ table
1137
+ }) {
1038
1138
  return operationsByTag.table.deleteTable({
1039
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1139
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1040
1140
  ...this.extraProps
1041
1141
  });
1042
1142
  }
1043
- updateTable(workspace, database, branch, tableName, options) {
1143
+ updateTable({
1144
+ workspace,
1145
+ region,
1146
+ database,
1147
+ branch,
1148
+ table,
1149
+ update
1150
+ }) {
1044
1151
  return operationsByTag.table.updateTable({
1045
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1046
- body: options,
1152
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1153
+ body: update,
1047
1154
  ...this.extraProps
1048
1155
  });
1049
1156
  }
1050
- getTableSchema(workspace, database, branch, tableName) {
1157
+ getTableSchema({
1158
+ workspace,
1159
+ region,
1160
+ database,
1161
+ branch,
1162
+ table
1163
+ }) {
1051
1164
  return operationsByTag.table.getTableSchema({
1052
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1165
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1053
1166
  ...this.extraProps
1054
1167
  });
1055
1168
  }
1056
- setTableSchema(workspace, database, branch, tableName, options) {
1169
+ setTableSchema({
1170
+ workspace,
1171
+ region,
1172
+ database,
1173
+ branch,
1174
+ table,
1175
+ schema
1176
+ }) {
1057
1177
  return operationsByTag.table.setTableSchema({
1058
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1059
- body: options,
1178
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1179
+ body: schema,
1060
1180
  ...this.extraProps
1061
1181
  });
1062
1182
  }
1063
- getTableColumns(workspace, database, branch, tableName) {
1183
+ getTableColumns({
1184
+ workspace,
1185
+ region,
1186
+ database,
1187
+ branch,
1188
+ table
1189
+ }) {
1064
1190
  return operationsByTag.table.getTableColumns({
1065
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1191
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1066
1192
  ...this.extraProps
1067
1193
  });
1068
1194
  }
1069
- addTableColumn(workspace, database, branch, tableName, column) {
1195
+ addTableColumn({
1196
+ workspace,
1197
+ region,
1198
+ database,
1199
+ branch,
1200
+ table,
1201
+ column
1202
+ }) {
1070
1203
  return operationsByTag.table.addTableColumn({
1071
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1204
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1072
1205
  body: column,
1073
1206
  ...this.extraProps
1074
1207
  });
1075
1208
  }
1076
- getColumn(workspace, database, branch, tableName, columnName) {
1209
+ getColumn({
1210
+ workspace,
1211
+ region,
1212
+ database,
1213
+ branch,
1214
+ table,
1215
+ column
1216
+ }) {
1077
1217
  return operationsByTag.table.getColumn({
1078
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1218
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1079
1219
  ...this.extraProps
1080
1220
  });
1081
1221
  }
1082
- deleteColumn(workspace, database, branch, tableName, columnName) {
1083
- return operationsByTag.table.deleteColumn({
1084
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1222
+ updateColumn({
1223
+ workspace,
1224
+ region,
1225
+ database,
1226
+ branch,
1227
+ table,
1228
+ column,
1229
+ update
1230
+ }) {
1231
+ return operationsByTag.table.updateColumn({
1232
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1233
+ body: update,
1085
1234
  ...this.extraProps
1086
1235
  });
1087
1236
  }
1088
- updateColumn(workspace, database, branch, tableName, columnName, options) {
1089
- return operationsByTag.table.updateColumn({
1090
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1091
- body: options,
1237
+ deleteColumn({
1238
+ workspace,
1239
+ region,
1240
+ database,
1241
+ branch,
1242
+ table,
1243
+ column
1244
+ }) {
1245
+ return operationsByTag.table.deleteColumn({
1246
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1092
1247
  ...this.extraProps
1093
1248
  });
1094
1249
  }
@@ -1097,85 +1252,213 @@ class RecordsApi {
1097
1252
  constructor(extraProps) {
1098
1253
  this.extraProps = extraProps;
1099
1254
  }
1100
- insertRecord(workspace, database, branch, tableName, record, options = {}) {
1255
+ insertRecord({
1256
+ workspace,
1257
+ region,
1258
+ database,
1259
+ branch,
1260
+ table,
1261
+ record,
1262
+ columns
1263
+ }) {
1101
1264
  return operationsByTag.records.insertRecord({
1102
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1103
- queryParams: options,
1265
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1266
+ queryParams: { columns },
1104
1267
  body: record,
1105
1268
  ...this.extraProps
1106
1269
  });
1107
1270
  }
1108
- insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1271
+ getRecord({
1272
+ workspace,
1273
+ region,
1274
+ database,
1275
+ branch,
1276
+ table,
1277
+ id,
1278
+ columns
1279
+ }) {
1280
+ return operationsByTag.records.getRecord({
1281
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1282
+ queryParams: { columns },
1283
+ ...this.extraProps
1284
+ });
1285
+ }
1286
+ insertRecordWithID({
1287
+ workspace,
1288
+ region,
1289
+ database,
1290
+ branch,
1291
+ table,
1292
+ id,
1293
+ record,
1294
+ columns,
1295
+ createOnly,
1296
+ ifVersion
1297
+ }) {
1109
1298
  return operationsByTag.records.insertRecordWithID({
1110
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1111
- queryParams: options,
1299
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1300
+ queryParams: { columns, createOnly, ifVersion },
1112
1301
  body: record,
1113
1302
  ...this.extraProps
1114
1303
  });
1115
1304
  }
1116
- updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1305
+ updateRecordWithID({
1306
+ workspace,
1307
+ region,
1308
+ database,
1309
+ branch,
1310
+ table,
1311
+ id,
1312
+ record,
1313
+ columns,
1314
+ ifVersion
1315
+ }) {
1117
1316
  return operationsByTag.records.updateRecordWithID({
1118
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1119
- queryParams: options,
1317
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1318
+ queryParams: { columns, ifVersion },
1120
1319
  body: record,
1121
1320
  ...this.extraProps
1122
1321
  });
1123
1322
  }
1124
- upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
1323
+ upsertRecordWithID({
1324
+ workspace,
1325
+ region,
1326
+ database,
1327
+ branch,
1328
+ table,
1329
+ id,
1330
+ record,
1331
+ columns,
1332
+ ifVersion
1333
+ }) {
1125
1334
  return operationsByTag.records.upsertRecordWithID({
1126
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1127
- queryParams: options,
1335
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1336
+ queryParams: { columns, ifVersion },
1128
1337
  body: record,
1129
1338
  ...this.extraProps
1130
1339
  });
1131
1340
  }
1132
- deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
1341
+ deleteRecord({
1342
+ workspace,
1343
+ region,
1344
+ database,
1345
+ branch,
1346
+ table,
1347
+ id,
1348
+ columns
1349
+ }) {
1133
1350
  return operationsByTag.records.deleteRecord({
1134
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1135
- queryParams: options,
1136
- ...this.extraProps
1137
- });
1138
- }
1139
- getRecord(workspace, database, branch, tableName, recordId, options = {}) {
1140
- return operationsByTag.records.getRecord({
1141
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1142
- queryParams: options,
1351
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1352
+ queryParams: { columns },
1143
1353
  ...this.extraProps
1144
1354
  });
1145
1355
  }
1146
- bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
1356
+ bulkInsertTableRecords({
1357
+ workspace,
1358
+ region,
1359
+ database,
1360
+ branch,
1361
+ table,
1362
+ records,
1363
+ columns
1364
+ }) {
1147
1365
  return operationsByTag.records.bulkInsertTableRecords({
1148
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1149
- queryParams: options,
1366
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1367
+ queryParams: { columns },
1150
1368
  body: { records },
1151
1369
  ...this.extraProps
1152
1370
  });
1153
1371
  }
1154
- queryTable(workspace, database, branch, tableName, query) {
1155
- return operationsByTag.records.queryTable({
1156
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1157
- body: query,
1158
- ...this.extraProps
1159
- });
1160
- }
1161
- searchTable(workspace, database, branch, tableName, query) {
1162
- return operationsByTag.records.searchTable({
1163
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1164
- body: query,
1165
- ...this.extraProps
1166
- });
1167
- }
1168
- searchBranch(workspace, database, branch, query) {
1169
- return operationsByTag.records.searchBranch({
1170
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1171
- body: query,
1172
- ...this.extraProps
1173
- });
1372
+ }
1373
+ class SearchAndFilterApi {
1374
+ constructor(extraProps) {
1375
+ this.extraProps = extraProps;
1174
1376
  }
1175
- summarizeTable(workspace, database, branch, tableName, query) {
1176
- return operationsByTag.records.summarizeTable({
1177
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1178
- body: query,
1377
+ queryTable({
1378
+ workspace,
1379
+ region,
1380
+ database,
1381
+ branch,
1382
+ table,
1383
+ filter,
1384
+ sort,
1385
+ page,
1386
+ columns
1387
+ }) {
1388
+ return operationsByTag.searchAndFilter.queryTable({
1389
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1390
+ body: { filter, sort, page, columns },
1391
+ ...this.extraProps
1392
+ });
1393
+ }
1394
+ searchTable({
1395
+ workspace,
1396
+ region,
1397
+ database,
1398
+ branch,
1399
+ table,
1400
+ query,
1401
+ fuzziness,
1402
+ target,
1403
+ prefix,
1404
+ filter,
1405
+ highlight,
1406
+ boosters
1407
+ }) {
1408
+ return operationsByTag.searchAndFilter.searchTable({
1409
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1410
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
1411
+ ...this.extraProps
1412
+ });
1413
+ }
1414
+ searchBranch({
1415
+ workspace,
1416
+ region,
1417
+ database,
1418
+ branch,
1419
+ tables,
1420
+ query,
1421
+ fuzziness,
1422
+ prefix,
1423
+ highlight
1424
+ }) {
1425
+ return operationsByTag.searchAndFilter.searchBranch({
1426
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1427
+ body: { tables, query, fuzziness, prefix, highlight },
1428
+ ...this.extraProps
1429
+ });
1430
+ }
1431
+ summarizeTable({
1432
+ workspace,
1433
+ region,
1434
+ database,
1435
+ branch,
1436
+ table,
1437
+ filter,
1438
+ columns,
1439
+ summaries,
1440
+ sort,
1441
+ summariesFilter,
1442
+ page
1443
+ }) {
1444
+ return operationsByTag.searchAndFilter.summarizeTable({
1445
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1446
+ body: { filter, columns, summaries, sort, summariesFilter, page },
1447
+ ...this.extraProps
1448
+ });
1449
+ }
1450
+ aggregateTable({
1451
+ workspace,
1452
+ region,
1453
+ database,
1454
+ branch,
1455
+ table,
1456
+ filter,
1457
+ aggs
1458
+ }) {
1459
+ return operationsByTag.searchAndFilter.aggregateTable({
1460
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1461
+ body: { filter, aggs },
1179
1462
  ...this.extraProps
1180
1463
  });
1181
1464
  }
@@ -1184,123 +1467,281 @@ class MigrationRequestsApi {
1184
1467
  constructor(extraProps) {
1185
1468
  this.extraProps = extraProps;
1186
1469
  }
1187
- queryMigrationRequests(workspace, database, options = {}) {
1470
+ queryMigrationRequests({
1471
+ workspace,
1472
+ region,
1473
+ database,
1474
+ filter,
1475
+ sort,
1476
+ page,
1477
+ columns
1478
+ }) {
1188
1479
  return operationsByTag.migrationRequests.queryMigrationRequests({
1189
- pathParams: { workspace, dbName: database },
1190
- body: options,
1480
+ pathParams: { workspace, region, dbName: database },
1481
+ body: { filter, sort, page, columns },
1191
1482
  ...this.extraProps
1192
1483
  });
1193
1484
  }
1194
- createMigrationRequest(workspace, database, options) {
1485
+ createMigrationRequest({
1486
+ workspace,
1487
+ region,
1488
+ database,
1489
+ migration
1490
+ }) {
1195
1491
  return operationsByTag.migrationRequests.createMigrationRequest({
1196
- pathParams: { workspace, dbName: database },
1197
- body: options,
1492
+ pathParams: { workspace, region, dbName: database },
1493
+ body: migration,
1198
1494
  ...this.extraProps
1199
1495
  });
1200
1496
  }
1201
- getMigrationRequest(workspace, database, migrationRequest) {
1497
+ getMigrationRequest({
1498
+ workspace,
1499
+ region,
1500
+ database,
1501
+ migrationRequest
1502
+ }) {
1202
1503
  return operationsByTag.migrationRequests.getMigrationRequest({
1203
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1504
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1204
1505
  ...this.extraProps
1205
1506
  });
1206
1507
  }
1207
- updateMigrationRequest(workspace, database, migrationRequest, options) {
1508
+ updateMigrationRequest({
1509
+ workspace,
1510
+ region,
1511
+ database,
1512
+ migrationRequest,
1513
+ update
1514
+ }) {
1208
1515
  return operationsByTag.migrationRequests.updateMigrationRequest({
1209
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1210
- body: options,
1516
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1517
+ body: update,
1211
1518
  ...this.extraProps
1212
1519
  });
1213
1520
  }
1214
- listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1521
+ listMigrationRequestsCommits({
1522
+ workspace,
1523
+ region,
1524
+ database,
1525
+ migrationRequest,
1526
+ page
1527
+ }) {
1215
1528
  return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1216
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1217
- body: options,
1529
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1530
+ body: { page },
1218
1531
  ...this.extraProps
1219
1532
  });
1220
1533
  }
1221
- compareMigrationRequest(workspace, database, migrationRequest) {
1534
+ compareMigrationRequest({
1535
+ workspace,
1536
+ region,
1537
+ database,
1538
+ migrationRequest
1539
+ }) {
1222
1540
  return operationsByTag.migrationRequests.compareMigrationRequest({
1223
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1541
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1224
1542
  ...this.extraProps
1225
1543
  });
1226
1544
  }
1227
- getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1545
+ getMigrationRequestIsMerged({
1546
+ workspace,
1547
+ region,
1548
+ database,
1549
+ migrationRequest
1550
+ }) {
1228
1551
  return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1229
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1552
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1230
1553
  ...this.extraProps
1231
1554
  });
1232
1555
  }
1233
- mergeMigrationRequest(workspace, database, migrationRequest) {
1556
+ mergeMigrationRequest({
1557
+ workspace,
1558
+ region,
1559
+ database,
1560
+ migrationRequest
1561
+ }) {
1234
1562
  return operationsByTag.migrationRequests.mergeMigrationRequest({
1235
- pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1563
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1236
1564
  ...this.extraProps
1237
1565
  });
1238
1566
  }
1239
1567
  }
1240
- class BranchSchemaApi {
1568
+ class MigrationsApi {
1241
1569
  constructor(extraProps) {
1242
1570
  this.extraProps = extraProps;
1243
1571
  }
1244
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
1245
- return operationsByTag.branchSchema.getBranchMigrationHistory({
1246
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1247
- body: options,
1572
+ getBranchMigrationHistory({
1573
+ workspace,
1574
+ region,
1575
+ database,
1576
+ branch,
1577
+ limit,
1578
+ startFrom
1579
+ }) {
1580
+ return operationsByTag.migrations.getBranchMigrationHistory({
1581
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1582
+ body: { limit, startFrom },
1583
+ ...this.extraProps
1584
+ });
1585
+ }
1586
+ getBranchMigrationPlan({
1587
+ workspace,
1588
+ region,
1589
+ database,
1590
+ branch,
1591
+ schema
1592
+ }) {
1593
+ return operationsByTag.migrations.getBranchMigrationPlan({
1594
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1595
+ body: schema,
1248
1596
  ...this.extraProps
1249
1597
  });
1250
1598
  }
1251
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1252
- return operationsByTag.branchSchema.executeBranchMigrationPlan({
1253
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1254
- body: migrationPlan,
1599
+ executeBranchMigrationPlan({
1600
+ workspace,
1601
+ region,
1602
+ database,
1603
+ branch,
1604
+ plan
1605
+ }) {
1606
+ return operationsByTag.migrations.executeBranchMigrationPlan({
1607
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1608
+ body: plan,
1255
1609
  ...this.extraProps
1256
1610
  });
1257
1611
  }
1258
- getBranchMigrationPlan(workspace, database, branch, schema) {
1259
- return operationsByTag.branchSchema.getBranchMigrationPlan({
1260
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1261
- body: schema,
1612
+ getBranchSchemaHistory({
1613
+ workspace,
1614
+ region,
1615
+ database,
1616
+ branch,
1617
+ page
1618
+ }) {
1619
+ return operationsByTag.migrations.getBranchSchemaHistory({
1620
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1621
+ body: { page },
1262
1622
  ...this.extraProps
1263
1623
  });
1264
1624
  }
1265
- compareBranchWithUserSchema(workspace, database, branch, schema) {
1266
- return operationsByTag.branchSchema.compareBranchWithUserSchema({
1267
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1625
+ compareBranchWithUserSchema({
1626
+ workspace,
1627
+ region,
1628
+ database,
1629
+ branch,
1630
+ schema
1631
+ }) {
1632
+ return operationsByTag.migrations.compareBranchWithUserSchema({
1633
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1268
1634
  body: { schema },
1269
1635
  ...this.extraProps
1270
1636
  });
1271
1637
  }
1272
- compareBranchSchemas(workspace, database, branch, branchName, schema) {
1273
- return operationsByTag.branchSchema.compareBranchSchemas({
1274
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1638
+ compareBranchSchemas({
1639
+ workspace,
1640
+ region,
1641
+ database,
1642
+ branch,
1643
+ compare,
1644
+ schema
1645
+ }) {
1646
+ return operationsByTag.migrations.compareBranchSchemas({
1647
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
1275
1648
  body: { schema },
1276
1649
  ...this.extraProps
1277
1650
  });
1278
1651
  }
1279
- updateBranchSchema(workspace, database, branch, migration) {
1280
- return operationsByTag.branchSchema.updateBranchSchema({
1281
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1652
+ updateBranchSchema({
1653
+ workspace,
1654
+ region,
1655
+ database,
1656
+ branch,
1657
+ migration
1658
+ }) {
1659
+ return operationsByTag.migrations.updateBranchSchema({
1660
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1282
1661
  body: migration,
1283
1662
  ...this.extraProps
1284
1663
  });
1285
1664
  }
1286
- previewBranchSchemaEdit(workspace, database, branch, migration) {
1287
- return operationsByTag.branchSchema.previewBranchSchemaEdit({
1288
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1289
- body: migration,
1665
+ previewBranchSchemaEdit({
1666
+ workspace,
1667
+ region,
1668
+ database,
1669
+ branch,
1670
+ data
1671
+ }) {
1672
+ return operationsByTag.migrations.previewBranchSchemaEdit({
1673
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1674
+ body: data,
1290
1675
  ...this.extraProps
1291
1676
  });
1292
1677
  }
1293
- applyBranchSchemaEdit(workspace, database, branch, edits) {
1294
- return operationsByTag.branchSchema.applyBranchSchemaEdit({
1295
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1678
+ applyBranchSchemaEdit({
1679
+ workspace,
1680
+ region,
1681
+ database,
1682
+ branch,
1683
+ edits
1684
+ }) {
1685
+ return operationsByTag.migrations.applyBranchSchemaEdit({
1686
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1296
1687
  body: { edits },
1297
1688
  ...this.extraProps
1298
1689
  });
1299
1690
  }
1300
- getBranchSchemaHistory(workspace, database, branch, options = {}) {
1301
- return operationsByTag.branchSchema.getBranchSchemaHistory({
1302
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1303
- body: options,
1691
+ }
1692
+ class DatabaseApi {
1693
+ constructor(extraProps) {
1694
+ this.extraProps = extraProps;
1695
+ }
1696
+ getDatabaseList({ workspace }) {
1697
+ return operationsByTag.databases.cPGetDatabaseList({
1698
+ pathParams: { workspaceId: workspace },
1699
+ ...this.extraProps
1700
+ });
1701
+ }
1702
+ createDatabase({
1703
+ workspace,
1704
+ database,
1705
+ data
1706
+ }) {
1707
+ return operationsByTag.databases.cPCreateDatabase({
1708
+ pathParams: { workspaceId: workspace, dbName: database },
1709
+ body: data,
1710
+ ...this.extraProps
1711
+ });
1712
+ }
1713
+ deleteDatabase({
1714
+ workspace,
1715
+ database
1716
+ }) {
1717
+ return operationsByTag.databases.cPDeleteDatabase({
1718
+ pathParams: { workspaceId: workspace, dbName: database },
1719
+ ...this.extraProps
1720
+ });
1721
+ }
1722
+ getDatabaseMetadata({
1723
+ workspace,
1724
+ database
1725
+ }) {
1726
+ return operationsByTag.databases.cPGetCPDatabaseMetadata({
1727
+ pathParams: { workspaceId: workspace, dbName: database },
1728
+ ...this.extraProps
1729
+ });
1730
+ }
1731
+ updateDatabaseMetadata({
1732
+ workspace,
1733
+ database,
1734
+ metadata
1735
+ }) {
1736
+ return operationsByTag.databases.cPUpdateCPDatabaseMetadata({
1737
+ pathParams: { workspaceId: workspace, dbName: database },
1738
+ body: metadata,
1739
+ ...this.extraProps
1740
+ });
1741
+ }
1742
+ listRegions({ workspace }) {
1743
+ return operationsByTag.databases.listRegions({
1744
+ pathParams: { workspaceId: workspace },
1304
1745
  ...this.extraProps
1305
1746
  });
1306
1747
  }
@@ -1316,6 +1757,20 @@ class XataApiPlugin {
1316
1757
  class XataPlugin {
1317
1758
  }
1318
1759
 
1760
+ function generateUUID() {
1761
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
1762
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
1763
+ return v.toString(16);
1764
+ });
1765
+ }
1766
+
1767
+ function cleanFilter(filter) {
1768
+ if (!filter)
1769
+ return void 0;
1770
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
1771
+ return values.length > 0 ? filter : void 0;
1772
+ }
1773
+
1319
1774
  var __accessCheck$6 = (obj, member, msg) => {
1320
1775
  if (!member.has(obj))
1321
1776
  throw TypeError("Cannot " + msg);
@@ -1455,7 +1910,7 @@ const _Query = class {
1455
1910
  __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
1456
1911
  __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
1457
1912
  __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
1458
- __privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
1913
+ __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
1459
1914
  __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
1460
1915
  __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
1461
1916
  this.any = this.any.bind(this);
@@ -1571,6 +2026,16 @@ const _Query = class {
1571
2026
  throw new Error("No results found.");
1572
2027
  return records[0];
1573
2028
  }
2029
+ async summarize(params = {}) {
2030
+ const { summaries, summariesFilter, ...options } = params;
2031
+ const query = new _Query(
2032
+ __privateGet$5(this, _repository),
2033
+ __privateGet$5(this, _table$1),
2034
+ options,
2035
+ __privateGet$5(this, _data)
2036
+ );
2037
+ return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
2038
+ }
1574
2039
  cache(ttl) {
1575
2040
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1576
2041
  }
@@ -1607,7 +2072,7 @@ cleanFilterConstraint_fn = function(column, value) {
1607
2072
  };
1608
2073
  function cleanParent(data, parent) {
1609
2074
  if (isCursorPaginationOptions(data.pagination)) {
1610
- return { ...parent, sorting: void 0, filter: void 0 };
2075
+ return { ...parent, sort: void 0, filter: void 0 };
1611
2076
  }
1612
2077
  return parent;
1613
2078
  }
@@ -1692,10 +2157,13 @@ class RestRepository extends Query {
1692
2157
  __privateAdd$4(this, _schemaTables$2, void 0);
1693
2158
  __privateAdd$4(this, _trace, void 0);
1694
2159
  __privateSet$4(this, _table, options.table);
1695
- __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1696
2160
  __privateSet$4(this, _db, options.db);
1697
2161
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1698
2162
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
2163
+ __privateSet$4(this, _getFetchProps, async () => {
2164
+ const props = await options.pluginOptions.getFetchProps();
2165
+ return { ...props, sessionID: generateUUID() };
2166
+ });
1699
2167
  const trace = options.pluginOptions.trace ?? defaultTrace;
1700
2168
  __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
1701
2169
  return trace(name, fn, {
@@ -1706,8 +2174,9 @@ class RestRepository extends Query {
1706
2174
  });
1707
2175
  });
1708
2176
  }
1709
- async create(a, b, c) {
2177
+ async create(a, b, c, d) {
1710
2178
  return __privateGet$4(this, _trace).call(this, "create", async () => {
2179
+ const ifVersion = parseIfVersion(b, c, d);
1711
2180
  if (Array.isArray(a)) {
1712
2181
  if (a.length === 0)
1713
2182
  return [];
@@ -1718,13 +2187,13 @@ class RestRepository extends Query {
1718
2187
  if (a === "")
1719
2188
  throw new Error("The id can't be empty");
1720
2189
  const columns = isStringArray(c) ? c : void 0;
1721
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
2190
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
1722
2191
  }
1723
2192
  if (isObject(a) && isString(a.id)) {
1724
2193
  if (a.id === "")
1725
2194
  throw new Error("The id can't be empty");
1726
2195
  const columns = isStringArray(b) ? b : void 0;
1727
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2196
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
1728
2197
  }
1729
2198
  if (isObject(a)) {
1730
2199
  const columns = isStringArray(b) ? b : void 0;
@@ -1755,6 +2224,7 @@ class RestRepository extends Query {
1755
2224
  pathParams: {
1756
2225
  workspace: "{workspaceId}",
1757
2226
  dbBranchName: "{dbBranch}",
2227
+ region: "{region}",
1758
2228
  tableName: __privateGet$4(this, _table),
1759
2229
  recordId: id
1760
2230
  },
@@ -1792,8 +2262,9 @@ class RestRepository extends Query {
1792
2262
  return result;
1793
2263
  });
1794
2264
  }
1795
- async update(a, b, c) {
2265
+ async update(a, b, c, d) {
1796
2266
  return __privateGet$4(this, _trace).call(this, "update", async () => {
2267
+ const ifVersion = parseIfVersion(b, c, d);
1797
2268
  if (Array.isArray(a)) {
1798
2269
  if (a.length === 0)
1799
2270
  return [];
@@ -1805,18 +2276,18 @@ class RestRepository extends Query {
1805
2276
  }
1806
2277
  if (isString(a) && isObject(b)) {
1807
2278
  const columns = isStringArray(c) ? c : void 0;
1808
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
2279
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1809
2280
  }
1810
2281
  if (isObject(a) && isString(a.id)) {
1811
2282
  const columns = isStringArray(b) ? b : void 0;
1812
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2283
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
1813
2284
  }
1814
2285
  throw new Error("Invalid arguments for update method");
1815
2286
  });
1816
2287
  }
1817
- async updateOrThrow(a, b, c) {
2288
+ async updateOrThrow(a, b, c, d) {
1818
2289
  return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1819
- const result = await this.update(a, b, c);
2290
+ const result = await this.update(a, b, c, d);
1820
2291
  if (Array.isArray(result)) {
1821
2292
  const missingIds = compact(
1822
2293
  a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
@@ -1833,8 +2304,9 @@ class RestRepository extends Query {
1833
2304
  return result;
1834
2305
  });
1835
2306
  }
1836
- async createOrUpdate(a, b, c) {
2307
+ async createOrUpdate(a, b, c, d) {
1837
2308
  return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
2309
+ const ifVersion = parseIfVersion(b, c, d);
1838
2310
  if (Array.isArray(a)) {
1839
2311
  if (a.length === 0)
1840
2312
  return [];
@@ -1846,15 +2318,35 @@ class RestRepository extends Query {
1846
2318
  }
1847
2319
  if (isString(a) && isObject(b)) {
1848
2320
  const columns = isStringArray(c) ? c : void 0;
1849
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
2321
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
1850
2322
  }
1851
2323
  if (isObject(a) && isString(a.id)) {
1852
2324
  const columns = isStringArray(c) ? c : void 0;
1853
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
2325
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
1854
2326
  }
1855
2327
  throw new Error("Invalid arguments for createOrUpdate method");
1856
2328
  });
1857
2329
  }
2330
+ async createOrReplace(a, b, c, d) {
2331
+ return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
2332
+ const ifVersion = parseIfVersion(b, c, d);
2333
+ if (Array.isArray(a)) {
2334
+ if (a.length === 0)
2335
+ return [];
2336
+ const columns = isStringArray(b) ? b : ["*"];
2337
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
2338
+ }
2339
+ if (isString(a) && isObject(b)) {
2340
+ const columns = isStringArray(c) ? c : void 0;
2341
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
2342
+ }
2343
+ if (isObject(a) && isString(a.id)) {
2344
+ const columns = isStringArray(c) ? c : void 0;
2345
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
2346
+ }
2347
+ throw new Error("Invalid arguments for createOrReplace method");
2348
+ });
2349
+ }
1858
2350
  async delete(a, b) {
1859
2351
  return __privateGet$4(this, _trace).call(this, "delete", async () => {
1860
2352
  if (Array.isArray(a)) {
@@ -1896,7 +2388,12 @@ class RestRepository extends Query {
1896
2388
  return __privateGet$4(this, _trace).call(this, "search", async () => {
1897
2389
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1898
2390
  const { records } = await searchTable({
1899
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2391
+ pathParams: {
2392
+ workspace: "{workspaceId}",
2393
+ dbBranchName: "{dbBranch}",
2394
+ region: "{region}",
2395
+ tableName: __privateGet$4(this, _table)
2396
+ },
1900
2397
  body: {
1901
2398
  query,
1902
2399
  fuzziness: options.fuzziness,
@@ -1911,22 +2408,42 @@ class RestRepository extends Query {
1911
2408
  return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
1912
2409
  });
1913
2410
  }
2411
+ async aggregate(aggs, filter) {
2412
+ return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
2413
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2414
+ const result = await aggregateTable({
2415
+ pathParams: {
2416
+ workspace: "{workspaceId}",
2417
+ dbBranchName: "{dbBranch}",
2418
+ region: "{region}",
2419
+ tableName: __privateGet$4(this, _table)
2420
+ },
2421
+ body: { aggs, filter },
2422
+ ...fetchProps
2423
+ });
2424
+ return result;
2425
+ });
2426
+ }
1914
2427
  async query(query) {
1915
2428
  return __privateGet$4(this, _trace).call(this, "query", async () => {
1916
2429
  const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1917
2430
  if (cacheQuery)
1918
2431
  return new Page(query, cacheQuery.meta, cacheQuery.records);
1919
2432
  const data = query.getQueryOptions();
1920
- const body = {
1921
- filter: cleanFilter(data.filter),
1922
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1923
- page: data.pagination,
1924
- columns: data.columns
1925
- };
1926
2433
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1927
2434
  const { meta, records: objects } = await queryTable({
1928
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1929
- body,
2435
+ pathParams: {
2436
+ workspace: "{workspaceId}",
2437
+ dbBranchName: "{dbBranch}",
2438
+ region: "{region}",
2439
+ tableName: __privateGet$4(this, _table)
2440
+ },
2441
+ body: {
2442
+ filter: cleanFilter(data.filter),
2443
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2444
+ page: data.pagination,
2445
+ columns: data.columns ?? ["*"]
2446
+ },
1930
2447
  ...fetchProps
1931
2448
  });
1932
2449
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
@@ -1937,6 +2454,30 @@ class RestRepository extends Query {
1937
2454
  return new Page(query, meta, records);
1938
2455
  });
1939
2456
  }
2457
+ async summarizeTable(query, summaries, summariesFilter) {
2458
+ return __privateGet$4(this, _trace).call(this, "summarize", async () => {
2459
+ const data = query.getQueryOptions();
2460
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2461
+ const result = await summarizeTable({
2462
+ pathParams: {
2463
+ workspace: "{workspaceId}",
2464
+ dbBranchName: "{dbBranch}",
2465
+ region: "{region}",
2466
+ tableName: __privateGet$4(this, _table)
2467
+ },
2468
+ body: {
2469
+ filter: cleanFilter(data.filter),
2470
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2471
+ columns: data.columns,
2472
+ page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
2473
+ summaries,
2474
+ summariesFilter
2475
+ },
2476
+ ...fetchProps
2477
+ });
2478
+ return result;
2479
+ });
2480
+ }
1940
2481
  }
1941
2482
  _table = new WeakMap();
1942
2483
  _getFetchProps = new WeakMap();
@@ -1952,6 +2493,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1952
2493
  pathParams: {
1953
2494
  workspace: "{workspaceId}",
1954
2495
  dbBranchName: "{dbBranch}",
2496
+ region: "{region}",
1955
2497
  tableName: __privateGet$4(this, _table)
1956
2498
  },
1957
2499
  queryParams: { columns },
@@ -1962,18 +2504,19 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1962
2504
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1963
2505
  };
1964
2506
  _insertRecordWithId = new WeakSet();
1965
- insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
2507
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
1966
2508
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1967
2509
  const record = transformObjectLinks(object);
1968
2510
  const response = await insertRecordWithID({
1969
2511
  pathParams: {
1970
2512
  workspace: "{workspaceId}",
1971
2513
  dbBranchName: "{dbBranch}",
2514
+ region: "{region}",
1972
2515
  tableName: __privateGet$4(this, _table),
1973
2516
  recordId
1974
2517
  },
1975
2518
  body: record,
1976
- queryParams: { createOnly: true, columns },
2519
+ queryParams: { createOnly, columns, ifVersion },
1977
2520
  ...fetchProps
1978
2521
  });
1979
2522
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
@@ -1984,7 +2527,12 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1984
2527
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1985
2528
  const records = objects.map((object) => transformObjectLinks(object));
1986
2529
  const response = await bulkInsertTableRecords({
1987
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2530
+ pathParams: {
2531
+ workspace: "{workspaceId}",
2532
+ dbBranchName: "{dbBranch}",
2533
+ region: "{region}",
2534
+ tableName: __privateGet$4(this, _table)
2535
+ },
1988
2536
  queryParams: { columns },
1989
2537
  body: { records },
1990
2538
  ...fetchProps
@@ -1996,13 +2544,19 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1996
2544
  return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
1997
2545
  };
1998
2546
  _updateRecordWithID = new WeakSet();
1999
- updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2547
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
2000
2548
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2001
2549
  const record = transformObjectLinks(object);
2002
2550
  try {
2003
2551
  const response = await updateRecordWithID({
2004
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2005
- queryParams: { columns },
2552
+ pathParams: {
2553
+ workspace: "{workspaceId}",
2554
+ dbBranchName: "{dbBranch}",
2555
+ region: "{region}",
2556
+ tableName: __privateGet$4(this, _table),
2557
+ recordId
2558
+ },
2559
+ queryParams: { columns, ifVersion },
2006
2560
  body: record,
2007
2561
  ...fetchProps
2008
2562
  });
@@ -2016,11 +2570,17 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2016
2570
  }
2017
2571
  };
2018
2572
  _upsertRecordWithID = new WeakSet();
2019
- upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2573
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
2020
2574
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2021
2575
  const response = await upsertRecordWithID({
2022
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2023
- queryParams: { columns },
2576
+ pathParams: {
2577
+ workspace: "{workspaceId}",
2578
+ dbBranchName: "{dbBranch}",
2579
+ region: "{region}",
2580
+ tableName: __privateGet$4(this, _table),
2581
+ recordId
2582
+ },
2583
+ queryParams: { columns, ifVersion },
2024
2584
  body: object,
2025
2585
  ...fetchProps
2026
2586
  });
@@ -2032,7 +2592,13 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
2032
2592
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2033
2593
  try {
2034
2594
  const response = await deleteRecord({
2035
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2595
+ pathParams: {
2596
+ workspace: "{workspaceId}",
2597
+ dbBranchName: "{dbBranch}",
2598
+ region: "{region}",
2599
+ tableName: __privateGet$4(this, _table),
2600
+ recordId
2601
+ },
2036
2602
  queryParams: { columns },
2037
2603
  ...fetchProps
2038
2604
  });
@@ -2067,7 +2633,7 @@ getSchemaTables_fn$1 = async function() {
2067
2633
  return __privateGet$4(this, _schemaTables$2);
2068
2634
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2069
2635
  const { schema } = await getBranchDetails({
2070
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2636
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2071
2637
  ...fetchProps
2072
2638
  });
2073
2639
  __privateSet$4(this, _schemaTables$2, schema.tables);
@@ -2133,8 +2699,15 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2133
2699
  result.read = function(columns2) {
2134
2700
  return db[table].read(result["id"], columns2);
2135
2701
  };
2136
- result.update = function(data, columns2) {
2137
- return db[table].update(result["id"], data, columns2);
2702
+ result.update = function(data, b, c) {
2703
+ const columns2 = isStringArray(b) ? b : ["*"];
2704
+ const ifVersion = parseIfVersion(b, c);
2705
+ return db[table].update(result["id"], data, columns2, { ifVersion });
2706
+ };
2707
+ result.replace = function(data, b, c) {
2708
+ const columns2 = isStringArray(b) ? b : ["*"];
2709
+ const ifVersion = parseIfVersion(b, c);
2710
+ return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
2138
2711
  };
2139
2712
  result.delete = function() {
2140
2713
  return db[table].delete(result["id"]);
@@ -2158,12 +2731,6 @@ function extractId(value) {
2158
2731
  return value.id;
2159
2732
  return void 0;
2160
2733
  }
2161
- function cleanFilter(filter) {
2162
- if (!filter)
2163
- return void 0;
2164
- const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2165
- return values.length > 0 ? filter : void 0;
2166
- }
2167
2734
  function isValidColumn(columns, column) {
2168
2735
  if (columns.includes("*"))
2169
2736
  return true;
@@ -2173,6 +2740,14 @@ function isValidColumn(columns, column) {
2173
2740
  }
2174
2741
  return columns.includes(column.name);
2175
2742
  }
2743
+ function parseIfVersion(...args) {
2744
+ for (const arg of args) {
2745
+ if (isObject(arg) && isNumber(arg.ifVersion)) {
2746
+ return arg.ifVersion;
2747
+ }
2748
+ }
2749
+ return void 0;
2750
+ }
2176
2751
 
2177
2752
  var __accessCheck$3 = (obj, member, msg) => {
2178
2753
  if (!member.has(obj))
@@ -2360,7 +2935,7 @@ search_fn = async function(query, options, getFetchProps) {
2360
2935
  const fetchProps = await getFetchProps();
2361
2936
  const { tables, fuzziness, highlight, prefix } = options ?? {};
2362
2937
  const { records } = await searchBranch({
2363
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2938
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2364
2939
  body: { tables, query, fuzziness, prefix, highlight },
2365
2940
  ...fetchProps
2366
2941
  });
@@ -2372,7 +2947,7 @@ getSchemaTables_fn = async function(getFetchProps) {
2372
2947
  return __privateGet$1(this, _schemaTables);
2373
2948
  const fetchProps = await getFetchProps();
2374
2949
  const { schema } = await getBranchDetails({
2375
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2950
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2376
2951
  ...fetchProps
2377
2952
  });
2378
2953
  __privateSet$1(this, _schemaTables, schema.tables);
@@ -2410,14 +2985,17 @@ async function resolveXataBranch(gitBranch, options) {
2410
2985
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2411
2986
  );
2412
2987
  const [protocol, , host, , dbName] = databaseURL.split("/");
2413
- const [workspace] = host.split(".");
2988
+ const urlParts = parseWorkspacesUrlParts(host);
2989
+ if (!urlParts)
2990
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
2991
+ const { workspace, region } = urlParts;
2414
2992
  const { fallbackBranch } = getEnvironment();
2415
2993
  const { branch } = await resolveBranch({
2416
2994
  apiKey,
2417
2995
  apiUrl: databaseURL,
2418
2996
  fetchImpl: getFetchImplementation(options?.fetchImpl),
2419
2997
  workspacesApiUrl: `${protocol}//${host}`,
2420
- pathParams: { dbName, workspace },
2998
+ pathParams: { dbName, workspace, region },
2421
2999
  queryParams: { gitBranch, fallbackBranch },
2422
3000
  trace: defaultTrace
2423
3001
  });
@@ -2435,15 +3013,17 @@ async function getDatabaseBranch(branch, options) {
2435
3013
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2436
3014
  );
2437
3015
  const [protocol, , host, , database] = databaseURL.split("/");
2438
- const [workspace] = host.split(".");
2439
- const dbBranchName = `${database}:${branch}`;
3016
+ const urlParts = parseWorkspacesUrlParts(host);
3017
+ if (!urlParts)
3018
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3019
+ const { workspace, region } = urlParts;
2440
3020
  try {
2441
3021
  return await getBranchDetails({
2442
3022
  apiKey,
2443
3023
  apiUrl: databaseURL,
2444
3024
  fetchImpl: getFetchImplementation(options?.fetchImpl),
2445
3025
  workspacesApiUrl: `${protocol}//${host}`,
2446
- pathParams: { dbBranchName, workspace },
3026
+ pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
2447
3027
  trace: defaultTrace
2448
3028
  });
2449
3029
  } catch (err) {
@@ -2534,8 +3114,8 @@ const buildClient = (plugins) => {
2534
3114
  if (!databaseURL) {
2535
3115
  throw new Error("Option databaseURL is required");
2536
3116
  }
2537
- return { fetch, databaseURL, apiKey, branch, cache, trace };
2538
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
3117
+ return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID() };
3118
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
2539
3119
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2540
3120
  if (!branchValue)
2541
3121
  throw new Error("Unable to resolve branch value");
@@ -2548,7 +3128,8 @@ const buildClient = (plugins) => {
2548
3128
  const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
2549
3129
  return databaseURL + newPath;
2550
3130
  },
2551
- trace
3131
+ trace,
3132
+ clientID
2552
3133
  };
2553
3134
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2554
3135
  if (__privateGet(this, _branch))
@@ -2682,10 +3263,16 @@ exports.XataPlugin = XataPlugin;
2682
3263
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
2683
3264
  exports.addGitBranchesEntry = addGitBranchesEntry;
2684
3265
  exports.addTableColumn = addTableColumn;
3266
+ exports.aggregateTable = aggregateTable;
2685
3267
  exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
2686
3268
  exports.buildClient = buildClient;
2687
3269
  exports.buildWorkerRunner = buildWorkerRunner;
2688
3270
  exports.bulkInsertTableRecords = bulkInsertTableRecords;
3271
+ exports.cPCreateDatabase = cPCreateDatabase;
3272
+ exports.cPDeleteDatabase = cPDeleteDatabase;
3273
+ exports.cPGetCPDatabaseMetadata = cPGetCPDatabaseMetadata;
3274
+ exports.cPGetDatabaseList = cPGetDatabaseList;
3275
+ exports.cPUpdateCPDatabaseMetadata = cPUpdateCPDatabaseMetadata;
2689
3276
  exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
2690
3277
  exports.compareBranchSchemas = compareBranchSchemas;
2691
3278
  exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
@@ -2726,6 +3313,7 @@ exports.getDatabaseList = getDatabaseList;
2726
3313
  exports.getDatabaseMetadata = getDatabaseMetadata;
2727
3314
  exports.getDatabaseURL = getDatabaseURL;
2728
3315
  exports.getGitBranchesMapping = getGitBranchesMapping;
3316
+ exports.getHostUrl = getHostUrl;
2729
3317
  exports.getMigrationRequest = getMigrationRequest;
2730
3318
  exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
2731
3319
  exports.getRecord = getRecord;
@@ -2750,6 +3338,8 @@ exports.insertRecordWithID = insertRecordWithID;
2750
3338
  exports.inviteWorkspaceMember = inviteWorkspaceMember;
2751
3339
  exports.is = is;
2752
3340
  exports.isCursorPaginationOptions = isCursorPaginationOptions;
3341
+ exports.isHostProviderAlias = isHostProviderAlias;
3342
+ exports.isHostProviderBuilder = isHostProviderBuilder;
2753
3343
  exports.isIdentifiable = isIdentifiable;
2754
3344
  exports.isNot = isNot;
2755
3345
  exports.isXataRecord = isXataRecord;
@@ -2758,11 +3348,14 @@ exports.lessEquals = lessEquals;
2758
3348
  exports.lessThan = lessThan;
2759
3349
  exports.lessThanEquals = lessThanEquals;
2760
3350
  exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
3351
+ exports.listRegions = listRegions;
2761
3352
  exports.lt = lt;
2762
3353
  exports.lte = lte;
2763
3354
  exports.mergeMigrationRequest = mergeMigrationRequest;
2764
3355
  exports.notExists = notExists;
2765
3356
  exports.operationsByTag = operationsByTag;
3357
+ exports.parseProviderString = parseProviderString;
3358
+ exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
2766
3359
  exports.pattern = pattern;
2767
3360
  exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
2768
3361
  exports.queryMigrationRequests = queryMigrationRequests;