@xata.io/client 0.0.0-alpha.vf0c7bc2 → 0.0.0-alpha.vf0e0021

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
@@ -24,13 +24,11 @@ const defaultTrace = async (_name, fn, _options) => {
24
24
  return await fn({
25
25
  setAttributes: () => {
26
26
  return;
27
- },
28
- onError: () => {
29
- return;
30
27
  }
31
28
  });
32
29
  };
33
30
  const TraceAttributes = {
31
+ KIND: "xata.trace.kind",
34
32
  VERSION: "xata.sdk.version",
35
33
  TABLE: "xata.table",
36
34
  HTTP_REQUEST_ID: "http.request_id",
@@ -168,13 +166,13 @@ function getFetchImplementation(userFetch) {
168
166
  const fetchImpl = userFetch ?? globalFetch;
169
167
  if (!fetchImpl) {
170
168
  throw new Error(
171
- `The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`
169
+ `Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
172
170
  );
173
171
  }
174
172
  return fetchImpl;
175
173
  }
176
174
 
177
- const VERSION = "0.0.0-alpha.vf0c7bc2";
175
+ const VERSION = "0.0.0-alpha.vf0e0021";
178
176
 
179
177
  class ErrorWithCause extends Error {
180
178
  constructor(message, options) {
@@ -225,7 +223,10 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
225
223
  }, {});
226
224
  const query = new URLSearchParams(cleanQueryParams).toString();
227
225
  const queryString = query.length > 0 ? `?${query}` : "";
228
- return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
226
+ const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
227
+ return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
228
+ }, {});
229
+ return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
229
230
  };
230
231
  function buildBaseUrl({
231
232
  path,
@@ -233,10 +234,10 @@ function buildBaseUrl({
233
234
  apiUrl,
234
235
  pathParams
235
236
  }) {
236
- if (!pathParams?.workspace)
237
+ if (pathParams?.workspace === void 0)
237
238
  return `${apiUrl}${path}`;
238
239
  const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
239
- return url.replace("{workspaceId}", pathParams.workspace);
240
+ return url.replace("{workspaceId}", String(pathParams.workspace));
240
241
  }
241
242
  function hostHeader(url) {
242
243
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
@@ -258,7 +259,7 @@ async function fetch$1({
258
259
  }) {
259
260
  return trace(
260
261
  `${method.toUpperCase()} ${path}`,
261
- async ({ setAttributes, onError }) => {
262
+ async ({ setAttributes }) => {
262
263
  const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
263
264
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
264
265
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
@@ -283,6 +284,7 @@ async function fetch$1({
283
284
  const { host, protocol } = parseUrl(response.url);
284
285
  const requestId = response.headers?.get("x-request-id") ?? void 0;
285
286
  setAttributes({
287
+ [TraceAttributes.KIND]: "http",
286
288
  [TraceAttributes.HTTP_REQUEST_ID]: requestId,
287
289
  [TraceAttributes.HTTP_STATUS_CODE]: response.status,
288
290
  [TraceAttributes.HTTP_HOST]: host,
@@ -295,9 +297,7 @@ async function fetch$1({
295
297
  }
296
298
  throw new FetcherError(response.status, jsonResponse, requestId);
297
299
  } catch (error) {
298
- const fetcherError = new FetcherError(response.status, error, requestId);
299
- onError(fetcherError.message);
300
- throw fetcherError;
300
+ throw new FetcherError(response.status, error, requestId);
301
301
  }
302
302
  },
303
303
  { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
@@ -408,6 +408,7 @@ const getDatabaseMetadata = (variables) => fetch$1({
408
408
  method: "get",
409
409
  ...variables
410
410
  });
411
+ const updateDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
411
412
  const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
412
413
  const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
413
414
  const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
@@ -416,6 +417,22 @@ const resolveBranch = (variables) => fetch$1({
416
417
  method: "get",
417
418
  ...variables
418
419
  });
420
+ const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
421
+ const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
422
+ const getMigrationRequest = (variables) => fetch$1({
423
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
424
+ method: "get",
425
+ ...variables
426
+ });
427
+ const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
428
+ const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
429
+ const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
430
+ const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
431
+ const mergeMigrationRequest = (variables) => fetch$1({
432
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
433
+ method: "post",
434
+ ...variables
435
+ });
419
436
  const getBranchDetails = (variables) => fetch$1({
420
437
  url: "/db/{dbBranchName}",
421
438
  method: "get",
@@ -440,6 +457,16 @@ const getBranchMetadata = (variables) => fetch$1({
440
457
  const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
441
458
  const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
442
459
  const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
460
+ const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
461
+ const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
462
+ const updateBranchSchema = (variables) => fetch$1({
463
+ url: "/db/{dbBranchName}/schema/update",
464
+ method: "post",
465
+ ...variables
466
+ });
467
+ const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
468
+ const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
469
+ const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
443
470
  const getBranchStats = (variables) => fetch$1({
444
471
  url: "/db/{dbBranchName}/stats",
445
472
  method: "get",
@@ -525,6 +552,26 @@ const searchBranch = (variables) => fetch$1({
525
552
  method: "post",
526
553
  ...variables
527
554
  });
555
+ const summarizeTable = (variables) => fetch$1({
556
+ url: "/db/{dbBranchName}/tables/{tableName}/summarize",
557
+ method: "post",
558
+ ...variables
559
+ });
560
+ const cPgetDatabaseList = (variables) => fetch$1({
561
+ url: "/workspaces/{workspaceId}/dbs",
562
+ method: "get",
563
+ ...variables
564
+ });
565
+ const cPcreateDatabase = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables });
566
+ const cPdeleteDatabase = (variables) => fetch$1({
567
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
568
+ method: "delete",
569
+ ...variables
570
+ });
571
+ const cPgetCPDatabaseMetadata = (variables) => fetch$1(
572
+ { url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "get", ...variables }
573
+ );
574
+ const cPupdateCPDatabaseMetadata = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "patch", ...variables });
528
575
  const operationsByTag = {
529
576
  users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
530
577
  workspaces: {
@@ -547,6 +594,7 @@ const operationsByTag = {
547
594
  createDatabase,
548
595
  deleteDatabase,
549
596
  getDatabaseMetadata,
597
+ updateDatabaseMetadata,
550
598
  getGitBranchesMapping,
551
599
  addGitBranchesEntry,
552
600
  removeGitBranchesEntry,
@@ -559,10 +607,28 @@ const operationsByTag = {
559
607
  deleteBranch,
560
608
  updateBranchMetadata,
561
609
  getBranchMetadata,
610
+ getBranchStats
611
+ },
612
+ migrationRequests: {
613
+ listMigrationRequests,
614
+ createMigrationRequest,
615
+ getMigrationRequest,
616
+ updateMigrationRequest,
617
+ listMigrationRequestsCommits,
618
+ compareMigrationRequest,
619
+ getMigrationRequestIsMerged,
620
+ mergeMigrationRequest
621
+ },
622
+ branchSchema: {
562
623
  getBranchMigrationHistory,
563
624
  executeBranchMigrationPlan,
564
625
  getBranchMigrationPlan,
565
- getBranchStats
626
+ compareBranchWithUserSchema,
627
+ compareBranchSchemas,
628
+ updateBranchSchema,
629
+ previewBranchSchemaEdit,
630
+ applyBranchSchemaEdit,
631
+ getBranchSchemaHistory
566
632
  },
567
633
  table: {
568
634
  createTable,
@@ -586,14 +652,22 @@ const operationsByTag = {
586
652
  bulkInsertTableRecords,
587
653
  queryTable,
588
654
  searchTable,
589
- searchBranch
655
+ searchBranch,
656
+ summarizeTable
657
+ },
658
+ databases: {
659
+ cPgetDatabaseList,
660
+ cPcreateDatabase,
661
+ cPdeleteDatabase,
662
+ cPgetCPDatabaseMetadata,
663
+ cPupdateCPDatabaseMetadata
590
664
  }
591
665
  };
592
666
 
593
667
  function getHostUrl(provider, type) {
594
- if (isValidAlias(provider)) {
668
+ if (isHostProviderAlias(provider)) {
595
669
  return providers[provider][type];
596
- } else if (isValidBuilder(provider)) {
670
+ } else if (isHostProviderBuilder(provider)) {
597
671
  return provider[type];
598
672
  }
599
673
  throw new Error("Invalid API provider");
@@ -608,10 +682,10 @@ const providers = {
608
682
  workspaces: "https://{workspaceId}.staging.xatabase.co"
609
683
  }
610
684
  };
611
- function isValidAlias(alias) {
685
+ function isHostProviderAlias(alias) {
612
686
  return isString(alias) && Object.keys(providers).includes(alias);
613
687
  }
614
- function isValidBuilder(builder) {
688
+ function isHostProviderBuilder(builder) {
615
689
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
616
690
  }
617
691
 
@@ -682,6 +756,16 @@ class XataApiClient {
682
756
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
683
757
  return __privateGet$7(this, _namespaces).records;
684
758
  }
759
+ get migrationRequests() {
760
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
761
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
762
+ return __privateGet$7(this, _namespaces).migrationRequests;
763
+ }
764
+ get branchSchema() {
765
+ if (!__privateGet$7(this, _namespaces).branchSchema)
766
+ __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
767
+ return __privateGet$7(this, _namespaces).branchSchema;
768
+ }
685
769
  }
686
770
  _extraProps = new WeakMap();
687
771
  _namespaces = new WeakMap();
@@ -827,6 +911,13 @@ class DatabaseApi {
827
911
  ...this.extraProps
828
912
  });
829
913
  }
914
+ updateDatabaseMetadata(workspace, dbName, options = {}) {
915
+ return operationsByTag.database.updateDatabaseMetadata({
916
+ pathParams: { workspace, dbName },
917
+ body: options,
918
+ ...this.extraProps
919
+ });
920
+ }
830
921
  getGitBranchesMapping(workspace, dbName) {
831
922
  return operationsByTag.database.getGitBranchesMapping({
832
923
  pathParams: { workspace, dbName },
@@ -898,27 +989,6 @@ class BranchApi {
898
989
  ...this.extraProps
899
990
  });
900
991
  }
901
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
902
- return operationsByTag.branch.getBranchMigrationHistory({
903
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
904
- body: options,
905
- ...this.extraProps
906
- });
907
- }
908
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
909
- return operationsByTag.branch.executeBranchMigrationPlan({
910
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
911
- body: migrationPlan,
912
- ...this.extraProps
913
- });
914
- }
915
- getBranchMigrationPlan(workspace, database, branch, schema) {
916
- return operationsByTag.branch.getBranchMigrationPlan({
917
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
918
- body: schema,
919
- ...this.extraProps
920
- });
921
- }
922
992
  getBranchStats(workspace, database, branch) {
923
993
  return operationsByTag.branch.getBranchStats({
924
994
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
@@ -1074,6 +1144,138 @@ class RecordsApi {
1074
1144
  ...this.extraProps
1075
1145
  });
1076
1146
  }
1147
+ summarizeTable(workspace, database, branch, tableName, query) {
1148
+ return operationsByTag.records.summarizeTable({
1149
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1150
+ body: query,
1151
+ ...this.extraProps
1152
+ });
1153
+ }
1154
+ }
1155
+ class MigrationRequestsApi {
1156
+ constructor(extraProps) {
1157
+ this.extraProps = extraProps;
1158
+ }
1159
+ listMigrationRequests(workspace, database, options = {}) {
1160
+ return operationsByTag.migrationRequests.listMigrationRequests({
1161
+ pathParams: { workspace, dbName: database },
1162
+ body: options,
1163
+ ...this.extraProps
1164
+ });
1165
+ }
1166
+ createMigrationRequest(workspace, database, options) {
1167
+ return operationsByTag.migrationRequests.createMigrationRequest({
1168
+ pathParams: { workspace, dbName: database },
1169
+ body: options,
1170
+ ...this.extraProps
1171
+ });
1172
+ }
1173
+ getMigrationRequest(workspace, database, migrationRequest) {
1174
+ return operationsByTag.migrationRequests.getMigrationRequest({
1175
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1176
+ ...this.extraProps
1177
+ });
1178
+ }
1179
+ updateMigrationRequest(workspace, database, migrationRequest, options) {
1180
+ return operationsByTag.migrationRequests.updateMigrationRequest({
1181
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1182
+ body: options,
1183
+ ...this.extraProps
1184
+ });
1185
+ }
1186
+ listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1187
+ return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1188
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1189
+ body: options,
1190
+ ...this.extraProps
1191
+ });
1192
+ }
1193
+ compareMigrationRequest(workspace, database, migrationRequest) {
1194
+ return operationsByTag.migrationRequests.compareMigrationRequest({
1195
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1196
+ ...this.extraProps
1197
+ });
1198
+ }
1199
+ getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1200
+ return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1201
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1202
+ ...this.extraProps
1203
+ });
1204
+ }
1205
+ mergeMigrationRequest(workspace, database, migrationRequest) {
1206
+ return operationsByTag.migrationRequests.mergeMigrationRequest({
1207
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1208
+ ...this.extraProps
1209
+ });
1210
+ }
1211
+ }
1212
+ class BranchSchemaApi {
1213
+ constructor(extraProps) {
1214
+ this.extraProps = extraProps;
1215
+ }
1216
+ getBranchMigrationHistory(workspace, database, branch, options = {}) {
1217
+ return operationsByTag.branchSchema.getBranchMigrationHistory({
1218
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1219
+ body: options,
1220
+ ...this.extraProps
1221
+ });
1222
+ }
1223
+ executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1224
+ return operationsByTag.branchSchema.executeBranchMigrationPlan({
1225
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1226
+ body: migrationPlan,
1227
+ ...this.extraProps
1228
+ });
1229
+ }
1230
+ getBranchMigrationPlan(workspace, database, branch, schema) {
1231
+ return operationsByTag.branchSchema.getBranchMigrationPlan({
1232
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1233
+ body: schema,
1234
+ ...this.extraProps
1235
+ });
1236
+ }
1237
+ compareBranchWithUserSchema(workspace, database, branch, schema) {
1238
+ return operationsByTag.branchSchema.compareBranchWithUserSchema({
1239
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1240
+ body: { schema },
1241
+ ...this.extraProps
1242
+ });
1243
+ }
1244
+ compareBranchSchemas(workspace, database, branch, branchName, schema) {
1245
+ return operationsByTag.branchSchema.compareBranchSchemas({
1246
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1247
+ body: { schema },
1248
+ ...this.extraProps
1249
+ });
1250
+ }
1251
+ updateBranchSchema(workspace, database, branch, migration) {
1252
+ return operationsByTag.branchSchema.updateBranchSchema({
1253
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1254
+ body: migration,
1255
+ ...this.extraProps
1256
+ });
1257
+ }
1258
+ previewBranchSchemaEdit(workspace, database, branch, migration) {
1259
+ return operationsByTag.branchSchema.previewBranchSchemaEdit({
1260
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1261
+ body: migration,
1262
+ ...this.extraProps
1263
+ });
1264
+ }
1265
+ applyBranchSchemaEdit(workspace, database, branch, edits) {
1266
+ return operationsByTag.branchSchema.applyBranchSchemaEdit({
1267
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1268
+ body: { edits },
1269
+ ...this.extraProps
1270
+ });
1271
+ }
1272
+ getBranchSchemaHistory(workspace, database, branch, options = {}) {
1273
+ return operationsByTag.branchSchema.getBranchSchemaHistory({
1274
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1275
+ body: options,
1276
+ ...this.extraProps
1277
+ });
1278
+ }
1077
1279
  }
1078
1280
 
1079
1281
  class XataApiPlugin {
@@ -1199,9 +1401,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
1199
1401
  setter ? setter.call(obj, value) : member.set(obj, value);
1200
1402
  return value;
1201
1403
  };
1202
- var _table$1, _repository, _data;
1404
+ var __privateMethod$3 = (obj, member, method) => {
1405
+ __accessCheck$5(obj, member, "access private method");
1406
+ return method;
1407
+ };
1408
+ var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
1203
1409
  const _Query = class {
1204
1410
  constructor(repository, table, data, rawParent) {
1411
+ __privateAdd$5(this, _cleanFilterConstraint);
1205
1412
  __privateAdd$5(this, _table$1, void 0);
1206
1413
  __privateAdd$5(this, _repository, void 0);
1207
1414
  __privateAdd$5(this, _data, { filter: {} });
@@ -1258,11 +1465,14 @@ const _Query = class {
1258
1465
  }
1259
1466
  filter(a, b) {
1260
1467
  if (arguments.length === 1) {
1261
- const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
1468
+ const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
1469
+ [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
1470
+ }));
1262
1471
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1263
1472
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1264
1473
  } else {
1265
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
1474
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
1475
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1266
1476
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1267
1477
  }
1268
1478
  }
@@ -1300,11 +1510,20 @@ const _Query = class {
1300
1510
  }
1301
1511
  }
1302
1512
  async getMany(options = {}) {
1303
- const page = await this.getPaginated(options);
1513
+ const { pagination = {}, ...rest } = options;
1514
+ const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
1515
+ const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
1516
+ let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
1517
+ const results = [...page.records];
1518
+ while (page.hasNextPage() && results.length < size) {
1519
+ page = await page.nextPage();
1520
+ results.push(...page.records);
1521
+ }
1304
1522
  if (page.hasNextPage() && options.pagination?.size === void 0) {
1305
1523
  console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
1306
1524
  }
1307
- return page.records;
1525
+ const array = new RecordArray(page, results.slice(0, size));
1526
+ return array;
1308
1527
  }
1309
1528
  async getAll(options = {}) {
1310
1529
  const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
@@ -1318,6 +1537,12 @@ const _Query = class {
1318
1537
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
1319
1538
  return records[0] ?? null;
1320
1539
  }
1540
+ async getFirstOrThrow(options = {}) {
1541
+ const records = await this.getMany({ ...options, pagination: { size: 1 } });
1542
+ if (records[0] === void 0)
1543
+ throw new Error("No results found.");
1544
+ return records[0];
1545
+ }
1321
1546
  cache(ttl) {
1322
1547
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1323
1548
  }
@@ -1341,6 +1566,17 @@ let Query = _Query;
1341
1566
  _table$1 = new WeakMap();
1342
1567
  _repository = new WeakMap();
1343
1568
  _data = new WeakMap();
1569
+ _cleanFilterConstraint = new WeakSet();
1570
+ cleanFilterConstraint_fn = function(column, value) {
1571
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
1572
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
1573
+ return { $includes: value };
1574
+ }
1575
+ if (columnType === "link" && isObject(value) && isString(value.id)) {
1576
+ return value.id;
1577
+ }
1578
+ return value;
1579
+ };
1344
1580
  function cleanParent(data, parent) {
1345
1581
  if (isCursorPaginationOptions(data.pagination)) {
1346
1582
  return { ...parent, sorting: void 0, filter: void 0 };
@@ -1407,7 +1643,11 @@ class Repository extends Query {
1407
1643
  }
1408
1644
  class RestRepository extends Query {
1409
1645
  constructor(options) {
1410
- super(null, options.table, {});
1646
+ super(
1647
+ null,
1648
+ { name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
1649
+ {}
1650
+ );
1411
1651
  __privateAdd$4(this, _insertRecordWithoutId);
1412
1652
  __privateAdd$4(this, _insertRecordWithId);
1413
1653
  __privateAdd$4(this, _bulkInsertTableRecords);
@@ -1433,6 +1673,7 @@ class RestRepository extends Query {
1433
1673
  return trace(name, fn, {
1434
1674
  ...options2,
1435
1675
  [TraceAttributes.TABLE]: __privateGet$4(this, _table),
1676
+ [TraceAttributes.KIND]: "sdk-operation",
1436
1677
  [TraceAttributes.VERSION]: VERSION
1437
1678
  });
1438
1679
  });
@@ -1470,16 +1711,16 @@ class RestRepository extends Query {
1470
1711
  if (Array.isArray(a)) {
1471
1712
  if (a.length === 0)
1472
1713
  return [];
1473
- const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
1474
- const finalObjects = await this.getAll({ filter: { id: { $any: ids } }, columns });
1714
+ const ids = a.map((item) => extractId(item));
1715
+ const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
1475
1716
  const dictionary = finalObjects.reduce((acc, object) => {
1476
1717
  acc[object.id] = object;
1477
1718
  return acc;
1478
1719
  }, {});
1479
- return ids.map((id2) => dictionary[id2] ?? null);
1720
+ return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
1480
1721
  }
1481
- const id = isString(a) ? a : a.id;
1482
- if (isString(id)) {
1722
+ const id = extractId(a);
1723
+ if (id) {
1483
1724
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1484
1725
  try {
1485
1726
  const response = await getRecord({
@@ -1493,7 +1734,7 @@ class RestRepository extends Query {
1493
1734
  ...fetchProps
1494
1735
  });
1495
1736
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1496
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1737
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1497
1738
  } catch (e) {
1498
1739
  if (isObject(e) && e.status === 404) {
1499
1740
  return null;
@@ -1504,6 +1745,25 @@ class RestRepository extends Query {
1504
1745
  return null;
1505
1746
  });
1506
1747
  }
1748
+ async readOrThrow(a, b) {
1749
+ return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
1750
+ const result = await this.read(a, b);
1751
+ if (Array.isArray(result)) {
1752
+ const missingIds = compact(
1753
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1754
+ );
1755
+ if (missingIds.length > 0) {
1756
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1757
+ }
1758
+ return result;
1759
+ }
1760
+ if (result === null) {
1761
+ const id = extractId(a) ?? "unknown";
1762
+ throw new Error(`Record with id ${id} not found`);
1763
+ }
1764
+ return result;
1765
+ });
1766
+ }
1507
1767
  async update(a, b, c) {
1508
1768
  return __privateGet$4(this, _trace).call(this, "update", async () => {
1509
1769
  if (Array.isArray(a)) {
@@ -1526,6 +1786,25 @@ class RestRepository extends Query {
1526
1786
  throw new Error("Invalid arguments for update method");
1527
1787
  });
1528
1788
  }
1789
+ async updateOrThrow(a, b, c) {
1790
+ return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1791
+ const result = await this.update(a, b, c);
1792
+ if (Array.isArray(result)) {
1793
+ const missingIds = compact(
1794
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1795
+ );
1796
+ if (missingIds.length > 0) {
1797
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1798
+ }
1799
+ return result;
1800
+ }
1801
+ if (result === null) {
1802
+ const id = extractId(a) ?? "unknown";
1803
+ throw new Error(`Record with id ${id} not found`);
1804
+ }
1805
+ return result;
1806
+ });
1807
+ }
1529
1808
  async createOrUpdate(a, b, c) {
1530
1809
  return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
1531
1810
  if (Array.isArray(a)) {
@@ -1548,28 +1827,43 @@ class RestRepository extends Query {
1548
1827
  throw new Error("Invalid arguments for createOrUpdate method");
1549
1828
  });
1550
1829
  }
1551
- async delete(a) {
1830
+ async delete(a, b) {
1552
1831
  return __privateGet$4(this, _trace).call(this, "delete", async () => {
1553
1832
  if (Array.isArray(a)) {
1554
1833
  if (a.length === 0)
1555
- return;
1834
+ return [];
1556
1835
  if (a.length > 100) {
1557
1836
  console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1558
1837
  }
1559
- await Promise.all(a.map((id) => this.delete(id)));
1560
- return;
1838
+ return Promise.all(a.map((id) => this.delete(id, b)));
1561
1839
  }
1562
1840
  if (isString(a)) {
1563
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
1564
- return;
1841
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
1565
1842
  }
1566
1843
  if (isObject(a) && isString(a.id)) {
1567
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
1568
- return;
1844
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
1569
1845
  }
1570
1846
  throw new Error("Invalid arguments for delete method");
1571
1847
  });
1572
1848
  }
1849
+ async deleteOrThrow(a, b) {
1850
+ return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
1851
+ const result = await this.delete(a, b);
1852
+ if (Array.isArray(result)) {
1853
+ const missingIds = compact(
1854
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1855
+ );
1856
+ if (missingIds.length > 0) {
1857
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1858
+ }
1859
+ return result;
1860
+ } else if (result === null) {
1861
+ const id = extractId(a) ?? "unknown";
1862
+ throw new Error(`Record with id ${id} not found`);
1863
+ }
1864
+ return result;
1865
+ });
1866
+ }
1573
1867
  async search(query, options = {}) {
1574
1868
  return __privateGet$4(this, _trace).call(this, "search", async () => {
1575
1869
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
@@ -1586,7 +1880,7 @@ class RestRepository extends Query {
1586
1880
  ...fetchProps
1587
1881
  });
1588
1882
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1589
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
1883
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
1590
1884
  });
1591
1885
  }
1592
1886
  async query(query) {
@@ -1596,7 +1890,7 @@ class RestRepository extends Query {
1596
1890
  return new Page(query, cacheQuery.meta, cacheQuery.records);
1597
1891
  const data = query.getQueryOptions();
1598
1892
  const body = {
1599
- filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1893
+ filter: cleanFilter(data.filter),
1600
1894
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1601
1895
  page: data.pagination,
1602
1896
  columns: data.columns
@@ -1608,7 +1902,9 @@ class RestRepository extends Query {
1608
1902
  ...fetchProps
1609
1903
  });
1610
1904
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1611
- const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
1905
+ const records = objects.map(
1906
+ (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
1907
+ );
1612
1908
  await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1613
1909
  return new Page(query, meta, records);
1614
1910
  });
@@ -1635,7 +1931,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1635
1931
  ...fetchProps
1636
1932
  });
1637
1933
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1638
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1934
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1639
1935
  };
1640
1936
  _insertRecordWithId = new WeakSet();
1641
1937
  insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
@@ -1653,7 +1949,7 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
1653
1949
  ...fetchProps
1654
1950
  });
1655
1951
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1656
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1952
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1657
1953
  };
1658
1954
  _bulkInsertTableRecords = new WeakSet();
1659
1955
  bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
@@ -1669,20 +1965,27 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1669
1965
  throw new Error("Request included columns but server didn't include them");
1670
1966
  }
1671
1967
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1672
- return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
1968
+ return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
1673
1969
  };
1674
1970
  _updateRecordWithID = new WeakSet();
1675
1971
  updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1676
1972
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1677
1973
  const record = transformObjectLinks(object);
1678
- const response = await updateRecordWithID({
1679
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1680
- queryParams: { columns },
1681
- body: record,
1682
- ...fetchProps
1683
- });
1684
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1685
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1974
+ try {
1975
+ const response = await updateRecordWithID({
1976
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1977
+ queryParams: { columns },
1978
+ body: record,
1979
+ ...fetchProps
1980
+ });
1981
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1982
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1983
+ } catch (e) {
1984
+ if (isObject(e) && e.status === 404) {
1985
+ return null;
1986
+ }
1987
+ throw e;
1988
+ }
1686
1989
  };
1687
1990
  _upsertRecordWithID = new WeakSet();
1688
1991
  upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
@@ -1694,15 +1997,25 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1694
1997
  ...fetchProps
1695
1998
  });
1696
1999
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1697
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2000
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1698
2001
  };
1699
2002
  _deleteRecord = new WeakSet();
1700
- deleteRecord_fn = async function(recordId) {
2003
+ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1701
2004
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1702
- await deleteRecord({
1703
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1704
- ...fetchProps
1705
- });
2005
+ try {
2006
+ const response = await deleteRecord({
2007
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2008
+ queryParams: { columns },
2009
+ ...fetchProps
2010
+ });
2011
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2012
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2013
+ } catch (e) {
2014
+ if (isObject(e) && e.status === 404) {
2015
+ return null;
2016
+ }
2017
+ throw e;
2018
+ }
1706
2019
  };
1707
2020
  _setCacheQuery = new WeakSet();
1708
2021
  setCacheQuery_fn = async function(query, meta, records) {
@@ -1739,7 +2052,7 @@ const transformObjectLinks = (object) => {
1739
2052
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
1740
2053
  }, {});
1741
2054
  };
1742
- const initObject = (db, schemaTables, table, object) => {
2055
+ const initObject = (db, schemaTables, table, object, selectedColumns) => {
1743
2056
  const result = {};
1744
2057
  const { xata, ...rest } = object ?? {};
1745
2058
  Object.assign(result, rest);
@@ -1747,6 +2060,8 @@ const initObject = (db, schemaTables, table, object) => {
1747
2060
  if (!columns)
1748
2061
  console.error(`Table ${table} not found in schema`);
1749
2062
  for (const column of columns ?? []) {
2063
+ if (!isValidColumn(selectedColumns, column))
2064
+ continue;
1750
2065
  const value = result[column.name];
1751
2066
  switch (column.type) {
1752
2067
  case "datetime": {
@@ -1763,10 +2078,28 @@ const initObject = (db, schemaTables, table, object) => {
1763
2078
  if (!linkTable) {
1764
2079
  console.error(`Failed to parse link for field ${column.name}`);
1765
2080
  } else if (isObject(value)) {
1766
- result[column.name] = initObject(db, schemaTables, linkTable, value);
2081
+ const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
2082
+ if (item === column.name) {
2083
+ return [...acc, "*"];
2084
+ }
2085
+ if (item.startsWith(`${column.name}.`)) {
2086
+ const [, ...path] = item.split(".");
2087
+ return [...acc, path.join(".")];
2088
+ }
2089
+ return acc;
2090
+ }, []);
2091
+ result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2092
+ } else {
2093
+ result[column.name] = null;
1767
2094
  }
1768
2095
  break;
1769
2096
  }
2097
+ default:
2098
+ result[column.name] = value ?? null;
2099
+ if (column.notNull === true && value === null) {
2100
+ console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2101
+ }
2102
+ break;
1770
2103
  }
1771
2104
  }
1772
2105
  result.read = function(columns2) {
@@ -1790,6 +2123,28 @@ const initObject = (db, schemaTables, table, object) => {
1790
2123
  function isResponseWithRecords(value) {
1791
2124
  return isObject(value) && Array.isArray(value.records);
1792
2125
  }
2126
+ function extractId(value) {
2127
+ if (isString(value))
2128
+ return value;
2129
+ if (isObject(value) && isString(value.id))
2130
+ return value.id;
2131
+ return void 0;
2132
+ }
2133
+ function cleanFilter(filter) {
2134
+ if (!filter)
2135
+ return void 0;
2136
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2137
+ return values.length > 0 ? filter : void 0;
2138
+ }
2139
+ function isValidColumn(columns, column) {
2140
+ if (columns.includes("*"))
2141
+ return true;
2142
+ if (column.type === "link") {
2143
+ const linkColumns = columns.filter((item) => item.startsWith(column.name));
2144
+ return linkColumns.length > 0;
2145
+ }
2146
+ return columns.includes(column.name);
2147
+ }
1793
2148
 
1794
2149
  var __accessCheck$3 = (obj, member, msg) => {
1795
2150
  if (!member.has(obj))
@@ -1840,18 +2195,25 @@ class SimpleCache {
1840
2195
  }
1841
2196
  _map = new WeakMap();
1842
2197
 
1843
- const gt = (value) => ({ $gt: value });
1844
- const ge = (value) => ({ $ge: value });
1845
- const gte = (value) => ({ $ge: value });
1846
- const lt = (value) => ({ $lt: value });
1847
- const lte = (value) => ({ $le: value });
1848
- const le = (value) => ({ $le: value });
2198
+ const greaterThan = (value) => ({ $gt: value });
2199
+ const gt = greaterThan;
2200
+ const greaterThanEquals = (value) => ({ $ge: value });
2201
+ const greaterEquals = greaterThanEquals;
2202
+ const gte = greaterThanEquals;
2203
+ const ge = greaterThanEquals;
2204
+ const lessThan = (value) => ({ $lt: value });
2205
+ const lt = lessThan;
2206
+ const lessThanEquals = (value) => ({ $le: value });
2207
+ const lessEquals = lessThanEquals;
2208
+ const lte = lessThanEquals;
2209
+ const le = lessThanEquals;
1849
2210
  const exists = (column) => ({ $exists: column });
1850
2211
  const notExists = (column) => ({ $notExists: column });
1851
2212
  const startsWith = (value) => ({ $startsWith: value });
1852
2213
  const endsWith = (value) => ({ $endsWith: value });
1853
2214
  const pattern = (value) => ({ $pattern: value });
1854
2215
  const is = (value) => ({ $is: value });
2216
+ const equals = is;
1855
2217
  const isNot = (value) => ({ $isNot: value });
1856
2218
  const contains = (value) => ({ $contains: value });
1857
2219
  const includes = (value) => ({ $includes: value });
@@ -1948,7 +2310,7 @@ class SearchPlugin extends XataPlugin {
1948
2310
  const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
1949
2311
  return records.map((record) => {
1950
2312
  const { table = "orphan" } = record.xata;
1951
- return { table, record: initObject(this.db, schemaTables, table, record) };
2313
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
1952
2314
  });
1953
2315
  },
1954
2316
  byTable: async (query, options = {}) => {
@@ -1957,7 +2319,7 @@ class SearchPlugin extends XataPlugin {
1957
2319
  return records.reduce((acc, record) => {
1958
2320
  const { table = "orphan" } = record.xata;
1959
2321
  const items = acc[table] ?? [];
1960
- const item = initObject(this.db, schemaTables, table, record);
2322
+ const item = initObject(this.db, schemaTables, table, record, ["*"]);
1961
2323
  return { ...acc, [table]: [...items, item] };
1962
2324
  }, {});
1963
2325
  }
@@ -2138,8 +2500,11 @@ const buildClient = (plugins) => {
2138
2500
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
2139
2501
  const trace = options?.trace ?? defaultTrace;
2140
2502
  const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
2141
- if (!databaseURL || !apiKey) {
2142
- throw new Error("Options databaseURL and apiKey are required");
2503
+ if (!apiKey) {
2504
+ throw new Error("Option apiKey is required");
2505
+ }
2506
+ if (!databaseURL) {
2507
+ throw new Error("Option databaseURL is required");
2143
2508
  }
2144
2509
  return { fetch, databaseURL, apiKey, branch, cache, trace };
2145
2510
  }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
@@ -2152,7 +2517,7 @@ const buildClient = (plugins) => {
2152
2517
  apiUrl: "",
2153
2518
  workspacesApiUrl: (path, params) => {
2154
2519
  const hasBranch = params.dbBranchName ?? params.branch;
2155
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
2520
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
2156
2521
  return databaseURL + newPath;
2157
2522
  },
2158
2523
  trace
@@ -2289,13 +2654,23 @@ exports.XataPlugin = XataPlugin;
2289
2654
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
2290
2655
  exports.addGitBranchesEntry = addGitBranchesEntry;
2291
2656
  exports.addTableColumn = addTableColumn;
2657
+ exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
2292
2658
  exports.buildClient = buildClient;
2293
2659
  exports.buildWorkerRunner = buildWorkerRunner;
2294
2660
  exports.bulkInsertTableRecords = bulkInsertTableRecords;
2661
+ exports.cPcreateDatabase = cPcreateDatabase;
2662
+ exports.cPdeleteDatabase = cPdeleteDatabase;
2663
+ exports.cPgetCPDatabaseMetadata = cPgetCPDatabaseMetadata;
2664
+ exports.cPgetDatabaseList = cPgetDatabaseList;
2665
+ exports.cPupdateCPDatabaseMetadata = cPupdateCPDatabaseMetadata;
2295
2666
  exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
2667
+ exports.compareBranchSchemas = compareBranchSchemas;
2668
+ exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
2669
+ exports.compareMigrationRequest = compareMigrationRequest;
2296
2670
  exports.contains = contains;
2297
2671
  exports.createBranch = createBranch;
2298
2672
  exports.createDatabase = createDatabase;
2673
+ exports.createMigrationRequest = createMigrationRequest;
2299
2674
  exports.createTable = createTable;
2300
2675
  exports.createUserAPIKey = createUserAPIKey;
2301
2676
  exports.createWorkspace = createWorkspace;
@@ -2309,6 +2684,7 @@ exports.deleteUserAPIKey = deleteUserAPIKey;
2309
2684
  exports.deleteWorkspace = deleteWorkspace;
2310
2685
  exports.deserialize = deserialize;
2311
2686
  exports.endsWith = endsWith;
2687
+ exports.equals = equals;
2312
2688
  exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
2313
2689
  exports.exists = exists;
2314
2690
  exports.ge = ge;
@@ -2318,6 +2694,7 @@ exports.getBranchList = getBranchList;
2318
2694
  exports.getBranchMetadata = getBranchMetadata;
2319
2695
  exports.getBranchMigrationHistory = getBranchMigrationHistory;
2320
2696
  exports.getBranchMigrationPlan = getBranchMigrationPlan;
2697
+ exports.getBranchSchemaHistory = getBranchSchemaHistory;
2321
2698
  exports.getBranchStats = getBranchStats;
2322
2699
  exports.getColumn = getColumn;
2323
2700
  exports.getCurrentBranchDetails = getCurrentBranchDetails;
@@ -2326,6 +2703,8 @@ exports.getDatabaseList = getDatabaseList;
2326
2703
  exports.getDatabaseMetadata = getDatabaseMetadata;
2327
2704
  exports.getDatabaseURL = getDatabaseURL;
2328
2705
  exports.getGitBranchesMapping = getGitBranchesMapping;
2706
+ exports.getMigrationRequest = getMigrationRequest;
2707
+ exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
2329
2708
  exports.getRecord = getRecord;
2330
2709
  exports.getTableColumns = getTableColumns;
2331
2710
  exports.getTableSchema = getTableSchema;
@@ -2334,6 +2713,9 @@ exports.getUserAPIKeys = getUserAPIKeys;
2334
2713
  exports.getWorkspace = getWorkspace;
2335
2714
  exports.getWorkspaceMembersList = getWorkspaceMembersList;
2336
2715
  exports.getWorkspacesList = getWorkspacesList;
2716
+ exports.greaterEquals = greaterEquals;
2717
+ exports.greaterThan = greaterThan;
2718
+ exports.greaterThanEquals = greaterThanEquals;
2337
2719
  exports.gt = gt;
2338
2720
  exports.gte = gte;
2339
2721
  exports.includes = includes;
@@ -2349,11 +2731,18 @@ exports.isIdentifiable = isIdentifiable;
2349
2731
  exports.isNot = isNot;
2350
2732
  exports.isXataRecord = isXataRecord;
2351
2733
  exports.le = le;
2734
+ exports.lessEquals = lessEquals;
2735
+ exports.lessThan = lessThan;
2736
+ exports.lessThanEquals = lessThanEquals;
2737
+ exports.listMigrationRequests = listMigrationRequests;
2738
+ exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
2352
2739
  exports.lt = lt;
2353
2740
  exports.lte = lte;
2741
+ exports.mergeMigrationRequest = mergeMigrationRequest;
2354
2742
  exports.notExists = notExists;
2355
2743
  exports.operationsByTag = operationsByTag;
2356
2744
  exports.pattern = pattern;
2745
+ exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
2357
2746
  exports.queryTable = queryTable;
2358
2747
  exports.removeGitBranchesEntry = removeGitBranchesEntry;
2359
2748
  exports.removeWorkspaceMember = removeWorkspaceMember;
@@ -2364,8 +2753,12 @@ exports.searchTable = searchTable;
2364
2753
  exports.serialize = serialize;
2365
2754
  exports.setTableSchema = setTableSchema;
2366
2755
  exports.startsWith = startsWith;
2756
+ exports.summarizeTable = summarizeTable;
2367
2757
  exports.updateBranchMetadata = updateBranchMetadata;
2758
+ exports.updateBranchSchema = updateBranchSchema;
2368
2759
  exports.updateColumn = updateColumn;
2760
+ exports.updateDatabaseMetadata = updateDatabaseMetadata;
2761
+ exports.updateMigrationRequest = updateMigrationRequest;
2369
2762
  exports.updateRecordWithID = updateRecordWithID;
2370
2763
  exports.updateTable = updateTable;
2371
2764
  exports.updateUser = updateUser;