@xata.io/client 0.0.0-alpha.vfa22996 → 0.0.0-alpha.vfac764c

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,5 +1,6 @@
1
- const defaultTrace = async (_name, fn, _options) => {
1
+ const defaultTrace = async (name, fn, _options) => {
2
2
  return await fn({
3
+ name,
3
4
  setAttributes: () => {
4
5
  return;
5
6
  }
@@ -169,9 +170,6 @@ async function getGitBranch() {
169
170
  const nodeModule = ["child", "process"].join("_");
170
171
  const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
171
172
  try {
172
- if (typeof require === "function") {
173
- return require(nodeModule).execSync(fullCmd, execOptions).trim();
174
- }
175
173
  const { execSync } = await import(nodeModule);
176
174
  return execSync(fullCmd, execOptions).toString().trim();
177
175
  } catch (err) {
@@ -294,7 +292,14 @@ enqueue_fn = function(task) {
294
292
  return promise;
295
293
  };
296
294
 
297
- const VERSION = "0.0.0-alpha.vfa22996";
295
+ function generateUUID() {
296
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
297
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
298
+ return v.toString(16);
299
+ });
300
+ }
301
+
302
+ const VERSION = "0.21.6";
298
303
 
299
304
  class ErrorWithCause extends Error {
300
305
  constructor(message, options) {
@@ -305,7 +310,7 @@ class FetcherError extends ErrorWithCause {
305
310
  constructor(status, data, requestId) {
306
311
  super(getMessage(data));
307
312
  this.status = status;
308
- this.errors = isBulkError(data) ? data.errors : void 0;
313
+ this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
309
314
  this.requestId = requestId;
310
315
  if (data instanceof Error) {
311
316
  this.stack = data.stack;
@@ -370,11 +375,12 @@ function hostHeader(url) {
370
375
  const { groups } = pattern.exec(url) ?? {};
371
376
  return groups?.host ? { Host: groups.host } : {};
372
377
  }
378
+ const defaultClientID = generateUUID();
373
379
  async function fetch$1({
374
380
  url: path,
375
381
  method,
376
382
  body,
377
- headers,
383
+ headers: customHeaders,
378
384
  pathParams,
379
385
  queryParams,
380
386
  fetchImpl,
@@ -386,6 +392,7 @@ async function fetch$1({
386
392
  signal,
387
393
  clientID,
388
394
  sessionID,
395
+ clientName,
389
396
  fetchOptions = {}
390
397
  }) {
391
398
  pool.setFetch(fetchImpl);
@@ -399,19 +406,26 @@ async function fetch$1({
399
406
  [TraceAttributes.HTTP_URL]: url,
400
407
  [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
401
408
  });
409
+ const xataAgent = compact([
410
+ ["client", "TS_SDK"],
411
+ ["version", VERSION],
412
+ isDefined(clientName) ? ["service", clientName] : void 0
413
+ ]).map(([key, value]) => `${key}=${value}`).join("; ");
414
+ const headers = {
415
+ "Accept-Encoding": "identity",
416
+ "Content-Type": "application/json",
417
+ "X-Xata-Client-ID": clientID ?? defaultClientID,
418
+ "X-Xata-Session-ID": sessionID ?? generateUUID(),
419
+ "X-Xata-Agent": xataAgent,
420
+ ...customHeaders,
421
+ ...hostHeader(fullUrl),
422
+ Authorization: `Bearer ${apiKey}`
423
+ };
402
424
  const response = await pool.request(url, {
403
425
  ...fetchOptions,
404
426
  method: method.toUpperCase(),
405
427
  body: body ? JSON.stringify(body) : void 0,
406
- headers: {
407
- "Content-Type": "application/json",
408
- "User-Agent": `Xata client-ts/${VERSION}`,
409
- "X-Xata-Client-ID": clientID ?? "",
410
- "X-Xata-Session-ID": sessionID ?? "",
411
- ...headers,
412
- ...hostHeader(fullUrl),
413
- Authorization: `Bearer ${apiKey}`
414
- },
428
+ headers,
415
429
  signal
416
430
  });
417
431
  const { host, protocol } = parseUrl(response.url);
@@ -453,17 +467,12 @@ function parseUrl(url) {
453
467
 
454
468
  const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
455
469
 
456
- const dEPRECATEDgetDatabaseList = (variables, signal) => dataPlaneFetch({ url: "/dbs", method: "get", ...variables, signal });
457
470
  const getBranchList = (variables, signal) => dataPlaneFetch({
458
471
  url: "/dbs/{dbName}",
459
472
  method: "get",
460
473
  ...variables,
461
474
  signal
462
475
  });
463
- const dEPRECATEDcreateDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
464
- const dEPRECATEDdeleteDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "delete", ...variables, signal });
465
- const dEPRECATEDgetDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "get", ...variables, signal });
466
- const dEPRECATEDupdateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
467
476
  const getBranchDetails = (variables, signal) => dataPlaneFetch({
468
477
  url: "/db/{dbBranchName}",
469
478
  method: "get",
@@ -502,7 +511,6 @@ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName
502
511
  const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
503
512
  const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
504
513
  const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
505
- const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
506
514
  const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
507
515
  const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
508
516
  const getMigrationRequest = (variables, signal) => dataPlaneFetch({
@@ -569,6 +577,7 @@ const deleteColumn = (variables, signal) => dataPlaneFetch({
569
577
  ...variables,
570
578
  signal
571
579
  });
580
+ const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
572
581
  const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
573
582
  const getRecord = (variables, signal) => dataPlaneFetch({
574
583
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
@@ -602,13 +611,6 @@ const searchTable = (variables, signal) => dataPlaneFetch({
602
611
  const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
603
612
  const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
604
613
  const operationsByTag$2 = {
605
- database: {
606
- dEPRECATEDgetDatabaseList,
607
- dEPRECATEDcreateDatabase,
608
- dEPRECATEDdeleteDatabase,
609
- dEPRECATEDgetDatabaseMetadata,
610
- dEPRECATEDupdateDatabaseMetadata
611
- },
612
614
  branch: {
613
615
  getBranchList,
614
616
  getBranchDetails,
@@ -633,16 +635,6 @@ const operationsByTag$2 = {
633
635
  previewBranchSchemaEdit,
634
636
  applyBranchSchemaEdit
635
637
  },
636
- records: {
637
- branchTransaction,
638
- insertRecord,
639
- getRecord,
640
- insertRecordWithID,
641
- updateRecordWithID,
642
- upsertRecordWithID,
643
- deleteRecord,
644
- bulkInsertTableRecords
645
- },
646
638
  migrationRequests: {
647
639
  queryMigrationRequests,
648
640
  createMigrationRequest,
@@ -665,6 +657,16 @@ const operationsByTag$2 = {
665
657
  updateColumn,
666
658
  deleteColumn
667
659
  },
660
+ records: {
661
+ branchTransaction,
662
+ insertRecord,
663
+ getRecord,
664
+ insertRecordWithID,
665
+ updateRecordWithID,
666
+ upsertRecordWithID,
667
+ deleteRecord,
668
+ bulkInsertTableRecords
669
+ },
668
670
  searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
669
671
  };
670
672
 
@@ -838,12 +840,12 @@ function parseProviderString(provider = "production") {
838
840
  function parseWorkspacesUrlParts(url) {
839
841
  if (!isString(url))
840
842
  return null;
841
- const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
842
- const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
843
+ const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
844
+ const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))\.xatabase\.co.*/;
843
845
  const match = url.match(regex) || url.match(regexStaging);
844
846
  if (!match)
845
847
  return null;
846
- return { workspace: match[1], region: match[2] ?? "eu-west-1" };
848
+ return { workspace: match[1], region: match[2] };
847
849
  }
848
850
 
849
851
  var __accessCheck$7 = (obj, member, msg) => {
@@ -872,6 +874,7 @@ class XataApiClient {
872
874
  const provider = options.host ?? "production";
873
875
  const apiKey = options.apiKey ?? getAPIKey();
874
876
  const trace = options.trace ?? defaultTrace;
877
+ const clientID = generateUUID();
875
878
  if (!apiKey) {
876
879
  throw new Error("Could not resolve a valid apiKey");
877
880
  }
@@ -880,7 +883,9 @@ class XataApiClient {
880
883
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
881
884
  fetchImpl: getFetchImplementation(options.fetch),
882
885
  apiKey,
883
- trace
886
+ trace,
887
+ clientName: options.clientName,
888
+ clientID
884
889
  });
885
890
  }
886
891
  get user() {
@@ -1885,13 +1890,6 @@ class XataApiPlugin {
1885
1890
  class XataPlugin {
1886
1891
  }
1887
1892
 
1888
- function generateUUID() {
1889
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
1890
- const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
1891
- return v.toString(16);
1892
- });
1893
- }
1894
-
1895
1893
  function cleanFilter(filter) {
1896
1894
  if (!filter)
1897
1895
  return void 0;
@@ -1968,6 +1966,12 @@ const _RecordArray = class extends Array {
1968
1966
  toArray() {
1969
1967
  return new Array(...this);
1970
1968
  }
1969
+ toSerializable() {
1970
+ return JSON.parse(this.toString());
1971
+ }
1972
+ toString() {
1973
+ return JSON.stringify(this.toArray());
1974
+ }
1971
1975
  map(callbackfn, thisArg) {
1972
1976
  return this.toArray().map(callbackfn, thisArg);
1973
1977
  }
@@ -2039,6 +2043,7 @@ const _Query = class {
2039
2043
  __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
2040
2044
  __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
2041
2045
  __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
2046
+ __privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
2042
2047
  __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
2043
2048
  __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
2044
2049
  __privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
@@ -2412,13 +2417,19 @@ class RestRepository extends Query {
2412
2417
  const result = await this.read(a, columns);
2413
2418
  return result;
2414
2419
  }
2415
- if (isString(a) && isObject(b)) {
2416
- const columns = isStringArray(c) ? c : void 0;
2417
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2418
- }
2419
- if (isObject(a) && isString(a.id)) {
2420
- const columns = isStringArray(b) ? b : void 0;
2421
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2420
+ try {
2421
+ if (isString(a) && isObject(b)) {
2422
+ const columns = isStringArray(c) ? c : void 0;
2423
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2424
+ }
2425
+ if (isObject(a) && isString(a.id)) {
2426
+ const columns = isStringArray(b) ? b : void 0;
2427
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2428
+ }
2429
+ } catch (error) {
2430
+ if (error.status === 422)
2431
+ return null;
2432
+ throw error;
2422
2433
  }
2423
2434
  throw new Error("Invalid arguments for update method");
2424
2435
  });
@@ -2549,7 +2560,9 @@ class RestRepository extends Query {
2549
2560
  prefix: options.prefix,
2550
2561
  highlight: options.highlight,
2551
2562
  filter: options.filter,
2552
- boosters: options.boosters
2563
+ boosters: options.boosters,
2564
+ page: options.page,
2565
+ target: options.target
2553
2566
  },
2554
2567
  ...fetchProps
2555
2568
  });
@@ -2591,7 +2604,8 @@ class RestRepository extends Query {
2591
2604
  filter: cleanFilter(data.filter),
2592
2605
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2593
2606
  page: data.pagination,
2594
- columns: data.columns ?? ["*"]
2607
+ columns: data.columns ?? ["*"],
2608
+ consistency: data.consistency
2595
2609
  },
2596
2610
  fetchOptions: data.fetchOptions,
2597
2611
  ...fetchProps
@@ -2619,6 +2633,7 @@ class RestRepository extends Query {
2619
2633
  filter: cleanFilter(data.filter),
2620
2634
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2621
2635
  columns: data.columns,
2636
+ consistency: data.consistency,
2622
2637
  page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
2623
2638
  summaries,
2624
2639
  summariesFilter
@@ -2855,23 +2870,23 @@ const transformObjectLinks = (object) => {
2855
2870
  }, {});
2856
2871
  };
2857
2872
  const initObject = (db, schemaTables, table, object, selectedColumns) => {
2858
- const result = {};
2873
+ const data = {};
2859
2874
  const { xata, ...rest } = object ?? {};
2860
- Object.assign(result, rest);
2875
+ Object.assign(data, rest);
2861
2876
  const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
2862
2877
  if (!columns)
2863
2878
  console.error(`Table ${table} not found in schema`);
2864
2879
  for (const column of columns ?? []) {
2865
2880
  if (!isValidColumn(selectedColumns, column))
2866
2881
  continue;
2867
- const value = result[column.name];
2882
+ const value = data[column.name];
2868
2883
  switch (column.type) {
2869
2884
  case "datetime": {
2870
2885
  const date = value !== void 0 ? new Date(value) : null;
2871
2886
  if (date !== null && isNaN(date.getTime())) {
2872
2887
  console.error(`Failed to parse date ${value} for field ${column.name}`);
2873
2888
  } else {
2874
- result[column.name] = date;
2889
+ data[column.name] = date;
2875
2890
  }
2876
2891
  break;
2877
2892
  }
@@ -2890,44 +2905,51 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2890
2905
  }
2891
2906
  return acc;
2892
2907
  }, []);
2893
- result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2908
+ data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2894
2909
  } else {
2895
- result[column.name] = null;
2910
+ data[column.name] = null;
2896
2911
  }
2897
2912
  break;
2898
2913
  }
2899
2914
  default:
2900
- result[column.name] = value ?? null;
2915
+ data[column.name] = value ?? null;
2901
2916
  if (column.notNull === true && value === null) {
2902
2917
  console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2903
2918
  }
2904
2919
  break;
2905
2920
  }
2906
2921
  }
2907
- result.read = function(columns2) {
2908
- return db[table].read(result["id"], columns2);
2922
+ const record = { ...data };
2923
+ record.read = function(columns2) {
2924
+ return db[table].read(record["id"], columns2);
2909
2925
  };
2910
- result.update = function(data, b, c) {
2926
+ record.update = function(data2, b, c) {
2911
2927
  const columns2 = isStringArray(b) ? b : ["*"];
2912
2928
  const ifVersion = parseIfVersion(b, c);
2913
- return db[table].update(result["id"], data, columns2, { ifVersion });
2929
+ return db[table].update(record["id"], data2, columns2, { ifVersion });
2914
2930
  };
2915
- result.replace = function(data, b, c) {
2931
+ record.replace = function(data2, b, c) {
2916
2932
  const columns2 = isStringArray(b) ? b : ["*"];
2917
2933
  const ifVersion = parseIfVersion(b, c);
2918
- return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
2934
+ return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
2919
2935
  };
2920
- result.delete = function() {
2921
- return db[table].delete(result["id"]);
2936
+ record.delete = function() {
2937
+ return db[table].delete(record["id"]);
2922
2938
  };
2923
- result.getMetadata = function() {
2939
+ record.getMetadata = function() {
2924
2940
  return xata;
2925
2941
  };
2926
- for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
2927
- Object.defineProperty(result, prop, { enumerable: false });
2942
+ record.toSerializable = function() {
2943
+ return JSON.parse(JSON.stringify(transformObjectLinks(data)));
2944
+ };
2945
+ record.toString = function() {
2946
+ return JSON.stringify(transformObjectLinks(data));
2947
+ };
2948
+ for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
2949
+ Object.defineProperty(record, prop, { enumerable: false });
2928
2950
  }
2929
- Object.freeze(result);
2930
- return result;
2951
+ Object.freeze(record);
2952
+ return record;
2931
2953
  };
2932
2954
  function extractId(value) {
2933
2955
  if (isString(value))
@@ -3138,10 +3160,10 @@ _schemaTables = new WeakMap();
3138
3160
  _search = new WeakSet();
3139
3161
  search_fn = async function(query, options, getFetchProps) {
3140
3162
  const fetchProps = await getFetchProps();
3141
- const { tables, fuzziness, highlight, prefix } = options ?? {};
3163
+ const { tables, fuzziness, highlight, prefix, page } = options ?? {};
3142
3164
  const { records } = await searchBranch({
3143
3165
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3144
- body: { tables, query, fuzziness, prefix, highlight },
3166
+ body: { tables, query, fuzziness, prefix, highlight, page },
3145
3167
  ...fetchProps
3146
3168
  });
3147
3169
  return records;
@@ -3181,12 +3203,8 @@ const isBranchStrategyBuilder = (strategy) => {
3181
3203
 
3182
3204
  async function getCurrentBranchName(options) {
3183
3205
  const { branch, envBranch } = getEnvironment();
3184
- if (branch) {
3185
- const details = await getDatabaseBranch(branch, options);
3186
- if (details)
3187
- return branch;
3188
- console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
3189
- }
3206
+ if (branch)
3207
+ return branch;
3190
3208
  const gitBranch = envBranch || await getGitBranch();
3191
3209
  return resolveXataBranch(gitBranch, options);
3192
3210
  }
@@ -3218,7 +3236,8 @@ async function resolveXataBranch(gitBranch, options) {
3218
3236
  workspacesApiUrl: `${protocol}//${host}`,
3219
3237
  pathParams: { dbName, workspace, region },
3220
3238
  queryParams: { gitBranch, fallbackBranch },
3221
- trace: defaultTrace
3239
+ trace: defaultTrace,
3240
+ clientName: options?.clientName
3222
3241
  });
3223
3242
  return branch;
3224
3243
  }
@@ -3326,7 +3345,7 @@ const buildClient = (plugins) => {
3326
3345
  }
3327
3346
  }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
3328
3347
  const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
3329
- const isBrowser = typeof window !== "undefined";
3348
+ const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
3330
3349
  if (isBrowser && !enableBrowser) {
3331
3350
  throw new Error(
3332
3351
  "You are trying to use Xata from the browser, which is potentially a non-secure environment. If you understand the security concerns, such as leaking your credentials, pass `enableBrowser: true` to the client options to remove this error."
@@ -3337,15 +3356,29 @@ const buildClient = (plugins) => {
3337
3356
  const apiKey = options?.apiKey || getAPIKey();
3338
3357
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
3339
3358
  const trace = options?.trace ?? defaultTrace;
3340
- const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
3359
+ const clientName = options?.clientName;
3360
+ const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({
3361
+ apiKey,
3362
+ databaseURL,
3363
+ fetchImpl: options?.fetch,
3364
+ clientName: options?.clientName
3365
+ });
3341
3366
  if (!apiKey) {
3342
3367
  throw new Error("Option apiKey is required");
3343
3368
  }
3344
3369
  if (!databaseURL) {
3345
3370
  throw new Error("Option databaseURL is required");
3346
3371
  }
3347
- return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser };
3348
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
3372
+ return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser, clientName };
3373
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
3374
+ fetch,
3375
+ apiKey,
3376
+ databaseURL,
3377
+ branch,
3378
+ trace,
3379
+ clientID,
3380
+ clientName
3381
+ }) {
3349
3382
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
3350
3383
  if (!branchValue)
3351
3384
  throw new Error("Unable to resolve branch value");
@@ -3359,7 +3392,8 @@ const buildClient = (plugins) => {
3359
3392
  return databaseURL + newPath;
3360
3393
  },
3361
3394
  trace,
3362
- clientID
3395
+ clientID,
3396
+ clientName
3363
3397
  };
3364
3398
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
3365
3399
  if (__privateGet(this, _branch))
@@ -3450,7 +3484,7 @@ const deserialize = (json) => {
3450
3484
  };
3451
3485
 
3452
3486
  function buildWorkerRunner(config) {
3453
- return function xataWorker(name, _worker) {
3487
+ return function xataWorker(name, worker) {
3454
3488
  return async (...args) => {
3455
3489
  const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
3456
3490
  const result = await fetch(url, {
@@ -3471,5 +3505,5 @@ class XataError extends Error {
3471
3505
  }
3472
3506
  }
3473
3507
 
3474
- 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, aggregateTable, applyBranchSchemaEdit, branchTransaction, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, dEPRECATEDcreateDatabase, dEPRECATEDdeleteDatabase, dEPRECATEDgetDatabaseList, dEPRECATEDgetDatabaseMetadata, dEPRECATEDupdateDatabaseMetadata, 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, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
3508
+ export { BaseClient, FetcherError, 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, aggregateTable, applyBranchSchemaEdit, branchTransaction, 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, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
3475
3509
  //# sourceMappingURL=index.mjs.map