@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.cjs CHANGED
@@ -2,6 +2,46 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ function _interopNamespace(e) {
6
+ if (e && e.__esModule) return e;
7
+ var n = Object.create(null);
8
+ if (e) {
9
+ Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default') {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n["default"] = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ const defaultTrace = async (_name, fn, _options) => {
24
+ return await fn({
25
+ setAttributes: () => {
26
+ return;
27
+ }
28
+ });
29
+ };
30
+ const TraceAttributes = {
31
+ KIND: "xata.trace.kind",
32
+ VERSION: "xata.sdk.version",
33
+ TABLE: "xata.table",
34
+ HTTP_REQUEST_ID: "http.request_id",
35
+ HTTP_STATUS_CODE: "http.status_code",
36
+ HTTP_HOST: "http.host",
37
+ HTTP_SCHEME: "http.scheme",
38
+ HTTP_USER_AGENT: "http.user_agent",
39
+ HTTP_METHOD: "http.method",
40
+ HTTP_URL: "http.url",
41
+ HTTP_ROUTE: "http.route",
42
+ HTTP_TARGET: "http.target"
43
+ };
44
+
5
45
  function notEmpty(value) {
6
46
  return value !== null && value !== void 0;
7
47
  }
@@ -17,6 +57,9 @@ function isDefined(value) {
17
57
  function isString(value) {
18
58
  return isDefined(value) && typeof value === "string";
19
59
  }
60
+ function isStringArray(value) {
61
+ return isDefined(value) && Array.isArray(value) && value.every(isString);
62
+ }
20
63
  function toBase64(value) {
21
64
  try {
22
65
  return btoa(value);
@@ -32,7 +75,8 @@ function getEnvironment() {
32
75
  return {
33
76
  apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
34
77
  databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
35
- branch: process.env.XATA_BRANCH ?? process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH ?? getGlobalBranch(),
78
+ branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
79
+ envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
36
80
  fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
37
81
  };
38
82
  }
@@ -43,7 +87,8 @@ function getEnvironment() {
43
87
  return {
44
88
  apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
45
89
  databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
46
- branch: Deno.env.get("XATA_BRANCH") ?? Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH") ?? getGlobalBranch(),
90
+ branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
91
+ envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
47
92
  fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
48
93
  };
49
94
  }
@@ -53,6 +98,7 @@ function getEnvironment() {
53
98
  apiKey: getGlobalApiKey(),
54
99
  databaseURL: getGlobalDatabaseURL(),
55
100
  branch: getGlobalBranch(),
101
+ envBranch: void 0,
56
102
  fallbackBranch: getGlobalFallbackBranch()
57
103
  };
58
104
  }
@@ -85,20 +131,21 @@ function getGlobalFallbackBranch() {
85
131
  }
86
132
  }
87
133
  async function getGitBranch() {
134
+ const cmd = ["git", "branch", "--show-current"];
135
+ const fullCmd = cmd.join(" ");
136
+ const nodeModule = ["child", "process"].join("_");
137
+ const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
88
138
  try {
89
139
  if (typeof require === "function") {
90
- const req = require;
91
- return req("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
140
+ return require(nodeModule).execSync(fullCmd, execOptions).trim();
92
141
  }
142
+ const { execSync } = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(nodeModule);
143
+ return execSync(fullCmd, execOptions).toString().trim();
93
144
  } catch (err) {
94
145
  }
95
146
  try {
96
147
  if (isObject(Deno)) {
97
- const process2 = Deno.run({
98
- cmd: ["git", "branch", "--show-current"],
99
- stdout: "piped",
100
- stderr: "piped"
101
- });
148
+ const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
102
149
  return new TextDecoder().decode(await process2.output()).trim();
103
150
  }
104
151
  } catch (err) {
@@ -118,12 +165,14 @@ function getFetchImplementation(userFetch) {
118
165
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
119
166
  const fetchImpl = userFetch ?? globalFetch;
120
167
  if (!fetchImpl) {
121
- throw new Error(`The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`);
168
+ throw new Error(
169
+ `Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
170
+ );
122
171
  }
123
172
  return fetchImpl;
124
173
  }
125
174
 
126
- const VERSION = "0.0.0-alpha.vf0f8e71";
175
+ const VERSION = "0.0.0-alpha.vf1de7db";
127
176
 
128
177
  class ErrorWithCause extends Error {
129
178
  constructor(message, options) {
@@ -174,7 +223,10 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
174
223
  }, {});
175
224
  const query = new URLSearchParams(cleanQueryParams).toString();
176
225
  const queryString = query.length > 0 ? `?${query}` : "";
177
- return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
226
+ const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
227
+ return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
228
+ }, {});
229
+ return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
178
230
  };
179
231
  function buildBaseUrl({
180
232
  path,
@@ -182,10 +234,10 @@ function buildBaseUrl({
182
234
  apiUrl,
183
235
  pathParams
184
236
  }) {
185
- if (!pathParams?.workspace)
237
+ if (pathParams?.workspace === void 0)
186
238
  return `${apiUrl}${path}`;
187
239
  const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
188
- return url.replace("{workspaceId}", pathParams.workspace);
240
+ return url.replace("{workspaceId}", String(pathParams.workspace));
189
241
  }
190
242
  function hostHeader(url) {
191
243
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
@@ -202,34 +254,61 @@ async function fetch$1({
202
254
  fetchImpl,
203
255
  apiKey,
204
256
  apiUrl,
205
- workspacesApiUrl
257
+ workspacesApiUrl,
258
+ trace
206
259
  }) {
207
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
208
- const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
209
- const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
210
- const response = await fetchImpl(url, {
211
- method: method.toUpperCase(),
212
- body: body ? JSON.stringify(body) : void 0,
213
- headers: {
214
- "Content-Type": "application/json",
215
- "User-Agent": `Xata client-ts/${VERSION}`,
216
- ...headers,
217
- ...hostHeader(fullUrl),
218
- Authorization: `Bearer ${apiKey}`
219
- }
220
- });
221
- if (response.status === 204) {
222
- return {};
223
- }
224
- const requestId = response.headers?.get("x-request-id") ?? void 0;
260
+ return trace(
261
+ `${method.toUpperCase()} ${path}`,
262
+ async ({ setAttributes }) => {
263
+ const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
264
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
265
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
266
+ setAttributes({
267
+ [TraceAttributes.HTTP_URL]: url,
268
+ [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
269
+ });
270
+ const response = await fetchImpl(url, {
271
+ method: method.toUpperCase(),
272
+ body: body ? JSON.stringify(body) : void 0,
273
+ headers: {
274
+ "Content-Type": "application/json",
275
+ "User-Agent": `Xata client-ts/${VERSION}`,
276
+ ...headers,
277
+ ...hostHeader(fullUrl),
278
+ Authorization: `Bearer ${apiKey}`
279
+ }
280
+ });
281
+ if (response.status === 204) {
282
+ return {};
283
+ }
284
+ const { host, protocol } = parseUrl(response.url);
285
+ const requestId = response.headers?.get("x-request-id") ?? void 0;
286
+ setAttributes({
287
+ [TraceAttributes.KIND]: "http",
288
+ [TraceAttributes.HTTP_REQUEST_ID]: requestId,
289
+ [TraceAttributes.HTTP_STATUS_CODE]: response.status,
290
+ [TraceAttributes.HTTP_HOST]: host,
291
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
292
+ });
293
+ try {
294
+ const jsonResponse = await response.json();
295
+ if (response.ok) {
296
+ return jsonResponse;
297
+ }
298
+ throw new FetcherError(response.status, jsonResponse, requestId);
299
+ } catch (error) {
300
+ throw new FetcherError(response.status, error, requestId);
301
+ }
302
+ },
303
+ { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
304
+ );
305
+ }
306
+ function parseUrl(url) {
225
307
  try {
226
- const jsonResponse = await response.json();
227
- if (response.ok) {
228
- return jsonResponse;
229
- }
230
- throw new FetcherError(response.status, jsonResponse, requestId);
308
+ const { host, protocol } = new URL(url);
309
+ return { host, protocol };
231
310
  } catch (error) {
232
- throw new FetcherError(response.status, error, requestId);
311
+ return {};
233
312
  }
234
313
  }
235
314
 
@@ -288,6 +367,7 @@ const removeWorkspaceMember = (variables) => fetch$1({
288
367
  ...variables
289
368
  });
290
369
  const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
370
+ const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
291
371
  const cancelWorkspaceMemberInvite = (variables) => fetch$1({
292
372
  url: "/workspaces/{workspaceId}/invites/{inviteId}",
293
373
  method: "delete",
@@ -323,6 +403,12 @@ const deleteDatabase = (variables) => fetch$1({
323
403
  method: "delete",
324
404
  ...variables
325
405
  });
406
+ const getDatabaseMetadata = (variables) => fetch$1({
407
+ url: "/dbs/{dbName}/metadata",
408
+ method: "get",
409
+ ...variables
410
+ });
411
+ const updateDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
326
412
  const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
327
413
  const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
328
414
  const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
@@ -331,16 +417,28 @@ const resolveBranch = (variables) => fetch$1({
331
417
  method: "get",
332
418
  ...variables
333
419
  });
334
- const getBranchDetails = (variables) => fetch$1({
335
- url: "/db/{dbBranchName}",
420
+ const queryMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables });
421
+ const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
422
+ const getMigrationRequest = (variables) => fetch$1({
423
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
336
424
  method: "get",
337
425
  ...variables
338
426
  });
339
- const createBranch = (variables) => fetch$1({
427
+ const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
428
+ const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
429
+ const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
430
+ const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
431
+ const mergeMigrationRequest = (variables) => fetch$1({
432
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
433
+ method: "post",
434
+ ...variables
435
+ });
436
+ const getBranchDetails = (variables) => fetch$1({
340
437
  url: "/db/{dbBranchName}",
341
- method: "put",
438
+ method: "get",
342
439
  ...variables
343
440
  });
441
+ const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
344
442
  const deleteBranch = (variables) => fetch$1({
345
443
  url: "/db/{dbBranchName}",
346
444
  method: "delete",
@@ -359,6 +457,16 @@ const getBranchMetadata = (variables) => fetch$1({
359
457
  const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
360
458
  const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
361
459
  const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
460
+ const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
461
+ const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
462
+ const updateBranchSchema = (variables) => fetch$1({
463
+ url: "/db/{dbBranchName}/schema/update",
464
+ method: "post",
465
+ ...variables
466
+ });
467
+ const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
468
+ const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
469
+ const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
362
470
  const getBranchStats = (variables) => fetch$1({
363
471
  url: "/db/{dbBranchName}/stats",
364
472
  method: "get",
@@ -414,11 +522,7 @@ const updateColumn = (variables) => fetch$1({
414
522
  method: "patch",
415
523
  ...variables
416
524
  });
417
- const insertRecord = (variables) => fetch$1({
418
- url: "/db/{dbBranchName}/tables/{tableName}/data",
419
- method: "post",
420
- ...variables
421
- });
525
+ const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
422
526
  const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
423
527
  const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
424
528
  const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
@@ -448,6 +552,26 @@ const searchBranch = (variables) => fetch$1({
448
552
  method: "post",
449
553
  ...variables
450
554
  });
555
+ const summarizeTable = (variables) => fetch$1({
556
+ url: "/db/{dbBranchName}/tables/{tableName}/summarize",
557
+ method: "post",
558
+ ...variables
559
+ });
560
+ const cPgetDatabaseList = (variables) => fetch$1({
561
+ url: "/workspaces/{workspaceId}/dbs",
562
+ method: "get",
563
+ ...variables
564
+ });
565
+ const cPcreateDatabase = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables });
566
+ const cPdeleteDatabase = (variables) => fetch$1({
567
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
568
+ method: "delete",
569
+ ...variables
570
+ });
571
+ const cPgetCPDatabaseMetadata = (variables) => fetch$1(
572
+ { url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "get", ...variables }
573
+ );
574
+ const cPupdateCPDatabaseMetadata = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "patch", ...variables });
451
575
  const operationsByTag = {
452
576
  users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
453
577
  workspaces: {
@@ -460,6 +584,7 @@ const operationsByTag = {
460
584
  updateWorkspaceMemberRole,
461
585
  removeWorkspaceMember,
462
586
  inviteWorkspaceMember,
587
+ updateWorkspaceMemberInvite,
463
588
  cancelWorkspaceMemberInvite,
464
589
  resendWorkspaceMemberInvite,
465
590
  acceptWorkspaceMemberInvite
@@ -468,6 +593,8 @@ const operationsByTag = {
468
593
  getDatabaseList,
469
594
  createDatabase,
470
595
  deleteDatabase,
596
+ getDatabaseMetadata,
597
+ updateDatabaseMetadata,
471
598
  getGitBranchesMapping,
472
599
  addGitBranchesEntry,
473
600
  removeGitBranchesEntry,
@@ -480,10 +607,28 @@ const operationsByTag = {
480
607
  deleteBranch,
481
608
  updateBranchMetadata,
482
609
  getBranchMetadata,
610
+ getBranchStats
611
+ },
612
+ migrationRequests: {
613
+ queryMigrationRequests,
614
+ createMigrationRequest,
615
+ getMigrationRequest,
616
+ updateMigrationRequest,
617
+ listMigrationRequestsCommits,
618
+ compareMigrationRequest,
619
+ getMigrationRequestIsMerged,
620
+ mergeMigrationRequest
621
+ },
622
+ branchSchema: {
483
623
  getBranchMigrationHistory,
484
624
  executeBranchMigrationPlan,
485
625
  getBranchMigrationPlan,
486
- getBranchStats
626
+ compareBranchWithUserSchema,
627
+ compareBranchSchemas,
628
+ updateBranchSchema,
629
+ previewBranchSchemaEdit,
630
+ applyBranchSchemaEdit,
631
+ getBranchSchemaHistory
487
632
  },
488
633
  table: {
489
634
  createTable,
@@ -507,14 +652,22 @@ const operationsByTag = {
507
652
  bulkInsertTableRecords,
508
653
  queryTable,
509
654
  searchTable,
510
- searchBranch
655
+ searchBranch,
656
+ summarizeTable
657
+ },
658
+ databases: {
659
+ cPgetDatabaseList,
660
+ cPcreateDatabase,
661
+ cPdeleteDatabase,
662
+ cPgetCPDatabaseMetadata,
663
+ cPupdateCPDatabaseMetadata
511
664
  }
512
665
  };
513
666
 
514
667
  function getHostUrl(provider, type) {
515
- if (isValidAlias(provider)) {
668
+ if (isHostProviderAlias(provider)) {
516
669
  return providers[provider][type];
517
- } else if (isValidBuilder(provider)) {
670
+ } else if (isHostProviderBuilder(provider)) {
518
671
  return provider[type];
519
672
  }
520
673
  throw new Error("Invalid API provider");
@@ -529,10 +682,10 @@ const providers = {
529
682
  workspaces: "https://{workspaceId}.staging.xatabase.co"
530
683
  }
531
684
  };
532
- function isValidAlias(alias) {
685
+ function isHostProviderAlias(alias) {
533
686
  return isString(alias) && Object.keys(providers).includes(alias);
534
687
  }
535
- function isValidBuilder(builder) {
688
+ function isHostProviderBuilder(builder) {
536
689
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
537
690
  }
538
691
 
@@ -560,7 +713,8 @@ class XataApiClient {
560
713
  __privateAdd$7(this, _extraProps, void 0);
561
714
  __privateAdd$7(this, _namespaces, {});
562
715
  const provider = options.host ?? "production";
563
- const apiKey = options?.apiKey ?? getAPIKey();
716
+ const apiKey = options.apiKey ?? getAPIKey();
717
+ const trace = options.trace ?? defaultTrace;
564
718
  if (!apiKey) {
565
719
  throw new Error("Could not resolve a valid apiKey");
566
720
  }
@@ -568,7 +722,8 @@ class XataApiClient {
568
722
  apiUrl: getHostUrl(provider, "main"),
569
723
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
570
724
  fetchImpl: getFetchImplementation(options.fetch),
571
- apiKey
725
+ apiKey,
726
+ trace
572
727
  });
573
728
  }
574
729
  get user() {
@@ -601,6 +756,16 @@ class XataApiClient {
601
756
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
602
757
  return __privateGet$7(this, _namespaces).records;
603
758
  }
759
+ get migrationRequests() {
760
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
761
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
762
+ return __privateGet$7(this, _namespaces).migrationRequests;
763
+ }
764
+ get branchSchema() {
765
+ if (!__privateGet$7(this, _namespaces).branchSchema)
766
+ __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
767
+ return __privateGet$7(this, _namespaces).branchSchema;
768
+ }
604
769
  }
605
770
  _extraProps = new WeakMap();
606
771
  _namespaces = new WeakMap();
@@ -691,6 +856,13 @@ class WorkspaceApi {
691
856
  ...this.extraProps
692
857
  });
693
858
  }
859
+ updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
860
+ return operationsByTag.workspaces.updateWorkspaceMemberInvite({
861
+ pathParams: { workspaceId, inviteId },
862
+ body: { role },
863
+ ...this.extraProps
864
+ });
865
+ }
694
866
  cancelWorkspaceMemberInvite(workspaceId, inviteId) {
695
867
  return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
696
868
  pathParams: { workspaceId, inviteId },
@@ -733,6 +905,19 @@ class DatabaseApi {
733
905
  ...this.extraProps
734
906
  });
735
907
  }
908
+ getDatabaseMetadata(workspace, dbName) {
909
+ return operationsByTag.database.getDatabaseMetadata({
910
+ pathParams: { workspace, dbName },
911
+ ...this.extraProps
912
+ });
913
+ }
914
+ updateDatabaseMetadata(workspace, dbName, options = {}) {
915
+ return operationsByTag.database.updateDatabaseMetadata({
916
+ pathParams: { workspace, dbName },
917
+ body: options,
918
+ ...this.extraProps
919
+ });
920
+ }
736
921
  getGitBranchesMapping(workspace, dbName) {
737
922
  return operationsByTag.database.getGitBranchesMapping({
738
923
  pathParams: { workspace, dbName },
@@ -804,27 +989,6 @@ class BranchApi {
804
989
  ...this.extraProps
805
990
  });
806
991
  }
807
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
808
- return operationsByTag.branch.getBranchMigrationHistory({
809
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
810
- body: options,
811
- ...this.extraProps
812
- });
813
- }
814
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
815
- return operationsByTag.branch.executeBranchMigrationPlan({
816
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
817
- body: migrationPlan,
818
- ...this.extraProps
819
- });
820
- }
821
- getBranchMigrationPlan(workspace, database, branch, schema) {
822
- return operationsByTag.branch.getBranchMigrationPlan({
823
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
824
- body: schema,
825
- ...this.extraProps
826
- });
827
- }
828
992
  getBranchStats(workspace, database, branch) {
829
993
  return operationsByTag.branch.getBranchStats({
830
994
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
@@ -905,9 +1069,10 @@ class RecordsApi {
905
1069
  constructor(extraProps) {
906
1070
  this.extraProps = extraProps;
907
1071
  }
908
- insertRecord(workspace, database, branch, tableName, record) {
1072
+ insertRecord(workspace, database, branch, tableName, record, options = {}) {
909
1073
  return operationsByTag.records.insertRecord({
910
1074
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1075
+ queryParams: options,
911
1076
  body: record,
912
1077
  ...this.extraProps
913
1078
  });
@@ -936,21 +1101,24 @@ class RecordsApi {
936
1101
  ...this.extraProps
937
1102
  });
938
1103
  }
939
- deleteRecord(workspace, database, branch, tableName, recordId) {
1104
+ deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
940
1105
  return operationsByTag.records.deleteRecord({
941
1106
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1107
+ queryParams: options,
942
1108
  ...this.extraProps
943
1109
  });
944
1110
  }
945
1111
  getRecord(workspace, database, branch, tableName, recordId, options = {}) {
946
1112
  return operationsByTag.records.getRecord({
947
1113
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1114
+ queryParams: options,
948
1115
  ...this.extraProps
949
1116
  });
950
1117
  }
951
- bulkInsertTableRecords(workspace, database, branch, tableName, records) {
1118
+ bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
952
1119
  return operationsByTag.records.bulkInsertTableRecords({
953
1120
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1121
+ queryParams: options,
954
1122
  body: { records },
955
1123
  ...this.extraProps
956
1124
  });
@@ -976,6 +1144,138 @@ class RecordsApi {
976
1144
  ...this.extraProps
977
1145
  });
978
1146
  }
1147
+ summarizeTable(workspace, database, branch, tableName, query) {
1148
+ return operationsByTag.records.summarizeTable({
1149
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1150
+ body: query,
1151
+ ...this.extraProps
1152
+ });
1153
+ }
1154
+ }
1155
+ class MigrationRequestsApi {
1156
+ constructor(extraProps) {
1157
+ this.extraProps = extraProps;
1158
+ }
1159
+ queryMigrationRequests(workspace, database, options = {}) {
1160
+ return operationsByTag.migrationRequests.queryMigrationRequests({
1161
+ pathParams: { workspace, dbName: database },
1162
+ body: options,
1163
+ ...this.extraProps
1164
+ });
1165
+ }
1166
+ createMigrationRequest(workspace, database, options) {
1167
+ return operationsByTag.migrationRequests.createMigrationRequest({
1168
+ pathParams: { workspace, dbName: database },
1169
+ body: options,
1170
+ ...this.extraProps
1171
+ });
1172
+ }
1173
+ getMigrationRequest(workspace, database, migrationRequest) {
1174
+ return operationsByTag.migrationRequests.getMigrationRequest({
1175
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1176
+ ...this.extraProps
1177
+ });
1178
+ }
1179
+ updateMigrationRequest(workspace, database, migrationRequest, options) {
1180
+ return operationsByTag.migrationRequests.updateMigrationRequest({
1181
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1182
+ body: options,
1183
+ ...this.extraProps
1184
+ });
1185
+ }
1186
+ listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1187
+ return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1188
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1189
+ body: options,
1190
+ ...this.extraProps
1191
+ });
1192
+ }
1193
+ compareMigrationRequest(workspace, database, migrationRequest) {
1194
+ return operationsByTag.migrationRequests.compareMigrationRequest({
1195
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1196
+ ...this.extraProps
1197
+ });
1198
+ }
1199
+ getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1200
+ return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1201
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1202
+ ...this.extraProps
1203
+ });
1204
+ }
1205
+ mergeMigrationRequest(workspace, database, migrationRequest) {
1206
+ return operationsByTag.migrationRequests.mergeMigrationRequest({
1207
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1208
+ ...this.extraProps
1209
+ });
1210
+ }
1211
+ }
1212
+ class BranchSchemaApi {
1213
+ constructor(extraProps) {
1214
+ this.extraProps = extraProps;
1215
+ }
1216
+ getBranchMigrationHistory(workspace, database, branch, options = {}) {
1217
+ return operationsByTag.branchSchema.getBranchMigrationHistory({
1218
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1219
+ body: options,
1220
+ ...this.extraProps
1221
+ });
1222
+ }
1223
+ executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1224
+ return operationsByTag.branchSchema.executeBranchMigrationPlan({
1225
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1226
+ body: migrationPlan,
1227
+ ...this.extraProps
1228
+ });
1229
+ }
1230
+ getBranchMigrationPlan(workspace, database, branch, schema) {
1231
+ return operationsByTag.branchSchema.getBranchMigrationPlan({
1232
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1233
+ body: schema,
1234
+ ...this.extraProps
1235
+ });
1236
+ }
1237
+ compareBranchWithUserSchema(workspace, database, branch, schema) {
1238
+ return operationsByTag.branchSchema.compareBranchWithUserSchema({
1239
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1240
+ body: { schema },
1241
+ ...this.extraProps
1242
+ });
1243
+ }
1244
+ compareBranchSchemas(workspace, database, branch, branchName, schema) {
1245
+ return operationsByTag.branchSchema.compareBranchSchemas({
1246
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1247
+ body: { schema },
1248
+ ...this.extraProps
1249
+ });
1250
+ }
1251
+ updateBranchSchema(workspace, database, branch, migration) {
1252
+ return operationsByTag.branchSchema.updateBranchSchema({
1253
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1254
+ body: migration,
1255
+ ...this.extraProps
1256
+ });
1257
+ }
1258
+ previewBranchSchemaEdit(workspace, database, branch, migration) {
1259
+ return operationsByTag.branchSchema.previewBranchSchemaEdit({
1260
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1261
+ body: migration,
1262
+ ...this.extraProps
1263
+ });
1264
+ }
1265
+ applyBranchSchemaEdit(workspace, database, branch, edits) {
1266
+ return operationsByTag.branchSchema.applyBranchSchemaEdit({
1267
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1268
+ body: { edits },
1269
+ ...this.extraProps
1270
+ });
1271
+ }
1272
+ getBranchSchemaHistory(workspace, database, branch, options = {}) {
1273
+ return operationsByTag.branchSchema.getBranchSchemaHistory({
1274
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1275
+ body: options,
1276
+ ...this.extraProps
1277
+ });
1278
+ }
979
1279
  }
980
1280
 
981
1281
  class XataApiPlugin {
@@ -1039,10 +1339,10 @@ function isCursorPaginationOptions(options) {
1039
1339
  return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
1040
1340
  }
1041
1341
  const _RecordArray = class extends Array {
1042
- constructor(page, overrideRecords) {
1043
- super(..._RecordArray.parseConstructorParams(page, overrideRecords));
1342
+ constructor(...args) {
1343
+ super(..._RecordArray.parseConstructorParams(...args));
1044
1344
  __privateAdd$6(this, _page, void 0);
1045
- __privateSet$6(this, _page, page);
1345
+ __privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
1046
1346
  }
1047
1347
  static parseConstructorParams(...args) {
1048
1348
  if (args.length === 1 && typeof args[0] === "number") {
@@ -1054,6 +1354,12 @@ const _RecordArray = class extends Array {
1054
1354
  }
1055
1355
  return new Array(...args);
1056
1356
  }
1357
+ toArray() {
1358
+ return new Array(...this);
1359
+ }
1360
+ map(callbackfn, thisArg) {
1361
+ return this.toArray().map(callbackfn, thisArg);
1362
+ }
1057
1363
  async nextPage(size, offset) {
1058
1364
  const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
1059
1365
  return new _RecordArray(newPage);
@@ -1095,9 +1401,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
1095
1401
  setter ? setter.call(obj, value) : member.set(obj, value);
1096
1402
  return value;
1097
1403
  };
1098
- var _table$1, _repository, _data;
1404
+ var __privateMethod$3 = (obj, member, method) => {
1405
+ __accessCheck$5(obj, member, "access private method");
1406
+ return method;
1407
+ };
1408
+ var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
1099
1409
  const _Query = class {
1100
1410
  constructor(repository, table, data, rawParent) {
1411
+ __privateAdd$5(this, _cleanFilterConstraint);
1101
1412
  __privateAdd$5(this, _table$1, void 0);
1102
1413
  __privateAdd$5(this, _repository, void 0);
1103
1414
  __privateAdd$5(this, _data, { filter: {} });
@@ -1154,21 +1465,29 @@ const _Query = class {
1154
1465
  }
1155
1466
  filter(a, b) {
1156
1467
  if (arguments.length === 1) {
1157
- const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
1468
+ const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
1469
+ [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
1470
+ }));
1158
1471
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1159
1472
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1160
1473
  } else {
1161
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
1474
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
1475
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1162
1476
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1163
1477
  }
1164
1478
  }
1165
- sort(column, direction) {
1479
+ sort(column, direction = "asc") {
1166
1480
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1167
1481
  const sort = [...originalSort, { column, direction }];
1168
1482
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
1169
1483
  }
1170
1484
  select(columns) {
1171
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { columns }, __privateGet$5(this, _data));
1485
+ return new _Query(
1486
+ __privateGet$5(this, _repository),
1487
+ __privateGet$5(this, _table$1),
1488
+ { columns },
1489
+ __privateGet$5(this, _data)
1490
+ );
1172
1491
  }
1173
1492
  getPaginated(options = {}) {
1174
1493
  const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
@@ -1191,11 +1510,20 @@ const _Query = class {
1191
1510
  }
1192
1511
  }
1193
1512
  async getMany(options = {}) {
1194
- const page = await this.getPaginated(options);
1513
+ const { pagination = {}, ...rest } = options;
1514
+ const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
1515
+ const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
1516
+ let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
1517
+ const results = [...page.records];
1518
+ while (page.hasNextPage() && results.length < size) {
1519
+ page = await page.nextPage();
1520
+ results.push(...page.records);
1521
+ }
1195
1522
  if (page.hasNextPage() && options.pagination?.size === void 0) {
1196
1523
  console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
1197
1524
  }
1198
- return page.records;
1525
+ const array = new RecordArray(page, results.slice(0, size));
1526
+ return array;
1199
1527
  }
1200
1528
  async getAll(options = {}) {
1201
1529
  const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
@@ -1209,6 +1537,12 @@ const _Query = class {
1209
1537
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
1210
1538
  return records[0] ?? null;
1211
1539
  }
1540
+ async getFirstOrThrow(options = {}) {
1541
+ const records = await this.getMany({ ...options, pagination: { size: 1 } });
1542
+ if (records[0] === void 0)
1543
+ throw new Error("No results found.");
1544
+ return records[0];
1545
+ }
1212
1546
  cache(ttl) {
1213
1547
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1214
1548
  }
@@ -1232,6 +1566,17 @@ let Query = _Query;
1232
1566
  _table$1 = new WeakMap();
1233
1567
  _repository = new WeakMap();
1234
1568
  _data = new WeakMap();
1569
+ _cleanFilterConstraint = new WeakSet();
1570
+ cleanFilterConstraint_fn = function(column, value) {
1571
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
1572
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
1573
+ return { $includes: value };
1574
+ }
1575
+ if (columnType === "link" && isObject(value) && isString(value.id)) {
1576
+ return value.id;
1577
+ }
1578
+ return value;
1579
+ };
1235
1580
  function cleanParent(data, parent) {
1236
1581
  if (isCursorPaginationOptions(data.pagination)) {
1237
1582
  return { ...parent, sorting: void 0, filter: void 0 };
@@ -1293,203 +1638,286 @@ var __privateMethod$2 = (obj, member, method) => {
1293
1638
  __accessCheck$4(obj, member, "access private method");
1294
1639
  return method;
1295
1640
  };
1296
- 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;
1641
+ 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;
1297
1642
  class Repository extends Query {
1298
1643
  }
1299
1644
  class RestRepository extends Query {
1300
1645
  constructor(options) {
1301
- super(null, options.table, {});
1646
+ super(
1647
+ null,
1648
+ { name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
1649
+ {}
1650
+ );
1302
1651
  __privateAdd$4(this, _insertRecordWithoutId);
1303
1652
  __privateAdd$4(this, _insertRecordWithId);
1304
1653
  __privateAdd$4(this, _bulkInsertTableRecords);
1305
1654
  __privateAdd$4(this, _updateRecordWithID);
1306
1655
  __privateAdd$4(this, _upsertRecordWithID);
1307
1656
  __privateAdd$4(this, _deleteRecord);
1308
- __privateAdd$4(this, _invalidateCache);
1309
- __privateAdd$4(this, _setCacheRecord);
1310
- __privateAdd$4(this, _getCacheRecord);
1311
1657
  __privateAdd$4(this, _setCacheQuery);
1312
1658
  __privateAdd$4(this, _getCacheQuery);
1313
1659
  __privateAdd$4(this, _getSchemaTables$1);
1314
1660
  __privateAdd$4(this, _table, void 0);
1315
1661
  __privateAdd$4(this, _getFetchProps, void 0);
1662
+ __privateAdd$4(this, _db, void 0);
1316
1663
  __privateAdd$4(this, _cache, void 0);
1317
1664
  __privateAdd$4(this, _schemaTables$2, void 0);
1665
+ __privateAdd$4(this, _trace, void 0);
1318
1666
  __privateSet$4(this, _table, options.table);
1319
1667
  __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1320
- this.db = options.db;
1668
+ __privateSet$4(this, _db, options.db);
1321
1669
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1322
1670
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
1671
+ const trace = options.pluginOptions.trace ?? defaultTrace;
1672
+ __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
1673
+ return trace(name, fn, {
1674
+ ...options2,
1675
+ [TraceAttributes.TABLE]: __privateGet$4(this, _table),
1676
+ [TraceAttributes.KIND]: "sdk-operation",
1677
+ [TraceAttributes.VERSION]: VERSION
1678
+ });
1679
+ });
1323
1680
  }
1324
- async create(a, b) {
1325
- if (Array.isArray(a)) {
1326
- if (a.length === 0)
1327
- return [];
1328
- const records = await __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a);
1329
- await Promise.all(records.map((record) => __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record)));
1330
- return records;
1331
- }
1332
- if (isString(a) && isObject(b)) {
1333
- if (a === "")
1334
- throw new Error("The id can't be empty");
1335
- const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b);
1336
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1337
- return record;
1338
- }
1339
- if (isObject(a) && isString(a.id)) {
1340
- if (a.id === "")
1341
- throw new Error("The id can't be empty");
1342
- const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 });
1343
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1344
- return record;
1345
- }
1346
- if (isObject(a)) {
1347
- const record = await __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a);
1348
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1349
- return record;
1350
- }
1351
- throw new Error("Invalid arguments for create method");
1352
- }
1353
- async read(a) {
1354
- if (Array.isArray(a)) {
1355
- if (a.length === 0)
1356
- return [];
1357
- const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
1358
- return this.getAll({ filter: { id: { $any: ids } } });
1359
- }
1360
- const id = isString(a) ? a : a.id;
1361
- if (isString(id)) {
1362
- const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, id);
1363
- if (cacheRecord)
1364
- return cacheRecord;
1365
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1366
- try {
1367
- const response = await getRecord({
1368
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: id },
1369
- ...fetchProps
1370
- });
1371
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1372
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1373
- } catch (e) {
1374
- if (isObject(e) && e.status === 404) {
1375
- return null;
1681
+ async create(a, b, c) {
1682
+ return __privateGet$4(this, _trace).call(this, "create", async () => {
1683
+ if (Array.isArray(a)) {
1684
+ if (a.length === 0)
1685
+ return [];
1686
+ const columns = isStringArray(b) ? b : void 0;
1687
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
1688
+ }
1689
+ if (isString(a) && isObject(b)) {
1690
+ if (a === "")
1691
+ throw new Error("The id can't be empty");
1692
+ const columns = isStringArray(c) ? c : void 0;
1693
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
1694
+ }
1695
+ if (isObject(a) && isString(a.id)) {
1696
+ if (a.id === "")
1697
+ throw new Error("The id can't be empty");
1698
+ const columns = isStringArray(b) ? b : void 0;
1699
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1700
+ }
1701
+ if (isObject(a)) {
1702
+ const columns = isStringArray(b) ? b : void 0;
1703
+ return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
1704
+ }
1705
+ throw new Error("Invalid arguments for create method");
1706
+ });
1707
+ }
1708
+ async read(a, b) {
1709
+ return __privateGet$4(this, _trace).call(this, "read", async () => {
1710
+ const columns = isStringArray(b) ? b : ["*"];
1711
+ if (Array.isArray(a)) {
1712
+ if (a.length === 0)
1713
+ return [];
1714
+ const ids = a.map((item) => extractId(item));
1715
+ const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
1716
+ const dictionary = finalObjects.reduce((acc, object) => {
1717
+ acc[object.id] = object;
1718
+ return acc;
1719
+ }, {});
1720
+ return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
1721
+ }
1722
+ const id = extractId(a);
1723
+ if (id) {
1724
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1725
+ try {
1726
+ const response = await getRecord({
1727
+ pathParams: {
1728
+ workspace: "{workspaceId}",
1729
+ dbBranchName: "{dbBranch}",
1730
+ tableName: __privateGet$4(this, _table),
1731
+ recordId: id
1732
+ },
1733
+ queryParams: { columns },
1734
+ ...fetchProps
1735
+ });
1736
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1737
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1738
+ } catch (e) {
1739
+ if (isObject(e) && e.status === 404) {
1740
+ return null;
1741
+ }
1742
+ throw e;
1376
1743
  }
1377
- throw e;
1378
1744
  }
1379
- }
1745
+ return null;
1746
+ });
1380
1747
  }
1381
- async update(a, b) {
1382
- if (Array.isArray(a)) {
1383
- if (a.length === 0)
1384
- return [];
1385
- if (a.length > 100) {
1386
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1748
+ async readOrThrow(a, b) {
1749
+ return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
1750
+ const result = await this.read(a, b);
1751
+ if (Array.isArray(result)) {
1752
+ const missingIds = compact(
1753
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1754
+ );
1755
+ if (missingIds.length > 0) {
1756
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1757
+ }
1758
+ return result;
1387
1759
  }
1388
- return Promise.all(a.map((object) => this.update(object)));
1389
- }
1390
- if (isString(a) && isObject(b)) {
1391
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1392
- const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b);
1393
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1394
- return record;
1395
- }
1396
- if (isObject(a) && isString(a.id)) {
1397
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1398
- const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1399
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1400
- return record;
1401
- }
1402
- throw new Error("Invalid arguments for update method");
1403
- }
1404
- async createOrUpdate(a, b) {
1405
- if (Array.isArray(a)) {
1406
- if (a.length === 0)
1407
- return [];
1408
- if (a.length > 100) {
1409
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1760
+ if (result === null) {
1761
+ const id = extractId(a) ?? "unknown";
1762
+ throw new Error(`Record with id ${id} not found`);
1410
1763
  }
1411
- return Promise.all(a.map((object) => this.createOrUpdate(object)));
1412
- }
1413
- if (isString(a) && isObject(b)) {
1414
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1415
- const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b);
1416
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1417
- return record;
1418
- }
1419
- if (isObject(a) && isString(a.id)) {
1420
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1421
- const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1422
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1423
- return record;
1424
- }
1425
- throw new Error("Invalid arguments for createOrUpdate method");
1426
- }
1427
- async delete(a) {
1428
- if (Array.isArray(a)) {
1429
- if (a.length === 0)
1430
- return;
1431
- if (a.length > 100) {
1432
- console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1764
+ return result;
1765
+ });
1766
+ }
1767
+ async update(a, b, c) {
1768
+ return __privateGet$4(this, _trace).call(this, "update", async () => {
1769
+ if (Array.isArray(a)) {
1770
+ if (a.length === 0)
1771
+ return [];
1772
+ if (a.length > 100) {
1773
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1774
+ }
1775
+ const columns = isStringArray(b) ? b : ["*"];
1776
+ return Promise.all(a.map((object) => this.update(object, columns)));
1433
1777
  }
1434
- await Promise.all(a.map((id) => this.delete(id)));
1435
- return;
1436
- }
1437
- if (isString(a)) {
1438
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
1439
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1440
- return;
1441
- }
1442
- if (isObject(a) && isString(a.id)) {
1443
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
1444
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1445
- return;
1446
- }
1447
- throw new Error("Invalid arguments for delete method");
1778
+ if (isString(a) && isObject(b)) {
1779
+ const columns = isStringArray(c) ? c : void 0;
1780
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
1781
+ }
1782
+ if (isObject(a) && isString(a.id)) {
1783
+ const columns = isStringArray(b) ? b : void 0;
1784
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1785
+ }
1786
+ throw new Error("Invalid arguments for update method");
1787
+ });
1788
+ }
1789
+ async updateOrThrow(a, b, c) {
1790
+ return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1791
+ const result = await this.update(a, b, c);
1792
+ if (Array.isArray(result)) {
1793
+ const missingIds = compact(
1794
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1795
+ );
1796
+ if (missingIds.length > 0) {
1797
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1798
+ }
1799
+ return result;
1800
+ }
1801
+ if (result === null) {
1802
+ const id = extractId(a) ?? "unknown";
1803
+ throw new Error(`Record with id ${id} not found`);
1804
+ }
1805
+ return result;
1806
+ });
1807
+ }
1808
+ async createOrUpdate(a, b, c) {
1809
+ return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
1810
+ if (Array.isArray(a)) {
1811
+ if (a.length === 0)
1812
+ return [];
1813
+ if (a.length > 100) {
1814
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1815
+ }
1816
+ const columns = isStringArray(b) ? b : ["*"];
1817
+ return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
1818
+ }
1819
+ if (isString(a) && isObject(b)) {
1820
+ const columns = isStringArray(c) ? c : void 0;
1821
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
1822
+ }
1823
+ if (isObject(a) && isString(a.id)) {
1824
+ const columns = isStringArray(c) ? c : void 0;
1825
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1826
+ }
1827
+ throw new Error("Invalid arguments for createOrUpdate method");
1828
+ });
1829
+ }
1830
+ async delete(a, b) {
1831
+ return __privateGet$4(this, _trace).call(this, "delete", async () => {
1832
+ if (Array.isArray(a)) {
1833
+ if (a.length === 0)
1834
+ return [];
1835
+ if (a.length > 100) {
1836
+ console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1837
+ }
1838
+ return Promise.all(a.map((id) => this.delete(id, b)));
1839
+ }
1840
+ if (isString(a)) {
1841
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
1842
+ }
1843
+ if (isObject(a) && isString(a.id)) {
1844
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
1845
+ }
1846
+ throw new Error("Invalid arguments for delete method");
1847
+ });
1848
+ }
1849
+ async deleteOrThrow(a, b) {
1850
+ return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
1851
+ const result = await this.delete(a, b);
1852
+ if (Array.isArray(result)) {
1853
+ const missingIds = compact(
1854
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1855
+ );
1856
+ if (missingIds.length > 0) {
1857
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1858
+ }
1859
+ return result;
1860
+ } else if (result === null) {
1861
+ const id = extractId(a) ?? "unknown";
1862
+ throw new Error(`Record with id ${id} not found`);
1863
+ }
1864
+ return result;
1865
+ });
1448
1866
  }
1449
1867
  async search(query, options = {}) {
1450
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1451
- const { records } = await searchTable({
1452
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1453
- body: {
1454
- query,
1455
- fuzziness: options.fuzziness,
1456
- highlight: options.highlight,
1457
- filter: options.filter
1458
- },
1459
- ...fetchProps
1868
+ return __privateGet$4(this, _trace).call(this, "search", async () => {
1869
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1870
+ const { records } = await searchTable({
1871
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1872
+ body: {
1873
+ query,
1874
+ fuzziness: options.fuzziness,
1875
+ prefix: options.prefix,
1876
+ highlight: options.highlight,
1877
+ filter: options.filter,
1878
+ boosters: options.boosters
1879
+ },
1880
+ ...fetchProps
1881
+ });
1882
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1883
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
1460
1884
  });
1461
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1462
- return records.map((item) => initObject(this.db, schemaTables, __privateGet$4(this, _table), item));
1463
1885
  }
1464
1886
  async query(query) {
1465
- const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1466
- if (cacheQuery)
1467
- return new Page(query, cacheQuery.meta, cacheQuery.records);
1468
- const data = query.getQueryOptions();
1469
- const body = {
1470
- filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1471
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1472
- page: data.pagination,
1473
- columns: data.columns
1474
- };
1475
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1476
- const { meta, records: objects } = await queryTable({
1477
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1478
- body,
1479
- ...fetchProps
1887
+ return __privateGet$4(this, _trace).call(this, "query", async () => {
1888
+ const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1889
+ if (cacheQuery)
1890
+ return new Page(query, cacheQuery.meta, cacheQuery.records);
1891
+ const data = query.getQueryOptions();
1892
+ const body = {
1893
+ filter: cleanFilter(data.filter),
1894
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1895
+ page: data.pagination,
1896
+ columns: data.columns
1897
+ };
1898
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1899
+ const { meta, records: objects } = await queryTable({
1900
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1901
+ body,
1902
+ ...fetchProps
1903
+ });
1904
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1905
+ const records = objects.map(
1906
+ (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
1907
+ );
1908
+ await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1909
+ return new Page(query, meta, records);
1480
1910
  });
1481
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1482
- const records = objects.map((record) => initObject(this.db, schemaTables, __privateGet$4(this, _table), record));
1483
- await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1484
- return new Page(query, meta, records);
1485
1911
  }
1486
1912
  }
1487
1913
  _table = new WeakMap();
1488
1914
  _getFetchProps = new WeakMap();
1915
+ _db = new WeakMap();
1489
1916
  _cache = new WeakMap();
1490
1917
  _schemaTables$2 = new WeakMap();
1918
+ _trace = new WeakMap();
1491
1919
  _insertRecordWithoutId = new WeakSet();
1492
- insertRecordWithoutId_fn = async function(object) {
1920
+ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1493
1921
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1494
1922
  const record = transformObjectLinks(object);
1495
1923
  const response = await insertRecord({
@@ -1498,17 +1926,15 @@ insertRecordWithoutId_fn = async function(object) {
1498
1926
  dbBranchName: "{dbBranch}",
1499
1927
  tableName: __privateGet$4(this, _table)
1500
1928
  },
1929
+ queryParams: { columns },
1501
1930
  body: record,
1502
1931
  ...fetchProps
1503
1932
  });
1504
- const finalObject = await this.read(response.id);
1505
- if (!finalObject) {
1506
- throw new Error("The server failed to save the record");
1507
- }
1508
- return finalObject;
1933
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1934
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1509
1935
  };
1510
1936
  _insertRecordWithId = new WeakSet();
1511
- insertRecordWithId_fn = async function(recordId, object) {
1937
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
1512
1938
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1513
1939
  const record = transformObjectLinks(object);
1514
1940
  const response = await insertRecordWithID({
@@ -1519,92 +1945,78 @@ insertRecordWithId_fn = async function(recordId, object) {
1519
1945
  recordId
1520
1946
  },
1521
1947
  body: record,
1522
- queryParams: { createOnly: true },
1948
+ queryParams: { createOnly: true, columns },
1523
1949
  ...fetchProps
1524
1950
  });
1525
- const finalObject = await this.read(response.id);
1526
- if (!finalObject) {
1527
- throw new Error("The server failed to save the record");
1528
- }
1529
- return finalObject;
1951
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1952
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1530
1953
  };
1531
1954
  _bulkInsertTableRecords = new WeakSet();
1532
- bulkInsertTableRecords_fn = async function(objects) {
1955
+ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1533
1956
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1534
1957
  const records = objects.map((object) => transformObjectLinks(object));
1535
- const { recordIDs } = await bulkInsertTableRecords({
1958
+ const response = await bulkInsertTableRecords({
1536
1959
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1960
+ queryParams: { columns },
1537
1961
  body: { records },
1538
1962
  ...fetchProps
1539
1963
  });
1540
- const finalObjects = await this.read(recordIDs);
1541
- if (finalObjects.length !== objects.length) {
1542
- throw new Error("The server failed to save some records");
1964
+ if (!isResponseWithRecords(response)) {
1965
+ throw new Error("Request included columns but server didn't include them");
1543
1966
  }
1544
- const dictionary = finalObjects.reduce((acc, object) => {
1545
- acc[object.id] = object;
1546
- return acc;
1547
- }, {});
1548
- return recordIDs.map((id) => dictionary[id]);
1967
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1968
+ return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
1549
1969
  };
1550
1970
  _updateRecordWithID = new WeakSet();
1551
- updateRecordWithID_fn = async function(recordId, object) {
1971
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1552
1972
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1553
1973
  const record = transformObjectLinks(object);
1554
- const response = await updateRecordWithID({
1555
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1556
- body: record,
1557
- ...fetchProps
1558
- });
1559
- const item = await this.read(response.id);
1560
- if (!item)
1561
- throw new Error("The server failed to save the record");
1562
- return item;
1974
+ try {
1975
+ const response = await updateRecordWithID({
1976
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1977
+ queryParams: { columns },
1978
+ body: record,
1979
+ ...fetchProps
1980
+ });
1981
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1982
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1983
+ } catch (e) {
1984
+ if (isObject(e) && e.status === 404) {
1985
+ return null;
1986
+ }
1987
+ throw e;
1988
+ }
1563
1989
  };
1564
1990
  _upsertRecordWithID = new WeakSet();
1565
- upsertRecordWithID_fn = async function(recordId, object) {
1991
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1566
1992
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1567
1993
  const response = await upsertRecordWithID({
1568
1994
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1995
+ queryParams: { columns },
1569
1996
  body: object,
1570
1997
  ...fetchProps
1571
1998
  });
1572
- const item = await this.read(response.id);
1573
- if (!item)
1574
- throw new Error("The server failed to save the record");
1575
- return item;
1999
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2000
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1576
2001
  };
1577
2002
  _deleteRecord = new WeakSet();
1578
- deleteRecord_fn = async function(recordId) {
2003
+ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1579
2004
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1580
- await deleteRecord({
1581
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1582
- ...fetchProps
1583
- });
1584
- };
1585
- _invalidateCache = new WeakSet();
1586
- invalidateCache_fn = async function(recordId) {
1587
- await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1588
- const cacheItems = await __privateGet$4(this, _cache).getAll();
1589
- const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
1590
- for (const [key, value] of queries) {
1591
- const ids = getIds(value);
1592
- if (ids.includes(recordId))
1593
- await __privateGet$4(this, _cache).delete(key);
2005
+ try {
2006
+ const response = await deleteRecord({
2007
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2008
+ queryParams: { columns },
2009
+ ...fetchProps
2010
+ });
2011
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2012
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2013
+ } catch (e) {
2014
+ if (isObject(e) && e.status === 404) {
2015
+ return null;
2016
+ }
2017
+ throw e;
1594
2018
  }
1595
2019
  };
1596
- _setCacheRecord = new WeakSet();
1597
- setCacheRecord_fn = async function(record) {
1598
- if (!__privateGet$4(this, _cache).cacheRecords)
1599
- return;
1600
- await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
1601
- };
1602
- _getCacheRecord = new WeakSet();
1603
- getCacheRecord_fn = async function(recordId) {
1604
- if (!__privateGet$4(this, _cache).cacheRecords)
1605
- return null;
1606
- return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1607
- };
1608
2020
  _setCacheQuery = new WeakSet();
1609
2021
  setCacheQuery_fn = async function(query, meta, records) {
1610
2022
  await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
@@ -1640,7 +2052,7 @@ const transformObjectLinks = (object) => {
1640
2052
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
1641
2053
  }, {});
1642
2054
  };
1643
- const initObject = (db, schemaTables, table, object) => {
2055
+ const initObject = (db, schemaTables, table, object, selectedColumns) => {
1644
2056
  const result = {};
1645
2057
  const { xata, ...rest } = object ?? {};
1646
2058
  Object.assign(result, rest);
@@ -1648,6 +2060,8 @@ const initObject = (db, schemaTables, table, object) => {
1648
2060
  if (!columns)
1649
2061
  console.error(`Table ${table} not found in schema`);
1650
2062
  for (const column of columns ?? []) {
2063
+ if (!isValidColumn(selectedColumns, column))
2064
+ continue;
1651
2065
  const value = result[column.name];
1652
2066
  switch (column.type) {
1653
2067
  case "datetime": {
@@ -1664,17 +2078,35 @@ const initObject = (db, schemaTables, table, object) => {
1664
2078
  if (!linkTable) {
1665
2079
  console.error(`Failed to parse link for field ${column.name}`);
1666
2080
  } else if (isObject(value)) {
1667
- result[column.name] = initObject(db, schemaTables, linkTable, value);
2081
+ const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
2082
+ if (item === column.name) {
2083
+ return [...acc, "*"];
2084
+ }
2085
+ if (item.startsWith(`${column.name}.`)) {
2086
+ const [, ...path] = item.split(".");
2087
+ return [...acc, path.join(".")];
2088
+ }
2089
+ return acc;
2090
+ }, []);
2091
+ result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2092
+ } else {
2093
+ result[column.name] = null;
1668
2094
  }
1669
2095
  break;
1670
2096
  }
2097
+ default:
2098
+ result[column.name] = value ?? null;
2099
+ if (column.notNull === true && value === null) {
2100
+ console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2101
+ }
2102
+ break;
1671
2103
  }
1672
2104
  }
1673
- result.read = function() {
1674
- return db[table].read(result["id"]);
2105
+ result.read = function(columns2) {
2106
+ return db[table].read(result["id"], columns2);
1675
2107
  };
1676
- result.update = function(data) {
1677
- return db[table].update(result["id"], data);
2108
+ result.update = function(data, columns2) {
2109
+ return db[table].update(result["id"], data, columns2);
1678
2110
  };
1679
2111
  result.delete = function() {
1680
2112
  return db[table].delete(result["id"]);
@@ -1688,14 +2120,30 @@ const initObject = (db, schemaTables, table, object) => {
1688
2120
  Object.freeze(result);
1689
2121
  return result;
1690
2122
  };
1691
- function getIds(value) {
1692
- if (Array.isArray(value)) {
1693
- return value.map((item) => getIds(item)).flat();
1694
- }
1695
- if (!isObject(value))
1696
- return [];
1697
- const nestedIds = Object.values(value).map((item) => getIds(item)).flat();
1698
- return isString(value.id) ? [value.id, ...nestedIds] : nestedIds;
2123
+ function isResponseWithRecords(value) {
2124
+ return isObject(value) && Array.isArray(value.records);
2125
+ }
2126
+ function extractId(value) {
2127
+ if (isString(value))
2128
+ return value;
2129
+ if (isObject(value) && isString(value.id))
2130
+ return value.id;
2131
+ return void 0;
2132
+ }
2133
+ function cleanFilter(filter) {
2134
+ if (!filter)
2135
+ return void 0;
2136
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2137
+ return values.length > 0 ? filter : void 0;
2138
+ }
2139
+ function isValidColumn(columns, column) {
2140
+ if (columns.includes("*"))
2141
+ return true;
2142
+ if (column.type === "link") {
2143
+ const linkColumns = columns.filter((item) => item.startsWith(column.name));
2144
+ return linkColumns.length > 0;
2145
+ }
2146
+ return columns.includes(column.name);
1699
2147
  }
1700
2148
 
1701
2149
  var __accessCheck$3 = (obj, member, msg) => {
@@ -1722,7 +2170,6 @@ class SimpleCache {
1722
2170
  __privateAdd$3(this, _map, void 0);
1723
2171
  __privateSet$3(this, _map, /* @__PURE__ */ new Map());
1724
2172
  this.capacity = options.max ?? 500;
1725
- this.cacheRecords = options.cacheRecords ?? true;
1726
2173
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
1727
2174
  }
1728
2175
  async getAll() {
@@ -1748,18 +2195,25 @@ class SimpleCache {
1748
2195
  }
1749
2196
  _map = new WeakMap();
1750
2197
 
1751
- const gt = (value) => ({ $gt: value });
1752
- const ge = (value) => ({ $ge: value });
1753
- const gte = (value) => ({ $ge: value });
1754
- const lt = (value) => ({ $lt: value });
1755
- const lte = (value) => ({ $le: value });
1756
- const le = (value) => ({ $le: value });
2198
+ const greaterThan = (value) => ({ $gt: value });
2199
+ const gt = greaterThan;
2200
+ const greaterThanEquals = (value) => ({ $ge: value });
2201
+ const greaterEquals = greaterThanEquals;
2202
+ const gte = greaterThanEquals;
2203
+ const ge = greaterThanEquals;
2204
+ const lessThan = (value) => ({ $lt: value });
2205
+ const lt = lessThan;
2206
+ const lessThanEquals = (value) => ({ $le: value });
2207
+ const lessEquals = lessThanEquals;
2208
+ const lte = lessThanEquals;
2209
+ const le = lessThanEquals;
1757
2210
  const exists = (column) => ({ $exists: column });
1758
2211
  const notExists = (column) => ({ $notExists: column });
1759
2212
  const startsWith = (value) => ({ $startsWith: value });
1760
2213
  const endsWith = (value) => ({ $endsWith: value });
1761
2214
  const pattern = (value) => ({ $pattern: value });
1762
2215
  const is = (value) => ({ $is: value });
2216
+ const equals = is;
1763
2217
  const isNot = (value) => ({ $isNot: value });
1764
2218
  const contains = (value) => ({ $contains: value });
1765
2219
  const includes = (value) => ({ $includes: value });
@@ -1794,16 +2248,19 @@ class SchemaPlugin extends XataPlugin {
1794
2248
  __privateSet$2(this, _schemaTables$1, schemaTables);
1795
2249
  }
1796
2250
  build(pluginOptions) {
1797
- const db = new Proxy({}, {
1798
- get: (_target, table) => {
1799
- if (!isString(table))
1800
- throw new Error("Invalid table name");
1801
- if (__privateGet$2(this, _tables)[table] === void 0) {
1802
- __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
2251
+ const db = new Proxy(
2252
+ {},
2253
+ {
2254
+ get: (_target, table) => {
2255
+ if (!isString(table))
2256
+ throw new Error("Invalid table name");
2257
+ if (__privateGet$2(this, _tables)[table] === void 0) {
2258
+ __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
2259
+ }
2260
+ return __privateGet$2(this, _tables)[table];
1803
2261
  }
1804
- return __privateGet$2(this, _tables)[table];
1805
2262
  }
1806
- });
2263
+ );
1807
2264
  const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
1808
2265
  for (const table of tableNames) {
1809
2266
  db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
@@ -1853,7 +2310,7 @@ class SearchPlugin extends XataPlugin {
1853
2310
  const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
1854
2311
  return records.map((record) => {
1855
2312
  const { table = "orphan" } = record.xata;
1856
- return { table, record: initObject(this.db, schemaTables, table, record) };
2313
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
1857
2314
  });
1858
2315
  },
1859
2316
  byTable: async (query, options = {}) => {
@@ -1862,7 +2319,7 @@ class SearchPlugin extends XataPlugin {
1862
2319
  return records.reduce((acc, record) => {
1863
2320
  const { table = "orphan" } = record.xata;
1864
2321
  const items = acc[table] ?? [];
1865
- const item = initObject(this.db, schemaTables, table, record);
2322
+ const item = initObject(this.db, schemaTables, table, record, ["*"]);
1866
2323
  return { ...acc, [table]: [...items, item] };
1867
2324
  }, {});
1868
2325
  }
@@ -1873,10 +2330,10 @@ _schemaTables = new WeakMap();
1873
2330
  _search = new WeakSet();
1874
2331
  search_fn = async function(query, options, getFetchProps) {
1875
2332
  const fetchProps = await getFetchProps();
1876
- const { tables, fuzziness, highlight } = options ?? {};
2333
+ const { tables, fuzziness, highlight, prefix } = options ?? {};
1877
2334
  const { records } = await searchBranch({
1878
2335
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1879
- body: { tables, query, fuzziness, highlight },
2336
+ body: { tables, query, fuzziness, prefix, highlight },
1880
2337
  ...fetchProps
1881
2338
  });
1882
2339
  return records;
@@ -1899,14 +2356,14 @@ const isBranchStrategyBuilder = (strategy) => {
1899
2356
  };
1900
2357
 
1901
2358
  async function getCurrentBranchName(options) {
1902
- const { branch } = getEnvironment();
2359
+ const { branch, envBranch } = getEnvironment();
1903
2360
  if (branch) {
1904
2361
  const details = await getDatabaseBranch(branch, options);
1905
2362
  if (details)
1906
2363
  return branch;
1907
2364
  console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
1908
2365
  }
1909
- const gitBranch = await getGitBranch();
2366
+ const gitBranch = envBranch || await getGitBranch();
1910
2367
  return resolveXataBranch(gitBranch, options);
1911
2368
  }
1912
2369
  async function getCurrentBranchDetails(options) {
@@ -1917,9 +2374,13 @@ async function resolveXataBranch(gitBranch, options) {
1917
2374
  const databaseURL = options?.databaseURL || getDatabaseURL();
1918
2375
  const apiKey = options?.apiKey || getAPIKey();
1919
2376
  if (!databaseURL)
1920
- throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
2377
+ throw new Error(
2378
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2379
+ );
1921
2380
  if (!apiKey)
1922
- throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
2381
+ throw new Error(
2382
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2383
+ );
1923
2384
  const [protocol, , host, , dbName] = databaseURL.split("/");
1924
2385
  const [workspace] = host.split(".");
1925
2386
  const { fallbackBranch } = getEnvironment();
@@ -1929,7 +2390,8 @@ async function resolveXataBranch(gitBranch, options) {
1929
2390
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1930
2391
  workspacesApiUrl: `${protocol}//${host}`,
1931
2392
  pathParams: { dbName, workspace },
1932
- queryParams: { gitBranch, fallbackBranch }
2393
+ queryParams: { gitBranch, fallbackBranch },
2394
+ trace: defaultTrace
1933
2395
  });
1934
2396
  return branch;
1935
2397
  }
@@ -1937,9 +2399,13 @@ async function getDatabaseBranch(branch, options) {
1937
2399
  const databaseURL = options?.databaseURL || getDatabaseURL();
1938
2400
  const apiKey = options?.apiKey || getAPIKey();
1939
2401
  if (!databaseURL)
1940
- throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
2402
+ throw new Error(
2403
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2404
+ );
1941
2405
  if (!apiKey)
1942
- throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
2406
+ throw new Error(
2407
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2408
+ );
1943
2409
  const [protocol, , host, , database] = databaseURL.split("/");
1944
2410
  const [workspace] = host.split(".");
1945
2411
  const dbBranchName = `${database}:${branch}`;
@@ -1949,7 +2415,8 @@ async function getDatabaseBranch(branch, options) {
1949
2415
  apiUrl: databaseURL,
1950
2416
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1951
2417
  workspacesApiUrl: `${protocol}//${host}`,
1952
- pathParams: { dbBranchName, workspace }
2418
+ pathParams: { dbBranchName, workspace },
2419
+ trace: defaultTrace
1953
2420
  });
1954
2421
  } catch (err) {
1955
2422
  if (isObject(err) && err.status === 404)
@@ -1989,17 +2456,20 @@ var __privateMethod = (obj, member, method) => {
1989
2456
  return method;
1990
2457
  };
1991
2458
  const buildClient = (plugins) => {
1992
- var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
2459
+ var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
1993
2460
  return _a = class {
1994
2461
  constructor(options = {}, schemaTables) {
1995
2462
  __privateAdd(this, _parseOptions);
1996
2463
  __privateAdd(this, _getFetchProps);
1997
2464
  __privateAdd(this, _evaluateBranch);
1998
2465
  __privateAdd(this, _branch, void 0);
2466
+ __privateAdd(this, _options, void 0);
1999
2467
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
2468
+ __privateSet(this, _options, safeOptions);
2000
2469
  const pluginOptions = {
2001
2470
  getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
2002
- cache: safeOptions.cache
2471
+ cache: safeOptions.cache,
2472
+ trace: safeOptions.trace
2003
2473
  };
2004
2474
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
2005
2475
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
@@ -2018,22 +2488,26 @@ const buildClient = (plugins) => {
2018
2488
  }
2019
2489
  }
2020
2490
  }
2021
- }, _branch = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
2491
+ async getConfig() {
2492
+ const databaseURL = __privateGet(this, _options).databaseURL;
2493
+ const branch = await __privateGet(this, _options).branch();
2494
+ return { databaseURL, branch };
2495
+ }
2496
+ }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
2022
2497
  const fetch = getFetchImplementation(options?.fetch);
2023
2498
  const databaseURL = options?.databaseURL || getDatabaseURL();
2024
2499
  const apiKey = options?.apiKey || getAPIKey();
2025
- const cache = options?.cache ?? new SimpleCache({ cacheRecords: false, defaultQueryTTL: 0 });
2500
+ const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
2501
+ const trace = options?.trace ?? defaultTrace;
2026
2502
  const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
2027
- if (!databaseURL || !apiKey) {
2028
- throw new Error("Options databaseURL and apiKey are required");
2503
+ if (!apiKey) {
2504
+ throw new Error("Option apiKey is required");
2029
2505
  }
2030
- return { fetch, databaseURL, apiKey, branch, cache };
2031
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
2032
- fetch,
2033
- apiKey,
2034
- databaseURL,
2035
- branch
2036
- }) {
2506
+ if (!databaseURL) {
2507
+ throw new Error("Option databaseURL is required");
2508
+ }
2509
+ return { fetch, databaseURL, apiKey, branch, cache, trace };
2510
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
2037
2511
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2038
2512
  if (!branchValue)
2039
2513
  throw new Error("Unable to resolve branch value");
@@ -2043,9 +2517,10 @@ const buildClient = (plugins) => {
2043
2517
  apiUrl: "",
2044
2518
  workspacesApiUrl: (path, params) => {
2045
2519
  const hasBranch = params.dbBranchName ?? params.branch;
2046
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
2520
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
2047
2521
  return databaseURL + newPath;
2048
- }
2522
+ },
2523
+ trace
2049
2524
  };
2050
2525
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2051
2526
  if (__privateGet(this, _branch))
@@ -2068,6 +2543,88 @@ const buildClient = (plugins) => {
2068
2543
  class BaseClient extends buildClient() {
2069
2544
  }
2070
2545
 
2546
+ const META = "__";
2547
+ const VALUE = "___";
2548
+ class Serializer {
2549
+ constructor() {
2550
+ this.classes = {};
2551
+ }
2552
+ add(clazz) {
2553
+ this.classes[clazz.name] = clazz;
2554
+ }
2555
+ toJSON(data) {
2556
+ function visit(obj) {
2557
+ if (Array.isArray(obj))
2558
+ return obj.map(visit);
2559
+ const type = typeof obj;
2560
+ if (type === "undefined")
2561
+ return { [META]: "undefined" };
2562
+ if (type === "bigint")
2563
+ return { [META]: "bigint", [VALUE]: obj.toString() };
2564
+ if (obj === null || type !== "object")
2565
+ return obj;
2566
+ const constructor = obj.constructor;
2567
+ const o = { [META]: constructor.name };
2568
+ for (const [key, value] of Object.entries(obj)) {
2569
+ o[key] = visit(value);
2570
+ }
2571
+ if (constructor === Date)
2572
+ o[VALUE] = obj.toISOString();
2573
+ if (constructor === Map)
2574
+ o[VALUE] = Object.fromEntries(obj);
2575
+ if (constructor === Set)
2576
+ o[VALUE] = [...obj];
2577
+ return o;
2578
+ }
2579
+ return JSON.stringify(visit(data));
2580
+ }
2581
+ fromJSON(json) {
2582
+ return JSON.parse(json, (key, value) => {
2583
+ if (value && typeof value === "object" && !Array.isArray(value)) {
2584
+ const { [META]: clazz, [VALUE]: val, ...rest } = value;
2585
+ const constructor = this.classes[clazz];
2586
+ if (constructor) {
2587
+ return Object.assign(Object.create(constructor.prototype), rest);
2588
+ }
2589
+ if (clazz === "Date")
2590
+ return new Date(val);
2591
+ if (clazz === "Set")
2592
+ return new Set(val);
2593
+ if (clazz === "Map")
2594
+ return new Map(Object.entries(val));
2595
+ if (clazz === "bigint")
2596
+ return BigInt(val);
2597
+ if (clazz === "undefined")
2598
+ return void 0;
2599
+ return rest;
2600
+ }
2601
+ return value;
2602
+ });
2603
+ }
2604
+ }
2605
+ const defaultSerializer = new Serializer();
2606
+ const serialize = (data) => {
2607
+ return defaultSerializer.toJSON(data);
2608
+ };
2609
+ const deserialize = (json) => {
2610
+ return defaultSerializer.fromJSON(json);
2611
+ };
2612
+
2613
+ function buildWorkerRunner(config) {
2614
+ return function xataWorker(name, _worker) {
2615
+ return async (...args) => {
2616
+ const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
2617
+ const result = await fetch(url, {
2618
+ method: "POST",
2619
+ headers: { "Content-Type": "application/json" },
2620
+ body: serialize({ args })
2621
+ });
2622
+ const text = await result.text();
2623
+ return deserialize(text);
2624
+ };
2625
+ };
2626
+ }
2627
+
2071
2628
  class XataError extends Error {
2072
2629
  constructor(message, status) {
2073
2630
  super(message);
@@ -2088,6 +2645,7 @@ exports.Repository = Repository;
2088
2645
  exports.RestRepository = RestRepository;
2089
2646
  exports.SchemaPlugin = SchemaPlugin;
2090
2647
  exports.SearchPlugin = SearchPlugin;
2648
+ exports.Serializer = Serializer;
2091
2649
  exports.SimpleCache = SimpleCache;
2092
2650
  exports.XataApiClient = XataApiClient;
2093
2651
  exports.XataApiPlugin = XataApiPlugin;
@@ -2096,12 +2654,23 @@ exports.XataPlugin = XataPlugin;
2096
2654
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
2097
2655
  exports.addGitBranchesEntry = addGitBranchesEntry;
2098
2656
  exports.addTableColumn = addTableColumn;
2657
+ exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
2099
2658
  exports.buildClient = buildClient;
2659
+ exports.buildWorkerRunner = buildWorkerRunner;
2100
2660
  exports.bulkInsertTableRecords = bulkInsertTableRecords;
2661
+ exports.cPcreateDatabase = cPcreateDatabase;
2662
+ exports.cPdeleteDatabase = cPdeleteDatabase;
2663
+ exports.cPgetCPDatabaseMetadata = cPgetCPDatabaseMetadata;
2664
+ exports.cPgetDatabaseList = cPgetDatabaseList;
2665
+ exports.cPupdateCPDatabaseMetadata = cPupdateCPDatabaseMetadata;
2101
2666
  exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
2667
+ exports.compareBranchSchemas = compareBranchSchemas;
2668
+ exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
2669
+ exports.compareMigrationRequest = compareMigrationRequest;
2102
2670
  exports.contains = contains;
2103
2671
  exports.createBranch = createBranch;
2104
2672
  exports.createDatabase = createDatabase;
2673
+ exports.createMigrationRequest = createMigrationRequest;
2105
2674
  exports.createTable = createTable;
2106
2675
  exports.createUserAPIKey = createUserAPIKey;
2107
2676
  exports.createWorkspace = createWorkspace;
@@ -2113,7 +2682,9 @@ exports.deleteTable = deleteTable;
2113
2682
  exports.deleteUser = deleteUser;
2114
2683
  exports.deleteUserAPIKey = deleteUserAPIKey;
2115
2684
  exports.deleteWorkspace = deleteWorkspace;
2685
+ exports.deserialize = deserialize;
2116
2686
  exports.endsWith = endsWith;
2687
+ exports.equals = equals;
2117
2688
  exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
2118
2689
  exports.exists = exists;
2119
2690
  exports.ge = ge;
@@ -2123,13 +2694,17 @@ exports.getBranchList = getBranchList;
2123
2694
  exports.getBranchMetadata = getBranchMetadata;
2124
2695
  exports.getBranchMigrationHistory = getBranchMigrationHistory;
2125
2696
  exports.getBranchMigrationPlan = getBranchMigrationPlan;
2697
+ exports.getBranchSchemaHistory = getBranchSchemaHistory;
2126
2698
  exports.getBranchStats = getBranchStats;
2127
2699
  exports.getColumn = getColumn;
2128
2700
  exports.getCurrentBranchDetails = getCurrentBranchDetails;
2129
2701
  exports.getCurrentBranchName = getCurrentBranchName;
2130
2702
  exports.getDatabaseList = getDatabaseList;
2703
+ exports.getDatabaseMetadata = getDatabaseMetadata;
2131
2704
  exports.getDatabaseURL = getDatabaseURL;
2132
2705
  exports.getGitBranchesMapping = getGitBranchesMapping;
2706
+ exports.getMigrationRequest = getMigrationRequest;
2707
+ exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
2133
2708
  exports.getRecord = getRecord;
2134
2709
  exports.getTableColumns = getTableColumns;
2135
2710
  exports.getTableSchema = getTableSchema;
@@ -2138,6 +2713,9 @@ exports.getUserAPIKeys = getUserAPIKeys;
2138
2713
  exports.getWorkspace = getWorkspace;
2139
2714
  exports.getWorkspaceMembersList = getWorkspaceMembersList;
2140
2715
  exports.getWorkspacesList = getWorkspacesList;
2716
+ exports.greaterEquals = greaterEquals;
2717
+ exports.greaterThan = greaterThan;
2718
+ exports.greaterThanEquals = greaterThanEquals;
2141
2719
  exports.gt = gt;
2142
2720
  exports.gte = gte;
2143
2721
  exports.includes = includes;
@@ -2153,11 +2731,18 @@ exports.isIdentifiable = isIdentifiable;
2153
2731
  exports.isNot = isNot;
2154
2732
  exports.isXataRecord = isXataRecord;
2155
2733
  exports.le = le;
2734
+ exports.lessEquals = lessEquals;
2735
+ exports.lessThan = lessThan;
2736
+ exports.lessThanEquals = lessThanEquals;
2737
+ exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
2156
2738
  exports.lt = lt;
2157
2739
  exports.lte = lte;
2740
+ exports.mergeMigrationRequest = mergeMigrationRequest;
2158
2741
  exports.notExists = notExists;
2159
2742
  exports.operationsByTag = operationsByTag;
2160
2743
  exports.pattern = pattern;
2744
+ exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
2745
+ exports.queryMigrationRequests = queryMigrationRequests;
2161
2746
  exports.queryTable = queryTable;
2162
2747
  exports.removeGitBranchesEntry = removeGitBranchesEntry;
2163
2748
  exports.removeWorkspaceMember = removeWorkspaceMember;
@@ -2165,14 +2750,20 @@ exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
2165
2750
  exports.resolveBranch = resolveBranch;
2166
2751
  exports.searchBranch = searchBranch;
2167
2752
  exports.searchTable = searchTable;
2753
+ exports.serialize = serialize;
2168
2754
  exports.setTableSchema = setTableSchema;
2169
2755
  exports.startsWith = startsWith;
2756
+ exports.summarizeTable = summarizeTable;
2170
2757
  exports.updateBranchMetadata = updateBranchMetadata;
2758
+ exports.updateBranchSchema = updateBranchSchema;
2171
2759
  exports.updateColumn = updateColumn;
2760
+ exports.updateDatabaseMetadata = updateDatabaseMetadata;
2761
+ exports.updateMigrationRequest = updateMigrationRequest;
2172
2762
  exports.updateRecordWithID = updateRecordWithID;
2173
2763
  exports.updateTable = updateTable;
2174
2764
  exports.updateUser = updateUser;
2175
2765
  exports.updateWorkspace = updateWorkspace;
2766
+ exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
2176
2767
  exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
2177
2768
  exports.upsertRecordWithID = upsertRecordWithID;
2178
2769
  //# sourceMappingURL=index.cjs.map