@xata.io/client 0.0.0-alpha.vf170c2c → 0.0.0-alpha.vf1f4abe

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
  }
@@ -11,36 +51,101 @@ function compact(arr) {
11
51
  function isObject(value) {
12
52
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
13
53
  }
54
+ function isDefined(value) {
55
+ return value !== null && value !== void 0;
56
+ }
14
57
  function isString(value) {
15
- return value !== void 0 && value !== null && typeof value === "string";
58
+ return isDefined(value) && typeof value === "string";
59
+ }
60
+ function isStringArray(value) {
61
+ return isDefined(value) && Array.isArray(value) && value.every(isString);
62
+ }
63
+ function toBase64(value) {
64
+ try {
65
+ return btoa(value);
66
+ } catch (err) {
67
+ const buf = Buffer;
68
+ return buf.from(value).toString("base64");
69
+ }
16
70
  }
17
71
 
18
- function getEnvVariable(name) {
72
+ function getEnvironment() {
19
73
  try {
20
- if (isObject(process) && isString(process?.env?.[name])) {
21
- 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
+ };
22
82
  }
23
83
  } catch (err) {
24
84
  }
25
85
  try {
26
- if (isObject(Deno) && isString(Deno?.env?.get(name))) {
27
- 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
+ };
28
94
  }
29
95
  } catch (err) {
30
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
+ }
31
132
  }
32
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"] };
33
138
  try {
34
- return require("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
139
+ if (typeof require === "function") {
140
+ return require(nodeModule).execSync(fullCmd, execOptions).trim();
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();
35
144
  } catch (err) {
36
145
  }
37
146
  try {
38
147
  if (isObject(Deno)) {
39
- const process2 = Deno.run({
40
- cmd: ["git", "branch", "--show-current"],
41
- stdout: "piped",
42
- stderr: "piped"
43
- });
148
+ const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
44
149
  return new TextDecoder().decode(await process2.output()).trim();
45
150
  }
46
151
  } catch (err) {
@@ -49,7 +154,8 @@ async function getGitBranch() {
49
154
 
50
155
  function getAPIKey() {
51
156
  try {
52
- return getEnvVariable("XATA_API_KEY") ?? XATA_API_KEY;
157
+ const { apiKey } = getEnvironment();
158
+ return apiKey;
53
159
  } catch (err) {
54
160
  return void 0;
55
161
  }
@@ -59,21 +165,35 @@ function getFetchImplementation(userFetch) {
59
165
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
60
166
  const fetchImpl = userFetch ?? globalFetch;
61
167
  if (!fetchImpl) {
62
- 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
+ );
63
171
  }
64
172
  return fetchImpl;
65
173
  }
66
174
 
67
- class FetcherError extends Error {
68
- constructor(status, data) {
175
+ const VERSION = "0.0.0-alpha.vf1f4abe";
176
+
177
+ class ErrorWithCause extends Error {
178
+ constructor(message, options) {
179
+ super(message, options);
180
+ }
181
+ }
182
+ class FetcherError extends ErrorWithCause {
183
+ constructor(status, data, requestId) {
69
184
  super(getMessage(data));
70
185
  this.status = status;
71
186
  this.errors = isBulkError(data) ? data.errors : void 0;
187
+ this.requestId = requestId;
72
188
  if (data instanceof Error) {
73
189
  this.stack = data.stack;
74
190
  this.cause = data.cause;
75
191
  }
76
192
  }
193
+ toString() {
194
+ const error = super.toString();
195
+ return `[${this.status}] (${this.requestId ?? "Unknown"}): ${error}`;
196
+ }
77
197
  }
78
198
  function isBulkError(error) {
79
199
  return isObject(error) && Array.isArray(error.errors);
@@ -96,9 +216,17 @@ function getMessage(data) {
96
216
  }
97
217
 
98
218
  const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
99
- const query = new URLSearchParams(queryParams).toString();
219
+ const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
220
+ if (value === void 0 || value === null)
221
+ return acc;
222
+ return { ...acc, [key]: value };
223
+ }, {});
224
+ const query = new URLSearchParams(cleanQueryParams).toString();
100
225
  const queryString = query.length > 0 ? `?${query}` : "";
101
- 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;
102
230
  };
103
231
  function buildBaseUrl({
104
232
  path,
@@ -106,10 +234,10 @@ function buildBaseUrl({
106
234
  apiUrl,
107
235
  pathParams
108
236
  }) {
109
- if (!pathParams?.workspace)
237
+ if (pathParams?.workspace === void 0)
110
238
  return `${apiUrl}${path}`;
111
239
  const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
112
- return url.replace("{workspaceId}", pathParams.workspace);
240
+ return url.replace("{workspaceId}", String(pathParams.workspace));
113
241
  }
114
242
  function hostHeader(url) {
115
243
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
@@ -126,236 +254,358 @@ async function fetch$1({
126
254
  fetchImpl,
127
255
  apiKey,
128
256
  apiUrl,
129
- workspacesApiUrl
257
+ workspacesApiUrl,
258
+ trace,
259
+ signal
130
260
  }) {
131
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
132
- const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
133
- const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
134
- const response = await fetchImpl(url, {
135
- method: method.toUpperCase(),
136
- body: body ? JSON.stringify(body) : void 0,
137
- headers: {
138
- "Content-Type": "application/json",
139
- ...headers,
140
- ...hostHeader(fullUrl),
141
- Authorization: `Bearer ${apiKey}`
142
- }
143
- });
144
- if (response.status === 204) {
145
- return {};
146
- }
261
+ return trace(
262
+ `${method.toUpperCase()} ${path}`,
263
+ async ({ setAttributes }) => {
264
+ const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
265
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
266
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
267
+ setAttributes({
268
+ [TraceAttributes.HTTP_URL]: url,
269
+ [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
270
+ });
271
+ const response = await fetchImpl(url, {
272
+ method: method.toUpperCase(),
273
+ body: body ? JSON.stringify(body) : void 0,
274
+ headers: {
275
+ "Content-Type": "application/json",
276
+ "User-Agent": `Xata client-ts/${VERSION}`,
277
+ ...headers,
278
+ ...hostHeader(fullUrl),
279
+ Authorization: `Bearer ${apiKey}`
280
+ },
281
+ signal
282
+ });
283
+ if (response.status === 204) {
284
+ return {};
285
+ }
286
+ const { host, protocol } = parseUrl(response.url);
287
+ const requestId = response.headers?.get("x-request-id") ?? void 0;
288
+ setAttributes({
289
+ [TraceAttributes.KIND]: "http",
290
+ [TraceAttributes.HTTP_REQUEST_ID]: requestId,
291
+ [TraceAttributes.HTTP_STATUS_CODE]: response.status,
292
+ [TraceAttributes.HTTP_HOST]: host,
293
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
294
+ });
295
+ try {
296
+ const jsonResponse = await response.json();
297
+ if (response.ok) {
298
+ return jsonResponse;
299
+ }
300
+ throw new FetcherError(response.status, jsonResponse, requestId);
301
+ } catch (error) {
302
+ throw new FetcherError(response.status, error, requestId);
303
+ }
304
+ },
305
+ { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
306
+ );
307
+ }
308
+ function parseUrl(url) {
147
309
  try {
148
- const jsonResponse = await response.json();
149
- if (response.ok) {
150
- return jsonResponse;
151
- }
152
- throw new FetcherError(response.status, jsonResponse);
310
+ const { host, protocol } = new URL(url);
311
+ return { host, protocol };
153
312
  } catch (error) {
154
- throw new FetcherError(response.status, error);
313
+ return {};
155
314
  }
156
315
  }
157
316
 
158
- const getUser = (variables) => fetch$1({ url: "/user", method: "get", ...variables });
159
- const updateUser = (variables) => fetch$1({ url: "/user", method: "put", ...variables });
160
- const deleteUser = (variables) => fetch$1({ url: "/user", method: "delete", ...variables });
161
- const getUserAPIKeys = (variables) => fetch$1({
317
+ const getUser = (variables, signal) => fetch$1({ url: "/user", method: "get", ...variables, signal });
318
+ const updateUser = (variables, signal) => fetch$1({
319
+ url: "/user",
320
+ method: "put",
321
+ ...variables,
322
+ signal
323
+ });
324
+ const deleteUser = (variables, signal) => fetch$1({ url: "/user", method: "delete", ...variables, signal });
325
+ const getUserAPIKeys = (variables, signal) => fetch$1({
162
326
  url: "/user/keys",
163
327
  method: "get",
164
- ...variables
328
+ ...variables,
329
+ signal
165
330
  });
166
- const createUserAPIKey = (variables) => fetch$1({
331
+ const createUserAPIKey = (variables, signal) => fetch$1({
167
332
  url: "/user/keys/{keyName}",
168
333
  method: "post",
169
- ...variables
334
+ ...variables,
335
+ signal
170
336
  });
171
- const deleteUserAPIKey = (variables) => fetch$1({
337
+ const deleteUserAPIKey = (variables, signal) => fetch$1({
172
338
  url: "/user/keys/{keyName}",
173
339
  method: "delete",
174
- ...variables
340
+ ...variables,
341
+ signal
175
342
  });
176
- const createWorkspace = (variables) => fetch$1({
343
+ const createWorkspace = (variables, signal) => fetch$1({
177
344
  url: "/workspaces",
178
345
  method: "post",
179
- ...variables
346
+ ...variables,
347
+ signal
180
348
  });
181
- const getWorkspacesList = (variables) => fetch$1({
349
+ const getWorkspacesList = (variables, signal) => fetch$1({
182
350
  url: "/workspaces",
183
351
  method: "get",
184
- ...variables
352
+ ...variables,
353
+ signal
185
354
  });
186
- const getWorkspace = (variables) => fetch$1({
355
+ const getWorkspace = (variables, signal) => fetch$1({
187
356
  url: "/workspaces/{workspaceId}",
188
357
  method: "get",
189
- ...variables
358
+ ...variables,
359
+ signal
190
360
  });
191
- const updateWorkspace = (variables) => fetch$1({
361
+ const updateWorkspace = (variables, signal) => fetch$1({
192
362
  url: "/workspaces/{workspaceId}",
193
363
  method: "put",
194
- ...variables
364
+ ...variables,
365
+ signal
195
366
  });
196
- const deleteWorkspace = (variables) => fetch$1({
367
+ const deleteWorkspace = (variables, signal) => fetch$1({
197
368
  url: "/workspaces/{workspaceId}",
198
369
  method: "delete",
199
- ...variables
370
+ ...variables,
371
+ signal
200
372
  });
201
- const getWorkspaceMembersList = (variables) => fetch$1({
373
+ const getWorkspaceMembersList = (variables, signal) => fetch$1({
202
374
  url: "/workspaces/{workspaceId}/members",
203
375
  method: "get",
204
- ...variables
376
+ ...variables,
377
+ signal
205
378
  });
206
- const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
207
- const removeWorkspaceMember = (variables) => fetch$1({
379
+ const updateWorkspaceMemberRole = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
380
+ const removeWorkspaceMember = (variables, signal) => fetch$1({
208
381
  url: "/workspaces/{workspaceId}/members/{userId}",
209
382
  method: "delete",
210
- ...variables
383
+ ...variables,
384
+ signal
211
385
  });
212
- const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
213
- const cancelWorkspaceMemberInvite = (variables) => fetch$1({
386
+ const inviteWorkspaceMember = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
387
+ const updateWorkspaceMemberInvite = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
388
+ const cancelWorkspaceMemberInvite = (variables, signal) => fetch$1({
214
389
  url: "/workspaces/{workspaceId}/invites/{inviteId}",
215
390
  method: "delete",
216
- ...variables
391
+ ...variables,
392
+ signal
217
393
  });
218
- const resendWorkspaceMemberInvite = (variables) => fetch$1({
394
+ const resendWorkspaceMemberInvite = (variables, signal) => fetch$1({
219
395
  url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
220
396
  method: "post",
221
- ...variables
397
+ ...variables,
398
+ signal
222
399
  });
223
- const acceptWorkspaceMemberInvite = (variables) => fetch$1({
400
+ const acceptWorkspaceMemberInvite = (variables, signal) => fetch$1({
224
401
  url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
225
402
  method: "post",
226
- ...variables
403
+ ...variables,
404
+ signal
227
405
  });
228
- const getDatabaseList = (variables) => fetch$1({
406
+ const getDatabaseList = (variables, signal) => fetch$1({
229
407
  url: "/dbs",
230
408
  method: "get",
231
- ...variables
409
+ ...variables,
410
+ signal
232
411
  });
233
- const getBranchList = (variables) => fetch$1({
412
+ const getBranchList = (variables, signal) => fetch$1({
234
413
  url: "/dbs/{dbName}",
235
414
  method: "get",
236
- ...variables
415
+ ...variables,
416
+ signal
237
417
  });
238
- const createDatabase = (variables) => fetch$1({
418
+ const createDatabase = (variables, signal) => fetch$1({
239
419
  url: "/dbs/{dbName}",
240
420
  method: "put",
241
- ...variables
421
+ ...variables,
422
+ signal
242
423
  });
243
- const deleteDatabase = (variables) => fetch$1({
424
+ const deleteDatabase = (variables, signal) => fetch$1({
244
425
  url: "/dbs/{dbName}",
245
426
  method: "delete",
246
- ...variables
427
+ ...variables,
428
+ signal
247
429
  });
248
- const getBranchDetails = (variables) => fetch$1({
249
- url: "/db/{dbBranchName}",
430
+ const getDatabaseMetadata = (variables, signal) => fetch$1({
431
+ url: "/dbs/{dbName}/metadata",
432
+ method: "get",
433
+ ...variables,
434
+ signal
435
+ });
436
+ const updateDatabaseMetadata = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
437
+ const getGitBranchesMapping = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
438
+ const addGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
439
+ const removeGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
440
+ const resolveBranch = (variables, signal) => fetch$1({
441
+ url: "/dbs/{dbName}/resolveBranch",
250
442
  method: "get",
251
- ...variables
443
+ ...variables,
444
+ signal
252
445
  });
253
- const createBranch = (variables) => fetch$1({
446
+ const queryMigrationRequests = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
447
+ const createMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
448
+ const getMigrationRequest = (variables, signal) => fetch$1({
449
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
450
+ method: "get",
451
+ ...variables,
452
+ signal
453
+ });
454
+ const updateMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
455
+ const listMigrationRequestsCommits = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
456
+ const compareMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
457
+ const getMigrationRequestIsMerged = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
458
+ const mergeMigrationRequest = (variables, signal) => fetch$1({
459
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
460
+ method: "post",
461
+ ...variables,
462
+ signal
463
+ });
464
+ const getBranchDetails = (variables, signal) => fetch$1({
254
465
  url: "/db/{dbBranchName}",
255
- method: "put",
256
- ...variables
466
+ method: "get",
467
+ ...variables,
468
+ signal
257
469
  });
258
- const deleteBranch = (variables) => fetch$1({
470
+ const createBranch = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
471
+ const deleteBranch = (variables, signal) => fetch$1({
259
472
  url: "/db/{dbBranchName}",
260
473
  method: "delete",
261
- ...variables
474
+ ...variables,
475
+ signal
262
476
  });
263
- const updateBranchMetadata = (variables) => fetch$1({
477
+ const updateBranchMetadata = (variables, signal) => fetch$1({
264
478
  url: "/db/{dbBranchName}/metadata",
265
479
  method: "put",
266
- ...variables
480
+ ...variables,
481
+ signal
267
482
  });
268
- const getBranchMetadata = (variables) => fetch$1({
483
+ const getBranchMetadata = (variables, signal) => fetch$1({
269
484
  url: "/db/{dbBranchName}/metadata",
270
485
  method: "get",
271
- ...variables
486
+ ...variables,
487
+ signal
488
+ });
489
+ const getBranchMigrationHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
490
+ const executeBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
491
+ const getBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
492
+ const compareBranchWithUserSchema = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
493
+ const compareBranchSchemas = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
494
+ const updateBranchSchema = (variables, signal) => fetch$1({
495
+ url: "/db/{dbBranchName}/schema/update",
496
+ method: "post",
497
+ ...variables,
498
+ signal
272
499
  });
273
- const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
274
- const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
275
- const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
276
- const getBranchStats = (variables) => fetch$1({
500
+ const previewBranchSchemaEdit = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
501
+ const applyBranchSchemaEdit = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
502
+ const getBranchSchemaHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
503
+ const getBranchStats = (variables, signal) => fetch$1({
277
504
  url: "/db/{dbBranchName}/stats",
278
505
  method: "get",
279
- ...variables
506
+ ...variables,
507
+ signal
280
508
  });
281
- const createTable = (variables) => fetch$1({
509
+ const createTable = (variables, signal) => fetch$1({
282
510
  url: "/db/{dbBranchName}/tables/{tableName}",
283
511
  method: "put",
284
- ...variables
512
+ ...variables,
513
+ signal
285
514
  });
286
- const deleteTable = (variables) => fetch$1({
515
+ const deleteTable = (variables, signal) => fetch$1({
287
516
  url: "/db/{dbBranchName}/tables/{tableName}",
288
517
  method: "delete",
289
- ...variables
518
+ ...variables,
519
+ signal
290
520
  });
291
- const updateTable = (variables) => fetch$1({
521
+ const updateTable = (variables, signal) => fetch$1({
292
522
  url: "/db/{dbBranchName}/tables/{tableName}",
293
523
  method: "patch",
294
- ...variables
524
+ ...variables,
525
+ signal
295
526
  });
296
- const getTableSchema = (variables) => fetch$1({
527
+ const getTableSchema = (variables, signal) => fetch$1({
297
528
  url: "/db/{dbBranchName}/tables/{tableName}/schema",
298
529
  method: "get",
299
- ...variables
530
+ ...variables,
531
+ signal
300
532
  });
301
- const setTableSchema = (variables) => fetch$1({
533
+ const setTableSchema = (variables, signal) => fetch$1({
302
534
  url: "/db/{dbBranchName}/tables/{tableName}/schema",
303
535
  method: "put",
304
- ...variables
536
+ ...variables,
537
+ signal
305
538
  });
306
- const getTableColumns = (variables) => fetch$1({
539
+ const getTableColumns = (variables, signal) => fetch$1({
307
540
  url: "/db/{dbBranchName}/tables/{tableName}/columns",
308
541
  method: "get",
309
- ...variables
542
+ ...variables,
543
+ signal
310
544
  });
311
- const addTableColumn = (variables) => fetch$1({
545
+ const addTableColumn = (variables, signal) => fetch$1({
312
546
  url: "/db/{dbBranchName}/tables/{tableName}/columns",
313
547
  method: "post",
314
- ...variables
548
+ ...variables,
549
+ signal
315
550
  });
316
- const getColumn = (variables) => fetch$1({
551
+ const getColumn = (variables, signal) => fetch$1({
317
552
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
318
553
  method: "get",
319
- ...variables
554
+ ...variables,
555
+ signal
320
556
  });
321
- const deleteColumn = (variables) => fetch$1({
557
+ const deleteColumn = (variables, signal) => fetch$1({
322
558
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
323
559
  method: "delete",
324
- ...variables
560
+ ...variables,
561
+ signal
325
562
  });
326
- const updateColumn = (variables) => fetch$1({
563
+ const updateColumn = (variables, signal) => fetch$1({
327
564
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
328
565
  method: "patch",
329
- ...variables
566
+ ...variables,
567
+ signal
330
568
  });
331
- const insertRecord = (variables) => fetch$1({
332
- url: "/db/{dbBranchName}/tables/{tableName}/data",
333
- method: "post",
334
- ...variables
335
- });
336
- const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
337
- const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
338
- const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
339
- const deleteRecord = (variables) => fetch$1({
569
+ const insertRecord = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
570
+ const insertRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
571
+ const updateRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
572
+ const upsertRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
573
+ const deleteRecord = (variables, signal) => fetch$1({
340
574
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
341
575
  method: "delete",
342
- ...variables
576
+ ...variables,
577
+ signal
343
578
  });
344
- const getRecord = (variables) => fetch$1({
579
+ const getRecord = (variables, signal) => fetch$1({
345
580
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
346
581
  method: "get",
347
- ...variables
582
+ ...variables,
583
+ signal
348
584
  });
349
- const bulkInsertTableRecords = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables });
350
- const queryTable = (variables) => fetch$1({
585
+ const bulkInsertTableRecords = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
586
+ const queryTable = (variables, signal) => fetch$1({
351
587
  url: "/db/{dbBranchName}/tables/{tableName}/query",
352
588
  method: "post",
353
- ...variables
589
+ ...variables,
590
+ signal
591
+ });
592
+ const searchTable = (variables, signal) => fetch$1({
593
+ url: "/db/{dbBranchName}/tables/{tableName}/search",
594
+ method: "post",
595
+ ...variables,
596
+ signal
354
597
  });
355
- const searchBranch = (variables) => fetch$1({
598
+ const searchBranch = (variables, signal) => fetch$1({
356
599
  url: "/db/{dbBranchName}/search",
357
600
  method: "post",
358
- ...variables
601
+ ...variables,
602
+ signal
603
+ });
604
+ const summarizeTable = (variables, signal) => fetch$1({
605
+ url: "/db/{dbBranchName}/tables/{tableName}/summarize",
606
+ method: "post",
607
+ ...variables,
608
+ signal
359
609
  });
360
610
  const operationsByTag = {
361
611
  users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
@@ -369,11 +619,22 @@ const operationsByTag = {
369
619
  updateWorkspaceMemberRole,
370
620
  removeWorkspaceMember,
371
621
  inviteWorkspaceMember,
622
+ updateWorkspaceMemberInvite,
372
623
  cancelWorkspaceMemberInvite,
373
624
  resendWorkspaceMemberInvite,
374
625
  acceptWorkspaceMemberInvite
375
626
  },
376
- database: { getDatabaseList, createDatabase, deleteDatabase },
627
+ database: {
628
+ getDatabaseList,
629
+ createDatabase,
630
+ deleteDatabase,
631
+ getDatabaseMetadata,
632
+ updateDatabaseMetadata,
633
+ getGitBranchesMapping,
634
+ addGitBranchesEntry,
635
+ removeGitBranchesEntry,
636
+ resolveBranch
637
+ },
377
638
  branch: {
378
639
  getBranchList,
379
640
  getBranchDetails,
@@ -381,10 +642,28 @@ const operationsByTag = {
381
642
  deleteBranch,
382
643
  updateBranchMetadata,
383
644
  getBranchMetadata,
645
+ getBranchStats
646
+ },
647
+ migrationRequests: {
648
+ queryMigrationRequests,
649
+ createMigrationRequest,
650
+ getMigrationRequest,
651
+ updateMigrationRequest,
652
+ listMigrationRequestsCommits,
653
+ compareMigrationRequest,
654
+ getMigrationRequestIsMerged,
655
+ mergeMigrationRequest
656
+ },
657
+ branchSchema: {
384
658
  getBranchMigrationHistory,
385
659
  executeBranchMigrationPlan,
386
660
  getBranchMigrationPlan,
387
- getBranchStats
661
+ compareBranchWithUserSchema,
662
+ compareBranchSchemas,
663
+ updateBranchSchema,
664
+ previewBranchSchemaEdit,
665
+ applyBranchSchemaEdit,
666
+ getBranchSchemaHistory
388
667
  },
389
668
  table: {
390
669
  createTable,
@@ -407,14 +686,16 @@ const operationsByTag = {
407
686
  getRecord,
408
687
  bulkInsertTableRecords,
409
688
  queryTable,
410
- searchBranch
689
+ searchTable,
690
+ searchBranch,
691
+ summarizeTable
411
692
  }
412
693
  };
413
694
 
414
695
  function getHostUrl(provider, type) {
415
- if (isValidAlias(provider)) {
696
+ if (isHostProviderAlias(provider)) {
416
697
  return providers[provider][type];
417
- } else if (isValidBuilder(provider)) {
698
+ } else if (isHostProviderBuilder(provider)) {
418
699
  return provider[type];
419
700
  }
420
701
  throw new Error("Invalid API provider");
@@ -429,77 +710,98 @@ const providers = {
429
710
  workspaces: "https://{workspaceId}.staging.xatabase.co"
430
711
  }
431
712
  };
432
- function isValidAlias(alias) {
713
+ function isHostProviderAlias(alias) {
433
714
  return isString(alias) && Object.keys(providers).includes(alias);
434
715
  }
435
- function isValidBuilder(builder) {
716
+ function isHostProviderBuilder(builder) {
436
717
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
437
718
  }
719
+ function parseProviderString(provider = "production") {
720
+ if (isHostProviderAlias(provider)) {
721
+ return provider;
722
+ }
723
+ const [main, workspaces] = provider.split(",");
724
+ if (!main || !workspaces)
725
+ return null;
726
+ return { main, workspaces };
727
+ }
438
728
 
439
- var __accessCheck$6 = (obj, member, msg) => {
729
+ var __accessCheck$7 = (obj, member, msg) => {
440
730
  if (!member.has(obj))
441
731
  throw TypeError("Cannot " + msg);
442
732
  };
443
- var __privateGet$5 = (obj, member, getter) => {
444
- __accessCheck$6(obj, member, "read from private field");
733
+ var __privateGet$7 = (obj, member, getter) => {
734
+ __accessCheck$7(obj, member, "read from private field");
445
735
  return getter ? getter.call(obj) : member.get(obj);
446
736
  };
447
- var __privateAdd$6 = (obj, member, value) => {
737
+ var __privateAdd$7 = (obj, member, value) => {
448
738
  if (member.has(obj))
449
739
  throw TypeError("Cannot add the same private member more than once");
450
740
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
451
741
  };
452
- var __privateSet$4 = (obj, member, value, setter) => {
453
- __accessCheck$6(obj, member, "write to private field");
742
+ var __privateSet$7 = (obj, member, value, setter) => {
743
+ __accessCheck$7(obj, member, "write to private field");
454
744
  setter ? setter.call(obj, value) : member.set(obj, value);
455
745
  return value;
456
746
  };
457
747
  var _extraProps, _namespaces;
458
748
  class XataApiClient {
459
749
  constructor(options = {}) {
460
- __privateAdd$6(this, _extraProps, void 0);
461
- __privateAdd$6(this, _namespaces, {});
750
+ __privateAdd$7(this, _extraProps, void 0);
751
+ __privateAdd$7(this, _namespaces, {});
462
752
  const provider = options.host ?? "production";
463
- const apiKey = options?.apiKey ?? getAPIKey();
753
+ const apiKey = options.apiKey ?? getAPIKey();
754
+ const trace = options.trace ?? defaultTrace;
464
755
  if (!apiKey) {
465
756
  throw new Error("Could not resolve a valid apiKey");
466
757
  }
467
- __privateSet$4(this, _extraProps, {
758
+ __privateSet$7(this, _extraProps, {
468
759
  apiUrl: getHostUrl(provider, "main"),
469
760
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
470
761
  fetchImpl: getFetchImplementation(options.fetch),
471
- apiKey
762
+ apiKey,
763
+ trace
472
764
  });
473
765
  }
474
766
  get user() {
475
- if (!__privateGet$5(this, _namespaces).user)
476
- __privateGet$5(this, _namespaces).user = new UserApi(__privateGet$5(this, _extraProps));
477
- return __privateGet$5(this, _namespaces).user;
767
+ if (!__privateGet$7(this, _namespaces).user)
768
+ __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
769
+ return __privateGet$7(this, _namespaces).user;
478
770
  }
479
771
  get workspaces() {
480
- if (!__privateGet$5(this, _namespaces).workspaces)
481
- __privateGet$5(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$5(this, _extraProps));
482
- return __privateGet$5(this, _namespaces).workspaces;
772
+ if (!__privateGet$7(this, _namespaces).workspaces)
773
+ __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
774
+ return __privateGet$7(this, _namespaces).workspaces;
483
775
  }
484
776
  get databases() {
485
- if (!__privateGet$5(this, _namespaces).databases)
486
- __privateGet$5(this, _namespaces).databases = new DatabaseApi(__privateGet$5(this, _extraProps));
487
- return __privateGet$5(this, _namespaces).databases;
777
+ if (!__privateGet$7(this, _namespaces).databases)
778
+ __privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
779
+ return __privateGet$7(this, _namespaces).databases;
488
780
  }
489
781
  get branches() {
490
- if (!__privateGet$5(this, _namespaces).branches)
491
- __privateGet$5(this, _namespaces).branches = new BranchApi(__privateGet$5(this, _extraProps));
492
- return __privateGet$5(this, _namespaces).branches;
782
+ if (!__privateGet$7(this, _namespaces).branches)
783
+ __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
784
+ return __privateGet$7(this, _namespaces).branches;
493
785
  }
494
786
  get tables() {
495
- if (!__privateGet$5(this, _namespaces).tables)
496
- __privateGet$5(this, _namespaces).tables = new TableApi(__privateGet$5(this, _extraProps));
497
- return __privateGet$5(this, _namespaces).tables;
787
+ if (!__privateGet$7(this, _namespaces).tables)
788
+ __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
789
+ return __privateGet$7(this, _namespaces).tables;
498
790
  }
499
791
  get records() {
500
- if (!__privateGet$5(this, _namespaces).records)
501
- __privateGet$5(this, _namespaces).records = new RecordsApi(__privateGet$5(this, _extraProps));
502
- return __privateGet$5(this, _namespaces).records;
792
+ if (!__privateGet$7(this, _namespaces).records)
793
+ __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
794
+ return __privateGet$7(this, _namespaces).records;
795
+ }
796
+ get migrationRequests() {
797
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
798
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
799
+ return __privateGet$7(this, _namespaces).migrationRequests;
800
+ }
801
+ get branchSchema() {
802
+ if (!__privateGet$7(this, _namespaces).branchSchema)
803
+ __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
804
+ return __privateGet$7(this, _namespaces).branchSchema;
503
805
  }
504
806
  }
505
807
  _extraProps = new WeakMap();
@@ -591,6 +893,13 @@ class WorkspaceApi {
591
893
  ...this.extraProps
592
894
  });
593
895
  }
896
+ updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
897
+ return operationsByTag.workspaces.updateWorkspaceMemberInvite({
898
+ pathParams: { workspaceId, inviteId },
899
+ body: { role },
900
+ ...this.extraProps
901
+ });
902
+ }
594
903
  cancelWorkspaceMemberInvite(workspaceId, inviteId) {
595
904
  return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
596
905
  pathParams: { workspaceId, inviteId },
@@ -633,6 +942,46 @@ class DatabaseApi {
633
942
  ...this.extraProps
634
943
  });
635
944
  }
945
+ getDatabaseMetadata(workspace, dbName) {
946
+ return operationsByTag.database.getDatabaseMetadata({
947
+ pathParams: { workspace, dbName },
948
+ ...this.extraProps
949
+ });
950
+ }
951
+ updateDatabaseMetadata(workspace, dbName, options = {}) {
952
+ return operationsByTag.database.updateDatabaseMetadata({
953
+ pathParams: { workspace, dbName },
954
+ body: options,
955
+ ...this.extraProps
956
+ });
957
+ }
958
+ getGitBranchesMapping(workspace, dbName) {
959
+ return operationsByTag.database.getGitBranchesMapping({
960
+ pathParams: { workspace, dbName },
961
+ ...this.extraProps
962
+ });
963
+ }
964
+ addGitBranchesEntry(workspace, dbName, body) {
965
+ return operationsByTag.database.addGitBranchesEntry({
966
+ pathParams: { workspace, dbName },
967
+ body,
968
+ ...this.extraProps
969
+ });
970
+ }
971
+ removeGitBranchesEntry(workspace, dbName, gitBranch) {
972
+ return operationsByTag.database.removeGitBranchesEntry({
973
+ pathParams: { workspace, dbName },
974
+ queryParams: { gitBranch },
975
+ ...this.extraProps
976
+ });
977
+ }
978
+ resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
979
+ return operationsByTag.database.resolveBranch({
980
+ pathParams: { workspace, dbName },
981
+ queryParams: { gitBranch, fallbackBranch },
982
+ ...this.extraProps
983
+ });
984
+ }
636
985
  }
637
986
  class BranchApi {
638
987
  constructor(extraProps) {
@@ -650,10 +999,10 @@ class BranchApi {
650
999
  ...this.extraProps
651
1000
  });
652
1001
  }
653
- createBranch(workspace, database, branch, from = "", options = {}) {
1002
+ createBranch(workspace, database, branch, from, options = {}) {
654
1003
  return operationsByTag.branch.createBranch({
655
1004
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
656
- queryParams: { from },
1005
+ queryParams: isString(from) ? { from } : void 0,
657
1006
  body: options,
658
1007
  ...this.extraProps
659
1008
  });
@@ -677,27 +1026,6 @@ class BranchApi {
677
1026
  ...this.extraProps
678
1027
  });
679
1028
  }
680
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
681
- return operationsByTag.branch.getBranchMigrationHistory({
682
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
683
- body: options,
684
- ...this.extraProps
685
- });
686
- }
687
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
688
- return operationsByTag.branch.executeBranchMigrationPlan({
689
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
690
- body: migrationPlan,
691
- ...this.extraProps
692
- });
693
- }
694
- getBranchMigrationPlan(workspace, database, branch, schema) {
695
- return operationsByTag.branch.getBranchMigrationPlan({
696
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
697
- body: schema,
698
- ...this.extraProps
699
- });
700
- }
701
1029
  getBranchStats(workspace, database, branch) {
702
1030
  return operationsByTag.branch.getBranchStats({
703
1031
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
@@ -778,9 +1106,10 @@ class RecordsApi {
778
1106
  constructor(extraProps) {
779
1107
  this.extraProps = extraProps;
780
1108
  }
781
- insertRecord(workspace, database, branch, tableName, record) {
1109
+ insertRecord(workspace, database, branch, tableName, record, options = {}) {
782
1110
  return operationsByTag.records.insertRecord({
783
1111
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1112
+ queryParams: options,
784
1113
  body: record,
785
1114
  ...this.extraProps
786
1115
  });
@@ -809,21 +1138,24 @@ class RecordsApi {
809
1138
  ...this.extraProps
810
1139
  });
811
1140
  }
812
- deleteRecord(workspace, database, branch, tableName, recordId) {
1141
+ deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
813
1142
  return operationsByTag.records.deleteRecord({
814
1143
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1144
+ queryParams: options,
815
1145
  ...this.extraProps
816
1146
  });
817
1147
  }
818
1148
  getRecord(workspace, database, branch, tableName, recordId, options = {}) {
819
1149
  return operationsByTag.records.getRecord({
820
1150
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1151
+ queryParams: options,
821
1152
  ...this.extraProps
822
1153
  });
823
1154
  }
824
- bulkInsertTableRecords(workspace, database, branch, tableName, records) {
1155
+ bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
825
1156
  return operationsByTag.records.bulkInsertTableRecords({
826
1157
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1158
+ queryParams: options,
827
1159
  body: { records },
828
1160
  ...this.extraProps
829
1161
  });
@@ -835,6 +1167,13 @@ class RecordsApi {
835
1167
  ...this.extraProps
836
1168
  });
837
1169
  }
1170
+ searchTable(workspace, database, branch, tableName, query) {
1171
+ return operationsByTag.records.searchTable({
1172
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1173
+ body: query,
1174
+ ...this.extraProps
1175
+ });
1176
+ }
838
1177
  searchBranch(workspace, database, branch, query) {
839
1178
  return operationsByTag.records.searchBranch({
840
1179
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
@@ -842,6 +1181,138 @@ class RecordsApi {
842
1181
  ...this.extraProps
843
1182
  });
844
1183
  }
1184
+ summarizeTable(workspace, database, branch, tableName, query) {
1185
+ return operationsByTag.records.summarizeTable({
1186
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1187
+ body: query,
1188
+ ...this.extraProps
1189
+ });
1190
+ }
1191
+ }
1192
+ class MigrationRequestsApi {
1193
+ constructor(extraProps) {
1194
+ this.extraProps = extraProps;
1195
+ }
1196
+ queryMigrationRequests(workspace, database, options = {}) {
1197
+ return operationsByTag.migrationRequests.queryMigrationRequests({
1198
+ pathParams: { workspace, dbName: database },
1199
+ body: options,
1200
+ ...this.extraProps
1201
+ });
1202
+ }
1203
+ createMigrationRequest(workspace, database, options) {
1204
+ return operationsByTag.migrationRequests.createMigrationRequest({
1205
+ pathParams: { workspace, dbName: database },
1206
+ body: options,
1207
+ ...this.extraProps
1208
+ });
1209
+ }
1210
+ getMigrationRequest(workspace, database, migrationRequest) {
1211
+ return operationsByTag.migrationRequests.getMigrationRequest({
1212
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1213
+ ...this.extraProps
1214
+ });
1215
+ }
1216
+ updateMigrationRequest(workspace, database, migrationRequest, options) {
1217
+ return operationsByTag.migrationRequests.updateMigrationRequest({
1218
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1219
+ body: options,
1220
+ ...this.extraProps
1221
+ });
1222
+ }
1223
+ listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1224
+ return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1225
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1226
+ body: options,
1227
+ ...this.extraProps
1228
+ });
1229
+ }
1230
+ compareMigrationRequest(workspace, database, migrationRequest) {
1231
+ return operationsByTag.migrationRequests.compareMigrationRequest({
1232
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1233
+ ...this.extraProps
1234
+ });
1235
+ }
1236
+ getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1237
+ return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1238
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1239
+ ...this.extraProps
1240
+ });
1241
+ }
1242
+ mergeMigrationRequest(workspace, database, migrationRequest) {
1243
+ return operationsByTag.migrationRequests.mergeMigrationRequest({
1244
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1245
+ ...this.extraProps
1246
+ });
1247
+ }
1248
+ }
1249
+ class BranchSchemaApi {
1250
+ constructor(extraProps) {
1251
+ this.extraProps = extraProps;
1252
+ }
1253
+ getBranchMigrationHistory(workspace, database, branch, options = {}) {
1254
+ return operationsByTag.branchSchema.getBranchMigrationHistory({
1255
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1256
+ body: options,
1257
+ ...this.extraProps
1258
+ });
1259
+ }
1260
+ executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1261
+ return operationsByTag.branchSchema.executeBranchMigrationPlan({
1262
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1263
+ body: migrationPlan,
1264
+ ...this.extraProps
1265
+ });
1266
+ }
1267
+ getBranchMigrationPlan(workspace, database, branch, schema) {
1268
+ return operationsByTag.branchSchema.getBranchMigrationPlan({
1269
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1270
+ body: schema,
1271
+ ...this.extraProps
1272
+ });
1273
+ }
1274
+ compareBranchWithUserSchema(workspace, database, branch, schema) {
1275
+ return operationsByTag.branchSchema.compareBranchWithUserSchema({
1276
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1277
+ body: { schema },
1278
+ ...this.extraProps
1279
+ });
1280
+ }
1281
+ compareBranchSchemas(workspace, database, branch, branchName, schema) {
1282
+ return operationsByTag.branchSchema.compareBranchSchemas({
1283
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1284
+ body: { schema },
1285
+ ...this.extraProps
1286
+ });
1287
+ }
1288
+ updateBranchSchema(workspace, database, branch, migration) {
1289
+ return operationsByTag.branchSchema.updateBranchSchema({
1290
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1291
+ body: migration,
1292
+ ...this.extraProps
1293
+ });
1294
+ }
1295
+ previewBranchSchemaEdit(workspace, database, branch, migration) {
1296
+ return operationsByTag.branchSchema.previewBranchSchemaEdit({
1297
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1298
+ body: migration,
1299
+ ...this.extraProps
1300
+ });
1301
+ }
1302
+ applyBranchSchemaEdit(workspace, database, branch, edits) {
1303
+ return operationsByTag.branchSchema.applyBranchSchemaEdit({
1304
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1305
+ body: { edits },
1306
+ ...this.extraProps
1307
+ });
1308
+ }
1309
+ getBranchSchemaHistory(workspace, database, branch, options = {}) {
1310
+ return operationsByTag.branchSchema.getBranchSchemaHistory({
1311
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1312
+ body: options,
1313
+ ...this.extraProps
1314
+ });
1315
+ }
845
1316
  }
846
1317
 
847
1318
  class XataApiPlugin {
@@ -854,43 +1325,43 @@ class XataApiPlugin {
854
1325
  class XataPlugin {
855
1326
  }
856
1327
 
857
- var __accessCheck$5 = (obj, member, msg) => {
1328
+ var __accessCheck$6 = (obj, member, msg) => {
858
1329
  if (!member.has(obj))
859
1330
  throw TypeError("Cannot " + msg);
860
1331
  };
861
- var __privateGet$4 = (obj, member, getter) => {
862
- __accessCheck$5(obj, member, "read from private field");
1332
+ var __privateGet$6 = (obj, member, getter) => {
1333
+ __accessCheck$6(obj, member, "read from private field");
863
1334
  return getter ? getter.call(obj) : member.get(obj);
864
1335
  };
865
- var __privateAdd$5 = (obj, member, value) => {
1336
+ var __privateAdd$6 = (obj, member, value) => {
866
1337
  if (member.has(obj))
867
1338
  throw TypeError("Cannot add the same private member more than once");
868
1339
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
869
1340
  };
870
- var __privateSet$3 = (obj, member, value, setter) => {
871
- __accessCheck$5(obj, member, "write to private field");
1341
+ var __privateSet$6 = (obj, member, value, setter) => {
1342
+ __accessCheck$6(obj, member, "write to private field");
872
1343
  setter ? setter.call(obj, value) : member.set(obj, value);
873
1344
  return value;
874
1345
  };
875
- var _query;
1346
+ var _query, _page;
876
1347
  class Page {
877
1348
  constructor(query, meta, records = []) {
878
- __privateAdd$5(this, _query, void 0);
879
- __privateSet$3(this, _query, query);
1349
+ __privateAdd$6(this, _query, void 0);
1350
+ __privateSet$6(this, _query, query);
880
1351
  this.meta = meta;
881
- this.records = records;
1352
+ this.records = new RecordArray(this, records);
882
1353
  }
883
1354
  async nextPage(size, offset) {
884
- return __privateGet$4(this, _query).getPaginated({ page: { size, offset, after: this.meta.page.cursor } });
1355
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
885
1356
  }
886
1357
  async previousPage(size, offset) {
887
- return __privateGet$4(this, _query).getPaginated({ page: { size, offset, before: this.meta.page.cursor } });
1358
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
888
1359
  }
889
1360
  async firstPage(size, offset) {
890
- return __privateGet$4(this, _query).getPaginated({ page: { size, offset, first: this.meta.page.cursor } });
1361
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
891
1362
  }
892
1363
  async lastPage(size, offset) {
893
- return __privateGet$4(this, _query).getPaginated({ page: { size, offset, last: this.meta.page.cursor } });
1364
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
894
1365
  }
895
1366
  hasNextPage() {
896
1367
  return this.meta.page.more;
@@ -898,50 +1369,104 @@ class Page {
898
1369
  }
899
1370
  _query = new WeakMap();
900
1371
  const PAGINATION_MAX_SIZE = 200;
901
- const PAGINATION_DEFAULT_SIZE = 200;
1372
+ const PAGINATION_DEFAULT_SIZE = 20;
902
1373
  const PAGINATION_MAX_OFFSET = 800;
903
1374
  const PAGINATION_DEFAULT_OFFSET = 0;
1375
+ function isCursorPaginationOptions(options) {
1376
+ return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
1377
+ }
1378
+ const _RecordArray = class extends Array {
1379
+ constructor(...args) {
1380
+ super(..._RecordArray.parseConstructorParams(...args));
1381
+ __privateAdd$6(this, _page, void 0);
1382
+ __privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
1383
+ }
1384
+ static parseConstructorParams(...args) {
1385
+ if (args.length === 1 && typeof args[0] === "number") {
1386
+ return new Array(args[0]);
1387
+ }
1388
+ if (args.length <= 2 && isObject(args[0]?.meta) && Array.isArray(args[1] ?? [])) {
1389
+ const result = args[1] ?? args[0].records ?? [];
1390
+ return new Array(...result);
1391
+ }
1392
+ return new Array(...args);
1393
+ }
1394
+ toArray() {
1395
+ return new Array(...this);
1396
+ }
1397
+ map(callbackfn, thisArg) {
1398
+ return this.toArray().map(callbackfn, thisArg);
1399
+ }
1400
+ async nextPage(size, offset) {
1401
+ const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
1402
+ return new _RecordArray(newPage);
1403
+ }
1404
+ async previousPage(size, offset) {
1405
+ const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
1406
+ return new _RecordArray(newPage);
1407
+ }
1408
+ async firstPage(size, offset) {
1409
+ const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
1410
+ return new _RecordArray(newPage);
1411
+ }
1412
+ async lastPage(size, offset) {
1413
+ const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
1414
+ return new _RecordArray(newPage);
1415
+ }
1416
+ hasNextPage() {
1417
+ return __privateGet$6(this, _page).meta.page.more;
1418
+ }
1419
+ };
1420
+ let RecordArray = _RecordArray;
1421
+ _page = new WeakMap();
904
1422
 
905
- var __accessCheck$4 = (obj, member, msg) => {
1423
+ var __accessCheck$5 = (obj, member, msg) => {
906
1424
  if (!member.has(obj))
907
1425
  throw TypeError("Cannot " + msg);
908
1426
  };
909
- var __privateGet$3 = (obj, member, getter) => {
910
- __accessCheck$4(obj, member, "read from private field");
1427
+ var __privateGet$5 = (obj, member, getter) => {
1428
+ __accessCheck$5(obj, member, "read from private field");
911
1429
  return getter ? getter.call(obj) : member.get(obj);
912
1430
  };
913
- var __privateAdd$4 = (obj, member, value) => {
1431
+ var __privateAdd$5 = (obj, member, value) => {
914
1432
  if (member.has(obj))
915
1433
  throw TypeError("Cannot add the same private member more than once");
916
1434
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
917
1435
  };
918
- var __privateSet$2 = (obj, member, value, setter) => {
919
- __accessCheck$4(obj, member, "write to private field");
1436
+ var __privateSet$5 = (obj, member, value, setter) => {
1437
+ __accessCheck$5(obj, member, "write to private field");
920
1438
  setter ? setter.call(obj, value) : member.set(obj, value);
921
1439
  return value;
922
1440
  };
923
- var _table$1, _repository, _data;
1441
+ var __privateMethod$3 = (obj, member, method) => {
1442
+ __accessCheck$5(obj, member, "access private method");
1443
+ return method;
1444
+ };
1445
+ var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
924
1446
  const _Query = class {
925
- constructor(repository, table, data, parent) {
926
- __privateAdd$4(this, _table$1, void 0);
927
- __privateAdd$4(this, _repository, void 0);
928
- __privateAdd$4(this, _data, { filter: {} });
1447
+ constructor(repository, table, data, rawParent) {
1448
+ __privateAdd$5(this, _cleanFilterConstraint);
1449
+ __privateAdd$5(this, _table$1, void 0);
1450
+ __privateAdd$5(this, _repository, void 0);
1451
+ __privateAdd$5(this, _data, { filter: {} });
929
1452
  this.meta = { page: { cursor: "start", more: true } };
930
- this.records = [];
931
- __privateSet$2(this, _table$1, table);
1453
+ this.records = new RecordArray(this, []);
1454
+ __privateSet$5(this, _table$1, table);
932
1455
  if (repository) {
933
- __privateSet$2(this, _repository, repository);
1456
+ __privateSet$5(this, _repository, repository);
934
1457
  } else {
935
- __privateSet$2(this, _repository, this);
1458
+ __privateSet$5(this, _repository, this);
936
1459
  }
937
- __privateGet$3(this, _data).filter = data.filter ?? parent?.filter ?? {};
938
- __privateGet$3(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
939
- __privateGet$3(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
940
- __privateGet$3(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
941
- __privateGet$3(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
942
- __privateGet$3(this, _data).sort = data.sort ?? parent?.sort;
943
- __privateGet$3(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
944
- __privateGet$3(this, _data).page = data.page ?? parent?.page;
1460
+ const parent = cleanParent(data, rawParent);
1461
+ __privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
1462
+ __privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
1463
+ __privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
1464
+ __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
1465
+ __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
1466
+ __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
1467
+ __privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
1468
+ __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
1469
+ __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
945
1470
  this.any = this.any.bind(this);
946
1471
  this.all = this.all.bind(this);
947
1472
  this.not = this.not.bind(this);
@@ -952,75 +1477,111 @@ const _Query = class {
952
1477
  Object.defineProperty(this, "repository", { enumerable: false });
953
1478
  }
954
1479
  getQueryOptions() {
955
- return __privateGet$3(this, _data);
1480
+ return __privateGet$5(this, _data);
1481
+ }
1482
+ key() {
1483
+ const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$5(this, _data);
1484
+ const key = JSON.stringify({ columns, filter, sort, pagination });
1485
+ return toBase64(key);
956
1486
  }
957
1487
  any(...queries) {
958
1488
  const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
959
- return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $any } }, __privateGet$3(this, _data));
1489
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
960
1490
  }
961
1491
  all(...queries) {
962
1492
  const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
963
- return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $all } }, __privateGet$3(this, _data));
1493
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
964
1494
  }
965
1495
  not(...queries) {
966
1496
  const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
967
- return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $not } }, __privateGet$3(this, _data));
1497
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
968
1498
  }
969
1499
  none(...queries) {
970
1500
  const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
971
- return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $none } }, __privateGet$3(this, _data));
1501
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
972
1502
  }
973
1503
  filter(a, b) {
974
1504
  if (arguments.length === 1) {
975
- const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
976
- const $all = compact([__privateGet$3(this, _data).filter?.$all].flat().concat(constraints));
977
- return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $all } }, __privateGet$3(this, _data));
1505
+ const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
1506
+ [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
1507
+ }));
1508
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1509
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
978
1510
  } else {
979
- const $all = compact([__privateGet$3(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
980
- return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $all } }, __privateGet$3(this, _data));
1511
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
1512
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1513
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
981
1514
  }
982
1515
  }
983
- sort(column, direction) {
984
- const originalSort = [__privateGet$3(this, _data).sort ?? []].flat();
1516
+ sort(column, direction = "asc") {
1517
+ const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
985
1518
  const sort = [...originalSort, { column, direction }];
986
- return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { sort }, __privateGet$3(this, _data));
1519
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
987
1520
  }
988
1521
  select(columns) {
989
- return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { columns }, __privateGet$3(this, _data));
1522
+ return new _Query(
1523
+ __privateGet$5(this, _repository),
1524
+ __privateGet$5(this, _table$1),
1525
+ { columns },
1526
+ __privateGet$5(this, _data)
1527
+ );
990
1528
  }
991
1529
  getPaginated(options = {}) {
992
- const query = new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), options, __privateGet$3(this, _data));
993
- return __privateGet$3(this, _repository).query(query);
1530
+ const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
1531
+ return __privateGet$5(this, _repository).query(query);
994
1532
  }
995
1533
  async *[Symbol.asyncIterator]() {
996
- for await (const [record] of this.getIterator(1)) {
1534
+ for await (const [record] of this.getIterator({ batchSize: 1 })) {
997
1535
  yield record;
998
1536
  }
999
1537
  }
1000
- async *getIterator(chunk, options = {}) {
1001
- let offset = 0;
1002
- let end = false;
1003
- while (!end) {
1004
- const { records, meta } = await this.getPaginated({ ...options, page: { size: chunk, offset } });
1005
- yield records;
1006
- offset += chunk;
1007
- end = !meta.page.more;
1538
+ async *getIterator(options = {}) {
1539
+ const { batchSize = 1 } = options;
1540
+ let page = await this.getPaginated({ ...options, pagination: { size: batchSize, offset: 0 } });
1541
+ let more = page.hasNextPage();
1542
+ yield page.records;
1543
+ while (more) {
1544
+ page = await page.nextPage();
1545
+ more = page.hasNextPage();
1546
+ yield page.records;
1008
1547
  }
1009
1548
  }
1010
1549
  async getMany(options = {}) {
1011
- const { records } = await this.getPaginated(options);
1012
- return records;
1550
+ const { pagination = {}, ...rest } = options;
1551
+ const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
1552
+ const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
1553
+ let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
1554
+ const results = [...page.records];
1555
+ while (page.hasNextPage() && results.length < size) {
1556
+ page = await page.nextPage();
1557
+ results.push(...page.records);
1558
+ }
1559
+ if (page.hasNextPage() && options.pagination?.size === void 0) {
1560
+ console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
1561
+ }
1562
+ const array = new RecordArray(page, results.slice(0, size));
1563
+ return array;
1013
1564
  }
1014
- async getAll(chunk = PAGINATION_MAX_SIZE, options = {}) {
1565
+ async getAll(options = {}) {
1566
+ const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
1015
1567
  const results = [];
1016
- for await (const page of this.getIterator(chunk, options)) {
1568
+ for await (const page of this.getIterator({ ...rest, batchSize })) {
1017
1569
  results.push(...page);
1018
1570
  }
1019
1571
  return results;
1020
1572
  }
1021
- async getOne(options = {}) {
1022
- const records = await this.getMany({ ...options, page: { size: 1 } });
1023
- return records[0] || null;
1573
+ async getFirst(options = {}) {
1574
+ const records = await this.getMany({ ...options, pagination: { size: 1 } });
1575
+ return records[0] ?? null;
1576
+ }
1577
+ async getFirstOrThrow(options = {}) {
1578
+ const records = await this.getMany({ ...options, pagination: { size: 1 } });
1579
+ if (records[0] === void 0)
1580
+ throw new Error("No results found.");
1581
+ return records[0];
1582
+ }
1583
+ cache(ttl) {
1584
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1024
1585
  }
1025
1586
  nextPage(size, offset) {
1026
1587
  return this.firstPage(size, offset);
@@ -1029,10 +1590,10 @@ const _Query = class {
1029
1590
  return this.firstPage(size, offset);
1030
1591
  }
1031
1592
  firstPage(size, offset) {
1032
- return this.getPaginated({ page: { size, offset } });
1593
+ return this.getPaginated({ pagination: { size, offset } });
1033
1594
  }
1034
1595
  lastPage(size, offset) {
1035
- return this.getPaginated({ page: { size, offset, before: "end" } });
1596
+ return this.getPaginated({ pagination: { size, offset, before: "end" } });
1036
1597
  }
1037
1598
  hasNextPage() {
1038
1599
  return this.meta.page.more;
@@ -1042,12 +1603,31 @@ let Query = _Query;
1042
1603
  _table$1 = new WeakMap();
1043
1604
  _repository = new WeakMap();
1044
1605
  _data = new WeakMap();
1606
+ _cleanFilterConstraint = new WeakSet();
1607
+ cleanFilterConstraint_fn = function(column, value) {
1608
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
1609
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
1610
+ return { $includes: value };
1611
+ }
1612
+ if (columnType === "link" && isObject(value) && isString(value.id)) {
1613
+ return value.id;
1614
+ }
1615
+ return value;
1616
+ };
1617
+ function cleanParent(data, parent) {
1618
+ if (isCursorPaginationOptions(data.pagination)) {
1619
+ return { ...parent, sorting: void 0, filter: void 0 };
1620
+ }
1621
+ return parent;
1622
+ }
1045
1623
 
1046
1624
  function isIdentifiable(x) {
1047
1625
  return isObject(x) && isString(x?.id);
1048
1626
  }
1049
1627
  function isXataRecord(x) {
1050
- return isIdentifiable(x) && typeof x?.xata === "object" && typeof x?.xata?.version === "number";
1628
+ const record = x;
1629
+ const metadata = record?.getMetadata();
1630
+ return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
1051
1631
  }
1052
1632
 
1053
1633
  function isSortFilterString(value) {
@@ -1073,249 +1653,434 @@ function buildSortFilter(filter) {
1073
1653
  }
1074
1654
  }
1075
1655
 
1076
- var __accessCheck$3 = (obj, member, msg) => {
1656
+ var __accessCheck$4 = (obj, member, msg) => {
1077
1657
  if (!member.has(obj))
1078
1658
  throw TypeError("Cannot " + msg);
1079
1659
  };
1080
- var __privateGet$2 = (obj, member, getter) => {
1081
- __accessCheck$3(obj, member, "read from private field");
1660
+ var __privateGet$4 = (obj, member, getter) => {
1661
+ __accessCheck$4(obj, member, "read from private field");
1082
1662
  return getter ? getter.call(obj) : member.get(obj);
1083
1663
  };
1084
- var __privateAdd$3 = (obj, member, value) => {
1664
+ var __privateAdd$4 = (obj, member, value) => {
1085
1665
  if (member.has(obj))
1086
1666
  throw TypeError("Cannot add the same private member more than once");
1087
1667
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1088
1668
  };
1089
- var __privateSet$1 = (obj, member, value, setter) => {
1090
- __accessCheck$3(obj, member, "write to private field");
1669
+ var __privateSet$4 = (obj, member, value, setter) => {
1670
+ __accessCheck$4(obj, member, "write to private field");
1091
1671
  setter ? setter.call(obj, value) : member.set(obj, value);
1092
1672
  return value;
1093
1673
  };
1094
1674
  var __privateMethod$2 = (obj, member, method) => {
1095
- __accessCheck$3(obj, member, "access private method");
1675
+ __accessCheck$4(obj, member, "access private method");
1096
1676
  return method;
1097
1677
  };
1098
- var _table, _links, _getFetchProps, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn;
1678
+ 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;
1099
1679
  class Repository extends Query {
1100
1680
  }
1101
1681
  class RestRepository extends Query {
1102
1682
  constructor(options) {
1103
- super(null, options.table, {});
1104
- __privateAdd$3(this, _insertRecordWithoutId);
1105
- __privateAdd$3(this, _insertRecordWithId);
1106
- __privateAdd$3(this, _bulkInsertTableRecords);
1107
- __privateAdd$3(this, _updateRecordWithID);
1108
- __privateAdd$3(this, _upsertRecordWithID);
1109
- __privateAdd$3(this, _deleteRecord);
1110
- __privateAdd$3(this, _table, void 0);
1111
- __privateAdd$3(this, _links, void 0);
1112
- __privateAdd$3(this, _getFetchProps, void 0);
1113
- __privateSet$1(this, _table, options.table);
1114
- __privateSet$1(this, _links, options.links ?? {});
1115
- __privateSet$1(this, _getFetchProps, options.getFetchProps);
1116
- this.db = options.db;
1117
- }
1118
- async create(a, b) {
1119
- if (Array.isArray(a)) {
1120
- return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a);
1121
- }
1122
- if (isString(a) && isObject(b)) {
1123
- if (a === "")
1124
- throw new Error("The id can't be empty");
1125
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b);
1126
- }
1127
- if (isObject(a) && isString(a.id)) {
1128
- if (a.id === "")
1129
- throw new Error("The id can't be empty");
1130
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 });
1131
- }
1132
- if (isObject(a)) {
1133
- return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a);
1134
- }
1135
- throw new Error("Invalid arguments for create method");
1136
- }
1137
- async read(recordId) {
1138
- const fetchProps = await __privateGet$2(this, _getFetchProps).call(this);
1139
- try {
1140
- const response = await getRecord({
1141
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$2(this, _table), recordId },
1142
- ...fetchProps
1683
+ super(
1684
+ null,
1685
+ { name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
1686
+ {}
1687
+ );
1688
+ __privateAdd$4(this, _insertRecordWithoutId);
1689
+ __privateAdd$4(this, _insertRecordWithId);
1690
+ __privateAdd$4(this, _bulkInsertTableRecords);
1691
+ __privateAdd$4(this, _updateRecordWithID);
1692
+ __privateAdd$4(this, _upsertRecordWithID);
1693
+ __privateAdd$4(this, _deleteRecord);
1694
+ __privateAdd$4(this, _setCacheQuery);
1695
+ __privateAdd$4(this, _getCacheQuery);
1696
+ __privateAdd$4(this, _getSchemaTables$1);
1697
+ __privateAdd$4(this, _table, void 0);
1698
+ __privateAdd$4(this, _getFetchProps, void 0);
1699
+ __privateAdd$4(this, _db, void 0);
1700
+ __privateAdd$4(this, _cache, void 0);
1701
+ __privateAdd$4(this, _schemaTables$2, void 0);
1702
+ __privateAdd$4(this, _trace, void 0);
1703
+ __privateSet$4(this, _table, options.table);
1704
+ __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1705
+ __privateSet$4(this, _db, options.db);
1706
+ __privateSet$4(this, _cache, options.pluginOptions.cache);
1707
+ __privateSet$4(this, _schemaTables$2, options.schemaTables);
1708
+ const trace = options.pluginOptions.trace ?? defaultTrace;
1709
+ __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
1710
+ return trace(name, fn, {
1711
+ ...options2,
1712
+ [TraceAttributes.TABLE]: __privateGet$4(this, _table),
1713
+ [TraceAttributes.KIND]: "sdk-operation",
1714
+ [TraceAttributes.VERSION]: VERSION
1143
1715
  });
1144
- return initObject(this.db, __privateGet$2(this, _links), __privateGet$2(this, _table), response);
1145
- } catch (e) {
1146
- if (isObject(e) && e.status === 404) {
1147
- return null;
1716
+ });
1717
+ }
1718
+ async create(a, b, c) {
1719
+ return __privateGet$4(this, _trace).call(this, "create", async () => {
1720
+ if (Array.isArray(a)) {
1721
+ if (a.length === 0)
1722
+ return [];
1723
+ const columns = isStringArray(b) ? b : void 0;
1724
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
1148
1725
  }
1149
- throw e;
1150
- }
1726
+ if (isString(a) && isObject(b)) {
1727
+ if (a === "")
1728
+ throw new Error("The id can't be empty");
1729
+ const columns = isStringArray(c) ? c : void 0;
1730
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
1731
+ }
1732
+ if (isObject(a) && isString(a.id)) {
1733
+ if (a.id === "")
1734
+ throw new Error("The id can't be empty");
1735
+ const columns = isStringArray(b) ? b : void 0;
1736
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1737
+ }
1738
+ if (isObject(a)) {
1739
+ const columns = isStringArray(b) ? b : void 0;
1740
+ return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
1741
+ }
1742
+ throw new Error("Invalid arguments for create method");
1743
+ });
1151
1744
  }
1152
- async update(a, b) {
1153
- if (Array.isArray(a)) {
1154
- if (a.length > 100) {
1155
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1745
+ async read(a, b) {
1746
+ return __privateGet$4(this, _trace).call(this, "read", async () => {
1747
+ const columns = isStringArray(b) ? b : ["*"];
1748
+ if (Array.isArray(a)) {
1749
+ if (a.length === 0)
1750
+ return [];
1751
+ const ids = a.map((item) => extractId(item));
1752
+ const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
1753
+ const dictionary = finalObjects.reduce((acc, object) => {
1754
+ acc[object.id] = object;
1755
+ return acc;
1756
+ }, {});
1757
+ return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
1156
1758
  }
1157
- return Promise.all(a.map((object) => this.update(object)));
1158
- }
1159
- if (isString(a) && isObject(b)) {
1160
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b);
1161
- }
1162
- if (isObject(a) && isString(a.id)) {
1163
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1164
- }
1165
- throw new Error("Invalid arguments for update method");
1759
+ const id = extractId(a);
1760
+ if (id) {
1761
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1762
+ try {
1763
+ const response = await getRecord({
1764
+ pathParams: {
1765
+ workspace: "{workspaceId}",
1766
+ dbBranchName: "{dbBranch}",
1767
+ tableName: __privateGet$4(this, _table),
1768
+ recordId: id
1769
+ },
1770
+ queryParams: { columns },
1771
+ ...fetchProps
1772
+ });
1773
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1774
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1775
+ } catch (e) {
1776
+ if (isObject(e) && e.status === 404) {
1777
+ return null;
1778
+ }
1779
+ throw e;
1780
+ }
1781
+ }
1782
+ return null;
1783
+ });
1166
1784
  }
1167
- async createOrUpdate(a, b) {
1168
- if (Array.isArray(a)) {
1169
- if (a.length > 100) {
1170
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1785
+ async readOrThrow(a, b) {
1786
+ return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
1787
+ const result = await this.read(a, b);
1788
+ if (Array.isArray(result)) {
1789
+ const missingIds = compact(
1790
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1791
+ );
1792
+ if (missingIds.length > 0) {
1793
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1794
+ }
1795
+ return result;
1171
1796
  }
1172
- return Promise.all(a.map((object) => this.createOrUpdate(object)));
1173
- }
1174
- if (isString(a) && isObject(b)) {
1175
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b);
1176
- }
1177
- if (isObject(a) && isString(a.id)) {
1178
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1179
- }
1180
- throw new Error("Invalid arguments for createOrUpdate method");
1797
+ if (result === null) {
1798
+ const id = extractId(a) ?? "unknown";
1799
+ throw new Error(`Record with id ${id} not found`);
1800
+ }
1801
+ return result;
1802
+ });
1181
1803
  }
1182
- async delete(recordId) {
1183
- if (Array.isArray(recordId)) {
1184
- if (recordId.length > 100) {
1185
- console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1804
+ async update(a, b, c) {
1805
+ return __privateGet$4(this, _trace).call(this, "update", async () => {
1806
+ if (Array.isArray(a)) {
1807
+ if (a.length === 0)
1808
+ return [];
1809
+ if (a.length > 100) {
1810
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1811
+ }
1812
+ const columns = isStringArray(b) ? b : ["*"];
1813
+ return Promise.all(a.map((object) => this.update(object, columns)));
1186
1814
  }
1187
- await Promise.all(recordId.map((id) => this.delete(id)));
1188
- return;
1189
- }
1190
- if (isString(recordId)) {
1191
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, recordId);
1192
- return;
1193
- }
1194
- if (isObject(recordId) && isString(recordId.id)) {
1195
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, recordId.id);
1196
- return;
1197
- }
1198
- throw new Error("Invalid arguments for delete method");
1815
+ if (isString(a) && isObject(b)) {
1816
+ const columns = isStringArray(c) ? c : void 0;
1817
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
1818
+ }
1819
+ if (isObject(a) && isString(a.id)) {
1820
+ const columns = isStringArray(b) ? b : void 0;
1821
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1822
+ }
1823
+ throw new Error("Invalid arguments for update method");
1824
+ });
1825
+ }
1826
+ async updateOrThrow(a, b, c) {
1827
+ return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1828
+ const result = await this.update(a, b, c);
1829
+ if (Array.isArray(result)) {
1830
+ const missingIds = compact(
1831
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1832
+ );
1833
+ if (missingIds.length > 0) {
1834
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1835
+ }
1836
+ return result;
1837
+ }
1838
+ if (result === null) {
1839
+ const id = extractId(a) ?? "unknown";
1840
+ throw new Error(`Record with id ${id} not found`);
1841
+ }
1842
+ return result;
1843
+ });
1844
+ }
1845
+ async createOrUpdate(a, b, c) {
1846
+ return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
1847
+ if (Array.isArray(a)) {
1848
+ if (a.length === 0)
1849
+ return [];
1850
+ if (a.length > 100) {
1851
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1852
+ }
1853
+ const columns = isStringArray(b) ? b : ["*"];
1854
+ return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
1855
+ }
1856
+ if (isString(a) && isObject(b)) {
1857
+ const columns = isStringArray(c) ? c : void 0;
1858
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
1859
+ }
1860
+ if (isObject(a) && isString(a.id)) {
1861
+ const columns = isStringArray(c) ? c : void 0;
1862
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1863
+ }
1864
+ throw new Error("Invalid arguments for createOrUpdate method");
1865
+ });
1866
+ }
1867
+ async delete(a, b) {
1868
+ return __privateGet$4(this, _trace).call(this, "delete", async () => {
1869
+ if (Array.isArray(a)) {
1870
+ if (a.length === 0)
1871
+ return [];
1872
+ if (a.length > 100) {
1873
+ console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1874
+ }
1875
+ return Promise.all(a.map((id) => this.delete(id, b)));
1876
+ }
1877
+ if (isString(a)) {
1878
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
1879
+ }
1880
+ if (isObject(a) && isString(a.id)) {
1881
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
1882
+ }
1883
+ throw new Error("Invalid arguments for delete method");
1884
+ });
1885
+ }
1886
+ async deleteOrThrow(a, b) {
1887
+ return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
1888
+ const result = await this.delete(a, b);
1889
+ if (Array.isArray(result)) {
1890
+ const missingIds = compact(
1891
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1892
+ );
1893
+ if (missingIds.length > 0) {
1894
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1895
+ }
1896
+ return result;
1897
+ } else if (result === null) {
1898
+ const id = extractId(a) ?? "unknown";
1899
+ throw new Error(`Record with id ${id} not found`);
1900
+ }
1901
+ return result;
1902
+ });
1199
1903
  }
1200
1904
  async search(query, options = {}) {
1201
- const fetchProps = await __privateGet$2(this, _getFetchProps).call(this);
1202
- const { records } = await searchBranch({
1203
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1204
- body: { tables: [__privateGet$2(this, _table)], query, fuzziness: options.fuzziness },
1205
- ...fetchProps
1905
+ return __privateGet$4(this, _trace).call(this, "search", async () => {
1906
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1907
+ const { records } = await searchTable({
1908
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1909
+ body: {
1910
+ query,
1911
+ fuzziness: options.fuzziness,
1912
+ prefix: options.prefix,
1913
+ highlight: options.highlight,
1914
+ filter: options.filter,
1915
+ boosters: options.boosters
1916
+ },
1917
+ ...fetchProps
1918
+ });
1919
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1920
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
1206
1921
  });
1207
- return records.map((item) => initObject(this.db, __privateGet$2(this, _links), __privateGet$2(this, _table), item));
1208
1922
  }
1209
1923
  async query(query) {
1210
- const data = query.getQueryOptions();
1211
- const body = {
1212
- filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1213
- sort: data.sort ? buildSortFilter(data.sort) : void 0,
1214
- page: data.page,
1215
- columns: data.columns
1216
- };
1217
- const fetchProps = await __privateGet$2(this, _getFetchProps).call(this);
1218
- const { meta, records: objects } = await queryTable({
1219
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$2(this, _table) },
1220
- body,
1221
- ...fetchProps
1924
+ return __privateGet$4(this, _trace).call(this, "query", async () => {
1925
+ const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1926
+ if (cacheQuery)
1927
+ return new Page(query, cacheQuery.meta, cacheQuery.records);
1928
+ const data = query.getQueryOptions();
1929
+ const body = {
1930
+ filter: cleanFilter(data.filter),
1931
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1932
+ page: data.pagination,
1933
+ columns: data.columns
1934
+ };
1935
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1936
+ const { meta, records: objects } = await queryTable({
1937
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1938
+ body,
1939
+ ...fetchProps
1940
+ });
1941
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1942
+ const records = objects.map(
1943
+ (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
1944
+ );
1945
+ await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1946
+ return new Page(query, meta, records);
1222
1947
  });
1223
- const records = objects.map((record) => initObject(this.db, __privateGet$2(this, _links), __privateGet$2(this, _table), record));
1224
- return new Page(query, meta, records);
1225
1948
  }
1226
1949
  }
1227
1950
  _table = new WeakMap();
1228
- _links = new WeakMap();
1229
1951
  _getFetchProps = new WeakMap();
1952
+ _db = new WeakMap();
1953
+ _cache = new WeakMap();
1954
+ _schemaTables$2 = new WeakMap();
1955
+ _trace = new WeakMap();
1230
1956
  _insertRecordWithoutId = new WeakSet();
1231
- insertRecordWithoutId_fn = async function(object) {
1232
- const fetchProps = await __privateGet$2(this, _getFetchProps).call(this);
1957
+ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1958
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1233
1959
  const record = transformObjectLinks(object);
1234
1960
  const response = await insertRecord({
1235
1961
  pathParams: {
1236
1962
  workspace: "{workspaceId}",
1237
1963
  dbBranchName: "{dbBranch}",
1238
- tableName: __privateGet$2(this, _table)
1964
+ tableName: __privateGet$4(this, _table)
1239
1965
  },
1966
+ queryParams: { columns },
1240
1967
  body: record,
1241
1968
  ...fetchProps
1242
1969
  });
1243
- const finalObject = await this.read(response.id);
1244
- if (!finalObject) {
1245
- throw new Error("The server failed to save the record");
1246
- }
1247
- return finalObject;
1970
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1971
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1248
1972
  };
1249
1973
  _insertRecordWithId = new WeakSet();
1250
- insertRecordWithId_fn = async function(recordId, object) {
1251
- const fetchProps = await __privateGet$2(this, _getFetchProps).call(this);
1974
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
1975
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1252
1976
  const record = transformObjectLinks(object);
1253
1977
  const response = await insertRecordWithID({
1254
1978
  pathParams: {
1255
1979
  workspace: "{workspaceId}",
1256
1980
  dbBranchName: "{dbBranch}",
1257
- tableName: __privateGet$2(this, _table),
1981
+ tableName: __privateGet$4(this, _table),
1258
1982
  recordId
1259
1983
  },
1260
1984
  body: record,
1261
- queryParams: { createOnly: true },
1985
+ queryParams: { createOnly: true, columns },
1262
1986
  ...fetchProps
1263
1987
  });
1264
- const finalObject = await this.read(response.id);
1265
- if (!finalObject) {
1266
- throw new Error("The server failed to save the record");
1267
- }
1268
- return finalObject;
1988
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1989
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1269
1990
  };
1270
1991
  _bulkInsertTableRecords = new WeakSet();
1271
- bulkInsertTableRecords_fn = async function(objects) {
1272
- const fetchProps = await __privateGet$2(this, _getFetchProps).call(this);
1992
+ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1993
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1273
1994
  const records = objects.map((object) => transformObjectLinks(object));
1274
1995
  const response = await bulkInsertTableRecords({
1275
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$2(this, _table) },
1996
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1997
+ queryParams: { columns },
1276
1998
  body: { records },
1277
1999
  ...fetchProps
1278
2000
  });
1279
- const finalObjects = await this.any(...response.recordIDs.map((id) => this.filter("id", id))).getAll();
1280
- if (finalObjects.length !== objects.length) {
1281
- throw new Error("The server failed to save some records");
2001
+ if (!isResponseWithRecords(response)) {
2002
+ throw new Error("Request included columns but server didn't include them");
1282
2003
  }
1283
- return finalObjects;
2004
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2005
+ return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
1284
2006
  };
1285
2007
  _updateRecordWithID = new WeakSet();
1286
- updateRecordWithID_fn = async function(recordId, object) {
1287
- const fetchProps = await __privateGet$2(this, _getFetchProps).call(this);
2008
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2009
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1288
2010
  const record = transformObjectLinks(object);
1289
- const response = await updateRecordWithID({
1290
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$2(this, _table), recordId },
1291
- body: record,
1292
- ...fetchProps
1293
- });
1294
- const item = await this.read(response.id);
1295
- if (!item)
1296
- throw new Error("The server failed to save the record");
1297
- return item;
2011
+ try {
2012
+ const response = await updateRecordWithID({
2013
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2014
+ queryParams: { columns },
2015
+ body: record,
2016
+ ...fetchProps
2017
+ });
2018
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2019
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2020
+ } catch (e) {
2021
+ if (isObject(e) && e.status === 404) {
2022
+ return null;
2023
+ }
2024
+ throw e;
2025
+ }
1298
2026
  };
1299
2027
  _upsertRecordWithID = new WeakSet();
1300
- upsertRecordWithID_fn = async function(recordId, object) {
1301
- const fetchProps = await __privateGet$2(this, _getFetchProps).call(this);
2028
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2029
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1302
2030
  const response = await upsertRecordWithID({
1303
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$2(this, _table), recordId },
2031
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2032
+ queryParams: { columns },
1304
2033
  body: object,
1305
2034
  ...fetchProps
1306
2035
  });
1307
- const item = await this.read(response.id);
1308
- if (!item)
1309
- throw new Error("The server failed to save the record");
1310
- return item;
2036
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2037
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1311
2038
  };
1312
2039
  _deleteRecord = new WeakSet();
1313
- deleteRecord_fn = async function(recordId) {
1314
- const fetchProps = await __privateGet$2(this, _getFetchProps).call(this);
1315
- await deleteRecord({
1316
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$2(this, _table), recordId },
2040
+ deleteRecord_fn = async function(recordId, columns = ["*"]) {
2041
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2042
+ try {
2043
+ const response = await deleteRecord({
2044
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2045
+ queryParams: { columns },
2046
+ ...fetchProps
2047
+ });
2048
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2049
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2050
+ } catch (e) {
2051
+ if (isObject(e) && e.status === 404) {
2052
+ return null;
2053
+ }
2054
+ throw e;
2055
+ }
2056
+ };
2057
+ _setCacheQuery = new WeakSet();
2058
+ setCacheQuery_fn = async function(query, meta, records) {
2059
+ await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
2060
+ };
2061
+ _getCacheQuery = new WeakSet();
2062
+ getCacheQuery_fn = async function(query) {
2063
+ const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
2064
+ const result = await __privateGet$4(this, _cache).get(key);
2065
+ if (!result)
2066
+ return null;
2067
+ const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
2068
+ if (ttl < 0)
2069
+ return null;
2070
+ const hasExpired = result.date.getTime() + ttl < Date.now();
2071
+ return hasExpired ? null : result;
2072
+ };
2073
+ _getSchemaTables$1 = new WeakSet();
2074
+ getSchemaTables_fn$1 = async function() {
2075
+ if (__privateGet$4(this, _schemaTables$2))
2076
+ return __privateGet$4(this, _schemaTables$2);
2077
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2078
+ const { schema } = await getBranchDetails({
2079
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1317
2080
  ...fetchProps
1318
2081
  });
2082
+ __privateSet$4(this, _schemaTables$2, schema.tables);
2083
+ return schema.tables;
1319
2084
  };
1320
2085
  const transformObjectLinks = (object) => {
1321
2086
  return Object.entries(object).reduce((acc, [key, value]) => {
@@ -1324,45 +2089,168 @@ const transformObjectLinks = (object) => {
1324
2089
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
1325
2090
  }, {});
1326
2091
  };
1327
- const initObject = (db, links, table, object) => {
2092
+ const initObject = (db, schemaTables, table, object, selectedColumns) => {
1328
2093
  const result = {};
1329
- Object.assign(result, object);
1330
- const tableLinks = links[table] || [];
1331
- for (const link of tableLinks) {
1332
- const [field, linkTable] = link;
1333
- const value = result[field];
1334
- if (value && isObject(value)) {
1335
- result[field] = initObject(db, links, linkTable, value);
2094
+ const { xata, ...rest } = object ?? {};
2095
+ Object.assign(result, rest);
2096
+ const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
2097
+ if (!columns)
2098
+ console.error(`Table ${table} not found in schema`);
2099
+ for (const column of columns ?? []) {
2100
+ if (!isValidColumn(selectedColumns, column))
2101
+ continue;
2102
+ const value = result[column.name];
2103
+ switch (column.type) {
2104
+ case "datetime": {
2105
+ const date = value !== void 0 ? new Date(value) : void 0;
2106
+ if (date && isNaN(date.getTime())) {
2107
+ console.error(`Failed to parse date ${value} for field ${column.name}`);
2108
+ } else if (date) {
2109
+ result[column.name] = date;
2110
+ }
2111
+ break;
2112
+ }
2113
+ case "link": {
2114
+ const linkTable = column.link?.table;
2115
+ if (!linkTable) {
2116
+ console.error(`Failed to parse link for field ${column.name}`);
2117
+ } else if (isObject(value)) {
2118
+ const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
2119
+ if (item === column.name) {
2120
+ return [...acc, "*"];
2121
+ }
2122
+ if (item.startsWith(`${column.name}.`)) {
2123
+ const [, ...path] = item.split(".");
2124
+ return [...acc, path.join(".")];
2125
+ }
2126
+ return acc;
2127
+ }, []);
2128
+ result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2129
+ } else {
2130
+ result[column.name] = null;
2131
+ }
2132
+ break;
2133
+ }
2134
+ default:
2135
+ result[column.name] = value ?? null;
2136
+ if (column.notNull === true && value === null) {
2137
+ console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2138
+ }
2139
+ break;
1336
2140
  }
1337
2141
  }
1338
- result.read = function() {
1339
- return db[table].read(result["id"]);
2142
+ result.read = function(columns2) {
2143
+ return db[table].read(result["id"], columns2);
1340
2144
  };
1341
- result.update = function(data) {
1342
- return db[table].update(result["id"], data);
2145
+ result.update = function(data, columns2) {
2146
+ return db[table].update(result["id"], data, columns2);
1343
2147
  };
1344
2148
  result.delete = function() {
1345
2149
  return db[table].delete(result["id"]);
1346
2150
  };
1347
- for (const prop of ["read", "update", "delete"]) {
2151
+ result.getMetadata = function() {
2152
+ return xata;
2153
+ };
2154
+ for (const prop of ["read", "update", "delete", "getMetadata"]) {
1348
2155
  Object.defineProperty(result, prop, { enumerable: false });
1349
2156
  }
1350
2157
  Object.freeze(result);
1351
2158
  return result;
1352
2159
  };
2160
+ function isResponseWithRecords(value) {
2161
+ return isObject(value) && Array.isArray(value.records);
2162
+ }
2163
+ function extractId(value) {
2164
+ if (isString(value))
2165
+ return value;
2166
+ if (isObject(value) && isString(value.id))
2167
+ return value.id;
2168
+ return void 0;
2169
+ }
2170
+ function cleanFilter(filter) {
2171
+ if (!filter)
2172
+ return void 0;
2173
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2174
+ return values.length > 0 ? filter : void 0;
2175
+ }
2176
+ function isValidColumn(columns, column) {
2177
+ if (columns.includes("*"))
2178
+ return true;
2179
+ if (column.type === "link") {
2180
+ const linkColumns = columns.filter((item) => item.startsWith(column.name));
2181
+ return linkColumns.length > 0;
2182
+ }
2183
+ return columns.includes(column.name);
2184
+ }
2185
+
2186
+ var __accessCheck$3 = (obj, member, msg) => {
2187
+ if (!member.has(obj))
2188
+ throw TypeError("Cannot " + msg);
2189
+ };
2190
+ var __privateGet$3 = (obj, member, getter) => {
2191
+ __accessCheck$3(obj, member, "read from private field");
2192
+ return getter ? getter.call(obj) : member.get(obj);
2193
+ };
2194
+ var __privateAdd$3 = (obj, member, value) => {
2195
+ if (member.has(obj))
2196
+ throw TypeError("Cannot add the same private member more than once");
2197
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2198
+ };
2199
+ var __privateSet$3 = (obj, member, value, setter) => {
2200
+ __accessCheck$3(obj, member, "write to private field");
2201
+ setter ? setter.call(obj, value) : member.set(obj, value);
2202
+ return value;
2203
+ };
2204
+ var _map;
2205
+ class SimpleCache {
2206
+ constructor(options = {}) {
2207
+ __privateAdd$3(this, _map, void 0);
2208
+ __privateSet$3(this, _map, /* @__PURE__ */ new Map());
2209
+ this.capacity = options.max ?? 500;
2210
+ this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
2211
+ }
2212
+ async getAll() {
2213
+ return Object.fromEntries(__privateGet$3(this, _map));
2214
+ }
2215
+ async get(key) {
2216
+ return __privateGet$3(this, _map).get(key) ?? null;
2217
+ }
2218
+ async set(key, value) {
2219
+ await this.delete(key);
2220
+ __privateGet$3(this, _map).set(key, value);
2221
+ if (__privateGet$3(this, _map).size > this.capacity) {
2222
+ const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
2223
+ await this.delete(leastRecentlyUsed);
2224
+ }
2225
+ }
2226
+ async delete(key) {
2227
+ __privateGet$3(this, _map).delete(key);
2228
+ }
2229
+ async clear() {
2230
+ return __privateGet$3(this, _map).clear();
2231
+ }
2232
+ }
2233
+ _map = new WeakMap();
1353
2234
 
1354
- const gt = (value) => ({ $gt: value });
1355
- const ge = (value) => ({ $ge: value });
1356
- const gte = (value) => ({ $ge: value });
1357
- const lt = (value) => ({ $lt: value });
1358
- const lte = (value) => ({ $le: value });
1359
- const le = (value) => ({ $le: value });
2235
+ const greaterThan = (value) => ({ $gt: value });
2236
+ const gt = greaterThan;
2237
+ const greaterThanEquals = (value) => ({ $ge: value });
2238
+ const greaterEquals = greaterThanEquals;
2239
+ const gte = greaterThanEquals;
2240
+ const ge = greaterThanEquals;
2241
+ const lessThan = (value) => ({ $lt: value });
2242
+ const lt = lessThan;
2243
+ const lessThanEquals = (value) => ({ $le: value });
2244
+ const lessEquals = lessThanEquals;
2245
+ const lte = lessThanEquals;
2246
+ const le = lessThanEquals;
1360
2247
  const exists = (column) => ({ $exists: column });
1361
2248
  const notExists = (column) => ({ $notExists: column });
1362
2249
  const startsWith = (value) => ({ $startsWith: value });
1363
2250
  const endsWith = (value) => ({ $endsWith: value });
1364
2251
  const pattern = (value) => ({ $pattern: value });
1365
2252
  const is = (value) => ({ $is: value });
2253
+ const equals = is;
1366
2254
  const isNot = (value) => ({ $isNot: value });
1367
2255
  const contains = (value) => ({ $contains: value });
1368
2256
  const includes = (value) => ({ $includes: value });
@@ -1374,7 +2262,7 @@ var __accessCheck$2 = (obj, member, msg) => {
1374
2262
  if (!member.has(obj))
1375
2263
  throw TypeError("Cannot " + msg);
1376
2264
  };
1377
- var __privateGet$1 = (obj, member, getter) => {
2265
+ var __privateGet$2 = (obj, member, getter) => {
1378
2266
  __accessCheck$2(obj, member, "read from private field");
1379
2267
  return getter ? getter.call(obj) : member.get(obj);
1380
2268
  };
@@ -1383,126 +2271,178 @@ var __privateAdd$2 = (obj, member, value) => {
1383
2271
  throw TypeError("Cannot add the same private member more than once");
1384
2272
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1385
2273
  };
1386
- var _tables;
2274
+ var __privateSet$2 = (obj, member, value, setter) => {
2275
+ __accessCheck$2(obj, member, "write to private field");
2276
+ setter ? setter.call(obj, value) : member.set(obj, value);
2277
+ return value;
2278
+ };
2279
+ var _tables, _schemaTables$1;
1387
2280
  class SchemaPlugin extends XataPlugin {
1388
- constructor(links) {
2281
+ constructor(schemaTables) {
1389
2282
  super();
1390
- this.links = links;
1391
2283
  __privateAdd$2(this, _tables, {});
1392
- }
1393
- build(options) {
1394
- const { getFetchProps } = options;
1395
- const links = this.links;
1396
- const db = new Proxy({}, {
1397
- get: (_target, table) => {
1398
- if (!isString(table))
1399
- throw new Error("Invalid table name");
1400
- if (!__privateGet$1(this, _tables)[table])
1401
- __privateGet$1(this, _tables)[table] = new RestRepository({ db, getFetchProps, table, links });
1402
- return __privateGet$1(this, _tables)[table];
2284
+ __privateAdd$2(this, _schemaTables$1, void 0);
2285
+ __privateSet$2(this, _schemaTables$1, schemaTables);
2286
+ }
2287
+ build(pluginOptions) {
2288
+ const db = new Proxy(
2289
+ {},
2290
+ {
2291
+ get: (_target, table) => {
2292
+ if (!isString(table))
2293
+ throw new Error("Invalid table name");
2294
+ if (__privateGet$2(this, _tables)[table] === void 0) {
2295
+ __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
2296
+ }
2297
+ return __privateGet$2(this, _tables)[table];
2298
+ }
1403
2299
  }
1404
- });
2300
+ );
2301
+ const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
2302
+ for (const table of tableNames) {
2303
+ db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
2304
+ }
1405
2305
  return db;
1406
2306
  }
1407
2307
  }
1408
2308
  _tables = new WeakMap();
2309
+ _schemaTables$1 = new WeakMap();
1409
2310
 
1410
2311
  var __accessCheck$1 = (obj, member, msg) => {
1411
2312
  if (!member.has(obj))
1412
2313
  throw TypeError("Cannot " + msg);
1413
2314
  };
2315
+ var __privateGet$1 = (obj, member, getter) => {
2316
+ __accessCheck$1(obj, member, "read from private field");
2317
+ return getter ? getter.call(obj) : member.get(obj);
2318
+ };
1414
2319
  var __privateAdd$1 = (obj, member, value) => {
1415
2320
  if (member.has(obj))
1416
2321
  throw TypeError("Cannot add the same private member more than once");
1417
2322
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1418
2323
  };
2324
+ var __privateSet$1 = (obj, member, value, setter) => {
2325
+ __accessCheck$1(obj, member, "write to private field");
2326
+ setter ? setter.call(obj, value) : member.set(obj, value);
2327
+ return value;
2328
+ };
1419
2329
  var __privateMethod$1 = (obj, member, method) => {
1420
2330
  __accessCheck$1(obj, member, "access private method");
1421
2331
  return method;
1422
2332
  };
1423
- var _search, search_fn;
2333
+ var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
1424
2334
  class SearchPlugin extends XataPlugin {
1425
- constructor(db, links) {
2335
+ constructor(db, schemaTables) {
1426
2336
  super();
1427
2337
  this.db = db;
1428
- this.links = links;
1429
2338
  __privateAdd$1(this, _search);
2339
+ __privateAdd$1(this, _getSchemaTables);
2340
+ __privateAdd$1(this, _schemaTables, void 0);
2341
+ __privateSet$1(this, _schemaTables, schemaTables);
1430
2342
  }
1431
2343
  build({ getFetchProps }) {
1432
2344
  return {
1433
2345
  all: async (query, options = {}) => {
1434
2346
  const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
2347
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
1435
2348
  return records.map((record) => {
1436
2349
  const { table = "orphan" } = record.xata;
1437
- return { table, record: initObject(this.db, this.links, table, record) };
2350
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
1438
2351
  });
1439
2352
  },
1440
2353
  byTable: async (query, options = {}) => {
1441
2354
  const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
2355
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
1442
2356
  return records.reduce((acc, record) => {
1443
2357
  const { table = "orphan" } = record.xata;
1444
2358
  const items = acc[table] ?? [];
1445
- const item = initObject(this.db, this.links, table, record);
2359
+ const item = initObject(this.db, schemaTables, table, record, ["*"]);
1446
2360
  return { ...acc, [table]: [...items, item] };
1447
2361
  }, {});
1448
2362
  }
1449
2363
  };
1450
2364
  }
1451
2365
  }
2366
+ _schemaTables = new WeakMap();
1452
2367
  _search = new WeakSet();
1453
2368
  search_fn = async function(query, options, getFetchProps) {
1454
2369
  const fetchProps = await getFetchProps();
1455
- const { tables, fuzziness } = options ?? {};
2370
+ const { tables, fuzziness, highlight, prefix } = options ?? {};
1456
2371
  const { records } = await searchBranch({
1457
2372
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1458
- body: { tables, query, fuzziness },
2373
+ body: { tables, query, fuzziness, prefix, highlight },
1459
2374
  ...fetchProps
1460
2375
  });
1461
2376
  return records;
1462
2377
  };
2378
+ _getSchemaTables = new WeakSet();
2379
+ getSchemaTables_fn = async function(getFetchProps) {
2380
+ if (__privateGet$1(this, _schemaTables))
2381
+ return __privateGet$1(this, _schemaTables);
2382
+ const fetchProps = await getFetchProps();
2383
+ const { schema } = await getBranchDetails({
2384
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2385
+ ...fetchProps
2386
+ });
2387
+ __privateSet$1(this, _schemaTables, schema.tables);
2388
+ return schema.tables;
2389
+ };
1463
2390
 
1464
2391
  const isBranchStrategyBuilder = (strategy) => {
1465
2392
  return typeof strategy === "function";
1466
2393
  };
1467
2394
 
1468
- const envBranchNames = [
1469
- "XATA_BRANCH",
1470
- "VERCEL_GIT_COMMIT_REF",
1471
- "CF_PAGES_BRANCH",
1472
- "BRANCH"
1473
- ];
1474
- const defaultBranch = "main";
1475
2395
  async function getCurrentBranchName(options) {
1476
- const env = await getBranchByEnvVariable();
1477
- if (env)
1478
- return env;
1479
- const branch = await getGitBranch();
1480
- if (!branch)
1481
- return defaultBranch;
1482
- const details = await getDatabaseBranch(branch, options);
1483
- if (details)
1484
- return branch;
1485
- return defaultBranch;
2396
+ const { branch, envBranch } = getEnvironment();
2397
+ if (branch) {
2398
+ const details = await getDatabaseBranch(branch, options);
2399
+ if (details)
2400
+ return branch;
2401
+ console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
2402
+ }
2403
+ const gitBranch = envBranch || await getGitBranch();
2404
+ return resolveXataBranch(gitBranch, options);
1486
2405
  }
1487
2406
  async function getCurrentBranchDetails(options) {
1488
- const env = await getBranchByEnvVariable();
1489
- if (env)
1490
- return getDatabaseBranch(env, options);
1491
- const branch = await getGitBranch();
1492
- if (!branch)
1493
- return getDatabaseBranch(defaultBranch, options);
1494
- const details = await getDatabaseBranch(branch, options);
1495
- if (details)
1496
- return details;
1497
- return getDatabaseBranch(defaultBranch, options);
2407
+ const branch = await getCurrentBranchName(options);
2408
+ return getDatabaseBranch(branch, options);
2409
+ }
2410
+ async function resolveXataBranch(gitBranch, options) {
2411
+ const databaseURL = options?.databaseURL || getDatabaseURL();
2412
+ const apiKey = options?.apiKey || getAPIKey();
2413
+ if (!databaseURL)
2414
+ throw new Error(
2415
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2416
+ );
2417
+ if (!apiKey)
2418
+ throw new Error(
2419
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2420
+ );
2421
+ const [protocol, , host, , dbName] = databaseURL.split("/");
2422
+ const [workspace] = host.split(".");
2423
+ const { fallbackBranch } = getEnvironment();
2424
+ const { branch } = await resolveBranch({
2425
+ apiKey,
2426
+ apiUrl: databaseURL,
2427
+ fetchImpl: getFetchImplementation(options?.fetchImpl),
2428
+ workspacesApiUrl: `${protocol}//${host}`,
2429
+ pathParams: { dbName, workspace },
2430
+ queryParams: { gitBranch, fallbackBranch },
2431
+ trace: defaultTrace
2432
+ });
2433
+ return branch;
1498
2434
  }
1499
2435
  async function getDatabaseBranch(branch, options) {
1500
2436
  const databaseURL = options?.databaseURL || getDatabaseURL();
1501
2437
  const apiKey = options?.apiKey || getAPIKey();
1502
2438
  if (!databaseURL)
1503
- throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
2439
+ throw new Error(
2440
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2441
+ );
1504
2442
  if (!apiKey)
1505
- throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
2443
+ throw new Error(
2444
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2445
+ );
1506
2446
  const [protocol, , host, , database] = databaseURL.split("/");
1507
2447
  const [workspace] = host.split(".");
1508
2448
  const dbBranchName = `${database}:${branch}`;
@@ -1512,10 +2452,8 @@ async function getDatabaseBranch(branch, options) {
1512
2452
  apiUrl: databaseURL,
1513
2453
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1514
2454
  workspacesApiUrl: `${protocol}//${host}`,
1515
- pathParams: {
1516
- dbBranchName,
1517
- workspace
1518
- }
2455
+ pathParams: { dbBranchName, workspace },
2456
+ trace: defaultTrace
1519
2457
  });
1520
2458
  } catch (err) {
1521
2459
  if (isObject(err) && err.status === 404)
@@ -1523,21 +2461,10 @@ async function getDatabaseBranch(branch, options) {
1523
2461
  throw err;
1524
2462
  }
1525
2463
  }
1526
- function getBranchByEnvVariable() {
1527
- for (const name of envBranchNames) {
1528
- const value = getEnvVariable(name);
1529
- if (value) {
1530
- return value;
1531
- }
1532
- }
1533
- try {
1534
- return XATA_BRANCH;
1535
- } catch (err) {
1536
- }
1537
- }
1538
2464
  function getDatabaseURL() {
1539
2465
  try {
1540
- return getEnvVariable("XATA_DATABASE_URL") ?? XATA_DATABASE_URL;
2466
+ const { databaseURL } = getEnvironment();
2467
+ return databaseURL;
1541
2468
  } catch (err) {
1542
2469
  return void 0;
1543
2470
  }
@@ -1566,24 +2493,29 @@ var __privateMethod = (obj, member, method) => {
1566
2493
  return method;
1567
2494
  };
1568
2495
  const buildClient = (plugins) => {
1569
- var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
2496
+ var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
1570
2497
  return _a = class {
1571
- constructor(options = {}, links) {
2498
+ constructor(options = {}, schemaTables) {
1572
2499
  __privateAdd(this, _parseOptions);
1573
2500
  __privateAdd(this, _getFetchProps);
1574
2501
  __privateAdd(this, _evaluateBranch);
1575
2502
  __privateAdd(this, _branch, void 0);
2503
+ __privateAdd(this, _options, void 0);
1576
2504
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
1577
- const db = new SchemaPlugin(links).build({ getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions) });
1578
- const search = new SearchPlugin(db, links ?? {}).build({
1579
- getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions)
1580
- });
2505
+ __privateSet(this, _options, safeOptions);
2506
+ const pluginOptions = {
2507
+ getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
2508
+ cache: safeOptions.cache,
2509
+ trace: safeOptions.trace
2510
+ };
2511
+ const db = new SchemaPlugin(schemaTables).build(pluginOptions);
2512
+ const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
1581
2513
  this.db = db;
1582
2514
  this.search = search;
1583
2515
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
1584
- if (!namespace)
2516
+ if (namespace === void 0)
1585
2517
  continue;
1586
- const result = namespace.build({ getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions) });
2518
+ const result = namespace.build(pluginOptions);
1587
2519
  if (result instanceof Promise) {
1588
2520
  void result.then((namespace2) => {
1589
2521
  this[key] = namespace2;
@@ -1593,21 +2525,26 @@ const buildClient = (plugins) => {
1593
2525
  }
1594
2526
  }
1595
2527
  }
1596
- }, _branch = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
2528
+ async getConfig() {
2529
+ const databaseURL = __privateGet(this, _options).databaseURL;
2530
+ const branch = await __privateGet(this, _options).branch();
2531
+ return { databaseURL, branch };
2532
+ }
2533
+ }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
1597
2534
  const fetch = getFetchImplementation(options?.fetch);
1598
2535
  const databaseURL = options?.databaseURL || getDatabaseURL();
1599
2536
  const apiKey = options?.apiKey || getAPIKey();
1600
- const branch = async () => options?.branch ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
1601
- if (!databaseURL || !apiKey) {
1602
- throw new Error("Options databaseURL and apiKey are required");
2537
+ const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
2538
+ const trace = options?.trace ?? defaultTrace;
2539
+ const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
2540
+ if (!apiKey) {
2541
+ throw new Error("Option apiKey is required");
1603
2542
  }
1604
- return { fetch, databaseURL, apiKey, branch };
1605
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
1606
- fetch,
1607
- apiKey,
1608
- databaseURL,
1609
- branch
1610
- }) {
2543
+ if (!databaseURL) {
2544
+ throw new Error("Option databaseURL is required");
2545
+ }
2546
+ return { fetch, databaseURL, apiKey, branch, cache, trace };
2547
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
1611
2548
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
1612
2549
  if (!branchValue)
1613
2550
  throw new Error("Unable to resolve branch value");
@@ -1617,14 +2554,15 @@ const buildClient = (plugins) => {
1617
2554
  apiUrl: "",
1618
2555
  workspacesApiUrl: (path, params) => {
1619
2556
  const hasBranch = params.dbBranchName ?? params.branch;
1620
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
2557
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
1621
2558
  return databaseURL + newPath;
1622
- }
2559
+ },
2560
+ trace
1623
2561
  };
1624
2562
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
1625
2563
  if (__privateGet(this, _branch))
1626
2564
  return __privateGet(this, _branch);
1627
- if (!param)
2565
+ if (param === void 0)
1628
2566
  return void 0;
1629
2567
  const strategies = Array.isArray(param) ? [...param] : [param];
1630
2568
  const evaluateBranch = async (strategy) => {
@@ -1642,6 +2580,88 @@ const buildClient = (plugins) => {
1642
2580
  class BaseClient extends buildClient() {
1643
2581
  }
1644
2582
 
2583
+ const META = "__";
2584
+ const VALUE = "___";
2585
+ class Serializer {
2586
+ constructor() {
2587
+ this.classes = {};
2588
+ }
2589
+ add(clazz) {
2590
+ this.classes[clazz.name] = clazz;
2591
+ }
2592
+ toJSON(data) {
2593
+ function visit(obj) {
2594
+ if (Array.isArray(obj))
2595
+ return obj.map(visit);
2596
+ const type = typeof obj;
2597
+ if (type === "undefined")
2598
+ return { [META]: "undefined" };
2599
+ if (type === "bigint")
2600
+ return { [META]: "bigint", [VALUE]: obj.toString() };
2601
+ if (obj === null || type !== "object")
2602
+ return obj;
2603
+ const constructor = obj.constructor;
2604
+ const o = { [META]: constructor.name };
2605
+ for (const [key, value] of Object.entries(obj)) {
2606
+ o[key] = visit(value);
2607
+ }
2608
+ if (constructor === Date)
2609
+ o[VALUE] = obj.toISOString();
2610
+ if (constructor === Map)
2611
+ o[VALUE] = Object.fromEntries(obj);
2612
+ if (constructor === Set)
2613
+ o[VALUE] = [...obj];
2614
+ return o;
2615
+ }
2616
+ return JSON.stringify(visit(data));
2617
+ }
2618
+ fromJSON(json) {
2619
+ return JSON.parse(json, (key, value) => {
2620
+ if (value && typeof value === "object" && !Array.isArray(value)) {
2621
+ const { [META]: clazz, [VALUE]: val, ...rest } = value;
2622
+ const constructor = this.classes[clazz];
2623
+ if (constructor) {
2624
+ return Object.assign(Object.create(constructor.prototype), rest);
2625
+ }
2626
+ if (clazz === "Date")
2627
+ return new Date(val);
2628
+ if (clazz === "Set")
2629
+ return new Set(val);
2630
+ if (clazz === "Map")
2631
+ return new Map(Object.entries(val));
2632
+ if (clazz === "bigint")
2633
+ return BigInt(val);
2634
+ if (clazz === "undefined")
2635
+ return void 0;
2636
+ return rest;
2637
+ }
2638
+ return value;
2639
+ });
2640
+ }
2641
+ }
2642
+ const defaultSerializer = new Serializer();
2643
+ const serialize = (data) => {
2644
+ return defaultSerializer.toJSON(data);
2645
+ };
2646
+ const deserialize = (json) => {
2647
+ return defaultSerializer.fromJSON(json);
2648
+ };
2649
+
2650
+ function buildWorkerRunner(config) {
2651
+ return function xataWorker(name, _worker) {
2652
+ return async (...args) => {
2653
+ const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
2654
+ const result = await fetch(url, {
2655
+ method: "POST",
2656
+ headers: { "Content-Type": "application/json" },
2657
+ body: serialize({ args })
2658
+ });
2659
+ const text = await result.text();
2660
+ return deserialize(text);
2661
+ };
2662
+ };
2663
+ }
2664
+
1645
2665
  class XataError extends Error {
1646
2666
  constructor(message, status) {
1647
2667
  super(message);
@@ -1657,22 +2677,32 @@ exports.PAGINATION_MAX_OFFSET = PAGINATION_MAX_OFFSET;
1657
2677
  exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
1658
2678
  exports.Page = Page;
1659
2679
  exports.Query = Query;
2680
+ exports.RecordArray = RecordArray;
1660
2681
  exports.Repository = Repository;
1661
2682
  exports.RestRepository = RestRepository;
1662
2683
  exports.SchemaPlugin = SchemaPlugin;
1663
2684
  exports.SearchPlugin = SearchPlugin;
2685
+ exports.Serializer = Serializer;
2686
+ exports.SimpleCache = SimpleCache;
1664
2687
  exports.XataApiClient = XataApiClient;
1665
2688
  exports.XataApiPlugin = XataApiPlugin;
1666
2689
  exports.XataError = XataError;
1667
2690
  exports.XataPlugin = XataPlugin;
1668
2691
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
2692
+ exports.addGitBranchesEntry = addGitBranchesEntry;
1669
2693
  exports.addTableColumn = addTableColumn;
2694
+ exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
1670
2695
  exports.buildClient = buildClient;
2696
+ exports.buildWorkerRunner = buildWorkerRunner;
1671
2697
  exports.bulkInsertTableRecords = bulkInsertTableRecords;
1672
2698
  exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
2699
+ exports.compareBranchSchemas = compareBranchSchemas;
2700
+ exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
2701
+ exports.compareMigrationRequest = compareMigrationRequest;
1673
2702
  exports.contains = contains;
1674
2703
  exports.createBranch = createBranch;
1675
2704
  exports.createDatabase = createDatabase;
2705
+ exports.createMigrationRequest = createMigrationRequest;
1676
2706
  exports.createTable = createTable;
1677
2707
  exports.createUserAPIKey = createUserAPIKey;
1678
2708
  exports.createWorkspace = createWorkspace;
@@ -1684,7 +2714,9 @@ exports.deleteTable = deleteTable;
1684
2714
  exports.deleteUser = deleteUser;
1685
2715
  exports.deleteUserAPIKey = deleteUserAPIKey;
1686
2716
  exports.deleteWorkspace = deleteWorkspace;
2717
+ exports.deserialize = deserialize;
1687
2718
  exports.endsWith = endsWith;
2719
+ exports.equals = equals;
1688
2720
  exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
1689
2721
  exports.exists = exists;
1690
2722
  exports.ge = ge;
@@ -1694,12 +2726,18 @@ exports.getBranchList = getBranchList;
1694
2726
  exports.getBranchMetadata = getBranchMetadata;
1695
2727
  exports.getBranchMigrationHistory = getBranchMigrationHistory;
1696
2728
  exports.getBranchMigrationPlan = getBranchMigrationPlan;
2729
+ exports.getBranchSchemaHistory = getBranchSchemaHistory;
1697
2730
  exports.getBranchStats = getBranchStats;
1698
2731
  exports.getColumn = getColumn;
1699
2732
  exports.getCurrentBranchDetails = getCurrentBranchDetails;
1700
2733
  exports.getCurrentBranchName = getCurrentBranchName;
1701
2734
  exports.getDatabaseList = getDatabaseList;
2735
+ exports.getDatabaseMetadata = getDatabaseMetadata;
1702
2736
  exports.getDatabaseURL = getDatabaseURL;
2737
+ exports.getGitBranchesMapping = getGitBranchesMapping;
2738
+ exports.getHostUrl = getHostUrl;
2739
+ exports.getMigrationRequest = getMigrationRequest;
2740
+ exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
1703
2741
  exports.getRecord = getRecord;
1704
2742
  exports.getTableColumns = getTableColumns;
1705
2743
  exports.getTableSchema = getTableSchema;
@@ -1708,6 +2746,9 @@ exports.getUserAPIKeys = getUserAPIKeys;
1708
2746
  exports.getWorkspace = getWorkspace;
1709
2747
  exports.getWorkspaceMembersList = getWorkspaceMembersList;
1710
2748
  exports.getWorkspacesList = getWorkspacesList;
2749
+ exports.greaterEquals = greaterEquals;
2750
+ exports.greaterThan = greaterThan;
2751
+ exports.greaterThanEquals = greaterThanEquals;
1711
2752
  exports.gt = gt;
1712
2753
  exports.gte = gte;
1713
2754
  exports.includes = includes;
@@ -1718,27 +2759,47 @@ exports.insertRecord = insertRecord;
1718
2759
  exports.insertRecordWithID = insertRecordWithID;
1719
2760
  exports.inviteWorkspaceMember = inviteWorkspaceMember;
1720
2761
  exports.is = is;
2762
+ exports.isCursorPaginationOptions = isCursorPaginationOptions;
2763
+ exports.isHostProviderAlias = isHostProviderAlias;
2764
+ exports.isHostProviderBuilder = isHostProviderBuilder;
1721
2765
  exports.isIdentifiable = isIdentifiable;
1722
2766
  exports.isNot = isNot;
1723
2767
  exports.isXataRecord = isXataRecord;
1724
2768
  exports.le = le;
2769
+ exports.lessEquals = lessEquals;
2770
+ exports.lessThan = lessThan;
2771
+ exports.lessThanEquals = lessThanEquals;
2772
+ exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
1725
2773
  exports.lt = lt;
1726
2774
  exports.lte = lte;
2775
+ exports.mergeMigrationRequest = mergeMigrationRequest;
1727
2776
  exports.notExists = notExists;
1728
2777
  exports.operationsByTag = operationsByTag;
2778
+ exports.parseProviderString = parseProviderString;
1729
2779
  exports.pattern = pattern;
2780
+ exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
2781
+ exports.queryMigrationRequests = queryMigrationRequests;
1730
2782
  exports.queryTable = queryTable;
2783
+ exports.removeGitBranchesEntry = removeGitBranchesEntry;
1731
2784
  exports.removeWorkspaceMember = removeWorkspaceMember;
1732
2785
  exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
2786
+ exports.resolveBranch = resolveBranch;
1733
2787
  exports.searchBranch = searchBranch;
2788
+ exports.searchTable = searchTable;
2789
+ exports.serialize = serialize;
1734
2790
  exports.setTableSchema = setTableSchema;
1735
2791
  exports.startsWith = startsWith;
2792
+ exports.summarizeTable = summarizeTable;
1736
2793
  exports.updateBranchMetadata = updateBranchMetadata;
2794
+ exports.updateBranchSchema = updateBranchSchema;
1737
2795
  exports.updateColumn = updateColumn;
2796
+ exports.updateDatabaseMetadata = updateDatabaseMetadata;
2797
+ exports.updateMigrationRequest = updateMigrationRequest;
1738
2798
  exports.updateRecordWithID = updateRecordWithID;
1739
2799
  exports.updateTable = updateTable;
1740
2800
  exports.updateUser = updateUser;
1741
2801
  exports.updateWorkspace = updateWorkspace;
2802
+ exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
1742
2803
  exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
1743
2804
  exports.upsertRecordWithID = upsertRecordWithID;
1744
2805
  //# sourceMappingURL=index.cjs.map