@xata.io/client 0.0.0-alpha.vf0f8e71 → 0.0.0-alpha.vf1de7db

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
  }
@@ -13,6 +35,9 @@ function isDefined(value) {
13
35
  function isString(value) {
14
36
  return isDefined(value) && typeof value === "string";
15
37
  }
38
+ function isStringArray(value) {
39
+ return isDefined(value) && Array.isArray(value) && value.every(isString);
40
+ }
16
41
  function toBase64(value) {
17
42
  try {
18
43
  return btoa(value);
@@ -28,7 +53,8 @@ function getEnvironment() {
28
53
  return {
29
54
  apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
30
55
  databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
31
- branch: process.env.XATA_BRANCH ?? process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH ?? getGlobalBranch(),
56
+ branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
57
+ envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
32
58
  fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
33
59
  };
34
60
  }
@@ -39,7 +65,8 @@ function getEnvironment() {
39
65
  return {
40
66
  apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
41
67
  databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
42
- branch: Deno.env.get("XATA_BRANCH") ?? Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH") ?? getGlobalBranch(),
68
+ branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
69
+ envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
43
70
  fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
44
71
  };
45
72
  }
@@ -49,6 +76,7 @@ function getEnvironment() {
49
76
  apiKey: getGlobalApiKey(),
50
77
  databaseURL: getGlobalDatabaseURL(),
51
78
  branch: getGlobalBranch(),
79
+ envBranch: void 0,
52
80
  fallbackBranch: getGlobalFallbackBranch()
53
81
  };
54
82
  }
@@ -81,20 +109,21 @@ function getGlobalFallbackBranch() {
81
109
  }
82
110
  }
83
111
  async function getGitBranch() {
112
+ const cmd = ["git", "branch", "--show-current"];
113
+ const fullCmd = cmd.join(" ");
114
+ const nodeModule = ["child", "process"].join("_");
115
+ const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
84
116
  try {
85
117
  if (typeof require === "function") {
86
- const req = require;
87
- return req("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
118
+ return require(nodeModule).execSync(fullCmd, execOptions).trim();
88
119
  }
120
+ const { execSync } = await import(nodeModule);
121
+ return execSync(fullCmd, execOptions).toString().trim();
89
122
  } catch (err) {
90
123
  }
91
124
  try {
92
125
  if (isObject(Deno)) {
93
- const process2 = Deno.run({
94
- cmd: ["git", "branch", "--show-current"],
95
- stdout: "piped",
96
- stderr: "piped"
97
- });
126
+ const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
98
127
  return new TextDecoder().decode(await process2.output()).trim();
99
128
  }
100
129
  } catch (err) {
@@ -114,12 +143,14 @@ function getFetchImplementation(userFetch) {
114
143
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
115
144
  const fetchImpl = userFetch ?? globalFetch;
116
145
  if (!fetchImpl) {
117
- throw new Error(`The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`);
146
+ throw new Error(
147
+ `Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
148
+ );
118
149
  }
119
150
  return fetchImpl;
120
151
  }
121
152
 
122
- const VERSION = "0.0.0-alpha.vf0f8e71";
153
+ const VERSION = "0.0.0-alpha.vf1de7db";
123
154
 
124
155
  class ErrorWithCause extends Error {
125
156
  constructor(message, options) {
@@ -170,7 +201,10 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
170
201
  }, {});
171
202
  const query = new URLSearchParams(cleanQueryParams).toString();
172
203
  const queryString = query.length > 0 ? `?${query}` : "";
173
- 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;
174
208
  };
175
209
  function buildBaseUrl({
176
210
  path,
@@ -178,10 +212,10 @@ function buildBaseUrl({
178
212
  apiUrl,
179
213
  pathParams
180
214
  }) {
181
- if (!pathParams?.workspace)
215
+ if (pathParams?.workspace === void 0)
182
216
  return `${apiUrl}${path}`;
183
217
  const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
184
- return url.replace("{workspaceId}", pathParams.workspace);
218
+ return url.replace("{workspaceId}", String(pathParams.workspace));
185
219
  }
186
220
  function hostHeader(url) {
187
221
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
@@ -198,34 +232,61 @@ async function fetch$1({
198
232
  fetchImpl,
199
233
  apiKey,
200
234
  apiUrl,
201
- workspacesApiUrl
235
+ workspacesApiUrl,
236
+ trace
202
237
  }) {
203
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
204
- const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
205
- const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
206
- const response = await fetchImpl(url, {
207
- method: method.toUpperCase(),
208
- body: body ? JSON.stringify(body) : void 0,
209
- headers: {
210
- "Content-Type": "application/json",
211
- "User-Agent": `Xata client-ts/${VERSION}`,
212
- ...headers,
213
- ...hostHeader(fullUrl),
214
- Authorization: `Bearer ${apiKey}`
215
- }
216
- });
217
- if (response.status === 204) {
218
- return {};
219
- }
220
- 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) {
221
285
  try {
222
- const jsonResponse = await response.json();
223
- if (response.ok) {
224
- return jsonResponse;
225
- }
226
- throw new FetcherError(response.status, jsonResponse, requestId);
286
+ const { host, protocol } = new URL(url);
287
+ return { host, protocol };
227
288
  } catch (error) {
228
- throw new FetcherError(response.status, error, requestId);
289
+ return {};
229
290
  }
230
291
  }
231
292
 
@@ -284,6 +345,7 @@ const removeWorkspaceMember = (variables) => fetch$1({
284
345
  ...variables
285
346
  });
286
347
  const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
348
+ const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
287
349
  const cancelWorkspaceMemberInvite = (variables) => fetch$1({
288
350
  url: "/workspaces/{workspaceId}/invites/{inviteId}",
289
351
  method: "delete",
@@ -319,6 +381,12 @@ const deleteDatabase = (variables) => fetch$1({
319
381
  method: "delete",
320
382
  ...variables
321
383
  });
384
+ const getDatabaseMetadata = (variables) => fetch$1({
385
+ url: "/dbs/{dbName}/metadata",
386
+ method: "get",
387
+ ...variables
388
+ });
389
+ const updateDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
322
390
  const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
323
391
  const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
324
392
  const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
@@ -327,16 +395,28 @@ const resolveBranch = (variables) => fetch$1({
327
395
  method: "get",
328
396
  ...variables
329
397
  });
330
- const getBranchDetails = (variables) => fetch$1({
331
- url: "/db/{dbBranchName}",
398
+ const queryMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/query", 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}",
332
402
  method: "get",
333
403
  ...variables
334
404
  });
335
- const createBranch = (variables) => fetch$1({
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
+ });
414
+ const getBranchDetails = (variables) => fetch$1({
336
415
  url: "/db/{dbBranchName}",
337
- method: "put",
416
+ method: "get",
338
417
  ...variables
339
418
  });
419
+ const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
340
420
  const deleteBranch = (variables) => fetch$1({
341
421
  url: "/db/{dbBranchName}",
342
422
  method: "delete",
@@ -355,6 +435,16 @@ const getBranchMetadata = (variables) => fetch$1({
355
435
  const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
356
436
  const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
357
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 });
358
448
  const getBranchStats = (variables) => fetch$1({
359
449
  url: "/db/{dbBranchName}/stats",
360
450
  method: "get",
@@ -410,11 +500,7 @@ const updateColumn = (variables) => fetch$1({
410
500
  method: "patch",
411
501
  ...variables
412
502
  });
413
- const insertRecord = (variables) => fetch$1({
414
- url: "/db/{dbBranchName}/tables/{tableName}/data",
415
- method: "post",
416
- ...variables
417
- });
503
+ const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
418
504
  const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
419
505
  const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
420
506
  const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
@@ -444,6 +530,26 @@ const searchBranch = (variables) => fetch$1({
444
530
  method: "post",
445
531
  ...variables
446
532
  });
533
+ const summarizeTable = (variables) => fetch$1({
534
+ url: "/db/{dbBranchName}/tables/{tableName}/summarize",
535
+ method: "post",
536
+ ...variables
537
+ });
538
+ const cPgetDatabaseList = (variables) => fetch$1({
539
+ url: "/workspaces/{workspaceId}/dbs",
540
+ method: "get",
541
+ ...variables
542
+ });
543
+ const cPcreateDatabase = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables });
544
+ const cPdeleteDatabase = (variables) => fetch$1({
545
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
546
+ method: "delete",
547
+ ...variables
548
+ });
549
+ const cPgetCPDatabaseMetadata = (variables) => fetch$1(
550
+ { url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "get", ...variables }
551
+ );
552
+ const cPupdateCPDatabaseMetadata = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "patch", ...variables });
447
553
  const operationsByTag = {
448
554
  users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
449
555
  workspaces: {
@@ -456,6 +562,7 @@ const operationsByTag = {
456
562
  updateWorkspaceMemberRole,
457
563
  removeWorkspaceMember,
458
564
  inviteWorkspaceMember,
565
+ updateWorkspaceMemberInvite,
459
566
  cancelWorkspaceMemberInvite,
460
567
  resendWorkspaceMemberInvite,
461
568
  acceptWorkspaceMemberInvite
@@ -464,6 +571,8 @@ const operationsByTag = {
464
571
  getDatabaseList,
465
572
  createDatabase,
466
573
  deleteDatabase,
574
+ getDatabaseMetadata,
575
+ updateDatabaseMetadata,
467
576
  getGitBranchesMapping,
468
577
  addGitBranchesEntry,
469
578
  removeGitBranchesEntry,
@@ -476,10 +585,28 @@ const operationsByTag = {
476
585
  deleteBranch,
477
586
  updateBranchMetadata,
478
587
  getBranchMetadata,
588
+ getBranchStats
589
+ },
590
+ migrationRequests: {
591
+ queryMigrationRequests,
592
+ createMigrationRequest,
593
+ getMigrationRequest,
594
+ updateMigrationRequest,
595
+ listMigrationRequestsCommits,
596
+ compareMigrationRequest,
597
+ getMigrationRequestIsMerged,
598
+ mergeMigrationRequest
599
+ },
600
+ branchSchema: {
479
601
  getBranchMigrationHistory,
480
602
  executeBranchMigrationPlan,
481
603
  getBranchMigrationPlan,
482
- getBranchStats
604
+ compareBranchWithUserSchema,
605
+ compareBranchSchemas,
606
+ updateBranchSchema,
607
+ previewBranchSchemaEdit,
608
+ applyBranchSchemaEdit,
609
+ getBranchSchemaHistory
483
610
  },
484
611
  table: {
485
612
  createTable,
@@ -503,14 +630,22 @@ const operationsByTag = {
503
630
  bulkInsertTableRecords,
504
631
  queryTable,
505
632
  searchTable,
506
- searchBranch
633
+ searchBranch,
634
+ summarizeTable
635
+ },
636
+ databases: {
637
+ cPgetDatabaseList,
638
+ cPcreateDatabase,
639
+ cPdeleteDatabase,
640
+ cPgetCPDatabaseMetadata,
641
+ cPupdateCPDatabaseMetadata
507
642
  }
508
643
  };
509
644
 
510
645
  function getHostUrl(provider, type) {
511
- if (isValidAlias(provider)) {
646
+ if (isHostProviderAlias(provider)) {
512
647
  return providers[provider][type];
513
- } else if (isValidBuilder(provider)) {
648
+ } else if (isHostProviderBuilder(provider)) {
514
649
  return provider[type];
515
650
  }
516
651
  throw new Error("Invalid API provider");
@@ -525,10 +660,10 @@ const providers = {
525
660
  workspaces: "https://{workspaceId}.staging.xatabase.co"
526
661
  }
527
662
  };
528
- function isValidAlias(alias) {
663
+ function isHostProviderAlias(alias) {
529
664
  return isString(alias) && Object.keys(providers).includes(alias);
530
665
  }
531
- function isValidBuilder(builder) {
666
+ function isHostProviderBuilder(builder) {
532
667
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
533
668
  }
534
669
 
@@ -556,7 +691,8 @@ class XataApiClient {
556
691
  __privateAdd$7(this, _extraProps, void 0);
557
692
  __privateAdd$7(this, _namespaces, {});
558
693
  const provider = options.host ?? "production";
559
- const apiKey = options?.apiKey ?? getAPIKey();
694
+ const apiKey = options.apiKey ?? getAPIKey();
695
+ const trace = options.trace ?? defaultTrace;
560
696
  if (!apiKey) {
561
697
  throw new Error("Could not resolve a valid apiKey");
562
698
  }
@@ -564,7 +700,8 @@ class XataApiClient {
564
700
  apiUrl: getHostUrl(provider, "main"),
565
701
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
566
702
  fetchImpl: getFetchImplementation(options.fetch),
567
- apiKey
703
+ apiKey,
704
+ trace
568
705
  });
569
706
  }
570
707
  get user() {
@@ -597,6 +734,16 @@ class XataApiClient {
597
734
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
598
735
  return __privateGet$7(this, _namespaces).records;
599
736
  }
737
+ get migrationRequests() {
738
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
739
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
740
+ return __privateGet$7(this, _namespaces).migrationRequests;
741
+ }
742
+ get branchSchema() {
743
+ if (!__privateGet$7(this, _namespaces).branchSchema)
744
+ __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
745
+ return __privateGet$7(this, _namespaces).branchSchema;
746
+ }
600
747
  }
601
748
  _extraProps = new WeakMap();
602
749
  _namespaces = new WeakMap();
@@ -687,6 +834,13 @@ class WorkspaceApi {
687
834
  ...this.extraProps
688
835
  });
689
836
  }
837
+ updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
838
+ return operationsByTag.workspaces.updateWorkspaceMemberInvite({
839
+ pathParams: { workspaceId, inviteId },
840
+ body: { role },
841
+ ...this.extraProps
842
+ });
843
+ }
690
844
  cancelWorkspaceMemberInvite(workspaceId, inviteId) {
691
845
  return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
692
846
  pathParams: { workspaceId, inviteId },
@@ -729,6 +883,19 @@ class DatabaseApi {
729
883
  ...this.extraProps
730
884
  });
731
885
  }
886
+ getDatabaseMetadata(workspace, dbName) {
887
+ return operationsByTag.database.getDatabaseMetadata({
888
+ pathParams: { workspace, dbName },
889
+ ...this.extraProps
890
+ });
891
+ }
892
+ updateDatabaseMetadata(workspace, dbName, options = {}) {
893
+ return operationsByTag.database.updateDatabaseMetadata({
894
+ pathParams: { workspace, dbName },
895
+ body: options,
896
+ ...this.extraProps
897
+ });
898
+ }
732
899
  getGitBranchesMapping(workspace, dbName) {
733
900
  return operationsByTag.database.getGitBranchesMapping({
734
901
  pathParams: { workspace, dbName },
@@ -800,27 +967,6 @@ class BranchApi {
800
967
  ...this.extraProps
801
968
  });
802
969
  }
803
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
804
- return operationsByTag.branch.getBranchMigrationHistory({
805
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
806
- body: options,
807
- ...this.extraProps
808
- });
809
- }
810
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
811
- return operationsByTag.branch.executeBranchMigrationPlan({
812
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
813
- body: migrationPlan,
814
- ...this.extraProps
815
- });
816
- }
817
- getBranchMigrationPlan(workspace, database, branch, schema) {
818
- return operationsByTag.branch.getBranchMigrationPlan({
819
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
820
- body: schema,
821
- ...this.extraProps
822
- });
823
- }
824
970
  getBranchStats(workspace, database, branch) {
825
971
  return operationsByTag.branch.getBranchStats({
826
972
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
@@ -901,9 +1047,10 @@ class RecordsApi {
901
1047
  constructor(extraProps) {
902
1048
  this.extraProps = extraProps;
903
1049
  }
904
- insertRecord(workspace, database, branch, tableName, record) {
1050
+ insertRecord(workspace, database, branch, tableName, record, options = {}) {
905
1051
  return operationsByTag.records.insertRecord({
906
1052
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1053
+ queryParams: options,
907
1054
  body: record,
908
1055
  ...this.extraProps
909
1056
  });
@@ -932,21 +1079,24 @@ class RecordsApi {
932
1079
  ...this.extraProps
933
1080
  });
934
1081
  }
935
- deleteRecord(workspace, database, branch, tableName, recordId) {
1082
+ deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
936
1083
  return operationsByTag.records.deleteRecord({
937
1084
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1085
+ queryParams: options,
938
1086
  ...this.extraProps
939
1087
  });
940
1088
  }
941
1089
  getRecord(workspace, database, branch, tableName, recordId, options = {}) {
942
1090
  return operationsByTag.records.getRecord({
943
1091
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1092
+ queryParams: options,
944
1093
  ...this.extraProps
945
1094
  });
946
1095
  }
947
- bulkInsertTableRecords(workspace, database, branch, tableName, records) {
1096
+ bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
948
1097
  return operationsByTag.records.bulkInsertTableRecords({
949
1098
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1099
+ queryParams: options,
950
1100
  body: { records },
951
1101
  ...this.extraProps
952
1102
  });
@@ -972,6 +1122,138 @@ class RecordsApi {
972
1122
  ...this.extraProps
973
1123
  });
974
1124
  }
1125
+ summarizeTable(workspace, database, branch, tableName, query) {
1126
+ return operationsByTag.records.summarizeTable({
1127
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1128
+ body: query,
1129
+ ...this.extraProps
1130
+ });
1131
+ }
1132
+ }
1133
+ class MigrationRequestsApi {
1134
+ constructor(extraProps) {
1135
+ this.extraProps = extraProps;
1136
+ }
1137
+ queryMigrationRequests(workspace, database, options = {}) {
1138
+ return operationsByTag.migrationRequests.queryMigrationRequests({
1139
+ pathParams: { workspace, dbName: database },
1140
+ body: options,
1141
+ ...this.extraProps
1142
+ });
1143
+ }
1144
+ createMigrationRequest(workspace, database, options) {
1145
+ return operationsByTag.migrationRequests.createMigrationRequest({
1146
+ pathParams: { workspace, dbName: database },
1147
+ body: options,
1148
+ ...this.extraProps
1149
+ });
1150
+ }
1151
+ getMigrationRequest(workspace, database, migrationRequest) {
1152
+ return operationsByTag.migrationRequests.getMigrationRequest({
1153
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1154
+ ...this.extraProps
1155
+ });
1156
+ }
1157
+ updateMigrationRequest(workspace, database, migrationRequest, options) {
1158
+ return operationsByTag.migrationRequests.updateMigrationRequest({
1159
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1160
+ body: options,
1161
+ ...this.extraProps
1162
+ });
1163
+ }
1164
+ listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1165
+ return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1166
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1167
+ body: options,
1168
+ ...this.extraProps
1169
+ });
1170
+ }
1171
+ compareMigrationRequest(workspace, database, migrationRequest) {
1172
+ return operationsByTag.migrationRequests.compareMigrationRequest({
1173
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1174
+ ...this.extraProps
1175
+ });
1176
+ }
1177
+ getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1178
+ return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1179
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1180
+ ...this.extraProps
1181
+ });
1182
+ }
1183
+ mergeMigrationRequest(workspace, database, migrationRequest) {
1184
+ return operationsByTag.migrationRequests.mergeMigrationRequest({
1185
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1186
+ ...this.extraProps
1187
+ });
1188
+ }
1189
+ }
1190
+ class BranchSchemaApi {
1191
+ constructor(extraProps) {
1192
+ this.extraProps = extraProps;
1193
+ }
1194
+ getBranchMigrationHistory(workspace, database, branch, options = {}) {
1195
+ return operationsByTag.branchSchema.getBranchMigrationHistory({
1196
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1197
+ body: options,
1198
+ ...this.extraProps
1199
+ });
1200
+ }
1201
+ executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1202
+ return operationsByTag.branchSchema.executeBranchMigrationPlan({
1203
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1204
+ body: migrationPlan,
1205
+ ...this.extraProps
1206
+ });
1207
+ }
1208
+ getBranchMigrationPlan(workspace, database, branch, schema) {
1209
+ return operationsByTag.branchSchema.getBranchMigrationPlan({
1210
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1211
+ body: schema,
1212
+ ...this.extraProps
1213
+ });
1214
+ }
1215
+ compareBranchWithUserSchema(workspace, database, branch, schema) {
1216
+ return operationsByTag.branchSchema.compareBranchWithUserSchema({
1217
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1218
+ body: { schema },
1219
+ ...this.extraProps
1220
+ });
1221
+ }
1222
+ compareBranchSchemas(workspace, database, branch, branchName, schema) {
1223
+ return operationsByTag.branchSchema.compareBranchSchemas({
1224
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1225
+ body: { schema },
1226
+ ...this.extraProps
1227
+ });
1228
+ }
1229
+ updateBranchSchema(workspace, database, branch, migration) {
1230
+ return operationsByTag.branchSchema.updateBranchSchema({
1231
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1232
+ body: migration,
1233
+ ...this.extraProps
1234
+ });
1235
+ }
1236
+ previewBranchSchemaEdit(workspace, database, branch, migration) {
1237
+ return operationsByTag.branchSchema.previewBranchSchemaEdit({
1238
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1239
+ body: migration,
1240
+ ...this.extraProps
1241
+ });
1242
+ }
1243
+ applyBranchSchemaEdit(workspace, database, branch, edits) {
1244
+ return operationsByTag.branchSchema.applyBranchSchemaEdit({
1245
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1246
+ body: { edits },
1247
+ ...this.extraProps
1248
+ });
1249
+ }
1250
+ getBranchSchemaHistory(workspace, database, branch, options = {}) {
1251
+ return operationsByTag.branchSchema.getBranchSchemaHistory({
1252
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1253
+ body: options,
1254
+ ...this.extraProps
1255
+ });
1256
+ }
975
1257
  }
976
1258
 
977
1259
  class XataApiPlugin {
@@ -1035,10 +1317,10 @@ function isCursorPaginationOptions(options) {
1035
1317
  return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
1036
1318
  }
1037
1319
  const _RecordArray = class extends Array {
1038
- constructor(page, overrideRecords) {
1039
- super(..._RecordArray.parseConstructorParams(page, overrideRecords));
1320
+ constructor(...args) {
1321
+ super(..._RecordArray.parseConstructorParams(...args));
1040
1322
  __privateAdd$6(this, _page, void 0);
1041
- __privateSet$6(this, _page, page);
1323
+ __privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
1042
1324
  }
1043
1325
  static parseConstructorParams(...args) {
1044
1326
  if (args.length === 1 && typeof args[0] === "number") {
@@ -1050,6 +1332,12 @@ const _RecordArray = class extends Array {
1050
1332
  }
1051
1333
  return new Array(...args);
1052
1334
  }
1335
+ toArray() {
1336
+ return new Array(...this);
1337
+ }
1338
+ map(callbackfn, thisArg) {
1339
+ return this.toArray().map(callbackfn, thisArg);
1340
+ }
1053
1341
  async nextPage(size, offset) {
1054
1342
  const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
1055
1343
  return new _RecordArray(newPage);
@@ -1091,9 +1379,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
1091
1379
  setter ? setter.call(obj, value) : member.set(obj, value);
1092
1380
  return value;
1093
1381
  };
1094
- var _table$1, _repository, _data;
1382
+ var __privateMethod$3 = (obj, member, method) => {
1383
+ __accessCheck$5(obj, member, "access private method");
1384
+ return method;
1385
+ };
1386
+ var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
1095
1387
  const _Query = class {
1096
1388
  constructor(repository, table, data, rawParent) {
1389
+ __privateAdd$5(this, _cleanFilterConstraint);
1097
1390
  __privateAdd$5(this, _table$1, void 0);
1098
1391
  __privateAdd$5(this, _repository, void 0);
1099
1392
  __privateAdd$5(this, _data, { filter: {} });
@@ -1150,21 +1443,29 @@ const _Query = class {
1150
1443
  }
1151
1444
  filter(a, b) {
1152
1445
  if (arguments.length === 1) {
1153
- const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
1446
+ const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
1447
+ [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
1448
+ }));
1154
1449
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1155
1450
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1156
1451
  } else {
1157
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
1452
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
1453
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1158
1454
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1159
1455
  }
1160
1456
  }
1161
- sort(column, direction) {
1457
+ sort(column, direction = "asc") {
1162
1458
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1163
1459
  const sort = [...originalSort, { column, direction }];
1164
1460
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
1165
1461
  }
1166
1462
  select(columns) {
1167
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { columns }, __privateGet$5(this, _data));
1463
+ return new _Query(
1464
+ __privateGet$5(this, _repository),
1465
+ __privateGet$5(this, _table$1),
1466
+ { columns },
1467
+ __privateGet$5(this, _data)
1468
+ );
1168
1469
  }
1169
1470
  getPaginated(options = {}) {
1170
1471
  const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
@@ -1187,11 +1488,20 @@ const _Query = class {
1187
1488
  }
1188
1489
  }
1189
1490
  async getMany(options = {}) {
1190
- const page = await this.getPaginated(options);
1491
+ const { pagination = {}, ...rest } = options;
1492
+ const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
1493
+ const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
1494
+ let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
1495
+ const results = [...page.records];
1496
+ while (page.hasNextPage() && results.length < size) {
1497
+ page = await page.nextPage();
1498
+ results.push(...page.records);
1499
+ }
1191
1500
  if (page.hasNextPage() && options.pagination?.size === void 0) {
1192
1501
  console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
1193
1502
  }
1194
- return page.records;
1503
+ const array = new RecordArray(page, results.slice(0, size));
1504
+ return array;
1195
1505
  }
1196
1506
  async getAll(options = {}) {
1197
1507
  const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
@@ -1205,6 +1515,12 @@ const _Query = class {
1205
1515
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
1206
1516
  return records[0] ?? null;
1207
1517
  }
1518
+ async getFirstOrThrow(options = {}) {
1519
+ const records = await this.getMany({ ...options, pagination: { size: 1 } });
1520
+ if (records[0] === void 0)
1521
+ throw new Error("No results found.");
1522
+ return records[0];
1523
+ }
1208
1524
  cache(ttl) {
1209
1525
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1210
1526
  }
@@ -1228,6 +1544,17 @@ let Query = _Query;
1228
1544
  _table$1 = new WeakMap();
1229
1545
  _repository = new WeakMap();
1230
1546
  _data = new WeakMap();
1547
+ _cleanFilterConstraint = new WeakSet();
1548
+ cleanFilterConstraint_fn = function(column, value) {
1549
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
1550
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
1551
+ return { $includes: value };
1552
+ }
1553
+ if (columnType === "link" && isObject(value) && isString(value.id)) {
1554
+ return value.id;
1555
+ }
1556
+ return value;
1557
+ };
1231
1558
  function cleanParent(data, parent) {
1232
1559
  if (isCursorPaginationOptions(data.pagination)) {
1233
1560
  return { ...parent, sorting: void 0, filter: void 0 };
@@ -1289,203 +1616,286 @@ var __privateMethod$2 = (obj, member, method) => {
1289
1616
  __accessCheck$4(obj, member, "access private method");
1290
1617
  return method;
1291
1618
  };
1292
- var _table, _getFetchProps, _cache, _schemaTables$2, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _invalidateCache, invalidateCache_fn, _setCacheRecord, setCacheRecord_fn, _getCacheRecord, getCacheRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
1619
+ 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;
1293
1620
  class Repository extends Query {
1294
1621
  }
1295
1622
  class RestRepository extends Query {
1296
1623
  constructor(options) {
1297
- super(null, options.table, {});
1624
+ super(
1625
+ null,
1626
+ { name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
1627
+ {}
1628
+ );
1298
1629
  __privateAdd$4(this, _insertRecordWithoutId);
1299
1630
  __privateAdd$4(this, _insertRecordWithId);
1300
1631
  __privateAdd$4(this, _bulkInsertTableRecords);
1301
1632
  __privateAdd$4(this, _updateRecordWithID);
1302
1633
  __privateAdd$4(this, _upsertRecordWithID);
1303
1634
  __privateAdd$4(this, _deleteRecord);
1304
- __privateAdd$4(this, _invalidateCache);
1305
- __privateAdd$4(this, _setCacheRecord);
1306
- __privateAdd$4(this, _getCacheRecord);
1307
1635
  __privateAdd$4(this, _setCacheQuery);
1308
1636
  __privateAdd$4(this, _getCacheQuery);
1309
1637
  __privateAdd$4(this, _getSchemaTables$1);
1310
1638
  __privateAdd$4(this, _table, void 0);
1311
1639
  __privateAdd$4(this, _getFetchProps, void 0);
1640
+ __privateAdd$4(this, _db, void 0);
1312
1641
  __privateAdd$4(this, _cache, void 0);
1313
1642
  __privateAdd$4(this, _schemaTables$2, void 0);
1643
+ __privateAdd$4(this, _trace, void 0);
1314
1644
  __privateSet$4(this, _table, options.table);
1315
1645
  __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1316
- this.db = options.db;
1646
+ __privateSet$4(this, _db, options.db);
1317
1647
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1318
1648
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
1649
+ const trace = options.pluginOptions.trace ?? defaultTrace;
1650
+ __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
1651
+ return trace(name, fn, {
1652
+ ...options2,
1653
+ [TraceAttributes.TABLE]: __privateGet$4(this, _table),
1654
+ [TraceAttributes.KIND]: "sdk-operation",
1655
+ [TraceAttributes.VERSION]: VERSION
1656
+ });
1657
+ });
1319
1658
  }
1320
- async create(a, b) {
1321
- if (Array.isArray(a)) {
1322
- if (a.length === 0)
1323
- return [];
1324
- const records = await __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a);
1325
- await Promise.all(records.map((record) => __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record)));
1326
- return records;
1327
- }
1328
- if (isString(a) && isObject(b)) {
1329
- if (a === "")
1330
- throw new Error("The id can't be empty");
1331
- const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b);
1332
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1333
- return record;
1334
- }
1335
- if (isObject(a) && isString(a.id)) {
1336
- if (a.id === "")
1337
- throw new Error("The id can't be empty");
1338
- const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 });
1339
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1340
- return record;
1341
- }
1342
- if (isObject(a)) {
1343
- const record = await __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a);
1344
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1345
- return record;
1346
- }
1347
- throw new Error("Invalid arguments for create method");
1348
- }
1349
- async read(a) {
1350
- if (Array.isArray(a)) {
1351
- if (a.length === 0)
1352
- return [];
1353
- const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
1354
- return this.getAll({ filter: { id: { $any: ids } } });
1355
- }
1356
- const id = isString(a) ? a : a.id;
1357
- if (isString(id)) {
1358
- const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, id);
1359
- if (cacheRecord)
1360
- return cacheRecord;
1361
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1362
- try {
1363
- const response = await getRecord({
1364
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: id },
1365
- ...fetchProps
1366
- });
1367
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1368
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1369
- } catch (e) {
1370
- if (isObject(e) && e.status === 404) {
1371
- return null;
1659
+ async create(a, b, c) {
1660
+ return __privateGet$4(this, _trace).call(this, "create", async () => {
1661
+ if (Array.isArray(a)) {
1662
+ if (a.length === 0)
1663
+ return [];
1664
+ const columns = isStringArray(b) ? b : void 0;
1665
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
1666
+ }
1667
+ if (isString(a) && isObject(b)) {
1668
+ if (a === "")
1669
+ throw new Error("The id can't be empty");
1670
+ const columns = isStringArray(c) ? c : void 0;
1671
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
1672
+ }
1673
+ if (isObject(a) && isString(a.id)) {
1674
+ if (a.id === "")
1675
+ throw new Error("The id can't be empty");
1676
+ const columns = isStringArray(b) ? b : void 0;
1677
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1678
+ }
1679
+ if (isObject(a)) {
1680
+ const columns = isStringArray(b) ? b : void 0;
1681
+ return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
1682
+ }
1683
+ throw new Error("Invalid arguments for create method");
1684
+ });
1685
+ }
1686
+ async read(a, b) {
1687
+ return __privateGet$4(this, _trace).call(this, "read", async () => {
1688
+ const columns = isStringArray(b) ? b : ["*"];
1689
+ if (Array.isArray(a)) {
1690
+ if (a.length === 0)
1691
+ return [];
1692
+ const ids = a.map((item) => extractId(item));
1693
+ const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
1694
+ const dictionary = finalObjects.reduce((acc, object) => {
1695
+ acc[object.id] = object;
1696
+ return acc;
1697
+ }, {});
1698
+ return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
1699
+ }
1700
+ const id = extractId(a);
1701
+ if (id) {
1702
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1703
+ try {
1704
+ const response = await getRecord({
1705
+ pathParams: {
1706
+ workspace: "{workspaceId}",
1707
+ dbBranchName: "{dbBranch}",
1708
+ tableName: __privateGet$4(this, _table),
1709
+ recordId: id
1710
+ },
1711
+ queryParams: { columns },
1712
+ ...fetchProps
1713
+ });
1714
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1715
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1716
+ } catch (e) {
1717
+ if (isObject(e) && e.status === 404) {
1718
+ return null;
1719
+ }
1720
+ throw e;
1372
1721
  }
1373
- throw e;
1374
1722
  }
1375
- }
1723
+ return null;
1724
+ });
1376
1725
  }
1377
- async update(a, b) {
1378
- if (Array.isArray(a)) {
1379
- if (a.length === 0)
1380
- return [];
1381
- if (a.length > 100) {
1382
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1726
+ async readOrThrow(a, b) {
1727
+ return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
1728
+ const result = await this.read(a, b);
1729
+ if (Array.isArray(result)) {
1730
+ const missingIds = compact(
1731
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1732
+ );
1733
+ if (missingIds.length > 0) {
1734
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1735
+ }
1736
+ return result;
1383
1737
  }
1384
- return Promise.all(a.map((object) => this.update(object)));
1385
- }
1386
- if (isString(a) && isObject(b)) {
1387
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1388
- const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b);
1389
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1390
- return record;
1391
- }
1392
- if (isObject(a) && isString(a.id)) {
1393
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1394
- const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1395
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1396
- return record;
1397
- }
1398
- throw new Error("Invalid arguments for update method");
1399
- }
1400
- async createOrUpdate(a, b) {
1401
- if (Array.isArray(a)) {
1402
- if (a.length === 0)
1403
- return [];
1404
- if (a.length > 100) {
1405
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1738
+ if (result === null) {
1739
+ const id = extractId(a) ?? "unknown";
1740
+ throw new Error(`Record with id ${id} not found`);
1406
1741
  }
1407
- return Promise.all(a.map((object) => this.createOrUpdate(object)));
1408
- }
1409
- if (isString(a) && isObject(b)) {
1410
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1411
- const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b);
1412
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1413
- return record;
1414
- }
1415
- if (isObject(a) && isString(a.id)) {
1416
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1417
- const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1418
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1419
- return record;
1420
- }
1421
- throw new Error("Invalid arguments for createOrUpdate method");
1422
- }
1423
- async delete(a) {
1424
- if (Array.isArray(a)) {
1425
- if (a.length === 0)
1426
- return;
1427
- if (a.length > 100) {
1428
- console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1742
+ return result;
1743
+ });
1744
+ }
1745
+ async update(a, b, c) {
1746
+ return __privateGet$4(this, _trace).call(this, "update", async () => {
1747
+ if (Array.isArray(a)) {
1748
+ if (a.length === 0)
1749
+ return [];
1750
+ if (a.length > 100) {
1751
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1752
+ }
1753
+ const columns = isStringArray(b) ? b : ["*"];
1754
+ return Promise.all(a.map((object) => this.update(object, columns)));
1429
1755
  }
1430
- await Promise.all(a.map((id) => this.delete(id)));
1431
- return;
1432
- }
1433
- if (isString(a)) {
1434
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
1435
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1436
- return;
1437
- }
1438
- if (isObject(a) && isString(a.id)) {
1439
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
1440
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1441
- return;
1442
- }
1443
- throw new Error("Invalid arguments for delete method");
1756
+ if (isString(a) && isObject(b)) {
1757
+ const columns = isStringArray(c) ? c : void 0;
1758
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
1759
+ }
1760
+ if (isObject(a) && isString(a.id)) {
1761
+ const columns = isStringArray(b) ? b : void 0;
1762
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1763
+ }
1764
+ throw new Error("Invalid arguments for update method");
1765
+ });
1766
+ }
1767
+ async updateOrThrow(a, b, c) {
1768
+ return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1769
+ const result = await this.update(a, b, c);
1770
+ if (Array.isArray(result)) {
1771
+ const missingIds = compact(
1772
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1773
+ );
1774
+ if (missingIds.length > 0) {
1775
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1776
+ }
1777
+ return result;
1778
+ }
1779
+ if (result === null) {
1780
+ const id = extractId(a) ?? "unknown";
1781
+ throw new Error(`Record with id ${id} not found`);
1782
+ }
1783
+ return result;
1784
+ });
1785
+ }
1786
+ async createOrUpdate(a, b, c) {
1787
+ return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
1788
+ if (Array.isArray(a)) {
1789
+ if (a.length === 0)
1790
+ return [];
1791
+ if (a.length > 100) {
1792
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1793
+ }
1794
+ const columns = isStringArray(b) ? b : ["*"];
1795
+ return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
1796
+ }
1797
+ if (isString(a) && isObject(b)) {
1798
+ const columns = isStringArray(c) ? c : void 0;
1799
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
1800
+ }
1801
+ if (isObject(a) && isString(a.id)) {
1802
+ const columns = isStringArray(c) ? c : void 0;
1803
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1804
+ }
1805
+ throw new Error("Invalid arguments for createOrUpdate method");
1806
+ });
1807
+ }
1808
+ async delete(a, b) {
1809
+ return __privateGet$4(this, _trace).call(this, "delete", async () => {
1810
+ if (Array.isArray(a)) {
1811
+ if (a.length === 0)
1812
+ return [];
1813
+ if (a.length > 100) {
1814
+ console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1815
+ }
1816
+ return Promise.all(a.map((id) => this.delete(id, b)));
1817
+ }
1818
+ if (isString(a)) {
1819
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
1820
+ }
1821
+ if (isObject(a) && isString(a.id)) {
1822
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
1823
+ }
1824
+ throw new Error("Invalid arguments for delete method");
1825
+ });
1826
+ }
1827
+ async deleteOrThrow(a, b) {
1828
+ return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
1829
+ const result = await this.delete(a, b);
1830
+ if (Array.isArray(result)) {
1831
+ const missingIds = compact(
1832
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1833
+ );
1834
+ if (missingIds.length > 0) {
1835
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1836
+ }
1837
+ return result;
1838
+ } else if (result === null) {
1839
+ const id = extractId(a) ?? "unknown";
1840
+ throw new Error(`Record with id ${id} not found`);
1841
+ }
1842
+ return result;
1843
+ });
1444
1844
  }
1445
1845
  async search(query, options = {}) {
1446
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1447
- const { records } = await searchTable({
1448
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1449
- body: {
1450
- query,
1451
- fuzziness: options.fuzziness,
1452
- highlight: options.highlight,
1453
- filter: options.filter
1454
- },
1455
- ...fetchProps
1846
+ return __privateGet$4(this, _trace).call(this, "search", async () => {
1847
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1848
+ const { records } = await searchTable({
1849
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1850
+ body: {
1851
+ query,
1852
+ fuzziness: options.fuzziness,
1853
+ prefix: options.prefix,
1854
+ highlight: options.highlight,
1855
+ filter: options.filter,
1856
+ boosters: options.boosters
1857
+ },
1858
+ ...fetchProps
1859
+ });
1860
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1861
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
1456
1862
  });
1457
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1458
- return records.map((item) => initObject(this.db, schemaTables, __privateGet$4(this, _table), item));
1459
1863
  }
1460
1864
  async query(query) {
1461
- const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1462
- if (cacheQuery)
1463
- return new Page(query, cacheQuery.meta, cacheQuery.records);
1464
- const data = query.getQueryOptions();
1465
- const body = {
1466
- filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1467
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1468
- page: data.pagination,
1469
- columns: data.columns
1470
- };
1471
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1472
- const { meta, records: objects } = await queryTable({
1473
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1474
- body,
1475
- ...fetchProps
1865
+ return __privateGet$4(this, _trace).call(this, "query", async () => {
1866
+ const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1867
+ if (cacheQuery)
1868
+ return new Page(query, cacheQuery.meta, cacheQuery.records);
1869
+ const data = query.getQueryOptions();
1870
+ const body = {
1871
+ filter: cleanFilter(data.filter),
1872
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1873
+ page: data.pagination,
1874
+ columns: data.columns
1875
+ };
1876
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1877
+ const { meta, records: objects } = await queryTable({
1878
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1879
+ body,
1880
+ ...fetchProps
1881
+ });
1882
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1883
+ const records = objects.map(
1884
+ (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
1885
+ );
1886
+ await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1887
+ return new Page(query, meta, records);
1476
1888
  });
1477
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1478
- const records = objects.map((record) => initObject(this.db, schemaTables, __privateGet$4(this, _table), record));
1479
- await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1480
- return new Page(query, meta, records);
1481
1889
  }
1482
1890
  }
1483
1891
  _table = new WeakMap();
1484
1892
  _getFetchProps = new WeakMap();
1893
+ _db = new WeakMap();
1485
1894
  _cache = new WeakMap();
1486
1895
  _schemaTables$2 = new WeakMap();
1896
+ _trace = new WeakMap();
1487
1897
  _insertRecordWithoutId = new WeakSet();
1488
- insertRecordWithoutId_fn = async function(object) {
1898
+ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1489
1899
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1490
1900
  const record = transformObjectLinks(object);
1491
1901
  const response = await insertRecord({
@@ -1494,17 +1904,15 @@ insertRecordWithoutId_fn = async function(object) {
1494
1904
  dbBranchName: "{dbBranch}",
1495
1905
  tableName: __privateGet$4(this, _table)
1496
1906
  },
1907
+ queryParams: { columns },
1497
1908
  body: record,
1498
1909
  ...fetchProps
1499
1910
  });
1500
- const finalObject = await this.read(response.id);
1501
- if (!finalObject) {
1502
- throw new Error("The server failed to save the record");
1503
- }
1504
- return finalObject;
1911
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1912
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1505
1913
  };
1506
1914
  _insertRecordWithId = new WeakSet();
1507
- insertRecordWithId_fn = async function(recordId, object) {
1915
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
1508
1916
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1509
1917
  const record = transformObjectLinks(object);
1510
1918
  const response = await insertRecordWithID({
@@ -1515,92 +1923,78 @@ insertRecordWithId_fn = async function(recordId, object) {
1515
1923
  recordId
1516
1924
  },
1517
1925
  body: record,
1518
- queryParams: { createOnly: true },
1926
+ queryParams: { createOnly: true, columns },
1519
1927
  ...fetchProps
1520
1928
  });
1521
- const finalObject = await this.read(response.id);
1522
- if (!finalObject) {
1523
- throw new Error("The server failed to save the record");
1524
- }
1525
- return finalObject;
1929
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1930
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1526
1931
  };
1527
1932
  _bulkInsertTableRecords = new WeakSet();
1528
- bulkInsertTableRecords_fn = async function(objects) {
1933
+ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1529
1934
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1530
1935
  const records = objects.map((object) => transformObjectLinks(object));
1531
- const { recordIDs } = await bulkInsertTableRecords({
1936
+ const response = await bulkInsertTableRecords({
1532
1937
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1938
+ queryParams: { columns },
1533
1939
  body: { records },
1534
1940
  ...fetchProps
1535
1941
  });
1536
- const finalObjects = await this.read(recordIDs);
1537
- if (finalObjects.length !== objects.length) {
1538
- throw new Error("The server failed to save some records");
1942
+ if (!isResponseWithRecords(response)) {
1943
+ throw new Error("Request included columns but server didn't include them");
1539
1944
  }
1540
- const dictionary = finalObjects.reduce((acc, object) => {
1541
- acc[object.id] = object;
1542
- return acc;
1543
- }, {});
1544
- return recordIDs.map((id) => dictionary[id]);
1945
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1946
+ return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
1545
1947
  };
1546
1948
  _updateRecordWithID = new WeakSet();
1547
- updateRecordWithID_fn = async function(recordId, object) {
1949
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1548
1950
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1549
1951
  const record = transformObjectLinks(object);
1550
- const response = await updateRecordWithID({
1551
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1552
- body: record,
1553
- ...fetchProps
1554
- });
1555
- const item = await this.read(response.id);
1556
- if (!item)
1557
- throw new Error("The server failed to save the record");
1558
- return item;
1952
+ try {
1953
+ const response = await updateRecordWithID({
1954
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1955
+ queryParams: { columns },
1956
+ body: record,
1957
+ ...fetchProps
1958
+ });
1959
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1960
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1961
+ } catch (e) {
1962
+ if (isObject(e) && e.status === 404) {
1963
+ return null;
1964
+ }
1965
+ throw e;
1966
+ }
1559
1967
  };
1560
1968
  _upsertRecordWithID = new WeakSet();
1561
- upsertRecordWithID_fn = async function(recordId, object) {
1969
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1562
1970
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1563
1971
  const response = await upsertRecordWithID({
1564
1972
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1973
+ queryParams: { columns },
1565
1974
  body: object,
1566
1975
  ...fetchProps
1567
1976
  });
1568
- const item = await this.read(response.id);
1569
- if (!item)
1570
- throw new Error("The server failed to save the record");
1571
- return item;
1977
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1978
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1572
1979
  };
1573
1980
  _deleteRecord = new WeakSet();
1574
- deleteRecord_fn = async function(recordId) {
1981
+ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1575
1982
  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
- });
1580
- };
1581
- _invalidateCache = new WeakSet();
1582
- invalidateCache_fn = async function(recordId) {
1583
- await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1584
- const cacheItems = await __privateGet$4(this, _cache).getAll();
1585
- const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
1586
- for (const [key, value] of queries) {
1587
- const ids = getIds(value);
1588
- if (ids.includes(recordId))
1589
- await __privateGet$4(this, _cache).delete(key);
1983
+ try {
1984
+ const response = await deleteRecord({
1985
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1986
+ queryParams: { columns },
1987
+ ...fetchProps
1988
+ });
1989
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1990
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1991
+ } catch (e) {
1992
+ if (isObject(e) && e.status === 404) {
1993
+ return null;
1994
+ }
1995
+ throw e;
1590
1996
  }
1591
1997
  };
1592
- _setCacheRecord = new WeakSet();
1593
- setCacheRecord_fn = async function(record) {
1594
- if (!__privateGet$4(this, _cache).cacheRecords)
1595
- return;
1596
- await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
1597
- };
1598
- _getCacheRecord = new WeakSet();
1599
- getCacheRecord_fn = async function(recordId) {
1600
- if (!__privateGet$4(this, _cache).cacheRecords)
1601
- return null;
1602
- return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1603
- };
1604
1998
  _setCacheQuery = new WeakSet();
1605
1999
  setCacheQuery_fn = async function(query, meta, records) {
1606
2000
  await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
@@ -1636,7 +2030,7 @@ const transformObjectLinks = (object) => {
1636
2030
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
1637
2031
  }, {});
1638
2032
  };
1639
- const initObject = (db, schemaTables, table, object) => {
2033
+ const initObject = (db, schemaTables, table, object, selectedColumns) => {
1640
2034
  const result = {};
1641
2035
  const { xata, ...rest } = object ?? {};
1642
2036
  Object.assign(result, rest);
@@ -1644,6 +2038,8 @@ const initObject = (db, schemaTables, table, object) => {
1644
2038
  if (!columns)
1645
2039
  console.error(`Table ${table} not found in schema`);
1646
2040
  for (const column of columns ?? []) {
2041
+ if (!isValidColumn(selectedColumns, column))
2042
+ continue;
1647
2043
  const value = result[column.name];
1648
2044
  switch (column.type) {
1649
2045
  case "datetime": {
@@ -1660,17 +2056,35 @@ const initObject = (db, schemaTables, table, object) => {
1660
2056
  if (!linkTable) {
1661
2057
  console.error(`Failed to parse link for field ${column.name}`);
1662
2058
  } else if (isObject(value)) {
1663
- result[column.name] = initObject(db, schemaTables, linkTable, value);
2059
+ const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
2060
+ if (item === column.name) {
2061
+ return [...acc, "*"];
2062
+ }
2063
+ if (item.startsWith(`${column.name}.`)) {
2064
+ const [, ...path] = item.split(".");
2065
+ return [...acc, path.join(".")];
2066
+ }
2067
+ return acc;
2068
+ }, []);
2069
+ result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2070
+ } else {
2071
+ result[column.name] = null;
1664
2072
  }
1665
2073
  break;
1666
2074
  }
2075
+ default:
2076
+ result[column.name] = value ?? null;
2077
+ if (column.notNull === true && value === null) {
2078
+ console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2079
+ }
2080
+ break;
1667
2081
  }
1668
2082
  }
1669
- result.read = function() {
1670
- return db[table].read(result["id"]);
2083
+ result.read = function(columns2) {
2084
+ return db[table].read(result["id"], columns2);
1671
2085
  };
1672
- result.update = function(data) {
1673
- return db[table].update(result["id"], data);
2086
+ result.update = function(data, columns2) {
2087
+ return db[table].update(result["id"], data, columns2);
1674
2088
  };
1675
2089
  result.delete = function() {
1676
2090
  return db[table].delete(result["id"]);
@@ -1684,14 +2098,30 @@ const initObject = (db, schemaTables, table, object) => {
1684
2098
  Object.freeze(result);
1685
2099
  return result;
1686
2100
  };
1687
- function getIds(value) {
1688
- if (Array.isArray(value)) {
1689
- return value.map((item) => getIds(item)).flat();
1690
- }
1691
- if (!isObject(value))
1692
- return [];
1693
- const nestedIds = Object.values(value).map((item) => getIds(item)).flat();
1694
- return isString(value.id) ? [value.id, ...nestedIds] : nestedIds;
2101
+ function isResponseWithRecords(value) {
2102
+ return isObject(value) && Array.isArray(value.records);
2103
+ }
2104
+ function extractId(value) {
2105
+ if (isString(value))
2106
+ return value;
2107
+ if (isObject(value) && isString(value.id))
2108
+ return value.id;
2109
+ return void 0;
2110
+ }
2111
+ function cleanFilter(filter) {
2112
+ if (!filter)
2113
+ return void 0;
2114
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2115
+ return values.length > 0 ? filter : void 0;
2116
+ }
2117
+ function isValidColumn(columns, column) {
2118
+ if (columns.includes("*"))
2119
+ return true;
2120
+ if (column.type === "link") {
2121
+ const linkColumns = columns.filter((item) => item.startsWith(column.name));
2122
+ return linkColumns.length > 0;
2123
+ }
2124
+ return columns.includes(column.name);
1695
2125
  }
1696
2126
 
1697
2127
  var __accessCheck$3 = (obj, member, msg) => {
@@ -1718,7 +2148,6 @@ class SimpleCache {
1718
2148
  __privateAdd$3(this, _map, void 0);
1719
2149
  __privateSet$3(this, _map, /* @__PURE__ */ new Map());
1720
2150
  this.capacity = options.max ?? 500;
1721
- this.cacheRecords = options.cacheRecords ?? true;
1722
2151
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
1723
2152
  }
1724
2153
  async getAll() {
@@ -1744,18 +2173,25 @@ class SimpleCache {
1744
2173
  }
1745
2174
  _map = new WeakMap();
1746
2175
 
1747
- const gt = (value) => ({ $gt: value });
1748
- const ge = (value) => ({ $ge: value });
1749
- const gte = (value) => ({ $ge: value });
1750
- const lt = (value) => ({ $lt: value });
1751
- const lte = (value) => ({ $le: value });
1752
- const le = (value) => ({ $le: value });
2176
+ const greaterThan = (value) => ({ $gt: value });
2177
+ const gt = greaterThan;
2178
+ const greaterThanEquals = (value) => ({ $ge: value });
2179
+ const greaterEquals = greaterThanEquals;
2180
+ const gte = greaterThanEquals;
2181
+ const ge = greaterThanEquals;
2182
+ const lessThan = (value) => ({ $lt: value });
2183
+ const lt = lessThan;
2184
+ const lessThanEquals = (value) => ({ $le: value });
2185
+ const lessEquals = lessThanEquals;
2186
+ const lte = lessThanEquals;
2187
+ const le = lessThanEquals;
1753
2188
  const exists = (column) => ({ $exists: column });
1754
2189
  const notExists = (column) => ({ $notExists: column });
1755
2190
  const startsWith = (value) => ({ $startsWith: value });
1756
2191
  const endsWith = (value) => ({ $endsWith: value });
1757
2192
  const pattern = (value) => ({ $pattern: value });
1758
2193
  const is = (value) => ({ $is: value });
2194
+ const equals = is;
1759
2195
  const isNot = (value) => ({ $isNot: value });
1760
2196
  const contains = (value) => ({ $contains: value });
1761
2197
  const includes = (value) => ({ $includes: value });
@@ -1790,16 +2226,19 @@ class SchemaPlugin extends XataPlugin {
1790
2226
  __privateSet$2(this, _schemaTables$1, schemaTables);
1791
2227
  }
1792
2228
  build(pluginOptions) {
1793
- const db = new Proxy({}, {
1794
- get: (_target, table) => {
1795
- if (!isString(table))
1796
- throw new Error("Invalid table name");
1797
- if (__privateGet$2(this, _tables)[table] === void 0) {
1798
- __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
2229
+ const db = new Proxy(
2230
+ {},
2231
+ {
2232
+ get: (_target, table) => {
2233
+ if (!isString(table))
2234
+ throw new Error("Invalid table name");
2235
+ if (__privateGet$2(this, _tables)[table] === void 0) {
2236
+ __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
2237
+ }
2238
+ return __privateGet$2(this, _tables)[table];
1799
2239
  }
1800
- return __privateGet$2(this, _tables)[table];
1801
2240
  }
1802
- });
2241
+ );
1803
2242
  const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
1804
2243
  for (const table of tableNames) {
1805
2244
  db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
@@ -1849,7 +2288,7 @@ class SearchPlugin extends XataPlugin {
1849
2288
  const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
1850
2289
  return records.map((record) => {
1851
2290
  const { table = "orphan" } = record.xata;
1852
- return { table, record: initObject(this.db, schemaTables, table, record) };
2291
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
1853
2292
  });
1854
2293
  },
1855
2294
  byTable: async (query, options = {}) => {
@@ -1858,7 +2297,7 @@ class SearchPlugin extends XataPlugin {
1858
2297
  return records.reduce((acc, record) => {
1859
2298
  const { table = "orphan" } = record.xata;
1860
2299
  const items = acc[table] ?? [];
1861
- const item = initObject(this.db, schemaTables, table, record);
2300
+ const item = initObject(this.db, schemaTables, table, record, ["*"]);
1862
2301
  return { ...acc, [table]: [...items, item] };
1863
2302
  }, {});
1864
2303
  }
@@ -1869,10 +2308,10 @@ _schemaTables = new WeakMap();
1869
2308
  _search = new WeakSet();
1870
2309
  search_fn = async function(query, options, getFetchProps) {
1871
2310
  const fetchProps = await getFetchProps();
1872
- const { tables, fuzziness, highlight } = options ?? {};
2311
+ const { tables, fuzziness, highlight, prefix } = options ?? {};
1873
2312
  const { records } = await searchBranch({
1874
2313
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1875
- body: { tables, query, fuzziness, highlight },
2314
+ body: { tables, query, fuzziness, prefix, highlight },
1876
2315
  ...fetchProps
1877
2316
  });
1878
2317
  return records;
@@ -1895,14 +2334,14 @@ const isBranchStrategyBuilder = (strategy) => {
1895
2334
  };
1896
2335
 
1897
2336
  async function getCurrentBranchName(options) {
1898
- const { branch } = getEnvironment();
2337
+ const { branch, envBranch } = getEnvironment();
1899
2338
  if (branch) {
1900
2339
  const details = await getDatabaseBranch(branch, options);
1901
2340
  if (details)
1902
2341
  return branch;
1903
2342
  console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
1904
2343
  }
1905
- const gitBranch = await getGitBranch();
2344
+ const gitBranch = envBranch || await getGitBranch();
1906
2345
  return resolveXataBranch(gitBranch, options);
1907
2346
  }
1908
2347
  async function getCurrentBranchDetails(options) {
@@ -1913,9 +2352,13 @@ async function resolveXataBranch(gitBranch, options) {
1913
2352
  const databaseURL = options?.databaseURL || getDatabaseURL();
1914
2353
  const apiKey = options?.apiKey || getAPIKey();
1915
2354
  if (!databaseURL)
1916
- throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
2355
+ throw new Error(
2356
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2357
+ );
1917
2358
  if (!apiKey)
1918
- throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
2359
+ throw new Error(
2360
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2361
+ );
1919
2362
  const [protocol, , host, , dbName] = databaseURL.split("/");
1920
2363
  const [workspace] = host.split(".");
1921
2364
  const { fallbackBranch } = getEnvironment();
@@ -1925,7 +2368,8 @@ async function resolveXataBranch(gitBranch, options) {
1925
2368
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1926
2369
  workspacesApiUrl: `${protocol}//${host}`,
1927
2370
  pathParams: { dbName, workspace },
1928
- queryParams: { gitBranch, fallbackBranch }
2371
+ queryParams: { gitBranch, fallbackBranch },
2372
+ trace: defaultTrace
1929
2373
  });
1930
2374
  return branch;
1931
2375
  }
@@ -1933,9 +2377,13 @@ async function getDatabaseBranch(branch, options) {
1933
2377
  const databaseURL = options?.databaseURL || getDatabaseURL();
1934
2378
  const apiKey = options?.apiKey || getAPIKey();
1935
2379
  if (!databaseURL)
1936
- throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
2380
+ throw new Error(
2381
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2382
+ );
1937
2383
  if (!apiKey)
1938
- throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
2384
+ throw new Error(
2385
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2386
+ );
1939
2387
  const [protocol, , host, , database] = databaseURL.split("/");
1940
2388
  const [workspace] = host.split(".");
1941
2389
  const dbBranchName = `${database}:${branch}`;
@@ -1945,7 +2393,8 @@ async function getDatabaseBranch(branch, options) {
1945
2393
  apiUrl: databaseURL,
1946
2394
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1947
2395
  workspacesApiUrl: `${protocol}//${host}`,
1948
- pathParams: { dbBranchName, workspace }
2396
+ pathParams: { dbBranchName, workspace },
2397
+ trace: defaultTrace
1949
2398
  });
1950
2399
  } catch (err) {
1951
2400
  if (isObject(err) && err.status === 404)
@@ -1985,17 +2434,20 @@ var __privateMethod = (obj, member, method) => {
1985
2434
  return method;
1986
2435
  };
1987
2436
  const buildClient = (plugins) => {
1988
- var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
2437
+ var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
1989
2438
  return _a = class {
1990
2439
  constructor(options = {}, schemaTables) {
1991
2440
  __privateAdd(this, _parseOptions);
1992
2441
  __privateAdd(this, _getFetchProps);
1993
2442
  __privateAdd(this, _evaluateBranch);
1994
2443
  __privateAdd(this, _branch, void 0);
2444
+ __privateAdd(this, _options, void 0);
1995
2445
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
2446
+ __privateSet(this, _options, safeOptions);
1996
2447
  const pluginOptions = {
1997
2448
  getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
1998
- cache: safeOptions.cache
2449
+ cache: safeOptions.cache,
2450
+ trace: safeOptions.trace
1999
2451
  };
2000
2452
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
2001
2453
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
@@ -2014,22 +2466,26 @@ const buildClient = (plugins) => {
2014
2466
  }
2015
2467
  }
2016
2468
  }
2017
- }, _branch = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
2469
+ async getConfig() {
2470
+ const databaseURL = __privateGet(this, _options).databaseURL;
2471
+ const branch = await __privateGet(this, _options).branch();
2472
+ return { databaseURL, branch };
2473
+ }
2474
+ }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
2018
2475
  const fetch = getFetchImplementation(options?.fetch);
2019
2476
  const databaseURL = options?.databaseURL || getDatabaseURL();
2020
2477
  const apiKey = options?.apiKey || getAPIKey();
2021
- const cache = options?.cache ?? new SimpleCache({ cacheRecords: false, defaultQueryTTL: 0 });
2478
+ const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
2479
+ const trace = options?.trace ?? defaultTrace;
2022
2480
  const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
2023
- if (!databaseURL || !apiKey) {
2024
- throw new Error("Options databaseURL and apiKey are required");
2481
+ if (!apiKey) {
2482
+ throw new Error("Option apiKey is required");
2025
2483
  }
2026
- return { fetch, databaseURL, apiKey, branch, cache };
2027
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
2028
- fetch,
2029
- apiKey,
2030
- databaseURL,
2031
- branch
2032
- }) {
2484
+ if (!databaseURL) {
2485
+ throw new Error("Option databaseURL is required");
2486
+ }
2487
+ return { fetch, databaseURL, apiKey, branch, cache, trace };
2488
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
2033
2489
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2034
2490
  if (!branchValue)
2035
2491
  throw new Error("Unable to resolve branch value");
@@ -2039,9 +2495,10 @@ const buildClient = (plugins) => {
2039
2495
  apiUrl: "",
2040
2496
  workspacesApiUrl: (path, params) => {
2041
2497
  const hasBranch = params.dbBranchName ?? params.branch;
2042
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
2498
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
2043
2499
  return databaseURL + newPath;
2044
- }
2500
+ },
2501
+ trace
2045
2502
  };
2046
2503
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2047
2504
  if (__privateGet(this, _branch))
@@ -2064,6 +2521,88 @@ const buildClient = (plugins) => {
2064
2521
  class BaseClient extends buildClient() {
2065
2522
  }
2066
2523
 
2524
+ const META = "__";
2525
+ const VALUE = "___";
2526
+ class Serializer {
2527
+ constructor() {
2528
+ this.classes = {};
2529
+ }
2530
+ add(clazz) {
2531
+ this.classes[clazz.name] = clazz;
2532
+ }
2533
+ toJSON(data) {
2534
+ function visit(obj) {
2535
+ if (Array.isArray(obj))
2536
+ return obj.map(visit);
2537
+ const type = typeof obj;
2538
+ if (type === "undefined")
2539
+ return { [META]: "undefined" };
2540
+ if (type === "bigint")
2541
+ return { [META]: "bigint", [VALUE]: obj.toString() };
2542
+ if (obj === null || type !== "object")
2543
+ return obj;
2544
+ const constructor = obj.constructor;
2545
+ const o = { [META]: constructor.name };
2546
+ for (const [key, value] of Object.entries(obj)) {
2547
+ o[key] = visit(value);
2548
+ }
2549
+ if (constructor === Date)
2550
+ o[VALUE] = obj.toISOString();
2551
+ if (constructor === Map)
2552
+ o[VALUE] = Object.fromEntries(obj);
2553
+ if (constructor === Set)
2554
+ o[VALUE] = [...obj];
2555
+ return o;
2556
+ }
2557
+ return JSON.stringify(visit(data));
2558
+ }
2559
+ fromJSON(json) {
2560
+ return JSON.parse(json, (key, value) => {
2561
+ if (value && typeof value === "object" && !Array.isArray(value)) {
2562
+ const { [META]: clazz, [VALUE]: val, ...rest } = value;
2563
+ const constructor = this.classes[clazz];
2564
+ if (constructor) {
2565
+ return Object.assign(Object.create(constructor.prototype), rest);
2566
+ }
2567
+ if (clazz === "Date")
2568
+ return new Date(val);
2569
+ if (clazz === "Set")
2570
+ return new Set(val);
2571
+ if (clazz === "Map")
2572
+ return new Map(Object.entries(val));
2573
+ if (clazz === "bigint")
2574
+ return BigInt(val);
2575
+ if (clazz === "undefined")
2576
+ return void 0;
2577
+ return rest;
2578
+ }
2579
+ return value;
2580
+ });
2581
+ }
2582
+ }
2583
+ const defaultSerializer = new Serializer();
2584
+ const serialize = (data) => {
2585
+ return defaultSerializer.toJSON(data);
2586
+ };
2587
+ const deserialize = (json) => {
2588
+ return defaultSerializer.fromJSON(json);
2589
+ };
2590
+
2591
+ function buildWorkerRunner(config) {
2592
+ return function xataWorker(name, _worker) {
2593
+ return async (...args) => {
2594
+ const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
2595
+ const result = await fetch(url, {
2596
+ method: "POST",
2597
+ headers: { "Content-Type": "application/json" },
2598
+ body: serialize({ args })
2599
+ });
2600
+ const text = await result.text();
2601
+ return deserialize(text);
2602
+ };
2603
+ };
2604
+ }
2605
+
2067
2606
  class XataError extends Error {
2068
2607
  constructor(message, status) {
2069
2608
  super(message);
@@ -2071,5 +2610,5 @@ class XataError extends Error {
2071
2610
  }
2072
2611
  }
2073
2612
 
2074
- 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, updateWorkspaceMemberRole, upsertRecordWithID };
2613
+ 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, cPcreateDatabase, cPdeleteDatabase, cPgetCPDatabaseMetadata, cPgetDatabaseList, cPupdateCPDatabaseMetadata, 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, listMigrationRequestsCommits, lt, lte, mergeMigrationRequest, notExists, operationsByTag, 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 };
2075
2614
  //# sourceMappingURL=index.mjs.map