@xata.io/client 0.0.0-alpha.vfbbe3c7 → 0.0.0-alpha.vfbe46c7

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
  }
@@ -121,12 +143,14 @@ function getFetchImplementation(userFetch) {
121
143
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
122
144
  const fetchImpl = userFetch ?? globalFetch;
123
145
  if (!fetchImpl) {
124
- throw new Error(`The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`);
146
+ throw new Error(
147
+ `Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
148
+ );
125
149
  }
126
150
  return fetchImpl;
127
151
  }
128
152
 
129
- const VERSION = "0.0.0-alpha.vfbbe3c7";
153
+ const VERSION = "0.0.0-alpha.vfbe46c7";
130
154
 
131
155
  class ErrorWithCause extends Error {
132
156
  constructor(message, options) {
@@ -177,7 +201,10 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
177
201
  }, {});
178
202
  const query = new URLSearchParams(cleanQueryParams).toString();
179
203
  const queryString = query.length > 0 ? `?${query}` : "";
180
- return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
204
+ const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
205
+ return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
206
+ }, {});
207
+ return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
181
208
  };
182
209
  function buildBaseUrl({
183
210
  path,
@@ -185,10 +212,10 @@ function buildBaseUrl({
185
212
  apiUrl,
186
213
  pathParams
187
214
  }) {
188
- if (!pathParams?.workspace)
215
+ if (pathParams?.workspace === void 0)
189
216
  return `${apiUrl}${path}`;
190
217
  const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
191
- return url.replace("{workspaceId}", pathParams.workspace);
218
+ return url.replace("{workspaceId}", String(pathParams.workspace));
192
219
  }
193
220
  function hostHeader(url) {
194
221
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
@@ -205,243 +232,362 @@ async function fetch$1({
205
232
  fetchImpl,
206
233
  apiKey,
207
234
  apiUrl,
208
- workspacesApiUrl
235
+ workspacesApiUrl,
236
+ trace,
237
+ signal
209
238
  }) {
210
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
211
- const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
212
- const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
213
- const response = await fetchImpl(url, {
214
- method: method.toUpperCase(),
215
- body: body ? JSON.stringify(body) : void 0,
216
- headers: {
217
- "Content-Type": "application/json",
218
- "User-Agent": `Xata client-ts/${VERSION}`,
219
- ...headers,
220
- ...hostHeader(fullUrl),
221
- Authorization: `Bearer ${apiKey}`
222
- }
223
- });
224
- if (response.status === 204) {
225
- return {};
226
- }
227
- const requestId = response.headers?.get("x-request-id") ?? void 0;
239
+ return trace(
240
+ `${method.toUpperCase()} ${path}`,
241
+ async ({ setAttributes }) => {
242
+ const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
243
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
244
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
245
+ setAttributes({
246
+ [TraceAttributes.HTTP_URL]: url,
247
+ [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
248
+ });
249
+ const response = await fetchImpl(url, {
250
+ method: method.toUpperCase(),
251
+ body: body ? JSON.stringify(body) : void 0,
252
+ headers: {
253
+ "Content-Type": "application/json",
254
+ "User-Agent": `Xata client-ts/${VERSION}`,
255
+ ...headers,
256
+ ...hostHeader(fullUrl),
257
+ Authorization: `Bearer ${apiKey}`
258
+ },
259
+ signal
260
+ });
261
+ if (response.status === 204) {
262
+ return {};
263
+ }
264
+ const { host, protocol } = parseUrl(response.url);
265
+ const requestId = response.headers?.get("x-request-id") ?? void 0;
266
+ setAttributes({
267
+ [TraceAttributes.KIND]: "http",
268
+ [TraceAttributes.HTTP_REQUEST_ID]: requestId,
269
+ [TraceAttributes.HTTP_STATUS_CODE]: response.status,
270
+ [TraceAttributes.HTTP_HOST]: host,
271
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
272
+ });
273
+ try {
274
+ const jsonResponse = await response.json();
275
+ if (response.ok) {
276
+ return jsonResponse;
277
+ }
278
+ throw new FetcherError(response.status, jsonResponse, requestId);
279
+ } catch (error) {
280
+ throw new FetcherError(response.status, error, requestId);
281
+ }
282
+ },
283
+ { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
284
+ );
285
+ }
286
+ function parseUrl(url) {
228
287
  try {
229
- const jsonResponse = await response.json();
230
- if (response.ok) {
231
- return jsonResponse;
232
- }
233
- throw new FetcherError(response.status, jsonResponse, requestId);
288
+ const { host, protocol } = new URL(url);
289
+ return { host, protocol };
234
290
  } catch (error) {
235
- throw new FetcherError(response.status, error, requestId);
291
+ return {};
236
292
  }
237
293
  }
238
294
 
239
- const getUser = (variables) => fetch$1({ url: "/user", method: "get", ...variables });
240
- const updateUser = (variables) => fetch$1({ url: "/user", method: "put", ...variables });
241
- const deleteUser = (variables) => fetch$1({ url: "/user", method: "delete", ...variables });
242
- const getUserAPIKeys = (variables) => fetch$1({
295
+ const getUser = (variables, signal) => fetch$1({ url: "/user", method: "get", ...variables, signal });
296
+ const updateUser = (variables, signal) => fetch$1({
297
+ url: "/user",
298
+ method: "put",
299
+ ...variables,
300
+ signal
301
+ });
302
+ const deleteUser = (variables, signal) => fetch$1({ url: "/user", method: "delete", ...variables, signal });
303
+ const getUserAPIKeys = (variables, signal) => fetch$1({
243
304
  url: "/user/keys",
244
305
  method: "get",
245
- ...variables
306
+ ...variables,
307
+ signal
246
308
  });
247
- const createUserAPIKey = (variables) => fetch$1({
309
+ const createUserAPIKey = (variables, signal) => fetch$1({
248
310
  url: "/user/keys/{keyName}",
249
311
  method: "post",
250
- ...variables
312
+ ...variables,
313
+ signal
251
314
  });
252
- const deleteUserAPIKey = (variables) => fetch$1({
315
+ const deleteUserAPIKey = (variables, signal) => fetch$1({
253
316
  url: "/user/keys/{keyName}",
254
317
  method: "delete",
255
- ...variables
318
+ ...variables,
319
+ signal
256
320
  });
257
- const createWorkspace = (variables) => fetch$1({
321
+ const createWorkspace = (variables, signal) => fetch$1({
258
322
  url: "/workspaces",
259
323
  method: "post",
260
- ...variables
324
+ ...variables,
325
+ signal
261
326
  });
262
- const getWorkspacesList = (variables) => fetch$1({
327
+ const getWorkspacesList = (variables, signal) => fetch$1({
263
328
  url: "/workspaces",
264
329
  method: "get",
265
- ...variables
330
+ ...variables,
331
+ signal
266
332
  });
267
- const getWorkspace = (variables) => fetch$1({
333
+ const getWorkspace = (variables, signal) => fetch$1({
268
334
  url: "/workspaces/{workspaceId}",
269
335
  method: "get",
270
- ...variables
336
+ ...variables,
337
+ signal
271
338
  });
272
- const updateWorkspace = (variables) => fetch$1({
339
+ const updateWorkspace = (variables, signal) => fetch$1({
273
340
  url: "/workspaces/{workspaceId}",
274
341
  method: "put",
275
- ...variables
342
+ ...variables,
343
+ signal
276
344
  });
277
- const deleteWorkspace = (variables) => fetch$1({
345
+ const deleteWorkspace = (variables, signal) => fetch$1({
278
346
  url: "/workspaces/{workspaceId}",
279
347
  method: "delete",
280
- ...variables
348
+ ...variables,
349
+ signal
281
350
  });
282
- const getWorkspaceMembersList = (variables) => fetch$1({
351
+ const getWorkspaceMembersList = (variables, signal) => fetch$1({
283
352
  url: "/workspaces/{workspaceId}/members",
284
353
  method: "get",
285
- ...variables
354
+ ...variables,
355
+ signal
286
356
  });
287
- const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
288
- const removeWorkspaceMember = (variables) => fetch$1({
357
+ const updateWorkspaceMemberRole = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
358
+ const removeWorkspaceMember = (variables, signal) => fetch$1({
289
359
  url: "/workspaces/{workspaceId}/members/{userId}",
290
360
  method: "delete",
291
- ...variables
361
+ ...variables,
362
+ signal
292
363
  });
293
- const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
294
- const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
295
- const cancelWorkspaceMemberInvite = (variables) => fetch$1({
364
+ const inviteWorkspaceMember = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
365
+ const updateWorkspaceMemberInvite = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
366
+ const cancelWorkspaceMemberInvite = (variables, signal) => fetch$1({
296
367
  url: "/workspaces/{workspaceId}/invites/{inviteId}",
297
368
  method: "delete",
298
- ...variables
369
+ ...variables,
370
+ signal
299
371
  });
300
- const resendWorkspaceMemberInvite = (variables) => fetch$1({
372
+ const resendWorkspaceMemberInvite = (variables, signal) => fetch$1({
301
373
  url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
302
374
  method: "post",
303
- ...variables
375
+ ...variables,
376
+ signal
304
377
  });
305
- const acceptWorkspaceMemberInvite = (variables) => fetch$1({
378
+ const acceptWorkspaceMemberInvite = (variables, signal) => fetch$1({
306
379
  url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
307
380
  method: "post",
308
- ...variables
381
+ ...variables,
382
+ signal
309
383
  });
310
- const getDatabaseList = (variables) => fetch$1({
384
+ const getDatabaseList = (variables, signal) => fetch$1({
311
385
  url: "/dbs",
312
386
  method: "get",
313
- ...variables
387
+ ...variables,
388
+ signal
314
389
  });
315
- const getBranchList = (variables) => fetch$1({
390
+ const getBranchList = (variables, signal) => fetch$1({
316
391
  url: "/dbs/{dbName}",
317
392
  method: "get",
318
- ...variables
393
+ ...variables,
394
+ signal
319
395
  });
320
- const createDatabase = (variables) => fetch$1({
396
+ const createDatabase = (variables, signal) => fetch$1({
321
397
  url: "/dbs/{dbName}",
322
398
  method: "put",
323
- ...variables
399
+ ...variables,
400
+ signal
324
401
  });
325
- const deleteDatabase = (variables) => fetch$1({
402
+ const deleteDatabase = (variables, signal) => fetch$1({
326
403
  url: "/dbs/{dbName}",
327
404
  method: "delete",
328
- ...variables
405
+ ...variables,
406
+ signal
329
407
  });
330
- const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
331
- const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
332
- const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
333
- const resolveBranch = (variables) => fetch$1({
408
+ const getDatabaseMetadata = (variables, signal) => fetch$1({
409
+ url: "/dbs/{dbName}/metadata",
410
+ method: "get",
411
+ ...variables,
412
+ signal
413
+ });
414
+ const updateDatabaseMetadata = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
415
+ const getGitBranchesMapping = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
416
+ const addGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
417
+ const removeGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
418
+ const resolveBranch = (variables, signal) => fetch$1({
334
419
  url: "/dbs/{dbName}/resolveBranch",
335
420
  method: "get",
336
- ...variables
421
+ ...variables,
422
+ signal
337
423
  });
338
- const getBranchDetails = (variables) => fetch$1({
424
+ const queryMigrationRequests = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
425
+ const createMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
426
+ const getMigrationRequest = (variables, signal) => fetch$1({
427
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
428
+ method: "get",
429
+ ...variables,
430
+ signal
431
+ });
432
+ const updateMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
433
+ const listMigrationRequestsCommits = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
434
+ const compareMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
435
+ const getMigrationRequestIsMerged = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
436
+ const mergeMigrationRequest = (variables, signal) => fetch$1({
437
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
438
+ method: "post",
439
+ ...variables,
440
+ signal
441
+ });
442
+ const getBranchDetails = (variables, signal) => fetch$1({
339
443
  url: "/db/{dbBranchName}",
340
444
  method: "get",
341
- ...variables
445
+ ...variables,
446
+ signal
342
447
  });
343
- const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
344
- const deleteBranch = (variables) => fetch$1({
448
+ const createBranch = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
449
+ const deleteBranch = (variables, signal) => fetch$1({
345
450
  url: "/db/{dbBranchName}",
346
451
  method: "delete",
347
- ...variables
452
+ ...variables,
453
+ signal
348
454
  });
349
- const updateBranchMetadata = (variables) => fetch$1({
455
+ const updateBranchMetadata = (variables, signal) => fetch$1({
350
456
  url: "/db/{dbBranchName}/metadata",
351
457
  method: "put",
352
- ...variables
458
+ ...variables,
459
+ signal
353
460
  });
354
- const getBranchMetadata = (variables) => fetch$1({
461
+ const getBranchMetadata = (variables, signal) => fetch$1({
355
462
  url: "/db/{dbBranchName}/metadata",
356
463
  method: "get",
357
- ...variables
464
+ ...variables,
465
+ signal
358
466
  });
359
- const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
360
- const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
361
- const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
362
- const getBranchStats = (variables) => fetch$1({
467
+ const getBranchMigrationHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
468
+ const executeBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
469
+ const getBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
470
+ const compareBranchWithUserSchema = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
471
+ const compareBranchSchemas = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
472
+ const updateBranchSchema = (variables, signal) => fetch$1({
473
+ url: "/db/{dbBranchName}/schema/update",
474
+ method: "post",
475
+ ...variables,
476
+ signal
477
+ });
478
+ const previewBranchSchemaEdit = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
479
+ const applyBranchSchemaEdit = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
480
+ const getBranchSchemaHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
481
+ const getBranchStats = (variables, signal) => fetch$1({
363
482
  url: "/db/{dbBranchName}/stats",
364
483
  method: "get",
365
- ...variables
484
+ ...variables,
485
+ signal
366
486
  });
367
- const createTable = (variables) => fetch$1({
487
+ const createTable = (variables, signal) => fetch$1({
368
488
  url: "/db/{dbBranchName}/tables/{tableName}",
369
489
  method: "put",
370
- ...variables
490
+ ...variables,
491
+ signal
371
492
  });
372
- const deleteTable = (variables) => fetch$1({
493
+ const deleteTable = (variables, signal) => fetch$1({
373
494
  url: "/db/{dbBranchName}/tables/{tableName}",
374
495
  method: "delete",
375
- ...variables
496
+ ...variables,
497
+ signal
376
498
  });
377
- const updateTable = (variables) => fetch$1({
499
+ const updateTable = (variables, signal) => fetch$1({
378
500
  url: "/db/{dbBranchName}/tables/{tableName}",
379
501
  method: "patch",
380
- ...variables
502
+ ...variables,
503
+ signal
381
504
  });
382
- const getTableSchema = (variables) => fetch$1({
505
+ const getTableSchema = (variables, signal) => fetch$1({
383
506
  url: "/db/{dbBranchName}/tables/{tableName}/schema",
384
507
  method: "get",
385
- ...variables
508
+ ...variables,
509
+ signal
386
510
  });
387
- const setTableSchema = (variables) => fetch$1({
511
+ const setTableSchema = (variables, signal) => fetch$1({
388
512
  url: "/db/{dbBranchName}/tables/{tableName}/schema",
389
513
  method: "put",
390
- ...variables
514
+ ...variables,
515
+ signal
391
516
  });
392
- const getTableColumns = (variables) => fetch$1({
517
+ const getTableColumns = (variables, signal) => fetch$1({
393
518
  url: "/db/{dbBranchName}/tables/{tableName}/columns",
394
519
  method: "get",
395
- ...variables
520
+ ...variables,
521
+ signal
396
522
  });
397
- const addTableColumn = (variables) => fetch$1({
523
+ const addTableColumn = (variables, signal) => fetch$1({
398
524
  url: "/db/{dbBranchName}/tables/{tableName}/columns",
399
525
  method: "post",
400
- ...variables
526
+ ...variables,
527
+ signal
401
528
  });
402
- const getColumn = (variables) => fetch$1({
529
+ const getColumn = (variables, signal) => fetch$1({
403
530
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
404
531
  method: "get",
405
- ...variables
532
+ ...variables,
533
+ signal
406
534
  });
407
- const deleteColumn = (variables) => fetch$1({
535
+ const deleteColumn = (variables, signal) => fetch$1({
408
536
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
409
537
  method: "delete",
410
- ...variables
538
+ ...variables,
539
+ signal
411
540
  });
412
- const updateColumn = (variables) => fetch$1({
541
+ const updateColumn = (variables, signal) => fetch$1({
413
542
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
414
543
  method: "patch",
415
- ...variables
544
+ ...variables,
545
+ signal
416
546
  });
417
- const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
418
- const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
419
- const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
420
- const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
421
- const deleteRecord = (variables) => fetch$1({
547
+ const insertRecord = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
548
+ const insertRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
549
+ const updateRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
550
+ const upsertRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
551
+ const deleteRecord = (variables, signal) => fetch$1({
422
552
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
423
553
  method: "delete",
424
- ...variables
554
+ ...variables,
555
+ signal
425
556
  });
426
- const getRecord = (variables) => fetch$1({
557
+ const getRecord = (variables, signal) => fetch$1({
427
558
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
428
559
  method: "get",
429
- ...variables
560
+ ...variables,
561
+ signal
430
562
  });
431
- const bulkInsertTableRecords = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables });
432
- const queryTable = (variables) => fetch$1({
563
+ const bulkInsertTableRecords = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
564
+ const queryTable = (variables, signal) => fetch$1({
433
565
  url: "/db/{dbBranchName}/tables/{tableName}/query",
434
566
  method: "post",
435
- ...variables
567
+ ...variables,
568
+ signal
436
569
  });
437
- const searchTable = (variables) => fetch$1({
570
+ const searchTable = (variables, signal) => fetch$1({
438
571
  url: "/db/{dbBranchName}/tables/{tableName}/search",
439
572
  method: "post",
440
- ...variables
573
+ ...variables,
574
+ signal
441
575
  });
442
- const searchBranch = (variables) => fetch$1({
576
+ const searchBranch = (variables, signal) => fetch$1({
443
577
  url: "/db/{dbBranchName}/search",
444
578
  method: "post",
579
+ ...variables,
580
+ signal
581
+ });
582
+ const summarizeTable = (variables, signal) => fetch$1({
583
+ url: "/db/{dbBranchName}/tables/{tableName}/summarize",
584
+ method: "post",
585
+ ...variables,
586
+ signal
587
+ });
588
+ const aggregateTable = (variables) => fetch$1({
589
+ url: "/db/{dbBranchName}/tables/{tableName}/aggregate",
590
+ method: "post",
445
591
  ...variables
446
592
  });
447
593
  const operationsByTag = {
@@ -465,6 +611,8 @@ const operationsByTag = {
465
611
  getDatabaseList,
466
612
  createDatabase,
467
613
  deleteDatabase,
614
+ getDatabaseMetadata,
615
+ updateDatabaseMetadata,
468
616
  getGitBranchesMapping,
469
617
  addGitBranchesEntry,
470
618
  removeGitBranchesEntry,
@@ -477,10 +625,28 @@ const operationsByTag = {
477
625
  deleteBranch,
478
626
  updateBranchMetadata,
479
627
  getBranchMetadata,
628
+ getBranchStats
629
+ },
630
+ migrationRequests: {
631
+ queryMigrationRequests,
632
+ createMigrationRequest,
633
+ getMigrationRequest,
634
+ updateMigrationRequest,
635
+ listMigrationRequestsCommits,
636
+ compareMigrationRequest,
637
+ getMigrationRequestIsMerged,
638
+ mergeMigrationRequest
639
+ },
640
+ branchSchema: {
480
641
  getBranchMigrationHistory,
481
642
  executeBranchMigrationPlan,
482
643
  getBranchMigrationPlan,
483
- getBranchStats
644
+ compareBranchWithUserSchema,
645
+ compareBranchSchemas,
646
+ updateBranchSchema,
647
+ previewBranchSchemaEdit,
648
+ applyBranchSchemaEdit,
649
+ getBranchSchemaHistory
484
650
  },
485
651
  table: {
486
652
  createTable,
@@ -504,14 +670,16 @@ const operationsByTag = {
504
670
  bulkInsertTableRecords,
505
671
  queryTable,
506
672
  searchTable,
507
- searchBranch
673
+ searchBranch,
674
+ summarizeTable,
675
+ aggregateTable
508
676
  }
509
677
  };
510
678
 
511
679
  function getHostUrl(provider, type) {
512
- if (isValidAlias(provider)) {
680
+ if (isHostProviderAlias(provider)) {
513
681
  return providers[provider][type];
514
- } else if (isValidBuilder(provider)) {
682
+ } else if (isHostProviderBuilder(provider)) {
515
683
  return provider[type];
516
684
  }
517
685
  throw new Error("Invalid API provider");
@@ -526,12 +694,21 @@ const providers = {
526
694
  workspaces: "https://{workspaceId}.staging.xatabase.co"
527
695
  }
528
696
  };
529
- function isValidAlias(alias) {
697
+ function isHostProviderAlias(alias) {
530
698
  return isString(alias) && Object.keys(providers).includes(alias);
531
699
  }
532
- function isValidBuilder(builder) {
700
+ function isHostProviderBuilder(builder) {
533
701
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
534
702
  }
703
+ function parseProviderString(provider = "production") {
704
+ if (isHostProviderAlias(provider)) {
705
+ return provider;
706
+ }
707
+ const [main, workspaces] = provider.split(",");
708
+ if (!main || !workspaces)
709
+ return null;
710
+ return { main, workspaces };
711
+ }
535
712
 
536
713
  var __accessCheck$7 = (obj, member, msg) => {
537
714
  if (!member.has(obj))
@@ -557,7 +734,8 @@ class XataApiClient {
557
734
  __privateAdd$7(this, _extraProps, void 0);
558
735
  __privateAdd$7(this, _namespaces, {});
559
736
  const provider = options.host ?? "production";
560
- const apiKey = options?.apiKey ?? getAPIKey();
737
+ const apiKey = options.apiKey ?? getAPIKey();
738
+ const trace = options.trace ?? defaultTrace;
561
739
  if (!apiKey) {
562
740
  throw new Error("Could not resolve a valid apiKey");
563
741
  }
@@ -565,7 +743,8 @@ class XataApiClient {
565
743
  apiUrl: getHostUrl(provider, "main"),
566
744
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
567
745
  fetchImpl: getFetchImplementation(options.fetch),
568
- apiKey
746
+ apiKey,
747
+ trace
569
748
  });
570
749
  }
571
750
  get user() {
@@ -598,6 +777,16 @@ class XataApiClient {
598
777
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
599
778
  return __privateGet$7(this, _namespaces).records;
600
779
  }
780
+ get migrationRequests() {
781
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
782
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
783
+ return __privateGet$7(this, _namespaces).migrationRequests;
784
+ }
785
+ get branchSchema() {
786
+ if (!__privateGet$7(this, _namespaces).branchSchema)
787
+ __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
788
+ return __privateGet$7(this, _namespaces).branchSchema;
789
+ }
601
790
  }
602
791
  _extraProps = new WeakMap();
603
792
  _namespaces = new WeakMap();
@@ -737,6 +926,19 @@ class DatabaseApi {
737
926
  ...this.extraProps
738
927
  });
739
928
  }
929
+ getDatabaseMetadata(workspace, dbName) {
930
+ return operationsByTag.database.getDatabaseMetadata({
931
+ pathParams: { workspace, dbName },
932
+ ...this.extraProps
933
+ });
934
+ }
935
+ updateDatabaseMetadata(workspace, dbName, options = {}) {
936
+ return operationsByTag.database.updateDatabaseMetadata({
937
+ pathParams: { workspace, dbName },
938
+ body: options,
939
+ ...this.extraProps
940
+ });
941
+ }
740
942
  getGitBranchesMapping(workspace, dbName) {
741
943
  return operationsByTag.database.getGitBranchesMapping({
742
944
  pathParams: { workspace, dbName },
@@ -808,27 +1010,6 @@ class BranchApi {
808
1010
  ...this.extraProps
809
1011
  });
810
1012
  }
811
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
812
- return operationsByTag.branch.getBranchMigrationHistory({
813
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
814
- body: options,
815
- ...this.extraProps
816
- });
817
- }
818
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
819
- return operationsByTag.branch.executeBranchMigrationPlan({
820
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
821
- body: migrationPlan,
822
- ...this.extraProps
823
- });
824
- }
825
- getBranchMigrationPlan(workspace, database, branch, schema) {
826
- return operationsByTag.branch.getBranchMigrationPlan({
827
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
828
- body: schema,
829
- ...this.extraProps
830
- });
831
- }
832
1013
  getBranchStats(workspace, database, branch) {
833
1014
  return operationsByTag.branch.getBranchStats({
834
1015
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
@@ -984,6 +1165,145 @@ class RecordsApi {
984
1165
  ...this.extraProps
985
1166
  });
986
1167
  }
1168
+ summarizeTable(workspace, database, branch, tableName, query) {
1169
+ return operationsByTag.records.summarizeTable({
1170
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1171
+ body: query,
1172
+ ...this.extraProps
1173
+ });
1174
+ }
1175
+ aggregateTable(workspace, database, branch, tableName, query) {
1176
+ return operationsByTag.records.aggregateTable({
1177
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1178
+ body: query,
1179
+ ...this.extraProps
1180
+ });
1181
+ }
1182
+ }
1183
+ class MigrationRequestsApi {
1184
+ constructor(extraProps) {
1185
+ this.extraProps = extraProps;
1186
+ }
1187
+ queryMigrationRequests(workspace, database, options = {}) {
1188
+ return operationsByTag.migrationRequests.queryMigrationRequests({
1189
+ pathParams: { workspace, dbName: database },
1190
+ body: options,
1191
+ ...this.extraProps
1192
+ });
1193
+ }
1194
+ createMigrationRequest(workspace, database, options) {
1195
+ return operationsByTag.migrationRequests.createMigrationRequest({
1196
+ pathParams: { workspace, dbName: database },
1197
+ body: options,
1198
+ ...this.extraProps
1199
+ });
1200
+ }
1201
+ getMigrationRequest(workspace, database, migrationRequest) {
1202
+ return operationsByTag.migrationRequests.getMigrationRequest({
1203
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1204
+ ...this.extraProps
1205
+ });
1206
+ }
1207
+ updateMigrationRequest(workspace, database, migrationRequest, options) {
1208
+ return operationsByTag.migrationRequests.updateMigrationRequest({
1209
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1210
+ body: options,
1211
+ ...this.extraProps
1212
+ });
1213
+ }
1214
+ listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1215
+ return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1216
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1217
+ body: options,
1218
+ ...this.extraProps
1219
+ });
1220
+ }
1221
+ compareMigrationRequest(workspace, database, migrationRequest) {
1222
+ return operationsByTag.migrationRequests.compareMigrationRequest({
1223
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1224
+ ...this.extraProps
1225
+ });
1226
+ }
1227
+ getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1228
+ return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1229
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1230
+ ...this.extraProps
1231
+ });
1232
+ }
1233
+ mergeMigrationRequest(workspace, database, migrationRequest) {
1234
+ return operationsByTag.migrationRequests.mergeMigrationRequest({
1235
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1236
+ ...this.extraProps
1237
+ });
1238
+ }
1239
+ }
1240
+ class BranchSchemaApi {
1241
+ constructor(extraProps) {
1242
+ this.extraProps = extraProps;
1243
+ }
1244
+ getBranchMigrationHistory(workspace, database, branch, options = {}) {
1245
+ return operationsByTag.branchSchema.getBranchMigrationHistory({
1246
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1247
+ body: options,
1248
+ ...this.extraProps
1249
+ });
1250
+ }
1251
+ executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1252
+ return operationsByTag.branchSchema.executeBranchMigrationPlan({
1253
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1254
+ body: migrationPlan,
1255
+ ...this.extraProps
1256
+ });
1257
+ }
1258
+ getBranchMigrationPlan(workspace, database, branch, schema) {
1259
+ return operationsByTag.branchSchema.getBranchMigrationPlan({
1260
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1261
+ body: schema,
1262
+ ...this.extraProps
1263
+ });
1264
+ }
1265
+ compareBranchWithUserSchema(workspace, database, branch, schema) {
1266
+ return operationsByTag.branchSchema.compareBranchWithUserSchema({
1267
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1268
+ body: { schema },
1269
+ ...this.extraProps
1270
+ });
1271
+ }
1272
+ compareBranchSchemas(workspace, database, branch, branchName, schema) {
1273
+ return operationsByTag.branchSchema.compareBranchSchemas({
1274
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1275
+ body: { schema },
1276
+ ...this.extraProps
1277
+ });
1278
+ }
1279
+ updateBranchSchema(workspace, database, branch, migration) {
1280
+ return operationsByTag.branchSchema.updateBranchSchema({
1281
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1282
+ body: migration,
1283
+ ...this.extraProps
1284
+ });
1285
+ }
1286
+ previewBranchSchemaEdit(workspace, database, branch, migration) {
1287
+ return operationsByTag.branchSchema.previewBranchSchemaEdit({
1288
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1289
+ body: migration,
1290
+ ...this.extraProps
1291
+ });
1292
+ }
1293
+ applyBranchSchemaEdit(workspace, database, branch, edits) {
1294
+ return operationsByTag.branchSchema.applyBranchSchemaEdit({
1295
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1296
+ body: { edits },
1297
+ ...this.extraProps
1298
+ });
1299
+ }
1300
+ getBranchSchemaHistory(workspace, database, branch, options = {}) {
1301
+ return operationsByTag.branchSchema.getBranchSchemaHistory({
1302
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1303
+ body: options,
1304
+ ...this.extraProps
1305
+ });
1306
+ }
987
1307
  }
988
1308
 
989
1309
  class XataApiPlugin {
@@ -1109,9 +1429,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
1109
1429
  setter ? setter.call(obj, value) : member.set(obj, value);
1110
1430
  return value;
1111
1431
  };
1112
- var _table$1, _repository, _data;
1432
+ var __privateMethod$3 = (obj, member, method) => {
1433
+ __accessCheck$5(obj, member, "access private method");
1434
+ return method;
1435
+ };
1436
+ var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
1113
1437
  const _Query = class {
1114
1438
  constructor(repository, table, data, rawParent) {
1439
+ __privateAdd$5(this, _cleanFilterConstraint);
1115
1440
  __privateAdd$5(this, _table$1, void 0);
1116
1441
  __privateAdd$5(this, _repository, void 0);
1117
1442
  __privateAdd$5(this, _data, { filter: {} });
@@ -1168,21 +1493,29 @@ const _Query = class {
1168
1493
  }
1169
1494
  filter(a, b) {
1170
1495
  if (arguments.length === 1) {
1171
- const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
1496
+ const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
1497
+ [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
1498
+ }));
1172
1499
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1173
1500
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1174
1501
  } else {
1175
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
1502
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
1503
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1176
1504
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1177
1505
  }
1178
1506
  }
1179
- sort(column, direction) {
1507
+ sort(column, direction = "asc") {
1180
1508
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1181
1509
  const sort = [...originalSort, { column, direction }];
1182
1510
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
1183
1511
  }
1184
1512
  select(columns) {
1185
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { columns }, __privateGet$5(this, _data));
1513
+ return new _Query(
1514
+ __privateGet$5(this, _repository),
1515
+ __privateGet$5(this, _table$1),
1516
+ { columns },
1517
+ __privateGet$5(this, _data)
1518
+ );
1186
1519
  }
1187
1520
  getPaginated(options = {}) {
1188
1521
  const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
@@ -1205,11 +1538,20 @@ const _Query = class {
1205
1538
  }
1206
1539
  }
1207
1540
  async getMany(options = {}) {
1208
- const page = await this.getPaginated(options);
1541
+ const { pagination = {}, ...rest } = options;
1542
+ const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
1543
+ const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
1544
+ let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
1545
+ const results = [...page.records];
1546
+ while (page.hasNextPage() && results.length < size) {
1547
+ page = await page.nextPage();
1548
+ results.push(...page.records);
1549
+ }
1209
1550
  if (page.hasNextPage() && options.pagination?.size === void 0) {
1210
1551
  console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
1211
1552
  }
1212
- return page.records;
1553
+ const array = new RecordArray(page, results.slice(0, size));
1554
+ return array;
1213
1555
  }
1214
1556
  async getAll(options = {}) {
1215
1557
  const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
@@ -1223,6 +1565,12 @@ const _Query = class {
1223
1565
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
1224
1566
  return records[0] ?? null;
1225
1567
  }
1568
+ async getFirstOrThrow(options = {}) {
1569
+ const records = await this.getMany({ ...options, pagination: { size: 1 } });
1570
+ if (records[0] === void 0)
1571
+ throw new Error("No results found.");
1572
+ return records[0];
1573
+ }
1226
1574
  cache(ttl) {
1227
1575
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1228
1576
  }
@@ -1246,6 +1594,17 @@ let Query = _Query;
1246
1594
  _table$1 = new WeakMap();
1247
1595
  _repository = new WeakMap();
1248
1596
  _data = new WeakMap();
1597
+ _cleanFilterConstraint = new WeakSet();
1598
+ cleanFilterConstraint_fn = function(column, value) {
1599
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
1600
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
1601
+ return { $includes: value };
1602
+ }
1603
+ if (columnType === "link" && isObject(value) && isString(value.id)) {
1604
+ return value.id;
1605
+ }
1606
+ return value;
1607
+ };
1249
1608
  function cleanParent(data, parent) {
1250
1609
  if (isCursorPaginationOptions(data.pagination)) {
1251
1610
  return { ...parent, sorting: void 0, filter: void 0 };
@@ -1307,12 +1666,16 @@ var __privateMethod$2 = (obj, member, method) => {
1307
1666
  __accessCheck$4(obj, member, "access private method");
1308
1667
  return method;
1309
1668
  };
1310
- var _table, _getFetchProps, _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;
1669
+ 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;
1311
1670
  class Repository extends Query {
1312
1671
  }
1313
1672
  class RestRepository extends Query {
1314
1673
  constructor(options) {
1315
- super(null, options.table, {});
1674
+ super(
1675
+ null,
1676
+ { name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
1677
+ {}
1678
+ );
1316
1679
  __privateAdd$4(this, _insertRecordWithoutId);
1317
1680
  __privateAdd$4(this, _insertRecordWithId);
1318
1681
  __privateAdd$4(this, _bulkInsertTableRecords);
@@ -1324,176 +1687,274 @@ class RestRepository extends Query {
1324
1687
  __privateAdd$4(this, _getSchemaTables$1);
1325
1688
  __privateAdd$4(this, _table, void 0);
1326
1689
  __privateAdd$4(this, _getFetchProps, void 0);
1690
+ __privateAdd$4(this, _db, void 0);
1327
1691
  __privateAdd$4(this, _cache, void 0);
1328
1692
  __privateAdd$4(this, _schemaTables$2, void 0);
1693
+ __privateAdd$4(this, _trace, void 0);
1329
1694
  __privateSet$4(this, _table, options.table);
1330
1695
  __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1331
- this.db = options.db;
1696
+ __privateSet$4(this, _db, options.db);
1332
1697
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1333
1698
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
1699
+ const trace = options.pluginOptions.trace ?? defaultTrace;
1700
+ __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
1701
+ return trace(name, fn, {
1702
+ ...options2,
1703
+ [TraceAttributes.TABLE]: __privateGet$4(this, _table),
1704
+ [TraceAttributes.KIND]: "sdk-operation",
1705
+ [TraceAttributes.VERSION]: VERSION
1706
+ });
1707
+ });
1334
1708
  }
1335
1709
  async create(a, b, c) {
1336
- if (Array.isArray(a)) {
1337
- if (a.length === 0)
1338
- return [];
1339
- const columns = isStringArray(b) ? b : void 0;
1340
- return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
1341
- }
1342
- if (isString(a) && isObject(b)) {
1343
- if (a === "")
1344
- throw new Error("The id can't be empty");
1345
- const columns = isStringArray(c) ? c : void 0;
1346
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
1347
- }
1348
- if (isObject(a) && isString(a.id)) {
1349
- if (a.id === "")
1350
- throw new Error("The id can't be empty");
1351
- const columns = isStringArray(b) ? b : void 0;
1352
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1353
- }
1354
- if (isObject(a)) {
1355
- const columns = isStringArray(b) ? b : void 0;
1356
- return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
1357
- }
1358
- throw new Error("Invalid arguments for create method");
1710
+ return __privateGet$4(this, _trace).call(this, "create", async () => {
1711
+ if (Array.isArray(a)) {
1712
+ if (a.length === 0)
1713
+ return [];
1714
+ const columns = isStringArray(b) ? b : void 0;
1715
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
1716
+ }
1717
+ if (isString(a) && isObject(b)) {
1718
+ if (a === "")
1719
+ throw new Error("The id can't be empty");
1720
+ const columns = isStringArray(c) ? c : void 0;
1721
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
1722
+ }
1723
+ if (isObject(a) && isString(a.id)) {
1724
+ if (a.id === "")
1725
+ throw new Error("The id can't be empty");
1726
+ const columns = isStringArray(b) ? b : void 0;
1727
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1728
+ }
1729
+ if (isObject(a)) {
1730
+ const columns = isStringArray(b) ? b : void 0;
1731
+ return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
1732
+ }
1733
+ throw new Error("Invalid arguments for create method");
1734
+ });
1359
1735
  }
1360
1736
  async read(a, b) {
1361
- const columns = isStringArray(b) ? b : ["*"];
1362
- if (Array.isArray(a)) {
1363
- if (a.length === 0)
1364
- return [];
1365
- const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
1366
- const finalObjects = await this.getAll({ filter: { id: { $any: ids } }, columns });
1367
- const dictionary = finalObjects.reduce((acc, object) => {
1368
- acc[object.id] = object;
1369
- return acc;
1370
- }, {});
1371
- return ids.map((id2) => dictionary[id2] ?? null);
1372
- }
1373
- const id = isString(a) ? a : a.id;
1374
- if (isString(id)) {
1375
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1376
- try {
1377
- const response = await getRecord({
1378
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: id },
1379
- queryParams: { columns },
1380
- ...fetchProps
1381
- });
1382
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1383
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1384
- } catch (e) {
1385
- if (isObject(e) && e.status === 404) {
1386
- return null;
1737
+ return __privateGet$4(this, _trace).call(this, "read", async () => {
1738
+ const columns = isStringArray(b) ? b : ["*"];
1739
+ if (Array.isArray(a)) {
1740
+ if (a.length === 0)
1741
+ return [];
1742
+ const ids = a.map((item) => extractId(item));
1743
+ const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
1744
+ const dictionary = finalObjects.reduce((acc, object) => {
1745
+ acc[object.id] = object;
1746
+ return acc;
1747
+ }, {});
1748
+ return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
1749
+ }
1750
+ const id = extractId(a);
1751
+ if (id) {
1752
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1753
+ try {
1754
+ const response = await getRecord({
1755
+ pathParams: {
1756
+ workspace: "{workspaceId}",
1757
+ dbBranchName: "{dbBranch}",
1758
+ tableName: __privateGet$4(this, _table),
1759
+ recordId: id
1760
+ },
1761
+ queryParams: { columns },
1762
+ ...fetchProps
1763
+ });
1764
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1765
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1766
+ } catch (e) {
1767
+ if (isObject(e) && e.status === 404) {
1768
+ return null;
1769
+ }
1770
+ throw e;
1387
1771
  }
1388
- throw e;
1389
1772
  }
1390
- }
1391
- return null;
1773
+ return null;
1774
+ });
1775
+ }
1776
+ async readOrThrow(a, b) {
1777
+ return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
1778
+ const result = await this.read(a, b);
1779
+ if (Array.isArray(result)) {
1780
+ const missingIds = compact(
1781
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1782
+ );
1783
+ if (missingIds.length > 0) {
1784
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1785
+ }
1786
+ return result;
1787
+ }
1788
+ if (result === null) {
1789
+ const id = extractId(a) ?? "unknown";
1790
+ throw new Error(`Record with id ${id} not found`);
1791
+ }
1792
+ return result;
1793
+ });
1392
1794
  }
1393
1795
  async update(a, b, c) {
1394
- if (Array.isArray(a)) {
1395
- if (a.length === 0)
1396
- return [];
1397
- if (a.length > 100) {
1398
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1796
+ return __privateGet$4(this, _trace).call(this, "update", async () => {
1797
+ if (Array.isArray(a)) {
1798
+ if (a.length === 0)
1799
+ return [];
1800
+ if (a.length > 100) {
1801
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1802
+ }
1803
+ const columns = isStringArray(b) ? b : ["*"];
1804
+ return Promise.all(a.map((object) => this.update(object, columns)));
1399
1805
  }
1400
- const columns = isStringArray(b) ? b : ["*"];
1401
- return Promise.all(a.map((object) => this.update(object, columns)));
1402
- }
1403
- if (isString(a) && isObject(b)) {
1404
- const columns = isStringArray(c) ? c : void 0;
1405
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
1406
- }
1407
- if (isObject(a) && isString(a.id)) {
1408
- const columns = isStringArray(b) ? b : void 0;
1409
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1410
- }
1411
- throw new Error("Invalid arguments for update method");
1806
+ if (isString(a) && isObject(b)) {
1807
+ const columns = isStringArray(c) ? c : void 0;
1808
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
1809
+ }
1810
+ if (isObject(a) && isString(a.id)) {
1811
+ const columns = isStringArray(b) ? b : void 0;
1812
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1813
+ }
1814
+ throw new Error("Invalid arguments for update method");
1815
+ });
1816
+ }
1817
+ async updateOrThrow(a, b, c) {
1818
+ return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1819
+ const result = await this.update(a, b, c);
1820
+ if (Array.isArray(result)) {
1821
+ const missingIds = compact(
1822
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1823
+ );
1824
+ if (missingIds.length > 0) {
1825
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1826
+ }
1827
+ return result;
1828
+ }
1829
+ if (result === null) {
1830
+ const id = extractId(a) ?? "unknown";
1831
+ throw new Error(`Record with id ${id} not found`);
1832
+ }
1833
+ return result;
1834
+ });
1412
1835
  }
1413
1836
  async createOrUpdate(a, b, c) {
1414
- if (Array.isArray(a)) {
1415
- if (a.length === 0)
1416
- return [];
1417
- if (a.length > 100) {
1418
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1837
+ return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
1838
+ if (Array.isArray(a)) {
1839
+ if (a.length === 0)
1840
+ return [];
1841
+ if (a.length > 100) {
1842
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1843
+ }
1844
+ const columns = isStringArray(b) ? b : ["*"];
1845
+ return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
1419
1846
  }
1420
- const columns = isStringArray(b) ? b : ["*"];
1421
- return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
1422
- }
1423
- if (isString(a) && isObject(b)) {
1424
- const columns = isStringArray(c) ? c : void 0;
1425
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
1426
- }
1427
- if (isObject(a) && isString(a.id)) {
1428
- const columns = isStringArray(c) ? c : void 0;
1429
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1430
- }
1431
- throw new Error("Invalid arguments for createOrUpdate method");
1432
- }
1433
- async delete(a) {
1434
- if (Array.isArray(a)) {
1435
- if (a.length === 0)
1436
- return;
1437
- if (a.length > 100) {
1438
- console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1847
+ if (isString(a) && isObject(b)) {
1848
+ const columns = isStringArray(c) ? c : void 0;
1849
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
1439
1850
  }
1440
- await Promise.all(a.map((id) => this.delete(id)));
1441
- return;
1442
- }
1443
- if (isString(a)) {
1444
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
1445
- return;
1446
- }
1447
- if (isObject(a) && isString(a.id)) {
1448
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
1449
- return;
1450
- }
1451
- throw new Error("Invalid arguments for delete method");
1851
+ if (isObject(a) && isString(a.id)) {
1852
+ const columns = isStringArray(c) ? c : void 0;
1853
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1854
+ }
1855
+ throw new Error("Invalid arguments for createOrUpdate method");
1856
+ });
1857
+ }
1858
+ async delete(a, b) {
1859
+ return __privateGet$4(this, _trace).call(this, "delete", async () => {
1860
+ if (Array.isArray(a)) {
1861
+ if (a.length === 0)
1862
+ return [];
1863
+ if (a.length > 100) {
1864
+ console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1865
+ }
1866
+ return Promise.all(a.map((id) => this.delete(id, b)));
1867
+ }
1868
+ if (isString(a)) {
1869
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
1870
+ }
1871
+ if (isObject(a) && isString(a.id)) {
1872
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
1873
+ }
1874
+ throw new Error("Invalid arguments for delete method");
1875
+ });
1876
+ }
1877
+ async deleteOrThrow(a, b) {
1878
+ return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
1879
+ const result = await this.delete(a, b);
1880
+ if (Array.isArray(result)) {
1881
+ const missingIds = compact(
1882
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1883
+ );
1884
+ if (missingIds.length > 0) {
1885
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1886
+ }
1887
+ return result;
1888
+ } else if (result === null) {
1889
+ const id = extractId(a) ?? "unknown";
1890
+ throw new Error(`Record with id ${id} not found`);
1891
+ }
1892
+ return result;
1893
+ });
1452
1894
  }
1453
1895
  async search(query, options = {}) {
1454
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1455
- const { records } = await searchTable({
1456
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1457
- body: {
1458
- query,
1459
- fuzziness: options.fuzziness,
1460
- prefix: options.prefix,
1461
- highlight: options.highlight,
1462
- filter: options.filter,
1463
- boosters: options.boosters
1464
- },
1465
- ...fetchProps
1896
+ return __privateGet$4(this, _trace).call(this, "search", async () => {
1897
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1898
+ const { records } = await searchTable({
1899
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1900
+ body: {
1901
+ query,
1902
+ fuzziness: options.fuzziness,
1903
+ prefix: options.prefix,
1904
+ highlight: options.highlight,
1905
+ filter: options.filter,
1906
+ boosters: options.boosters
1907
+ },
1908
+ ...fetchProps
1909
+ });
1910
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1911
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
1912
+ });
1913
+ }
1914
+ async aggregate(aggs, filter) {
1915
+ return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
1916
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1917
+ const result = await aggregateTable({
1918
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1919
+ body: { aggs, filter },
1920
+ ...fetchProps
1921
+ });
1922
+ return result;
1466
1923
  });
1467
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1468
- return records.map((item) => initObject(this.db, schemaTables, __privateGet$4(this, _table), item));
1469
1924
  }
1470
1925
  async query(query) {
1471
- const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1472
- if (cacheQuery)
1473
- return new Page(query, cacheQuery.meta, cacheQuery.records);
1474
- const data = query.getQueryOptions();
1475
- const body = {
1476
- filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1477
- sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1478
- page: data.pagination,
1479
- columns: data.columns
1480
- };
1481
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1482
- const { meta, records: objects } = await queryTable({
1483
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1484
- body,
1485
- ...fetchProps
1926
+ return __privateGet$4(this, _trace).call(this, "query", async () => {
1927
+ const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1928
+ if (cacheQuery)
1929
+ return new Page(query, cacheQuery.meta, cacheQuery.records);
1930
+ const data = query.getQueryOptions();
1931
+ const body = {
1932
+ filter: cleanFilter(data.filter),
1933
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1934
+ page: data.pagination,
1935
+ columns: data.columns
1936
+ };
1937
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1938
+ const { meta, records: objects } = await queryTable({
1939
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1940
+ body,
1941
+ ...fetchProps
1942
+ });
1943
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1944
+ const records = objects.map(
1945
+ (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
1946
+ );
1947
+ await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1948
+ return new Page(query, meta, records);
1486
1949
  });
1487
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1488
- const records = objects.map((record) => initObject(this.db, schemaTables, __privateGet$4(this, _table), record));
1489
- await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1490
- return new Page(query, meta, records);
1491
1950
  }
1492
1951
  }
1493
1952
  _table = new WeakMap();
1494
1953
  _getFetchProps = new WeakMap();
1954
+ _db = new WeakMap();
1495
1955
  _cache = new WeakMap();
1496
1956
  _schemaTables$2 = new WeakMap();
1957
+ _trace = new WeakMap();
1497
1958
  _insertRecordWithoutId = new WeakSet();
1498
1959
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1499
1960
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
@@ -1509,7 +1970,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1509
1970
  ...fetchProps
1510
1971
  });
1511
1972
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1512
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1973
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1513
1974
  };
1514
1975
  _insertRecordWithId = new WeakSet();
1515
1976
  insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
@@ -1527,7 +1988,7 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
1527
1988
  ...fetchProps
1528
1989
  });
1529
1990
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1530
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1991
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1531
1992
  };
1532
1993
  _bulkInsertTableRecords = new WeakSet();
1533
1994
  bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
@@ -1543,20 +2004,27 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1543
2004
  throw new Error("Request included columns but server didn't include them");
1544
2005
  }
1545
2006
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1546
- return response.records?.map((item) => initObject(this.db, schemaTables, __privateGet$4(this, _table), item));
2007
+ return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
1547
2008
  };
1548
2009
  _updateRecordWithID = new WeakSet();
1549
2010
  updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1550
2011
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1551
2012
  const record = transformObjectLinks(object);
1552
- const response = await updateRecordWithID({
1553
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1554
- queryParams: { columns },
1555
- body: record,
1556
- ...fetchProps
1557
- });
1558
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1559
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
2013
+ try {
2014
+ const response = await updateRecordWithID({
2015
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2016
+ queryParams: { columns },
2017
+ body: record,
2018
+ ...fetchProps
2019
+ });
2020
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2021
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2022
+ } catch (e) {
2023
+ if (isObject(e) && e.status === 404) {
2024
+ return null;
2025
+ }
2026
+ throw e;
2027
+ }
1560
2028
  };
1561
2029
  _upsertRecordWithID = new WeakSet();
1562
2030
  upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
@@ -1568,15 +2036,25 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1568
2036
  ...fetchProps
1569
2037
  });
1570
2038
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1571
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
2039
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
1572
2040
  };
1573
2041
  _deleteRecord = new WeakSet();
1574
- deleteRecord_fn = async function(recordId) {
2042
+ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1575
2043
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1576
- await deleteRecord({
1577
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1578
- ...fetchProps
1579
- });
2044
+ try {
2045
+ const response = await deleteRecord({
2046
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
2047
+ queryParams: { columns },
2048
+ ...fetchProps
2049
+ });
2050
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2051
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
2052
+ } catch (e) {
2053
+ if (isObject(e) && e.status === 404) {
2054
+ return null;
2055
+ }
2056
+ throw e;
2057
+ }
1580
2058
  };
1581
2059
  _setCacheQuery = new WeakSet();
1582
2060
  setCacheQuery_fn = async function(query, meta, records) {
@@ -1613,7 +2091,7 @@ const transformObjectLinks = (object) => {
1613
2091
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
1614
2092
  }, {});
1615
2093
  };
1616
- const initObject = (db, schemaTables, table, object) => {
2094
+ const initObject = (db, schemaTables, table, object, selectedColumns) => {
1617
2095
  const result = {};
1618
2096
  const { xata, ...rest } = object ?? {};
1619
2097
  Object.assign(result, rest);
@@ -1621,6 +2099,8 @@ const initObject = (db, schemaTables, table, object) => {
1621
2099
  if (!columns)
1622
2100
  console.error(`Table ${table} not found in schema`);
1623
2101
  for (const column of columns ?? []) {
2102
+ if (!isValidColumn(selectedColumns, column))
2103
+ continue;
1624
2104
  const value = result[column.name];
1625
2105
  switch (column.type) {
1626
2106
  case "datetime": {
@@ -1637,10 +2117,28 @@ const initObject = (db, schemaTables, table, object) => {
1637
2117
  if (!linkTable) {
1638
2118
  console.error(`Failed to parse link for field ${column.name}`);
1639
2119
  } else if (isObject(value)) {
1640
- result[column.name] = initObject(db, schemaTables, linkTable, value);
2120
+ const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
2121
+ if (item === column.name) {
2122
+ return [...acc, "*"];
2123
+ }
2124
+ if (item.startsWith(`${column.name}.`)) {
2125
+ const [, ...path] = item.split(".");
2126
+ return [...acc, path.join(".")];
2127
+ }
2128
+ return acc;
2129
+ }, []);
2130
+ result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2131
+ } else {
2132
+ result[column.name] = null;
1641
2133
  }
1642
2134
  break;
1643
2135
  }
2136
+ default:
2137
+ result[column.name] = value ?? null;
2138
+ if (column.notNull === true && value === null) {
2139
+ console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2140
+ }
2141
+ break;
1644
2142
  }
1645
2143
  }
1646
2144
  result.read = function(columns2) {
@@ -1664,6 +2162,28 @@ const initObject = (db, schemaTables, table, object) => {
1664
2162
  function isResponseWithRecords(value) {
1665
2163
  return isObject(value) && Array.isArray(value.records);
1666
2164
  }
2165
+ function extractId(value) {
2166
+ if (isString(value))
2167
+ return value;
2168
+ if (isObject(value) && isString(value.id))
2169
+ return value.id;
2170
+ return void 0;
2171
+ }
2172
+ function cleanFilter(filter) {
2173
+ if (!filter)
2174
+ return void 0;
2175
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2176
+ return values.length > 0 ? filter : void 0;
2177
+ }
2178
+ function isValidColumn(columns, column) {
2179
+ if (columns.includes("*"))
2180
+ return true;
2181
+ if (column.type === "link") {
2182
+ const linkColumns = columns.filter((item) => item.startsWith(column.name));
2183
+ return linkColumns.length > 0;
2184
+ }
2185
+ return columns.includes(column.name);
2186
+ }
1667
2187
 
1668
2188
  var __accessCheck$3 = (obj, member, msg) => {
1669
2189
  if (!member.has(obj))
@@ -1714,18 +2234,25 @@ class SimpleCache {
1714
2234
  }
1715
2235
  _map = new WeakMap();
1716
2236
 
1717
- const gt = (value) => ({ $gt: value });
1718
- const ge = (value) => ({ $ge: value });
1719
- const gte = (value) => ({ $ge: value });
1720
- const lt = (value) => ({ $lt: value });
1721
- const lte = (value) => ({ $le: value });
1722
- const le = (value) => ({ $le: value });
2237
+ const greaterThan = (value) => ({ $gt: value });
2238
+ const gt = greaterThan;
2239
+ const greaterThanEquals = (value) => ({ $ge: value });
2240
+ const greaterEquals = greaterThanEquals;
2241
+ const gte = greaterThanEquals;
2242
+ const ge = greaterThanEquals;
2243
+ const lessThan = (value) => ({ $lt: value });
2244
+ const lt = lessThan;
2245
+ const lessThanEquals = (value) => ({ $le: value });
2246
+ const lessEquals = lessThanEquals;
2247
+ const lte = lessThanEquals;
2248
+ const le = lessThanEquals;
1723
2249
  const exists = (column) => ({ $exists: column });
1724
2250
  const notExists = (column) => ({ $notExists: column });
1725
2251
  const startsWith = (value) => ({ $startsWith: value });
1726
2252
  const endsWith = (value) => ({ $endsWith: value });
1727
2253
  const pattern = (value) => ({ $pattern: value });
1728
2254
  const is = (value) => ({ $is: value });
2255
+ const equals = is;
1729
2256
  const isNot = (value) => ({ $isNot: value });
1730
2257
  const contains = (value) => ({ $contains: value });
1731
2258
  const includes = (value) => ({ $includes: value });
@@ -1760,16 +2287,19 @@ class SchemaPlugin extends XataPlugin {
1760
2287
  __privateSet$2(this, _schemaTables$1, schemaTables);
1761
2288
  }
1762
2289
  build(pluginOptions) {
1763
- const db = new Proxy({}, {
1764
- get: (_target, table) => {
1765
- if (!isString(table))
1766
- throw new Error("Invalid table name");
1767
- if (__privateGet$2(this, _tables)[table] === void 0) {
1768
- __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
2290
+ const db = new Proxy(
2291
+ {},
2292
+ {
2293
+ get: (_target, table) => {
2294
+ if (!isString(table))
2295
+ throw new Error("Invalid table name");
2296
+ if (__privateGet$2(this, _tables)[table] === void 0) {
2297
+ __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
2298
+ }
2299
+ return __privateGet$2(this, _tables)[table];
1769
2300
  }
1770
- return __privateGet$2(this, _tables)[table];
1771
2301
  }
1772
- });
2302
+ );
1773
2303
  const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
1774
2304
  for (const table of tableNames) {
1775
2305
  db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
@@ -1819,7 +2349,7 @@ class SearchPlugin extends XataPlugin {
1819
2349
  const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
1820
2350
  return records.map((record) => {
1821
2351
  const { table = "orphan" } = record.xata;
1822
- return { table, record: initObject(this.db, schemaTables, table, record) };
2352
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
1823
2353
  });
1824
2354
  },
1825
2355
  byTable: async (query, options = {}) => {
@@ -1828,7 +2358,7 @@ class SearchPlugin extends XataPlugin {
1828
2358
  return records.reduce((acc, record) => {
1829
2359
  const { table = "orphan" } = record.xata;
1830
2360
  const items = acc[table] ?? [];
1831
- const item = initObject(this.db, schemaTables, table, record);
2361
+ const item = initObject(this.db, schemaTables, table, record, ["*"]);
1832
2362
  return { ...acc, [table]: [...items, item] };
1833
2363
  }, {});
1834
2364
  }
@@ -1883,9 +2413,13 @@ async function resolveXataBranch(gitBranch, options) {
1883
2413
  const databaseURL = options?.databaseURL || getDatabaseURL();
1884
2414
  const apiKey = options?.apiKey || getAPIKey();
1885
2415
  if (!databaseURL)
1886
- throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
2416
+ throw new Error(
2417
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2418
+ );
1887
2419
  if (!apiKey)
1888
- throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
2420
+ throw new Error(
2421
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2422
+ );
1889
2423
  const [protocol, , host, , dbName] = databaseURL.split("/");
1890
2424
  const [workspace] = host.split(".");
1891
2425
  const { fallbackBranch } = getEnvironment();
@@ -1895,7 +2429,8 @@ async function resolveXataBranch(gitBranch, options) {
1895
2429
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1896
2430
  workspacesApiUrl: `${protocol}//${host}`,
1897
2431
  pathParams: { dbName, workspace },
1898
- queryParams: { gitBranch, fallbackBranch }
2432
+ queryParams: { gitBranch, fallbackBranch },
2433
+ trace: defaultTrace
1899
2434
  });
1900
2435
  return branch;
1901
2436
  }
@@ -1903,9 +2438,13 @@ async function getDatabaseBranch(branch, options) {
1903
2438
  const databaseURL = options?.databaseURL || getDatabaseURL();
1904
2439
  const apiKey = options?.apiKey || getAPIKey();
1905
2440
  if (!databaseURL)
1906
- throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
2441
+ throw new Error(
2442
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2443
+ );
1907
2444
  if (!apiKey)
1908
- throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
2445
+ throw new Error(
2446
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2447
+ );
1909
2448
  const [protocol, , host, , database] = databaseURL.split("/");
1910
2449
  const [workspace] = host.split(".");
1911
2450
  const dbBranchName = `${database}:${branch}`;
@@ -1915,7 +2454,8 @@ async function getDatabaseBranch(branch, options) {
1915
2454
  apiUrl: databaseURL,
1916
2455
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1917
2456
  workspacesApiUrl: `${protocol}//${host}`,
1918
- pathParams: { dbBranchName, workspace }
2457
+ pathParams: { dbBranchName, workspace },
2458
+ trace: defaultTrace
1919
2459
  });
1920
2460
  } catch (err) {
1921
2461
  if (isObject(err) && err.status === 404)
@@ -1955,17 +2495,20 @@ var __privateMethod = (obj, member, method) => {
1955
2495
  return method;
1956
2496
  };
1957
2497
  const buildClient = (plugins) => {
1958
- var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
2498
+ var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
1959
2499
  return _a = class {
1960
2500
  constructor(options = {}, schemaTables) {
1961
2501
  __privateAdd(this, _parseOptions);
1962
2502
  __privateAdd(this, _getFetchProps);
1963
2503
  __privateAdd(this, _evaluateBranch);
1964
2504
  __privateAdd(this, _branch, void 0);
2505
+ __privateAdd(this, _options, void 0);
1965
2506
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
2507
+ __privateSet(this, _options, safeOptions);
1966
2508
  const pluginOptions = {
1967
2509
  getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
1968
- cache: safeOptions.cache
2510
+ cache: safeOptions.cache,
2511
+ trace: safeOptions.trace
1969
2512
  };
1970
2513
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
1971
2514
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
@@ -1984,22 +2527,26 @@ const buildClient = (plugins) => {
1984
2527
  }
1985
2528
  }
1986
2529
  }
1987
- }, _branch = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
2530
+ async getConfig() {
2531
+ const databaseURL = __privateGet(this, _options).databaseURL;
2532
+ const branch = await __privateGet(this, _options).branch();
2533
+ return { databaseURL, branch };
2534
+ }
2535
+ }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
1988
2536
  const fetch = getFetchImplementation(options?.fetch);
1989
2537
  const databaseURL = options?.databaseURL || getDatabaseURL();
1990
2538
  const apiKey = options?.apiKey || getAPIKey();
1991
2539
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
2540
+ const trace = options?.trace ?? defaultTrace;
1992
2541
  const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
1993
- if (!databaseURL || !apiKey) {
1994
- throw new Error("Options databaseURL and apiKey are required");
2542
+ if (!apiKey) {
2543
+ throw new Error("Option apiKey is required");
1995
2544
  }
1996
- return { fetch, databaseURL, apiKey, branch, cache };
1997
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
1998
- fetch,
1999
- apiKey,
2000
- databaseURL,
2001
- branch
2002
- }) {
2545
+ if (!databaseURL) {
2546
+ throw new Error("Option databaseURL is required");
2547
+ }
2548
+ return { fetch, databaseURL, apiKey, branch, cache, trace };
2549
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
2003
2550
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2004
2551
  if (!branchValue)
2005
2552
  throw new Error("Unable to resolve branch value");
@@ -2009,9 +2556,10 @@ const buildClient = (plugins) => {
2009
2556
  apiUrl: "",
2010
2557
  workspacesApiUrl: (path, params) => {
2011
2558
  const hasBranch = params.dbBranchName ?? params.branch;
2012
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
2559
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
2013
2560
  return databaseURL + newPath;
2014
- }
2561
+ },
2562
+ trace
2015
2563
  };
2016
2564
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2017
2565
  if (__privateGet(this, _branch))
@@ -2034,6 +2582,88 @@ const buildClient = (plugins) => {
2034
2582
  class BaseClient extends buildClient() {
2035
2583
  }
2036
2584
 
2585
+ const META = "__";
2586
+ const VALUE = "___";
2587
+ class Serializer {
2588
+ constructor() {
2589
+ this.classes = {};
2590
+ }
2591
+ add(clazz) {
2592
+ this.classes[clazz.name] = clazz;
2593
+ }
2594
+ toJSON(data) {
2595
+ function visit(obj) {
2596
+ if (Array.isArray(obj))
2597
+ return obj.map(visit);
2598
+ const type = typeof obj;
2599
+ if (type === "undefined")
2600
+ return { [META]: "undefined" };
2601
+ if (type === "bigint")
2602
+ return { [META]: "bigint", [VALUE]: obj.toString() };
2603
+ if (obj === null || type !== "object")
2604
+ return obj;
2605
+ const constructor = obj.constructor;
2606
+ const o = { [META]: constructor.name };
2607
+ for (const [key, value] of Object.entries(obj)) {
2608
+ o[key] = visit(value);
2609
+ }
2610
+ if (constructor === Date)
2611
+ o[VALUE] = obj.toISOString();
2612
+ if (constructor === Map)
2613
+ o[VALUE] = Object.fromEntries(obj);
2614
+ if (constructor === Set)
2615
+ o[VALUE] = [...obj];
2616
+ return o;
2617
+ }
2618
+ return JSON.stringify(visit(data));
2619
+ }
2620
+ fromJSON(json) {
2621
+ return JSON.parse(json, (key, value) => {
2622
+ if (value && typeof value === "object" && !Array.isArray(value)) {
2623
+ const { [META]: clazz, [VALUE]: val, ...rest } = value;
2624
+ const constructor = this.classes[clazz];
2625
+ if (constructor) {
2626
+ return Object.assign(Object.create(constructor.prototype), rest);
2627
+ }
2628
+ if (clazz === "Date")
2629
+ return new Date(val);
2630
+ if (clazz === "Set")
2631
+ return new Set(val);
2632
+ if (clazz === "Map")
2633
+ return new Map(Object.entries(val));
2634
+ if (clazz === "bigint")
2635
+ return BigInt(val);
2636
+ if (clazz === "undefined")
2637
+ return void 0;
2638
+ return rest;
2639
+ }
2640
+ return value;
2641
+ });
2642
+ }
2643
+ }
2644
+ const defaultSerializer = new Serializer();
2645
+ const serialize = (data) => {
2646
+ return defaultSerializer.toJSON(data);
2647
+ };
2648
+ const deserialize = (json) => {
2649
+ return defaultSerializer.fromJSON(json);
2650
+ };
2651
+
2652
+ function buildWorkerRunner(config) {
2653
+ return function xataWorker(name, _worker) {
2654
+ return async (...args) => {
2655
+ const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
2656
+ const result = await fetch(url, {
2657
+ method: "POST",
2658
+ headers: { "Content-Type": "application/json" },
2659
+ body: serialize({ args })
2660
+ });
2661
+ const text = await result.text();
2662
+ return deserialize(text);
2663
+ };
2664
+ };
2665
+ }
2666
+
2037
2667
  class XataError extends Error {
2038
2668
  constructor(message, status) {
2039
2669
  super(message);
@@ -2041,5 +2671,5 @@ class XataError extends Error {
2041
2671
  }
2042
2672
  }
2043
2673
 
2044
- 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 };
2674
+ 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, 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, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, 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 };
2045
2675
  //# sourceMappingURL=index.mjs.map