@xata.io/client 0.0.0-alpha.vfe4ae98 → 0.0.0-alpha.vfe9bed6

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);
@@ -26,35 +69,83 @@ function toBase64(value) {
26
69
  }
27
70
  }
28
71
 
29
- function getEnvVariable(name) {
72
+ function getEnvironment() {
30
73
  try {
31
- if (isObject(process) && isString(process?.env?.[name])) {
32
- return process.env[name];
74
+ if (isObject(process) && isObject(process.env)) {
75
+ return {
76
+ apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
77
+ databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
78
+ branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
79
+ envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
80
+ fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
81
+ };
33
82
  }
34
83
  } catch (err) {
35
84
  }
36
85
  try {
37
- if (isObject(Deno) && isString(Deno?.env?.get(name))) {
38
- return Deno.env.get(name);
86
+ if (isObject(Deno) && isObject(Deno.env)) {
87
+ return {
88
+ apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
89
+ databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
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"),
92
+ fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
93
+ };
39
94
  }
40
95
  } catch (err) {
41
96
  }
97
+ return {
98
+ apiKey: getGlobalApiKey(),
99
+ databaseURL: getGlobalDatabaseURL(),
100
+ branch: getGlobalBranch(),
101
+ envBranch: void 0,
102
+ fallbackBranch: getGlobalFallbackBranch()
103
+ };
104
+ }
105
+ function getGlobalApiKey() {
106
+ try {
107
+ return XATA_API_KEY;
108
+ } catch (err) {
109
+ return void 0;
110
+ }
111
+ }
112
+ function getGlobalDatabaseURL() {
113
+ try {
114
+ return XATA_DATABASE_URL;
115
+ } catch (err) {
116
+ return void 0;
117
+ }
118
+ }
119
+ function getGlobalBranch() {
120
+ try {
121
+ return XATA_BRANCH;
122
+ } catch (err) {
123
+ return void 0;
124
+ }
125
+ }
126
+ function getGlobalFallbackBranch() {
127
+ try {
128
+ return XATA_FALLBACK_BRANCH;
129
+ } catch (err) {
130
+ return void 0;
131
+ }
42
132
  }
43
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"] };
44
138
  try {
45
139
  if (typeof require === "function") {
46
- const req = require;
47
- return req("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
140
+ return require(nodeModule).execSync(fullCmd, execOptions).trim();
48
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();
49
144
  } catch (err) {
50
145
  }
51
146
  try {
52
147
  if (isObject(Deno)) {
53
- const process2 = Deno.run({
54
- cmd: ["git", "branch", "--show-current"],
55
- stdout: "piped",
56
- stderr: "piped"
57
- });
148
+ const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
58
149
  return new TextDecoder().decode(await process2.output()).trim();
59
150
  }
60
151
  } catch (err) {
@@ -63,7 +154,8 @@ async function getGitBranch() {
63
154
 
64
155
  function getAPIKey() {
65
156
  try {
66
- return getEnvVariable("XATA_API_KEY") ?? XATA_API_KEY;
157
+ const { apiKey } = getEnvironment();
158
+ return apiKey;
67
159
  } catch (err) {
68
160
  return void 0;
69
161
  }
@@ -73,12 +165,14 @@ function getFetchImplementation(userFetch) {
73
165
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
74
166
  const fetchImpl = userFetch ?? globalFetch;
75
167
  if (!fetchImpl) {
76
- 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
+ );
77
171
  }
78
172
  return fetchImpl;
79
173
  }
80
174
 
81
- const VERSION = "0.0.0-alpha.vfe4ae98";
175
+ const VERSION = "0.0.0-alpha.vfe9bed6";
82
176
 
83
177
  class ErrorWithCause extends Error {
84
178
  constructor(message, options) {
@@ -129,7 +223,10 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
129
223
  }, {});
130
224
  const query = new URLSearchParams(cleanQueryParams).toString();
131
225
  const queryString = query.length > 0 ? `?${query}` : "";
132
- 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;
133
230
  };
134
231
  function buildBaseUrl({
135
232
  path,
@@ -137,10 +234,10 @@ function buildBaseUrl({
137
234
  apiUrl,
138
235
  pathParams
139
236
  }) {
140
- if (!pathParams?.workspace)
237
+ if (pathParams?.workspace === void 0)
141
238
  return `${apiUrl}${path}`;
142
239
  const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
143
- return url.replace("{workspaceId}", pathParams.workspace);
240
+ return url.replace("{workspaceId}", String(pathParams.workspace));
144
241
  }
145
242
  function hostHeader(url) {
146
243
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
@@ -157,34 +254,61 @@ async function fetch$1({
157
254
  fetchImpl,
158
255
  apiKey,
159
256
  apiUrl,
160
- workspacesApiUrl
257
+ workspacesApiUrl,
258
+ trace
161
259
  }) {
162
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
163
- const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
164
- const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
165
- const response = await fetchImpl(url, {
166
- method: method.toUpperCase(),
167
- body: body ? JSON.stringify(body) : void 0,
168
- headers: {
169
- "Content-Type": "application/json",
170
- "User-Agent": `Xata client-ts/${VERSION}`,
171
- ...headers,
172
- ...hostHeader(fullUrl),
173
- Authorization: `Bearer ${apiKey}`
174
- }
175
- });
176
- if (response.status === 204) {
177
- return {};
178
- }
179
- 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) {
180
307
  try {
181
- const jsonResponse = await response.json();
182
- if (response.ok) {
183
- return jsonResponse;
184
- }
185
- throw new FetcherError(response.status, jsonResponse, requestId);
308
+ const { host, protocol } = new URL(url);
309
+ return { host, protocol };
186
310
  } catch (error) {
187
- throw new FetcherError(response.status, error, requestId);
311
+ return {};
188
312
  }
189
313
  }
190
314
 
@@ -243,6 +367,7 @@ const removeWorkspaceMember = (variables) => fetch$1({
243
367
  ...variables
244
368
  });
245
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 });
246
371
  const cancelWorkspaceMemberInvite = (variables) => fetch$1({
247
372
  url: "/workspaces/{workspaceId}/invites/{inviteId}",
248
373
  method: "delete",
@@ -278,6 +403,12 @@ const deleteDatabase = (variables) => fetch$1({
278
403
  method: "delete",
279
404
  ...variables
280
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 });
281
412
  const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
282
413
  const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
283
414
  const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
@@ -286,16 +417,28 @@ const resolveBranch = (variables) => fetch$1({
286
417
  method: "get",
287
418
  ...variables
288
419
  });
289
- const getBranchDetails = (variables) => fetch$1({
290
- url: "/db/{dbBranchName}",
420
+ const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", 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}",
291
424
  method: "get",
292
425
  ...variables
293
426
  });
294
- 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({
295
437
  url: "/db/{dbBranchName}",
296
- method: "put",
438
+ method: "get",
297
439
  ...variables
298
440
  });
441
+ const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
299
442
  const deleteBranch = (variables) => fetch$1({
300
443
  url: "/db/{dbBranchName}",
301
444
  method: "delete",
@@ -314,6 +457,16 @@ const getBranchMetadata = (variables) => fetch$1({
314
457
  const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
315
458
  const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
316
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 });
317
470
  const getBranchStats = (variables) => fetch$1({
318
471
  url: "/db/{dbBranchName}/stats",
319
472
  method: "get",
@@ -369,11 +522,7 @@ const updateColumn = (variables) => fetch$1({
369
522
  method: "patch",
370
523
  ...variables
371
524
  });
372
- const insertRecord = (variables) => fetch$1({
373
- url: "/db/{dbBranchName}/tables/{tableName}/data",
374
- method: "post",
375
- ...variables
376
- });
525
+ const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
377
526
  const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
378
527
  const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
379
528
  const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
@@ -403,6 +552,11 @@ const searchBranch = (variables) => fetch$1({
403
552
  method: "post",
404
553
  ...variables
405
554
  });
555
+ const summarizeTable = (variables) => fetch$1({
556
+ url: "/db/{dbBranchName}/tables/{tableName}/summarize",
557
+ method: "post",
558
+ ...variables
559
+ });
406
560
  const operationsByTag = {
407
561
  users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
408
562
  workspaces: {
@@ -415,6 +569,7 @@ const operationsByTag = {
415
569
  updateWorkspaceMemberRole,
416
570
  removeWorkspaceMember,
417
571
  inviteWorkspaceMember,
572
+ updateWorkspaceMemberInvite,
418
573
  cancelWorkspaceMemberInvite,
419
574
  resendWorkspaceMemberInvite,
420
575
  acceptWorkspaceMemberInvite
@@ -423,6 +578,8 @@ const operationsByTag = {
423
578
  getDatabaseList,
424
579
  createDatabase,
425
580
  deleteDatabase,
581
+ getDatabaseMetadata,
582
+ updateDatabaseMetadata,
426
583
  getGitBranchesMapping,
427
584
  addGitBranchesEntry,
428
585
  removeGitBranchesEntry,
@@ -435,10 +592,28 @@ const operationsByTag = {
435
592
  deleteBranch,
436
593
  updateBranchMetadata,
437
594
  getBranchMetadata,
595
+ getBranchStats
596
+ },
597
+ migrationRequests: {
598
+ listMigrationRequests,
599
+ createMigrationRequest,
600
+ getMigrationRequest,
601
+ updateMigrationRequest,
602
+ listMigrationRequestsCommits,
603
+ compareMigrationRequest,
604
+ getMigrationRequestIsMerged,
605
+ mergeMigrationRequest
606
+ },
607
+ branchSchema: {
438
608
  getBranchMigrationHistory,
439
609
  executeBranchMigrationPlan,
440
610
  getBranchMigrationPlan,
441
- getBranchStats
611
+ compareBranchWithUserSchema,
612
+ compareBranchSchemas,
613
+ updateBranchSchema,
614
+ previewBranchSchemaEdit,
615
+ applyBranchSchemaEdit,
616
+ getBranchSchemaHistory
442
617
  },
443
618
  table: {
444
619
  createTable,
@@ -462,14 +637,15 @@ const operationsByTag = {
462
637
  bulkInsertTableRecords,
463
638
  queryTable,
464
639
  searchTable,
465
- searchBranch
640
+ searchBranch,
641
+ summarizeTable
466
642
  }
467
643
  };
468
644
 
469
645
  function getHostUrl(provider, type) {
470
- if (isValidAlias(provider)) {
646
+ if (isHostProviderAlias(provider)) {
471
647
  return providers[provider][type];
472
- } else if (isValidBuilder(provider)) {
648
+ } else if (isHostProviderBuilder(provider)) {
473
649
  return provider[type];
474
650
  }
475
651
  throw new Error("Invalid API provider");
@@ -484,10 +660,10 @@ const providers = {
484
660
  workspaces: "https://{workspaceId}.staging.xatabase.co"
485
661
  }
486
662
  };
487
- function isValidAlias(alias) {
663
+ function isHostProviderAlias(alias) {
488
664
  return isString(alias) && Object.keys(providers).includes(alias);
489
665
  }
490
- function isValidBuilder(builder) {
666
+ function isHostProviderBuilder(builder) {
491
667
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
492
668
  }
493
669
 
@@ -515,7 +691,8 @@ class XataApiClient {
515
691
  __privateAdd$7(this, _extraProps, void 0);
516
692
  __privateAdd$7(this, _namespaces, {});
517
693
  const provider = options.host ?? "production";
518
- const apiKey = options?.apiKey ?? getAPIKey();
694
+ const apiKey = options.apiKey ?? getAPIKey();
695
+ const trace = options.trace ?? defaultTrace;
519
696
  if (!apiKey) {
520
697
  throw new Error("Could not resolve a valid apiKey");
521
698
  }
@@ -523,7 +700,8 @@ class XataApiClient {
523
700
  apiUrl: getHostUrl(provider, "main"),
524
701
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
525
702
  fetchImpl: getFetchImplementation(options.fetch),
526
- apiKey
703
+ apiKey,
704
+ trace
527
705
  });
528
706
  }
529
707
  get user() {
@@ -556,6 +734,16 @@ class XataApiClient {
556
734
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
557
735
  return __privateGet$7(this, _namespaces).records;
558
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
+ }
559
747
  }
560
748
  _extraProps = new WeakMap();
561
749
  _namespaces = new WeakMap();
@@ -646,6 +834,13 @@ class WorkspaceApi {
646
834
  ...this.extraProps
647
835
  });
648
836
  }
837
+ updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
838
+ return operationsByTag.workspaces.updateWorkspaceMemberInvite({
839
+ pathParams: { workspaceId, inviteId },
840
+ body: { role },
841
+ ...this.extraProps
842
+ });
843
+ }
649
844
  cancelWorkspaceMemberInvite(workspaceId, inviteId) {
650
845
  return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
651
846
  pathParams: { workspaceId, inviteId },
@@ -688,6 +883,19 @@ class DatabaseApi {
688
883
  ...this.extraProps
689
884
  });
690
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
+ }
691
899
  getGitBranchesMapping(workspace, dbName) {
692
900
  return operationsByTag.database.getGitBranchesMapping({
693
901
  pathParams: { workspace, dbName },
@@ -759,27 +967,6 @@ class BranchApi {
759
967
  ...this.extraProps
760
968
  });
761
969
  }
762
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
763
- return operationsByTag.branch.getBranchMigrationHistory({
764
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
765
- body: options,
766
- ...this.extraProps
767
- });
768
- }
769
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
770
- return operationsByTag.branch.executeBranchMigrationPlan({
771
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
772
- body: migrationPlan,
773
- ...this.extraProps
774
- });
775
- }
776
- getBranchMigrationPlan(workspace, database, branch, schema) {
777
- return operationsByTag.branch.getBranchMigrationPlan({
778
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
779
- body: schema,
780
- ...this.extraProps
781
- });
782
- }
783
970
  getBranchStats(workspace, database, branch) {
784
971
  return operationsByTag.branch.getBranchStats({
785
972
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
@@ -860,9 +1047,10 @@ class RecordsApi {
860
1047
  constructor(extraProps) {
861
1048
  this.extraProps = extraProps;
862
1049
  }
863
- insertRecord(workspace, database, branch, tableName, record) {
1050
+ insertRecord(workspace, database, branch, tableName, record, options = {}) {
864
1051
  return operationsByTag.records.insertRecord({
865
1052
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1053
+ queryParams: options,
866
1054
  body: record,
867
1055
  ...this.extraProps
868
1056
  });
@@ -891,21 +1079,24 @@ class RecordsApi {
891
1079
  ...this.extraProps
892
1080
  });
893
1081
  }
894
- deleteRecord(workspace, database, branch, tableName, recordId) {
1082
+ deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
895
1083
  return operationsByTag.records.deleteRecord({
896
1084
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1085
+ queryParams: options,
897
1086
  ...this.extraProps
898
1087
  });
899
1088
  }
900
1089
  getRecord(workspace, database, branch, tableName, recordId, options = {}) {
901
1090
  return operationsByTag.records.getRecord({
902
1091
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1092
+ queryParams: options,
903
1093
  ...this.extraProps
904
1094
  });
905
1095
  }
906
- bulkInsertTableRecords(workspace, database, branch, tableName, records) {
1096
+ bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
907
1097
  return operationsByTag.records.bulkInsertTableRecords({
908
1098
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1099
+ queryParams: options,
909
1100
  body: { records },
910
1101
  ...this.extraProps
911
1102
  });
@@ -931,6 +1122,138 @@ class RecordsApi {
931
1122
  ...this.extraProps
932
1123
  });
933
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
+ listMigrationRequests(workspace, database, options = {}) {
1138
+ return operationsByTag.migrationRequests.listMigrationRequests({
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
+ }
934
1257
  }
935
1258
 
936
1259
  class XataApiPlugin {
@@ -997,7 +1320,7 @@ const _RecordArray = class extends Array {
997
1320
  constructor(...args) {
998
1321
  super(..._RecordArray.parseConstructorParams(...args));
999
1322
  __privateAdd$6(this, _page, void 0);
1000
- __privateSet$6(this, _page, args[0]);
1323
+ __privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
1001
1324
  }
1002
1325
  static parseConstructorParams(...args) {
1003
1326
  if (args.length === 1 && typeof args[0] === "number") {
@@ -1009,6 +1332,12 @@ const _RecordArray = class extends Array {
1009
1332
  }
1010
1333
  return new Array(...args);
1011
1334
  }
1335
+ toArray() {
1336
+ return new Array(...this);
1337
+ }
1338
+ map(callbackfn, thisArg) {
1339
+ return this.toArray().map(callbackfn, thisArg);
1340
+ }
1012
1341
  async nextPage(size, offset) {
1013
1342
  const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
1014
1343
  return new _RecordArray(newPage);
@@ -1050,9 +1379,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
1050
1379
  setter ? setter.call(obj, value) : member.set(obj, value);
1051
1380
  return value;
1052
1381
  };
1053
- 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;
1054
1387
  const _Query = class {
1055
1388
  constructor(repository, table, data, rawParent) {
1389
+ __privateAdd$5(this, _cleanFilterConstraint);
1056
1390
  __privateAdd$5(this, _table$1, void 0);
1057
1391
  __privateAdd$5(this, _repository, void 0);
1058
1392
  __privateAdd$5(this, _data, { filter: {} });
@@ -1109,21 +1443,29 @@ const _Query = class {
1109
1443
  }
1110
1444
  filter(a, b) {
1111
1445
  if (arguments.length === 1) {
1112
- 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
+ }));
1113
1449
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1114
1450
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1115
1451
  } else {
1116
- 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));
1117
1454
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1118
1455
  }
1119
1456
  }
1120
- sort(column, direction) {
1457
+ sort(column, direction = "asc") {
1121
1458
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1122
1459
  const sort = [...originalSort, { column, direction }];
1123
1460
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
1124
1461
  }
1125
1462
  select(columns) {
1126
- 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
+ );
1127
1469
  }
1128
1470
  getPaginated(options = {}) {
1129
1471
  const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
@@ -1146,11 +1488,20 @@ const _Query = class {
1146
1488
  }
1147
1489
  }
1148
1490
  async getMany(options = {}) {
1149
- 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
+ }
1150
1500
  if (page.hasNextPage() && options.pagination?.size === void 0) {
1151
1501
  console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
1152
1502
  }
1153
- return page.records;
1503
+ const array = new RecordArray(page, results.slice(0, size));
1504
+ return array;
1154
1505
  }
1155
1506
  async getAll(options = {}) {
1156
1507
  const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
@@ -1164,6 +1515,12 @@ const _Query = class {
1164
1515
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
1165
1516
  return records[0] ?? null;
1166
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
+ }
1167
1524
  cache(ttl) {
1168
1525
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1169
1526
  }
@@ -1187,6 +1544,17 @@ let Query = _Query;
1187
1544
  _table$1 = new WeakMap();
1188
1545
  _repository = new WeakMap();
1189
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
+ };
1190
1558
  function cleanParent(data, parent) {
1191
1559
  if (isCursorPaginationOptions(data.pagination)) {
1192
1560
  return { ...parent, sorting: void 0, filter: void 0 };
@@ -1248,203 +1616,284 @@ var __privateMethod$2 = (obj, member, method) => {
1248
1616
  __accessCheck$4(obj, member, "access private method");
1249
1617
  return method;
1250
1618
  };
1251
- 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;
1252
1620
  class Repository extends Query {
1253
1621
  }
1254
1622
  class RestRepository extends Query {
1255
1623
  constructor(options) {
1256
- super(null, options.table, {});
1624
+ super(
1625
+ null,
1626
+ { name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
1627
+ {}
1628
+ );
1257
1629
  __privateAdd$4(this, _insertRecordWithoutId);
1258
1630
  __privateAdd$4(this, _insertRecordWithId);
1259
1631
  __privateAdd$4(this, _bulkInsertTableRecords);
1260
1632
  __privateAdd$4(this, _updateRecordWithID);
1261
1633
  __privateAdd$4(this, _upsertRecordWithID);
1262
1634
  __privateAdd$4(this, _deleteRecord);
1263
- __privateAdd$4(this, _invalidateCache);
1264
- __privateAdd$4(this, _setCacheRecord);
1265
- __privateAdd$4(this, _getCacheRecord);
1266
1635
  __privateAdd$4(this, _setCacheQuery);
1267
1636
  __privateAdd$4(this, _getCacheQuery);
1268
1637
  __privateAdd$4(this, _getSchemaTables$1);
1269
1638
  __privateAdd$4(this, _table, void 0);
1270
1639
  __privateAdd$4(this, _getFetchProps, void 0);
1640
+ __privateAdd$4(this, _db, void 0);
1271
1641
  __privateAdd$4(this, _cache, void 0);
1272
1642
  __privateAdd$4(this, _schemaTables$2, void 0);
1643
+ __privateAdd$4(this, _trace, void 0);
1273
1644
  __privateSet$4(this, _table, options.table);
1274
1645
  __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1275
- this.db = options.db;
1646
+ __privateSet$4(this, _db, options.db);
1276
1647
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1277
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
+ });
1278
1658
  }
1279
- async create(a, b) {
1280
- if (Array.isArray(a)) {
1281
- if (a.length === 0)
1282
- return [];
1283
- const records = await __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a);
1284
- await Promise.all(records.map((record) => __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record)));
1285
- return records;
1286
- }
1287
- if (isString(a) && isObject(b)) {
1288
- if (a === "")
1289
- throw new Error("The id can't be empty");
1290
- const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b);
1291
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1292
- return record;
1293
- }
1294
- if (isObject(a) && isString(a.id)) {
1295
- if (a.id === "")
1296
- throw new Error("The id can't be empty");
1297
- const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 });
1298
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1299
- return record;
1300
- }
1301
- if (isObject(a)) {
1302
- const record = await __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a);
1303
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1304
- return record;
1305
- }
1306
- throw new Error("Invalid arguments for create method");
1307
- }
1308
- async read(a) {
1309
- if (Array.isArray(a)) {
1310
- if (a.length === 0)
1311
- return [];
1312
- const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
1313
- return this.getAll({ filter: { id: { $any: ids } } });
1314
- }
1315
- const id = isString(a) ? a : a.id;
1316
- if (isString(id)) {
1317
- const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, id);
1318
- if (cacheRecord)
1319
- return cacheRecord;
1320
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1321
- try {
1322
- const response = await getRecord({
1323
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: id },
1324
- ...fetchProps
1325
- });
1326
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1327
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1328
- } catch (e) {
1329
- if (isObject(e) && e.status === 404) {
1330
- 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);
1716
+ } catch (e) {
1717
+ if (isObject(e) && e.status === 404) {
1718
+ return null;
1719
+ }
1720
+ throw e;
1331
1721
  }
1332
- throw e;
1333
1722
  }
1334
- }
1723
+ return null;
1724
+ });
1335
1725
  }
1336
- async update(a, b) {
1337
- if (Array.isArray(a)) {
1338
- if (a.length === 0)
1339
- return [];
1340
- if (a.length > 100) {
1341
- 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;
1342
1737
  }
1343
- return Promise.all(a.map((object) => this.update(object)));
1344
- }
1345
- if (isString(a) && isObject(b)) {
1346
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1347
- const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b);
1348
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1349
- return record;
1350
- }
1351
- if (isObject(a) && isString(a.id)) {
1352
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1353
- const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1354
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1355
- return record;
1356
- }
1357
- throw new Error("Invalid arguments for update method");
1358
- }
1359
- async createOrUpdate(a, b) {
1360
- if (Array.isArray(a)) {
1361
- if (a.length === 0)
1362
- return [];
1363
- if (a.length > 100) {
1364
- 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`);
1365
1741
  }
1366
- return Promise.all(a.map((object) => this.createOrUpdate(object)));
1367
- }
1368
- if (isString(a) && isObject(b)) {
1369
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1370
- const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b);
1371
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1372
- return record;
1373
- }
1374
- if (isObject(a) && isString(a.id)) {
1375
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1376
- const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1377
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1378
- return record;
1379
- }
1380
- throw new Error("Invalid arguments for createOrUpdate method");
1381
- }
1382
- async delete(a) {
1383
- if (Array.isArray(a)) {
1384
- if (a.length === 0)
1385
- return;
1386
- if (a.length > 100) {
1387
- 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)));
1388
1755
  }
1389
- await Promise.all(a.map((id) => this.delete(id)));
1390
- return;
1391
- }
1392
- if (isString(a)) {
1393
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
1394
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1395
- return;
1396
- }
1397
- if (isObject(a) && isString(a.id)) {
1398
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
1399
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1400
- return;
1401
- }
1402
- 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
+ });
1403
1844
  }
1404
1845
  async search(query, options = {}) {
1405
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1406
- const { records } = await searchTable({
1407
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1408
- body: {
1409
- query,
1410
- fuzziness: options.fuzziness,
1411
- highlight: options.highlight,
1412
- filter: options.filter
1413
- },
1414
- ...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));
1415
1862
  });
1416
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1417
- return records.map((item) => initObject(this.db, schemaTables, __privateGet$4(this, _table), item));
1418
1863
  }
1419
1864
  async query(query) {
1420
- const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1421
- if (cacheQuery)
1422
- return new Page(query, cacheQuery.meta, cacheQuery.records);
1423
- const data = query.getQueryOptions();
1424
- const body = {
1425
- filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1426
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1427
- page: data.pagination,
1428
- columns: data.columns
1429
- };
1430
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1431
- const { meta, records: objects } = await queryTable({
1432
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1433
- body,
1434
- ...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((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
1884
+ await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1885
+ return new Page(query, meta, records);
1435
1886
  });
1436
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1437
- const records = objects.map((record) => initObject(this.db, schemaTables, __privateGet$4(this, _table), record));
1438
- await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1439
- return new Page(query, meta, records);
1440
1887
  }
1441
1888
  }
1442
1889
  _table = new WeakMap();
1443
1890
  _getFetchProps = new WeakMap();
1891
+ _db = new WeakMap();
1444
1892
  _cache = new WeakMap();
1445
1893
  _schemaTables$2 = new WeakMap();
1894
+ _trace = new WeakMap();
1446
1895
  _insertRecordWithoutId = new WeakSet();
1447
- insertRecordWithoutId_fn = async function(object) {
1896
+ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1448
1897
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1449
1898
  const record = transformObjectLinks(object);
1450
1899
  const response = await insertRecord({
@@ -1453,17 +1902,15 @@ insertRecordWithoutId_fn = async function(object) {
1453
1902
  dbBranchName: "{dbBranch}",
1454
1903
  tableName: __privateGet$4(this, _table)
1455
1904
  },
1905
+ queryParams: { columns },
1456
1906
  body: record,
1457
1907
  ...fetchProps
1458
1908
  });
1459
- const finalObject = await this.read(response.id);
1460
- if (!finalObject) {
1461
- throw new Error("The server failed to save the record");
1462
- }
1463
- return finalObject;
1909
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1910
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1464
1911
  };
1465
1912
  _insertRecordWithId = new WeakSet();
1466
- insertRecordWithId_fn = async function(recordId, object) {
1913
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
1467
1914
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1468
1915
  const record = transformObjectLinks(object);
1469
1916
  const response = await insertRecordWithID({
@@ -1474,92 +1921,78 @@ insertRecordWithId_fn = async function(recordId, object) {
1474
1921
  recordId
1475
1922
  },
1476
1923
  body: record,
1477
- queryParams: { createOnly: true },
1924
+ queryParams: { createOnly: true, columns },
1478
1925
  ...fetchProps
1479
1926
  });
1480
- const finalObject = await this.read(response.id);
1481
- if (!finalObject) {
1482
- throw new Error("The server failed to save the record");
1483
- }
1484
- return finalObject;
1927
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1928
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1485
1929
  };
1486
1930
  _bulkInsertTableRecords = new WeakSet();
1487
- bulkInsertTableRecords_fn = async function(objects) {
1931
+ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1488
1932
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1489
1933
  const records = objects.map((object) => transformObjectLinks(object));
1490
- const { recordIDs } = await bulkInsertTableRecords({
1934
+ const response = await bulkInsertTableRecords({
1491
1935
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1936
+ queryParams: { columns },
1492
1937
  body: { records },
1493
1938
  ...fetchProps
1494
1939
  });
1495
- const finalObjects = await this.read(recordIDs);
1496
- if (finalObjects.length !== objects.length) {
1497
- throw new Error("The server failed to save some records");
1940
+ if (!isResponseWithRecords(response)) {
1941
+ throw new Error("Request included columns but server didn't include them");
1498
1942
  }
1499
- const dictionary = finalObjects.reduce((acc, object) => {
1500
- acc[object.id] = object;
1501
- return acc;
1502
- }, {});
1503
- return recordIDs.map((id) => dictionary[id]);
1943
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1944
+ return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
1504
1945
  };
1505
1946
  _updateRecordWithID = new WeakSet();
1506
- updateRecordWithID_fn = async function(recordId, object) {
1947
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1507
1948
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1508
1949
  const record = transformObjectLinks(object);
1509
- const response = await updateRecordWithID({
1510
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1511
- body: record,
1512
- ...fetchProps
1513
- });
1514
- const item = await this.read(response.id);
1515
- if (!item)
1516
- throw new Error("The server failed to save the record");
1517
- return item;
1950
+ try {
1951
+ const response = await updateRecordWithID({
1952
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1953
+ queryParams: { columns },
1954
+ body: record,
1955
+ ...fetchProps
1956
+ });
1957
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1958
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1959
+ } catch (e) {
1960
+ if (isObject(e) && e.status === 404) {
1961
+ return null;
1962
+ }
1963
+ throw e;
1964
+ }
1518
1965
  };
1519
1966
  _upsertRecordWithID = new WeakSet();
1520
- upsertRecordWithID_fn = async function(recordId, object) {
1967
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1521
1968
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1522
1969
  const response = await upsertRecordWithID({
1523
1970
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1971
+ queryParams: { columns },
1524
1972
  body: object,
1525
1973
  ...fetchProps
1526
1974
  });
1527
- const item = await this.read(response.id);
1528
- if (!item)
1529
- throw new Error("The server failed to save the record");
1530
- return item;
1975
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1976
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1531
1977
  };
1532
1978
  _deleteRecord = new WeakSet();
1533
- deleteRecord_fn = async function(recordId) {
1979
+ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1534
1980
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1535
- await deleteRecord({
1536
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1537
- ...fetchProps
1538
- });
1539
- };
1540
- _invalidateCache = new WeakSet();
1541
- invalidateCache_fn = async function(recordId) {
1542
- await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1543
- const cacheItems = await __privateGet$4(this, _cache).getAll();
1544
- const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
1545
- for (const [key, value] of queries) {
1546
- const ids = getIds(value);
1547
- if (ids.includes(recordId))
1548
- await __privateGet$4(this, _cache).delete(key);
1981
+ try {
1982
+ const response = await deleteRecord({
1983
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1984
+ queryParams: { columns },
1985
+ ...fetchProps
1986
+ });
1987
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1988
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1989
+ } catch (e) {
1990
+ if (isObject(e) && e.status === 404) {
1991
+ return null;
1992
+ }
1993
+ throw e;
1549
1994
  }
1550
1995
  };
1551
- _setCacheRecord = new WeakSet();
1552
- setCacheRecord_fn = async function(record) {
1553
- if (!__privateGet$4(this, _cache).cacheRecords)
1554
- return;
1555
- await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
1556
- };
1557
- _getCacheRecord = new WeakSet();
1558
- getCacheRecord_fn = async function(recordId) {
1559
- if (!__privateGet$4(this, _cache).cacheRecords)
1560
- return null;
1561
- return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1562
- };
1563
1996
  _setCacheQuery = new WeakSet();
1564
1997
  setCacheQuery_fn = async function(query, meta, records) {
1565
1998
  await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
@@ -1620,16 +2053,24 @@ const initObject = (db, schemaTables, table, object) => {
1620
2053
  console.error(`Failed to parse link for field ${column.name}`);
1621
2054
  } else if (isObject(value)) {
1622
2055
  result[column.name] = initObject(db, schemaTables, linkTable, value);
2056
+ } else {
2057
+ result[column.name] = null;
1623
2058
  }
1624
2059
  break;
1625
2060
  }
2061
+ default:
2062
+ result[column.name] = value ?? null;
2063
+ if (column.notNull === true && value === null) {
2064
+ console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2065
+ }
2066
+ break;
1626
2067
  }
1627
2068
  }
1628
- result.read = function() {
1629
- return db[table].read(result["id"]);
2069
+ result.read = function(columns2) {
2070
+ return db[table].read(result["id"], columns2);
1630
2071
  };
1631
- result.update = function(data) {
1632
- return db[table].update(result["id"], data);
2072
+ result.update = function(data, columns2) {
2073
+ return db[table].update(result["id"], data, columns2);
1633
2074
  };
1634
2075
  result.delete = function() {
1635
2076
  return db[table].delete(result["id"]);
@@ -1643,14 +2084,21 @@ const initObject = (db, schemaTables, table, object) => {
1643
2084
  Object.freeze(result);
1644
2085
  return result;
1645
2086
  };
1646
- function getIds(value) {
1647
- if (Array.isArray(value)) {
1648
- return value.map((item) => getIds(item)).flat();
1649
- }
1650
- if (!isObject(value))
1651
- return [];
1652
- const nestedIds = Object.values(value).map((item) => getIds(item)).flat();
1653
- return isString(value.id) ? [value.id, ...nestedIds] : nestedIds;
2087
+ function isResponseWithRecords(value) {
2088
+ return isObject(value) && Array.isArray(value.records);
2089
+ }
2090
+ function extractId(value) {
2091
+ if (isString(value))
2092
+ return value;
2093
+ if (isObject(value) && isString(value.id))
2094
+ return value.id;
2095
+ return void 0;
2096
+ }
2097
+ function cleanFilter(filter) {
2098
+ if (!filter)
2099
+ return void 0;
2100
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2101
+ return values.length > 0 ? filter : void 0;
1654
2102
  }
1655
2103
 
1656
2104
  var __accessCheck$3 = (obj, member, msg) => {
@@ -1677,7 +2125,6 @@ class SimpleCache {
1677
2125
  __privateAdd$3(this, _map, void 0);
1678
2126
  __privateSet$3(this, _map, /* @__PURE__ */ new Map());
1679
2127
  this.capacity = options.max ?? 500;
1680
- this.cacheRecords = options.cacheRecords ?? true;
1681
2128
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
1682
2129
  }
1683
2130
  async getAll() {
@@ -1703,18 +2150,25 @@ class SimpleCache {
1703
2150
  }
1704
2151
  _map = new WeakMap();
1705
2152
 
1706
- const gt = (value) => ({ $gt: value });
1707
- const ge = (value) => ({ $ge: value });
1708
- const gte = (value) => ({ $ge: value });
1709
- const lt = (value) => ({ $lt: value });
1710
- const lte = (value) => ({ $le: value });
1711
- const le = (value) => ({ $le: value });
2153
+ const greaterThan = (value) => ({ $gt: value });
2154
+ const gt = greaterThan;
2155
+ const greaterThanEquals = (value) => ({ $ge: value });
2156
+ const greaterEquals = greaterThanEquals;
2157
+ const gte = greaterThanEquals;
2158
+ const ge = greaterThanEquals;
2159
+ const lessThan = (value) => ({ $lt: value });
2160
+ const lt = lessThan;
2161
+ const lessThanEquals = (value) => ({ $le: value });
2162
+ const lessEquals = lessThanEquals;
2163
+ const lte = lessThanEquals;
2164
+ const le = lessThanEquals;
1712
2165
  const exists = (column) => ({ $exists: column });
1713
2166
  const notExists = (column) => ({ $notExists: column });
1714
2167
  const startsWith = (value) => ({ $startsWith: value });
1715
2168
  const endsWith = (value) => ({ $endsWith: value });
1716
2169
  const pattern = (value) => ({ $pattern: value });
1717
2170
  const is = (value) => ({ $is: value });
2171
+ const equals = is;
1718
2172
  const isNot = (value) => ({ $isNot: value });
1719
2173
  const contains = (value) => ({ $contains: value });
1720
2174
  const includes = (value) => ({ $includes: value });
@@ -1749,16 +2203,19 @@ class SchemaPlugin extends XataPlugin {
1749
2203
  __privateSet$2(this, _schemaTables$1, schemaTables);
1750
2204
  }
1751
2205
  build(pluginOptions) {
1752
- const db = new Proxy({}, {
1753
- get: (_target, table) => {
1754
- if (!isString(table))
1755
- throw new Error("Invalid table name");
1756
- if (__privateGet$2(this, _tables)[table] === void 0) {
1757
- __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
2206
+ const db = new Proxy(
2207
+ {},
2208
+ {
2209
+ get: (_target, table) => {
2210
+ if (!isString(table))
2211
+ throw new Error("Invalid table name");
2212
+ if (__privateGet$2(this, _tables)[table] === void 0) {
2213
+ __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
2214
+ }
2215
+ return __privateGet$2(this, _tables)[table];
1758
2216
  }
1759
- return __privateGet$2(this, _tables)[table];
1760
2217
  }
1761
- });
2218
+ );
1762
2219
  const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
1763
2220
  for (const table of tableNames) {
1764
2221
  db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
@@ -1828,10 +2285,10 @@ _schemaTables = new WeakMap();
1828
2285
  _search = new WeakSet();
1829
2286
  search_fn = async function(query, options, getFetchProps) {
1830
2287
  const fetchProps = await getFetchProps();
1831
- const { tables, fuzziness, highlight } = options ?? {};
2288
+ const { tables, fuzziness, highlight, prefix } = options ?? {};
1832
2289
  const { records } = await searchBranch({
1833
2290
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1834
- body: { tables, query, fuzziness, highlight },
2291
+ body: { tables, query, fuzziness, prefix, highlight },
1835
2292
  ...fetchProps
1836
2293
  });
1837
2294
  return records;
@@ -1853,21 +2310,15 @@ const isBranchStrategyBuilder = (strategy) => {
1853
2310
  return typeof strategy === "function";
1854
2311
  };
1855
2312
 
1856
- const envBranchNames = [
1857
- "XATA_BRANCH",
1858
- "VERCEL_GIT_COMMIT_REF",
1859
- "CF_PAGES_BRANCH",
1860
- "BRANCH"
1861
- ];
1862
2313
  async function getCurrentBranchName(options) {
1863
- const env = getBranchByEnvVariable();
1864
- if (env) {
1865
- const details = await getDatabaseBranch(env, options);
2314
+ const { branch, envBranch } = getEnvironment();
2315
+ if (branch) {
2316
+ const details = await getDatabaseBranch(branch, options);
1866
2317
  if (details)
1867
- return env;
1868
- console.warn(`Branch ${env} not found in Xata. Ignoring...`);
2318
+ return branch;
2319
+ console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
1869
2320
  }
1870
- const gitBranch = await getGitBranch();
2321
+ const gitBranch = envBranch || await getGitBranch();
1871
2322
  return resolveXataBranch(gitBranch, options);
1872
2323
  }
1873
2324
  async function getCurrentBranchDetails(options) {
@@ -1878,18 +2329,24 @@ async function resolveXataBranch(gitBranch, options) {
1878
2329
  const databaseURL = options?.databaseURL || getDatabaseURL();
1879
2330
  const apiKey = options?.apiKey || getAPIKey();
1880
2331
  if (!databaseURL)
1881
- throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
2332
+ throw new Error(
2333
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2334
+ );
1882
2335
  if (!apiKey)
1883
- throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
2336
+ throw new Error(
2337
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2338
+ );
1884
2339
  const [protocol, , host, , dbName] = databaseURL.split("/");
1885
2340
  const [workspace] = host.split(".");
2341
+ const { fallbackBranch } = getEnvironment();
1886
2342
  const { branch } = await resolveBranch({
1887
2343
  apiKey,
1888
2344
  apiUrl: databaseURL,
1889
2345
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1890
2346
  workspacesApiUrl: `${protocol}//${host}`,
1891
2347
  pathParams: { dbName, workspace },
1892
- queryParams: { gitBranch, fallbackBranch: getEnvVariable("XATA_FALLBACK_BRANCH") }
2348
+ queryParams: { gitBranch, fallbackBranch },
2349
+ trace: defaultTrace
1893
2350
  });
1894
2351
  return branch;
1895
2352
  }
@@ -1897,9 +2354,13 @@ async function getDatabaseBranch(branch, options) {
1897
2354
  const databaseURL = options?.databaseURL || getDatabaseURL();
1898
2355
  const apiKey = options?.apiKey || getAPIKey();
1899
2356
  if (!databaseURL)
1900
- throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
2357
+ throw new Error(
2358
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2359
+ );
1901
2360
  if (!apiKey)
1902
- throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
2361
+ throw new Error(
2362
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2363
+ );
1903
2364
  const [protocol, , host, , database] = databaseURL.split("/");
1904
2365
  const [workspace] = host.split(".");
1905
2366
  const dbBranchName = `${database}:${branch}`;
@@ -1909,7 +2370,8 @@ async function getDatabaseBranch(branch, options) {
1909
2370
  apiUrl: databaseURL,
1910
2371
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1911
2372
  workspacesApiUrl: `${protocol}//${host}`,
1912
- pathParams: { dbBranchName, workspace }
2373
+ pathParams: { dbBranchName, workspace },
2374
+ trace: defaultTrace
1913
2375
  });
1914
2376
  } catch (err) {
1915
2377
  if (isObject(err) && err.status === 404)
@@ -1917,21 +2379,10 @@ async function getDatabaseBranch(branch, options) {
1917
2379
  throw err;
1918
2380
  }
1919
2381
  }
1920
- function getBranchByEnvVariable() {
1921
- for (const name of envBranchNames) {
1922
- const value = getEnvVariable(name);
1923
- if (value) {
1924
- return value;
1925
- }
1926
- }
1927
- try {
1928
- return XATA_BRANCH;
1929
- } catch (err) {
1930
- }
1931
- }
1932
2382
  function getDatabaseURL() {
1933
2383
  try {
1934
- return getEnvVariable("XATA_DATABASE_URL") ?? XATA_DATABASE_URL;
2384
+ const { databaseURL } = getEnvironment();
2385
+ return databaseURL;
1935
2386
  } catch (err) {
1936
2387
  return void 0;
1937
2388
  }
@@ -1960,17 +2411,20 @@ var __privateMethod = (obj, member, method) => {
1960
2411
  return method;
1961
2412
  };
1962
2413
  const buildClient = (plugins) => {
1963
- var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
2414
+ var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
1964
2415
  return _a = class {
1965
2416
  constructor(options = {}, schemaTables) {
1966
2417
  __privateAdd(this, _parseOptions);
1967
2418
  __privateAdd(this, _getFetchProps);
1968
2419
  __privateAdd(this, _evaluateBranch);
1969
2420
  __privateAdd(this, _branch, void 0);
2421
+ __privateAdd(this, _options, void 0);
1970
2422
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
2423
+ __privateSet(this, _options, safeOptions);
1971
2424
  const pluginOptions = {
1972
2425
  getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
1973
- cache: safeOptions.cache
2426
+ cache: safeOptions.cache,
2427
+ trace: safeOptions.trace
1974
2428
  };
1975
2429
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
1976
2430
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
@@ -1989,22 +2443,26 @@ const buildClient = (plugins) => {
1989
2443
  }
1990
2444
  }
1991
2445
  }
1992
- }, _branch = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
2446
+ async getConfig() {
2447
+ const databaseURL = __privateGet(this, _options).databaseURL;
2448
+ const branch = await __privateGet(this, _options).branch();
2449
+ return { databaseURL, branch };
2450
+ }
2451
+ }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
1993
2452
  const fetch = getFetchImplementation(options?.fetch);
1994
2453
  const databaseURL = options?.databaseURL || getDatabaseURL();
1995
2454
  const apiKey = options?.apiKey || getAPIKey();
1996
- const cache = options?.cache ?? new SimpleCache({ cacheRecords: false, defaultQueryTTL: 0 });
2455
+ const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
2456
+ const trace = options?.trace ?? defaultTrace;
1997
2457
  const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
1998
- if (!databaseURL || !apiKey) {
1999
- throw new Error("Options databaseURL and apiKey are required");
2458
+ if (!apiKey) {
2459
+ throw new Error("Option apiKey is required");
2000
2460
  }
2001
- return { fetch, databaseURL, apiKey, branch, cache };
2002
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
2003
- fetch,
2004
- apiKey,
2005
- databaseURL,
2006
- branch
2007
- }) {
2461
+ if (!databaseURL) {
2462
+ throw new Error("Option databaseURL is required");
2463
+ }
2464
+ return { fetch, databaseURL, apiKey, branch, cache, trace };
2465
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
2008
2466
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2009
2467
  if (!branchValue)
2010
2468
  throw new Error("Unable to resolve branch value");
@@ -2014,9 +2472,10 @@ const buildClient = (plugins) => {
2014
2472
  apiUrl: "",
2015
2473
  workspacesApiUrl: (path, params) => {
2016
2474
  const hasBranch = params.dbBranchName ?? params.branch;
2017
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
2475
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
2018
2476
  return databaseURL + newPath;
2019
- }
2477
+ },
2478
+ trace
2020
2479
  };
2021
2480
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2022
2481
  if (__privateGet(this, _branch))
@@ -2039,6 +2498,88 @@ const buildClient = (plugins) => {
2039
2498
  class BaseClient extends buildClient() {
2040
2499
  }
2041
2500
 
2501
+ const META = "__";
2502
+ const VALUE = "___";
2503
+ class Serializer {
2504
+ constructor() {
2505
+ this.classes = {};
2506
+ }
2507
+ add(clazz) {
2508
+ this.classes[clazz.name] = clazz;
2509
+ }
2510
+ toJSON(data) {
2511
+ function visit(obj) {
2512
+ if (Array.isArray(obj))
2513
+ return obj.map(visit);
2514
+ const type = typeof obj;
2515
+ if (type === "undefined")
2516
+ return { [META]: "undefined" };
2517
+ if (type === "bigint")
2518
+ return { [META]: "bigint", [VALUE]: obj.toString() };
2519
+ if (obj === null || type !== "object")
2520
+ return obj;
2521
+ const constructor = obj.constructor;
2522
+ const o = { [META]: constructor.name };
2523
+ for (const [key, value] of Object.entries(obj)) {
2524
+ o[key] = visit(value);
2525
+ }
2526
+ if (constructor === Date)
2527
+ o[VALUE] = obj.toISOString();
2528
+ if (constructor === Map)
2529
+ o[VALUE] = Object.fromEntries(obj);
2530
+ if (constructor === Set)
2531
+ o[VALUE] = [...obj];
2532
+ return o;
2533
+ }
2534
+ return JSON.stringify(visit(data));
2535
+ }
2536
+ fromJSON(json) {
2537
+ return JSON.parse(json, (key, value) => {
2538
+ if (value && typeof value === "object" && !Array.isArray(value)) {
2539
+ const { [META]: clazz, [VALUE]: val, ...rest } = value;
2540
+ const constructor = this.classes[clazz];
2541
+ if (constructor) {
2542
+ return Object.assign(Object.create(constructor.prototype), rest);
2543
+ }
2544
+ if (clazz === "Date")
2545
+ return new Date(val);
2546
+ if (clazz === "Set")
2547
+ return new Set(val);
2548
+ if (clazz === "Map")
2549
+ return new Map(Object.entries(val));
2550
+ if (clazz === "bigint")
2551
+ return BigInt(val);
2552
+ if (clazz === "undefined")
2553
+ return void 0;
2554
+ return rest;
2555
+ }
2556
+ return value;
2557
+ });
2558
+ }
2559
+ }
2560
+ const defaultSerializer = new Serializer();
2561
+ const serialize = (data) => {
2562
+ return defaultSerializer.toJSON(data);
2563
+ };
2564
+ const deserialize = (json) => {
2565
+ return defaultSerializer.fromJSON(json);
2566
+ };
2567
+
2568
+ function buildWorkerRunner(config) {
2569
+ return function xataWorker(name, _worker) {
2570
+ return async (...args) => {
2571
+ const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
2572
+ const result = await fetch(url, {
2573
+ method: "POST",
2574
+ headers: { "Content-Type": "application/json" },
2575
+ body: serialize({ args })
2576
+ });
2577
+ const text = await result.text();
2578
+ return deserialize(text);
2579
+ };
2580
+ };
2581
+ }
2582
+
2042
2583
  class XataError extends Error {
2043
2584
  constructor(message, status) {
2044
2585
  super(message);
@@ -2059,6 +2600,7 @@ exports.Repository = Repository;
2059
2600
  exports.RestRepository = RestRepository;
2060
2601
  exports.SchemaPlugin = SchemaPlugin;
2061
2602
  exports.SearchPlugin = SearchPlugin;
2603
+ exports.Serializer = Serializer;
2062
2604
  exports.SimpleCache = SimpleCache;
2063
2605
  exports.XataApiClient = XataApiClient;
2064
2606
  exports.XataApiPlugin = XataApiPlugin;
@@ -2067,12 +2609,18 @@ exports.XataPlugin = XataPlugin;
2067
2609
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
2068
2610
  exports.addGitBranchesEntry = addGitBranchesEntry;
2069
2611
  exports.addTableColumn = addTableColumn;
2612
+ exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
2070
2613
  exports.buildClient = buildClient;
2614
+ exports.buildWorkerRunner = buildWorkerRunner;
2071
2615
  exports.bulkInsertTableRecords = bulkInsertTableRecords;
2072
2616
  exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
2617
+ exports.compareBranchSchemas = compareBranchSchemas;
2618
+ exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
2619
+ exports.compareMigrationRequest = compareMigrationRequest;
2073
2620
  exports.contains = contains;
2074
2621
  exports.createBranch = createBranch;
2075
2622
  exports.createDatabase = createDatabase;
2623
+ exports.createMigrationRequest = createMigrationRequest;
2076
2624
  exports.createTable = createTable;
2077
2625
  exports.createUserAPIKey = createUserAPIKey;
2078
2626
  exports.createWorkspace = createWorkspace;
@@ -2084,7 +2632,9 @@ exports.deleteTable = deleteTable;
2084
2632
  exports.deleteUser = deleteUser;
2085
2633
  exports.deleteUserAPIKey = deleteUserAPIKey;
2086
2634
  exports.deleteWorkspace = deleteWorkspace;
2635
+ exports.deserialize = deserialize;
2087
2636
  exports.endsWith = endsWith;
2637
+ exports.equals = equals;
2088
2638
  exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
2089
2639
  exports.exists = exists;
2090
2640
  exports.ge = ge;
@@ -2094,13 +2644,17 @@ exports.getBranchList = getBranchList;
2094
2644
  exports.getBranchMetadata = getBranchMetadata;
2095
2645
  exports.getBranchMigrationHistory = getBranchMigrationHistory;
2096
2646
  exports.getBranchMigrationPlan = getBranchMigrationPlan;
2647
+ exports.getBranchSchemaHistory = getBranchSchemaHistory;
2097
2648
  exports.getBranchStats = getBranchStats;
2098
2649
  exports.getColumn = getColumn;
2099
2650
  exports.getCurrentBranchDetails = getCurrentBranchDetails;
2100
2651
  exports.getCurrentBranchName = getCurrentBranchName;
2101
2652
  exports.getDatabaseList = getDatabaseList;
2653
+ exports.getDatabaseMetadata = getDatabaseMetadata;
2102
2654
  exports.getDatabaseURL = getDatabaseURL;
2103
2655
  exports.getGitBranchesMapping = getGitBranchesMapping;
2656
+ exports.getMigrationRequest = getMigrationRequest;
2657
+ exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
2104
2658
  exports.getRecord = getRecord;
2105
2659
  exports.getTableColumns = getTableColumns;
2106
2660
  exports.getTableSchema = getTableSchema;
@@ -2109,6 +2663,9 @@ exports.getUserAPIKeys = getUserAPIKeys;
2109
2663
  exports.getWorkspace = getWorkspace;
2110
2664
  exports.getWorkspaceMembersList = getWorkspaceMembersList;
2111
2665
  exports.getWorkspacesList = getWorkspacesList;
2666
+ exports.greaterEquals = greaterEquals;
2667
+ exports.greaterThan = greaterThan;
2668
+ exports.greaterThanEquals = greaterThanEquals;
2112
2669
  exports.gt = gt;
2113
2670
  exports.gte = gte;
2114
2671
  exports.includes = includes;
@@ -2124,11 +2681,18 @@ exports.isIdentifiable = isIdentifiable;
2124
2681
  exports.isNot = isNot;
2125
2682
  exports.isXataRecord = isXataRecord;
2126
2683
  exports.le = le;
2684
+ exports.lessEquals = lessEquals;
2685
+ exports.lessThan = lessThan;
2686
+ exports.lessThanEquals = lessThanEquals;
2687
+ exports.listMigrationRequests = listMigrationRequests;
2688
+ exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
2127
2689
  exports.lt = lt;
2128
2690
  exports.lte = lte;
2691
+ exports.mergeMigrationRequest = mergeMigrationRequest;
2129
2692
  exports.notExists = notExists;
2130
2693
  exports.operationsByTag = operationsByTag;
2131
2694
  exports.pattern = pattern;
2695
+ exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
2132
2696
  exports.queryTable = queryTable;
2133
2697
  exports.removeGitBranchesEntry = removeGitBranchesEntry;
2134
2698
  exports.removeWorkspaceMember = removeWorkspaceMember;
@@ -2136,14 +2700,20 @@ exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
2136
2700
  exports.resolveBranch = resolveBranch;
2137
2701
  exports.searchBranch = searchBranch;
2138
2702
  exports.searchTable = searchTable;
2703
+ exports.serialize = serialize;
2139
2704
  exports.setTableSchema = setTableSchema;
2140
2705
  exports.startsWith = startsWith;
2706
+ exports.summarizeTable = summarizeTable;
2141
2707
  exports.updateBranchMetadata = updateBranchMetadata;
2708
+ exports.updateBranchSchema = updateBranchSchema;
2142
2709
  exports.updateColumn = updateColumn;
2710
+ exports.updateDatabaseMetadata = updateDatabaseMetadata;
2711
+ exports.updateMigrationRequest = updateMigrationRequest;
2143
2712
  exports.updateRecordWithID = updateRecordWithID;
2144
2713
  exports.updateTable = updateTable;
2145
2714
  exports.updateUser = updateUser;
2146
2715
  exports.updateWorkspace = updateWorkspace;
2716
+ exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
2147
2717
  exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
2148
2718
  exports.upsertRecordWithID = upsertRecordWithID;
2149
2719
  //# sourceMappingURL=index.cjs.map