@xata.io/client 0.0.0-alpha.vfef462e → 0.0.0-alpha.vff52a72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,3 +1,25 @@
1
+ const defaultTrace = async (_name, fn, _options) => {
2
+ return await fn({
3
+ setAttributes: () => {
4
+ return;
5
+ }
6
+ });
7
+ };
8
+ const TraceAttributes = {
9
+ KIND: "xata.trace.kind",
10
+ VERSION: "xata.sdk.version",
11
+ TABLE: "xata.table",
12
+ HTTP_REQUEST_ID: "http.request_id",
13
+ HTTP_STATUS_CODE: "http.status_code",
14
+ HTTP_HOST: "http.host",
15
+ HTTP_SCHEME: "http.scheme",
16
+ HTTP_USER_AGENT: "http.user_agent",
17
+ HTTP_METHOD: "http.method",
18
+ HTTP_URL: "http.url",
19
+ HTTP_ROUTE: "http.route",
20
+ HTTP_TARGET: "http.target"
21
+ };
22
+
1
23
  function notEmpty(value) {
2
24
  return value !== null && value !== void 0;
3
25
  }
@@ -16,6 +38,9 @@ function isString(value) {
16
38
  function isStringArray(value) {
17
39
  return isDefined(value) && Array.isArray(value) && value.every(isString);
18
40
  }
41
+ function isNumber(value) {
42
+ return isDefined(value) && typeof value === "number";
43
+ }
19
44
  function toBase64(value) {
20
45
  try {
21
46
  return btoa(value);
@@ -24,6 +49,17 @@ function toBase64(value) {
24
49
  return buf.from(value).toString("base64");
25
50
  }
26
51
  }
52
+ function deepMerge(a, b) {
53
+ const result = { ...a };
54
+ for (const [key, value] of Object.entries(b)) {
55
+ if (isObject(value) && isObject(result[key])) {
56
+ result[key] = deepMerge(result[key], value);
57
+ } else {
58
+ result[key] = value;
59
+ }
60
+ }
61
+ return result;
62
+ }
27
63
 
28
64
  function getEnvironment() {
29
65
  try {
@@ -122,13 +158,13 @@ function getFetchImplementation(userFetch) {
122
158
  const fetchImpl = userFetch ?? globalFetch;
123
159
  if (!fetchImpl) {
124
160
  throw new Error(
125
- `The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`
161
+ `Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
126
162
  );
127
163
  }
128
164
  return fetchImpl;
129
165
  }
130
166
 
131
- const VERSION = "0.0.0-alpha.vfef462e";
167
+ const VERSION = "0.0.0-alpha.vff52a72";
132
168
 
133
169
  class ErrorWithCause extends Error {
134
170
  constructor(message, options) {
@@ -179,18 +215,24 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
179
215
  }, {});
180
216
  const query = new URLSearchParams(cleanQueryParams).toString();
181
217
  const queryString = query.length > 0 ? `?${query}` : "";
182
- return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
218
+ const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
219
+ return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
220
+ }, {});
221
+ return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
183
222
  };
184
223
  function buildBaseUrl({
224
+ endpoint,
185
225
  path,
186
226
  workspacesApiUrl,
187
227
  apiUrl,
188
- pathParams
228
+ pathParams = {}
189
229
  }) {
190
- if (!pathParams?.workspace)
191
- return `${apiUrl}${path}`;
192
- const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
193
- return url.replace("{workspaceId}", pathParams.workspace);
230
+ if (endpoint === "dataPlane") {
231
+ const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
232
+ const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
233
+ return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
234
+ }
235
+ return `${apiUrl}${path}`;
194
236
  }
195
237
  function hostHeader(url) {
196
238
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
@@ -206,271 +248,228 @@ async function fetch$1({
206
248
  queryParams,
207
249
  fetchImpl,
208
250
  apiKey,
251
+ endpoint,
209
252
  apiUrl,
210
- workspacesApiUrl
253
+ workspacesApiUrl,
254
+ trace,
255
+ signal,
256
+ clientID,
257
+ sessionID
211
258
  }) {
212
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
213
- const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
214
- const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
215
- const response = await fetchImpl(url, {
216
- method: method.toUpperCase(),
217
- body: body ? JSON.stringify(body) : void 0,
218
- headers: {
219
- "Content-Type": "application/json",
220
- "User-Agent": `Xata client-ts/${VERSION}`,
221
- ...headers,
222
- ...hostHeader(fullUrl),
223
- Authorization: `Bearer ${apiKey}`
224
- }
225
- });
226
- if (response.status === 204) {
227
- return {};
228
- }
229
- const requestId = response.headers?.get("x-request-id") ?? void 0;
259
+ return trace(
260
+ `${method.toUpperCase()} ${path}`,
261
+ async ({ setAttributes }) => {
262
+ const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
263
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
264
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
265
+ setAttributes({
266
+ [TraceAttributes.HTTP_URL]: url,
267
+ [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
268
+ });
269
+ const response = await fetchImpl(url, {
270
+ method: method.toUpperCase(),
271
+ body: body ? JSON.stringify(body) : void 0,
272
+ headers: {
273
+ "Content-Type": "application/json",
274
+ "User-Agent": `Xata client-ts/${VERSION}`,
275
+ "X-Xata-Client-ID": clientID ?? "",
276
+ "X-Xata-Session-ID": sessionID ?? "",
277
+ ...headers,
278
+ ...hostHeader(fullUrl),
279
+ Authorization: `Bearer ${apiKey}`
280
+ },
281
+ signal
282
+ });
283
+ if (response.status === 204) {
284
+ return {};
285
+ }
286
+ const { host, protocol } = parseUrl(response.url);
287
+ const requestId = response.headers?.get("x-request-id") ?? void 0;
288
+ setAttributes({
289
+ [TraceAttributes.KIND]: "http",
290
+ [TraceAttributes.HTTP_REQUEST_ID]: requestId,
291
+ [TraceAttributes.HTTP_STATUS_CODE]: response.status,
292
+ [TraceAttributes.HTTP_HOST]: host,
293
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
294
+ });
295
+ try {
296
+ const jsonResponse = await response.json();
297
+ if (response.ok) {
298
+ return jsonResponse;
299
+ }
300
+ throw new FetcherError(response.status, jsonResponse, requestId);
301
+ } catch (error) {
302
+ throw new FetcherError(response.status, error, requestId);
303
+ }
304
+ },
305
+ { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
306
+ );
307
+ }
308
+ function parseUrl(url) {
230
309
  try {
231
- const jsonResponse = await response.json();
232
- if (response.ok) {
233
- return jsonResponse;
234
- }
235
- throw new FetcherError(response.status, jsonResponse, requestId);
310
+ const { host, protocol } = new URL(url);
311
+ return { host, protocol };
236
312
  } catch (error) {
237
- throw new FetcherError(response.status, error, requestId);
313
+ return {};
238
314
  }
239
315
  }
240
316
 
241
- const getUser = (variables) => fetch$1({ url: "/user", method: "get", ...variables });
242
- const updateUser = (variables) => fetch$1({ url: "/user", method: "put", ...variables });
243
- const deleteUser = (variables) => fetch$1({ url: "/user", method: "delete", ...variables });
244
- const getUserAPIKeys = (variables) => fetch$1({
245
- url: "/user/keys",
246
- method: "get",
247
- ...variables
248
- });
249
- const createUserAPIKey = (variables) => fetch$1({
250
- url: "/user/keys/{keyName}",
251
- method: "post",
252
- ...variables
253
- });
254
- const deleteUserAPIKey = (variables) => fetch$1({
255
- url: "/user/keys/{keyName}",
256
- method: "delete",
257
- ...variables
258
- });
259
- const createWorkspace = (variables) => fetch$1({
260
- url: "/workspaces",
261
- method: "post",
262
- ...variables
263
- });
264
- const getWorkspacesList = (variables) => fetch$1({
265
- url: "/workspaces",
266
- method: "get",
267
- ...variables
268
- });
269
- const getWorkspace = (variables) => fetch$1({
270
- url: "/workspaces/{workspaceId}",
271
- method: "get",
272
- ...variables
273
- });
274
- const updateWorkspace = (variables) => fetch$1({
275
- url: "/workspaces/{workspaceId}",
276
- method: "put",
277
- ...variables
278
- });
279
- const deleteWorkspace = (variables) => fetch$1({
280
- url: "/workspaces/{workspaceId}",
281
- method: "delete",
282
- ...variables
283
- });
284
- const getWorkspaceMembersList = (variables) => fetch$1({
285
- url: "/workspaces/{workspaceId}/members",
286
- method: "get",
287
- ...variables
288
- });
289
- const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
290
- const removeWorkspaceMember = (variables) => fetch$1({
291
- url: "/workspaces/{workspaceId}/members/{userId}",
292
- method: "delete",
293
- ...variables
294
- });
295
- const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
296
- const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
297
- const cancelWorkspaceMemberInvite = (variables) => fetch$1({
298
- url: "/workspaces/{workspaceId}/invites/{inviteId}",
299
- method: "delete",
300
- ...variables
301
- });
302
- const resendWorkspaceMemberInvite = (variables) => fetch$1({
303
- url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
304
- method: "post",
305
- ...variables
306
- });
307
- const acceptWorkspaceMemberInvite = (variables) => fetch$1({
308
- url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
309
- method: "post",
310
- ...variables
311
- });
312
- const getDatabaseList = (variables) => fetch$1({
313
- url: "/dbs",
314
- method: "get",
315
- ...variables
316
- });
317
- const getBranchList = (variables) => fetch$1({
318
- url: "/dbs/{dbName}",
319
- method: "get",
320
- ...variables
321
- });
322
- const createDatabase = (variables) => fetch$1({
323
- url: "/dbs/{dbName}",
324
- method: "put",
325
- ...variables
326
- });
327
- const deleteDatabase = (variables) => fetch$1({
317
+ const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
318
+
319
+ const dEPRECATEDgetDatabaseList = (variables, signal) => dataPlaneFetch({ url: "/dbs", method: "get", ...variables, signal });
320
+ const getBranchList = (variables, signal) => dataPlaneFetch({
328
321
  url: "/dbs/{dbName}",
329
- method: "delete",
330
- ...variables
331
- });
332
- const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
333
- const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
334
- const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
335
- const resolveBranch = (variables) => fetch$1({
336
- url: "/dbs/{dbName}/resolveBranch",
337
322
  method: "get",
338
- ...variables
323
+ ...variables,
324
+ signal
339
325
  });
340
- const getBranchDetails = (variables) => fetch$1({
326
+ const dEPRECATEDcreateDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
327
+ const dEPRECATEDdeleteDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "delete", ...variables, signal });
328
+ const dEPRECATEDgetDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "get", ...variables, signal });
329
+ const dEPRECATEDupdateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
330
+ const getBranchDetails = (variables, signal) => dataPlaneFetch({
341
331
  url: "/db/{dbBranchName}",
342
332
  method: "get",
343
- ...variables
333
+ ...variables,
334
+ signal
344
335
  });
345
- const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
346
- const deleteBranch = (variables) => fetch$1({
336
+ const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
337
+ const deleteBranch = (variables, signal) => dataPlaneFetch({
347
338
  url: "/db/{dbBranchName}",
348
339
  method: "delete",
349
- ...variables
340
+ ...variables,
341
+ signal
350
342
  });
351
- const updateBranchMetadata = (variables) => fetch$1({
343
+ const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
352
344
  url: "/db/{dbBranchName}/metadata",
353
345
  method: "put",
354
- ...variables
346
+ ...variables,
347
+ signal
355
348
  });
356
- const getBranchMetadata = (variables) => fetch$1({
349
+ const getBranchMetadata = (variables, signal) => dataPlaneFetch({
357
350
  url: "/db/{dbBranchName}/metadata",
358
351
  method: "get",
359
- ...variables
352
+ ...variables,
353
+ signal
360
354
  });
361
- const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
362
- const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
363
- const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
364
- const getBranchStats = (variables) => fetch$1({
355
+ const getBranchStats = (variables, signal) => dataPlaneFetch({
365
356
  url: "/db/{dbBranchName}/stats",
366
357
  method: "get",
367
- ...variables
358
+ ...variables,
359
+ signal
360
+ });
361
+ const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
362
+ const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
363
+ const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
364
+ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
365
+ const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
366
+ const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
367
+ const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
368
+ const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
369
+ const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
370
+ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
371
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
372
+ method: "get",
373
+ ...variables,
374
+ signal
368
375
  });
369
- const createTable = (variables) => fetch$1({
376
+ const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
377
+ const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
378
+ const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
379
+ const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
380
+ const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
381
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
382
+ method: "post",
383
+ ...variables,
384
+ signal
385
+ });
386
+ const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
387
+ const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
388
+ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
389
+ const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
390
+ const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
391
+ const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
392
+ const createTable = (variables, signal) => dataPlaneFetch({
370
393
  url: "/db/{dbBranchName}/tables/{tableName}",
371
394
  method: "put",
372
- ...variables
395
+ ...variables,
396
+ signal
373
397
  });
374
- const deleteTable = (variables) => fetch$1({
398
+ const deleteTable = (variables, signal) => dataPlaneFetch({
375
399
  url: "/db/{dbBranchName}/tables/{tableName}",
376
400
  method: "delete",
377
- ...variables
401
+ ...variables,
402
+ signal
378
403
  });
379
- const updateTable = (variables) => fetch$1({
380
- url: "/db/{dbBranchName}/tables/{tableName}",
381
- method: "patch",
382
- ...variables
383
- });
384
- const getTableSchema = (variables) => fetch$1({
404
+ const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
405
+ const getTableSchema = (variables, signal) => dataPlaneFetch({
385
406
  url: "/db/{dbBranchName}/tables/{tableName}/schema",
386
407
  method: "get",
387
- ...variables
388
- });
389
- const setTableSchema = (variables) => fetch$1({
390
- url: "/db/{dbBranchName}/tables/{tableName}/schema",
391
- method: "put",
392
- ...variables
408
+ ...variables,
409
+ signal
393
410
  });
394
- const getTableColumns = (variables) => fetch$1({
411
+ const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
412
+ const getTableColumns = (variables, signal) => dataPlaneFetch({
395
413
  url: "/db/{dbBranchName}/tables/{tableName}/columns",
396
414
  method: "get",
397
- ...variables
398
- });
399
- const addTableColumn = (variables) => fetch$1({
400
- url: "/db/{dbBranchName}/tables/{tableName}/columns",
401
- method: "post",
402
- ...variables
415
+ ...variables,
416
+ signal
403
417
  });
404
- const getColumn = (variables) => fetch$1({
418
+ const addTableColumn = (variables, signal) => dataPlaneFetch(
419
+ { url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
420
+ );
421
+ const getColumn = (variables, signal) => dataPlaneFetch({
405
422
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
406
423
  method: "get",
407
- ...variables
424
+ ...variables,
425
+ signal
408
426
  });
409
- const deleteColumn = (variables) => fetch$1({
427
+ const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
428
+ const deleteColumn = (variables, signal) => dataPlaneFetch({
410
429
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
411
430
  method: "delete",
412
- ...variables
431
+ ...variables,
432
+ signal
413
433
  });
414
- const updateColumn = (variables) => fetch$1({
415
- url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
416
- method: "patch",
417
- ...variables
418
- });
419
- const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
420
- const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
421
- const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
422
- const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
423
- const deleteRecord = (variables) => fetch$1({
424
- url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
425
- method: "delete",
426
- ...variables
427
- });
428
- const getRecord = (variables) => fetch$1({
434
+ const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
435
+ const getRecord = (variables, signal) => dataPlaneFetch({
429
436
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
430
437
  method: "get",
431
- ...variables
438
+ ...variables,
439
+ signal
432
440
  });
433
- const bulkInsertTableRecords = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables });
434
- const queryTable = (variables) => fetch$1({
441
+ const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
442
+ const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
443
+ const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
444
+ const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
445
+ const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
446
+ const queryTable = (variables, signal) => dataPlaneFetch({
435
447
  url: "/db/{dbBranchName}/tables/{tableName}/query",
436
448
  method: "post",
437
- ...variables
449
+ ...variables,
450
+ signal
438
451
  });
439
- const searchTable = (variables) => fetch$1({
440
- url: "/db/{dbBranchName}/tables/{tableName}/search",
452
+ const searchBranch = (variables, signal) => dataPlaneFetch({
453
+ url: "/db/{dbBranchName}/search",
441
454
  method: "post",
442
- ...variables
455
+ ...variables,
456
+ signal
443
457
  });
444
- const searchBranch = (variables) => fetch$1({
445
- url: "/db/{dbBranchName}/search",
458
+ const searchTable = (variables, signal) => dataPlaneFetch({
459
+ url: "/db/{dbBranchName}/tables/{tableName}/search",
446
460
  method: "post",
447
- ...variables
461
+ ...variables,
462
+ signal
448
463
  });
449
- const operationsByTag = {
450
- users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
451
- workspaces: {
452
- createWorkspace,
453
- getWorkspacesList,
454
- getWorkspace,
455
- updateWorkspace,
456
- deleteWorkspace,
457
- getWorkspaceMembersList,
458
- updateWorkspaceMemberRole,
459
- removeWorkspaceMember,
460
- inviteWorkspaceMember,
461
- updateWorkspaceMemberInvite,
462
- cancelWorkspaceMemberInvite,
463
- resendWorkspaceMemberInvite,
464
- acceptWorkspaceMemberInvite
465
- },
464
+ const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
465
+ const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
466
+ const operationsByTag$2 = {
466
467
  database: {
467
- getDatabaseList,
468
- createDatabase,
469
- deleteDatabase,
470
- getGitBranchesMapping,
471
- addGitBranchesEntry,
472
- removeGitBranchesEntry,
473
- resolveBranch
468
+ dEPRECATEDgetDatabaseList,
469
+ dEPRECATEDcreateDatabase,
470
+ dEPRECATEDdeleteDatabase,
471
+ dEPRECATEDgetDatabaseMetadata,
472
+ dEPRECATEDupdateDatabaseMetadata
474
473
  },
475
474
  branch: {
476
475
  getBranchList,
@@ -479,10 +478,32 @@ const operationsByTag = {
479
478
  deleteBranch,
480
479
  updateBranchMetadata,
481
480
  getBranchMetadata,
481
+ getBranchStats,
482
+ getGitBranchesMapping,
483
+ addGitBranchesEntry,
484
+ removeGitBranchesEntry,
485
+ resolveBranch
486
+ },
487
+ migrations: {
482
488
  getBranchMigrationHistory,
483
- executeBranchMigrationPlan,
484
489
  getBranchMigrationPlan,
485
- getBranchStats
490
+ executeBranchMigrationPlan,
491
+ getBranchSchemaHistory,
492
+ compareBranchWithUserSchema,
493
+ compareBranchSchemas,
494
+ updateBranchSchema,
495
+ previewBranchSchemaEdit,
496
+ applyBranchSchemaEdit
497
+ },
498
+ migrationRequests: {
499
+ queryMigrationRequests,
500
+ createMigrationRequest,
501
+ getMigrationRequest,
502
+ updateMigrationRequest,
503
+ listMigrationRequestsCommits,
504
+ compareMigrationRequest,
505
+ getMigrationRequestIsMerged,
506
+ mergeMigrationRequest
486
507
  },
487
508
  table: {
488
509
  createTable,
@@ -493,27 +514,159 @@ const operationsByTag = {
493
514
  getTableColumns,
494
515
  addTableColumn,
495
516
  getColumn,
496
- deleteColumn,
497
- updateColumn
517
+ updateColumn,
518
+ deleteColumn
498
519
  },
499
520
  records: {
500
521
  insertRecord,
522
+ getRecord,
501
523
  insertRecordWithID,
502
524
  updateRecordWithID,
503
525
  upsertRecordWithID,
504
526
  deleteRecord,
505
- getRecord,
506
- bulkInsertTableRecords,
507
- queryTable,
508
- searchTable,
509
- searchBranch
527
+ bulkInsertTableRecords
528
+ },
529
+ searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
530
+ };
531
+
532
+ const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
533
+
534
+ const getUser = (variables, signal) => controlPlaneFetch({
535
+ url: "/user",
536
+ method: "get",
537
+ ...variables,
538
+ signal
539
+ });
540
+ const updateUser = (variables, signal) => controlPlaneFetch({
541
+ url: "/user",
542
+ method: "put",
543
+ ...variables,
544
+ signal
545
+ });
546
+ const deleteUser = (variables, signal) => controlPlaneFetch({
547
+ url: "/user",
548
+ method: "delete",
549
+ ...variables,
550
+ signal
551
+ });
552
+ const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
553
+ url: "/user/keys",
554
+ method: "get",
555
+ ...variables,
556
+ signal
557
+ });
558
+ const createUserAPIKey = (variables, signal) => controlPlaneFetch({
559
+ url: "/user/keys/{keyName}",
560
+ method: "post",
561
+ ...variables,
562
+ signal
563
+ });
564
+ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
565
+ url: "/user/keys/{keyName}",
566
+ method: "delete",
567
+ ...variables,
568
+ signal
569
+ });
570
+ const getWorkspacesList = (variables, signal) => controlPlaneFetch({
571
+ url: "/workspaces",
572
+ method: "get",
573
+ ...variables,
574
+ signal
575
+ });
576
+ const createWorkspace = (variables, signal) => controlPlaneFetch({
577
+ url: "/workspaces",
578
+ method: "post",
579
+ ...variables,
580
+ signal
581
+ });
582
+ const getWorkspace = (variables, signal) => controlPlaneFetch({
583
+ url: "/workspaces/{workspaceId}",
584
+ method: "get",
585
+ ...variables,
586
+ signal
587
+ });
588
+ const updateWorkspace = (variables, signal) => controlPlaneFetch({
589
+ url: "/workspaces/{workspaceId}",
590
+ method: "put",
591
+ ...variables,
592
+ signal
593
+ });
594
+ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
595
+ url: "/workspaces/{workspaceId}",
596
+ method: "delete",
597
+ ...variables,
598
+ signal
599
+ });
600
+ const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
601
+ const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
602
+ const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
603
+ url: "/workspaces/{workspaceId}/members/{userId}",
604
+ method: "delete",
605
+ ...variables,
606
+ signal
607
+ });
608
+ const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
609
+ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
610
+ const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
611
+ const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
612
+ const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
613
+ const getDatabaseList = (variables, signal) => controlPlaneFetch({
614
+ url: "/workspaces/{workspaceId}/dbs",
615
+ method: "get",
616
+ ...variables,
617
+ signal
618
+ });
619
+ const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
620
+ const deleteDatabase = (variables, signal) => controlPlaneFetch({
621
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
622
+ method: "delete",
623
+ ...variables,
624
+ signal
625
+ });
626
+ const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
627
+ const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
628
+ const listRegions = (variables, signal) => controlPlaneFetch({
629
+ url: "/workspaces/{workspaceId}/regions",
630
+ method: "get",
631
+ ...variables,
632
+ signal
633
+ });
634
+ const operationsByTag$1 = {
635
+ users: { getUser, updateUser, deleteUser },
636
+ authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
637
+ workspaces: {
638
+ getWorkspacesList,
639
+ createWorkspace,
640
+ getWorkspace,
641
+ updateWorkspace,
642
+ deleteWorkspace,
643
+ getWorkspaceMembersList,
644
+ updateWorkspaceMemberRole,
645
+ removeWorkspaceMember
646
+ },
647
+ invites: {
648
+ inviteWorkspaceMember,
649
+ updateWorkspaceMemberInvite,
650
+ cancelWorkspaceMemberInvite,
651
+ acceptWorkspaceMemberInvite,
652
+ resendWorkspaceMemberInvite
653
+ },
654
+ databases: {
655
+ getDatabaseList,
656
+ createDatabase,
657
+ deleteDatabase,
658
+ getDatabaseMetadata,
659
+ updateDatabaseMetadata,
660
+ listRegions
510
661
  }
511
662
  };
512
663
 
664
+ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
665
+
513
666
  function getHostUrl(provider, type) {
514
- if (isValidAlias(provider)) {
667
+ if (isHostProviderAlias(provider)) {
515
668
  return providers[provider][type];
516
- } else if (isValidBuilder(provider)) {
669
+ } else if (isHostProviderBuilder(provider)) {
517
670
  return provider[type];
518
671
  }
519
672
  throw new Error("Invalid API provider");
@@ -521,19 +674,38 @@ function getHostUrl(provider, type) {
521
674
  const providers = {
522
675
  production: {
523
676
  main: "https://api.xata.io",
524
- workspaces: "https://{workspaceId}.xata.sh"
677
+ workspaces: "https://{workspaceId}.{region}.xata.sh"
525
678
  },
526
679
  staging: {
527
680
  main: "https://staging.xatabase.co",
528
- workspaces: "https://{workspaceId}.staging.xatabase.co"
681
+ workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
529
682
  }
530
683
  };
531
- function isValidAlias(alias) {
684
+ function isHostProviderAlias(alias) {
532
685
  return isString(alias) && Object.keys(providers).includes(alias);
533
686
  }
534
- function isValidBuilder(builder) {
687
+ function isHostProviderBuilder(builder) {
535
688
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
536
689
  }
690
+ function parseProviderString(provider = "production") {
691
+ if (isHostProviderAlias(provider)) {
692
+ return provider;
693
+ }
694
+ const [main, workspaces] = provider.split(",");
695
+ if (!main || !workspaces)
696
+ return null;
697
+ return { main, workspaces };
698
+ }
699
+ function parseWorkspacesUrlParts(url) {
700
+ if (!isString(url))
701
+ return null;
702
+ const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
703
+ const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
704
+ const match = url.match(regex) || url.match(regexStaging);
705
+ if (!match)
706
+ return null;
707
+ return { workspace: match[1], region: match[2] ?? "eu-west-1" };
708
+ }
537
709
 
538
710
  var __accessCheck$7 = (obj, member, msg) => {
539
711
  if (!member.has(obj))
@@ -559,7 +731,8 @@ class XataApiClient {
559
731
  __privateAdd$7(this, _extraProps, void 0);
560
732
  __privateAdd$7(this, _namespaces, {});
561
733
  const provider = options.host ?? "production";
562
- const apiKey = options?.apiKey ?? getAPIKey();
734
+ const apiKey = options.apiKey ?? getAPIKey();
735
+ const trace = options.trace ?? defaultTrace;
563
736
  if (!apiKey) {
564
737
  throw new Error("Could not resolve a valid apiKey");
565
738
  }
@@ -567,7 +740,8 @@ class XataApiClient {
567
740
  apiUrl: getHostUrl(provider, "main"),
568
741
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
569
742
  fetchImpl: getFetchImplementation(options.fetch),
570
- apiKey
743
+ apiKey,
744
+ trace
571
745
  });
572
746
  }
573
747
  get user() {
@@ -575,21 +749,41 @@ class XataApiClient {
575
749
  __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
576
750
  return __privateGet$7(this, _namespaces).user;
577
751
  }
752
+ get authentication() {
753
+ if (!__privateGet$7(this, _namespaces).authentication)
754
+ __privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
755
+ return __privateGet$7(this, _namespaces).authentication;
756
+ }
578
757
  get workspaces() {
579
758
  if (!__privateGet$7(this, _namespaces).workspaces)
580
759
  __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
581
760
  return __privateGet$7(this, _namespaces).workspaces;
582
761
  }
583
- get databases() {
584
- if (!__privateGet$7(this, _namespaces).databases)
585
- __privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
586
- return __privateGet$7(this, _namespaces).databases;
762
+ get invites() {
763
+ if (!__privateGet$7(this, _namespaces).invites)
764
+ __privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
765
+ return __privateGet$7(this, _namespaces).invites;
766
+ }
767
+ get database() {
768
+ if (!__privateGet$7(this, _namespaces).database)
769
+ __privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
770
+ return __privateGet$7(this, _namespaces).database;
587
771
  }
588
772
  get branches() {
589
773
  if (!__privateGet$7(this, _namespaces).branches)
590
774
  __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
591
775
  return __privateGet$7(this, _namespaces).branches;
592
776
  }
777
+ get migrations() {
778
+ if (!__privateGet$7(this, _namespaces).migrations)
779
+ __privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
780
+ return __privateGet$7(this, _namespaces).migrations;
781
+ }
782
+ get migrationRequests() {
783
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
784
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
785
+ return __privateGet$7(this, _namespaces).migrationRequests;
786
+ }
593
787
  get tables() {
594
788
  if (!__privateGet$7(this, _namespaces).tables)
595
789
  __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
@@ -600,6 +794,11 @@ class XataApiClient {
600
794
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
601
795
  return __privateGet$7(this, _namespaces).records;
602
796
  }
797
+ get searchAndFilter() {
798
+ if (!__privateGet$7(this, _namespaces).searchAndFilter)
799
+ __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
800
+ return __privateGet$7(this, _namespaces).searchAndFilter;
801
+ }
603
802
  }
604
803
  _extraProps = new WeakMap();
605
804
  _namespaces = new WeakMap();
@@ -610,24 +809,29 @@ class UserApi {
610
809
  getUser() {
611
810
  return operationsByTag.users.getUser({ ...this.extraProps });
612
811
  }
613
- updateUser(user) {
812
+ updateUser({ user }) {
614
813
  return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
615
814
  }
616
815
  deleteUser() {
617
816
  return operationsByTag.users.deleteUser({ ...this.extraProps });
618
817
  }
818
+ }
819
+ class AuthenticationApi {
820
+ constructor(extraProps) {
821
+ this.extraProps = extraProps;
822
+ }
619
823
  getUserAPIKeys() {
620
- return operationsByTag.users.getUserAPIKeys({ ...this.extraProps });
824
+ return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
621
825
  }
622
- createUserAPIKey(keyName) {
623
- return operationsByTag.users.createUserAPIKey({
624
- pathParams: { keyName },
826
+ createUserAPIKey({ name }) {
827
+ return operationsByTag.authentication.createUserAPIKey({
828
+ pathParams: { keyName: name },
625
829
  ...this.extraProps
626
830
  });
627
831
  }
628
- deleteUserAPIKey(keyName) {
629
- return operationsByTag.users.deleteUserAPIKey({
630
- pathParams: { keyName },
832
+ deleteUserAPIKey({ name }) {
833
+ return operationsByTag.authentication.deleteUserAPIKey({
834
+ pathParams: { keyName: name },
631
835
  ...this.extraProps
632
836
  });
633
837
  }
@@ -636,353 +840,882 @@ class WorkspaceApi {
636
840
  constructor(extraProps) {
637
841
  this.extraProps = extraProps;
638
842
  }
639
- createWorkspace(workspaceMeta) {
843
+ getWorkspacesList() {
844
+ return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
845
+ }
846
+ createWorkspace({ data }) {
640
847
  return operationsByTag.workspaces.createWorkspace({
641
- body: workspaceMeta,
848
+ body: data,
642
849
  ...this.extraProps
643
850
  });
644
851
  }
645
- getWorkspacesList() {
646
- return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
647
- }
648
- getWorkspace(workspaceId) {
852
+ getWorkspace({ workspace }) {
649
853
  return operationsByTag.workspaces.getWorkspace({
650
- pathParams: { workspaceId },
854
+ pathParams: { workspaceId: workspace },
651
855
  ...this.extraProps
652
856
  });
653
857
  }
654
- updateWorkspace(workspaceId, workspaceMeta) {
858
+ updateWorkspace({
859
+ workspace,
860
+ update
861
+ }) {
655
862
  return operationsByTag.workspaces.updateWorkspace({
656
- pathParams: { workspaceId },
657
- body: workspaceMeta,
863
+ pathParams: { workspaceId: workspace },
864
+ body: update,
658
865
  ...this.extraProps
659
866
  });
660
867
  }
661
- deleteWorkspace(workspaceId) {
868
+ deleteWorkspace({ workspace }) {
662
869
  return operationsByTag.workspaces.deleteWorkspace({
663
- pathParams: { workspaceId },
870
+ pathParams: { workspaceId: workspace },
664
871
  ...this.extraProps
665
872
  });
666
873
  }
667
- getWorkspaceMembersList(workspaceId) {
874
+ getWorkspaceMembersList({ workspace }) {
668
875
  return operationsByTag.workspaces.getWorkspaceMembersList({
669
- pathParams: { workspaceId },
876
+ pathParams: { workspaceId: workspace },
670
877
  ...this.extraProps
671
878
  });
672
879
  }
673
- updateWorkspaceMemberRole(workspaceId, userId, role) {
880
+ updateWorkspaceMemberRole({
881
+ workspace,
882
+ user,
883
+ role
884
+ }) {
674
885
  return operationsByTag.workspaces.updateWorkspaceMemberRole({
675
- pathParams: { workspaceId, userId },
886
+ pathParams: { workspaceId: workspace, userId: user },
676
887
  body: { role },
677
888
  ...this.extraProps
678
889
  });
679
890
  }
680
- removeWorkspaceMember(workspaceId, userId) {
891
+ removeWorkspaceMember({
892
+ workspace,
893
+ user
894
+ }) {
681
895
  return operationsByTag.workspaces.removeWorkspaceMember({
682
- pathParams: { workspaceId, userId },
896
+ pathParams: { workspaceId: workspace, userId: user },
897
+ ...this.extraProps
898
+ });
899
+ }
900
+ }
901
+ class InvitesApi {
902
+ constructor(extraProps) {
903
+ this.extraProps = extraProps;
904
+ }
905
+ inviteWorkspaceMember({
906
+ workspace,
907
+ email,
908
+ role
909
+ }) {
910
+ return operationsByTag.invites.inviteWorkspaceMember({
911
+ pathParams: { workspaceId: workspace },
912
+ body: { email, role },
913
+ ...this.extraProps
914
+ });
915
+ }
916
+ updateWorkspaceMemberInvite({
917
+ workspace,
918
+ invite,
919
+ role
920
+ }) {
921
+ return operationsByTag.invites.updateWorkspaceMemberInvite({
922
+ pathParams: { workspaceId: workspace, inviteId: invite },
923
+ body: { role },
924
+ ...this.extraProps
925
+ });
926
+ }
927
+ cancelWorkspaceMemberInvite({
928
+ workspace,
929
+ invite
930
+ }) {
931
+ return operationsByTag.invites.cancelWorkspaceMemberInvite({
932
+ pathParams: { workspaceId: workspace, inviteId: invite },
933
+ ...this.extraProps
934
+ });
935
+ }
936
+ acceptWorkspaceMemberInvite({
937
+ workspace,
938
+ key
939
+ }) {
940
+ return operationsByTag.invites.acceptWorkspaceMemberInvite({
941
+ pathParams: { workspaceId: workspace, inviteKey: key },
942
+ ...this.extraProps
943
+ });
944
+ }
945
+ resendWorkspaceMemberInvite({
946
+ workspace,
947
+ invite
948
+ }) {
949
+ return operationsByTag.invites.resendWorkspaceMemberInvite({
950
+ pathParams: { workspaceId: workspace, inviteId: invite },
951
+ ...this.extraProps
952
+ });
953
+ }
954
+ }
955
+ class BranchApi {
956
+ constructor(extraProps) {
957
+ this.extraProps = extraProps;
958
+ }
959
+ getBranchList({
960
+ workspace,
961
+ region,
962
+ database
963
+ }) {
964
+ return operationsByTag.branch.getBranchList({
965
+ pathParams: { workspace, region, dbName: database },
966
+ ...this.extraProps
967
+ });
968
+ }
969
+ getBranchDetails({
970
+ workspace,
971
+ region,
972
+ database,
973
+ branch
974
+ }) {
975
+ return operationsByTag.branch.getBranchDetails({
976
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
977
+ ...this.extraProps
978
+ });
979
+ }
980
+ createBranch({
981
+ workspace,
982
+ region,
983
+ database,
984
+ branch,
985
+ from,
986
+ metadata
987
+ }) {
988
+ return operationsByTag.branch.createBranch({
989
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
990
+ body: { from, metadata },
991
+ ...this.extraProps
992
+ });
993
+ }
994
+ deleteBranch({
995
+ workspace,
996
+ region,
997
+ database,
998
+ branch
999
+ }) {
1000
+ return operationsByTag.branch.deleteBranch({
1001
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1002
+ ...this.extraProps
1003
+ });
1004
+ }
1005
+ updateBranchMetadata({
1006
+ workspace,
1007
+ region,
1008
+ database,
1009
+ branch,
1010
+ metadata
1011
+ }) {
1012
+ return operationsByTag.branch.updateBranchMetadata({
1013
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1014
+ body: metadata,
1015
+ ...this.extraProps
1016
+ });
1017
+ }
1018
+ getBranchMetadata({
1019
+ workspace,
1020
+ region,
1021
+ database,
1022
+ branch
1023
+ }) {
1024
+ return operationsByTag.branch.getBranchMetadata({
1025
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1026
+ ...this.extraProps
1027
+ });
1028
+ }
1029
+ getBranchStats({
1030
+ workspace,
1031
+ region,
1032
+ database,
1033
+ branch
1034
+ }) {
1035
+ return operationsByTag.branch.getBranchStats({
1036
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1037
+ ...this.extraProps
1038
+ });
1039
+ }
1040
+ getGitBranchesMapping({
1041
+ workspace,
1042
+ region,
1043
+ database
1044
+ }) {
1045
+ return operationsByTag.branch.getGitBranchesMapping({
1046
+ pathParams: { workspace, region, dbName: database },
1047
+ ...this.extraProps
1048
+ });
1049
+ }
1050
+ addGitBranchesEntry({
1051
+ workspace,
1052
+ region,
1053
+ database,
1054
+ gitBranch,
1055
+ xataBranch
1056
+ }) {
1057
+ return operationsByTag.branch.addGitBranchesEntry({
1058
+ pathParams: { workspace, region, dbName: database },
1059
+ body: { gitBranch, xataBranch },
1060
+ ...this.extraProps
1061
+ });
1062
+ }
1063
+ removeGitBranchesEntry({
1064
+ workspace,
1065
+ region,
1066
+ database,
1067
+ gitBranch
1068
+ }) {
1069
+ return operationsByTag.branch.removeGitBranchesEntry({
1070
+ pathParams: { workspace, region, dbName: database },
1071
+ queryParams: { gitBranch },
1072
+ ...this.extraProps
1073
+ });
1074
+ }
1075
+ resolveBranch({
1076
+ workspace,
1077
+ region,
1078
+ database,
1079
+ gitBranch,
1080
+ fallbackBranch
1081
+ }) {
1082
+ return operationsByTag.branch.resolveBranch({
1083
+ pathParams: { workspace, region, dbName: database },
1084
+ queryParams: { gitBranch, fallbackBranch },
1085
+ ...this.extraProps
1086
+ });
1087
+ }
1088
+ }
1089
+ class TableApi {
1090
+ constructor(extraProps) {
1091
+ this.extraProps = extraProps;
1092
+ }
1093
+ createTable({
1094
+ workspace,
1095
+ region,
1096
+ database,
1097
+ branch,
1098
+ table
1099
+ }) {
1100
+ return operationsByTag.table.createTable({
1101
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1102
+ ...this.extraProps
1103
+ });
1104
+ }
1105
+ deleteTable({
1106
+ workspace,
1107
+ region,
1108
+ database,
1109
+ branch,
1110
+ table
1111
+ }) {
1112
+ return operationsByTag.table.deleteTable({
1113
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1114
+ ...this.extraProps
1115
+ });
1116
+ }
1117
+ updateTable({
1118
+ workspace,
1119
+ region,
1120
+ database,
1121
+ branch,
1122
+ table,
1123
+ update
1124
+ }) {
1125
+ return operationsByTag.table.updateTable({
1126
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1127
+ body: update,
1128
+ ...this.extraProps
1129
+ });
1130
+ }
1131
+ getTableSchema({
1132
+ workspace,
1133
+ region,
1134
+ database,
1135
+ branch,
1136
+ table
1137
+ }) {
1138
+ return operationsByTag.table.getTableSchema({
1139
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1140
+ ...this.extraProps
1141
+ });
1142
+ }
1143
+ setTableSchema({
1144
+ workspace,
1145
+ region,
1146
+ database,
1147
+ branch,
1148
+ table,
1149
+ schema
1150
+ }) {
1151
+ return operationsByTag.table.setTableSchema({
1152
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1153
+ body: schema,
683
1154
  ...this.extraProps
684
1155
  });
685
1156
  }
686
- inviteWorkspaceMember(workspaceId, email, role) {
687
- return operationsByTag.workspaces.inviteWorkspaceMember({
688
- pathParams: { workspaceId },
689
- body: { email, role },
1157
+ getTableColumns({
1158
+ workspace,
1159
+ region,
1160
+ database,
1161
+ branch,
1162
+ table
1163
+ }) {
1164
+ return operationsByTag.table.getTableColumns({
1165
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
690
1166
  ...this.extraProps
691
1167
  });
692
1168
  }
693
- updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
694
- return operationsByTag.workspaces.updateWorkspaceMemberInvite({
695
- pathParams: { workspaceId, inviteId },
696
- body: { role },
1169
+ addTableColumn({
1170
+ workspace,
1171
+ region,
1172
+ database,
1173
+ branch,
1174
+ table,
1175
+ column
1176
+ }) {
1177
+ return operationsByTag.table.addTableColumn({
1178
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1179
+ body: column,
697
1180
  ...this.extraProps
698
1181
  });
699
1182
  }
700
- cancelWorkspaceMemberInvite(workspaceId, inviteId) {
701
- return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
702
- pathParams: { workspaceId, inviteId },
1183
+ getColumn({
1184
+ workspace,
1185
+ region,
1186
+ database,
1187
+ branch,
1188
+ table,
1189
+ column
1190
+ }) {
1191
+ return operationsByTag.table.getColumn({
1192
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
703
1193
  ...this.extraProps
704
1194
  });
705
1195
  }
706
- resendWorkspaceMemberInvite(workspaceId, inviteId) {
707
- return operationsByTag.workspaces.resendWorkspaceMemberInvite({
708
- pathParams: { workspaceId, inviteId },
1196
+ updateColumn({
1197
+ workspace,
1198
+ region,
1199
+ database,
1200
+ branch,
1201
+ table,
1202
+ column,
1203
+ update
1204
+ }) {
1205
+ return operationsByTag.table.updateColumn({
1206
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
1207
+ body: update,
709
1208
  ...this.extraProps
710
1209
  });
711
1210
  }
712
- acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
713
- return operationsByTag.workspaces.acceptWorkspaceMemberInvite({
714
- pathParams: { workspaceId, inviteKey },
1211
+ deleteColumn({
1212
+ workspace,
1213
+ region,
1214
+ database,
1215
+ branch,
1216
+ table,
1217
+ column
1218
+ }) {
1219
+ return operationsByTag.table.deleteColumn({
1220
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
715
1221
  ...this.extraProps
716
1222
  });
717
1223
  }
718
1224
  }
719
- class DatabaseApi {
1225
+ class RecordsApi {
720
1226
  constructor(extraProps) {
721
1227
  this.extraProps = extraProps;
722
1228
  }
723
- getDatabaseList(workspace) {
724
- return operationsByTag.database.getDatabaseList({
725
- pathParams: { workspace },
1229
+ insertRecord({
1230
+ workspace,
1231
+ region,
1232
+ database,
1233
+ branch,
1234
+ table,
1235
+ record,
1236
+ columns
1237
+ }) {
1238
+ return operationsByTag.records.insertRecord({
1239
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1240
+ queryParams: { columns },
1241
+ body: record,
726
1242
  ...this.extraProps
727
1243
  });
728
1244
  }
729
- createDatabase(workspace, dbName, options = {}) {
730
- return operationsByTag.database.createDatabase({
731
- pathParams: { workspace, dbName },
732
- body: options,
1245
+ getRecord({
1246
+ workspace,
1247
+ region,
1248
+ database,
1249
+ branch,
1250
+ table,
1251
+ id,
1252
+ columns
1253
+ }) {
1254
+ return operationsByTag.records.getRecord({
1255
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1256
+ queryParams: { columns },
733
1257
  ...this.extraProps
734
1258
  });
735
1259
  }
736
- deleteDatabase(workspace, dbName) {
737
- return operationsByTag.database.deleteDatabase({
738
- pathParams: { workspace, dbName },
1260
+ insertRecordWithID({
1261
+ workspace,
1262
+ region,
1263
+ database,
1264
+ branch,
1265
+ table,
1266
+ id,
1267
+ record,
1268
+ columns,
1269
+ createOnly,
1270
+ ifVersion
1271
+ }) {
1272
+ return operationsByTag.records.insertRecordWithID({
1273
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1274
+ queryParams: { columns, createOnly, ifVersion },
1275
+ body: record,
739
1276
  ...this.extraProps
740
1277
  });
741
1278
  }
742
- getGitBranchesMapping(workspace, dbName) {
743
- return operationsByTag.database.getGitBranchesMapping({
744
- pathParams: { workspace, dbName },
1279
+ updateRecordWithID({
1280
+ workspace,
1281
+ region,
1282
+ database,
1283
+ branch,
1284
+ table,
1285
+ id,
1286
+ record,
1287
+ columns,
1288
+ ifVersion
1289
+ }) {
1290
+ return operationsByTag.records.updateRecordWithID({
1291
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1292
+ queryParams: { columns, ifVersion },
1293
+ body: record,
745
1294
  ...this.extraProps
746
1295
  });
747
1296
  }
748
- addGitBranchesEntry(workspace, dbName, body) {
749
- return operationsByTag.database.addGitBranchesEntry({
750
- pathParams: { workspace, dbName },
751
- body,
1297
+ upsertRecordWithID({
1298
+ workspace,
1299
+ region,
1300
+ database,
1301
+ branch,
1302
+ table,
1303
+ id,
1304
+ record,
1305
+ columns,
1306
+ ifVersion
1307
+ }) {
1308
+ return operationsByTag.records.upsertRecordWithID({
1309
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1310
+ queryParams: { columns, ifVersion },
1311
+ body: record,
752
1312
  ...this.extraProps
753
1313
  });
754
1314
  }
755
- removeGitBranchesEntry(workspace, dbName, gitBranch) {
756
- return operationsByTag.database.removeGitBranchesEntry({
757
- pathParams: { workspace, dbName },
758
- queryParams: { gitBranch },
1315
+ deleteRecord({
1316
+ workspace,
1317
+ region,
1318
+ database,
1319
+ branch,
1320
+ table,
1321
+ id,
1322
+ columns
1323
+ }) {
1324
+ return operationsByTag.records.deleteRecord({
1325
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
1326
+ queryParams: { columns },
759
1327
  ...this.extraProps
760
1328
  });
761
1329
  }
762
- resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
763
- return operationsByTag.database.resolveBranch({
764
- pathParams: { workspace, dbName },
765
- queryParams: { gitBranch, fallbackBranch },
1330
+ bulkInsertTableRecords({
1331
+ workspace,
1332
+ region,
1333
+ database,
1334
+ branch,
1335
+ table,
1336
+ records,
1337
+ columns
1338
+ }) {
1339
+ return operationsByTag.records.bulkInsertTableRecords({
1340
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1341
+ queryParams: { columns },
1342
+ body: { records },
766
1343
  ...this.extraProps
767
1344
  });
768
1345
  }
769
1346
  }
770
- class BranchApi {
1347
+ class SearchAndFilterApi {
771
1348
  constructor(extraProps) {
772
1349
  this.extraProps = extraProps;
773
1350
  }
774
- getBranchList(workspace, dbName) {
775
- return operationsByTag.branch.getBranchList({
776
- pathParams: { workspace, dbName },
1351
+ queryTable({
1352
+ workspace,
1353
+ region,
1354
+ database,
1355
+ branch,
1356
+ table,
1357
+ filter,
1358
+ sort,
1359
+ page,
1360
+ columns
1361
+ }) {
1362
+ return operationsByTag.searchAndFilter.queryTable({
1363
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1364
+ body: { filter, sort, page, columns },
777
1365
  ...this.extraProps
778
1366
  });
779
1367
  }
780
- getBranchDetails(workspace, database, branch) {
781
- return operationsByTag.branch.getBranchDetails({
782
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1368
+ searchTable({
1369
+ workspace,
1370
+ region,
1371
+ database,
1372
+ branch,
1373
+ table,
1374
+ query,
1375
+ fuzziness,
1376
+ target,
1377
+ prefix,
1378
+ filter,
1379
+ highlight,
1380
+ boosters
1381
+ }) {
1382
+ return operationsByTag.searchAndFilter.searchTable({
1383
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1384
+ body: { query, fuzziness, target, prefix, filter, highlight, boosters },
783
1385
  ...this.extraProps
784
1386
  });
785
1387
  }
786
- createBranch(workspace, database, branch, from, options = {}) {
787
- return operationsByTag.branch.createBranch({
788
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
789
- queryParams: isString(from) ? { from } : void 0,
790
- body: options,
1388
+ searchBranch({
1389
+ workspace,
1390
+ region,
1391
+ database,
1392
+ branch,
1393
+ tables,
1394
+ query,
1395
+ fuzziness,
1396
+ prefix,
1397
+ highlight
1398
+ }) {
1399
+ return operationsByTag.searchAndFilter.searchBranch({
1400
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1401
+ body: { tables, query, fuzziness, prefix, highlight },
791
1402
  ...this.extraProps
792
1403
  });
793
1404
  }
794
- deleteBranch(workspace, database, branch) {
795
- return operationsByTag.branch.deleteBranch({
796
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1405
+ summarizeTable({
1406
+ workspace,
1407
+ region,
1408
+ database,
1409
+ branch,
1410
+ table,
1411
+ filter,
1412
+ columns,
1413
+ summaries,
1414
+ sort,
1415
+ summariesFilter,
1416
+ page
1417
+ }) {
1418
+ return operationsByTag.searchAndFilter.summarizeTable({
1419
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1420
+ body: { filter, columns, summaries, sort, summariesFilter, page },
797
1421
  ...this.extraProps
798
1422
  });
799
1423
  }
800
- updateBranchMetadata(workspace, database, branch, metadata = {}) {
801
- return operationsByTag.branch.updateBranchMetadata({
802
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
803
- body: metadata,
1424
+ aggregateTable({
1425
+ workspace,
1426
+ region,
1427
+ database,
1428
+ branch,
1429
+ table,
1430
+ filter,
1431
+ aggs
1432
+ }) {
1433
+ return operationsByTag.searchAndFilter.aggregateTable({
1434
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
1435
+ body: { filter, aggs },
804
1436
  ...this.extraProps
805
1437
  });
806
1438
  }
807
- getBranchMetadata(workspace, database, branch) {
808
- return operationsByTag.branch.getBranchMetadata({
809
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
810
- ...this.extraProps
811
- });
1439
+ }
1440
+ class MigrationRequestsApi {
1441
+ constructor(extraProps) {
1442
+ this.extraProps = extraProps;
812
1443
  }
813
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
814
- return operationsByTag.branch.getBranchMigrationHistory({
815
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
816
- body: options,
1444
+ queryMigrationRequests({
1445
+ workspace,
1446
+ region,
1447
+ database,
1448
+ filter,
1449
+ sort,
1450
+ page,
1451
+ columns
1452
+ }) {
1453
+ return operationsByTag.migrationRequests.queryMigrationRequests({
1454
+ pathParams: { workspace, region, dbName: database },
1455
+ body: { filter, sort, page, columns },
817
1456
  ...this.extraProps
818
1457
  });
819
1458
  }
820
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
821
- return operationsByTag.branch.executeBranchMigrationPlan({
822
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
823
- body: migrationPlan,
1459
+ createMigrationRequest({
1460
+ workspace,
1461
+ region,
1462
+ database,
1463
+ migration
1464
+ }) {
1465
+ return operationsByTag.migrationRequests.createMigrationRequest({
1466
+ pathParams: { workspace, region, dbName: database },
1467
+ body: migration,
824
1468
  ...this.extraProps
825
1469
  });
826
1470
  }
827
- getBranchMigrationPlan(workspace, database, branch, schema) {
828
- return operationsByTag.branch.getBranchMigrationPlan({
829
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
830
- body: schema,
1471
+ getMigrationRequest({
1472
+ workspace,
1473
+ region,
1474
+ database,
1475
+ migrationRequest
1476
+ }) {
1477
+ return operationsByTag.migrationRequests.getMigrationRequest({
1478
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
831
1479
  ...this.extraProps
832
1480
  });
833
1481
  }
834
- getBranchStats(workspace, database, branch) {
835
- return operationsByTag.branch.getBranchStats({
836
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1482
+ updateMigrationRequest({
1483
+ workspace,
1484
+ region,
1485
+ database,
1486
+ migrationRequest,
1487
+ update
1488
+ }) {
1489
+ return operationsByTag.migrationRequests.updateMigrationRequest({
1490
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1491
+ body: update,
837
1492
  ...this.extraProps
838
1493
  });
839
1494
  }
840
- }
841
- class TableApi {
842
- constructor(extraProps) {
843
- this.extraProps = extraProps;
844
- }
845
- createTable(workspace, database, branch, tableName) {
846
- return operationsByTag.table.createTable({
847
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1495
+ listMigrationRequestsCommits({
1496
+ workspace,
1497
+ region,
1498
+ database,
1499
+ migrationRequest,
1500
+ page
1501
+ }) {
1502
+ return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1503
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
1504
+ body: { page },
848
1505
  ...this.extraProps
849
1506
  });
850
1507
  }
851
- deleteTable(workspace, database, branch, tableName) {
852
- return operationsByTag.table.deleteTable({
853
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1508
+ compareMigrationRequest({
1509
+ workspace,
1510
+ region,
1511
+ database,
1512
+ migrationRequest
1513
+ }) {
1514
+ return operationsByTag.migrationRequests.compareMigrationRequest({
1515
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
854
1516
  ...this.extraProps
855
1517
  });
856
1518
  }
857
- updateTable(workspace, database, branch, tableName, options) {
858
- return operationsByTag.table.updateTable({
859
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
860
- body: options,
1519
+ getMigrationRequestIsMerged({
1520
+ workspace,
1521
+ region,
1522
+ database,
1523
+ migrationRequest
1524
+ }) {
1525
+ return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1526
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
861
1527
  ...this.extraProps
862
1528
  });
863
1529
  }
864
- getTableSchema(workspace, database, branch, tableName) {
865
- return operationsByTag.table.getTableSchema({
866
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1530
+ mergeMigrationRequest({
1531
+ workspace,
1532
+ region,
1533
+ database,
1534
+ migrationRequest
1535
+ }) {
1536
+ return operationsByTag.migrationRequests.mergeMigrationRequest({
1537
+ pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
867
1538
  ...this.extraProps
868
1539
  });
869
1540
  }
870
- setTableSchema(workspace, database, branch, tableName, options) {
871
- return operationsByTag.table.setTableSchema({
872
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
873
- body: options,
874
- ...this.extraProps
875
- });
1541
+ }
1542
+ class MigrationsApi {
1543
+ constructor(extraProps) {
1544
+ this.extraProps = extraProps;
876
1545
  }
877
- getTableColumns(workspace, database, branch, tableName) {
878
- return operationsByTag.table.getTableColumns({
879
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1546
+ getBranchMigrationHistory({
1547
+ workspace,
1548
+ region,
1549
+ database,
1550
+ branch,
1551
+ limit,
1552
+ startFrom
1553
+ }) {
1554
+ return operationsByTag.migrations.getBranchMigrationHistory({
1555
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1556
+ body: { limit, startFrom },
880
1557
  ...this.extraProps
881
1558
  });
882
1559
  }
883
- addTableColumn(workspace, database, branch, tableName, column) {
884
- return operationsByTag.table.addTableColumn({
885
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
886
- body: column,
1560
+ getBranchMigrationPlan({
1561
+ workspace,
1562
+ region,
1563
+ database,
1564
+ branch,
1565
+ schema
1566
+ }) {
1567
+ return operationsByTag.migrations.getBranchMigrationPlan({
1568
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1569
+ body: schema,
887
1570
  ...this.extraProps
888
1571
  });
889
1572
  }
890
- getColumn(workspace, database, branch, tableName, columnName) {
891
- return operationsByTag.table.getColumn({
892
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1573
+ executeBranchMigrationPlan({
1574
+ workspace,
1575
+ region,
1576
+ database,
1577
+ branch,
1578
+ plan
1579
+ }) {
1580
+ return operationsByTag.migrations.executeBranchMigrationPlan({
1581
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1582
+ body: plan,
893
1583
  ...this.extraProps
894
1584
  });
895
1585
  }
896
- deleteColumn(workspace, database, branch, tableName, columnName) {
897
- return operationsByTag.table.deleteColumn({
898
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
1586
+ getBranchSchemaHistory({
1587
+ workspace,
1588
+ region,
1589
+ database,
1590
+ branch,
1591
+ page
1592
+ }) {
1593
+ return operationsByTag.migrations.getBranchSchemaHistory({
1594
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1595
+ body: { page },
899
1596
  ...this.extraProps
900
1597
  });
901
1598
  }
902
- updateColumn(workspace, database, branch, tableName, columnName, options) {
903
- return operationsByTag.table.updateColumn({
904
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
905
- body: options,
1599
+ compareBranchWithUserSchema({
1600
+ workspace,
1601
+ region,
1602
+ database,
1603
+ branch,
1604
+ schema
1605
+ }) {
1606
+ return operationsByTag.migrations.compareBranchWithUserSchema({
1607
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1608
+ body: { schema },
906
1609
  ...this.extraProps
907
1610
  });
908
1611
  }
909
- }
910
- class RecordsApi {
911
- constructor(extraProps) {
912
- this.extraProps = extraProps;
913
- }
914
- insertRecord(workspace, database, branch, tableName, record, options = {}) {
915
- return operationsByTag.records.insertRecord({
916
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
917
- queryParams: options,
918
- body: record,
1612
+ compareBranchSchemas({
1613
+ workspace,
1614
+ region,
1615
+ database,
1616
+ branch,
1617
+ compare,
1618
+ schema
1619
+ }) {
1620
+ return operationsByTag.migrations.compareBranchSchemas({
1621
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
1622
+ body: { schema },
919
1623
  ...this.extraProps
920
1624
  });
921
1625
  }
922
- insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
923
- return operationsByTag.records.insertRecordWithID({
924
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
925
- queryParams: options,
926
- body: record,
1626
+ updateBranchSchema({
1627
+ workspace,
1628
+ region,
1629
+ database,
1630
+ branch,
1631
+ migration
1632
+ }) {
1633
+ return operationsByTag.migrations.updateBranchSchema({
1634
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1635
+ body: migration,
927
1636
  ...this.extraProps
928
1637
  });
929
1638
  }
930
- updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
931
- return operationsByTag.records.updateRecordWithID({
932
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
933
- queryParams: options,
934
- body: record,
1639
+ previewBranchSchemaEdit({
1640
+ workspace,
1641
+ region,
1642
+ database,
1643
+ branch,
1644
+ data
1645
+ }) {
1646
+ return operationsByTag.migrations.previewBranchSchemaEdit({
1647
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1648
+ body: data,
935
1649
  ...this.extraProps
936
1650
  });
937
1651
  }
938
- upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
939
- return operationsByTag.records.upsertRecordWithID({
940
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
941
- queryParams: options,
942
- body: record,
1652
+ applyBranchSchemaEdit({
1653
+ workspace,
1654
+ region,
1655
+ database,
1656
+ branch,
1657
+ edits
1658
+ }) {
1659
+ return operationsByTag.migrations.applyBranchSchemaEdit({
1660
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1661
+ body: { edits },
943
1662
  ...this.extraProps
944
1663
  });
945
1664
  }
946
- deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
947
- return operationsByTag.records.deleteRecord({
948
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
949
- queryParams: options,
1665
+ }
1666
+ class DatabaseApi {
1667
+ constructor(extraProps) {
1668
+ this.extraProps = extraProps;
1669
+ }
1670
+ getDatabaseList({ workspace }) {
1671
+ return operationsByTag.databases.getDatabaseList({
1672
+ pathParams: { workspaceId: workspace },
950
1673
  ...this.extraProps
951
1674
  });
952
1675
  }
953
- getRecord(workspace, database, branch, tableName, recordId, options = {}) {
954
- return operationsByTag.records.getRecord({
955
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
956
- queryParams: options,
1676
+ createDatabase({
1677
+ workspace,
1678
+ database,
1679
+ data
1680
+ }) {
1681
+ return operationsByTag.databases.createDatabase({
1682
+ pathParams: { workspaceId: workspace, dbName: database },
1683
+ body: data,
957
1684
  ...this.extraProps
958
1685
  });
959
1686
  }
960
- bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
961
- return operationsByTag.records.bulkInsertTableRecords({
962
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
963
- queryParams: options,
964
- body: { records },
1687
+ deleteDatabase({
1688
+ workspace,
1689
+ database
1690
+ }) {
1691
+ return operationsByTag.databases.deleteDatabase({
1692
+ pathParams: { workspaceId: workspace, dbName: database },
965
1693
  ...this.extraProps
966
1694
  });
967
1695
  }
968
- queryTable(workspace, database, branch, tableName, query) {
969
- return operationsByTag.records.queryTable({
970
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
971
- body: query,
1696
+ getDatabaseMetadata({
1697
+ workspace,
1698
+ database
1699
+ }) {
1700
+ return operationsByTag.databases.getDatabaseMetadata({
1701
+ pathParams: { workspaceId: workspace, dbName: database },
972
1702
  ...this.extraProps
973
1703
  });
974
1704
  }
975
- searchTable(workspace, database, branch, tableName, query) {
976
- return operationsByTag.records.searchTable({
977
- pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
978
- body: query,
1705
+ updateDatabaseMetadata({
1706
+ workspace,
1707
+ database,
1708
+ metadata
1709
+ }) {
1710
+ return operationsByTag.databases.updateDatabaseMetadata({
1711
+ pathParams: { workspaceId: workspace, dbName: database },
1712
+ body: metadata,
979
1713
  ...this.extraProps
980
1714
  });
981
1715
  }
982
- searchBranch(workspace, database, branch, query) {
983
- return operationsByTag.records.searchBranch({
984
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
985
- body: query,
1716
+ listRegions({ workspace }) {
1717
+ return operationsByTag.databases.listRegions({
1718
+ pathParams: { workspaceId: workspace },
986
1719
  ...this.extraProps
987
1720
  });
988
1721
  }
@@ -998,6 +1731,20 @@ class XataApiPlugin {
998
1731
  class XataPlugin {
999
1732
  }
1000
1733
 
1734
+ function generateUUID() {
1735
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
1736
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
1737
+ return v.toString(16);
1738
+ });
1739
+ }
1740
+
1741
+ function cleanFilter(filter) {
1742
+ if (!filter)
1743
+ return void 0;
1744
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
1745
+ return values.length > 0 ? filter : void 0;
1746
+ }
1747
+
1001
1748
  var __accessCheck$6 = (obj, member, msg) => {
1002
1749
  if (!member.has(obj))
1003
1750
  throw TypeError("Cannot " + msg);
@@ -1111,9 +1858,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
1111
1858
  setter ? setter.call(obj, value) : member.set(obj, value);
1112
1859
  return value;
1113
1860
  };
1114
- var _table$1, _repository, _data;
1861
+ var __privateMethod$3 = (obj, member, method) => {
1862
+ __accessCheck$5(obj, member, "access private method");
1863
+ return method;
1864
+ };
1865
+ var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
1115
1866
  const _Query = class {
1116
1867
  constructor(repository, table, data, rawParent) {
1868
+ __privateAdd$5(this, _cleanFilterConstraint);
1117
1869
  __privateAdd$5(this, _table$1, void 0);
1118
1870
  __privateAdd$5(this, _repository, void 0);
1119
1871
  __privateAdd$5(this, _data, { filter: {} });
@@ -1132,7 +1884,7 @@ const _Query = class {
1132
1884
  __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
1133
1885
  __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
1134
1886
  __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
1135
- __privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
1887
+ __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
1136
1888
  __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
1137
1889
  __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
1138
1890
  this.any = this.any.bind(this);
@@ -1170,15 +1922,18 @@ const _Query = class {
1170
1922
  }
1171
1923
  filter(a, b) {
1172
1924
  if (arguments.length === 1) {
1173
- const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
1925
+ const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
1926
+ [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
1927
+ }));
1174
1928
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1175
1929
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1176
1930
  } else {
1177
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
1931
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
1932
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1178
1933
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1179
1934
  }
1180
1935
  }
1181
- sort(column, direction) {
1936
+ sort(column, direction = "asc") {
1182
1937
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1183
1938
  const sort = [...originalSort, { column, direction }];
1184
1939
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
@@ -1212,11 +1967,20 @@ const _Query = class {
1212
1967
  }
1213
1968
  }
1214
1969
  async getMany(options = {}) {
1215
- const page = await this.getPaginated(options);
1970
+ const { pagination = {}, ...rest } = options;
1971
+ const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
1972
+ const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
1973
+ let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
1974
+ const results = [...page.records];
1975
+ while (page.hasNextPage() && results.length < size) {
1976
+ page = await page.nextPage();
1977
+ results.push(...page.records);
1978
+ }
1216
1979
  if (page.hasNextPage() && options.pagination?.size === void 0) {
1217
1980
  console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
1218
1981
  }
1219
- return page.records;
1982
+ const array = new RecordArray(page, results.slice(0, size));
1983
+ return array;
1220
1984
  }
1221
1985
  async getAll(options = {}) {
1222
1986
  const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
@@ -1230,6 +1994,22 @@ const _Query = class {
1230
1994
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
1231
1995
  return records[0] ?? null;
1232
1996
  }
1997
+ async getFirstOrThrow(options = {}) {
1998
+ const records = await this.getMany({ ...options, pagination: { size: 1 } });
1999
+ if (records[0] === void 0)
2000
+ throw new Error("No results found.");
2001
+ return records[0];
2002
+ }
2003
+ async summarize(params = {}) {
2004
+ const { summaries, summariesFilter, ...options } = params;
2005
+ const query = new _Query(
2006
+ __privateGet$5(this, _repository),
2007
+ __privateGet$5(this, _table$1),
2008
+ options,
2009
+ __privateGet$5(this, _data)
2010
+ );
2011
+ return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
2012
+ }
1233
2013
  cache(ttl) {
1234
2014
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1235
2015
  }
@@ -1253,9 +2033,20 @@ let Query = _Query;
1253
2033
  _table$1 = new WeakMap();
1254
2034
  _repository = new WeakMap();
1255
2035
  _data = new WeakMap();
2036
+ _cleanFilterConstraint = new WeakSet();
2037
+ cleanFilterConstraint_fn = function(column, value) {
2038
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
2039
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
2040
+ return { $includes: value };
2041
+ }
2042
+ if (columnType === "link" && isObject(value) && isString(value.id)) {
2043
+ return value.id;
2044
+ }
2045
+ return value;
2046
+ };
1256
2047
  function cleanParent(data, parent) {
1257
2048
  if (isCursorPaginationOptions(data.pagination)) {
1258
- return { ...parent, sorting: void 0, filter: void 0 };
2049
+ return { ...parent, sort: void 0, filter: void 0 };
1259
2050
  }
1260
2051
  return parent;
1261
2052
  }
@@ -1314,12 +2105,16 @@ var __privateMethod$2 = (obj, member, method) => {
1314
2105
  __accessCheck$4(obj, member, "access private method");
1315
2106
  return method;
1316
2107
  };
1317
- var _table, _getFetchProps, _db, _cache, _schemaTables$2, _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;
2108
+ 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;
1318
2109
  class Repository extends Query {
1319
2110
  }
1320
2111
  class RestRepository extends Query {
1321
2112
  constructor(options) {
1322
- super(null, options.table, {});
2113
+ super(
2114
+ null,
2115
+ { name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
2116
+ {}
2117
+ );
1323
2118
  __privateAdd$4(this, _insertRecordWithoutId);
1324
2119
  __privateAdd$4(this, _insertRecordWithId);
1325
2120
  __privateAdd$4(this, _bulkInsertTableRecords);
@@ -1334,168 +2129,328 @@ class RestRepository extends Query {
1334
2129
  __privateAdd$4(this, _db, void 0);
1335
2130
  __privateAdd$4(this, _cache, void 0);
1336
2131
  __privateAdd$4(this, _schemaTables$2, void 0);
2132
+ __privateAdd$4(this, _trace, void 0);
1337
2133
  __privateSet$4(this, _table, options.table);
1338
- __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1339
2134
  __privateSet$4(this, _db, options.db);
1340
2135
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1341
2136
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
2137
+ __privateSet$4(this, _getFetchProps, async () => {
2138
+ const props = await options.pluginOptions.getFetchProps();
2139
+ return { ...props, sessionID: generateUUID() };
2140
+ });
2141
+ const trace = options.pluginOptions.trace ?? defaultTrace;
2142
+ __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
2143
+ return trace(name, fn, {
2144
+ ...options2,
2145
+ [TraceAttributes.TABLE]: __privateGet$4(this, _table),
2146
+ [TraceAttributes.KIND]: "sdk-operation",
2147
+ [TraceAttributes.VERSION]: VERSION
2148
+ });
2149
+ });
1342
2150
  }
1343
- async create(a, b, c) {
1344
- if (Array.isArray(a)) {
1345
- if (a.length === 0)
1346
- return [];
1347
- const columns = isStringArray(b) ? b : void 0;
1348
- return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
1349
- }
1350
- if (isString(a) && isObject(b)) {
1351
- if (a === "")
1352
- throw new Error("The id can't be empty");
1353
- const columns = isStringArray(c) ? c : void 0;
1354
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
1355
- }
1356
- if (isObject(a) && isString(a.id)) {
1357
- if (a.id === "")
1358
- throw new Error("The id can't be empty");
1359
- const columns = isStringArray(b) ? b : void 0;
1360
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1361
- }
1362
- if (isObject(a)) {
1363
- const columns = isStringArray(b) ? b : void 0;
1364
- return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
1365
- }
1366
- throw new Error("Invalid arguments for create method");
2151
+ async create(a, b, c, d) {
2152
+ return __privateGet$4(this, _trace).call(this, "create", async () => {
2153
+ const ifVersion = parseIfVersion(b, c, d);
2154
+ if (Array.isArray(a)) {
2155
+ if (a.length === 0)
2156
+ return [];
2157
+ const columns = isStringArray(b) ? b : void 0;
2158
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
2159
+ }
2160
+ if (isString(a) && isObject(b)) {
2161
+ if (a === "")
2162
+ throw new Error("The id can't be empty");
2163
+ const columns = isStringArray(c) ? c : void 0;
2164
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
2165
+ }
2166
+ if (isObject(a) && isString(a.id)) {
2167
+ if (a.id === "")
2168
+ throw new Error("The id can't be empty");
2169
+ const columns = isStringArray(b) ? b : void 0;
2170
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
2171
+ }
2172
+ if (isObject(a)) {
2173
+ const columns = isStringArray(b) ? b : void 0;
2174
+ return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
2175
+ }
2176
+ throw new Error("Invalid arguments for create method");
2177
+ });
1367
2178
  }
1368
2179
  async read(a, b) {
1369
- const columns = isStringArray(b) ? b : ["*"];
1370
- if (Array.isArray(a)) {
1371
- if (a.length === 0)
1372
- return [];
1373
- const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
1374
- const finalObjects = await this.getAll({ filter: { id: { $any: ids } }, columns });
1375
- const dictionary = finalObjects.reduce((acc, object) => {
1376
- acc[object.id] = object;
1377
- return acc;
1378
- }, {});
1379
- return ids.map((id2) => dictionary[id2] ?? null);
1380
- }
1381
- const id = isString(a) ? a : a.id;
1382
- if (isString(id)) {
1383
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1384
- try {
1385
- const response = await getRecord({
1386
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: id },
1387
- queryParams: { columns },
1388
- ...fetchProps
1389
- });
1390
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1391
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1392
- } catch (e) {
1393
- if (isObject(e) && e.status === 404) {
1394
- return null;
2180
+ return __privateGet$4(this, _trace).call(this, "read", async () => {
2181
+ const columns = isStringArray(b) ? b : ["*"];
2182
+ if (Array.isArray(a)) {
2183
+ if (a.length === 0)
2184
+ return [];
2185
+ const ids = a.map((item) => extractId(item));
2186
+ const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
2187
+ const dictionary = finalObjects.reduce((acc, object) => {
2188
+ acc[object.id] = object;
2189
+ return acc;
2190
+ }, {});
2191
+ return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
2192
+ }
2193
+ const id = extractId(a);
2194
+ if (id) {
2195
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2196
+ try {
2197
+ const response = await getRecord({
2198
+ pathParams: {
2199
+ workspace: "{workspaceId}",
2200
+ dbBranchName: "{dbBranch}",
2201
+ region: "{region}",
2202
+ tableName: __privateGet$4(this, _table),
2203
+ recordId: id
2204
+ },
2205
+ queryParams: { columns },
2206
+ ...fetchProps
2207
+ });
2208
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2209
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2210
+ } catch (e) {
2211
+ if (isObject(e) && e.status === 404) {
2212
+ return null;
2213
+ }
2214
+ throw e;
1395
2215
  }
1396
- throw e;
1397
2216
  }
1398
- }
1399
- return null;
2217
+ return null;
2218
+ });
1400
2219
  }
1401
- async update(a, b, c) {
1402
- if (Array.isArray(a)) {
1403
- if (a.length === 0)
1404
- return [];
1405
- if (a.length > 100) {
1406
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
2220
+ async readOrThrow(a, b) {
2221
+ return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
2222
+ const result = await this.read(a, b);
2223
+ if (Array.isArray(result)) {
2224
+ const missingIds = compact(
2225
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
2226
+ );
2227
+ if (missingIds.length > 0) {
2228
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
2229
+ }
2230
+ return result;
1407
2231
  }
1408
- const columns = isStringArray(b) ? b : ["*"];
1409
- return Promise.all(a.map((object) => this.update(object, columns)));
1410
- }
1411
- if (isString(a) && isObject(b)) {
1412
- const columns = isStringArray(c) ? c : void 0;
1413
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
1414
- }
1415
- if (isObject(a) && isString(a.id)) {
1416
- const columns = isStringArray(b) ? b : void 0;
1417
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1418
- }
1419
- throw new Error("Invalid arguments for update method");
1420
- }
1421
- async createOrUpdate(a, b, c) {
1422
- if (Array.isArray(a)) {
1423
- if (a.length === 0)
1424
- return [];
1425
- if (a.length > 100) {
1426
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
2232
+ if (result === null) {
2233
+ const id = extractId(a) ?? "unknown";
2234
+ throw new Error(`Record with id ${id} not found`);
1427
2235
  }
1428
- const columns = isStringArray(b) ? b : ["*"];
1429
- return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
1430
- }
1431
- if (isString(a) && isObject(b)) {
1432
- const columns = isStringArray(c) ? c : void 0;
1433
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
1434
- }
1435
- if (isObject(a) && isString(a.id)) {
1436
- const columns = isStringArray(c) ? c : void 0;
1437
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1438
- }
1439
- throw new Error("Invalid arguments for createOrUpdate method");
1440
- }
1441
- async delete(a) {
1442
- if (Array.isArray(a)) {
1443
- if (a.length === 0)
1444
- return;
1445
- if (a.length > 100) {
1446
- console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
2236
+ return result;
2237
+ });
2238
+ }
2239
+ async update(a, b, c, d) {
2240
+ return __privateGet$4(this, _trace).call(this, "update", async () => {
2241
+ const ifVersion = parseIfVersion(b, c, d);
2242
+ if (Array.isArray(a)) {
2243
+ if (a.length === 0)
2244
+ return [];
2245
+ if (a.length > 100) {
2246
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
2247
+ }
2248
+ const columns = isStringArray(b) ? b : ["*"];
2249
+ return Promise.all(a.map((object) => this.update(object, columns)));
1447
2250
  }
1448
- await Promise.all(a.map((id) => this.delete(id)));
1449
- return;
1450
- }
1451
- if (isString(a)) {
1452
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
1453
- return;
1454
- }
1455
- if (isObject(a) && isString(a.id)) {
1456
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
1457
- return;
1458
- }
1459
- throw new Error("Invalid arguments for delete method");
2251
+ if (isString(a) && isObject(b)) {
2252
+ const columns = isStringArray(c) ? c : void 0;
2253
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2254
+ }
2255
+ if (isObject(a) && isString(a.id)) {
2256
+ const columns = isStringArray(b) ? b : void 0;
2257
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2258
+ }
2259
+ throw new Error("Invalid arguments for update method");
2260
+ });
2261
+ }
2262
+ async updateOrThrow(a, b, c, d) {
2263
+ return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
2264
+ const result = await this.update(a, b, c, d);
2265
+ if (Array.isArray(result)) {
2266
+ const missingIds = compact(
2267
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
2268
+ );
2269
+ if (missingIds.length > 0) {
2270
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
2271
+ }
2272
+ return result;
2273
+ }
2274
+ if (result === null) {
2275
+ const id = extractId(a) ?? "unknown";
2276
+ throw new Error(`Record with id ${id} not found`);
2277
+ }
2278
+ return result;
2279
+ });
2280
+ }
2281
+ async createOrUpdate(a, b, c, d) {
2282
+ return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
2283
+ const ifVersion = parseIfVersion(b, c, d);
2284
+ if (Array.isArray(a)) {
2285
+ if (a.length === 0)
2286
+ return [];
2287
+ if (a.length > 100) {
2288
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
2289
+ }
2290
+ const columns = isStringArray(b) ? b : ["*"];
2291
+ return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
2292
+ }
2293
+ if (isString(a) && isObject(b)) {
2294
+ const columns = isStringArray(c) ? c : void 0;
2295
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2296
+ }
2297
+ if (isObject(a) && isString(a.id)) {
2298
+ const columns = isStringArray(c) ? c : void 0;
2299
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2300
+ }
2301
+ throw new Error("Invalid arguments for createOrUpdate method");
2302
+ });
2303
+ }
2304
+ async createOrReplace(a, b, c, d) {
2305
+ return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
2306
+ const ifVersion = parseIfVersion(b, c, d);
2307
+ if (Array.isArray(a)) {
2308
+ if (a.length === 0)
2309
+ return [];
2310
+ const columns = isStringArray(b) ? b : ["*"];
2311
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
2312
+ }
2313
+ if (isString(a) && isObject(b)) {
2314
+ const columns = isStringArray(c) ? c : void 0;
2315
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
2316
+ }
2317
+ if (isObject(a) && isString(a.id)) {
2318
+ const columns = isStringArray(c) ? c : void 0;
2319
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
2320
+ }
2321
+ throw new Error("Invalid arguments for createOrReplace method");
2322
+ });
2323
+ }
2324
+ async delete(a, b) {
2325
+ return __privateGet$4(this, _trace).call(this, "delete", async () => {
2326
+ if (Array.isArray(a)) {
2327
+ if (a.length === 0)
2328
+ return [];
2329
+ if (a.length > 100) {
2330
+ console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
2331
+ }
2332
+ return Promise.all(a.map((id) => this.delete(id, b)));
2333
+ }
2334
+ if (isString(a)) {
2335
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
2336
+ }
2337
+ if (isObject(a) && isString(a.id)) {
2338
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
2339
+ }
2340
+ throw new Error("Invalid arguments for delete method");
2341
+ });
2342
+ }
2343
+ async deleteOrThrow(a, b) {
2344
+ return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
2345
+ const result = await this.delete(a, b);
2346
+ if (Array.isArray(result)) {
2347
+ const missingIds = compact(
2348
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
2349
+ );
2350
+ if (missingIds.length > 0) {
2351
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
2352
+ }
2353
+ return result;
2354
+ } else if (result === null) {
2355
+ const id = extractId(a) ?? "unknown";
2356
+ throw new Error(`Record with id ${id} not found`);
2357
+ }
2358
+ return result;
2359
+ });
1460
2360
  }
1461
2361
  async search(query, options = {}) {
1462
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1463
- const { records } = await searchTable({
1464
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1465
- body: {
1466
- query,
1467
- fuzziness: options.fuzziness,
1468
- prefix: options.prefix,
1469
- highlight: options.highlight,
1470
- filter: options.filter,
1471
- boosters: options.boosters
1472
- },
1473
- ...fetchProps
2362
+ return __privateGet$4(this, _trace).call(this, "search", async () => {
2363
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2364
+ const { records } = await searchTable({
2365
+ pathParams: {
2366
+ workspace: "{workspaceId}",
2367
+ dbBranchName: "{dbBranch}",
2368
+ region: "{region}",
2369
+ tableName: __privateGet$4(this, _table)
2370
+ },
2371
+ body: {
2372
+ query,
2373
+ fuzziness: options.fuzziness,
2374
+ prefix: options.prefix,
2375
+ highlight: options.highlight,
2376
+ filter: options.filter,
2377
+ boosters: options.boosters
2378
+ },
2379
+ ...fetchProps
2380
+ });
2381
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2382
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
2383
+ });
2384
+ }
2385
+ async aggregate(aggs, filter) {
2386
+ return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
2387
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2388
+ const result = await aggregateTable({
2389
+ pathParams: {
2390
+ workspace: "{workspaceId}",
2391
+ dbBranchName: "{dbBranch}",
2392
+ region: "{region}",
2393
+ tableName: __privateGet$4(this, _table)
2394
+ },
2395
+ body: { aggs, filter },
2396
+ ...fetchProps
2397
+ });
2398
+ return result;
1474
2399
  });
1475
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1476
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
1477
2400
  }
1478
2401
  async query(query) {
1479
- const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1480
- if (cacheQuery)
1481
- return new Page(query, cacheQuery.meta, cacheQuery.records);
1482
- const data = query.getQueryOptions();
1483
- const body = {
1484
- filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1485
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1486
- page: data.pagination,
1487
- columns: data.columns
1488
- };
1489
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1490
- const { meta, records: objects } = await queryTable({
1491
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1492
- body,
1493
- ...fetchProps
2402
+ return __privateGet$4(this, _trace).call(this, "query", async () => {
2403
+ const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
2404
+ if (cacheQuery)
2405
+ return new Page(query, cacheQuery.meta, cacheQuery.records);
2406
+ const data = query.getQueryOptions();
2407
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2408
+ const { meta, records: objects } = await queryTable({
2409
+ pathParams: {
2410
+ workspace: "{workspaceId}",
2411
+ dbBranchName: "{dbBranch}",
2412
+ region: "{region}",
2413
+ tableName: __privateGet$4(this, _table)
2414
+ },
2415
+ body: {
2416
+ filter: cleanFilter(data.filter),
2417
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2418
+ page: data.pagination,
2419
+ columns: data.columns ?? ["*"]
2420
+ },
2421
+ ...fetchProps
2422
+ });
2423
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2424
+ const records = objects.map(
2425
+ (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
2426
+ );
2427
+ await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
2428
+ return new Page(query, meta, records);
2429
+ });
2430
+ }
2431
+ async summarizeTable(query, summaries, summariesFilter) {
2432
+ return __privateGet$4(this, _trace).call(this, "summarize", async () => {
2433
+ const data = query.getQueryOptions();
2434
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2435
+ const result = await summarizeTable({
2436
+ pathParams: {
2437
+ workspace: "{workspaceId}",
2438
+ dbBranchName: "{dbBranch}",
2439
+ region: "{region}",
2440
+ tableName: __privateGet$4(this, _table)
2441
+ },
2442
+ body: {
2443
+ filter: cleanFilter(data.filter),
2444
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2445
+ columns: data.columns,
2446
+ page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
2447
+ summaries,
2448
+ summariesFilter
2449
+ },
2450
+ ...fetchProps
2451
+ });
2452
+ return result;
1494
2453
  });
1495
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1496
- const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
1497
- await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1498
- return new Page(query, meta, records);
1499
2454
  }
1500
2455
  }
1501
2456
  _table = new WeakMap();
@@ -1503,6 +2458,7 @@ _getFetchProps = new WeakMap();
1503
2458
  _db = new WeakMap();
1504
2459
  _cache = new WeakMap();
1505
2460
  _schemaTables$2 = new WeakMap();
2461
+ _trace = new WeakMap();
1506
2462
  _insertRecordWithoutId = new WeakSet();
1507
2463
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1508
2464
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
@@ -1511,6 +2467,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1511
2467
  pathParams: {
1512
2468
  workspace: "{workspaceId}",
1513
2469
  dbBranchName: "{dbBranch}",
2470
+ region: "{region}",
1514
2471
  tableName: __privateGet$4(this, _table)
1515
2472
  },
1516
2473
  queryParams: { columns },
@@ -1518,32 +2475,38 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1518
2475
  ...fetchProps
1519
2476
  });
1520
2477
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1521
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2478
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1522
2479
  };
1523
2480
  _insertRecordWithId = new WeakSet();
1524
- insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
2481
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
1525
2482
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1526
2483
  const record = transformObjectLinks(object);
1527
2484
  const response = await insertRecordWithID({
1528
2485
  pathParams: {
1529
2486
  workspace: "{workspaceId}",
1530
2487
  dbBranchName: "{dbBranch}",
2488
+ region: "{region}",
1531
2489
  tableName: __privateGet$4(this, _table),
1532
2490
  recordId
1533
2491
  },
1534
2492
  body: record,
1535
- queryParams: { createOnly: true, columns },
2493
+ queryParams: { createOnly, columns, ifVersion },
1536
2494
  ...fetchProps
1537
2495
  });
1538
2496
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1539
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2497
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1540
2498
  };
1541
2499
  _bulkInsertTableRecords = new WeakSet();
1542
2500
  bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1543
2501
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1544
2502
  const records = objects.map((object) => transformObjectLinks(object));
1545
2503
  const response = await bulkInsertTableRecords({
1546
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
2504
+ pathParams: {
2505
+ workspace: "{workspaceId}",
2506
+ dbBranchName: "{dbBranch}",
2507
+ region: "{region}",
2508
+ tableName: __privateGet$4(this, _table)
2509
+ },
1547
2510
  queryParams: { columns },
1548
2511
  body: { records },
1549
2512
  ...fetchProps
@@ -1552,40 +2515,75 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1552
2515
  throw new Error("Request included columns but server didn't include them");
1553
2516
  }
1554
2517
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1555
- return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
2518
+ return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
1556
2519
  };
1557
2520
  _updateRecordWithID = new WeakSet();
1558
- updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2521
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
1559
2522
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1560
2523
  const record = transformObjectLinks(object);
1561
- const response = await updateRecordWithID({
1562
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1563
- queryParams: { columns },
1564
- body: record,
1565
- ...fetchProps
1566
- });
1567
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1568
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2524
+ try {
2525
+ const response = await updateRecordWithID({
2526
+ pathParams: {
2527
+ workspace: "{workspaceId}",
2528
+ dbBranchName: "{dbBranch}",
2529
+ region: "{region}",
2530
+ tableName: __privateGet$4(this, _table),
2531
+ recordId
2532
+ },
2533
+ queryParams: { columns, ifVersion },
2534
+ body: record,
2535
+ ...fetchProps
2536
+ });
2537
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2538
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2539
+ } catch (e) {
2540
+ if (isObject(e) && e.status === 404) {
2541
+ return null;
2542
+ }
2543
+ throw e;
2544
+ }
1569
2545
  };
1570
2546
  _upsertRecordWithID = new WeakSet();
1571
- upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
2547
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
1572
2548
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1573
2549
  const response = await upsertRecordWithID({
1574
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1575
- queryParams: { columns },
2550
+ pathParams: {
2551
+ workspace: "{workspaceId}",
2552
+ dbBranchName: "{dbBranch}",
2553
+ region: "{region}",
2554
+ tableName: __privateGet$4(this, _table),
2555
+ recordId
2556
+ },
2557
+ queryParams: { columns, ifVersion },
1576
2558
  body: object,
1577
2559
  ...fetchProps
1578
2560
  });
1579
2561
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1580
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
2562
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1581
2563
  };
1582
2564
  _deleteRecord = new WeakSet();
1583
- deleteRecord_fn = async function(recordId) {
2565
+ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1584
2566
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1585
- await deleteRecord({
1586
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1587
- ...fetchProps
1588
- });
2567
+ try {
2568
+ const response = await deleteRecord({
2569
+ pathParams: {
2570
+ workspace: "{workspaceId}",
2571
+ dbBranchName: "{dbBranch}",
2572
+ region: "{region}",
2573
+ tableName: __privateGet$4(this, _table),
2574
+ recordId
2575
+ },
2576
+ queryParams: { columns },
2577
+ ...fetchProps
2578
+ });
2579
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2580
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2581
+ } catch (e) {
2582
+ if (isObject(e) && e.status === 404) {
2583
+ return null;
2584
+ }
2585
+ throw e;
2586
+ }
1589
2587
  };
1590
2588
  _setCacheQuery = new WeakSet();
1591
2589
  setCacheQuery_fn = async function(query, meta, records) {
@@ -1609,7 +2607,7 @@ getSchemaTables_fn$1 = async function() {
1609
2607
  return __privateGet$4(this, _schemaTables$2);
1610
2608
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1611
2609
  const { schema } = await getBranchDetails({
1612
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2610
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
1613
2611
  ...fetchProps
1614
2612
  });
1615
2613
  __privateSet$4(this, _schemaTables$2, schema.tables);
@@ -1622,7 +2620,7 @@ const transformObjectLinks = (object) => {
1622
2620
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
1623
2621
  }, {});
1624
2622
  };
1625
- const initObject = (db, schemaTables, table, object) => {
2623
+ const initObject = (db, schemaTables, table, object, selectedColumns) => {
1626
2624
  const result = {};
1627
2625
  const { xata, ...rest } = object ?? {};
1628
2626
  Object.assign(result, rest);
@@ -1630,6 +2628,8 @@ const initObject = (db, schemaTables, table, object) => {
1630
2628
  if (!columns)
1631
2629
  console.error(`Table ${table} not found in schema`);
1632
2630
  for (const column of columns ?? []) {
2631
+ if (!isValidColumn(selectedColumns, column))
2632
+ continue;
1633
2633
  const value = result[column.name];
1634
2634
  switch (column.type) {
1635
2635
  case "datetime": {
@@ -1646,17 +2646,42 @@ const initObject = (db, schemaTables, table, object) => {
1646
2646
  if (!linkTable) {
1647
2647
  console.error(`Failed to parse link for field ${column.name}`);
1648
2648
  } else if (isObject(value)) {
1649
- result[column.name] = initObject(db, schemaTables, linkTable, value);
2649
+ const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
2650
+ if (item === column.name) {
2651
+ return [...acc, "*"];
2652
+ }
2653
+ if (item.startsWith(`${column.name}.`)) {
2654
+ const [, ...path] = item.split(".");
2655
+ return [...acc, path.join(".")];
2656
+ }
2657
+ return acc;
2658
+ }, []);
2659
+ result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2660
+ } else {
2661
+ result[column.name] = null;
1650
2662
  }
1651
2663
  break;
1652
2664
  }
2665
+ default:
2666
+ result[column.name] = value ?? null;
2667
+ if (column.notNull === true && value === null) {
2668
+ console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2669
+ }
2670
+ break;
1653
2671
  }
1654
2672
  }
1655
2673
  result.read = function(columns2) {
1656
2674
  return db[table].read(result["id"], columns2);
1657
2675
  };
1658
- result.update = function(data, columns2) {
1659
- return db[table].update(result["id"], data, columns2);
2676
+ result.update = function(data, b, c) {
2677
+ const columns2 = isStringArray(b) ? b : ["*"];
2678
+ const ifVersion = parseIfVersion(b, c);
2679
+ return db[table].update(result["id"], data, columns2, { ifVersion });
2680
+ };
2681
+ result.replace = function(data, b, c) {
2682
+ const columns2 = isStringArray(b) ? b : ["*"];
2683
+ const ifVersion = parseIfVersion(b, c);
2684
+ return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
1660
2685
  };
1661
2686
  result.delete = function() {
1662
2687
  return db[table].delete(result["id"]);
@@ -1673,6 +2698,30 @@ const initObject = (db, schemaTables, table, object) => {
1673
2698
  function isResponseWithRecords(value) {
1674
2699
  return isObject(value) && Array.isArray(value.records);
1675
2700
  }
2701
+ function extractId(value) {
2702
+ if (isString(value))
2703
+ return value;
2704
+ if (isObject(value) && isString(value.id))
2705
+ return value.id;
2706
+ return void 0;
2707
+ }
2708
+ function isValidColumn(columns, column) {
2709
+ if (columns.includes("*"))
2710
+ return true;
2711
+ if (column.type === "link") {
2712
+ const linkColumns = columns.filter((item) => item.startsWith(column.name));
2713
+ return linkColumns.length > 0;
2714
+ }
2715
+ return columns.includes(column.name);
2716
+ }
2717
+ function parseIfVersion(...args) {
2718
+ for (const arg of args) {
2719
+ if (isObject(arg) && isNumber(arg.ifVersion)) {
2720
+ return arg.ifVersion;
2721
+ }
2722
+ }
2723
+ return void 0;
2724
+ }
1676
2725
 
1677
2726
  var __accessCheck$3 = (obj, member, msg) => {
1678
2727
  if (!member.has(obj))
@@ -1723,18 +2772,25 @@ class SimpleCache {
1723
2772
  }
1724
2773
  _map = new WeakMap();
1725
2774
 
1726
- const gt = (value) => ({ $gt: value });
1727
- const ge = (value) => ({ $ge: value });
1728
- const gte = (value) => ({ $ge: value });
1729
- const lt = (value) => ({ $lt: value });
1730
- const lte = (value) => ({ $le: value });
1731
- const le = (value) => ({ $le: value });
2775
+ const greaterThan = (value) => ({ $gt: value });
2776
+ const gt = greaterThan;
2777
+ const greaterThanEquals = (value) => ({ $ge: value });
2778
+ const greaterEquals = greaterThanEquals;
2779
+ const gte = greaterThanEquals;
2780
+ const ge = greaterThanEquals;
2781
+ const lessThan = (value) => ({ $lt: value });
2782
+ const lt = lessThan;
2783
+ const lessThanEquals = (value) => ({ $le: value });
2784
+ const lessEquals = lessThanEquals;
2785
+ const lte = lessThanEquals;
2786
+ const le = lessThanEquals;
1732
2787
  const exists = (column) => ({ $exists: column });
1733
2788
  const notExists = (column) => ({ $notExists: column });
1734
2789
  const startsWith = (value) => ({ $startsWith: value });
1735
2790
  const endsWith = (value) => ({ $endsWith: value });
1736
2791
  const pattern = (value) => ({ $pattern: value });
1737
2792
  const is = (value) => ({ $is: value });
2793
+ const equals = is;
1738
2794
  const isNot = (value) => ({ $isNot: value });
1739
2795
  const contains = (value) => ({ $contains: value });
1740
2796
  const includes = (value) => ({ $includes: value });
@@ -1831,7 +2887,7 @@ class SearchPlugin extends XataPlugin {
1831
2887
  const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
1832
2888
  return records.map((record) => {
1833
2889
  const { table = "orphan" } = record.xata;
1834
- return { table, record: initObject(this.db, schemaTables, table, record) };
2890
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
1835
2891
  });
1836
2892
  },
1837
2893
  byTable: async (query, options = {}) => {
@@ -1840,7 +2896,7 @@ class SearchPlugin extends XataPlugin {
1840
2896
  return records.reduce((acc, record) => {
1841
2897
  const { table = "orphan" } = record.xata;
1842
2898
  const items = acc[table] ?? [];
1843
- const item = initObject(this.db, schemaTables, table, record);
2899
+ const item = initObject(this.db, schemaTables, table, record, ["*"]);
1844
2900
  return { ...acc, [table]: [...items, item] };
1845
2901
  }, {});
1846
2902
  }
@@ -1853,7 +2909,7 @@ search_fn = async function(query, options, getFetchProps) {
1853
2909
  const fetchProps = await getFetchProps();
1854
2910
  const { tables, fuzziness, highlight, prefix } = options ?? {};
1855
2911
  const { records } = await searchBranch({
1856
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2912
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
1857
2913
  body: { tables, query, fuzziness, prefix, highlight },
1858
2914
  ...fetchProps
1859
2915
  });
@@ -1865,7 +2921,7 @@ getSchemaTables_fn = async function(getFetchProps) {
1865
2921
  return __privateGet$1(this, _schemaTables);
1866
2922
  const fetchProps = await getFetchProps();
1867
2923
  const { schema } = await getBranchDetails({
1868
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
2924
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
1869
2925
  ...fetchProps
1870
2926
  });
1871
2927
  __privateSet$1(this, _schemaTables, schema.tables);
@@ -1903,15 +2959,19 @@ async function resolveXataBranch(gitBranch, options) {
1903
2959
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
1904
2960
  );
1905
2961
  const [protocol, , host, , dbName] = databaseURL.split("/");
1906
- const [workspace] = host.split(".");
2962
+ const urlParts = parseWorkspacesUrlParts(host);
2963
+ if (!urlParts)
2964
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
2965
+ const { workspace, region } = urlParts;
1907
2966
  const { fallbackBranch } = getEnvironment();
1908
2967
  const { branch } = await resolveBranch({
1909
2968
  apiKey,
1910
2969
  apiUrl: databaseURL,
1911
2970
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1912
2971
  workspacesApiUrl: `${protocol}//${host}`,
1913
- pathParams: { dbName, workspace },
1914
- queryParams: { gitBranch, fallbackBranch }
2972
+ pathParams: { dbName, workspace, region },
2973
+ queryParams: { gitBranch, fallbackBranch },
2974
+ trace: defaultTrace
1915
2975
  });
1916
2976
  return branch;
1917
2977
  }
@@ -1927,15 +2987,18 @@ async function getDatabaseBranch(branch, options) {
1927
2987
  "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
1928
2988
  );
1929
2989
  const [protocol, , host, , database] = databaseURL.split("/");
1930
- const [workspace] = host.split(".");
1931
- const dbBranchName = `${database}:${branch}`;
2990
+ const urlParts = parseWorkspacesUrlParts(host);
2991
+ if (!urlParts)
2992
+ throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
2993
+ const { workspace, region } = urlParts;
1932
2994
  try {
1933
2995
  return await getBranchDetails({
1934
2996
  apiKey,
1935
2997
  apiUrl: databaseURL,
1936
2998
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1937
2999
  workspacesApiUrl: `${protocol}//${host}`,
1938
- pathParams: { dbBranchName, workspace }
3000
+ pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
3001
+ trace: defaultTrace
1939
3002
  });
1940
3003
  } catch (err) {
1941
3004
  if (isObject(err) && err.status === 404)
@@ -1987,7 +3050,8 @@ const buildClient = (plugins) => {
1987
3050
  __privateSet(this, _options, safeOptions);
1988
3051
  const pluginOptions = {
1989
3052
  getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
1990
- cache: safeOptions.cache
3053
+ cache: safeOptions.cache,
3054
+ trace: safeOptions.trace
1991
3055
  };
1992
3056
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
1993
3057
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
@@ -2016,12 +3080,16 @@ const buildClient = (plugins) => {
2016
3080
  const databaseURL = options?.databaseURL || getDatabaseURL();
2017
3081
  const apiKey = options?.apiKey || getAPIKey();
2018
3082
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
3083
+ const trace = options?.trace ?? defaultTrace;
2019
3084
  const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
2020
- if (!databaseURL || !apiKey) {
2021
- throw new Error("Options databaseURL and apiKey are required");
3085
+ if (!apiKey) {
3086
+ throw new Error("Option apiKey is required");
3087
+ }
3088
+ if (!databaseURL) {
3089
+ throw new Error("Option databaseURL is required");
2022
3090
  }
2023
- return { fetch, databaseURL, apiKey, branch, cache };
2024
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch }) {
3091
+ return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID() };
3092
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
2025
3093
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2026
3094
  if (!branchValue)
2027
3095
  throw new Error("Unable to resolve branch value");
@@ -2031,9 +3099,11 @@ const buildClient = (plugins) => {
2031
3099
  apiUrl: "",
2032
3100
  workspacesApiUrl: (path, params) => {
2033
3101
  const hasBranch = params.dbBranchName ?? params.branch;
2034
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
3102
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
2035
3103
  return databaseURL + newPath;
2036
- }
3104
+ },
3105
+ trace,
3106
+ clientID
2037
3107
  };
2038
3108
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2039
3109
  if (__privateGet(this, _branch))
@@ -2056,6 +3126,88 @@ const buildClient = (plugins) => {
2056
3126
  class BaseClient extends buildClient() {
2057
3127
  }
2058
3128
 
3129
+ const META = "__";
3130
+ const VALUE = "___";
3131
+ class Serializer {
3132
+ constructor() {
3133
+ this.classes = {};
3134
+ }
3135
+ add(clazz) {
3136
+ this.classes[clazz.name] = clazz;
3137
+ }
3138
+ toJSON(data) {
3139
+ function visit(obj) {
3140
+ if (Array.isArray(obj))
3141
+ return obj.map(visit);
3142
+ const type = typeof obj;
3143
+ if (type === "undefined")
3144
+ return { [META]: "undefined" };
3145
+ if (type === "bigint")
3146
+ return { [META]: "bigint", [VALUE]: obj.toString() };
3147
+ if (obj === null || type !== "object")
3148
+ return obj;
3149
+ const constructor = obj.constructor;
3150
+ const o = { [META]: constructor.name };
3151
+ for (const [key, value] of Object.entries(obj)) {
3152
+ o[key] = visit(value);
3153
+ }
3154
+ if (constructor === Date)
3155
+ o[VALUE] = obj.toISOString();
3156
+ if (constructor === Map)
3157
+ o[VALUE] = Object.fromEntries(obj);
3158
+ if (constructor === Set)
3159
+ o[VALUE] = [...obj];
3160
+ return o;
3161
+ }
3162
+ return JSON.stringify(visit(data));
3163
+ }
3164
+ fromJSON(json) {
3165
+ return JSON.parse(json, (key, value) => {
3166
+ if (value && typeof value === "object" && !Array.isArray(value)) {
3167
+ const { [META]: clazz, [VALUE]: val, ...rest } = value;
3168
+ const constructor = this.classes[clazz];
3169
+ if (constructor) {
3170
+ return Object.assign(Object.create(constructor.prototype), rest);
3171
+ }
3172
+ if (clazz === "Date")
3173
+ return new Date(val);
3174
+ if (clazz === "Set")
3175
+ return new Set(val);
3176
+ if (clazz === "Map")
3177
+ return new Map(Object.entries(val));
3178
+ if (clazz === "bigint")
3179
+ return BigInt(val);
3180
+ if (clazz === "undefined")
3181
+ return void 0;
3182
+ return rest;
3183
+ }
3184
+ return value;
3185
+ });
3186
+ }
3187
+ }
3188
+ const defaultSerializer = new Serializer();
3189
+ const serialize = (data) => {
3190
+ return defaultSerializer.toJSON(data);
3191
+ };
3192
+ const deserialize = (json) => {
3193
+ return defaultSerializer.fromJSON(json);
3194
+ };
3195
+
3196
+ function buildWorkerRunner(config) {
3197
+ return function xataWorker(name, _worker) {
3198
+ return async (...args) => {
3199
+ const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
3200
+ const result = await fetch(url, {
3201
+ method: "POST",
3202
+ headers: { "Content-Type": "application/json" },
3203
+ body: serialize({ args })
3204
+ });
3205
+ const text = await result.text();
3206
+ return deserialize(text);
3207
+ };
3208
+ };
3209
+ }
3210
+
2059
3211
  class XataError extends Error {
2060
3212
  constructor(message, status) {
2061
3213
  super(message);
@@ -2063,5 +3215,5 @@ class XataError extends Error {
2063
3215
  }
2064
3216
  }
2065
3217
 
2066
- export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
3218
+ export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, dEPRECATEDcreateDatabase, dEPRECATEDdeleteDatabase, dEPRECATEDgetDatabaseList, dEPRECATEDgetDatabaseMetadata, dEPRECATEDupdateDatabaseMetadata, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
2067
3219
  //# sourceMappingURL=index.mjs.map