@xata.io/client 0.0.0-alpha.vfd6aaf3 → 0.0.0-alpha.vfde8eac

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2,6 +2,46 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ function _interopNamespace(e) {
6
+ if (e && e.__esModule) return e;
7
+ var n = Object.create(null);
8
+ if (e) {
9
+ Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default') {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n["default"] = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ const defaultTrace = async (_name, fn, _options) => {
24
+ return await fn({
25
+ setAttributes: () => {
26
+ return;
27
+ }
28
+ });
29
+ };
30
+ const TraceAttributes = {
31
+ KIND: "xata.trace.kind",
32
+ VERSION: "xata.sdk.version",
33
+ TABLE: "xata.table",
34
+ HTTP_REQUEST_ID: "http.request_id",
35
+ HTTP_STATUS_CODE: "http.status_code",
36
+ HTTP_HOST: "http.host",
37
+ HTTP_SCHEME: "http.scheme",
38
+ HTTP_USER_AGENT: "http.user_agent",
39
+ HTTP_METHOD: "http.method",
40
+ HTTP_URL: "http.url",
41
+ HTTP_ROUTE: "http.route",
42
+ HTTP_TARGET: "http.target"
43
+ };
44
+
5
45
  function notEmpty(value) {
6
46
  return value !== null && value !== void 0;
7
47
  }
@@ -17,6 +57,12 @@ function isDefined(value) {
17
57
  function isString(value) {
18
58
  return isDefined(value) && typeof value === "string";
19
59
  }
60
+ function isStringArray(value) {
61
+ return isDefined(value) && Array.isArray(value) && value.every(isString);
62
+ }
63
+ function isNumber(value) {
64
+ return isDefined(value) && typeof value === "number";
65
+ }
20
66
  function toBase64(value) {
21
67
  try {
22
68
  return btoa(value);
@@ -25,36 +71,95 @@ function toBase64(value) {
25
71
  return buf.from(value).toString("base64");
26
72
  }
27
73
  }
74
+ function deepMerge(a, b) {
75
+ const result = { ...a };
76
+ for (const [key, value] of Object.entries(b)) {
77
+ if (isObject(value) && isObject(result[key])) {
78
+ result[key] = deepMerge(result[key], value);
79
+ } else {
80
+ result[key] = value;
81
+ }
82
+ }
83
+ return result;
84
+ }
28
85
 
29
- function getEnvVariable(name) {
86
+ function getEnvironment() {
30
87
  try {
31
- if (isObject(process) && isString(process?.env?.[name])) {
32
- return process.env[name];
88
+ if (isObject(process) && isObject(process.env)) {
89
+ return {
90
+ apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
91
+ databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
92
+ branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
93
+ envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
94
+ fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
95
+ };
33
96
  }
34
97
  } catch (err) {
35
98
  }
36
99
  try {
37
- if (isObject(Deno) && isString(Deno?.env?.get(name))) {
38
- return Deno.env.get(name);
100
+ if (isObject(Deno) && isObject(Deno.env)) {
101
+ return {
102
+ apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
103
+ databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
104
+ branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
105
+ envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
106
+ fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
107
+ };
39
108
  }
40
109
  } catch (err) {
41
110
  }
111
+ return {
112
+ apiKey: getGlobalApiKey(),
113
+ databaseURL: getGlobalDatabaseURL(),
114
+ branch: getGlobalBranch(),
115
+ envBranch: void 0,
116
+ fallbackBranch: getGlobalFallbackBranch()
117
+ };
118
+ }
119
+ function getGlobalApiKey() {
120
+ try {
121
+ return XATA_API_KEY;
122
+ } catch (err) {
123
+ return void 0;
124
+ }
125
+ }
126
+ function getGlobalDatabaseURL() {
127
+ try {
128
+ return XATA_DATABASE_URL;
129
+ } catch (err) {
130
+ return void 0;
131
+ }
132
+ }
133
+ function getGlobalBranch() {
134
+ try {
135
+ return XATA_BRANCH;
136
+ } catch (err) {
137
+ return void 0;
138
+ }
139
+ }
140
+ function getGlobalFallbackBranch() {
141
+ try {
142
+ return XATA_FALLBACK_BRANCH;
143
+ } catch (err) {
144
+ return void 0;
145
+ }
42
146
  }
43
147
  async function getGitBranch() {
148
+ const cmd = ["git", "branch", "--show-current"];
149
+ const fullCmd = cmd.join(" ");
150
+ const nodeModule = ["child", "process"].join("_");
151
+ const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
44
152
  try {
45
153
  if (typeof require === "function") {
46
- const req = require;
47
- return req("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
154
+ return require(nodeModule).execSync(fullCmd, execOptions).trim();
48
155
  }
156
+ const { execSync } = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(nodeModule);
157
+ return execSync(fullCmd, execOptions).toString().trim();
49
158
  } catch (err) {
50
159
  }
51
160
  try {
52
161
  if (isObject(Deno)) {
53
- const process2 = Deno.run({
54
- cmd: ["git", "branch", "--show-current"],
55
- stdout: "piped",
56
- stderr: "piped"
57
- });
162
+ const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
58
163
  return new TextDecoder().decode(await process2.output()).trim();
59
164
  }
60
165
  } catch (err) {
@@ -63,7 +168,8 @@ async function getGitBranch() {
63
168
 
64
169
  function getAPIKey() {
65
170
  try {
66
- return getEnvVariable("XATA_API_KEY") ?? XATA_API_KEY;
171
+ const { apiKey } = getEnvironment();
172
+ return apiKey;
67
173
  } catch (err) {
68
174
  return void 0;
69
175
  }
@@ -73,12 +179,14 @@ function getFetchImplementation(userFetch) {
73
179
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
74
180
  const fetchImpl = userFetch ?? globalFetch;
75
181
  if (!fetchImpl) {
76
- throw new Error(`The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`);
182
+ throw new Error(
183
+ `Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
184
+ );
77
185
  }
78
186
  return fetchImpl;
79
187
  }
80
188
 
81
- const VERSION = "0.0.0-alpha.vfd6aaf3";
189
+ const VERSION = "0.0.0-alpha.vfde8eac";
82
190
 
83
191
  class ErrorWithCause extends Error {
84
192
  constructor(message, options) {
@@ -129,18 +237,24 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
129
237
  }, {});
130
238
  const query = new URLSearchParams(cleanQueryParams).toString();
131
239
  const queryString = query.length > 0 ? `?${query}` : "";
132
- return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
240
+ const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
241
+ return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
242
+ }, {});
243
+ return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
133
244
  };
134
245
  function buildBaseUrl({
246
+ endpoint,
135
247
  path,
136
248
  workspacesApiUrl,
137
249
  apiUrl,
138
- pathParams
250
+ pathParams = {}
139
251
  }) {
140
- if (!pathParams?.workspace)
141
- return `${apiUrl}${path}`;
142
- const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
143
- return url.replace("{workspaceId}", pathParams.workspace);
252
+ if (endpoint === "dataPlane") {
253
+ const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
254
+ const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
255
+ return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
256
+ }
257
+ return `${apiUrl}${path}`;
144
258
  }
145
259
  function hostHeader(url) {
146
260
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
@@ -156,278 +270,238 @@ async function fetch$1({
156
270
  queryParams,
157
271
  fetchImpl,
158
272
  apiKey,
273
+ endpoint,
159
274
  apiUrl,
160
- workspacesApiUrl
275
+ workspacesApiUrl,
276
+ trace,
277
+ signal,
278
+ clientID,
279
+ sessionID
161
280
  }) {
162
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
163
- const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
164
- const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
165
- const response = await fetchImpl(url, {
166
- method: method.toUpperCase(),
167
- body: body ? JSON.stringify(body) : void 0,
168
- headers: {
169
- "Content-Type": "application/json",
170
- "User-Agent": `Xata client-ts/${VERSION}`,
171
- ...headers,
172
- ...hostHeader(fullUrl),
173
- Authorization: `Bearer ${apiKey}`
174
- }
175
- });
176
- if (response.status === 204) {
177
- return {};
178
- }
179
- const requestId = response.headers?.get("x-request-id") ?? void 0;
281
+ return trace(
282
+ `${method.toUpperCase()} ${path}`,
283
+ async ({ setAttributes }) => {
284
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
285
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
286
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
287
+ setAttributes({
288
+ [TraceAttributes.HTTP_URL]: url,
289
+ [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
290
+ });
291
+ const response = await fetchImpl(url, {
292
+ method: method.toUpperCase(),
293
+ body: body ? JSON.stringify(body) : void 0,
294
+ headers: {
295
+ "Content-Type": "application/json",
296
+ "User-Agent": `Xata client-ts/${VERSION}`,
297
+ "X-Xata-Client-ID": clientID ?? "",
298
+ "X-Xata-Session-ID": sessionID ?? "",
299
+ ...headers,
300
+ ...hostHeader(fullUrl),
301
+ Authorization: `Bearer ${apiKey}`
302
+ },
303
+ signal
304
+ });
305
+ if (response.status === 204) {
306
+ return {};
307
+ }
308
+ const { host, protocol } = parseUrl(response.url);
309
+ const requestId = response.headers?.get("x-request-id") ?? void 0;
310
+ setAttributes({
311
+ [TraceAttributes.KIND]: "http",
312
+ [TraceAttributes.HTTP_REQUEST_ID]: requestId,
313
+ [TraceAttributes.HTTP_STATUS_CODE]: response.status,
314
+ [TraceAttributes.HTTP_HOST]: host,
315
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
316
+ });
317
+ try {
318
+ const jsonResponse = await response.json();
319
+ if (response.ok) {
320
+ return jsonResponse;
321
+ }
322
+ throw new FetcherError(response.status, jsonResponse, requestId);
323
+ } catch (error) {
324
+ throw new FetcherError(response.status, error, requestId);
325
+ }
326
+ },
327
+ { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
328
+ );
329
+ }
330
+ function parseUrl(url) {
180
331
  try {
181
- const jsonResponse = await response.json();
182
- if (response.ok) {
183
- return jsonResponse;
184
- }
185
- throw new FetcherError(response.status, jsonResponse, requestId);
332
+ const { host, protocol } = new URL(url);
333
+ return { host, protocol };
186
334
  } catch (error) {
187
- throw new FetcherError(response.status, error, requestId);
335
+ return {};
188
336
  }
189
337
  }
190
338
 
191
- const getUser = (variables) => fetch$1({ url: "/user", method: "get", ...variables });
192
- const updateUser = (variables) => fetch$1({ url: "/user", method: "put", ...variables });
193
- const deleteUser = (variables) => fetch$1({ url: "/user", method: "delete", ...variables });
194
- const getUserAPIKeys = (variables) => fetch$1({
195
- url: "/user/keys",
196
- method: "get",
197
- ...variables
198
- });
199
- const createUserAPIKey = (variables) => fetch$1({
200
- url: "/user/keys/{keyName}",
201
- method: "post",
202
- ...variables
203
- });
204
- const deleteUserAPIKey = (variables) => fetch$1({
205
- url: "/user/keys/{keyName}",
206
- method: "delete",
207
- ...variables
208
- });
209
- const createWorkspace = (variables) => fetch$1({
210
- url: "/workspaces",
211
- method: "post",
212
- ...variables
213
- });
214
- const getWorkspacesList = (variables) => fetch$1({
215
- url: "/workspaces",
216
- method: "get",
217
- ...variables
218
- });
219
- const getWorkspace = (variables) => fetch$1({
220
- url: "/workspaces/{workspaceId}",
221
- method: "get",
222
- ...variables
223
- });
224
- const updateWorkspace = (variables) => fetch$1({
225
- url: "/workspaces/{workspaceId}",
226
- method: "put",
227
- ...variables
228
- });
229
- const deleteWorkspace = (variables) => fetch$1({
230
- url: "/workspaces/{workspaceId}",
231
- method: "delete",
232
- ...variables
233
- });
234
- const getWorkspaceMembersList = (variables) => fetch$1({
235
- url: "/workspaces/{workspaceId}/members",
236
- method: "get",
237
- ...variables
238
- });
239
- const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
240
- const removeWorkspaceMember = (variables) => fetch$1({
241
- url: "/workspaces/{workspaceId}/members/{userId}",
242
- method: "delete",
243
- ...variables
244
- });
245
- const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
246
- const cancelWorkspaceMemberInvite = (variables) => fetch$1({
247
- url: "/workspaces/{workspaceId}/invites/{inviteId}",
248
- method: "delete",
249
- ...variables
250
- });
251
- const resendWorkspaceMemberInvite = (variables) => fetch$1({
252
- url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
253
- method: "post",
254
- ...variables
255
- });
256
- const acceptWorkspaceMemberInvite = (variables) => fetch$1({
257
- url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
258
- method: "post",
259
- ...variables
260
- });
261
- const getDatabaseList = (variables) => fetch$1({
339
+ const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
340
+
341
+ const getDatabaseList = (variables, signal) => dataPlaneFetch({
262
342
  url: "/dbs",
263
343
  method: "get",
264
- ...variables
344
+ ...variables,
345
+ signal
265
346
  });
266
- const getBranchList = (variables) => fetch$1({
347
+ const getBranchList = (variables, signal) => dataPlaneFetch({
267
348
  url: "/dbs/{dbName}",
268
349
  method: "get",
269
- ...variables
270
- });
271
- const createDatabase = (variables) => fetch$1({
272
- url: "/dbs/{dbName}",
273
- method: "put",
274
- ...variables
350
+ ...variables,
351
+ signal
275
352
  });
276
- const deleteDatabase = (variables) => fetch$1({
353
+ const createDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
354
+ const deleteDatabase = (variables, signal) => dataPlaneFetch({
277
355
  url: "/dbs/{dbName}",
278
356
  method: "delete",
279
- ...variables
357
+ ...variables,
358
+ signal
280
359
  });
281
- const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
282
- const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
283
- const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
284
- const resolveBranch = (variables) => fetch$1({
285
- url: "/dbs/{dbName}/resolveBranch",
360
+ const getDatabaseMetadata = (variables, signal) => dataPlaneFetch({
361
+ url: "/dbs/{dbName}/metadata",
286
362
  method: "get",
287
- ...variables
363
+ ...variables,
364
+ signal
288
365
  });
289
- const getBranchDetails = (variables) => fetch$1({
366
+ const updateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
367
+ const getBranchDetails = (variables, signal) => dataPlaneFetch({
290
368
  url: "/db/{dbBranchName}",
291
369
  method: "get",
292
- ...variables
293
- });
294
- const createBranch = (variables) => fetch$1({
295
- url: "/db/{dbBranchName}",
296
- method: "put",
297
- ...variables
370
+ ...variables,
371
+ signal
298
372
  });
299
- const deleteBranch = (variables) => fetch$1({
373
+ const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
374
+ const deleteBranch = (variables, signal) => dataPlaneFetch({
300
375
  url: "/db/{dbBranchName}",
301
376
  method: "delete",
302
- ...variables
377
+ ...variables,
378
+ signal
303
379
  });
304
- const updateBranchMetadata = (variables) => fetch$1({
380
+ const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
305
381
  url: "/db/{dbBranchName}/metadata",
306
382
  method: "put",
307
- ...variables
383
+ ...variables,
384
+ signal
308
385
  });
309
- const getBranchMetadata = (variables) => fetch$1({
386
+ const getBranchMetadata = (variables, signal) => dataPlaneFetch({
310
387
  url: "/db/{dbBranchName}/metadata",
311
388
  method: "get",
312
- ...variables
389
+ ...variables,
390
+ signal
313
391
  });
314
- const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
315
- const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
316
- const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
317
- const getBranchStats = (variables) => fetch$1({
392
+ const getBranchStats = (variables, signal) => dataPlaneFetch({
318
393
  url: "/db/{dbBranchName}/stats",
319
394
  method: "get",
320
- ...variables
395
+ ...variables,
396
+ signal
397
+ });
398
+ const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
399
+ const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
400
+ const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
401
+ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
402
+ const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
403
+ const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
404
+ const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
405
+ const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
406
+ const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
407
+ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
408
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
409
+ method: "get",
410
+ ...variables,
411
+ signal
321
412
  });
322
- const createTable = (variables) => fetch$1({
413
+ const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
414
+ const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
415
+ const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
416
+ const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
417
+ const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
418
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
419
+ method: "post",
420
+ ...variables,
421
+ signal
422
+ });
423
+ const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
424
+ const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
425
+ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
426
+ const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
427
+ const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
428
+ const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
429
+ const createTable = (variables, signal) => dataPlaneFetch({
323
430
  url: "/db/{dbBranchName}/tables/{tableName}",
324
431
  method: "put",
325
- ...variables
432
+ ...variables,
433
+ signal
326
434
  });
327
- const deleteTable = (variables) => fetch$1({
435
+ const deleteTable = (variables, signal) => dataPlaneFetch({
328
436
  url: "/db/{dbBranchName}/tables/{tableName}",
329
437
  method: "delete",
330
- ...variables
331
- });
332
- const updateTable = (variables) => fetch$1({
333
- url: "/db/{dbBranchName}/tables/{tableName}",
334
- method: "patch",
335
- ...variables
438
+ ...variables,
439
+ signal
336
440
  });
337
- const getTableSchema = (variables) => fetch$1({
441
+ const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
442
+ const getTableSchema = (variables, signal) => dataPlaneFetch({
338
443
  url: "/db/{dbBranchName}/tables/{tableName}/schema",
339
444
  method: "get",
340
- ...variables
445
+ ...variables,
446
+ signal
341
447
  });
342
- const setTableSchema = (variables) => fetch$1({
343
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
344
- method: "put",
345
- ...variables
346
- });
347
- const getTableColumns = (variables) => fetch$1({
448
+ const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
449
+ const getTableColumns = (variables, signal) => dataPlaneFetch({
348
450
  url: "/db/{dbBranchName}/tables/{tableName}/columns",
349
451
  method: "get",
350
- ...variables
351
- });
352
- const addTableColumn = (variables) => fetch$1({
353
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
354
- method: "post",
355
- ...variables
452
+ ...variables,
453
+ signal
356
454
  });
357
- const getColumn = (variables) => fetch$1({
455
+ const addTableColumn = (variables, signal) => dataPlaneFetch(
456
+ { url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
457
+ );
458
+ const getColumn = (variables, signal) => dataPlaneFetch({
358
459
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
359
460
  method: "get",
360
- ...variables
461
+ ...variables,
462
+ signal
361
463
  });
362
- const deleteColumn = (variables) => fetch$1({
464
+ const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
465
+ const deleteColumn = (variables, signal) => dataPlaneFetch({
363
466
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
364
467
  method: "delete",
365
- ...variables
468
+ ...variables,
469
+ signal
366
470
  });
367
- const updateColumn = (variables) => fetch$1({
368
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
369
- method: "patch",
370
- ...variables
371
- });
372
- const insertRecord = (variables) => fetch$1({
373
- url: "/db/{dbBranchName}/tables/{tableName}/data",
374
- method: "post",
375
- ...variables
376
- });
377
- const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
378
- const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
379
- const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
380
- const deleteRecord = (variables) => fetch$1({
381
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
382
- method: "delete",
383
- ...variables
384
- });
385
- const getRecord = (variables) => fetch$1({
471
+ const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
472
+ const getRecord = (variables, signal) => dataPlaneFetch({
386
473
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
387
474
  method: "get",
388
- ...variables
475
+ ...variables,
476
+ signal
389
477
  });
390
- const bulkInsertTableRecords = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables });
391
- const queryTable = (variables) => fetch$1({
478
+ const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
479
+ const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
480
+ const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
481
+ const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
482
+ const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
483
+ const queryTable = (variables, signal) => dataPlaneFetch({
392
484
  url: "/db/{dbBranchName}/tables/{tableName}/query",
393
485
  method: "post",
394
- ...variables
486
+ ...variables,
487
+ signal
395
488
  });
396
- const searchTable = (variables) => fetch$1({
397
- url: "/db/{dbBranchName}/tables/{tableName}/search",
489
+ const searchBranch = (variables, signal) => dataPlaneFetch({
490
+ url: "/db/{dbBranchName}/search",
398
491
  method: "post",
399
- ...variables
492
+ ...variables,
493
+ signal
400
494
  });
401
- const searchBranch = (variables) => fetch$1({
402
- url: "/db/{dbBranchName}/search",
495
+ const searchTable = (variables, signal) => dataPlaneFetch({
496
+ url: "/db/{dbBranchName}/tables/{tableName}/search",
403
497
  method: "post",
404
- ...variables
498
+ ...variables,
499
+ signal
405
500
  });
406
- const operationsByTag = {
407
- users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
408
- workspaces: {
409
- createWorkspace,
410
- getWorkspacesList,
411
- getWorkspace,
412
- updateWorkspace,
413
- deleteWorkspace,
414
- getWorkspaceMembersList,
415
- updateWorkspaceMemberRole,
416
- removeWorkspaceMember,
417
- inviteWorkspaceMember,
418
- cancelWorkspaceMemberInvite,
419
- resendWorkspaceMemberInvite,
420
- acceptWorkspaceMemberInvite
421
- },
422
- database: {
423
- getDatabaseList,
424
- createDatabase,
425
- deleteDatabase,
426
- getGitBranchesMapping,
427
- addGitBranchesEntry,
428
- removeGitBranchesEntry,
429
- resolveBranch
430
- },
501
+ const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
502
+ const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
503
+ const operationsByTag$2 = {
504
+ database: { getDatabaseList, createDatabase, deleteDatabase, getDatabaseMetadata, updateDatabaseMetadata },
431
505
  branch: {
432
506
  getBranchList,
433
507
  getBranchDetails,
@@ -435,10 +509,32 @@ const operationsByTag = {
435
509
  deleteBranch,
436
510
  updateBranchMetadata,
437
511
  getBranchMetadata,
512
+ getBranchStats,
513
+ getGitBranchesMapping,
514
+ addGitBranchesEntry,
515
+ removeGitBranchesEntry,
516
+ resolveBranch
517
+ },
518
+ migrations: {
438
519
  getBranchMigrationHistory,
439
- executeBranchMigrationPlan,
440
520
  getBranchMigrationPlan,
441
- getBranchStats
521
+ executeBranchMigrationPlan,
522
+ getBranchSchemaHistory,
523
+ compareBranchWithUserSchema,
524
+ compareBranchSchemas,
525
+ updateBranchSchema,
526
+ previewBranchSchemaEdit,
527
+ applyBranchSchemaEdit
528
+ },
529
+ migrationRequests: {
530
+ queryMigrationRequests,
531
+ createMigrationRequest,
532
+ getMigrationRequest,
533
+ updateMigrationRequest,
534
+ listMigrationRequestsCommits,
535
+ compareMigrationRequest,
536
+ getMigrationRequestIsMerged,
537
+ mergeMigrationRequest
442
538
  },
443
539
  table: {
444
540
  createTable,
@@ -449,27 +545,154 @@ const operationsByTag = {
449
545
  getTableColumns,
450
546
  addTableColumn,
451
547
  getColumn,
452
- deleteColumn,
453
- updateColumn
548
+ updateColumn,
549
+ deleteColumn
454
550
  },
455
551
  records: {
456
552
  insertRecord,
553
+ getRecord,
457
554
  insertRecordWithID,
458
555
  updateRecordWithID,
459
556
  upsertRecordWithID,
460
557
  deleteRecord,
461
- getRecord,
462
- bulkInsertTableRecords,
463
- queryTable,
464
- searchTable,
465
- searchBranch
558
+ bulkInsertTableRecords
559
+ },
560
+ searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
561
+ };
562
+
563
+ const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
564
+
565
+ const getUser = (variables, signal) => controlPlaneFetch({
566
+ url: "/user",
567
+ method: "get",
568
+ ...variables,
569
+ signal
570
+ });
571
+ const updateUser = (variables, signal) => controlPlaneFetch({
572
+ url: "/user",
573
+ method: "put",
574
+ ...variables,
575
+ signal
576
+ });
577
+ const deleteUser = (variables, signal) => controlPlaneFetch({
578
+ url: "/user",
579
+ method: "delete",
580
+ ...variables,
581
+ signal
582
+ });
583
+ const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
584
+ url: "/user/keys",
585
+ method: "get",
586
+ ...variables,
587
+ signal
588
+ });
589
+ const createUserAPIKey = (variables, signal) => controlPlaneFetch({
590
+ url: "/user/keys/{keyName}",
591
+ method: "post",
592
+ ...variables,
593
+ signal
594
+ });
595
+ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
596
+ url: "/user/keys/{keyName}",
597
+ method: "delete",
598
+ ...variables,
599
+ signal
600
+ });
601
+ const getWorkspacesList = (variables, signal) => controlPlaneFetch({
602
+ url: "/workspaces",
603
+ method: "get",
604
+ ...variables,
605
+ signal
606
+ });
607
+ const createWorkspace = (variables, signal) => controlPlaneFetch({
608
+ url: "/workspaces",
609
+ method: "post",
610
+ ...variables,
611
+ signal
612
+ });
613
+ const getWorkspace = (variables, signal) => controlPlaneFetch({
614
+ url: "/workspaces/{workspaceId}",
615
+ method: "get",
616
+ ...variables,
617
+ signal
618
+ });
619
+ const updateWorkspace = (variables, signal) => controlPlaneFetch({
620
+ url: "/workspaces/{workspaceId}",
621
+ method: "put",
622
+ ...variables,
623
+ signal
624
+ });
625
+ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
626
+ url: "/workspaces/{workspaceId}",
627
+ method: "delete",
628
+ ...variables,
629
+ signal
630
+ });
631
+ const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
632
+ const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
633
+ const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
634
+ url: "/workspaces/{workspaceId}/members/{userId}",
635
+ method: "delete",
636
+ ...variables,
637
+ signal
638
+ });
639
+ const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
640
+ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
641
+ const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
642
+ const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
643
+ const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
644
+ const cPGetDatabaseList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs", method: "get", ...variables, signal });
645
+ const cPCreateDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
646
+ const cPDeleteDatabase = (variables, signal) => controlPlaneFetch({
647
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
648
+ method: "delete",
649
+ ...variables,
650
+ signal
651
+ });
652
+ const cPGetCPDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
653
+ const cPUpdateCPDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
654
+ const listRegions = (variables, signal) => controlPlaneFetch({
655
+ url: "/workspaces/{workspaceId}/regions",
656
+ method: "get",
657
+ ...variables,
658
+ signal
659
+ });
660
+ const operationsByTag$1 = {
661
+ users: { getUser, updateUser, deleteUser },
662
+ authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
663
+ workspaces: {
664
+ getWorkspacesList,
665
+ createWorkspace,
666
+ getWorkspace,
667
+ updateWorkspace,
668
+ deleteWorkspace,
669
+ getWorkspaceMembersList,
670
+ updateWorkspaceMemberRole,
671
+ removeWorkspaceMember
672
+ },
673
+ invites: {
674
+ inviteWorkspaceMember,
675
+ updateWorkspaceMemberInvite,
676
+ cancelWorkspaceMemberInvite,
677
+ acceptWorkspaceMemberInvite,
678
+ resendWorkspaceMemberInvite
679
+ },
680
+ databases: {
681
+ cPGetDatabaseList,
682
+ cPCreateDatabase,
683
+ cPDeleteDatabase,
684
+ cPGetCPDatabaseMetadata,
685
+ cPUpdateCPDatabaseMetadata,
686
+ listRegions
466
687
  }
467
688
  };
468
689
 
690
+ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
691
+
469
692
  function getHostUrl(provider, type) {
470
- if (isValidAlias(provider)) {
693
+ if (isHostProviderAlias(provider)) {
471
694
  return providers[provider][type];
472
- } else if (isValidBuilder(provider)) {
695
+ } else if (isHostProviderBuilder(provider)) {
473
696
  return provider[type];
474
697
  }
475
698
  throw new Error("Invalid API provider");
@@ -477,19 +700,38 @@ function getHostUrl(provider, type) {
477
700
  const providers = {
478
701
  production: {
479
702
  main: "https://api.xata.io",
480
- workspaces: "https://{workspaceId}.xata.sh"
703
+ workspaces: "https://{workspaceId}.{region}.xata.sh"
481
704
  },
482
705
  staging: {
483
706
  main: "https://staging.xatabase.co",
484
- workspaces: "https://{workspaceId}.staging.xatabase.co"
707
+ workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
485
708
  }
486
709
  };
487
- function isValidAlias(alias) {
710
+ function isHostProviderAlias(alias) {
488
711
  return isString(alias) && Object.keys(providers).includes(alias);
489
712
  }
490
- function isValidBuilder(builder) {
713
+ function isHostProviderBuilder(builder) {
491
714
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
492
715
  }
716
+ function parseProviderString(provider = "production") {
717
+ if (isHostProviderAlias(provider)) {
718
+ return provider;
719
+ }
720
+ const [main, workspaces] = provider.split(",");
721
+ if (!main || !workspaces)
722
+ return null;
723
+ return { main, workspaces };
724
+ }
725
+ function parseWorkspacesUrlParts(url) {
726
+ if (!isString(url))
727
+ return null;
728
+ const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
729
+ const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
730
+ const match = url.match(regex) || url.match(regexStaging);
731
+ if (!match)
732
+ return null;
733
+ return { workspace: match[1], region: match[2] ?? "eu-west-1" };
734
+ }
493
735
 
494
736
  var __accessCheck$7 = (obj, member, msg) => {
495
737
  if (!member.has(obj))
@@ -504,7 +746,7 @@ var __privateAdd$7 = (obj, member, value) => {
504
746
  throw TypeError("Cannot add the same private member more than once");
505
747
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
506
748
  };
507
- var __privateSet$6 = (obj, member, value, setter) => {
749
+ var __privateSet$7 = (obj, member, value, setter) => {
508
750
  __accessCheck$7(obj, member, "write to private field");
509
751
  setter ? setter.call(obj, value) : member.set(obj, value);
510
752
  return value;
@@ -515,15 +757,17 @@ class XataApiClient {
515
757
  __privateAdd$7(this, _extraProps, void 0);
516
758
  __privateAdd$7(this, _namespaces, {});
517
759
  const provider = options.host ?? "production";
518
- const apiKey = options?.apiKey ?? getAPIKey();
760
+ const apiKey = options.apiKey ?? getAPIKey();
761
+ const trace = options.trace ?? defaultTrace;
519
762
  if (!apiKey) {
520
763
  throw new Error("Could not resolve a valid apiKey");
521
764
  }
522
- __privateSet$6(this, _extraProps, {
765
+ __privateSet$7(this, _extraProps, {
523
766
  apiUrl: getHostUrl(provider, "main"),
524
767
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
525
768
  fetchImpl: getFetchImplementation(options.fetch),
526
- apiKey
769
+ apiKey,
770
+ trace
527
771
  });
528
772
  }
529
773
  get user() {
@@ -531,21 +775,41 @@ class XataApiClient {
531
775
  __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
532
776
  return __privateGet$7(this, _namespaces).user;
533
777
  }
778
+ get authentication() {
779
+ if (!__privateGet$7(this, _namespaces).authentication)
780
+ __privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
781
+ return __privateGet$7(this, _namespaces).authentication;
782
+ }
534
783
  get workspaces() {
535
784
  if (!__privateGet$7(this, _namespaces).workspaces)
536
785
  __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
537
786
  return __privateGet$7(this, _namespaces).workspaces;
538
787
  }
539
- get databases() {
540
- if (!__privateGet$7(this, _namespaces).databases)
541
- __privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
542
- return __privateGet$7(this, _namespaces).databases;
788
+ get invites() {
789
+ if (!__privateGet$7(this, _namespaces).invites)
790
+ __privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
791
+ return __privateGet$7(this, _namespaces).invites;
792
+ }
793
+ get database() {
794
+ if (!__privateGet$7(this, _namespaces).database)
795
+ __privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
796
+ return __privateGet$7(this, _namespaces).database;
543
797
  }
544
798
  get branches() {
545
799
  if (!__privateGet$7(this, _namespaces).branches)
546
800
  __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
547
801
  return __privateGet$7(this, _namespaces).branches;
548
802
  }
803
+ get migrations() {
804
+ if (!__privateGet$7(this, _namespaces).migrations)
805
+ __privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
806
+ return __privateGet$7(this, _namespaces).migrations;
807
+ }
808
+ get migrationRequests() {
809
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
810
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
811
+ return __privateGet$7(this, _namespaces).migrationRequests;
812
+ }
549
813
  get tables() {
550
814
  if (!__privateGet$7(this, _namespaces).tables)
551
815
  __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
@@ -556,6 +820,11 @@ class XataApiClient {
556
820
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
557
821
  return __privateGet$7(this, _namespaces).records;
558
822
  }
823
+ get searchAndFilter() {
824
+ if (!__privateGet$7(this, _namespaces).searchAndFilter)
825
+ __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
826
+ return __privateGet$7(this, _namespaces).searchAndFilter;
827
+ }
559
828
  }
560
829
  _extraProps = new WeakMap();
561
830
  _namespaces = new WeakMap();
@@ -566,24 +835,29 @@ class UserApi {
566
835
  getUser() {
567
836
  return operationsByTag.users.getUser({ ...this.extraProps });
568
837
  }
569
- updateUser(user) {
838
+ updateUser({ user }) {
570
839
  return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
571
840
  }
572
841
  deleteUser() {
573
842
  return operationsByTag.users.deleteUser({ ...this.extraProps });
574
843
  }
844
+ }
845
+ class AuthenticationApi {
846
+ constructor(extraProps) {
847
+ this.extraProps = extraProps;
848
+ }
575
849
  getUserAPIKeys() {
576
- return operationsByTag.users.getUserAPIKeys({ ...this.extraProps });
850
+ return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
577
851
  }
578
- createUserAPIKey(keyName) {
579
- return operationsByTag.users.createUserAPIKey({
580
- pathParams: { keyName },
852
+ createUserAPIKey({ name }) {
853
+ return operationsByTag.authentication.createUserAPIKey({
854
+ pathParams: { keyName: name },
581
855
  ...this.extraProps
582
856
  });
583
857
  }
584
- deleteUserAPIKey(keyName) {
585
- return operationsByTag.users.deleteUserAPIKey({
586
- pathParams: { keyName },
858
+ deleteUserAPIKey({ name }) {
859
+ return operationsByTag.authentication.deleteUserAPIKey({
860
+ pathParams: { keyName: name },
587
861
  ...this.extraProps
588
862
  });
589
863
  }
@@ -592,342 +866,882 @@ class WorkspaceApi {
592
866
  constructor(extraProps) {
593
867
  this.extraProps = extraProps;
594
868
  }
595
- createWorkspace(workspaceMeta) {
869
+ getWorkspacesList() {
870
+ return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
871
+ }
872
+ createWorkspace({ data }) {
596
873
  return operationsByTag.workspaces.createWorkspace({
597
- body: workspaceMeta,
874
+ body: data,
598
875
  ...this.extraProps
599
876
  });
600
877
  }
601
- getWorkspacesList() {
602
- return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
603
- }
604
- getWorkspace(workspaceId) {
878
+ getWorkspace({ workspace }) {
605
879
  return operationsByTag.workspaces.getWorkspace({
606
- pathParams: { workspaceId },
880
+ pathParams: { workspaceId: workspace },
607
881
  ...this.extraProps
608
882
  });
609
883
  }
610
- updateWorkspace(workspaceId, workspaceMeta) {
884
+ updateWorkspace({
885
+ workspace,
886
+ update
887
+ }) {
611
888
  return operationsByTag.workspaces.updateWorkspace({
612
- pathParams: { workspaceId },
613
- body: workspaceMeta,
889
+ pathParams: { workspaceId: workspace },
890
+ body: update,
614
891
  ...this.extraProps
615
892
  });
616
893
  }
617
- deleteWorkspace(workspaceId) {
894
+ deleteWorkspace({ workspace }) {
618
895
  return operationsByTag.workspaces.deleteWorkspace({
619
- pathParams: { workspaceId },
896
+ pathParams: { workspaceId: workspace },
620
897
  ...this.extraProps
621
898
  });
622
899
  }
623
- getWorkspaceMembersList(workspaceId) {
900
+ getWorkspaceMembersList({ workspace }) {
624
901
  return operationsByTag.workspaces.getWorkspaceMembersList({
625
- pathParams: { workspaceId },
902
+ pathParams: { workspaceId: workspace },
626
903
  ...this.extraProps
627
904
  });
628
905
  }
629
- updateWorkspaceMemberRole(workspaceId, userId, role) {
906
+ updateWorkspaceMemberRole({
907
+ workspace,
908
+ user,
909
+ role
910
+ }) {
630
911
  return operationsByTag.workspaces.updateWorkspaceMemberRole({
631
- pathParams: { workspaceId, userId },
912
+ pathParams: { workspaceId: workspace, userId: user },
632
913
  body: { role },
633
914
  ...this.extraProps
634
915
  });
635
916
  }
636
- removeWorkspaceMember(workspaceId, userId) {
917
+ removeWorkspaceMember({
918
+ workspace,
919
+ user
920
+ }) {
637
921
  return operationsByTag.workspaces.removeWorkspaceMember({
638
- pathParams: { workspaceId, userId },
922
+ pathParams: { workspaceId: workspace, userId: user },
639
923
  ...this.extraProps
640
924
  });
641
925
  }
642
- inviteWorkspaceMember(workspaceId, email, role) {
643
- return operationsByTag.workspaces.inviteWorkspaceMember({
644
- pathParams: { workspaceId },
926
+ }
927
+ class InvitesApi {
928
+ constructor(extraProps) {
929
+ this.extraProps = extraProps;
930
+ }
931
+ inviteWorkspaceMember({
932
+ workspace,
933
+ email,
934
+ role
935
+ }) {
936
+ return operationsByTag.invites.inviteWorkspaceMember({
937
+ pathParams: { workspaceId: workspace },
645
938
  body: { email, role },
646
939
  ...this.extraProps
647
940
  });
648
941
  }
649
- cancelWorkspaceMemberInvite(workspaceId, inviteId) {
650
- return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
651
- pathParams: { workspaceId, inviteId },
942
+ updateWorkspaceMemberInvite({
943
+ workspace,
944
+ invite,
945
+ role
946
+ }) {
947
+ return operationsByTag.invites.updateWorkspaceMemberInvite({
948
+ pathParams: { workspaceId: workspace, inviteId: invite },
949
+ body: { role },
950
+ ...this.extraProps
951
+ });
952
+ }
953
+ cancelWorkspaceMemberInvite({
954
+ workspace,
955
+ invite
956
+ }) {
957
+ return operationsByTag.invites.cancelWorkspaceMemberInvite({
958
+ pathParams: { workspaceId: workspace, inviteId: invite },
652
959
  ...this.extraProps
653
960
  });
654
961
  }
655
- resendWorkspaceMemberInvite(workspaceId, inviteId) {
656
- return operationsByTag.workspaces.resendWorkspaceMemberInvite({
657
- pathParams: { workspaceId, inviteId },
962
+ acceptWorkspaceMemberInvite({
963
+ workspace,
964
+ key
965
+ }) {
966
+ return operationsByTag.invites.acceptWorkspaceMemberInvite({
967
+ pathParams: { workspaceId: workspace, inviteKey: key },
658
968
  ...this.extraProps
659
969
  });
660
970
  }
661
- acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
662
- return operationsByTag.workspaces.acceptWorkspaceMemberInvite({
663
- pathParams: { workspaceId, inviteKey },
971
+ resendWorkspaceMemberInvite({
972
+ workspace,
973
+ invite
974
+ }) {
975
+ return operationsByTag.invites.resendWorkspaceMemberInvite({
976
+ pathParams: { workspaceId: workspace, inviteId: invite },
664
977
  ...this.extraProps
665
978
  });
666
979
  }
667
980
  }
668
- class DatabaseApi {
981
+ class BranchApi {
669
982
  constructor(extraProps) {
670
983
  this.extraProps = extraProps;
671
984
  }
672
- getDatabaseList(workspace) {
673
- return operationsByTag.database.getDatabaseList({
674
- pathParams: { workspace },
985
+ getBranchList({
986
+ workspace,
987
+ region,
988
+ database
989
+ }) {
990
+ return operationsByTag.branch.getBranchList({
991
+ pathParams: { workspace, region, dbName: database },
675
992
  ...this.extraProps
676
993
  });
677
994
  }
678
- createDatabase(workspace, dbName, options = {}) {
679
- return operationsByTag.database.createDatabase({
680
- pathParams: { workspace, dbName },
681
- body: options,
995
+ getBranchDetails({
996
+ workspace,
997
+ region,
998
+ database,
999
+ branch
1000
+ }) {
1001
+ return operationsByTag.branch.getBranchDetails({
1002
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
682
1003
  ...this.extraProps
683
1004
  });
684
1005
  }
685
- deleteDatabase(workspace, dbName) {
686
- return operationsByTag.database.deleteDatabase({
687
- pathParams: { workspace, dbName },
1006
+ createBranch({
1007
+ workspace,
1008
+ region,
1009
+ database,
1010
+ branch,
1011
+ from,
1012
+ metadata
1013
+ }) {
1014
+ return operationsByTag.branch.createBranch({
1015
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1016
+ body: { from, metadata },
688
1017
  ...this.extraProps
689
1018
  });
690
1019
  }
691
- getGitBranchesMapping(workspace, dbName) {
692
- return operationsByTag.database.getGitBranchesMapping({
693
- pathParams: { workspace, dbName },
1020
+ deleteBranch({
1021
+ workspace,
1022
+ region,
1023
+ database,
1024
+ branch
1025
+ }) {
1026
+ return operationsByTag.branch.deleteBranch({
1027
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
694
1028
  ...this.extraProps
695
1029
  });
696
1030
  }
697
- addGitBranchesEntry(workspace, dbName, body) {
698
- return operationsByTag.database.addGitBranchesEntry({
699
- pathParams: { workspace, dbName },
700
- body,
1031
+ updateBranchMetadata({
1032
+ workspace,
1033
+ region,
1034
+ database,
1035
+ branch,
1036
+ metadata
1037
+ }) {
1038
+ return operationsByTag.branch.updateBranchMetadata({
1039
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1040
+ body: metadata,
1041
+ ...this.extraProps
1042
+ });
1043
+ }
1044
+ getBranchMetadata({
1045
+ workspace,
1046
+ region,
1047
+ database,
1048
+ branch
1049
+ }) {
1050
+ return operationsByTag.branch.getBranchMetadata({
1051
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1052
+ ...this.extraProps
1053
+ });
1054
+ }
1055
+ getBranchStats({
1056
+ workspace,
1057
+ region,
1058
+ database,
1059
+ branch
1060
+ }) {
1061
+ return operationsByTag.branch.getBranchStats({
1062
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
701
1063
  ...this.extraProps
702
1064
  });
703
1065
  }
704
- removeGitBranchesEntry(workspace, dbName, gitBranch) {
705
- return operationsByTag.database.removeGitBranchesEntry({
706
- pathParams: { workspace, dbName },
1066
+ getGitBranchesMapping({
1067
+ workspace,
1068
+ region,
1069
+ database
1070
+ }) {
1071
+ return operationsByTag.branch.getGitBranchesMapping({
1072
+ pathParams: { workspace, region, dbName: database },
1073
+ ...this.extraProps
1074
+ });
1075
+ }
1076
+ addGitBranchesEntry({
1077
+ workspace,
1078
+ region,
1079
+ database,
1080
+ gitBranch,
1081
+ xataBranch
1082
+ }) {
1083
+ return operationsByTag.branch.addGitBranchesEntry({
1084
+ pathParams: { workspace, region, dbName: database },
1085
+ body: { gitBranch, xataBranch },
1086
+ ...this.extraProps
1087
+ });
1088
+ }
1089
+ removeGitBranchesEntry({
1090
+ workspace,
1091
+ region,
1092
+ database,
1093
+ gitBranch
1094
+ }) {
1095
+ return operationsByTag.branch.removeGitBranchesEntry({
1096
+ pathParams: { workspace, region, dbName: database },
707
1097
  queryParams: { gitBranch },
708
1098
  ...this.extraProps
709
1099
  });
710
1100
  }
711
- resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
712
- return operationsByTag.database.resolveBranch({
713
- pathParams: { workspace, dbName },
1101
+ resolveBranch({
1102
+ workspace,
1103
+ region,
1104
+ database,
1105
+ gitBranch,
1106
+ fallbackBranch
1107
+ }) {
1108
+ return operationsByTag.branch.resolveBranch({
1109
+ pathParams: { workspace, region, dbName: database },
714
1110
  queryParams: { gitBranch, fallbackBranch },
715
1111
  ...this.extraProps
716
1112
  });
717
1113
  }
718
1114
  }
719
- class BranchApi {
1115
+ class TableApi {
720
1116
  constructor(extraProps) {
721
1117
  this.extraProps = extraProps;
722
1118
  }
723
- getBranchList(workspace, dbName) {
724
- return operationsByTag.branch.getBranchList({
725
- pathParams: { workspace, dbName },
1119
+ createTable({
1120
+ workspace,
1121
+ region,
1122
+ database,
1123
+ branch,
1124
+ table
1125
+ }) {
1126
+ return operationsByTag.table.createTable({
1127
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
726
1128
  ...this.extraProps
727
1129
  });
728
1130
  }
729
- getBranchDetails(workspace, database, branch) {
730
- return operationsByTag.branch.getBranchDetails({
731
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1131
+ deleteTable({
1132
+ workspace,
1133
+ region,
1134
+ database,
1135
+ branch,
1136
+ table
1137
+ }) {
1138
+ return operationsByTag.table.deleteTable({
1139
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
732
1140
  ...this.extraProps
733
1141
  });
734
1142
  }
735
- createBranch(workspace, database, branch, from, options = {}) {
736
- return operationsByTag.branch.createBranch({
737
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
738
- queryParams: isString(from) ? { from } : void 0,
739
- body: options,
1143
+ updateTable({
1144
+ workspace,
1145
+ region,
1146
+ database,
1147
+ branch,
1148
+ table,
1149
+ update
1150
+ }) {
1151
+ return operationsByTag.table.updateTable({
1152
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1153
+ body: update,
740
1154
  ...this.extraProps
741
1155
  });
742
1156
  }
743
- deleteBranch(workspace, database, branch) {
744
- return operationsByTag.branch.deleteBranch({
745
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1157
+ getTableSchema({
1158
+ workspace,
1159
+ region,
1160
+ database,
1161
+ branch,
1162
+ table
1163
+ }) {
1164
+ return operationsByTag.table.getTableSchema({
1165
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
746
1166
  ...this.extraProps
747
1167
  });
748
1168
  }
749
- updateBranchMetadata(workspace, database, branch, metadata = {}) {
750
- return operationsByTag.branch.updateBranchMetadata({
751
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
752
- body: metadata,
1169
+ setTableSchema({
1170
+ workspace,
1171
+ region,
1172
+ database,
1173
+ branch,
1174
+ table,
1175
+ schema
1176
+ }) {
1177
+ return operationsByTag.table.setTableSchema({
1178
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1179
+ body: schema,
1180
+ ...this.extraProps
1181
+ });
1182
+ }
1183
+ getTableColumns({
1184
+ workspace,
1185
+ region,
1186
+ database,
1187
+ branch,
1188
+ table
1189
+ }) {
1190
+ return operationsByTag.table.getTableColumns({
1191
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1192
+ ...this.extraProps
1193
+ });
1194
+ }
1195
+ addTableColumn({
1196
+ workspace,
1197
+ region,
1198
+ database,
1199
+ branch,
1200
+ table,
1201
+ column
1202
+ }) {
1203
+ return operationsByTag.table.addTableColumn({
1204
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1205
+ body: column,
1206
+ ...this.extraProps
1207
+ });
1208
+ }
1209
+ getColumn({
1210
+ workspace,
1211
+ region,
1212
+ database,
1213
+ branch,
1214
+ table,
1215
+ column
1216
+ }) {
1217
+ return operationsByTag.table.getColumn({
1218
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1219
+ ...this.extraProps
1220
+ });
1221
+ }
1222
+ updateColumn({
1223
+ workspace,
1224
+ region,
1225
+ database,
1226
+ branch,
1227
+ table,
1228
+ column,
1229
+ update
1230
+ }) {
1231
+ return operationsByTag.table.updateColumn({
1232
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1233
+ body: update,
1234
+ ...this.extraProps
1235
+ });
1236
+ }
1237
+ deleteColumn({
1238
+ workspace,
1239
+ region,
1240
+ database,
1241
+ branch,
1242
+ table,
1243
+ column
1244
+ }) {
1245
+ return operationsByTag.table.deleteColumn({
1246
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1247
+ ...this.extraProps
1248
+ });
1249
+ }
1250
+ }
1251
+ class RecordsApi {
1252
+ constructor(extraProps) {
1253
+ this.extraProps = extraProps;
1254
+ }
1255
+ insertRecord({
1256
+ workspace,
1257
+ region,
1258
+ database,
1259
+ branch,
1260
+ table,
1261
+ record,
1262
+ columns
1263
+ }) {
1264
+ return operationsByTag.records.insertRecord({
1265
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1266
+ queryParams: { columns },
1267
+ body: record,
1268
+ ...this.extraProps
1269
+ });
1270
+ }
1271
+ getRecord({
1272
+ workspace,
1273
+ region,
1274
+ database,
1275
+ branch,
1276
+ table,
1277
+ id,
1278
+ columns
1279
+ }) {
1280
+ return operationsByTag.records.getRecord({
1281
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1282
+ queryParams: { columns },
1283
+ ...this.extraProps
1284
+ });
1285
+ }
1286
+ insertRecordWithID({
1287
+ workspace,
1288
+ region,
1289
+ database,
1290
+ branch,
1291
+ table,
1292
+ id,
1293
+ record,
1294
+ columns,
1295
+ createOnly,
1296
+ ifVersion
1297
+ }) {
1298
+ return operationsByTag.records.insertRecordWithID({
1299
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1300
+ queryParams: { columns, createOnly, ifVersion },
1301
+ body: record,
1302
+ ...this.extraProps
1303
+ });
1304
+ }
1305
+ updateRecordWithID({
1306
+ workspace,
1307
+ region,
1308
+ database,
1309
+ branch,
1310
+ table,
1311
+ id,
1312
+ record,
1313
+ columns,
1314
+ ifVersion
1315
+ }) {
1316
+ return operationsByTag.records.updateRecordWithID({
1317
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1318
+ queryParams: { columns, ifVersion },
1319
+ body: record,
1320
+ ...this.extraProps
1321
+ });
1322
+ }
1323
+ upsertRecordWithID({
1324
+ workspace,
1325
+ region,
1326
+ database,
1327
+ branch,
1328
+ table,
1329
+ id,
1330
+ record,
1331
+ columns,
1332
+ ifVersion
1333
+ }) {
1334
+ return operationsByTag.records.upsertRecordWithID({
1335
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1336
+ queryParams: { columns, ifVersion },
1337
+ body: record,
1338
+ ...this.extraProps
1339
+ });
1340
+ }
1341
+ deleteRecord({
1342
+ workspace,
1343
+ region,
1344
+ database,
1345
+ branch,
1346
+ table,
1347
+ id,
1348
+ columns
1349
+ }) {
1350
+ return operationsByTag.records.deleteRecord({
1351
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1352
+ queryParams: { columns },
1353
+ ...this.extraProps
1354
+ });
1355
+ }
1356
+ bulkInsertTableRecords({
1357
+ workspace,
1358
+ region,
1359
+ database,
1360
+ branch,
1361
+ table,
1362
+ records,
1363
+ columns
1364
+ }) {
1365
+ return operationsByTag.records.bulkInsertTableRecords({
1366
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1367
+ queryParams: { columns },
1368
+ body: { records },
1369
+ ...this.extraProps
1370
+ });
1371
+ }
1372
+ }
1373
+ class SearchAndFilterApi {
1374
+ constructor(extraProps) {
1375
+ this.extraProps = extraProps;
1376
+ }
1377
+ queryTable({
1378
+ workspace,
1379
+ region,
1380
+ database,
1381
+ branch,
1382
+ table,
1383
+ filter,
1384
+ sort,
1385
+ page,
1386
+ columns
1387
+ }) {
1388
+ return operationsByTag.searchAndFilter.queryTable({
1389
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1390
+ body: { filter, sort, page, columns },
1391
+ ...this.extraProps
1392
+ });
1393
+ }
1394
+ searchTable({
1395
+ workspace,
1396
+ region,
1397
+ database,
1398
+ branch,
1399
+ table,
1400
+ query,
1401
+ fuzziness,
1402
+ target,
1403
+ prefix,
1404
+ filter,
1405
+ highlight,
1406
+ boosters
1407
+ }) {
1408
+ return operationsByTag.searchAndFilter.searchTable({
1409
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1410
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
1411
+ ...this.extraProps
1412
+ });
1413
+ }
1414
+ searchBranch({
1415
+ workspace,
1416
+ region,
1417
+ database,
1418
+ branch,
1419
+ tables,
1420
+ query,
1421
+ fuzziness,
1422
+ prefix,
1423
+ highlight
1424
+ }) {
1425
+ return operationsByTag.searchAndFilter.searchBranch({
1426
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1427
+ body: { tables, query, fuzziness, prefix, highlight },
1428
+ ...this.extraProps
1429
+ });
1430
+ }
1431
+ summarizeTable({
1432
+ workspace,
1433
+ region,
1434
+ database,
1435
+ branch,
1436
+ table,
1437
+ filter,
1438
+ columns,
1439
+ summaries,
1440
+ sort,
1441
+ summariesFilter,
1442
+ page
1443
+ }) {
1444
+ return operationsByTag.searchAndFilter.summarizeTable({
1445
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1446
+ body: { filter, columns, summaries, sort, summariesFilter, page },
1447
+ ...this.extraProps
1448
+ });
1449
+ }
1450
+ aggregateTable({
1451
+ workspace,
1452
+ region,
1453
+ database,
1454
+ branch,
1455
+ table,
1456
+ filter,
1457
+ aggs
1458
+ }) {
1459
+ return operationsByTag.searchAndFilter.aggregateTable({
1460
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1461
+ body: { filter, aggs },
1462
+ ...this.extraProps
1463
+ });
1464
+ }
1465
+ }
1466
+ class MigrationRequestsApi {
1467
+ constructor(extraProps) {
1468
+ this.extraProps = extraProps;
1469
+ }
1470
+ queryMigrationRequests({
1471
+ workspace,
1472
+ region,
1473
+ database,
1474
+ filter,
1475
+ sort,
1476
+ page,
1477
+ columns
1478
+ }) {
1479
+ return operationsByTag.migrationRequests.queryMigrationRequests({
1480
+ pathParams: { workspace, region, dbName: database },
1481
+ body: { filter, sort, page, columns },
1482
+ ...this.extraProps
1483
+ });
1484
+ }
1485
+ createMigrationRequest({
1486
+ workspace,
1487
+ region,
1488
+ database,
1489
+ migration
1490
+ }) {
1491
+ return operationsByTag.migrationRequests.createMigrationRequest({
1492
+ pathParams: { workspace, region, dbName: database },
1493
+ body: migration,
1494
+ ...this.extraProps
1495
+ });
1496
+ }
1497
+ getMigrationRequest({
1498
+ workspace,
1499
+ region,
1500
+ database,
1501
+ migrationRequest
1502
+ }) {
1503
+ return operationsByTag.migrationRequests.getMigrationRequest({
1504
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
753
1505
  ...this.extraProps
754
1506
  });
755
1507
  }
756
- getBranchMetadata(workspace, database, branch) {
757
- return operationsByTag.branch.getBranchMetadata({
758
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1508
+ updateMigrationRequest({
1509
+ workspace,
1510
+ region,
1511
+ database,
1512
+ migrationRequest,
1513
+ update
1514
+ }) {
1515
+ return operationsByTag.migrationRequests.updateMigrationRequest({
1516
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1517
+ body: update,
759
1518
  ...this.extraProps
760
1519
  });
761
1520
  }
762
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
763
- return operationsByTag.branch.getBranchMigrationHistory({
764
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
765
- body: options,
1521
+ listMigrationRequestsCommits({
1522
+ workspace,
1523
+ region,
1524
+ database,
1525
+ migrationRequest,
1526
+ page
1527
+ }) {
1528
+ return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1529
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1530
+ body: { page },
766
1531
  ...this.extraProps
767
1532
  });
768
1533
  }
769
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
770
- return operationsByTag.branch.executeBranchMigrationPlan({
771
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
772
- body: migrationPlan,
1534
+ compareMigrationRequest({
1535
+ workspace,
1536
+ region,
1537
+ database,
1538
+ migrationRequest
1539
+ }) {
1540
+ return operationsByTag.migrationRequests.compareMigrationRequest({
1541
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
773
1542
  ...this.extraProps
774
1543
  });
775
1544
  }
776
- getBranchMigrationPlan(workspace, database, branch, schema) {
777
- return operationsByTag.branch.getBranchMigrationPlan({
778
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
779
- body: schema,
1545
+ getMigrationRequestIsMerged({
1546
+ workspace,
1547
+ region,
1548
+ database,
1549
+ migrationRequest
1550
+ }) {
1551
+ return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1552
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
780
1553
  ...this.extraProps
781
1554
  });
782
1555
  }
783
- getBranchStats(workspace, database, branch) {
784
- return operationsByTag.branch.getBranchStats({
785
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1556
+ mergeMigrationRequest({
1557
+ workspace,
1558
+ region,
1559
+ database,
1560
+ migrationRequest
1561
+ }) {
1562
+ return operationsByTag.migrationRequests.mergeMigrationRequest({
1563
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
786
1564
  ...this.extraProps
787
1565
  });
788
1566
  }
789
1567
  }
790
- class TableApi {
1568
+ class MigrationsApi {
791
1569
  constructor(extraProps) {
792
1570
  this.extraProps = extraProps;
793
1571
  }
794
- createTable(workspace, database, branch, tableName) {
795
- return operationsByTag.table.createTable({
796
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
797
- ...this.extraProps
798
- });
799
- }
800
- deleteTable(workspace, database, branch, tableName) {
801
- return operationsByTag.table.deleteTable({
802
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1572
+ getBranchMigrationHistory({
1573
+ workspace,
1574
+ region,
1575
+ database,
1576
+ branch,
1577
+ limit,
1578
+ startFrom
1579
+ }) {
1580
+ return operationsByTag.migrations.getBranchMigrationHistory({
1581
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1582
+ body: { limit, startFrom },
803
1583
  ...this.extraProps
804
1584
  });
805
1585
  }
806
- updateTable(workspace, database, branch, tableName, options) {
807
- return operationsByTag.table.updateTable({
808
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
809
- body: options,
1586
+ getBranchMigrationPlan({
1587
+ workspace,
1588
+ region,
1589
+ database,
1590
+ branch,
1591
+ schema
1592
+ }) {
1593
+ return operationsByTag.migrations.getBranchMigrationPlan({
1594
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1595
+ body: schema,
810
1596
  ...this.extraProps
811
1597
  });
812
1598
  }
813
- getTableSchema(workspace, database, branch, tableName) {
814
- return operationsByTag.table.getTableSchema({
815
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1599
+ executeBranchMigrationPlan({
1600
+ workspace,
1601
+ region,
1602
+ database,
1603
+ branch,
1604
+ plan
1605
+ }) {
1606
+ return operationsByTag.migrations.executeBranchMigrationPlan({
1607
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1608
+ body: plan,
816
1609
  ...this.extraProps
817
1610
  });
818
1611
  }
819
- setTableSchema(workspace, database, branch, tableName, options) {
820
- return operationsByTag.table.setTableSchema({
821
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
822
- body: options,
1612
+ getBranchSchemaHistory({
1613
+ workspace,
1614
+ region,
1615
+ database,
1616
+ branch,
1617
+ page
1618
+ }) {
1619
+ return operationsByTag.migrations.getBranchSchemaHistory({
1620
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1621
+ body: { page },
823
1622
  ...this.extraProps
824
1623
  });
825
1624
  }
826
- getTableColumns(workspace, database, branch, tableName) {
827
- return operationsByTag.table.getTableColumns({
828
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1625
+ compareBranchWithUserSchema({
1626
+ workspace,
1627
+ region,
1628
+ database,
1629
+ branch,
1630
+ schema
1631
+ }) {
1632
+ return operationsByTag.migrations.compareBranchWithUserSchema({
1633
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1634
+ body: { schema },
829
1635
  ...this.extraProps
830
1636
  });
831
1637
  }
832
- addTableColumn(workspace, database, branch, tableName, column) {
833
- return operationsByTag.table.addTableColumn({
834
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
835
- body: column,
1638
+ compareBranchSchemas({
1639
+ workspace,
1640
+ region,
1641
+ database,
1642
+ branch,
1643
+ compare,
1644
+ schema
1645
+ }) {
1646
+ return operationsByTag.migrations.compareBranchSchemas({
1647
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
1648
+ body: { schema },
836
1649
  ...this.extraProps
837
1650
  });
838
1651
  }
839
- getColumn(workspace, database, branch, tableName, columnName) {
840
- return operationsByTag.table.getColumn({
841
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1652
+ updateBranchSchema({
1653
+ workspace,
1654
+ region,
1655
+ database,
1656
+ branch,
1657
+ migration
1658
+ }) {
1659
+ return operationsByTag.migrations.updateBranchSchema({
1660
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1661
+ body: migration,
842
1662
  ...this.extraProps
843
1663
  });
844
1664
  }
845
- deleteColumn(workspace, database, branch, tableName, columnName) {
846
- return operationsByTag.table.deleteColumn({
847
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1665
+ previewBranchSchemaEdit({
1666
+ workspace,
1667
+ region,
1668
+ database,
1669
+ branch,
1670
+ data
1671
+ }) {
1672
+ return operationsByTag.migrations.previewBranchSchemaEdit({
1673
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1674
+ body: data,
848
1675
  ...this.extraProps
849
1676
  });
850
1677
  }
851
- updateColumn(workspace, database, branch, tableName, columnName, options) {
852
- return operationsByTag.table.updateColumn({
853
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
854
- body: options,
1678
+ applyBranchSchemaEdit({
1679
+ workspace,
1680
+ region,
1681
+ database,
1682
+ branch,
1683
+ edits
1684
+ }) {
1685
+ return operationsByTag.migrations.applyBranchSchemaEdit({
1686
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1687
+ body: { edits },
855
1688
  ...this.extraProps
856
1689
  });
857
1690
  }
858
1691
  }
859
- class RecordsApi {
1692
+ class DatabaseApi {
860
1693
  constructor(extraProps) {
861
1694
  this.extraProps = extraProps;
862
1695
  }
863
- insertRecord(workspace, database, branch, tableName, record) {
864
- return operationsByTag.records.insertRecord({
865
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
866
- body: record,
867
- ...this.extraProps
868
- });
869
- }
870
- insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
871
- return operationsByTag.records.insertRecordWithID({
872
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
873
- queryParams: options,
874
- body: record,
875
- ...this.extraProps
876
- });
877
- }
878
- updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
879
- return operationsByTag.records.updateRecordWithID({
880
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
881
- queryParams: options,
882
- body: record,
883
- ...this.extraProps
884
- });
885
- }
886
- upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
887
- return operationsByTag.records.upsertRecordWithID({
888
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
889
- queryParams: options,
890
- body: record,
891
- ...this.extraProps
892
- });
893
- }
894
- deleteRecord(workspace, database, branch, tableName, recordId) {
895
- return operationsByTag.records.deleteRecord({
896
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1696
+ getDatabaseList({ workspace }) {
1697
+ return operationsByTag.databases.cPGetDatabaseList({
1698
+ pathParams: { workspaceId: workspace },
897
1699
  ...this.extraProps
898
1700
  });
899
1701
  }
900
- getRecord(workspace, database, branch, tableName, recordId, options = {}) {
901
- return operationsByTag.records.getRecord({
902
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1702
+ createDatabase({
1703
+ workspace,
1704
+ database,
1705
+ data
1706
+ }) {
1707
+ return operationsByTag.databases.cPCreateDatabase({
1708
+ pathParams: { workspaceId: workspace, dbName: database },
1709
+ body: data,
903
1710
  ...this.extraProps
904
1711
  });
905
1712
  }
906
- bulkInsertTableRecords(workspace, database, branch, tableName, records) {
907
- return operationsByTag.records.bulkInsertTableRecords({
908
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
909
- body: { records },
1713
+ deleteDatabase({
1714
+ workspace,
1715
+ database
1716
+ }) {
1717
+ return operationsByTag.databases.cPDeleteDatabase({
1718
+ pathParams: { workspaceId: workspace, dbName: database },
910
1719
  ...this.extraProps
911
1720
  });
912
1721
  }
913
- queryTable(workspace, database, branch, tableName, query) {
914
- return operationsByTag.records.queryTable({
915
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
916
- body: query,
1722
+ getDatabaseMetadata({
1723
+ workspace,
1724
+ database
1725
+ }) {
1726
+ return operationsByTag.databases.cPGetCPDatabaseMetadata({
1727
+ pathParams: { workspaceId: workspace, dbName: database },
917
1728
  ...this.extraProps
918
1729
  });
919
1730
  }
920
- searchTable(workspace, database, branch, tableName, query) {
921
- return operationsByTag.records.searchTable({
922
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
923
- body: query,
1731
+ updateDatabaseMetadata({
1732
+ workspace,
1733
+ database,
1734
+ metadata
1735
+ }) {
1736
+ return operationsByTag.databases.cPUpdateCPDatabaseMetadata({
1737
+ pathParams: { workspaceId: workspace, dbName: database },
1738
+ body: metadata,
924
1739
  ...this.extraProps
925
1740
  });
926
1741
  }
927
- searchBranch(workspace, database, branch, query) {
928
- return operationsByTag.records.searchBranch({
929
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
930
- body: query,
1742
+ listRegions({ workspace }) {
1743
+ return operationsByTag.databases.listRegions({
1744
+ pathParams: { workspaceId: workspace },
931
1745
  ...this.extraProps
932
1746
  });
933
1747
  }
@@ -943,6 +1757,20 @@ class XataApiPlugin {
943
1757
  class XataPlugin {
944
1758
  }
945
1759
 
1760
+ function generateUUID() {
1761
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
1762
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
1763
+ return v.toString(16);
1764
+ });
1765
+ }
1766
+
1767
+ function cleanFilter(filter) {
1768
+ if (!filter)
1769
+ return void 0;
1770
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
1771
+ return values.length > 0 ? filter : void 0;
1772
+ }
1773
+
946
1774
  var __accessCheck$6 = (obj, member, msg) => {
947
1775
  if (!member.has(obj))
948
1776
  throw TypeError("Cannot " + msg);
@@ -956,7 +1784,7 @@ var __privateAdd$6 = (obj, member, value) => {
956
1784
  throw TypeError("Cannot add the same private member more than once");
957
1785
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
958
1786
  };
959
- var __privateSet$5 = (obj, member, value, setter) => {
1787
+ var __privateSet$6 = (obj, member, value, setter) => {
960
1788
  __accessCheck$6(obj, member, "write to private field");
961
1789
  setter ? setter.call(obj, value) : member.set(obj, value);
962
1790
  return value;
@@ -965,7 +1793,7 @@ var _query, _page;
965
1793
  class Page {
966
1794
  constructor(query, meta, records = []) {
967
1795
  __privateAdd$6(this, _query, void 0);
968
- __privateSet$5(this, _query, query);
1796
+ __privateSet$6(this, _query, query);
969
1797
  this.meta = meta;
970
1798
  this.records = new RecordArray(this, records);
971
1799
  }
@@ -994,10 +1822,10 @@ function isCursorPaginationOptions(options) {
994
1822
  return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
995
1823
  }
996
1824
  const _RecordArray = class extends Array {
997
- constructor(page, overrideRecords) {
998
- super(..._RecordArray.parseConstructorParams(page, overrideRecords));
1825
+ constructor(...args) {
1826
+ super(..._RecordArray.parseConstructorParams(...args));
999
1827
  __privateAdd$6(this, _page, void 0);
1000
- __privateSet$5(this, _page, page);
1828
+ __privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
1001
1829
  }
1002
1830
  static parseConstructorParams(...args) {
1003
1831
  if (args.length === 1 && typeof args[0] === "number") {
@@ -1009,6 +1837,12 @@ const _RecordArray = class extends Array {
1009
1837
  }
1010
1838
  return new Array(...args);
1011
1839
  }
1840
+ toArray() {
1841
+ return new Array(...this);
1842
+ }
1843
+ map(callbackfn, thisArg) {
1844
+ return this.toArray().map(callbackfn, thisArg);
1845
+ }
1012
1846
  async nextPage(size, offset) {
1013
1847
  const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
1014
1848
  return new _RecordArray(newPage);
@@ -1045,24 +1879,29 @@ var __privateAdd$5 = (obj, member, value) => {
1045
1879
  throw TypeError("Cannot add the same private member more than once");
1046
1880
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1047
1881
  };
1048
- var __privateSet$4 = (obj, member, value, setter) => {
1882
+ var __privateSet$5 = (obj, member, value, setter) => {
1049
1883
  __accessCheck$5(obj, member, "write to private field");
1050
1884
  setter ? setter.call(obj, value) : member.set(obj, value);
1051
1885
  return value;
1052
1886
  };
1053
- var _table$1, _repository, _data;
1887
+ var __privateMethod$3 = (obj, member, method) => {
1888
+ __accessCheck$5(obj, member, "access private method");
1889
+ return method;
1890
+ };
1891
+ var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
1054
1892
  const _Query = class {
1055
1893
  constructor(repository, table, data, rawParent) {
1894
+ __privateAdd$5(this, _cleanFilterConstraint);
1056
1895
  __privateAdd$5(this, _table$1, void 0);
1057
1896
  __privateAdd$5(this, _repository, void 0);
1058
1897
  __privateAdd$5(this, _data, { filter: {} });
1059
1898
  this.meta = { page: { cursor: "start", more: true } };
1060
1899
  this.records = new RecordArray(this, []);
1061
- __privateSet$4(this, _table$1, table);
1900
+ __privateSet$5(this, _table$1, table);
1062
1901
  if (repository) {
1063
- __privateSet$4(this, _repository, repository);
1902
+ __privateSet$5(this, _repository, repository);
1064
1903
  } else {
1065
- __privateSet$4(this, _repository, this);
1904
+ __privateSet$5(this, _repository, this);
1066
1905
  }
1067
1906
  const parent = cleanParent(data, rawParent);
1068
1907
  __privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
@@ -1071,7 +1910,7 @@ const _Query = class {
1071
1910
  __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
1072
1911
  __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
1073
1912
  __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
1074
- __privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
1913
+ __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
1075
1914
  __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
1076
1915
  __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
1077
1916
  this.any = this.any.bind(this);
@@ -1109,21 +1948,29 @@ const _Query = class {
1109
1948
  }
1110
1949
  filter(a, b) {
1111
1950
  if (arguments.length === 1) {
1112
- const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
1951
+ const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
1952
+ [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
1953
+ }));
1113
1954
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1114
1955
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1115
1956
  } else {
1116
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
1957
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
1958
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1117
1959
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1118
1960
  }
1119
1961
  }
1120
- sort(column, direction) {
1962
+ sort(column, direction = "asc") {
1121
1963
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1122
1964
  const sort = [...originalSort, { column, direction }];
1123
1965
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
1124
1966
  }
1125
1967
  select(columns) {
1126
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { columns }, __privateGet$5(this, _data));
1968
+ return new _Query(
1969
+ __privateGet$5(this, _repository),
1970
+ __privateGet$5(this, _table$1),
1971
+ { columns },
1972
+ __privateGet$5(this, _data)
1973
+ );
1127
1974
  }
1128
1975
  getPaginated(options = {}) {
1129
1976
  const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
@@ -1146,11 +1993,20 @@ const _Query = class {
1146
1993
  }
1147
1994
  }
1148
1995
  async getMany(options = {}) {
1149
- const page = await this.getPaginated(options);
1996
+ const { pagination = {}, ...rest } = options;
1997
+ const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
1998
+ const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
1999
+ let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
2000
+ const results = [...page.records];
2001
+ while (page.hasNextPage() && results.length < size) {
2002
+ page = await page.nextPage();
2003
+ results.push(...page.records);
2004
+ }
1150
2005
  if (page.hasNextPage() && options.pagination?.size === void 0) {
1151
2006
  console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
1152
2007
  }
1153
- return page.records;
2008
+ const array = new RecordArray(page, results.slice(0, size));
2009
+ return array;
1154
2010
  }
1155
2011
  async getAll(options = {}) {
1156
2012
  const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
@@ -1164,6 +2020,22 @@ const _Query = class {
1164
2020
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
1165
2021
  return records[0] ?? null;
1166
2022
  }
2023
+ async getFirstOrThrow(options = {}) {
2024
+ const records = await this.getMany({ ...options, pagination: { size: 1 } });
2025
+ if (records[0] === void 0)
2026
+ throw new Error("No results found.");
2027
+ return records[0];
2028
+ }
2029
+ async summarize(params = {}) {
2030
+ const { summaries, summariesFilter, ...options } = params;
2031
+ const query = new _Query(
2032
+ __privateGet$5(this, _repository),
2033
+ __privateGet$5(this, _table$1),
2034
+ options,
2035
+ __privateGet$5(this, _data)
2036
+ );
2037
+ return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
2038
+ }
1167
2039
  cache(ttl) {
1168
2040
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1169
2041
  }
@@ -1187,9 +2059,20 @@ let Query = _Query;
1187
2059
  _table$1 = new WeakMap();
1188
2060
  _repository = new WeakMap();
1189
2061
  _data = new WeakMap();
2062
+ _cleanFilterConstraint = new WeakSet();
2063
+ cleanFilterConstraint_fn = function(column, value) {
2064
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
2065
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
2066
+ return { $includes: value };
2067
+ }
2068
+ if (columnType === "link" && isObject(value) && isString(value.id)) {
2069
+ return value.id;
2070
+ }
2071
+ return value;
2072
+ };
1190
2073
  function cleanParent(data, parent) {
1191
2074
  if (isCursorPaginationOptions(data.pagination)) {
1192
- return { ...parent, sorting: void 0, filter: void 0 };
2075
+ return { ...parent, sort: void 0, filter: void 0 };
1193
2076
  }
1194
2077
  return parent;
1195
2078
  }
@@ -1239,7 +2122,7 @@ var __privateAdd$4 = (obj, member, value) => {
1239
2122
  throw TypeError("Cannot add the same private member more than once");
1240
2123
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1241
2124
  };
1242
- var __privateSet$3 = (obj, member, value, setter) => {
2125
+ var __privateSet$4 = (obj, member, value, setter) => {
1243
2126
  __accessCheck$4(obj, member, "write to private field");
1244
2127
  setter ? setter.call(obj, value) : member.set(obj, value);
1245
2128
  return value;
@@ -1248,333 +2131,486 @@ var __privateMethod$2 = (obj, member, method) => {
1248
2131
  __accessCheck$4(obj, member, "access private method");
1249
2132
  return method;
1250
2133
  };
1251
- var _table, _getFetchProps, _cache, _schema$1, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _invalidateCache, invalidateCache_fn, _setCacheRecord, setCacheRecord_fn, _getCacheRecord, getCacheRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchema$1, getSchema_fn$1;
2134
+ var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
1252
2135
  class Repository extends Query {
1253
2136
  }
1254
2137
  class RestRepository extends Query {
1255
2138
  constructor(options) {
1256
- super(null, options.table, {});
2139
+ super(
2140
+ null,
2141
+ { name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
2142
+ {}
2143
+ );
1257
2144
  __privateAdd$4(this, _insertRecordWithoutId);
1258
2145
  __privateAdd$4(this, _insertRecordWithId);
1259
2146
  __privateAdd$4(this, _bulkInsertTableRecords);
1260
2147
  __privateAdd$4(this, _updateRecordWithID);
1261
2148
  __privateAdd$4(this, _upsertRecordWithID);
1262
2149
  __privateAdd$4(this, _deleteRecord);
1263
- __privateAdd$4(this, _invalidateCache);
1264
- __privateAdd$4(this, _setCacheRecord);
1265
- __privateAdd$4(this, _getCacheRecord);
1266
2150
  __privateAdd$4(this, _setCacheQuery);
1267
2151
  __privateAdd$4(this, _getCacheQuery);
1268
- __privateAdd$4(this, _getSchema$1);
2152
+ __privateAdd$4(this, _getSchemaTables$1);
1269
2153
  __privateAdd$4(this, _table, void 0);
1270
2154
  __privateAdd$4(this, _getFetchProps, void 0);
2155
+ __privateAdd$4(this, _db, void 0);
1271
2156
  __privateAdd$4(this, _cache, void 0);
1272
- __privateAdd$4(this, _schema$1, void 0);
1273
- __privateSet$3(this, _table, options.table);
1274
- __privateSet$3(this, _getFetchProps, options.pluginOptions.getFetchProps);
1275
- this.db = options.db;
1276
- __privateSet$3(this, _cache, options.pluginOptions.cache);
1277
- }
1278
- async create(a, b) {
1279
- if (Array.isArray(a)) {
1280
- if (a.length === 0)
1281
- return [];
1282
- const [itemsWithoutIds, itemsWithIds, order] = a.reduce(([accWithoutIds, accWithIds, accOrder], item) => {
1283
- const condition = isString(item.id);
1284
- accOrder.push(condition);
1285
- if (condition) {
1286
- accWithIds.push(item);
1287
- } else {
1288
- accWithoutIds.push(item);
2157
+ __privateAdd$4(this, _schemaTables$2, void 0);
2158
+ __privateAdd$4(this, _trace, void 0);
2159
+ __privateSet$4(this, _table, options.table);
2160
+ __privateSet$4(this, _db, options.db);
2161
+ __privateSet$4(this, _cache, options.pluginOptions.cache);
2162
+ __privateSet$4(this, _schemaTables$2, options.schemaTables);
2163
+ __privateSet$4(this, _getFetchProps, async () => {
2164
+ const props = await options.pluginOptions.getFetchProps();
2165
+ return { ...props, sessionID: generateUUID() };
2166
+ });
2167
+ const trace = options.pluginOptions.trace ?? defaultTrace;
2168
+ __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
2169
+ return trace(name, fn, {
2170
+ ...options2,
2171
+ [TraceAttributes.TABLE]: __privateGet$4(this, _table),
2172
+ [TraceAttributes.KIND]: "sdk-operation",
2173
+ [TraceAttributes.VERSION]: VERSION
2174
+ });
2175
+ });
2176
+ }
2177
+ async create(a, b, c, d) {
2178
+ return __privateGet$4(this, _trace).call(this, "create", async () => {
2179
+ const ifVersion = parseIfVersion(b, c, d);
2180
+ if (Array.isArray(a)) {
2181
+ if (a.length === 0)
2182
+ return [];
2183
+ const columns = isStringArray(b) ? b : void 0;
2184
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
2185
+ }
2186
+ if (isString(a) && isObject(b)) {
2187
+ if (a === "")
2188
+ throw new Error("The id can't be empty");
2189
+ const columns = isStringArray(c) ? c : void 0;
2190
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
2191
+ }
2192
+ if (isObject(a) && isString(a.id)) {
2193
+ if (a.id === "")
2194
+ throw new Error("The id can't be empty");
2195
+ const columns = isStringArray(b) ? b : void 0;
2196
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
2197
+ }
2198
+ if (isObject(a)) {
2199
+ const columns = isStringArray(b) ? b : void 0;
2200
+ return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
2201
+ }
2202
+ throw new Error("Invalid arguments for create method");
2203
+ });
2204
+ }
2205
+ async read(a, b) {
2206
+ return __privateGet$4(this, _trace).call(this, "read", async () => {
2207
+ const columns = isStringArray(b) ? b : ["*"];
2208
+ if (Array.isArray(a)) {
2209
+ if (a.length === 0)
2210
+ return [];
2211
+ const ids = a.map((item) => extractId(item));
2212
+ const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
2213
+ const dictionary = finalObjects.reduce((acc, object) => {
2214
+ acc[object.id] = object;
2215
+ return acc;
2216
+ }, {});
2217
+ return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
2218
+ }
2219
+ const id = extractId(a);
2220
+ if (id) {
2221
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2222
+ try {
2223
+ const response = await getRecord({
2224
+ pathParams: {
2225
+ workspace: "{workspaceId}",
2226
+ dbBranchName: "{dbBranch}",
2227
+ region: "{region}",
2228
+ tableName: __privateGet$4(this, _table),
2229
+ recordId: id
2230
+ },
2231
+ queryParams: { columns },
2232
+ ...fetchProps
2233
+ });
2234
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2235
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2236
+ } catch (e) {
2237
+ if (isObject(e) && e.status === 404) {
2238
+ return null;
2239
+ }
2240
+ throw e;
1289
2241
  }
1290
- return [accWithoutIds, accWithIds, accOrder];
1291
- }, [[], [], []]);
1292
- const recordsWithoutId = await __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, itemsWithoutIds);
1293
- await Promise.all(recordsWithoutId.map((record) => __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record)));
1294
- if (itemsWithIds.length > 100) {
1295
- console.warn("Bulk create operation with id is not optimized in the Xata API yet, this request might be slow");
1296
2242
  }
1297
- const recordsWithId = await Promise.all(itemsWithIds.map((object) => this.create(object)));
1298
- return order.map((condition) => {
1299
- if (condition) {
1300
- return recordsWithId.shift();
1301
- } else {
1302
- return recordsWithoutId.shift();
2243
+ return null;
2244
+ });
2245
+ }
2246
+ async readOrThrow(a, b) {
2247
+ return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
2248
+ const result = await this.read(a, b);
2249
+ if (Array.isArray(result)) {
2250
+ const missingIds = compact(
2251
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
2252
+ );
2253
+ if (missingIds.length > 0) {
2254
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1303
2255
  }
1304
- }).filter((record) => !!record);
1305
- }
1306
- if (isString(a) && isObject(b)) {
1307
- if (a === "")
1308
- throw new Error("The id can't be empty");
1309
- const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b);
1310
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1311
- return record;
1312
- }
1313
- if (isObject(a) && isString(a.id)) {
1314
- if (a.id === "")
1315
- throw new Error("The id can't be empty");
1316
- const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 });
1317
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1318
- return record;
1319
- }
1320
- if (isObject(a)) {
1321
- const record = await __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a);
1322
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1323
- return record;
1324
- }
1325
- throw new Error("Invalid arguments for create method");
1326
- }
1327
- async read(a) {
1328
- if (Array.isArray(a)) {
1329
- if (a.length === 0)
1330
- return [];
1331
- const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
1332
- return this.getAll({ filter: { id: { $any: ids } } });
1333
- }
1334
- const id = isString(a) ? a : a.id;
1335
- if (isString(id)) {
1336
- const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, id);
1337
- if (cacheRecord)
1338
- return cacheRecord;
1339
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1340
- try {
1341
- const response = await getRecord({
1342
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: id },
1343
- ...fetchProps
1344
- });
1345
- const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1346
- return initObject(this.db, schema, __privateGet$4(this, _table), response);
1347
- } catch (e) {
1348
- if (isObject(e) && e.status === 404) {
1349
- return null;
2256
+ return result;
2257
+ }
2258
+ if (result === null) {
2259
+ const id = extractId(a) ?? "unknown";
2260
+ throw new Error(`Record with id ${id} not found`);
2261
+ }
2262
+ return result;
2263
+ });
2264
+ }
2265
+ async update(a, b, c, d) {
2266
+ return __privateGet$4(this, _trace).call(this, "update", async () => {
2267
+ const ifVersion = parseIfVersion(b, c, d);
2268
+ if (Array.isArray(a)) {
2269
+ if (a.length === 0)
2270
+ return [];
2271
+ if (a.length > 100) {
2272
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1350
2273
  }
1351
- throw e;
2274
+ const columns = isStringArray(b) ? b : ["*"];
2275
+ return Promise.all(a.map((object) => this.update(object, columns)));
1352
2276
  }
1353
- }
2277
+ if (isString(a) && isObject(b)) {
2278
+ const columns = isStringArray(c) ? c : void 0;
2279
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2280
+ }
2281
+ if (isObject(a) && isString(a.id)) {
2282
+ const columns = isStringArray(b) ? b : void 0;
2283
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2284
+ }
2285
+ throw new Error("Invalid arguments for update method");
2286
+ });
1354
2287
  }
1355
- async update(a, b) {
1356
- if (Array.isArray(a)) {
1357
- if (a.length === 0)
1358
- return [];
1359
- if (a.length > 100) {
1360
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
2288
+ async updateOrThrow(a, b, c, d) {
2289
+ return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
2290
+ const result = await this.update(a, b, c, d);
2291
+ if (Array.isArray(result)) {
2292
+ const missingIds = compact(
2293
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
2294
+ );
2295
+ if (missingIds.length > 0) {
2296
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
2297
+ }
2298
+ return result;
1361
2299
  }
1362
- return Promise.all(a.map((object) => this.update(object)));
1363
- }
1364
- if (isString(a) && isObject(b)) {
1365
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1366
- const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b);
1367
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1368
- return record;
1369
- }
1370
- if (isObject(a) && isString(a.id)) {
1371
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1372
- const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1373
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1374
- return record;
1375
- }
1376
- throw new Error("Invalid arguments for update method");
1377
- }
1378
- async createOrUpdate(a, b) {
1379
- if (Array.isArray(a)) {
1380
- if (a.length === 0)
1381
- return [];
1382
- if (a.length > 100) {
1383
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
2300
+ if (result === null) {
2301
+ const id = extractId(a) ?? "unknown";
2302
+ throw new Error(`Record with id ${id} not found`);
1384
2303
  }
1385
- return Promise.all(a.map((object) => this.createOrUpdate(object)));
1386
- }
1387
- if (isString(a) && isObject(b)) {
1388
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1389
- const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b);
1390
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1391
- return record;
1392
- }
1393
- if (isObject(a) && isString(a.id)) {
1394
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1395
- const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1396
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1397
- return record;
1398
- }
1399
- throw new Error("Invalid arguments for createOrUpdate method");
1400
- }
1401
- async delete(a) {
1402
- if (Array.isArray(a)) {
1403
- if (a.length === 0)
1404
- return;
1405
- if (a.length > 100) {
1406
- console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
2304
+ return result;
2305
+ });
2306
+ }
2307
+ async createOrUpdate(a, b, c, d) {
2308
+ return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
2309
+ const ifVersion = parseIfVersion(b, c, d);
2310
+ if (Array.isArray(a)) {
2311
+ if (a.length === 0)
2312
+ return [];
2313
+ if (a.length > 100) {
2314
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
2315
+ }
2316
+ const columns = isStringArray(b) ? b : ["*"];
2317
+ return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
1407
2318
  }
1408
- await Promise.all(a.map((id) => this.delete(id)));
1409
- return;
1410
- }
1411
- if (isString(a)) {
1412
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
1413
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1414
- return;
1415
- }
1416
- if (isObject(a) && isString(a.id)) {
1417
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
1418
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1419
- return;
1420
- }
1421
- throw new Error("Invalid arguments for delete method");
2319
+ if (isString(a) && isObject(b)) {
2320
+ const columns = isStringArray(c) ? c : void 0;
2321
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2322
+ }
2323
+ if (isObject(a) && isString(a.id)) {
2324
+ const columns = isStringArray(c) ? c : void 0;
2325
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2326
+ }
2327
+ throw new Error("Invalid arguments for createOrUpdate method");
2328
+ });
2329
+ }
2330
+ async createOrReplace(a, b, c, d) {
2331
+ return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
2332
+ const ifVersion = parseIfVersion(b, c, d);
2333
+ if (Array.isArray(a)) {
2334
+ if (a.length === 0)
2335
+ return [];
2336
+ const columns = isStringArray(b) ? b : ["*"];
2337
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
2338
+ }
2339
+ if (isString(a) && isObject(b)) {
2340
+ const columns = isStringArray(c) ? c : void 0;
2341
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
2342
+ }
2343
+ if (isObject(a) && isString(a.id)) {
2344
+ const columns = isStringArray(c) ? c : void 0;
2345
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
2346
+ }
2347
+ throw new Error("Invalid arguments for createOrReplace method");
2348
+ });
2349
+ }
2350
+ async delete(a, b) {
2351
+ return __privateGet$4(this, _trace).call(this, "delete", async () => {
2352
+ if (Array.isArray(a)) {
2353
+ if (a.length === 0)
2354
+ return [];
2355
+ if (a.length > 100) {
2356
+ console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
2357
+ }
2358
+ return Promise.all(a.map((id) => this.delete(id, b)));
2359
+ }
2360
+ if (isString(a)) {
2361
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
2362
+ }
2363
+ if (isObject(a) && isString(a.id)) {
2364
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
2365
+ }
2366
+ throw new Error("Invalid arguments for delete method");
2367
+ });
2368
+ }
2369
+ async deleteOrThrow(a, b) {
2370
+ return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
2371
+ const result = await this.delete(a, b);
2372
+ if (Array.isArray(result)) {
2373
+ const missingIds = compact(
2374
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
2375
+ );
2376
+ if (missingIds.length > 0) {
2377
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
2378
+ }
2379
+ return result;
2380
+ } else if (result === null) {
2381
+ const id = extractId(a) ?? "unknown";
2382
+ throw new Error(`Record with id ${id} not found`);
2383
+ }
2384
+ return result;
2385
+ });
1422
2386
  }
1423
2387
  async search(query, options = {}) {
1424
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1425
- const { records } = await searchTable({
1426
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1427
- body: {
1428
- query,
1429
- fuzziness: options.fuzziness,
1430
- highlight: options.highlight,
1431
- filter: options.filter
1432
- },
1433
- ...fetchProps
2388
+ return __privateGet$4(this, _trace).call(this, "search", async () => {
2389
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2390
+ const { records } = await searchTable({
2391
+ pathParams: {
2392
+ workspace: "{workspaceId}",
2393
+ dbBranchName: "{dbBranch}",
2394
+ region: "{region}",
2395
+ tableName: __privateGet$4(this, _table)
2396
+ },
2397
+ body: {
2398
+ query,
2399
+ fuzziness: options.fuzziness,
2400
+ prefix: options.prefix,
2401
+ highlight: options.highlight,
2402
+ filter: options.filter,
2403
+ boosters: options.boosters
2404
+ },
2405
+ ...fetchProps
2406
+ });
2407
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2408
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
2409
+ });
2410
+ }
2411
+ async aggregate(aggs, filter) {
2412
+ return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
2413
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2414
+ const result = await aggregateTable({
2415
+ pathParams: {
2416
+ workspace: "{workspaceId}",
2417
+ dbBranchName: "{dbBranch}",
2418
+ region: "{region}",
2419
+ tableName: __privateGet$4(this, _table)
2420
+ },
2421
+ body: { aggs, filter },
2422
+ ...fetchProps
2423
+ });
2424
+ return result;
1434
2425
  });
1435
- const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1436
- return records.map((item) => initObject(this.db, schema, __privateGet$4(this, _table), item));
1437
2426
  }
1438
2427
  async query(query) {
1439
- const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1440
- if (cacheQuery)
1441
- return new Page(query, cacheQuery.meta, cacheQuery.records);
1442
- const data = query.getQueryOptions();
1443
- const body = {
1444
- filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1445
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1446
- page: data.pagination,
1447
- columns: data.columns
1448
- };
1449
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1450
- const { meta, records: objects } = await queryTable({
1451
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1452
- body,
1453
- ...fetchProps
2428
+ return __privateGet$4(this, _trace).call(this, "query", async () => {
2429
+ const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
2430
+ if (cacheQuery)
2431
+ return new Page(query, cacheQuery.meta, cacheQuery.records);
2432
+ const data = query.getQueryOptions();
2433
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2434
+ const { meta, records: objects } = await queryTable({
2435
+ pathParams: {
2436
+ workspace: "{workspaceId}",
2437
+ dbBranchName: "{dbBranch}",
2438
+ region: "{region}",
2439
+ tableName: __privateGet$4(this, _table)
2440
+ },
2441
+ body: {
2442
+ filter: cleanFilter(data.filter),
2443
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2444
+ page: data.pagination,
2445
+ columns: data.columns ?? ["*"]
2446
+ },
2447
+ ...fetchProps
2448
+ });
2449
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2450
+ const records = objects.map(
2451
+ (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
2452
+ );
2453
+ await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
2454
+ return new Page(query, meta, records);
2455
+ });
2456
+ }
2457
+ async summarizeTable(query, summaries, summariesFilter) {
2458
+ return __privateGet$4(this, _trace).call(this, "summarize", async () => {
2459
+ const data = query.getQueryOptions();
2460
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2461
+ const result = await summarizeTable({
2462
+ pathParams: {
2463
+ workspace: "{workspaceId}",
2464
+ dbBranchName: "{dbBranch}",
2465
+ region: "{region}",
2466
+ tableName: __privateGet$4(this, _table)
2467
+ },
2468
+ body: {
2469
+ filter: cleanFilter(data.filter),
2470
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2471
+ columns: data.columns,
2472
+ page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
2473
+ summaries,
2474
+ summariesFilter
2475
+ },
2476
+ ...fetchProps
2477
+ });
2478
+ return result;
1454
2479
  });
1455
- const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1456
- const records = objects.map((record) => initObject(this.db, schema, __privateGet$4(this, _table), record));
1457
- await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1458
- return new Page(query, meta, records);
1459
2480
  }
1460
2481
  }
1461
2482
  _table = new WeakMap();
1462
2483
  _getFetchProps = new WeakMap();
2484
+ _db = new WeakMap();
1463
2485
  _cache = new WeakMap();
1464
- _schema$1 = new WeakMap();
2486
+ _schemaTables$2 = new WeakMap();
2487
+ _trace = new WeakMap();
1465
2488
  _insertRecordWithoutId = new WeakSet();
1466
- insertRecordWithoutId_fn = async function(object) {
2489
+ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1467
2490
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1468
2491
  const record = transformObjectLinks(object);
1469
2492
  const response = await insertRecord({
1470
2493
  pathParams: {
1471
2494
  workspace: "{workspaceId}",
1472
2495
  dbBranchName: "{dbBranch}",
2496
+ region: "{region}",
1473
2497
  tableName: __privateGet$4(this, _table)
1474
2498
  },
2499
+ queryParams: { columns },
1475
2500
  body: record,
1476
2501
  ...fetchProps
1477
2502
  });
1478
- const finalObject = await this.read(response.id);
1479
- if (!finalObject) {
1480
- throw new Error("The server failed to save the record");
1481
- }
1482
- return finalObject;
2503
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2504
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1483
2505
  };
1484
2506
  _insertRecordWithId = new WeakSet();
1485
- insertRecordWithId_fn = async function(recordId, object) {
2507
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
1486
2508
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1487
2509
  const record = transformObjectLinks(object);
1488
2510
  const response = await insertRecordWithID({
1489
2511
  pathParams: {
1490
2512
  workspace: "{workspaceId}",
1491
2513
  dbBranchName: "{dbBranch}",
2514
+ region: "{region}",
1492
2515
  tableName: __privateGet$4(this, _table),
1493
2516
  recordId
1494
2517
  },
1495
2518
  body: record,
1496
- queryParams: { createOnly: true },
2519
+ queryParams: { createOnly, columns, ifVersion },
1497
2520
  ...fetchProps
1498
2521
  });
1499
- const finalObject = await this.read(response.id);
1500
- if (!finalObject) {
1501
- throw new Error("The server failed to save the record");
1502
- }
1503
- return finalObject;
2522
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2523
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1504
2524
  };
1505
2525
  _bulkInsertTableRecords = new WeakSet();
1506
- bulkInsertTableRecords_fn = async function(objects) {
2526
+ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1507
2527
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1508
2528
  const records = objects.map((object) => transformObjectLinks(object));
1509
2529
  const response = await bulkInsertTableRecords({
1510
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2530
+ pathParams: {
2531
+ workspace: "{workspaceId}",
2532
+ dbBranchName: "{dbBranch}",
2533
+ region: "{region}",
2534
+ tableName: __privateGet$4(this, _table)
2535
+ },
2536
+ queryParams: { columns },
1511
2537
  body: { records },
1512
2538
  ...fetchProps
1513
2539
  });
1514
- const finalObjects = await this.read(response.recordIDs);
1515
- if (finalObjects.length !== objects.length) {
1516
- throw new Error("The server failed to save some records");
2540
+ if (!isResponseWithRecords(response)) {
2541
+ throw new Error("Request included columns but server didn't include them");
1517
2542
  }
1518
- return finalObjects;
2543
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2544
+ return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
1519
2545
  };
1520
2546
  _updateRecordWithID = new WeakSet();
1521
- updateRecordWithID_fn = async function(recordId, object) {
2547
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
1522
2548
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1523
2549
  const record = transformObjectLinks(object);
1524
- const response = await updateRecordWithID({
1525
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1526
- body: record,
1527
- ...fetchProps
1528
- });
1529
- const item = await this.read(response.id);
1530
- if (!item)
1531
- throw new Error("The server failed to save the record");
1532
- return item;
2550
+ try {
2551
+ const response = await updateRecordWithID({
2552
+ pathParams: {
2553
+ workspace: "{workspaceId}",
2554
+ dbBranchName: "{dbBranch}",
2555
+ region: "{region}",
2556
+ tableName: __privateGet$4(this, _table),
2557
+ recordId
2558
+ },
2559
+ queryParams: { columns, ifVersion },
2560
+ body: record,
2561
+ ...fetchProps
2562
+ });
2563
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2564
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2565
+ } catch (e) {
2566
+ if (isObject(e) && e.status === 404) {
2567
+ return null;
2568
+ }
2569
+ throw e;
2570
+ }
1533
2571
  };
1534
2572
  _upsertRecordWithID = new WeakSet();
1535
- upsertRecordWithID_fn = async function(recordId, object) {
2573
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
1536
2574
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1537
2575
  const response = await upsertRecordWithID({
1538
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2576
+ pathParams: {
2577
+ workspace: "{workspaceId}",
2578
+ dbBranchName: "{dbBranch}",
2579
+ region: "{region}",
2580
+ tableName: __privateGet$4(this, _table),
2581
+ recordId
2582
+ },
2583
+ queryParams: { columns, ifVersion },
1539
2584
  body: object,
1540
2585
  ...fetchProps
1541
2586
  });
1542
- const item = await this.read(response.id);
1543
- if (!item)
1544
- throw new Error("The server failed to save the record");
1545
- return item;
2587
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2588
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1546
2589
  };
1547
2590
  _deleteRecord = new WeakSet();
1548
- deleteRecord_fn = async function(recordId) {
2591
+ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1549
2592
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1550
- await deleteRecord({
1551
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1552
- ...fetchProps
1553
- });
1554
- };
1555
- _invalidateCache = new WeakSet();
1556
- invalidateCache_fn = async function(recordId) {
1557
- await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1558
- const cacheItems = await __privateGet$4(this, _cache).getAll();
1559
- const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
1560
- for (const [key, value] of queries) {
1561
- const ids = getIds(value);
1562
- if (ids.includes(recordId))
1563
- await __privateGet$4(this, _cache).delete(key);
2593
+ try {
2594
+ const response = await deleteRecord({
2595
+ pathParams: {
2596
+ workspace: "{workspaceId}",
2597
+ dbBranchName: "{dbBranch}",
2598
+ region: "{region}",
2599
+ tableName: __privateGet$4(this, _table),
2600
+ recordId
2601
+ },
2602
+ queryParams: { columns },
2603
+ ...fetchProps
2604
+ });
2605
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2606
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2607
+ } catch (e) {
2608
+ if (isObject(e) && e.status === 404) {
2609
+ return null;
2610
+ }
2611
+ throw e;
1564
2612
  }
1565
2613
  };
1566
- _setCacheRecord = new WeakSet();
1567
- setCacheRecord_fn = async function(record) {
1568
- if (!__privateGet$4(this, _cache).cacheRecords)
1569
- return;
1570
- await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
1571
- };
1572
- _getCacheRecord = new WeakSet();
1573
- getCacheRecord_fn = async function(recordId) {
1574
- if (!__privateGet$4(this, _cache).cacheRecords)
1575
- return null;
1576
- return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1577
- };
1578
2614
  _setCacheQuery = new WeakSet();
1579
2615
  setCacheQuery_fn = async function(query, meta, records) {
1580
2616
  await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
@@ -1591,17 +2627,17 @@ getCacheQuery_fn = async function(query) {
1591
2627
  const hasExpired = result.date.getTime() + ttl < Date.now();
1592
2628
  return hasExpired ? null : result;
1593
2629
  };
1594
- _getSchema$1 = new WeakSet();
1595
- getSchema_fn$1 = async function() {
1596
- if (__privateGet$4(this, _schema$1))
1597
- return __privateGet$4(this, _schema$1);
2630
+ _getSchemaTables$1 = new WeakSet();
2631
+ getSchemaTables_fn$1 = async function() {
2632
+ if (__privateGet$4(this, _schemaTables$2))
2633
+ return __privateGet$4(this, _schemaTables$2);
1598
2634
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1599
2635
  const { schema } = await getBranchDetails({
1600
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2636
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
1601
2637
  ...fetchProps
1602
2638
  });
1603
- __privateSet$3(this, _schema$1, schema);
1604
- return schema;
2639
+ __privateSet$4(this, _schemaTables$2, schema.tables);
2640
+ return schema.tables;
1605
2641
  };
1606
2642
  const transformObjectLinks = (object) => {
1607
2643
  return Object.entries(object).reduce((acc, [key, value]) => {
@@ -1610,14 +2646,16 @@ const transformObjectLinks = (object) => {
1610
2646
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
1611
2647
  }, {});
1612
2648
  };
1613
- const initObject = (db, schema, table, object) => {
2649
+ const initObject = (db, schemaTables, table, object, selectedColumns) => {
1614
2650
  const result = {};
1615
2651
  const { xata, ...rest } = object ?? {};
1616
2652
  Object.assign(result, rest);
1617
- const { columns } = schema.tables.find(({ name }) => name === table) ?? {};
2653
+ const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
1618
2654
  if (!columns)
1619
2655
  console.error(`Table ${table} not found in schema`);
1620
2656
  for (const column of columns ?? []) {
2657
+ if (!isValidColumn(selectedColumns, column))
2658
+ continue;
1621
2659
  const value = result[column.name];
1622
2660
  switch (column.type) {
1623
2661
  case "datetime": {
@@ -1634,17 +2672,35 @@ const initObject = (db, schema, table, object) => {
1634
2672
  if (!linkTable) {
1635
2673
  console.error(`Failed to parse link for field ${column.name}`);
1636
2674
  } else if (isObject(value)) {
1637
- result[column.name] = initObject(db, schema, linkTable, value);
2675
+ const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
2676
+ if (item === column.name) {
2677
+ return [...acc, "*"];
2678
+ }
2679
+ if (item.startsWith(`${column.name}.`)) {
2680
+ const [, ...path] = item.split(".");
2681
+ return [...acc, path.join(".")];
2682
+ }
2683
+ return acc;
2684
+ }, []);
2685
+ result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2686
+ } else {
2687
+ result[column.name] = null;
1638
2688
  }
1639
2689
  break;
1640
2690
  }
2691
+ default:
2692
+ result[column.name] = value ?? null;
2693
+ if (column.notNull === true && value === null) {
2694
+ console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2695
+ }
2696
+ break;
1641
2697
  }
1642
2698
  }
1643
- result.read = function() {
1644
- return db[table].read(result["id"]);
2699
+ result.read = function(columns2) {
2700
+ return db[table].read(result["id"], columns2);
1645
2701
  };
1646
- result.update = function(data) {
1647
- return db[table].update(result["id"], data);
2702
+ result.update = function(data, columns2) {
2703
+ return db[table].update(result["id"], data, columns2);
1648
2704
  };
1649
2705
  result.delete = function() {
1650
2706
  return db[table].delete(result["id"]);
@@ -1658,14 +2714,32 @@ const initObject = (db, schema, table, object) => {
1658
2714
  Object.freeze(result);
1659
2715
  return result;
1660
2716
  };
1661
- function getIds(value) {
1662
- if (Array.isArray(value)) {
1663
- return value.map((item) => getIds(item)).flat();
2717
+ function isResponseWithRecords(value) {
2718
+ return isObject(value) && Array.isArray(value.records);
2719
+ }
2720
+ function extractId(value) {
2721
+ if (isString(value))
2722
+ return value;
2723
+ if (isObject(value) && isString(value.id))
2724
+ return value.id;
2725
+ return void 0;
2726
+ }
2727
+ function isValidColumn(columns, column) {
2728
+ if (columns.includes("*"))
2729
+ return true;
2730
+ if (column.type === "link") {
2731
+ const linkColumns = columns.filter((item) => item.startsWith(column.name));
2732
+ return linkColumns.length > 0;
2733
+ }
2734
+ return columns.includes(column.name);
2735
+ }
2736
+ function parseIfVersion(...args) {
2737
+ for (const arg of args) {
2738
+ if (isObject(arg) && isNumber(arg.ifVersion)) {
2739
+ return arg.ifVersion;
2740
+ }
1664
2741
  }
1665
- if (!isObject(value))
1666
- return [];
1667
- const nestedIds = Object.values(value).map((item) => getIds(item)).flat();
1668
- return isString(value.id) ? [value.id, ...nestedIds] : nestedIds;
2742
+ return void 0;
1669
2743
  }
1670
2744
 
1671
2745
  var __accessCheck$3 = (obj, member, msg) => {
@@ -1681,7 +2755,7 @@ var __privateAdd$3 = (obj, member, value) => {
1681
2755
  throw TypeError("Cannot add the same private member more than once");
1682
2756
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1683
2757
  };
1684
- var __privateSet$2 = (obj, member, value, setter) => {
2758
+ var __privateSet$3 = (obj, member, value, setter) => {
1685
2759
  __accessCheck$3(obj, member, "write to private field");
1686
2760
  setter ? setter.call(obj, value) : member.set(obj, value);
1687
2761
  return value;
@@ -1690,9 +2764,8 @@ var _map;
1690
2764
  class SimpleCache {
1691
2765
  constructor(options = {}) {
1692
2766
  __privateAdd$3(this, _map, void 0);
1693
- __privateSet$2(this, _map, /* @__PURE__ */ new Map());
2767
+ __privateSet$3(this, _map, /* @__PURE__ */ new Map());
1694
2768
  this.capacity = options.max ?? 500;
1695
- this.cacheRecords = options.cacheRecords ?? true;
1696
2769
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
1697
2770
  }
1698
2771
  async getAll() {
@@ -1718,18 +2791,25 @@ class SimpleCache {
1718
2791
  }
1719
2792
  _map = new WeakMap();
1720
2793
 
1721
- const gt = (value) => ({ $gt: value });
1722
- const ge = (value) => ({ $ge: value });
1723
- const gte = (value) => ({ $ge: value });
1724
- const lt = (value) => ({ $lt: value });
1725
- const lte = (value) => ({ $le: value });
1726
- const le = (value) => ({ $le: value });
2794
+ const greaterThan = (value) => ({ $gt: value });
2795
+ const gt = greaterThan;
2796
+ const greaterThanEquals = (value) => ({ $ge: value });
2797
+ const greaterEquals = greaterThanEquals;
2798
+ const gte = greaterThanEquals;
2799
+ const ge = greaterThanEquals;
2800
+ const lessThan = (value) => ({ $lt: value });
2801
+ const lt = lessThan;
2802
+ const lessThanEquals = (value) => ({ $le: value });
2803
+ const lessEquals = lessThanEquals;
2804
+ const lte = lessThanEquals;
2805
+ const le = lessThanEquals;
1727
2806
  const exists = (column) => ({ $exists: column });
1728
2807
  const notExists = (column) => ({ $notExists: column });
1729
2808
  const startsWith = (value) => ({ $startsWith: value });
1730
2809
  const endsWith = (value) => ({ $endsWith: value });
1731
2810
  const pattern = (value) => ({ $pattern: value });
1732
2811
  const is = (value) => ({ $is: value });
2812
+ const equals = is;
1733
2813
  const isNot = (value) => ({ $isNot: value });
1734
2814
  const contains = (value) => ({ $contains: value });
1735
2815
  const includes = (value) => ({ $includes: value });
@@ -1750,31 +2830,42 @@ var __privateAdd$2 = (obj, member, value) => {
1750
2830
  throw TypeError("Cannot add the same private member more than once");
1751
2831
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1752
2832
  };
1753
- var _tables;
2833
+ var __privateSet$2 = (obj, member, value, setter) => {
2834
+ __accessCheck$2(obj, member, "write to private field");
2835
+ setter ? setter.call(obj, value) : member.set(obj, value);
2836
+ return value;
2837
+ };
2838
+ var _tables, _schemaTables$1;
1754
2839
  class SchemaPlugin extends XataPlugin {
1755
- constructor(tableNames) {
2840
+ constructor(schemaTables) {
1756
2841
  super();
1757
- this.tableNames = tableNames;
1758
2842
  __privateAdd$2(this, _tables, {});
2843
+ __privateAdd$2(this, _schemaTables$1, void 0);
2844
+ __privateSet$2(this, _schemaTables$1, schemaTables);
1759
2845
  }
1760
2846
  build(pluginOptions) {
1761
- const db = new Proxy({}, {
1762
- get: (_target, table) => {
1763
- if (!isString(table))
1764
- throw new Error("Invalid table name");
1765
- if (__privateGet$2(this, _tables)[table] === void 0) {
1766
- __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
2847
+ const db = new Proxy(
2848
+ {},
2849
+ {
2850
+ get: (_target, table) => {
2851
+ if (!isString(table))
2852
+ throw new Error("Invalid table name");
2853
+ if (__privateGet$2(this, _tables)[table] === void 0) {
2854
+ __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
2855
+ }
2856
+ return __privateGet$2(this, _tables)[table];
1767
2857
  }
1768
- return __privateGet$2(this, _tables)[table];
1769
2858
  }
1770
- });
1771
- for (const table of this.tableNames ?? []) {
1772
- db[table] = new RestRepository({ db, pluginOptions, table });
2859
+ );
2860
+ const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
2861
+ for (const table of tableNames) {
2862
+ db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
1773
2863
  }
1774
2864
  return db;
1775
2865
  }
1776
2866
  }
1777
2867
  _tables = new WeakMap();
2868
+ _schemaTables$1 = new WeakMap();
1778
2869
 
1779
2870
  var __accessCheck$1 = (obj, member, msg) => {
1780
2871
  if (!member.has(obj))
@@ -1798,82 +2889,77 @@ var __privateMethod$1 = (obj, member, method) => {
1798
2889
  __accessCheck$1(obj, member, "access private method");
1799
2890
  return method;
1800
2891
  };
1801
- var _schema, _search, search_fn, _getSchema, getSchema_fn;
2892
+ var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
1802
2893
  class SearchPlugin extends XataPlugin {
1803
- constructor(db) {
2894
+ constructor(db, schemaTables) {
1804
2895
  super();
1805
2896
  this.db = db;
1806
2897
  __privateAdd$1(this, _search);
1807
- __privateAdd$1(this, _getSchema);
1808
- __privateAdd$1(this, _schema, void 0);
2898
+ __privateAdd$1(this, _getSchemaTables);
2899
+ __privateAdd$1(this, _schemaTables, void 0);
2900
+ __privateSet$1(this, _schemaTables, schemaTables);
1809
2901
  }
1810
2902
  build({ getFetchProps }) {
1811
2903
  return {
1812
2904
  all: async (query, options = {}) => {
1813
2905
  const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
1814
- const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
2906
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
1815
2907
  return records.map((record) => {
1816
2908
  const { table = "orphan" } = record.xata;
1817
- return { table, record: initObject(this.db, schema, table, record) };
2909
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
1818
2910
  });
1819
2911
  },
1820
2912
  byTable: async (query, options = {}) => {
1821
2913
  const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
1822
- const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
2914
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
1823
2915
  return records.reduce((acc, record) => {
1824
2916
  const { table = "orphan" } = record.xata;
1825
2917
  const items = acc[table] ?? [];
1826
- const item = initObject(this.db, schema, table, record);
2918
+ const item = initObject(this.db, schemaTables, table, record, ["*"]);
1827
2919
  return { ...acc, [table]: [...items, item] };
1828
2920
  }, {});
1829
2921
  }
1830
2922
  };
1831
2923
  }
1832
2924
  }
1833
- _schema = new WeakMap();
2925
+ _schemaTables = new WeakMap();
1834
2926
  _search = new WeakSet();
1835
2927
  search_fn = async function(query, options, getFetchProps) {
1836
2928
  const fetchProps = await getFetchProps();
1837
- const { tables, fuzziness, highlight } = options ?? {};
2929
+ const { tables, fuzziness, highlight, prefix } = options ?? {};
1838
2930
  const { records } = await searchBranch({
1839
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1840
- body: { tables, query, fuzziness, highlight },
2931
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
2932
+ body: { tables, query, fuzziness, prefix, highlight },
1841
2933
  ...fetchProps
1842
2934
  });
1843
2935
  return records;
1844
2936
  };
1845
- _getSchema = new WeakSet();
1846
- getSchema_fn = async function(getFetchProps) {
1847
- if (__privateGet$1(this, _schema))
1848
- return __privateGet$1(this, _schema);
2937
+ _getSchemaTables = new WeakSet();
2938
+ getSchemaTables_fn = async function(getFetchProps) {
2939
+ if (__privateGet$1(this, _schemaTables))
2940
+ return __privateGet$1(this, _schemaTables);
1849
2941
  const fetchProps = await getFetchProps();
1850
2942
  const { schema } = await getBranchDetails({
1851
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2943
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
1852
2944
  ...fetchProps
1853
2945
  });
1854
- __privateSet$1(this, _schema, schema);
1855
- return schema;
2946
+ __privateSet$1(this, _schemaTables, schema.tables);
2947
+ return schema.tables;
1856
2948
  };
1857
2949
 
1858
2950
  const isBranchStrategyBuilder = (strategy) => {
1859
2951
  return typeof strategy === "function";
1860
2952
  };
1861
2953
 
1862
- const envBranchNames = [
1863
- "XATA_BRANCH",
1864
- "VERCEL_GIT_COMMIT_REF",
1865
- "CF_PAGES_BRANCH",
1866
- "BRANCH"
1867
- ];
1868
2954
  async function getCurrentBranchName(options) {
1869
- const env = getBranchByEnvVariable();
1870
- if (env) {
1871
- const details = await getDatabaseBranch(env, options);
2955
+ const { branch, envBranch } = getEnvironment();
2956
+ if (branch) {
2957
+ const details = await getDatabaseBranch(branch, options);
1872
2958
  if (details)
1873
- return env;
1874
- console.warn(`Branch ${env} not found in Xata. Ignoring...`);
2959
+ return branch;
2960
+ console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
1875
2961
  }
1876
- const gitBranch = await getGitBranch();
2962
+ const gitBranch = envBranch || await getGitBranch();
1877
2963
  return resolveXataBranch(gitBranch, options);
1878
2964
  }
1879
2965
  async function getCurrentBranchDetails(options) {
@@ -1884,18 +2970,27 @@ async function resolveXataBranch(gitBranch, options) {
1884
2970
  const databaseURL = options?.databaseURL || getDatabaseURL();
1885
2971
  const apiKey = options?.apiKey || getAPIKey();
1886
2972
  if (!databaseURL)
1887
- throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
2973
+ throw new Error(
2974
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2975
+ );
1888
2976
  if (!apiKey)
1889
- throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
2977
+ throw new Error(
2978
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2979
+ );
1890
2980
  const [protocol, , host, , dbName] = databaseURL.split("/");
1891
- const [workspace] = host.split(".");
2981
+ const urlParts = parseWorkspacesUrlParts(host);
2982
+ if (!urlParts)
2983
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
2984
+ const { workspace, region } = urlParts;
2985
+ const { fallbackBranch } = getEnvironment();
1892
2986
  const { branch } = await resolveBranch({
1893
2987
  apiKey,
1894
2988
  apiUrl: databaseURL,
1895
2989
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1896
2990
  workspacesApiUrl: `${protocol}//${host}`,
1897
- pathParams: { dbName, workspace },
1898
- queryParams: { gitBranch, fallbackBranch: getEnvVariable("XATA_FALLBACK_BRANCH") }
2991
+ pathParams: { dbName, workspace, region },
2992
+ queryParams: { gitBranch, fallbackBranch },
2993
+ trace: defaultTrace
1899
2994
  });
1900
2995
  return branch;
1901
2996
  }
@@ -1903,19 +2998,26 @@ async function getDatabaseBranch(branch, options) {
1903
2998
  const databaseURL = options?.databaseURL || getDatabaseURL();
1904
2999
  const apiKey = options?.apiKey || getAPIKey();
1905
3000
  if (!databaseURL)
1906
- throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
3001
+ throw new Error(
3002
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
3003
+ );
1907
3004
  if (!apiKey)
1908
- throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
3005
+ throw new Error(
3006
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
3007
+ );
1909
3008
  const [protocol, , host, , database] = databaseURL.split("/");
1910
- const [workspace] = host.split(".");
1911
- const dbBranchName = `${database}:${branch}`;
3009
+ const urlParts = parseWorkspacesUrlParts(host);
3010
+ if (!urlParts)
3011
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3012
+ const { workspace, region } = urlParts;
1912
3013
  try {
1913
3014
  return await getBranchDetails({
1914
3015
  apiKey,
1915
3016
  apiUrl: databaseURL,
1916
3017
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1917
3018
  workspacesApiUrl: `${protocol}//${host}`,
1918
- pathParams: { dbBranchName, workspace }
3019
+ pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
3020
+ trace: defaultTrace
1919
3021
  });
1920
3022
  } catch (err) {
1921
3023
  if (isObject(err) && err.status === 404)
@@ -1923,21 +3025,10 @@ async function getDatabaseBranch(branch, options) {
1923
3025
  throw err;
1924
3026
  }
1925
3027
  }
1926
- function getBranchByEnvVariable() {
1927
- for (const name of envBranchNames) {
1928
- const value = getEnvVariable(name);
1929
- if (value) {
1930
- return value;
1931
- }
1932
- }
1933
- try {
1934
- return XATA_BRANCH;
1935
- } catch (err) {
1936
- }
1937
- }
1938
3028
  function getDatabaseURL() {
1939
3029
  try {
1940
- return getEnvVariable("XATA_DATABASE_URL") ?? XATA_DATABASE_URL;
3030
+ const { databaseURL } = getEnvironment();
3031
+ return databaseURL;
1941
3032
  } catch (err) {
1942
3033
  return void 0;
1943
3034
  }
@@ -1966,20 +3057,23 @@ var __privateMethod = (obj, member, method) => {
1966
3057
  return method;
1967
3058
  };
1968
3059
  const buildClient = (plugins) => {
1969
- var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
3060
+ var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
1970
3061
  return _a = class {
1971
- constructor(options = {}, tables) {
3062
+ constructor(options = {}, schemaTables) {
1972
3063
  __privateAdd(this, _parseOptions);
1973
3064
  __privateAdd(this, _getFetchProps);
1974
3065
  __privateAdd(this, _evaluateBranch);
1975
3066
  __privateAdd(this, _branch, void 0);
3067
+ __privateAdd(this, _options, void 0);
1976
3068
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
3069
+ __privateSet(this, _options, safeOptions);
1977
3070
  const pluginOptions = {
1978
3071
  getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
1979
- cache: safeOptions.cache
3072
+ cache: safeOptions.cache,
3073
+ trace: safeOptions.trace
1980
3074
  };
1981
- const db = new SchemaPlugin(tables).build(pluginOptions);
1982
- const search = new SearchPlugin(db).build(pluginOptions);
3075
+ const db = new SchemaPlugin(schemaTables).build(pluginOptions);
3076
+ const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
1983
3077
  this.db = db;
1984
3078
  this.search = search;
1985
3079
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
@@ -1995,22 +3089,26 @@ const buildClient = (plugins) => {
1995
3089
  }
1996
3090
  }
1997
3091
  }
1998
- }, _branch = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
3092
+ async getConfig() {
3093
+ const databaseURL = __privateGet(this, _options).databaseURL;
3094
+ const branch = await __privateGet(this, _options).branch();
3095
+ return { databaseURL, branch };
3096
+ }
3097
+ }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
1999
3098
  const fetch = getFetchImplementation(options?.fetch);
2000
3099
  const databaseURL = options?.databaseURL || getDatabaseURL();
2001
3100
  const apiKey = options?.apiKey || getAPIKey();
2002
- const cache = options?.cache ?? new SimpleCache({ cacheRecords: false, defaultQueryTTL: 0 });
3101
+ const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
3102
+ const trace = options?.trace ?? defaultTrace;
2003
3103
  const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
2004
- if (!databaseURL || !apiKey) {
2005
- throw new Error("Options databaseURL and apiKey are required");
3104
+ if (!apiKey) {
3105
+ throw new Error("Option apiKey is required");
2006
3106
  }
2007
- return { fetch, databaseURL, apiKey, branch, cache };
2008
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
2009
- fetch,
2010
- apiKey,
2011
- databaseURL,
2012
- branch
2013
- }) {
3107
+ if (!databaseURL) {
3108
+ throw new Error("Option databaseURL is required");
3109
+ }
3110
+ return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID() };
3111
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
2014
3112
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2015
3113
  if (!branchValue)
2016
3114
  throw new Error("Unable to resolve branch value");
@@ -2020,9 +3118,11 @@ const buildClient = (plugins) => {
2020
3118
  apiUrl: "",
2021
3119
  workspacesApiUrl: (path, params) => {
2022
3120
  const hasBranch = params.dbBranchName ?? params.branch;
2023
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
3121
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
2024
3122
  return databaseURL + newPath;
2025
- }
3123
+ },
3124
+ trace,
3125
+ clientID
2026
3126
  };
2027
3127
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2028
3128
  if (__privateGet(this, _branch))
@@ -2045,6 +3145,88 @@ const buildClient = (plugins) => {
2045
3145
  class BaseClient extends buildClient() {
2046
3146
  }
2047
3147
 
3148
+ const META = "__";
3149
+ const VALUE = "___";
3150
+ class Serializer {
3151
+ constructor() {
3152
+ this.classes = {};
3153
+ }
3154
+ add(clazz) {
3155
+ this.classes[clazz.name] = clazz;
3156
+ }
3157
+ toJSON(data) {
3158
+ function visit(obj) {
3159
+ if (Array.isArray(obj))
3160
+ return obj.map(visit);
3161
+ const type = typeof obj;
3162
+ if (type === "undefined")
3163
+ return { [META]: "undefined" };
3164
+ if (type === "bigint")
3165
+ return { [META]: "bigint", [VALUE]: obj.toString() };
3166
+ if (obj === null || type !== "object")
3167
+ return obj;
3168
+ const constructor = obj.constructor;
3169
+ const o = { [META]: constructor.name };
3170
+ for (const [key, value] of Object.entries(obj)) {
3171
+ o[key] = visit(value);
3172
+ }
3173
+ if (constructor === Date)
3174
+ o[VALUE] = obj.toISOString();
3175
+ if (constructor === Map)
3176
+ o[VALUE] = Object.fromEntries(obj);
3177
+ if (constructor === Set)
3178
+ o[VALUE] = [...obj];
3179
+ return o;
3180
+ }
3181
+ return JSON.stringify(visit(data));
3182
+ }
3183
+ fromJSON(json) {
3184
+ return JSON.parse(json, (key, value) => {
3185
+ if (value && typeof value === "object" && !Array.isArray(value)) {
3186
+ const { [META]: clazz, [VALUE]: val, ...rest } = value;
3187
+ const constructor = this.classes[clazz];
3188
+ if (constructor) {
3189
+ return Object.assign(Object.create(constructor.prototype), rest);
3190
+ }
3191
+ if (clazz === "Date")
3192
+ return new Date(val);
3193
+ if (clazz === "Set")
3194
+ return new Set(val);
3195
+ if (clazz === "Map")
3196
+ return new Map(Object.entries(val));
3197
+ if (clazz === "bigint")
3198
+ return BigInt(val);
3199
+ if (clazz === "undefined")
3200
+ return void 0;
3201
+ return rest;
3202
+ }
3203
+ return value;
3204
+ });
3205
+ }
3206
+ }
3207
+ const defaultSerializer = new Serializer();
3208
+ const serialize = (data) => {
3209
+ return defaultSerializer.toJSON(data);
3210
+ };
3211
+ const deserialize = (json) => {
3212
+ return defaultSerializer.fromJSON(json);
3213
+ };
3214
+
3215
+ function buildWorkerRunner(config) {
3216
+ return function xataWorker(name, _worker) {
3217
+ return async (...args) => {
3218
+ const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
3219
+ const result = await fetch(url, {
3220
+ method: "POST",
3221
+ headers: { "Content-Type": "application/json" },
3222
+ body: serialize({ args })
3223
+ });
3224
+ const text = await result.text();
3225
+ return deserialize(text);
3226
+ };
3227
+ };
3228
+ }
3229
+
2048
3230
  class XataError extends Error {
2049
3231
  constructor(message, status) {
2050
3232
  super(message);
@@ -2065,6 +3247,7 @@ exports.Repository = Repository;
2065
3247
  exports.RestRepository = RestRepository;
2066
3248
  exports.SchemaPlugin = SchemaPlugin;
2067
3249
  exports.SearchPlugin = SearchPlugin;
3250
+ exports.Serializer = Serializer;
2068
3251
  exports.SimpleCache = SimpleCache;
2069
3252
  exports.XataApiClient = XataApiClient;
2070
3253
  exports.XataApiPlugin = XataApiPlugin;
@@ -2073,12 +3256,24 @@ exports.XataPlugin = XataPlugin;
2073
3256
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
2074
3257
  exports.addGitBranchesEntry = addGitBranchesEntry;
2075
3258
  exports.addTableColumn = addTableColumn;
3259
+ exports.aggregateTable = aggregateTable;
3260
+ exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
2076
3261
  exports.buildClient = buildClient;
3262
+ exports.buildWorkerRunner = buildWorkerRunner;
2077
3263
  exports.bulkInsertTableRecords = bulkInsertTableRecords;
3264
+ exports.cPCreateDatabase = cPCreateDatabase;
3265
+ exports.cPDeleteDatabase = cPDeleteDatabase;
3266
+ exports.cPGetCPDatabaseMetadata = cPGetCPDatabaseMetadata;
3267
+ exports.cPGetDatabaseList = cPGetDatabaseList;
3268
+ exports.cPUpdateCPDatabaseMetadata = cPUpdateCPDatabaseMetadata;
2078
3269
  exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
3270
+ exports.compareBranchSchemas = compareBranchSchemas;
3271
+ exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
3272
+ exports.compareMigrationRequest = compareMigrationRequest;
2079
3273
  exports.contains = contains;
2080
3274
  exports.createBranch = createBranch;
2081
3275
  exports.createDatabase = createDatabase;
3276
+ exports.createMigrationRequest = createMigrationRequest;
2082
3277
  exports.createTable = createTable;
2083
3278
  exports.createUserAPIKey = createUserAPIKey;
2084
3279
  exports.createWorkspace = createWorkspace;
@@ -2090,7 +3285,9 @@ exports.deleteTable = deleteTable;
2090
3285
  exports.deleteUser = deleteUser;
2091
3286
  exports.deleteUserAPIKey = deleteUserAPIKey;
2092
3287
  exports.deleteWorkspace = deleteWorkspace;
3288
+ exports.deserialize = deserialize;
2093
3289
  exports.endsWith = endsWith;
3290
+ exports.equals = equals;
2094
3291
  exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
2095
3292
  exports.exists = exists;
2096
3293
  exports.ge = ge;
@@ -2100,13 +3297,18 @@ exports.getBranchList = getBranchList;
2100
3297
  exports.getBranchMetadata = getBranchMetadata;
2101
3298
  exports.getBranchMigrationHistory = getBranchMigrationHistory;
2102
3299
  exports.getBranchMigrationPlan = getBranchMigrationPlan;
3300
+ exports.getBranchSchemaHistory = getBranchSchemaHistory;
2103
3301
  exports.getBranchStats = getBranchStats;
2104
3302
  exports.getColumn = getColumn;
2105
3303
  exports.getCurrentBranchDetails = getCurrentBranchDetails;
2106
3304
  exports.getCurrentBranchName = getCurrentBranchName;
2107
3305
  exports.getDatabaseList = getDatabaseList;
3306
+ exports.getDatabaseMetadata = getDatabaseMetadata;
2108
3307
  exports.getDatabaseURL = getDatabaseURL;
2109
3308
  exports.getGitBranchesMapping = getGitBranchesMapping;
3309
+ exports.getHostUrl = getHostUrl;
3310
+ exports.getMigrationRequest = getMigrationRequest;
3311
+ exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
2110
3312
  exports.getRecord = getRecord;
2111
3313
  exports.getTableColumns = getTableColumns;
2112
3314
  exports.getTableSchema = getTableSchema;
@@ -2115,6 +3317,9 @@ exports.getUserAPIKeys = getUserAPIKeys;
2115
3317
  exports.getWorkspace = getWorkspace;
2116
3318
  exports.getWorkspaceMembersList = getWorkspaceMembersList;
2117
3319
  exports.getWorkspacesList = getWorkspacesList;
3320
+ exports.greaterEquals = greaterEquals;
3321
+ exports.greaterThan = greaterThan;
3322
+ exports.greaterThanEquals = greaterThanEquals;
2118
3323
  exports.gt = gt;
2119
3324
  exports.gte = gte;
2120
3325
  exports.includes = includes;
@@ -2126,15 +3331,27 @@ exports.insertRecordWithID = insertRecordWithID;
2126
3331
  exports.inviteWorkspaceMember = inviteWorkspaceMember;
2127
3332
  exports.is = is;
2128
3333
  exports.isCursorPaginationOptions = isCursorPaginationOptions;
3334
+ exports.isHostProviderAlias = isHostProviderAlias;
3335
+ exports.isHostProviderBuilder = isHostProviderBuilder;
2129
3336
  exports.isIdentifiable = isIdentifiable;
2130
3337
  exports.isNot = isNot;
2131
3338
  exports.isXataRecord = isXataRecord;
2132
3339
  exports.le = le;
3340
+ exports.lessEquals = lessEquals;
3341
+ exports.lessThan = lessThan;
3342
+ exports.lessThanEquals = lessThanEquals;
3343
+ exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
3344
+ exports.listRegions = listRegions;
2133
3345
  exports.lt = lt;
2134
3346
  exports.lte = lte;
3347
+ exports.mergeMigrationRequest = mergeMigrationRequest;
2135
3348
  exports.notExists = notExists;
2136
3349
  exports.operationsByTag = operationsByTag;
3350
+ exports.parseProviderString = parseProviderString;
3351
+ exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
2137
3352
  exports.pattern = pattern;
3353
+ exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
3354
+ exports.queryMigrationRequests = queryMigrationRequests;
2138
3355
  exports.queryTable = queryTable;
2139
3356
  exports.removeGitBranchesEntry = removeGitBranchesEntry;
2140
3357
  exports.removeWorkspaceMember = removeWorkspaceMember;
@@ -2142,14 +3359,20 @@ exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
2142
3359
  exports.resolveBranch = resolveBranch;
2143
3360
  exports.searchBranch = searchBranch;
2144
3361
  exports.searchTable = searchTable;
3362
+ exports.serialize = serialize;
2145
3363
  exports.setTableSchema = setTableSchema;
2146
3364
  exports.startsWith = startsWith;
3365
+ exports.summarizeTable = summarizeTable;
2147
3366
  exports.updateBranchMetadata = updateBranchMetadata;
3367
+ exports.updateBranchSchema = updateBranchSchema;
2148
3368
  exports.updateColumn = updateColumn;
3369
+ exports.updateDatabaseMetadata = updateDatabaseMetadata;
3370
+ exports.updateMigrationRequest = updateMigrationRequest;
2149
3371
  exports.updateRecordWithID = updateRecordWithID;
2150
3372
  exports.updateTable = updateTable;
2151
3373
  exports.updateUser = updateUser;
2152
3374
  exports.updateWorkspace = updateWorkspace;
3375
+ exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
2153
3376
  exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
2154
3377
  exports.upsertRecordWithID = upsertRecordWithID;
2155
3378
  //# sourceMappingURL=index.cjs.map