@xata.io/client 0.0.0-alpha.vf73045e → 0.0.0-alpha.vf87d751

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,3 +1,25 @@
1
+ const defaultTrace = async (_name, fn, _options) => {
2
+ return await fn({
3
+ setAttributes: () => {
4
+ return;
5
+ }
6
+ });
7
+ };
8
+ const TraceAttributes = {
9
+ KIND: "xata.trace.kind",
10
+ VERSION: "xata.sdk.version",
11
+ TABLE: "xata.table",
12
+ HTTP_REQUEST_ID: "http.request_id",
13
+ HTTP_STATUS_CODE: "http.status_code",
14
+ HTTP_HOST: "http.host",
15
+ HTTP_SCHEME: "http.scheme",
16
+ HTTP_USER_AGENT: "http.user_agent",
17
+ HTTP_METHOD: "http.method",
18
+ HTTP_URL: "http.url",
19
+ HTTP_ROUTE: "http.route",
20
+ HTTP_TARGET: "http.target"
21
+ };
22
+
1
23
  function notEmpty(value) {
2
24
  return value !== null && value !== void 0;
3
25
  }
@@ -122,13 +144,13 @@ function getFetchImplementation(userFetch) {
122
144
  const fetchImpl = userFetch ?? globalFetch;
123
145
  if (!fetchImpl) {
124
146
  throw new Error(
125
- `The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`
147
+ `Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
126
148
  );
127
149
  }
128
150
  return fetchImpl;
129
151
  }
130
152
 
131
- const VERSION = "0.0.0-alpha.vf73045e";
153
+ const VERSION = "0.0.0-alpha.vf87d751";
132
154
 
133
155
  class ErrorWithCause extends Error {
134
156
  constructor(message, options) {
@@ -179,7 +201,10 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
179
201
  }, {});
180
202
  const query = new URLSearchParams(cleanQueryParams).toString();
181
203
  const queryString = query.length > 0 ? `?${query}` : "";
182
- return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
204
+ const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
205
+ return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
206
+ }, {});
207
+ return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
183
208
  };
184
209
  function buildBaseUrl({
185
210
  path,
@@ -187,10 +212,10 @@ function buildBaseUrl({
187
212
  apiUrl,
188
213
  pathParams
189
214
  }) {
190
- if (!pathParams?.workspace)
215
+ if (pathParams?.workspace === void 0)
191
216
  return `${apiUrl}${path}`;
192
217
  const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
193
- return url.replace("{workspaceId}", pathParams.workspace);
218
+ return url.replace("{workspaceId}", String(pathParams.workspace));
194
219
  }
195
220
  function hostHeader(url) {
196
221
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
@@ -207,34 +232,61 @@ async function fetch$1({
207
232
  fetchImpl,
208
233
  apiKey,
209
234
  apiUrl,
210
- workspacesApiUrl
235
+ workspacesApiUrl,
236
+ trace
211
237
  }) {
212
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
213
- const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
214
- const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
215
- const response = await fetchImpl(url, {
216
- method: method.toUpperCase(),
217
- body: body ? JSON.stringify(body) : void 0,
218
- headers: {
219
- "Content-Type": "application/json",
220
- "User-Agent": `Xata client-ts/${VERSION}`,
221
- ...headers,
222
- ...hostHeader(fullUrl),
223
- Authorization: `Bearer ${apiKey}`
224
- }
225
- });
226
- if (response.status === 204) {
227
- return {};
228
- }
229
- const requestId = response.headers?.get("x-request-id") ?? void 0;
238
+ return trace(
239
+ `${method.toUpperCase()} ${path}`,
240
+ async ({ setAttributes }) => {
241
+ const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
242
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
243
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
244
+ setAttributes({
245
+ [TraceAttributes.HTTP_URL]: url,
246
+ [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
247
+ });
248
+ const response = await fetchImpl(url, {
249
+ method: method.toUpperCase(),
250
+ body: body ? JSON.stringify(body) : void 0,
251
+ headers: {
252
+ "Content-Type": "application/json",
253
+ "User-Agent": `Xata client-ts/${VERSION}`,
254
+ ...headers,
255
+ ...hostHeader(fullUrl),
256
+ Authorization: `Bearer ${apiKey}`
257
+ }
258
+ });
259
+ if (response.status === 204) {
260
+ return {};
261
+ }
262
+ const { host, protocol } = parseUrl(response.url);
263
+ const requestId = response.headers?.get("x-request-id") ?? void 0;
264
+ setAttributes({
265
+ [TraceAttributes.KIND]: "http",
266
+ [TraceAttributes.HTTP_REQUEST_ID]: requestId,
267
+ [TraceAttributes.HTTP_STATUS_CODE]: response.status,
268
+ [TraceAttributes.HTTP_HOST]: host,
269
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
270
+ });
271
+ try {
272
+ const jsonResponse = await response.json();
273
+ if (response.ok) {
274
+ return jsonResponse;
275
+ }
276
+ throw new FetcherError(response.status, jsonResponse, requestId);
277
+ } catch (error) {
278
+ throw new FetcherError(response.status, error, requestId);
279
+ }
280
+ },
281
+ { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
282
+ );
283
+ }
284
+ function parseUrl(url) {
230
285
  try {
231
- const jsonResponse = await response.json();
232
- if (response.ok) {
233
- return jsonResponse;
234
- }
235
- throw new FetcherError(response.status, jsonResponse, requestId);
286
+ const { host, protocol } = new URL(url);
287
+ return { host, protocol };
236
288
  } catch (error) {
237
- throw new FetcherError(response.status, error, requestId);
289
+ return {};
238
290
  }
239
291
  }
240
292
 
@@ -334,6 +386,7 @@ const getDatabaseMetadata = (variables) => fetch$1({
334
386
  method: "get",
335
387
  ...variables
336
388
  });
389
+ const patchDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
337
390
  const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
338
391
  const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
339
392
  const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
@@ -342,6 +395,22 @@ const resolveBranch = (variables) => fetch$1({
342
395
  method: "get",
343
396
  ...variables
344
397
  });
398
+ const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
399
+ const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
400
+ const getMigrationRequest = (variables) => fetch$1({
401
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
402
+ method: "get",
403
+ ...variables
404
+ });
405
+ const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
406
+ const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
407
+ const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
408
+ const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
409
+ const mergeMigrationRequest = (variables) => fetch$1({
410
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
411
+ method: "post",
412
+ ...variables
413
+ });
345
414
  const getBranchDetails = (variables) => fetch$1({
346
415
  url: "/db/{dbBranchName}",
347
416
  method: "get",
@@ -366,6 +435,16 @@ const getBranchMetadata = (variables) => fetch$1({
366
435
  const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
367
436
  const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
368
437
  const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
438
+ const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
439
+ const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
440
+ const updateBranchSchema = (variables) => fetch$1({
441
+ url: "/db/{dbBranchName}/schema/update",
442
+ method: "post",
443
+ ...variables
444
+ });
445
+ const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
446
+ const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
447
+ const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
369
448
  const getBranchStats = (variables) => fetch$1({
370
449
  url: "/db/{dbBranchName}/stats",
371
450
  method: "get",
@@ -473,6 +552,7 @@ const operationsByTag = {
473
552
  createDatabase,
474
553
  deleteDatabase,
475
554
  getDatabaseMetadata,
555
+ patchDatabaseMetadata,
476
556
  getGitBranchesMapping,
477
557
  addGitBranchesEntry,
478
558
  removeGitBranchesEntry,
@@ -485,10 +565,28 @@ const operationsByTag = {
485
565
  deleteBranch,
486
566
  updateBranchMetadata,
487
567
  getBranchMetadata,
568
+ getBranchStats
569
+ },
570
+ migrationRequests: {
571
+ listMigrationRequests,
572
+ createMigrationRequest,
573
+ getMigrationRequest,
574
+ updateMigrationRequest,
575
+ listMigrationRequestsCommits,
576
+ compareMigrationRequest,
577
+ getMigrationRequestIsMerged,
578
+ mergeMigrationRequest
579
+ },
580
+ branchSchema: {
488
581
  getBranchMigrationHistory,
489
582
  executeBranchMigrationPlan,
490
583
  getBranchMigrationPlan,
491
- getBranchStats
584
+ compareBranchWithUserSchema,
585
+ compareBranchSchemas,
586
+ updateBranchSchema,
587
+ previewBranchSchemaEdit,
588
+ applyBranchSchemaEdit,
589
+ getBranchSchemaHistory
492
590
  },
493
591
  table: {
494
592
  createTable,
@@ -517,9 +615,9 @@ const operationsByTag = {
517
615
  };
518
616
 
519
617
  function getHostUrl(provider, type) {
520
- if (isValidAlias(provider)) {
618
+ if (isHostProviderAlias(provider)) {
521
619
  return providers[provider][type];
522
- } else if (isValidBuilder(provider)) {
620
+ } else if (isHostProviderBuilder(provider)) {
523
621
  return provider[type];
524
622
  }
525
623
  throw new Error("Invalid API provider");
@@ -534,10 +632,10 @@ const providers = {
534
632
  workspaces: "https://{workspaceId}.staging.xatabase.co"
535
633
  }
536
634
  };
537
- function isValidAlias(alias) {
635
+ function isHostProviderAlias(alias) {
538
636
  return isString(alias) && Object.keys(providers).includes(alias);
539
637
  }
540
- function isValidBuilder(builder) {
638
+ function isHostProviderBuilder(builder) {
541
639
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
542
640
  }
543
641
 
@@ -565,7 +663,8 @@ class XataApiClient {
565
663
  __privateAdd$7(this, _extraProps, void 0);
566
664
  __privateAdd$7(this, _namespaces, {});
567
665
  const provider = options.host ?? "production";
568
- const apiKey = options?.apiKey ?? getAPIKey();
666
+ const apiKey = options.apiKey ?? getAPIKey();
667
+ const trace = options.trace ?? defaultTrace;
569
668
  if (!apiKey) {
570
669
  throw new Error("Could not resolve a valid apiKey");
571
670
  }
@@ -573,7 +672,8 @@ class XataApiClient {
573
672
  apiUrl: getHostUrl(provider, "main"),
574
673
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
575
674
  fetchImpl: getFetchImplementation(options.fetch),
576
- apiKey
675
+ apiKey,
676
+ trace
577
677
  });
578
678
  }
579
679
  get user() {
@@ -606,6 +706,16 @@ class XataApiClient {
606
706
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
607
707
  return __privateGet$7(this, _namespaces).records;
608
708
  }
709
+ get migrationRequests() {
710
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
711
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
712
+ return __privateGet$7(this, _namespaces).migrationRequests;
713
+ }
714
+ get branchSchema() {
715
+ if (!__privateGet$7(this, _namespaces).branchSchema)
716
+ __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
717
+ return __privateGet$7(this, _namespaces).branchSchema;
718
+ }
609
719
  }
610
720
  _extraProps = new WeakMap();
611
721
  _namespaces = new WeakMap();
@@ -751,6 +861,13 @@ class DatabaseApi {
751
861
  ...this.extraProps
752
862
  });
753
863
  }
864
+ patchDatabaseMetadata(workspace, dbName, options = {}) {
865
+ return operationsByTag.database.patchDatabaseMetadata({
866
+ pathParams: { workspace, dbName },
867
+ body: options,
868
+ ...this.extraProps
869
+ });
870
+ }
754
871
  getGitBranchesMapping(workspace, dbName) {
755
872
  return operationsByTag.database.getGitBranchesMapping({
756
873
  pathParams: { workspace, dbName },
@@ -822,27 +939,6 @@ class BranchApi {
822
939
  ...this.extraProps
823
940
  });
824
941
  }
825
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
826
- return operationsByTag.branch.getBranchMigrationHistory({
827
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
828
- body: options,
829
- ...this.extraProps
830
- });
831
- }
832
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
833
- return operationsByTag.branch.executeBranchMigrationPlan({
834
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
835
- body: migrationPlan,
836
- ...this.extraProps
837
- });
838
- }
839
- getBranchMigrationPlan(workspace, database, branch, schema) {
840
- return operationsByTag.branch.getBranchMigrationPlan({
841
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
842
- body: schema,
843
- ...this.extraProps
844
- });
845
- }
846
942
  getBranchStats(workspace, database, branch) {
847
943
  return operationsByTag.branch.getBranchStats({
848
944
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
@@ -999,6 +1095,131 @@ class RecordsApi {
999
1095
  });
1000
1096
  }
1001
1097
  }
1098
+ class MigrationRequestsApi {
1099
+ constructor(extraProps) {
1100
+ this.extraProps = extraProps;
1101
+ }
1102
+ listMigrationRequests(workspace, database, options = {}) {
1103
+ return operationsByTag.migrationRequests.listMigrationRequests({
1104
+ pathParams: { workspace, dbName: database },
1105
+ body: options,
1106
+ ...this.extraProps
1107
+ });
1108
+ }
1109
+ createMigrationRequest(workspace, database, options) {
1110
+ return operationsByTag.migrationRequests.createMigrationRequest({
1111
+ pathParams: { workspace, dbName: database },
1112
+ body: options,
1113
+ ...this.extraProps
1114
+ });
1115
+ }
1116
+ getMigrationRequest(workspace, database, migrationRequest) {
1117
+ return operationsByTag.migrationRequests.getMigrationRequest({
1118
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1119
+ ...this.extraProps
1120
+ });
1121
+ }
1122
+ updateMigrationRequest(workspace, database, migrationRequest, options) {
1123
+ return operationsByTag.migrationRequests.updateMigrationRequest({
1124
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1125
+ body: options,
1126
+ ...this.extraProps
1127
+ });
1128
+ }
1129
+ listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1130
+ return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1131
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1132
+ body: options,
1133
+ ...this.extraProps
1134
+ });
1135
+ }
1136
+ compareMigrationRequest(workspace, database, migrationRequest) {
1137
+ return operationsByTag.migrationRequests.compareMigrationRequest({
1138
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1139
+ ...this.extraProps
1140
+ });
1141
+ }
1142
+ getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1143
+ return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1144
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1145
+ ...this.extraProps
1146
+ });
1147
+ }
1148
+ mergeMigrationRequest(workspace, database, migrationRequest) {
1149
+ return operationsByTag.migrationRequests.mergeMigrationRequest({
1150
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1151
+ ...this.extraProps
1152
+ });
1153
+ }
1154
+ }
1155
+ class BranchSchemaApi {
1156
+ constructor(extraProps) {
1157
+ this.extraProps = extraProps;
1158
+ }
1159
+ getBranchMigrationHistory(workspace, database, branch, options = {}) {
1160
+ return operationsByTag.branchSchema.getBranchMigrationHistory({
1161
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1162
+ body: options,
1163
+ ...this.extraProps
1164
+ });
1165
+ }
1166
+ executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1167
+ return operationsByTag.branchSchema.executeBranchMigrationPlan({
1168
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1169
+ body: migrationPlan,
1170
+ ...this.extraProps
1171
+ });
1172
+ }
1173
+ getBranchMigrationPlan(workspace, database, branch, schema) {
1174
+ return operationsByTag.branchSchema.getBranchMigrationPlan({
1175
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1176
+ body: schema,
1177
+ ...this.extraProps
1178
+ });
1179
+ }
1180
+ compareBranchWithUserSchema(workspace, database, branch, schema) {
1181
+ return operationsByTag.branchSchema.compareBranchWithUserSchema({
1182
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1183
+ body: { schema },
1184
+ ...this.extraProps
1185
+ });
1186
+ }
1187
+ compareBranchSchemas(workspace, database, branch, branchName, schema) {
1188
+ return operationsByTag.branchSchema.compareBranchSchemas({
1189
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1190
+ body: { schema },
1191
+ ...this.extraProps
1192
+ });
1193
+ }
1194
+ updateBranchSchema(workspace, database, branch, migration) {
1195
+ return operationsByTag.branchSchema.updateBranchSchema({
1196
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1197
+ body: migration,
1198
+ ...this.extraProps
1199
+ });
1200
+ }
1201
+ previewBranchSchemaEdit(workspace, database, branch, migration) {
1202
+ return operationsByTag.branchSchema.previewBranchSchemaEdit({
1203
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1204
+ body: migration,
1205
+ ...this.extraProps
1206
+ });
1207
+ }
1208
+ applyBranchSchemaEdit(workspace, database, branch, edits) {
1209
+ return operationsByTag.branchSchema.applyBranchSchemaEdit({
1210
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1211
+ body: { edits },
1212
+ ...this.extraProps
1213
+ });
1214
+ }
1215
+ getBranchSchemaHistory(workspace, database, branch, options = {}) {
1216
+ return operationsByTag.branchSchema.getBranchSchemaHistory({
1217
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1218
+ body: options,
1219
+ ...this.extraProps
1220
+ });
1221
+ }
1222
+ }
1002
1223
 
1003
1224
  class XataApiPlugin {
1004
1225
  async build(options) {
@@ -1182,14 +1403,22 @@ const _Query = class {
1182
1403
  }
1183
1404
  filter(a, b) {
1184
1405
  if (arguments.length === 1) {
1185
- const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
1406
+ const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({ [column]: constraint }));
1186
1407
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1187
1408
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1188
1409
  } else {
1189
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
1410
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.defaultFilter(a, b) }] : void 0;
1411
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1190
1412
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1191
1413
  }
1192
1414
  }
1415
+ defaultFilter(column, value) {
1416
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
1417
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
1418
+ return { $includes: value };
1419
+ }
1420
+ return value;
1421
+ }
1193
1422
  sort(column, direction = "asc") {
1194
1423
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1195
1424
  const sort = [...originalSort, { column, direction }];
@@ -1326,12 +1555,16 @@ var __privateMethod$2 = (obj, member, method) => {
1326
1555
  __accessCheck$4(obj, member, "access private method");
1327
1556
  return method;
1328
1557
  };
1329
- var _table, _getFetchProps, _db, _cache, _schemaTables$2, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
1558
+ var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
1330
1559
  class Repository extends Query {
1331
1560
  }
1332
1561
  class RestRepository extends Query {
1333
1562
  constructor(options) {
1334
- super(null, options.table, {});
1563
+ super(
1564
+ null,
1565
+ { name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
1566
+ {}
1567
+ );
1335
1568
  __privateAdd$4(this, _insertRecordWithoutId);
1336
1569
  __privateAdd$4(this, _insertRecordWithId);
1337
1570
  __privateAdd$4(this, _bulkInsertTableRecords);
@@ -1346,168 +1579,194 @@ class RestRepository extends Query {
1346
1579
  __privateAdd$4(this, _db, void 0);
1347
1580
  __privateAdd$4(this, _cache, void 0);
1348
1581
  __privateAdd$4(this, _schemaTables$2, void 0);
1582
+ __privateAdd$4(this, _trace, void 0);
1349
1583
  __privateSet$4(this, _table, options.table);
1350
1584
  __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1351
1585
  __privateSet$4(this, _db, options.db);
1352
1586
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1353
1587
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
1588
+ const trace = options.pluginOptions.trace ?? defaultTrace;
1589
+ __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
1590
+ return trace(name, fn, {
1591
+ ...options2,
1592
+ [TraceAttributes.TABLE]: __privateGet$4(this, _table),
1593
+ [TraceAttributes.KIND]: "sdk-operation",
1594
+ [TraceAttributes.VERSION]: VERSION
1595
+ });
1596
+ });
1354
1597
  }
1355
1598
  async create(a, b, c) {
1356
- if (Array.isArray(a)) {
1357
- if (a.length === 0)
1358
- return [];
1359
- const columns = isStringArray(b) ? b : void 0;
1360
- return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
1361
- }
1362
- if (isString(a) && isObject(b)) {
1363
- if (a === "")
1364
- throw new Error("The id can't be empty");
1365
- const columns = isStringArray(c) ? c : void 0;
1366
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
1367
- }
1368
- if (isObject(a) && isString(a.id)) {
1369
- if (a.id === "")
1370
- throw new Error("The id can't be empty");
1371
- const columns = isStringArray(b) ? b : void 0;
1372
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1373
- }
1374
- if (isObject(a)) {
1375
- const columns = isStringArray(b) ? b : void 0;
1376
- return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
1377
- }
1378
- throw new Error("Invalid arguments for create method");
1599
+ return __privateGet$4(this, _trace).call(this, "create", async () => {
1600
+ if (Array.isArray(a)) {
1601
+ if (a.length === 0)
1602
+ return [];
1603
+ const columns = isStringArray(b) ? b : void 0;
1604
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
1605
+ }
1606
+ if (isString(a) && isObject(b)) {
1607
+ if (a === "")
1608
+ throw new Error("The id can't be empty");
1609
+ const columns = isStringArray(c) ? c : void 0;
1610
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
1611
+ }
1612
+ if (isObject(a) && isString(a.id)) {
1613
+ if (a.id === "")
1614
+ throw new Error("The id can't be empty");
1615
+ const columns = isStringArray(b) ? b : void 0;
1616
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1617
+ }
1618
+ if (isObject(a)) {
1619
+ const columns = isStringArray(b) ? b : void 0;
1620
+ return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
1621
+ }
1622
+ throw new Error("Invalid arguments for create method");
1623
+ });
1379
1624
  }
1380
1625
  async read(a, b) {
1381
- const columns = isStringArray(b) ? b : ["*"];
1382
- if (Array.isArray(a)) {
1383
- if (a.length === 0)
1384
- return [];
1385
- const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
1386
- const finalObjects = await this.getAll({ filter: { id: { $any: ids } }, columns });
1387
- const dictionary = finalObjects.reduce((acc, object) => {
1388
- acc[object.id] = object;
1389
- return acc;
1390
- }, {});
1391
- return ids.map((id2) => dictionary[id2] ?? null);
1392
- }
1393
- const id = isString(a) ? a : a.id;
1394
- if (isString(id)) {
1395
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1396
- try {
1397
- const response = await getRecord({
1398
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: id },
1399
- queryParams: { columns },
1400
- ...fetchProps
1401
- });
1402
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1403
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1404
- } catch (e) {
1405
- if (isObject(e) && e.status === 404) {
1406
- return null;
1626
+ return __privateGet$4(this, _trace).call(this, "read", async () => {
1627
+ const columns = isStringArray(b) ? b : ["*"];
1628
+ if (Array.isArray(a)) {
1629
+ if (a.length === 0)
1630
+ return [];
1631
+ const ids = a.map((item) => extractId(item));
1632
+ const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
1633
+ const dictionary = finalObjects.reduce((acc, object) => {
1634
+ acc[object.id] = object;
1635
+ return acc;
1636
+ }, {});
1637
+ return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
1638
+ }
1639
+ const id = extractId(a);
1640
+ if (id) {
1641
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1642
+ try {
1643
+ const response = await getRecord({
1644
+ pathParams: {
1645
+ workspace: "{workspaceId}",
1646
+ dbBranchName: "{dbBranch}",
1647
+ tableName: __privateGet$4(this, _table),
1648
+ recordId: id
1649
+ },
1650
+ queryParams: { columns },
1651
+ ...fetchProps
1652
+ });
1653
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1654
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1655
+ } catch (e) {
1656
+ if (isObject(e) && e.status === 404) {
1657
+ return null;
1658
+ }
1659
+ throw e;
1407
1660
  }
1408
- throw e;
1409
1661
  }
1410
- }
1411
- return null;
1662
+ return null;
1663
+ });
1412
1664
  }
1413
1665
  async update(a, b, c) {
1414
- if (Array.isArray(a)) {
1415
- if (a.length === 0)
1416
- return [];
1417
- if (a.length > 100) {
1418
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1666
+ return __privateGet$4(this, _trace).call(this, "update", async () => {
1667
+ if (Array.isArray(a)) {
1668
+ if (a.length === 0)
1669
+ return [];
1670
+ if (a.length > 100) {
1671
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1672
+ }
1673
+ const columns = isStringArray(b) ? b : ["*"];
1674
+ return Promise.all(a.map((object) => this.update(object, columns)));
1419
1675
  }
1420
- const columns = isStringArray(b) ? b : ["*"];
1421
- return Promise.all(a.map((object) => this.update(object, columns)));
1422
- }
1423
- if (isString(a) && isObject(b)) {
1424
- const columns = isStringArray(c) ? c : void 0;
1425
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
1426
- }
1427
- if (isObject(a) && isString(a.id)) {
1428
- const columns = isStringArray(b) ? b : void 0;
1429
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1430
- }
1431
- throw new Error("Invalid arguments for update method");
1676
+ if (isString(a) && isObject(b)) {
1677
+ const columns = isStringArray(c) ? c : void 0;
1678
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
1679
+ }
1680
+ if (isObject(a) && isString(a.id)) {
1681
+ const columns = isStringArray(b) ? b : void 0;
1682
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1683
+ }
1684
+ throw new Error("Invalid arguments for update method");
1685
+ });
1432
1686
  }
1433
1687
  async createOrUpdate(a, b, c) {
1434
- if (Array.isArray(a)) {
1435
- if (a.length === 0)
1436
- return [];
1437
- if (a.length > 100) {
1438
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1688
+ return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
1689
+ if (Array.isArray(a)) {
1690
+ if (a.length === 0)
1691
+ return [];
1692
+ if (a.length > 100) {
1693
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1694
+ }
1695
+ const columns = isStringArray(b) ? b : ["*"];
1696
+ return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
1439
1697
  }
1440
- const columns = isStringArray(b) ? b : ["*"];
1441
- return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
1442
- }
1443
- if (isString(a) && isObject(b)) {
1444
- const columns = isStringArray(c) ? c : void 0;
1445
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
1446
- }
1447
- if (isObject(a) && isString(a.id)) {
1448
- const columns = isStringArray(c) ? c : void 0;
1449
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1450
- }
1451
- throw new Error("Invalid arguments for createOrUpdate method");
1452
- }
1453
- async delete(a) {
1454
- if (Array.isArray(a)) {
1455
- if (a.length === 0)
1456
- return;
1457
- if (a.length > 100) {
1458
- console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1698
+ if (isString(a) && isObject(b)) {
1699
+ const columns = isStringArray(c) ? c : void 0;
1700
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
1459
1701
  }
1460
- await Promise.all(a.map((id) => this.delete(id)));
1461
- return;
1462
- }
1463
- if (isString(a)) {
1464
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
1465
- return;
1466
- }
1467
- if (isObject(a) && isString(a.id)) {
1468
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
1469
- return;
1470
- }
1471
- throw new Error("Invalid arguments for delete method");
1702
+ if (isObject(a) && isString(a.id)) {
1703
+ const columns = isStringArray(c) ? c : void 0;
1704
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1705
+ }
1706
+ throw new Error("Invalid arguments for createOrUpdate method");
1707
+ });
1708
+ }
1709
+ async delete(a, b) {
1710
+ return __privateGet$4(this, _trace).call(this, "delete", async () => {
1711
+ if (Array.isArray(a)) {
1712
+ if (a.length === 0)
1713
+ return [];
1714
+ if (a.length > 100) {
1715
+ console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1716
+ }
1717
+ return Promise.all(a.map((id) => this.delete(id, b)));
1718
+ }
1719
+ if (isString(a)) {
1720
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
1721
+ }
1722
+ if (isObject(a) && isString(a.id)) {
1723
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
1724
+ }
1725
+ throw new Error("Invalid arguments for delete method");
1726
+ });
1472
1727
  }
1473
1728
  async search(query, options = {}) {
1474
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1475
- const { records } = await searchTable({
1476
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1477
- body: {
1478
- query,
1479
- fuzziness: options.fuzziness,
1480
- prefix: options.prefix,
1481
- highlight: options.highlight,
1482
- filter: options.filter,
1483
- boosters: options.boosters
1484
- },
1485
- ...fetchProps
1729
+ return __privateGet$4(this, _trace).call(this, "search", async () => {
1730
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1731
+ const { records } = await searchTable({
1732
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1733
+ body: {
1734
+ query,
1735
+ fuzziness: options.fuzziness,
1736
+ prefix: options.prefix,
1737
+ highlight: options.highlight,
1738
+ filter: options.filter,
1739
+ boosters: options.boosters
1740
+ },
1741
+ ...fetchProps
1742
+ });
1743
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1744
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
1486
1745
  });
1487
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1488
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
1489
1746
  }
1490
1747
  async query(query) {
1491
- const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1492
- if (cacheQuery)
1493
- return new Page(query, cacheQuery.meta, cacheQuery.records);
1494
- const data = query.getQueryOptions();
1495
- const body = {
1496
- filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1497
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1498
- page: data.pagination,
1499
- columns: data.columns
1500
- };
1501
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1502
- const { meta, records: objects } = await queryTable({
1503
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1504
- body,
1505
- ...fetchProps
1748
+ return __privateGet$4(this, _trace).call(this, "query", async () => {
1749
+ const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1750
+ if (cacheQuery)
1751
+ return new Page(query, cacheQuery.meta, cacheQuery.records);
1752
+ const data = query.getQueryOptions();
1753
+ const body = {
1754
+ filter: cleanFilter(data.filter),
1755
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1756
+ page: data.pagination,
1757
+ columns: data.columns
1758
+ };
1759
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1760
+ const { meta, records: objects } = await queryTable({
1761
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1762
+ body,
1763
+ ...fetchProps
1764
+ });
1765
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1766
+ const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
1767
+ await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1768
+ return new Page(query, meta, records);
1506
1769
  });
1507
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1508
- const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
1509
- await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1510
- return new Page(query, meta, records);
1511
1770
  }
1512
1771
  }
1513
1772
  _table = new WeakMap();
@@ -1515,6 +1774,7 @@ _getFetchProps = new WeakMap();
1515
1774
  _db = new WeakMap();
1516
1775
  _cache = new WeakMap();
1517
1776
  _schemaTables$2 = new WeakMap();
1777
+ _trace = new WeakMap();
1518
1778
  _insertRecordWithoutId = new WeakSet();
1519
1779
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1520
1780
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
@@ -1570,14 +1830,21 @@ _updateRecordWithID = new WeakSet();
1570
1830
  updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1571
1831
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1572
1832
  const record = transformObjectLinks(object);
1573
- const response = await updateRecordWithID({
1574
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1575
- queryParams: { columns },
1576
- body: record,
1577
- ...fetchProps
1578
- });
1579
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1580
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1833
+ try {
1834
+ const response = await updateRecordWithID({
1835
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1836
+ queryParams: { columns },
1837
+ body: record,
1838
+ ...fetchProps
1839
+ });
1840
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1841
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1842
+ } catch (e) {
1843
+ if (isObject(e) && e.status === 404) {
1844
+ return null;
1845
+ }
1846
+ throw e;
1847
+ }
1581
1848
  };
1582
1849
  _upsertRecordWithID = new WeakSet();
1583
1850
  upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
@@ -1592,12 +1859,22 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1592
1859
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1593
1860
  };
1594
1861
  _deleteRecord = new WeakSet();
1595
- deleteRecord_fn = async function(recordId) {
1862
+ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1596
1863
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1597
- await deleteRecord({
1598
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1599
- ...fetchProps
1600
- });
1864
+ try {
1865
+ const response = await deleteRecord({
1866
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1867
+ queryParams: { columns },
1868
+ ...fetchProps
1869
+ });
1870
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1871
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1872
+ } catch (e) {
1873
+ if (isObject(e) && e.status === 404) {
1874
+ return null;
1875
+ }
1876
+ throw e;
1877
+ }
1601
1878
  };
1602
1879
  _setCacheQuery = new WeakSet();
1603
1880
  setCacheQuery_fn = async function(query, meta, records) {
@@ -1685,6 +1962,19 @@ const initObject = (db, schemaTables, table, object) => {
1685
1962
  function isResponseWithRecords(value) {
1686
1963
  return isObject(value) && Array.isArray(value.records);
1687
1964
  }
1965
+ function extractId(value) {
1966
+ if (isString(value))
1967
+ return value;
1968
+ if (isObject(value) && isString(value.id))
1969
+ return value.id;
1970
+ return void 0;
1971
+ }
1972
+ function cleanFilter(filter) {
1973
+ if (!filter)
1974
+ return void 0;
1975
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
1976
+ return values.length > 0 ? filter : void 0;
1977
+ }
1688
1978
 
1689
1979
  var __accessCheck$3 = (obj, member, msg) => {
1690
1980
  if (!member.has(obj))
@@ -1735,18 +2025,25 @@ class SimpleCache {
1735
2025
  }
1736
2026
  _map = new WeakMap();
1737
2027
 
1738
- const gt = (value) => ({ $gt: value });
1739
- const ge = (value) => ({ $ge: value });
1740
- const gte = (value) => ({ $ge: value });
1741
- const lt = (value) => ({ $lt: value });
1742
- const lte = (value) => ({ $le: value });
1743
- const le = (value) => ({ $le: value });
2028
+ const greaterThan = (value) => ({ $gt: value });
2029
+ const gt = greaterThan;
2030
+ const greaterThanEquals = (value) => ({ $ge: value });
2031
+ const greaterEquals = greaterThanEquals;
2032
+ const gte = greaterThanEquals;
2033
+ const ge = greaterThanEquals;
2034
+ const lessThan = (value) => ({ $lt: value });
2035
+ const lt = lessThan;
2036
+ const lessThanEquals = (value) => ({ $le: value });
2037
+ const lessEquals = lessThanEquals;
2038
+ const lte = lessThanEquals;
2039
+ const le = lessThanEquals;
1744
2040
  const exists = (column) => ({ $exists: column });
1745
2041
  const notExists = (column) => ({ $notExists: column });
1746
2042
  const startsWith = (value) => ({ $startsWith: value });
1747
2043
  const endsWith = (value) => ({ $endsWith: value });
1748
2044
  const pattern = (value) => ({ $pattern: value });
1749
2045
  const is = (value) => ({ $is: value });
2046
+ const equals = is;
1750
2047
  const isNot = (value) => ({ $isNot: value });
1751
2048
  const contains = (value) => ({ $contains: value });
1752
2049
  const includes = (value) => ({ $includes: value });
@@ -1923,7 +2220,8 @@ async function resolveXataBranch(gitBranch, options) {
1923
2220
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1924
2221
  workspacesApiUrl: `${protocol}//${host}`,
1925
2222
  pathParams: { dbName, workspace },
1926
- queryParams: { gitBranch, fallbackBranch }
2223
+ queryParams: { gitBranch, fallbackBranch },
2224
+ trace: defaultTrace
1927
2225
  });
1928
2226
  return branch;
1929
2227
  }
@@ -1947,7 +2245,8 @@ async function getDatabaseBranch(branch, options) {
1947
2245
  apiUrl: databaseURL,
1948
2246
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1949
2247
  workspacesApiUrl: `${protocol}//${host}`,
1950
- pathParams: { dbBranchName, workspace }
2248
+ pathParams: { dbBranchName, workspace },
2249
+ trace: defaultTrace
1951
2250
  });
1952
2251
  } catch (err) {
1953
2252
  if (isObject(err) && err.status === 404)
@@ -1999,7 +2298,8 @@ const buildClient = (plugins) => {
1999
2298
  __privateSet(this, _options, safeOptions);
2000
2299
  const pluginOptions = {
2001
2300
  getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
2002
- cache: safeOptions.cache
2301
+ cache: safeOptions.cache,
2302
+ trace: safeOptions.trace
2003
2303
  };
2004
2304
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
2005
2305
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
@@ -2028,12 +2328,16 @@ const buildClient = (plugins) => {
2028
2328
  const databaseURL = options?.databaseURL || getDatabaseURL();
2029
2329
  const apiKey = options?.apiKey || getAPIKey();
2030
2330
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
2331
+ const trace = options?.trace ?? defaultTrace;
2031
2332
  const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
2032
- if (!databaseURL || !apiKey) {
2033
- throw new Error("Options databaseURL and apiKey are required");
2333
+ if (!apiKey) {
2334
+ throw new Error("Option apiKey is required");
2034
2335
  }
2035
- return { fetch, databaseURL, apiKey, branch, cache };
2036
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch }) {
2336
+ if (!databaseURL) {
2337
+ throw new Error("Option databaseURL is required");
2338
+ }
2339
+ return { fetch, databaseURL, apiKey, branch, cache, trace };
2340
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
2037
2341
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2038
2342
  if (!branchValue)
2039
2343
  throw new Error("Unable to resolve branch value");
@@ -2043,9 +2347,10 @@ const buildClient = (plugins) => {
2043
2347
  apiUrl: "",
2044
2348
  workspacesApiUrl: (path, params) => {
2045
2349
  const hasBranch = params.dbBranchName ?? params.branch;
2046
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
2350
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
2047
2351
  return databaseURL + newPath;
2048
- }
2352
+ },
2353
+ trace
2049
2354
  };
2050
2355
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2051
2356
  if (__privateGet(this, _branch))
@@ -2157,5 +2462,5 @@ class XataError extends Error {
2157
2462
  }
2158
2463
  }
2159
2464
 
2160
- export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
2465
+ export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, applyBranchSchemaEdit, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequests, listMigrationRequestsCommits, lt, lte, mergeMigrationRequest, notExists, operationsByTag, patchDatabaseMetadata, pattern, previewBranchSchemaEdit, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, updateBranchMetadata, updateBranchSchema, updateColumn, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
2161
2466
  //# sourceMappingURL=index.mjs.map