@xata.io/client 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,3 +1,27 @@
1
+ const defaultTrace = async (_name, fn, _options) => {
2
+ return await fn({
3
+ setAttributes: () => {
4
+ return;
5
+ },
6
+ onError: () => {
7
+ return;
8
+ }
9
+ });
10
+ };
11
+ const TraceAttributes = {
12
+ VERSION: "xata.sdk.version",
13
+ TABLE: "xata.table",
14
+ HTTP_REQUEST_ID: "http.request_id",
15
+ HTTP_STATUS_CODE: "http.status_code",
16
+ HTTP_HOST: "http.host",
17
+ HTTP_SCHEME: "http.scheme",
18
+ HTTP_USER_AGENT: "http.user_agent",
19
+ HTTP_METHOD: "http.method",
20
+ HTTP_URL: "http.url",
21
+ HTTP_ROUTE: "http.route",
22
+ HTTP_TARGET: "http.target"
23
+ };
24
+
1
25
  function notEmpty(value) {
2
26
  return value !== null && value !== void 0;
3
27
  }
@@ -121,12 +145,14 @@ function getFetchImplementation(userFetch) {
121
145
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
122
146
  const fetchImpl = userFetch ?? globalFetch;
123
147
  if (!fetchImpl) {
124
- throw new Error(`The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`);
148
+ throw new Error(
149
+ `Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
150
+ );
125
151
  }
126
152
  return fetchImpl;
127
153
  }
128
154
 
129
- const VERSION = "0.16.0";
155
+ const VERSION = "0.17.0";
130
156
 
131
157
  class ErrorWithCause extends Error {
132
158
  constructor(message, options) {
@@ -205,34 +231,62 @@ async function fetch$1({
205
231
  fetchImpl,
206
232
  apiKey,
207
233
  apiUrl,
208
- workspacesApiUrl
234
+ workspacesApiUrl,
235
+ trace
209
236
  }) {
210
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
211
- const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
212
- const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
213
- const response = await fetchImpl(url, {
214
- method: method.toUpperCase(),
215
- body: body ? JSON.stringify(body) : void 0,
216
- headers: {
217
- "Content-Type": "application/json",
218
- "User-Agent": `Xata client-ts/${VERSION}`,
219
- ...headers,
220
- ...hostHeader(fullUrl),
221
- Authorization: `Bearer ${apiKey}`
222
- }
223
- });
224
- if (response.status === 204) {
225
- return {};
226
- }
227
- const requestId = response.headers?.get("x-request-id") ?? void 0;
237
+ return trace(
238
+ `${method.toUpperCase()} ${path}`,
239
+ async ({ setAttributes, onError }) => {
240
+ const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
241
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
242
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
243
+ setAttributes({
244
+ [TraceAttributes.HTTP_URL]: url,
245
+ [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
246
+ });
247
+ const response = await fetchImpl(url, {
248
+ method: method.toUpperCase(),
249
+ body: body ? JSON.stringify(body) : void 0,
250
+ headers: {
251
+ "Content-Type": "application/json",
252
+ "User-Agent": `Xata client-ts/${VERSION}`,
253
+ ...headers,
254
+ ...hostHeader(fullUrl),
255
+ Authorization: `Bearer ${apiKey}`
256
+ }
257
+ });
258
+ if (response.status === 204) {
259
+ return {};
260
+ }
261
+ const { host, protocol } = parseUrl(response.url);
262
+ const requestId = response.headers?.get("x-request-id") ?? void 0;
263
+ setAttributes({
264
+ [TraceAttributes.HTTP_REQUEST_ID]: requestId,
265
+ [TraceAttributes.HTTP_STATUS_CODE]: response.status,
266
+ [TraceAttributes.HTTP_HOST]: host,
267
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
268
+ });
269
+ try {
270
+ const jsonResponse = await response.json();
271
+ if (response.ok) {
272
+ return jsonResponse;
273
+ }
274
+ throw new FetcherError(response.status, jsonResponse, requestId);
275
+ } catch (error) {
276
+ const fetcherError = new FetcherError(response.status, error, requestId);
277
+ onError(fetcherError.message);
278
+ throw fetcherError;
279
+ }
280
+ },
281
+ { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
282
+ );
283
+ }
284
+ function parseUrl(url) {
228
285
  try {
229
- const jsonResponse = await response.json();
230
- if (response.ok) {
231
- return jsonResponse;
232
- }
233
- throw new FetcherError(response.status, jsonResponse, requestId);
286
+ const { host, protocol } = new URL(url);
287
+ return { host, protocol };
234
288
  } catch (error) {
235
- throw new FetcherError(response.status, error, requestId);
289
+ return {};
236
290
  }
237
291
  }
238
292
 
@@ -327,6 +381,11 @@ const deleteDatabase = (variables) => fetch$1({
327
381
  method: "delete",
328
382
  ...variables
329
383
  });
384
+ const getDatabaseMetadata = (variables) => fetch$1({
385
+ url: "/dbs/{dbName}/metadata",
386
+ method: "get",
387
+ ...variables
388
+ });
330
389
  const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
331
390
  const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
332
391
  const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
@@ -465,6 +524,7 @@ const operationsByTag = {
465
524
  getDatabaseList,
466
525
  createDatabase,
467
526
  deleteDatabase,
527
+ getDatabaseMetadata,
468
528
  getGitBranchesMapping,
469
529
  addGitBranchesEntry,
470
530
  removeGitBranchesEntry,
@@ -557,7 +617,8 @@ class XataApiClient {
557
617
  __privateAdd$7(this, _extraProps, void 0);
558
618
  __privateAdd$7(this, _namespaces, {});
559
619
  const provider = options.host ?? "production";
560
- const apiKey = options?.apiKey ?? getAPIKey();
620
+ const apiKey = options.apiKey ?? getAPIKey();
621
+ const trace = options.trace ?? defaultTrace;
561
622
  if (!apiKey) {
562
623
  throw new Error("Could not resolve a valid apiKey");
563
624
  }
@@ -565,7 +626,8 @@ class XataApiClient {
565
626
  apiUrl: getHostUrl(provider, "main"),
566
627
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
567
628
  fetchImpl: getFetchImplementation(options.fetch),
568
- apiKey
629
+ apiKey,
630
+ trace
569
631
  });
570
632
  }
571
633
  get user() {
@@ -737,6 +799,12 @@ class DatabaseApi {
737
799
  ...this.extraProps
738
800
  });
739
801
  }
802
+ getDatabaseMetadata(workspace, dbName) {
803
+ return operationsByTag.database.getDatabaseMetadata({
804
+ pathParams: { workspace, dbName },
805
+ ...this.extraProps
806
+ });
807
+ }
740
808
  getGitBranchesMapping(workspace, dbName) {
741
809
  return operationsByTag.database.getGitBranchesMapping({
742
810
  pathParams: { workspace, dbName },
@@ -1176,13 +1244,18 @@ const _Query = class {
1176
1244
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1177
1245
  }
1178
1246
  }
1179
- sort(column, direction) {
1247
+ sort(column, direction = "asc") {
1180
1248
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1181
1249
  const sort = [...originalSort, { column, direction }];
1182
1250
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
1183
1251
  }
1184
1252
  select(columns) {
1185
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { columns }, __privateGet$5(this, _data));
1253
+ return new _Query(
1254
+ __privateGet$5(this, _repository),
1255
+ __privateGet$5(this, _table$1),
1256
+ { columns },
1257
+ __privateGet$5(this, _data)
1258
+ );
1186
1259
  }
1187
1260
  getPaginated(options = {}) {
1188
1261
  const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
@@ -1307,7 +1380,7 @@ var __privateMethod$2 = (obj, member, method) => {
1307
1380
  __accessCheck$4(obj, member, "access private method");
1308
1381
  return method;
1309
1382
  };
1310
- var _table, _getFetchProps, _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;
1383
+ 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;
1311
1384
  class Repository extends Query {
1312
1385
  }
1313
1386
  class RestRepository extends Query {
@@ -1324,176 +1397,204 @@ class RestRepository extends Query {
1324
1397
  __privateAdd$4(this, _getSchemaTables$1);
1325
1398
  __privateAdd$4(this, _table, void 0);
1326
1399
  __privateAdd$4(this, _getFetchProps, void 0);
1400
+ __privateAdd$4(this, _db, void 0);
1327
1401
  __privateAdd$4(this, _cache, void 0);
1328
1402
  __privateAdd$4(this, _schemaTables$2, void 0);
1403
+ __privateAdd$4(this, _trace, void 0);
1329
1404
  __privateSet$4(this, _table, options.table);
1330
1405
  __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1331
- this.db = options.db;
1406
+ __privateSet$4(this, _db, options.db);
1332
1407
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1333
1408
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
1409
+ const trace = options.pluginOptions.trace ?? defaultTrace;
1410
+ __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
1411
+ return trace(name, fn, {
1412
+ ...options2,
1413
+ [TraceAttributes.TABLE]: __privateGet$4(this, _table),
1414
+ [TraceAttributes.VERSION]: VERSION
1415
+ });
1416
+ });
1334
1417
  }
1335
1418
  async create(a, b, c) {
1336
- if (Array.isArray(a)) {
1337
- if (a.length === 0)
1338
- return [];
1339
- const columns = isStringArray(b) ? b : void 0;
1340
- return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
1341
- }
1342
- if (isString(a) && isObject(b)) {
1343
- if (a === "")
1344
- throw new Error("The id can't be empty");
1345
- const columns = isStringArray(c) ? c : void 0;
1346
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
1347
- }
1348
- if (isObject(a) && isString(a.id)) {
1349
- if (a.id === "")
1350
- throw new Error("The id can't be empty");
1351
- const columns = isStringArray(b) ? b : void 0;
1352
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1353
- }
1354
- if (isObject(a)) {
1355
- const columns = isStringArray(b) ? b : void 0;
1356
- return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
1357
- }
1358
- throw new Error("Invalid arguments for create method");
1419
+ return __privateGet$4(this, _trace).call(this, "create", async () => {
1420
+ if (Array.isArray(a)) {
1421
+ if (a.length === 0)
1422
+ return [];
1423
+ const columns = isStringArray(b) ? b : void 0;
1424
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
1425
+ }
1426
+ if (isString(a) && isObject(b)) {
1427
+ if (a === "")
1428
+ throw new Error("The id can't be empty");
1429
+ const columns = isStringArray(c) ? c : void 0;
1430
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
1431
+ }
1432
+ if (isObject(a) && isString(a.id)) {
1433
+ if (a.id === "")
1434
+ throw new Error("The id can't be empty");
1435
+ const columns = isStringArray(b) ? b : void 0;
1436
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1437
+ }
1438
+ if (isObject(a)) {
1439
+ const columns = isStringArray(b) ? b : void 0;
1440
+ return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
1441
+ }
1442
+ throw new Error("Invalid arguments for create method");
1443
+ });
1359
1444
  }
1360
1445
  async read(a, b) {
1361
- const columns = isStringArray(b) ? b : ["*"];
1362
- if (Array.isArray(a)) {
1363
- if (a.length === 0)
1364
- return [];
1365
- const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
1366
- const finalObjects = await this.getAll({ filter: { id: { $any: ids } }, columns });
1367
- const dictionary = finalObjects.reduce((acc, object) => {
1368
- acc[object.id] = object;
1369
- return acc;
1370
- }, {});
1371
- return ids.map((id2) => dictionary[id2] ?? null);
1372
- }
1373
- const id = isString(a) ? a : a.id;
1374
- if (isString(id)) {
1375
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1376
- try {
1377
- const response = await getRecord({
1378
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: id },
1379
- queryParams: { columns },
1380
- ...fetchProps
1381
- });
1382
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1383
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1384
- } catch (e) {
1385
- if (isObject(e) && e.status === 404) {
1386
- return null;
1446
+ return __privateGet$4(this, _trace).call(this, "read", async () => {
1447
+ const columns = isStringArray(b) ? b : ["*"];
1448
+ if (Array.isArray(a)) {
1449
+ if (a.length === 0)
1450
+ return [];
1451
+ const ids = a.map((item) => extractId(item));
1452
+ const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
1453
+ const dictionary = finalObjects.reduce((acc, object) => {
1454
+ acc[object.id] = object;
1455
+ return acc;
1456
+ }, {});
1457
+ return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
1458
+ }
1459
+ const id = extractId(a);
1460
+ if (id) {
1461
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1462
+ try {
1463
+ const response = await getRecord({
1464
+ pathParams: {
1465
+ workspace: "{workspaceId}",
1466
+ dbBranchName: "{dbBranch}",
1467
+ tableName: __privateGet$4(this, _table),
1468
+ recordId: id
1469
+ },
1470
+ queryParams: { columns },
1471
+ ...fetchProps
1472
+ });
1473
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1474
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1475
+ } catch (e) {
1476
+ if (isObject(e) && e.status === 404) {
1477
+ return null;
1478
+ }
1479
+ throw e;
1387
1480
  }
1388
- throw e;
1389
1481
  }
1390
- }
1391
- return null;
1482
+ return null;
1483
+ });
1392
1484
  }
1393
1485
  async update(a, b, c) {
1394
- if (Array.isArray(a)) {
1395
- if (a.length === 0)
1396
- return [];
1397
- if (a.length > 100) {
1398
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1486
+ return __privateGet$4(this, _trace).call(this, "update", async () => {
1487
+ if (Array.isArray(a)) {
1488
+ if (a.length === 0)
1489
+ return [];
1490
+ if (a.length > 100) {
1491
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1492
+ }
1493
+ const columns = isStringArray(b) ? b : ["*"];
1494
+ return Promise.all(a.map((object) => this.update(object, columns)));
1399
1495
  }
1400
- const columns = isStringArray(b) ? b : ["*"];
1401
- return Promise.all(a.map((object) => this.update(object, columns)));
1402
- }
1403
- if (isString(a) && isObject(b)) {
1404
- const columns = isStringArray(c) ? c : void 0;
1405
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
1406
- }
1407
- if (isObject(a) && isString(a.id)) {
1408
- const columns = isStringArray(b) ? b : void 0;
1409
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1410
- }
1411
- throw new Error("Invalid arguments for update method");
1496
+ if (isString(a) && isObject(b)) {
1497
+ const columns = isStringArray(c) ? c : void 0;
1498
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
1499
+ }
1500
+ if (isObject(a) && isString(a.id)) {
1501
+ const columns = isStringArray(b) ? b : void 0;
1502
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1503
+ }
1504
+ throw new Error("Invalid arguments for update method");
1505
+ });
1412
1506
  }
1413
1507
  async createOrUpdate(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");
1508
+ return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
1509
+ if (Array.isArray(a)) {
1510
+ if (a.length === 0)
1511
+ return [];
1512
+ if (a.length > 100) {
1513
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1514
+ }
1515
+ const columns = isStringArray(b) ? b : ["*"];
1516
+ return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
1419
1517
  }
1420
- const columns = isStringArray(b) ? b : ["*"];
1421
- return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
1422
- }
1423
- if (isString(a) && isObject(b)) {
1424
- const columns = isStringArray(c) ? c : void 0;
1425
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
1426
- }
1427
- if (isObject(a) && isString(a.id)) {
1428
- const columns = isStringArray(c) ? c : void 0;
1429
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1430
- }
1431
- throw new Error("Invalid arguments for createOrUpdate method");
1432
- }
1433
- async delete(a) {
1434
- if (Array.isArray(a)) {
1435
- if (a.length === 0)
1436
- return;
1437
- if (a.length > 100) {
1438
- console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1518
+ if (isString(a) && isObject(b)) {
1519
+ const columns = isStringArray(c) ? c : void 0;
1520
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
1439
1521
  }
1440
- await Promise.all(a.map((id) => this.delete(id)));
1441
- return;
1442
- }
1443
- if (isString(a)) {
1444
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
1445
- return;
1446
- }
1447
- if (isObject(a) && isString(a.id)) {
1448
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
1449
- return;
1450
- }
1451
- throw new Error("Invalid arguments for delete method");
1522
+ if (isObject(a) && isString(a.id)) {
1523
+ const columns = isStringArray(c) ? c : void 0;
1524
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1525
+ }
1526
+ throw new Error("Invalid arguments for createOrUpdate method");
1527
+ });
1528
+ }
1529
+ async delete(a, b) {
1530
+ return __privateGet$4(this, _trace).call(this, "delete", async () => {
1531
+ if (Array.isArray(a)) {
1532
+ if (a.length === 0)
1533
+ return [];
1534
+ if (a.length > 100) {
1535
+ console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1536
+ }
1537
+ return Promise.all(a.map((id) => this.delete(id, b)));
1538
+ }
1539
+ if (isString(a)) {
1540
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
1541
+ }
1542
+ if (isObject(a) && isString(a.id)) {
1543
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
1544
+ }
1545
+ throw new Error("Invalid arguments for delete method");
1546
+ });
1452
1547
  }
1453
1548
  async search(query, options = {}) {
1454
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1455
- const { records } = await searchTable({
1456
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1457
- body: {
1458
- query,
1459
- fuzziness: options.fuzziness,
1460
- prefix: options.prefix,
1461
- highlight: options.highlight,
1462
- filter: options.filter,
1463
- boosters: options.boosters
1464
- },
1465
- ...fetchProps
1549
+ return __privateGet$4(this, _trace).call(this, "search", async () => {
1550
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1551
+ const { records } = await searchTable({
1552
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1553
+ body: {
1554
+ query,
1555
+ fuzziness: options.fuzziness,
1556
+ prefix: options.prefix,
1557
+ highlight: options.highlight,
1558
+ filter: options.filter,
1559
+ boosters: options.boosters
1560
+ },
1561
+ ...fetchProps
1562
+ });
1563
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1564
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
1466
1565
  });
1467
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1468
- return records.map((item) => initObject(this.db, schemaTables, __privateGet$4(this, _table), item));
1469
1566
  }
1470
1567
  async query(query) {
1471
- const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1472
- if (cacheQuery)
1473
- return new Page(query, cacheQuery.meta, cacheQuery.records);
1474
- const data = query.getQueryOptions();
1475
- const body = {
1476
- filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1477
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1478
- page: data.pagination,
1479
- columns: data.columns
1480
- };
1481
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1482
- const { meta, records: objects } = await queryTable({
1483
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1484
- body,
1485
- ...fetchProps
1568
+ return __privateGet$4(this, _trace).call(this, "query", async () => {
1569
+ const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1570
+ if (cacheQuery)
1571
+ return new Page(query, cacheQuery.meta, cacheQuery.records);
1572
+ const data = query.getQueryOptions();
1573
+ const body = {
1574
+ filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1575
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1576
+ page: data.pagination,
1577
+ columns: data.columns
1578
+ };
1579
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1580
+ const { meta, records: objects } = await queryTable({
1581
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1582
+ body,
1583
+ ...fetchProps
1584
+ });
1585
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1586
+ const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
1587
+ await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1588
+ return new Page(query, meta, records);
1486
1589
  });
1487
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1488
- const records = objects.map((record) => initObject(this.db, schemaTables, __privateGet$4(this, _table), record));
1489
- await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1490
- return new Page(query, meta, records);
1491
1590
  }
1492
1591
  }
1493
1592
  _table = new WeakMap();
1494
1593
  _getFetchProps = new WeakMap();
1594
+ _db = new WeakMap();
1495
1595
  _cache = new WeakMap();
1496
1596
  _schemaTables$2 = new WeakMap();
1597
+ _trace = new WeakMap();
1497
1598
  _insertRecordWithoutId = new WeakSet();
1498
1599
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1499
1600
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
@@ -1509,7 +1610,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1509
1610
  ...fetchProps
1510
1611
  });
1511
1612
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1512
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1613
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1513
1614
  };
1514
1615
  _insertRecordWithId = new WeakSet();
1515
1616
  insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
@@ -1527,7 +1628,7 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
1527
1628
  ...fetchProps
1528
1629
  });
1529
1630
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1530
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1631
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1531
1632
  };
1532
1633
  _bulkInsertTableRecords = new WeakSet();
1533
1634
  bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
@@ -1543,20 +1644,27 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1543
1644
  throw new Error("Request included columns but server didn't include them");
1544
1645
  }
1545
1646
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1546
- return response.records?.map((item) => initObject(this.db, schemaTables, __privateGet$4(this, _table), item));
1647
+ return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
1547
1648
  };
1548
1649
  _updateRecordWithID = new WeakSet();
1549
1650
  updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1550
1651
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1551
1652
  const record = transformObjectLinks(object);
1552
- const response = await updateRecordWithID({
1553
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1554
- queryParams: { columns },
1555
- body: record,
1556
- ...fetchProps
1557
- });
1558
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1559
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1653
+ try {
1654
+ const response = await updateRecordWithID({
1655
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1656
+ queryParams: { columns },
1657
+ body: record,
1658
+ ...fetchProps
1659
+ });
1660
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1661
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1662
+ } catch (e) {
1663
+ if (isObject(e) && e.status === 404) {
1664
+ return null;
1665
+ }
1666
+ throw e;
1667
+ }
1560
1668
  };
1561
1669
  _upsertRecordWithID = new WeakSet();
1562
1670
  upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
@@ -1568,15 +1676,25 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1568
1676
  ...fetchProps
1569
1677
  });
1570
1678
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1571
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1679
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1572
1680
  };
1573
1681
  _deleteRecord = new WeakSet();
1574
- deleteRecord_fn = async function(recordId) {
1682
+ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1575
1683
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1576
- await deleteRecord({
1577
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1578
- ...fetchProps
1579
- });
1684
+ try {
1685
+ const response = await deleteRecord({
1686
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1687
+ queryParams: { columns },
1688
+ ...fetchProps
1689
+ });
1690
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1691
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1692
+ } catch (e) {
1693
+ if (isObject(e) && e.status === 404) {
1694
+ return null;
1695
+ }
1696
+ throw e;
1697
+ }
1580
1698
  };
1581
1699
  _setCacheQuery = new WeakSet();
1582
1700
  setCacheQuery_fn = async function(query, meta, records) {
@@ -1664,6 +1782,13 @@ const initObject = (db, schemaTables, table, object) => {
1664
1782
  function isResponseWithRecords(value) {
1665
1783
  return isObject(value) && Array.isArray(value.records);
1666
1784
  }
1785
+ function extractId(value) {
1786
+ if (isString(value))
1787
+ return value;
1788
+ if (isObject(value) && isString(value.id))
1789
+ return value.id;
1790
+ return void 0;
1791
+ }
1667
1792
 
1668
1793
  var __accessCheck$3 = (obj, member, msg) => {
1669
1794
  if (!member.has(obj))
@@ -1714,18 +1839,25 @@ class SimpleCache {
1714
1839
  }
1715
1840
  _map = new WeakMap();
1716
1841
 
1717
- const gt = (value) => ({ $gt: value });
1718
- const ge = (value) => ({ $ge: value });
1719
- const gte = (value) => ({ $ge: value });
1720
- const lt = (value) => ({ $lt: value });
1721
- const lte = (value) => ({ $le: value });
1722
- const le = (value) => ({ $le: value });
1842
+ const greaterThan = (value) => ({ $gt: value });
1843
+ const gt = greaterThan;
1844
+ const greaterThanEquals = (value) => ({ $ge: value });
1845
+ const greaterEquals = greaterThanEquals;
1846
+ const gte = greaterThanEquals;
1847
+ const ge = greaterThanEquals;
1848
+ const lessThan = (value) => ({ $lt: value });
1849
+ const lt = lessThan;
1850
+ const lessThanEquals = (value) => ({ $le: value });
1851
+ const lessEquals = lessThanEquals;
1852
+ const lte = lessThanEquals;
1853
+ const le = lessThanEquals;
1723
1854
  const exists = (column) => ({ $exists: column });
1724
1855
  const notExists = (column) => ({ $notExists: column });
1725
1856
  const startsWith = (value) => ({ $startsWith: value });
1726
1857
  const endsWith = (value) => ({ $endsWith: value });
1727
1858
  const pattern = (value) => ({ $pattern: value });
1728
1859
  const is = (value) => ({ $is: value });
1860
+ const equals = is;
1729
1861
  const isNot = (value) => ({ $isNot: value });
1730
1862
  const contains = (value) => ({ $contains: value });
1731
1863
  const includes = (value) => ({ $includes: value });
@@ -1760,16 +1892,19 @@ class SchemaPlugin extends XataPlugin {
1760
1892
  __privateSet$2(this, _schemaTables$1, schemaTables);
1761
1893
  }
1762
1894
  build(pluginOptions) {
1763
- const db = new Proxy({}, {
1764
- get: (_target, table) => {
1765
- if (!isString(table))
1766
- throw new Error("Invalid table name");
1767
- if (__privateGet$2(this, _tables)[table] === void 0) {
1768
- __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
1895
+ const db = new Proxy(
1896
+ {},
1897
+ {
1898
+ get: (_target, table) => {
1899
+ if (!isString(table))
1900
+ throw new Error("Invalid table name");
1901
+ if (__privateGet$2(this, _tables)[table] === void 0) {
1902
+ __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
1903
+ }
1904
+ return __privateGet$2(this, _tables)[table];
1769
1905
  }
1770
- return __privateGet$2(this, _tables)[table];
1771
1906
  }
1772
- });
1907
+ );
1773
1908
  const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
1774
1909
  for (const table of tableNames) {
1775
1910
  db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
@@ -1883,9 +2018,13 @@ async function resolveXataBranch(gitBranch, options) {
1883
2018
  const databaseURL = options?.databaseURL || getDatabaseURL();
1884
2019
  const apiKey = options?.apiKey || getAPIKey();
1885
2020
  if (!databaseURL)
1886
- throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
2021
+ throw new Error(
2022
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2023
+ );
1887
2024
  if (!apiKey)
1888
- throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
2025
+ throw new Error(
2026
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2027
+ );
1889
2028
  const [protocol, , host, , dbName] = databaseURL.split("/");
1890
2029
  const [workspace] = host.split(".");
1891
2030
  const { fallbackBranch } = getEnvironment();
@@ -1895,7 +2034,8 @@ async function resolveXataBranch(gitBranch, options) {
1895
2034
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1896
2035
  workspacesApiUrl: `${protocol}//${host}`,
1897
2036
  pathParams: { dbName, workspace },
1898
- queryParams: { gitBranch, fallbackBranch }
2037
+ queryParams: { gitBranch, fallbackBranch },
2038
+ trace: defaultTrace
1899
2039
  });
1900
2040
  return branch;
1901
2041
  }
@@ -1903,9 +2043,13 @@ async function getDatabaseBranch(branch, options) {
1903
2043
  const databaseURL = options?.databaseURL || getDatabaseURL();
1904
2044
  const apiKey = options?.apiKey || getAPIKey();
1905
2045
  if (!databaseURL)
1906
- throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
2046
+ throw new Error(
2047
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2048
+ );
1907
2049
  if (!apiKey)
1908
- throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
2050
+ throw new Error(
2051
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2052
+ );
1909
2053
  const [protocol, , host, , database] = databaseURL.split("/");
1910
2054
  const [workspace] = host.split(".");
1911
2055
  const dbBranchName = `${database}:${branch}`;
@@ -1915,7 +2059,8 @@ async function getDatabaseBranch(branch, options) {
1915
2059
  apiUrl: databaseURL,
1916
2060
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1917
2061
  workspacesApiUrl: `${protocol}//${host}`,
1918
- pathParams: { dbBranchName, workspace }
2062
+ pathParams: { dbBranchName, workspace },
2063
+ trace: defaultTrace
1919
2064
  });
1920
2065
  } catch (err) {
1921
2066
  if (isObject(err) && err.status === 404)
@@ -1955,17 +2100,20 @@ var __privateMethod = (obj, member, method) => {
1955
2100
  return method;
1956
2101
  };
1957
2102
  const buildClient = (plugins) => {
1958
- var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
2103
+ var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
1959
2104
  return _a = class {
1960
2105
  constructor(options = {}, schemaTables) {
1961
2106
  __privateAdd(this, _parseOptions);
1962
2107
  __privateAdd(this, _getFetchProps);
1963
2108
  __privateAdd(this, _evaluateBranch);
1964
2109
  __privateAdd(this, _branch, void 0);
2110
+ __privateAdd(this, _options, void 0);
1965
2111
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
2112
+ __privateSet(this, _options, safeOptions);
1966
2113
  const pluginOptions = {
1967
2114
  getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
1968
- cache: safeOptions.cache
2115
+ cache: safeOptions.cache,
2116
+ trace: safeOptions.trace
1969
2117
  };
1970
2118
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
1971
2119
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
@@ -1984,22 +2132,26 @@ const buildClient = (plugins) => {
1984
2132
  }
1985
2133
  }
1986
2134
  }
1987
- }, _branch = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
2135
+ async getConfig() {
2136
+ const databaseURL = __privateGet(this, _options).databaseURL;
2137
+ const branch = await __privateGet(this, _options).branch();
2138
+ return { databaseURL, branch };
2139
+ }
2140
+ }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
1988
2141
  const fetch = getFetchImplementation(options?.fetch);
1989
2142
  const databaseURL = options?.databaseURL || getDatabaseURL();
1990
2143
  const apiKey = options?.apiKey || getAPIKey();
1991
2144
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
2145
+ const trace = options?.trace ?? defaultTrace;
1992
2146
  const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
1993
- if (!databaseURL || !apiKey) {
1994
- throw new Error("Options databaseURL and apiKey are required");
2147
+ if (!apiKey) {
2148
+ throw new Error("Option apiKey is required");
1995
2149
  }
1996
- return { fetch, databaseURL, apiKey, branch, cache };
1997
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
1998
- fetch,
1999
- apiKey,
2000
- databaseURL,
2001
- branch
2002
- }) {
2150
+ if (!databaseURL) {
2151
+ throw new Error("Option databaseURL is required");
2152
+ }
2153
+ return { fetch, databaseURL, apiKey, branch, cache, trace };
2154
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
2003
2155
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2004
2156
  if (!branchValue)
2005
2157
  throw new Error("Unable to resolve branch value");
@@ -2011,7 +2163,8 @@ const buildClient = (plugins) => {
2011
2163
  const hasBranch = params.dbBranchName ?? params.branch;
2012
2164
  const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
2013
2165
  return databaseURL + newPath;
2014
- }
2166
+ },
2167
+ trace
2015
2168
  };
2016
2169
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2017
2170
  if (__privateGet(this, _branch))
@@ -2034,6 +2187,88 @@ const buildClient = (plugins) => {
2034
2187
  class BaseClient extends buildClient() {
2035
2188
  }
2036
2189
 
2190
+ const META = "__";
2191
+ const VALUE = "___";
2192
+ class Serializer {
2193
+ constructor() {
2194
+ this.classes = {};
2195
+ }
2196
+ add(clazz) {
2197
+ this.classes[clazz.name] = clazz;
2198
+ }
2199
+ toJSON(data) {
2200
+ function visit(obj) {
2201
+ if (Array.isArray(obj))
2202
+ return obj.map(visit);
2203
+ const type = typeof obj;
2204
+ if (type === "undefined")
2205
+ return { [META]: "undefined" };
2206
+ if (type === "bigint")
2207
+ return { [META]: "bigint", [VALUE]: obj.toString() };
2208
+ if (obj === null || type !== "object")
2209
+ return obj;
2210
+ const constructor = obj.constructor;
2211
+ const o = { [META]: constructor.name };
2212
+ for (const [key, value] of Object.entries(obj)) {
2213
+ o[key] = visit(value);
2214
+ }
2215
+ if (constructor === Date)
2216
+ o[VALUE] = obj.toISOString();
2217
+ if (constructor === Map)
2218
+ o[VALUE] = Object.fromEntries(obj);
2219
+ if (constructor === Set)
2220
+ o[VALUE] = [...obj];
2221
+ return o;
2222
+ }
2223
+ return JSON.stringify(visit(data));
2224
+ }
2225
+ fromJSON(json) {
2226
+ return JSON.parse(json, (key, value) => {
2227
+ if (value && typeof value === "object" && !Array.isArray(value)) {
2228
+ const { [META]: clazz, [VALUE]: val, ...rest } = value;
2229
+ const constructor = this.classes[clazz];
2230
+ if (constructor) {
2231
+ return Object.assign(Object.create(constructor.prototype), rest);
2232
+ }
2233
+ if (clazz === "Date")
2234
+ return new Date(val);
2235
+ if (clazz === "Set")
2236
+ return new Set(val);
2237
+ if (clazz === "Map")
2238
+ return new Map(Object.entries(val));
2239
+ if (clazz === "bigint")
2240
+ return BigInt(val);
2241
+ if (clazz === "undefined")
2242
+ return void 0;
2243
+ return rest;
2244
+ }
2245
+ return value;
2246
+ });
2247
+ }
2248
+ }
2249
+ const defaultSerializer = new Serializer();
2250
+ const serialize = (data) => {
2251
+ return defaultSerializer.toJSON(data);
2252
+ };
2253
+ const deserialize = (json) => {
2254
+ return defaultSerializer.fromJSON(json);
2255
+ };
2256
+
2257
+ function buildWorkerRunner(config) {
2258
+ return function xataWorker(name, _worker) {
2259
+ return async (...args) => {
2260
+ const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
2261
+ const result = await fetch(url, {
2262
+ method: "POST",
2263
+ headers: { "Content-Type": "application/json" },
2264
+ body: serialize({ args })
2265
+ });
2266
+ const text = await result.text();
2267
+ return deserialize(text);
2268
+ };
2269
+ };
2270
+ }
2271
+
2037
2272
  class XataError extends Error {
2038
2273
  constructor(message, status) {
2039
2274
  super(message);
@@ -2041,5 +2276,5 @@ class XataError extends Error {
2041
2276
  }
2042
2277
  }
2043
2278
 
2044
- export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, 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, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
2279
+ 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, equals, 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, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
2045
2280
  //# sourceMappingURL=index.mjs.map