@xata.io/client 0.0.0-alpha.vf7b5320 → 0.0.0-alpha.vf7fccd9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2,6 +2,46 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ function _interopNamespace(e) {
6
+ if (e && e.__esModule) return e;
7
+ var n = Object.create(null);
8
+ if (e) {
9
+ Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default') {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n["default"] = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ const defaultTrace = async (_name, fn, _options) => {
24
+ return await fn({
25
+ setAttributes: () => {
26
+ return;
27
+ }
28
+ });
29
+ };
30
+ const TraceAttributes = {
31
+ KIND: "xata.trace.kind",
32
+ VERSION: "xata.sdk.version",
33
+ TABLE: "xata.table",
34
+ HTTP_REQUEST_ID: "http.request_id",
35
+ HTTP_STATUS_CODE: "http.status_code",
36
+ HTTP_HOST: "http.host",
37
+ HTTP_SCHEME: "http.scheme",
38
+ HTTP_USER_AGENT: "http.user_agent",
39
+ HTTP_METHOD: "http.method",
40
+ HTTP_URL: "http.url",
41
+ HTTP_ROUTE: "http.route",
42
+ HTTP_TARGET: "http.target"
43
+ };
44
+
5
45
  function notEmpty(value) {
6
46
  return value !== null && value !== void 0;
7
47
  }
@@ -11,46 +51,101 @@ function compact(arr) {
11
51
  function isObject(value) {
12
52
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
13
53
  }
54
+ function isDefined(value) {
55
+ return value !== null && value !== void 0;
56
+ }
14
57
  function isString(value) {
15
- return value !== void 0 && value !== null && typeof value === "string";
58
+ return isDefined(value) && typeof value === "string";
59
+ }
60
+ function isStringArray(value) {
61
+ return isDefined(value) && Array.isArray(value) && value.every(isString);
16
62
  }
17
63
  function toBase64(value) {
18
64
  try {
19
65
  return btoa(value);
20
66
  } catch (err) {
21
- return Buffer.from(value).toString("base64");
67
+ const buf = Buffer;
68
+ return buf.from(value).toString("base64");
22
69
  }
23
70
  }
24
71
 
25
- function getEnvVariable(name) {
72
+ function getEnvironment() {
26
73
  try {
27
- if (isObject(process) && isString(process?.env?.[name])) {
28
- return process.env[name];
74
+ if (isObject(process) && isObject(process.env)) {
75
+ return {
76
+ apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
77
+ databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
78
+ branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
79
+ envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
80
+ fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
81
+ };
29
82
  }
30
83
  } catch (err) {
31
84
  }
32
85
  try {
33
- if (isObject(Deno) && isString(Deno?.env?.get(name))) {
34
- return Deno.env.get(name);
86
+ if (isObject(Deno) && isObject(Deno.env)) {
87
+ return {
88
+ apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
89
+ databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
90
+ branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
91
+ envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
92
+ fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
93
+ };
35
94
  }
36
95
  } catch (err) {
37
96
  }
97
+ return {
98
+ apiKey: getGlobalApiKey(),
99
+ databaseURL: getGlobalDatabaseURL(),
100
+ branch: getGlobalBranch(),
101
+ envBranch: void 0,
102
+ fallbackBranch: getGlobalFallbackBranch()
103
+ };
104
+ }
105
+ function getGlobalApiKey() {
106
+ try {
107
+ return XATA_API_KEY;
108
+ } catch (err) {
109
+ return void 0;
110
+ }
111
+ }
112
+ function getGlobalDatabaseURL() {
113
+ try {
114
+ return XATA_DATABASE_URL;
115
+ } catch (err) {
116
+ return void 0;
117
+ }
118
+ }
119
+ function getGlobalBranch() {
120
+ try {
121
+ return XATA_BRANCH;
122
+ } catch (err) {
123
+ return void 0;
124
+ }
125
+ }
126
+ function getGlobalFallbackBranch() {
127
+ try {
128
+ return XATA_FALLBACK_BRANCH;
129
+ } catch (err) {
130
+ return void 0;
131
+ }
38
132
  }
39
133
  async function getGitBranch() {
134
+ const cmd = ["git", "branch", "--show-current"];
135
+ const fullCmd = cmd.join(" ");
136
+ const nodeModule = ["child", "process"].join("_");
137
+ const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
40
138
  try {
41
139
  if (typeof require === "function") {
42
- const req = require;
43
- return req("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
140
+ return require(nodeModule).execSync(fullCmd, execOptions).trim();
44
141
  }
142
+ const { execSync } = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(nodeModule);
143
+ return execSync(fullCmd, execOptions).toString().trim();
45
144
  } catch (err) {
46
145
  }
47
146
  try {
48
147
  if (isObject(Deno)) {
49
- const process2 = Deno.run({
50
- cmd: ["git", "branch", "--show-current"],
51
- stdout: "piped",
52
- stderr: "piped"
53
- });
148
+ const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
54
149
  return new TextDecoder().decode(await process2.output()).trim();
55
150
  }
56
151
  } catch (err) {
@@ -59,7 +154,8 @@ async function getGitBranch() {
59
154
 
60
155
  function getAPIKey() {
61
156
  try {
62
- return getEnvVariable("XATA_API_KEY") ?? XATA_API_KEY;
157
+ const { apiKey } = getEnvironment();
158
+ return apiKey;
63
159
  } catch (err) {
64
160
  return void 0;
65
161
  }
@@ -69,21 +165,35 @@ function getFetchImplementation(userFetch) {
69
165
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
70
166
  const fetchImpl = userFetch ?? globalFetch;
71
167
  if (!fetchImpl) {
72
- throw new Error(`The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`);
168
+ throw new Error(
169
+ `Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
170
+ );
73
171
  }
74
172
  return fetchImpl;
75
173
  }
76
174
 
77
- class FetcherError extends Error {
78
- constructor(status, data) {
175
+ const VERSION = "0.0.0-alpha.vf7fccd9";
176
+
177
+ class ErrorWithCause extends Error {
178
+ constructor(message, options) {
179
+ super(message, options);
180
+ }
181
+ }
182
+ class FetcherError extends ErrorWithCause {
183
+ constructor(status, data, requestId) {
79
184
  super(getMessage(data));
80
185
  this.status = status;
81
186
  this.errors = isBulkError(data) ? data.errors : void 0;
187
+ this.requestId = requestId;
82
188
  if (data instanceof Error) {
83
189
  this.stack = data.stack;
84
190
  this.cause = data.cause;
85
191
  }
86
192
  }
193
+ toString() {
194
+ const error = super.toString();
195
+ return `[${this.status}] (${this.requestId ?? "Unknown"}): ${error}`;
196
+ }
87
197
  }
88
198
  function isBulkError(error) {
89
199
  return isObject(error) && Array.isArray(error.errors);
@@ -106,9 +216,17 @@ function getMessage(data) {
106
216
  }
107
217
 
108
218
  const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
109
- const query = new URLSearchParams(queryParams).toString();
219
+ const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
220
+ if (value === void 0 || value === null)
221
+ return acc;
222
+ return { ...acc, [key]: value };
223
+ }, {});
224
+ const query = new URLSearchParams(cleanQueryParams).toString();
110
225
  const queryString = query.length > 0 ? `?${query}` : "";
111
- return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
226
+ const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
227
+ return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
228
+ }, {});
229
+ return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
112
230
  };
113
231
  function buildBaseUrl({
114
232
  path,
@@ -116,10 +234,10 @@ function buildBaseUrl({
116
234
  apiUrl,
117
235
  pathParams
118
236
  }) {
119
- if (!pathParams?.workspace)
237
+ if (pathParams?.workspace === void 0)
120
238
  return `${apiUrl}${path}`;
121
239
  const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
122
- return url.replace("{workspaceId}", pathParams.workspace);
240
+ return url.replace("{workspaceId}", String(pathParams.workspace));
123
241
  }
124
242
  function hostHeader(url) {
125
243
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
@@ -136,32 +254,61 @@ async function fetch$1({
136
254
  fetchImpl,
137
255
  apiKey,
138
256
  apiUrl,
139
- workspacesApiUrl
257
+ workspacesApiUrl,
258
+ trace
140
259
  }) {
141
- const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
142
- const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
143
- const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
144
- const response = await fetchImpl(url, {
145
- method: method.toUpperCase(),
146
- body: body ? JSON.stringify(body) : void 0,
147
- headers: {
148
- "Content-Type": "application/json",
149
- ...headers,
150
- ...hostHeader(fullUrl),
151
- Authorization: `Bearer ${apiKey}`
152
- }
153
- });
154
- if (response.status === 204) {
155
- return {};
156
- }
260
+ return trace(
261
+ `${method.toUpperCase()} ${path}`,
262
+ async ({ setAttributes }) => {
263
+ const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
264
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
265
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
266
+ setAttributes({
267
+ [TraceAttributes.HTTP_URL]: url,
268
+ [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
269
+ });
270
+ const response = await fetchImpl(url, {
271
+ method: method.toUpperCase(),
272
+ body: body ? JSON.stringify(body) : void 0,
273
+ headers: {
274
+ "Content-Type": "application/json",
275
+ "User-Agent": `Xata client-ts/${VERSION}`,
276
+ ...headers,
277
+ ...hostHeader(fullUrl),
278
+ Authorization: `Bearer ${apiKey}`
279
+ }
280
+ });
281
+ if (response.status === 204) {
282
+ return {};
283
+ }
284
+ const { host, protocol } = parseUrl(response.url);
285
+ const requestId = response.headers?.get("x-request-id") ?? void 0;
286
+ setAttributes({
287
+ [TraceAttributes.KIND]: "http",
288
+ [TraceAttributes.HTTP_REQUEST_ID]: requestId,
289
+ [TraceAttributes.HTTP_STATUS_CODE]: response.status,
290
+ [TraceAttributes.HTTP_HOST]: host,
291
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
292
+ });
293
+ try {
294
+ const jsonResponse = await response.json();
295
+ if (response.ok) {
296
+ return jsonResponse;
297
+ }
298
+ throw new FetcherError(response.status, jsonResponse, requestId);
299
+ } catch (error) {
300
+ throw new FetcherError(response.status, error, requestId);
301
+ }
302
+ },
303
+ { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
304
+ );
305
+ }
306
+ function parseUrl(url) {
157
307
  try {
158
- const jsonResponse = await response.json();
159
- if (response.ok) {
160
- return jsonResponse;
161
- }
162
- throw new FetcherError(response.status, jsonResponse);
308
+ const { host, protocol } = new URL(url);
309
+ return { host, protocol };
163
310
  } catch (error) {
164
- throw new FetcherError(response.status, error);
311
+ return {};
165
312
  }
166
313
  }
167
314
 
@@ -220,6 +367,7 @@ const removeWorkspaceMember = (variables) => fetch$1({
220
367
  ...variables
221
368
  });
222
369
  const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
370
+ const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
223
371
  const cancelWorkspaceMemberInvite = (variables) => fetch$1({
224
372
  url: "/workspaces/{workspaceId}/invites/{inviteId}",
225
373
  method: "delete",
@@ -255,6 +403,12 @@ const deleteDatabase = (variables) => fetch$1({
255
403
  method: "delete",
256
404
  ...variables
257
405
  });
406
+ const getDatabaseMetadata = (variables) => fetch$1({
407
+ url: "/dbs/{dbName}/metadata",
408
+ method: "get",
409
+ ...variables
410
+ });
411
+ const updateDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
258
412
  const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
259
413
  const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
260
414
  const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
@@ -263,16 +417,28 @@ const resolveBranch = (variables) => fetch$1({
263
417
  method: "get",
264
418
  ...variables
265
419
  });
266
- const getBranchDetails = (variables) => fetch$1({
267
- url: "/db/{dbBranchName}",
420
+ const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
421
+ const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
422
+ const getMigrationRequest = (variables) => fetch$1({
423
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
268
424
  method: "get",
269
425
  ...variables
270
426
  });
271
- const createBranch = (variables) => fetch$1({
427
+ const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
428
+ const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
429
+ const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
430
+ const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
431
+ const mergeMigrationRequest = (variables) => fetch$1({
432
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
433
+ method: "post",
434
+ ...variables
435
+ });
436
+ const getBranchDetails = (variables) => fetch$1({
272
437
  url: "/db/{dbBranchName}",
273
- method: "put",
438
+ method: "get",
274
439
  ...variables
275
440
  });
441
+ const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
276
442
  const deleteBranch = (variables) => fetch$1({
277
443
  url: "/db/{dbBranchName}",
278
444
  method: "delete",
@@ -291,6 +457,16 @@ const getBranchMetadata = (variables) => fetch$1({
291
457
  const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
292
458
  const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
293
459
  const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
460
+ const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
461
+ const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
462
+ const updateBranchSchema = (variables) => fetch$1({
463
+ url: "/db/{dbBranchName}/schema/update",
464
+ method: "post",
465
+ ...variables
466
+ });
467
+ const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
468
+ const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
469
+ const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
294
470
  const getBranchStats = (variables) => fetch$1({
295
471
  url: "/db/{dbBranchName}/stats",
296
472
  method: "get",
@@ -346,11 +522,7 @@ const updateColumn = (variables) => fetch$1({
346
522
  method: "patch",
347
523
  ...variables
348
524
  });
349
- const insertRecord = (variables) => fetch$1({
350
- url: "/db/{dbBranchName}/tables/{tableName}/data",
351
- method: "post",
352
- ...variables
353
- });
525
+ const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
354
526
  const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
355
527
  const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
356
528
  const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
@@ -370,11 +542,21 @@ const queryTable = (variables) => fetch$1({
370
542
  method: "post",
371
543
  ...variables
372
544
  });
545
+ const searchTable = (variables) => fetch$1({
546
+ url: "/db/{dbBranchName}/tables/{tableName}/search",
547
+ method: "post",
548
+ ...variables
549
+ });
373
550
  const searchBranch = (variables) => fetch$1({
374
551
  url: "/db/{dbBranchName}/search",
375
552
  method: "post",
376
553
  ...variables
377
554
  });
555
+ const summarizeTable = (variables) => fetch$1({
556
+ url: "/db/{dbBranchName}/tables/{tableName}/summarize",
557
+ method: "post",
558
+ ...variables
559
+ });
378
560
  const operationsByTag = {
379
561
  users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
380
562
  workspaces: {
@@ -387,6 +569,7 @@ const operationsByTag = {
387
569
  updateWorkspaceMemberRole,
388
570
  removeWorkspaceMember,
389
571
  inviteWorkspaceMember,
572
+ updateWorkspaceMemberInvite,
390
573
  cancelWorkspaceMemberInvite,
391
574
  resendWorkspaceMemberInvite,
392
575
  acceptWorkspaceMemberInvite
@@ -395,6 +578,8 @@ const operationsByTag = {
395
578
  getDatabaseList,
396
579
  createDatabase,
397
580
  deleteDatabase,
581
+ getDatabaseMetadata,
582
+ updateDatabaseMetadata,
398
583
  getGitBranchesMapping,
399
584
  addGitBranchesEntry,
400
585
  removeGitBranchesEntry,
@@ -407,10 +592,28 @@ const operationsByTag = {
407
592
  deleteBranch,
408
593
  updateBranchMetadata,
409
594
  getBranchMetadata,
595
+ getBranchStats
596
+ },
597
+ migrationRequests: {
598
+ listMigrationRequests,
599
+ createMigrationRequest,
600
+ getMigrationRequest,
601
+ updateMigrationRequest,
602
+ listMigrationRequestsCommits,
603
+ compareMigrationRequest,
604
+ getMigrationRequestIsMerged,
605
+ mergeMigrationRequest
606
+ },
607
+ branchSchema: {
410
608
  getBranchMigrationHistory,
411
609
  executeBranchMigrationPlan,
412
610
  getBranchMigrationPlan,
413
- getBranchStats
611
+ compareBranchWithUserSchema,
612
+ compareBranchSchemas,
613
+ updateBranchSchema,
614
+ previewBranchSchemaEdit,
615
+ applyBranchSchemaEdit,
616
+ getBranchSchemaHistory
414
617
  },
415
618
  table: {
416
619
  createTable,
@@ -433,14 +636,16 @@ const operationsByTag = {
433
636
  getRecord,
434
637
  bulkInsertTableRecords,
435
638
  queryTable,
436
- searchBranch
639
+ searchTable,
640
+ searchBranch,
641
+ summarizeTable
437
642
  }
438
643
  };
439
644
 
440
645
  function getHostUrl(provider, type) {
441
- if (isValidAlias(provider)) {
646
+ if (isHostProviderAlias(provider)) {
442
647
  return providers[provider][type];
443
- } else if (isValidBuilder(provider)) {
648
+ } else if (isHostProviderBuilder(provider)) {
444
649
  return provider[type];
445
650
  }
446
651
  throw new Error("Invalid API provider");
@@ -455,10 +660,10 @@ const providers = {
455
660
  workspaces: "https://{workspaceId}.staging.xatabase.co"
456
661
  }
457
662
  };
458
- function isValidAlias(alias) {
663
+ function isHostProviderAlias(alias) {
459
664
  return isString(alias) && Object.keys(providers).includes(alias);
460
665
  }
461
- function isValidBuilder(builder) {
666
+ function isHostProviderBuilder(builder) {
462
667
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
463
668
  }
464
669
 
@@ -475,7 +680,7 @@ var __privateAdd$7 = (obj, member, value) => {
475
680
  throw TypeError("Cannot add the same private member more than once");
476
681
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
477
682
  };
478
- var __privateSet$6 = (obj, member, value, setter) => {
683
+ var __privateSet$7 = (obj, member, value, setter) => {
479
684
  __accessCheck$7(obj, member, "write to private field");
480
685
  setter ? setter.call(obj, value) : member.set(obj, value);
481
686
  return value;
@@ -486,15 +691,17 @@ class XataApiClient {
486
691
  __privateAdd$7(this, _extraProps, void 0);
487
692
  __privateAdd$7(this, _namespaces, {});
488
693
  const provider = options.host ?? "production";
489
- const apiKey = options?.apiKey ?? getAPIKey();
694
+ const apiKey = options.apiKey ?? getAPIKey();
695
+ const trace = options.trace ?? defaultTrace;
490
696
  if (!apiKey) {
491
697
  throw new Error("Could not resolve a valid apiKey");
492
698
  }
493
- __privateSet$6(this, _extraProps, {
699
+ __privateSet$7(this, _extraProps, {
494
700
  apiUrl: getHostUrl(provider, "main"),
495
701
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
496
702
  fetchImpl: getFetchImplementation(options.fetch),
497
- apiKey
703
+ apiKey,
704
+ trace
498
705
  });
499
706
  }
500
707
  get user() {
@@ -527,6 +734,16 @@ class XataApiClient {
527
734
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
528
735
  return __privateGet$7(this, _namespaces).records;
529
736
  }
737
+ get migrationRequests() {
738
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
739
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
740
+ return __privateGet$7(this, _namespaces).migrationRequests;
741
+ }
742
+ get branchSchema() {
743
+ if (!__privateGet$7(this, _namespaces).branchSchema)
744
+ __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
745
+ return __privateGet$7(this, _namespaces).branchSchema;
746
+ }
530
747
  }
531
748
  _extraProps = new WeakMap();
532
749
  _namespaces = new WeakMap();
@@ -617,6 +834,13 @@ class WorkspaceApi {
617
834
  ...this.extraProps
618
835
  });
619
836
  }
837
+ updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
838
+ return operationsByTag.workspaces.updateWorkspaceMemberInvite({
839
+ pathParams: { workspaceId, inviteId },
840
+ body: { role },
841
+ ...this.extraProps
842
+ });
843
+ }
620
844
  cancelWorkspaceMemberInvite(workspaceId, inviteId) {
621
845
  return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
622
846
  pathParams: { workspaceId, inviteId },
@@ -659,6 +883,19 @@ class DatabaseApi {
659
883
  ...this.extraProps
660
884
  });
661
885
  }
886
+ getDatabaseMetadata(workspace, dbName) {
887
+ return operationsByTag.database.getDatabaseMetadata({
888
+ pathParams: { workspace, dbName },
889
+ ...this.extraProps
890
+ });
891
+ }
892
+ updateDatabaseMetadata(workspace, dbName, options = {}) {
893
+ return operationsByTag.database.updateDatabaseMetadata({
894
+ pathParams: { workspace, dbName },
895
+ body: options,
896
+ ...this.extraProps
897
+ });
898
+ }
662
899
  getGitBranchesMapping(workspace, dbName) {
663
900
  return operationsByTag.database.getGitBranchesMapping({
664
901
  pathParams: { workspace, dbName },
@@ -679,10 +916,10 @@ class DatabaseApi {
679
916
  ...this.extraProps
680
917
  });
681
918
  }
682
- resolveBranch(workspace, dbName, gitBranch) {
919
+ resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
683
920
  return operationsByTag.database.resolveBranch({
684
921
  pathParams: { workspace, dbName },
685
- queryParams: { gitBranch },
922
+ queryParams: { gitBranch, fallbackBranch },
686
923
  ...this.extraProps
687
924
  });
688
925
  }
@@ -703,10 +940,10 @@ class BranchApi {
703
940
  ...this.extraProps
704
941
  });
705
942
  }
706
- createBranch(workspace, database, branch, from = "", options = {}) {
943
+ createBranch(workspace, database, branch, from, options = {}) {
707
944
  return operationsByTag.branch.createBranch({
708
945
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
709
- queryParams: { from },
946
+ queryParams: isString(from) ? { from } : void 0,
710
947
  body: options,
711
948
  ...this.extraProps
712
949
  });
@@ -730,27 +967,6 @@ class BranchApi {
730
967
  ...this.extraProps
731
968
  });
732
969
  }
733
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
734
- return operationsByTag.branch.getBranchMigrationHistory({
735
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
736
- body: options,
737
- ...this.extraProps
738
- });
739
- }
740
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
741
- return operationsByTag.branch.executeBranchMigrationPlan({
742
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
743
- body: migrationPlan,
744
- ...this.extraProps
745
- });
746
- }
747
- getBranchMigrationPlan(workspace, database, branch, schema) {
748
- return operationsByTag.branch.getBranchMigrationPlan({
749
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
750
- body: schema,
751
- ...this.extraProps
752
- });
753
- }
754
970
  getBranchStats(workspace, database, branch) {
755
971
  return operationsByTag.branch.getBranchStats({
756
972
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
@@ -831,9 +1047,10 @@ class RecordsApi {
831
1047
  constructor(extraProps) {
832
1048
  this.extraProps = extraProps;
833
1049
  }
834
- insertRecord(workspace, database, branch, tableName, record) {
1050
+ insertRecord(workspace, database, branch, tableName, record, options = {}) {
835
1051
  return operationsByTag.records.insertRecord({
836
1052
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1053
+ queryParams: options,
837
1054
  body: record,
838
1055
  ...this.extraProps
839
1056
  });
@@ -862,21 +1079,24 @@ class RecordsApi {
862
1079
  ...this.extraProps
863
1080
  });
864
1081
  }
865
- deleteRecord(workspace, database, branch, tableName, recordId) {
1082
+ deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
866
1083
  return operationsByTag.records.deleteRecord({
867
1084
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1085
+ queryParams: options,
868
1086
  ...this.extraProps
869
1087
  });
870
1088
  }
871
1089
  getRecord(workspace, database, branch, tableName, recordId, options = {}) {
872
1090
  return operationsByTag.records.getRecord({
873
1091
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
1092
+ queryParams: options,
874
1093
  ...this.extraProps
875
1094
  });
876
1095
  }
877
- bulkInsertTableRecords(workspace, database, branch, tableName, records) {
1096
+ bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
878
1097
  return operationsByTag.records.bulkInsertTableRecords({
879
1098
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1099
+ queryParams: options,
880
1100
  body: { records },
881
1101
  ...this.extraProps
882
1102
  });
@@ -888,6 +1108,13 @@ class RecordsApi {
888
1108
  ...this.extraProps
889
1109
  });
890
1110
  }
1111
+ searchTable(workspace, database, branch, tableName, query) {
1112
+ return operationsByTag.records.searchTable({
1113
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1114
+ body: query,
1115
+ ...this.extraProps
1116
+ });
1117
+ }
891
1118
  searchBranch(workspace, database, branch, query) {
892
1119
  return operationsByTag.records.searchBranch({
893
1120
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
@@ -895,6 +1122,138 @@ class RecordsApi {
895
1122
  ...this.extraProps
896
1123
  });
897
1124
  }
1125
+ summarizeTable(workspace, database, branch, tableName, query) {
1126
+ return operationsByTag.records.summarizeTable({
1127
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1128
+ body: query,
1129
+ ...this.extraProps
1130
+ });
1131
+ }
1132
+ }
1133
+ class MigrationRequestsApi {
1134
+ constructor(extraProps) {
1135
+ this.extraProps = extraProps;
1136
+ }
1137
+ listMigrationRequests(workspace, database, options = {}) {
1138
+ return operationsByTag.migrationRequests.listMigrationRequests({
1139
+ pathParams: { workspace, dbName: database },
1140
+ body: options,
1141
+ ...this.extraProps
1142
+ });
1143
+ }
1144
+ createMigrationRequest(workspace, database, options) {
1145
+ return operationsByTag.migrationRequests.createMigrationRequest({
1146
+ pathParams: { workspace, dbName: database },
1147
+ body: options,
1148
+ ...this.extraProps
1149
+ });
1150
+ }
1151
+ getMigrationRequest(workspace, database, migrationRequest) {
1152
+ return operationsByTag.migrationRequests.getMigrationRequest({
1153
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1154
+ ...this.extraProps
1155
+ });
1156
+ }
1157
+ updateMigrationRequest(workspace, database, migrationRequest, options) {
1158
+ return operationsByTag.migrationRequests.updateMigrationRequest({
1159
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1160
+ body: options,
1161
+ ...this.extraProps
1162
+ });
1163
+ }
1164
+ listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1165
+ return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1166
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1167
+ body: options,
1168
+ ...this.extraProps
1169
+ });
1170
+ }
1171
+ compareMigrationRequest(workspace, database, migrationRequest) {
1172
+ return operationsByTag.migrationRequests.compareMigrationRequest({
1173
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1174
+ ...this.extraProps
1175
+ });
1176
+ }
1177
+ getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1178
+ return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1179
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1180
+ ...this.extraProps
1181
+ });
1182
+ }
1183
+ mergeMigrationRequest(workspace, database, migrationRequest) {
1184
+ return operationsByTag.migrationRequests.mergeMigrationRequest({
1185
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1186
+ ...this.extraProps
1187
+ });
1188
+ }
1189
+ }
1190
+ class BranchSchemaApi {
1191
+ constructor(extraProps) {
1192
+ this.extraProps = extraProps;
1193
+ }
1194
+ getBranchMigrationHistory(workspace, database, branch, options = {}) {
1195
+ return operationsByTag.branchSchema.getBranchMigrationHistory({
1196
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1197
+ body: options,
1198
+ ...this.extraProps
1199
+ });
1200
+ }
1201
+ executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1202
+ return operationsByTag.branchSchema.executeBranchMigrationPlan({
1203
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1204
+ body: migrationPlan,
1205
+ ...this.extraProps
1206
+ });
1207
+ }
1208
+ getBranchMigrationPlan(workspace, database, branch, schema) {
1209
+ return operationsByTag.branchSchema.getBranchMigrationPlan({
1210
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1211
+ body: schema,
1212
+ ...this.extraProps
1213
+ });
1214
+ }
1215
+ compareBranchWithUserSchema(workspace, database, branch, schema) {
1216
+ return operationsByTag.branchSchema.compareBranchWithUserSchema({
1217
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1218
+ body: { schema },
1219
+ ...this.extraProps
1220
+ });
1221
+ }
1222
+ compareBranchSchemas(workspace, database, branch, branchName, schema) {
1223
+ return operationsByTag.branchSchema.compareBranchSchemas({
1224
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1225
+ body: { schema },
1226
+ ...this.extraProps
1227
+ });
1228
+ }
1229
+ updateBranchSchema(workspace, database, branch, migration) {
1230
+ return operationsByTag.branchSchema.updateBranchSchema({
1231
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1232
+ body: migration,
1233
+ ...this.extraProps
1234
+ });
1235
+ }
1236
+ previewBranchSchemaEdit(workspace, database, branch, migration) {
1237
+ return operationsByTag.branchSchema.previewBranchSchemaEdit({
1238
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1239
+ body: migration,
1240
+ ...this.extraProps
1241
+ });
1242
+ }
1243
+ applyBranchSchemaEdit(workspace, database, branch, edits) {
1244
+ return operationsByTag.branchSchema.applyBranchSchemaEdit({
1245
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1246
+ body: { edits },
1247
+ ...this.extraProps
1248
+ });
1249
+ }
1250
+ getBranchSchemaHistory(workspace, database, branch, options = {}) {
1251
+ return operationsByTag.branchSchema.getBranchSchemaHistory({
1252
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1253
+ body: options,
1254
+ ...this.extraProps
1255
+ });
1256
+ }
898
1257
  }
899
1258
 
900
1259
  class XataApiPlugin {
@@ -920,18 +1279,18 @@ var __privateAdd$6 = (obj, member, value) => {
920
1279
  throw TypeError("Cannot add the same private member more than once");
921
1280
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
922
1281
  };
923
- var __privateSet$5 = (obj, member, value, setter) => {
1282
+ var __privateSet$6 = (obj, member, value, setter) => {
924
1283
  __accessCheck$6(obj, member, "write to private field");
925
1284
  setter ? setter.call(obj, value) : member.set(obj, value);
926
1285
  return value;
927
1286
  };
928
- var _query;
1287
+ var _query, _page;
929
1288
  class Page {
930
1289
  constructor(query, meta, records = []) {
931
1290
  __privateAdd$6(this, _query, void 0);
932
- __privateSet$5(this, _query, query);
1291
+ __privateSet$6(this, _query, query);
933
1292
  this.meta = meta;
934
- this.records = records;
1293
+ this.records = new RecordArray(this, records);
935
1294
  }
936
1295
  async nextPage(size, offset) {
937
1296
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
@@ -951,9 +1310,56 @@ class Page {
951
1310
  }
952
1311
  _query = new WeakMap();
953
1312
  const PAGINATION_MAX_SIZE = 200;
954
- const PAGINATION_DEFAULT_SIZE = 200;
1313
+ const PAGINATION_DEFAULT_SIZE = 20;
955
1314
  const PAGINATION_MAX_OFFSET = 800;
956
1315
  const PAGINATION_DEFAULT_OFFSET = 0;
1316
+ function isCursorPaginationOptions(options) {
1317
+ return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
1318
+ }
1319
+ const _RecordArray = class extends Array {
1320
+ constructor(...args) {
1321
+ super(..._RecordArray.parseConstructorParams(...args));
1322
+ __privateAdd$6(this, _page, void 0);
1323
+ __privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
1324
+ }
1325
+ static parseConstructorParams(...args) {
1326
+ if (args.length === 1 && typeof args[0] === "number") {
1327
+ return new Array(args[0]);
1328
+ }
1329
+ if (args.length <= 2 && isObject(args[0]?.meta) && Array.isArray(args[1] ?? [])) {
1330
+ const result = args[1] ?? args[0].records ?? [];
1331
+ return new Array(...result);
1332
+ }
1333
+ return new Array(...args);
1334
+ }
1335
+ toArray() {
1336
+ return new Array(...this);
1337
+ }
1338
+ map(callbackfn, thisArg) {
1339
+ return this.toArray().map(callbackfn, thisArg);
1340
+ }
1341
+ async nextPage(size, offset) {
1342
+ const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
1343
+ return new _RecordArray(newPage);
1344
+ }
1345
+ async previousPage(size, offset) {
1346
+ const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
1347
+ return new _RecordArray(newPage);
1348
+ }
1349
+ async firstPage(size, offset) {
1350
+ const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
1351
+ return new _RecordArray(newPage);
1352
+ }
1353
+ async lastPage(size, offset) {
1354
+ const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
1355
+ return new _RecordArray(newPage);
1356
+ }
1357
+ hasNextPage() {
1358
+ return __privateGet$6(this, _page).meta.page.more;
1359
+ }
1360
+ };
1361
+ let RecordArray = _RecordArray;
1362
+ _page = new WeakMap();
957
1363
 
958
1364
  var __accessCheck$5 = (obj, member, msg) => {
959
1365
  if (!member.has(obj))
@@ -968,25 +1374,26 @@ var __privateAdd$5 = (obj, member, value) => {
968
1374
  throw TypeError("Cannot add the same private member more than once");
969
1375
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
970
1376
  };
971
- var __privateSet$4 = (obj, member, value, setter) => {
1377
+ var __privateSet$5 = (obj, member, value, setter) => {
972
1378
  __accessCheck$5(obj, member, "write to private field");
973
1379
  setter ? setter.call(obj, value) : member.set(obj, value);
974
1380
  return value;
975
1381
  };
976
1382
  var _table$1, _repository, _data;
977
1383
  const _Query = class {
978
- constructor(repository, table, data, parent) {
1384
+ constructor(repository, table, data, rawParent) {
979
1385
  __privateAdd$5(this, _table$1, void 0);
980
1386
  __privateAdd$5(this, _repository, void 0);
981
1387
  __privateAdd$5(this, _data, { filter: {} });
982
1388
  this.meta = { page: { cursor: "start", more: true } };
983
- this.records = [];
984
- __privateSet$4(this, _table$1, table);
1389
+ this.records = new RecordArray(this, []);
1390
+ __privateSet$5(this, _table$1, table);
985
1391
  if (repository) {
986
- __privateSet$4(this, _repository, repository);
1392
+ __privateSet$5(this, _repository, repository);
987
1393
  } else {
988
- __privateSet$4(this, _repository, this);
1394
+ __privateSet$5(this, _repository, this);
989
1395
  }
1396
+ const parent = cleanParent(data, rawParent);
990
1397
  __privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
991
1398
  __privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
992
1399
  __privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
@@ -1031,55 +1438,93 @@ const _Query = class {
1031
1438
  }
1032
1439
  filter(a, b) {
1033
1440
  if (arguments.length === 1) {
1034
- const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
1441
+ const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
1442
+ [column]: this.cleanFilterConstraint(column, constraint)
1443
+ }));
1035
1444
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1036
1445
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1037
1446
  } else {
1038
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
1447
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.cleanFilterConstraint(a, b) }] : void 0;
1448
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1039
1449
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1040
1450
  }
1041
1451
  }
1042
- sort(column, direction) {
1452
+ cleanFilterConstraint(column, value) {
1453
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
1454
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
1455
+ return { $includes: value };
1456
+ }
1457
+ if (columnType === "link" && isObject(value) && isString(value.id)) {
1458
+ return value.id;
1459
+ }
1460
+ return value;
1461
+ }
1462
+ sort(column, direction = "asc") {
1043
1463
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1044
1464
  const sort = [...originalSort, { column, direction }];
1045
1465
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
1046
1466
  }
1047
1467
  select(columns) {
1048
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { columns }, __privateGet$5(this, _data));
1468
+ return new _Query(
1469
+ __privateGet$5(this, _repository),
1470
+ __privateGet$5(this, _table$1),
1471
+ { columns },
1472
+ __privateGet$5(this, _data)
1473
+ );
1049
1474
  }
1050
1475
  getPaginated(options = {}) {
1051
1476
  const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
1052
1477
  return __privateGet$5(this, _repository).query(query);
1053
1478
  }
1054
1479
  async *[Symbol.asyncIterator]() {
1055
- for await (const [record] of this.getIterator(1)) {
1480
+ for await (const [record] of this.getIterator({ batchSize: 1 })) {
1056
1481
  yield record;
1057
1482
  }
1058
1483
  }
1059
- async *getIterator(chunk, options = {}) {
1060
- let offset = 0;
1061
- let end = false;
1062
- while (!end) {
1063
- const { records, meta } = await this.getPaginated({ ...options, pagination: { size: chunk, offset } });
1064
- yield records;
1065
- offset += chunk;
1066
- end = !meta.page.more;
1484
+ async *getIterator(options = {}) {
1485
+ const { batchSize = 1 } = options;
1486
+ let page = await this.getPaginated({ ...options, pagination: { size: batchSize, offset: 0 } });
1487
+ let more = page.hasNextPage();
1488
+ yield page.records;
1489
+ while (more) {
1490
+ page = await page.nextPage();
1491
+ more = page.hasNextPage();
1492
+ yield page.records;
1067
1493
  }
1068
1494
  }
1069
1495
  async getMany(options = {}) {
1070
- const { records } = await this.getPaginated(options);
1071
- return records;
1496
+ const { pagination = {}, ...rest } = options;
1497
+ const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
1498
+ const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
1499
+ let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
1500
+ const results = [...page.records];
1501
+ while (page.hasNextPage() && results.length < size) {
1502
+ page = await page.nextPage();
1503
+ results.push(...page.records);
1504
+ }
1505
+ if (page.hasNextPage() && options.pagination?.size === void 0) {
1506
+ console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
1507
+ }
1508
+ const array = new RecordArray(page, results.slice(0, size));
1509
+ return array;
1072
1510
  }
1073
- async getAll(chunk = PAGINATION_MAX_SIZE, options = {}) {
1511
+ async getAll(options = {}) {
1512
+ const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
1074
1513
  const results = [];
1075
- for await (const page of this.getIterator(chunk, options)) {
1514
+ for await (const page of this.getIterator({ ...rest, batchSize })) {
1076
1515
  results.push(...page);
1077
1516
  }
1078
1517
  return results;
1079
1518
  }
1080
1519
  async getFirst(options = {}) {
1081
1520
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
1082
- return records[0] || null;
1521
+ return records[0] ?? null;
1522
+ }
1523
+ async getFirstOrThrow(options = {}) {
1524
+ const records = await this.getMany({ ...options, pagination: { size: 1 } });
1525
+ if (records[0] === void 0)
1526
+ throw new Error("No results found.");
1527
+ return records[0];
1083
1528
  }
1084
1529
  cache(ttl) {
1085
1530
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
@@ -1104,12 +1549,20 @@ let Query = _Query;
1104
1549
  _table$1 = new WeakMap();
1105
1550
  _repository = new WeakMap();
1106
1551
  _data = new WeakMap();
1552
+ function cleanParent(data, parent) {
1553
+ if (isCursorPaginationOptions(data.pagination)) {
1554
+ return { ...parent, sorting: void 0, filter: void 0 };
1555
+ }
1556
+ return parent;
1557
+ }
1107
1558
 
1108
1559
  function isIdentifiable(x) {
1109
1560
  return isObject(x) && isString(x?.id);
1110
1561
  }
1111
1562
  function isXataRecord(x) {
1112
- return isIdentifiable(x) && typeof x?.xata === "object" && typeof x?.xata?.version === "number";
1563
+ const record = x;
1564
+ const metadata = record?.getMetadata();
1565
+ return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
1113
1566
  }
1114
1567
 
1115
1568
  function isSortFilterString(value) {
@@ -1148,7 +1601,7 @@ var __privateAdd$4 = (obj, member, value) => {
1148
1601
  throw TypeError("Cannot add the same private member more than once");
1149
1602
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1150
1603
  };
1151
- var __privateSet$3 = (obj, member, value, setter) => {
1604
+ var __privateSet$4 = (obj, member, value, setter) => {
1152
1605
  __accessCheck$4(obj, member, "write to private field");
1153
1606
  setter ? setter.call(obj, value) : member.set(obj, value);
1154
1607
  return value;
@@ -1157,180 +1610,284 @@ var __privateMethod$2 = (obj, member, method) => {
1157
1610
  __accessCheck$4(obj, member, "access private method");
1158
1611
  return method;
1159
1612
  };
1160
- var _table, _getFetchProps, _cache, _schema$1, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _invalidateCache, invalidateCache_fn, _setCacheRecord, setCacheRecord_fn, _getCacheRecord, getCacheRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchema$1, getSchema_fn$1;
1613
+ 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;
1161
1614
  class Repository extends Query {
1162
1615
  }
1163
1616
  class RestRepository extends Query {
1164
1617
  constructor(options) {
1165
- super(null, options.table, {});
1618
+ super(
1619
+ null,
1620
+ { name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
1621
+ {}
1622
+ );
1166
1623
  __privateAdd$4(this, _insertRecordWithoutId);
1167
1624
  __privateAdd$4(this, _insertRecordWithId);
1168
1625
  __privateAdd$4(this, _bulkInsertTableRecords);
1169
1626
  __privateAdd$4(this, _updateRecordWithID);
1170
1627
  __privateAdd$4(this, _upsertRecordWithID);
1171
1628
  __privateAdd$4(this, _deleteRecord);
1172
- __privateAdd$4(this, _invalidateCache);
1173
- __privateAdd$4(this, _setCacheRecord);
1174
- __privateAdd$4(this, _getCacheRecord);
1175
1629
  __privateAdd$4(this, _setCacheQuery);
1176
1630
  __privateAdd$4(this, _getCacheQuery);
1177
- __privateAdd$4(this, _getSchema$1);
1631
+ __privateAdd$4(this, _getSchemaTables$1);
1178
1632
  __privateAdd$4(this, _table, void 0);
1179
1633
  __privateAdd$4(this, _getFetchProps, void 0);
1634
+ __privateAdd$4(this, _db, void 0);
1180
1635
  __privateAdd$4(this, _cache, void 0);
1181
- __privateAdd$4(this, _schema$1, void 0);
1182
- __privateSet$3(this, _table, options.table);
1183
- __privateSet$3(this, _getFetchProps, options.pluginOptions.getFetchProps);
1184
- this.db = options.db;
1185
- __privateSet$3(this, _cache, options.pluginOptions.cache);
1186
- }
1187
- async create(a, b) {
1188
- if (Array.isArray(a)) {
1189
- const records = await __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a);
1190
- await Promise.all(records.map((record) => __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record)));
1191
- return records;
1192
- }
1193
- if (isString(a) && isObject(b)) {
1194
- if (a === "")
1195
- throw new Error("The id can't be empty");
1196
- const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b);
1197
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1198
- return record;
1199
- }
1200
- if (isObject(a) && isString(a.id)) {
1201
- if (a.id === "")
1202
- throw new Error("The id can't be empty");
1203
- const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 });
1204
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1205
- return record;
1206
- }
1207
- if (isObject(a)) {
1208
- const record = await __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a);
1209
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1210
- return record;
1211
- }
1212
- throw new Error("Invalid arguments for create method");
1213
- }
1214
- async read(recordId) {
1215
- const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, recordId);
1216
- if (cacheRecord)
1217
- return cacheRecord;
1218
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1219
- try {
1220
- const response = await getRecord({
1221
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1222
- ...fetchProps
1636
+ __privateAdd$4(this, _schemaTables$2, void 0);
1637
+ __privateAdd$4(this, _trace, void 0);
1638
+ __privateSet$4(this, _table, options.table);
1639
+ __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1640
+ __privateSet$4(this, _db, options.db);
1641
+ __privateSet$4(this, _cache, options.pluginOptions.cache);
1642
+ __privateSet$4(this, _schemaTables$2, options.schemaTables);
1643
+ const trace = options.pluginOptions.trace ?? defaultTrace;
1644
+ __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
1645
+ return trace(name, fn, {
1646
+ ...options2,
1647
+ [TraceAttributes.TABLE]: __privateGet$4(this, _table),
1648
+ [TraceAttributes.KIND]: "sdk-operation",
1649
+ [TraceAttributes.VERSION]: VERSION
1223
1650
  });
1224
- const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1225
- return initObject(this.db, schema, __privateGet$4(this, _table), response);
1226
- } catch (e) {
1227
- if (isObject(e) && e.status === 404) {
1228
- return null;
1651
+ });
1652
+ }
1653
+ async create(a, b, c) {
1654
+ return __privateGet$4(this, _trace).call(this, "create", async () => {
1655
+ if (Array.isArray(a)) {
1656
+ if (a.length === 0)
1657
+ return [];
1658
+ const columns = isStringArray(b) ? b : void 0;
1659
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
1229
1660
  }
1230
- throw e;
1231
- }
1661
+ if (isString(a) && isObject(b)) {
1662
+ if (a === "")
1663
+ throw new Error("The id can't be empty");
1664
+ const columns = isStringArray(c) ? c : void 0;
1665
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
1666
+ }
1667
+ if (isObject(a) && isString(a.id)) {
1668
+ if (a.id === "")
1669
+ throw new Error("The id can't be empty");
1670
+ const columns = isStringArray(b) ? b : void 0;
1671
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1672
+ }
1673
+ if (isObject(a)) {
1674
+ const columns = isStringArray(b) ? b : void 0;
1675
+ return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
1676
+ }
1677
+ throw new Error("Invalid arguments for create method");
1678
+ });
1232
1679
  }
1233
- async update(a, b) {
1234
- if (Array.isArray(a)) {
1235
- if (a.length > 100) {
1236
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1680
+ async read(a, b) {
1681
+ return __privateGet$4(this, _trace).call(this, "read", async () => {
1682
+ const columns = isStringArray(b) ? b : ["*"];
1683
+ if (Array.isArray(a)) {
1684
+ if (a.length === 0)
1685
+ return [];
1686
+ const ids = a.map((item) => extractId(item));
1687
+ const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
1688
+ const dictionary = finalObjects.reduce((acc, object) => {
1689
+ acc[object.id] = object;
1690
+ return acc;
1691
+ }, {});
1692
+ return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
1237
1693
  }
1238
- return Promise.all(a.map((object) => this.update(object)));
1239
- }
1240
- if (isString(a) && isObject(b)) {
1241
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1242
- const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b);
1243
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1244
- return record;
1245
- }
1246
- if (isObject(a) && isString(a.id)) {
1247
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1248
- const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1249
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1250
- return record;
1251
- }
1252
- throw new Error("Invalid arguments for update method");
1694
+ const id = extractId(a);
1695
+ if (id) {
1696
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1697
+ try {
1698
+ const response = await getRecord({
1699
+ pathParams: {
1700
+ workspace: "{workspaceId}",
1701
+ dbBranchName: "{dbBranch}",
1702
+ tableName: __privateGet$4(this, _table),
1703
+ recordId: id
1704
+ },
1705
+ queryParams: { columns },
1706
+ ...fetchProps
1707
+ });
1708
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1709
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1710
+ } catch (e) {
1711
+ if (isObject(e) && e.status === 404) {
1712
+ return null;
1713
+ }
1714
+ throw e;
1715
+ }
1716
+ }
1717
+ return null;
1718
+ });
1253
1719
  }
1254
- async createOrUpdate(a, b) {
1255
- if (Array.isArray(a)) {
1256
- if (a.length > 100) {
1257
- console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1720
+ async readOrThrow(a, b) {
1721
+ return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
1722
+ const result = await this.read(a, b);
1723
+ if (Array.isArray(result)) {
1724
+ const missingIds = compact(
1725
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1726
+ );
1727
+ if (missingIds.length > 0) {
1728
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1729
+ }
1730
+ return result;
1258
1731
  }
1259
- return Promise.all(a.map((object) => this.createOrUpdate(object)));
1260
- }
1261
- if (isString(a) && isObject(b)) {
1262
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1263
- const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b);
1264
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1265
- return record;
1266
- }
1267
- if (isObject(a) && isString(a.id)) {
1268
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1269
- const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1270
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1271
- return record;
1272
- }
1273
- throw new Error("Invalid arguments for createOrUpdate method");
1732
+ if (result === null) {
1733
+ const id = extractId(a) ?? "unknown";
1734
+ throw new Error(`Record with id ${id} not found`);
1735
+ }
1736
+ return result;
1737
+ });
1274
1738
  }
1275
- async delete(a) {
1276
- if (Array.isArray(a)) {
1277
- if (a.length > 100) {
1278
- console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1739
+ async update(a, b, c) {
1740
+ return __privateGet$4(this, _trace).call(this, "update", async () => {
1741
+ if (Array.isArray(a)) {
1742
+ if (a.length === 0)
1743
+ return [];
1744
+ if (a.length > 100) {
1745
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1746
+ }
1747
+ const columns = isStringArray(b) ? b : ["*"];
1748
+ return Promise.all(a.map((object) => this.update(object, columns)));
1279
1749
  }
1280
- await Promise.all(a.map((id) => this.delete(id)));
1281
- return;
1282
- }
1283
- if (isString(a)) {
1284
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
1285
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1286
- return;
1287
- }
1288
- if (isObject(a) && isString(a.id)) {
1289
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
1290
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1291
- return;
1292
- }
1293
- throw new Error("Invalid arguments for delete method");
1750
+ if (isString(a) && isObject(b)) {
1751
+ const columns = isStringArray(c) ? c : void 0;
1752
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
1753
+ }
1754
+ if (isObject(a) && isString(a.id)) {
1755
+ const columns = isStringArray(b) ? b : void 0;
1756
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1757
+ }
1758
+ throw new Error("Invalid arguments for update method");
1759
+ });
1760
+ }
1761
+ async updateOrThrow(a, b, c) {
1762
+ return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
1763
+ const result = await this.update(a, b, c);
1764
+ if (Array.isArray(result)) {
1765
+ const missingIds = compact(
1766
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1767
+ );
1768
+ if (missingIds.length > 0) {
1769
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1770
+ }
1771
+ return result;
1772
+ }
1773
+ if (result === null) {
1774
+ const id = extractId(a) ?? "unknown";
1775
+ throw new Error(`Record with id ${id} not found`);
1776
+ }
1777
+ return result;
1778
+ });
1779
+ }
1780
+ async createOrUpdate(a, b, c) {
1781
+ return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
1782
+ if (Array.isArray(a)) {
1783
+ if (a.length === 0)
1784
+ return [];
1785
+ if (a.length > 100) {
1786
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1787
+ }
1788
+ const columns = isStringArray(b) ? b : ["*"];
1789
+ return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
1790
+ }
1791
+ if (isString(a) && isObject(b)) {
1792
+ const columns = isStringArray(c) ? c : void 0;
1793
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
1794
+ }
1795
+ if (isObject(a) && isString(a.id)) {
1796
+ const columns = isStringArray(c) ? c : void 0;
1797
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1798
+ }
1799
+ throw new Error("Invalid arguments for createOrUpdate method");
1800
+ });
1801
+ }
1802
+ async delete(a, b) {
1803
+ return __privateGet$4(this, _trace).call(this, "delete", async () => {
1804
+ if (Array.isArray(a)) {
1805
+ if (a.length === 0)
1806
+ return [];
1807
+ if (a.length > 100) {
1808
+ console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1809
+ }
1810
+ return Promise.all(a.map((id) => this.delete(id, b)));
1811
+ }
1812
+ if (isString(a)) {
1813
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
1814
+ }
1815
+ if (isObject(a) && isString(a.id)) {
1816
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
1817
+ }
1818
+ throw new Error("Invalid arguments for delete method");
1819
+ });
1820
+ }
1821
+ async deleteOrThrow(a, b) {
1822
+ return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
1823
+ const result = await this.delete(a, b);
1824
+ if (Array.isArray(result)) {
1825
+ const missingIds = compact(
1826
+ a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
1827
+ );
1828
+ if (missingIds.length > 0) {
1829
+ throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
1830
+ }
1831
+ return result;
1832
+ } else if (result === null) {
1833
+ const id = extractId(a) ?? "unknown";
1834
+ throw new Error(`Record with id ${id} not found`);
1835
+ }
1836
+ return result;
1837
+ });
1294
1838
  }
1295
1839
  async search(query, options = {}) {
1296
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1297
- const { records } = await searchBranch({
1298
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1299
- body: { tables: [__privateGet$4(this, _table)], query, fuzziness: options.fuzziness },
1300
- ...fetchProps
1840
+ return __privateGet$4(this, _trace).call(this, "search", async () => {
1841
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1842
+ const { records } = await searchTable({
1843
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1844
+ body: {
1845
+ query,
1846
+ fuzziness: options.fuzziness,
1847
+ prefix: options.prefix,
1848
+ highlight: options.highlight,
1849
+ filter: options.filter,
1850
+ boosters: options.boosters
1851
+ },
1852
+ ...fetchProps
1853
+ });
1854
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1855
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
1301
1856
  });
1302
- const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1303
- return records.map((item) => initObject(this.db, schema, __privateGet$4(this, _table), item));
1304
1857
  }
1305
1858
  async query(query) {
1306
- const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1307
- if (cacheQuery)
1308
- return new Page(query, cacheQuery.meta, cacheQuery.records);
1309
- const data = query.getQueryOptions();
1310
- const body = {
1311
- filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1312
- sort: data.sort ? buildSortFilter(data.sort) : void 0,
1313
- page: data.pagination,
1314
- columns: data.columns
1315
- };
1316
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1317
- const { meta, records: objects } = await queryTable({
1318
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1319
- body,
1320
- ...fetchProps
1859
+ return __privateGet$4(this, _trace).call(this, "query", async () => {
1860
+ const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1861
+ if (cacheQuery)
1862
+ return new Page(query, cacheQuery.meta, cacheQuery.records);
1863
+ const data = query.getQueryOptions();
1864
+ const body = {
1865
+ filter: cleanFilter(data.filter),
1866
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1867
+ page: data.pagination,
1868
+ columns: data.columns
1869
+ };
1870
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1871
+ const { meta, records: objects } = await queryTable({
1872
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1873
+ body,
1874
+ ...fetchProps
1875
+ });
1876
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1877
+ const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
1878
+ await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1879
+ return new Page(query, meta, records);
1321
1880
  });
1322
- const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1323
- const records = objects.map((record) => initObject(this.db, schema, __privateGet$4(this, _table), record));
1324
- await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1325
- return new Page(query, meta, records);
1326
1881
  }
1327
1882
  }
1328
1883
  _table = new WeakMap();
1329
1884
  _getFetchProps = new WeakMap();
1885
+ _db = new WeakMap();
1330
1886
  _cache = new WeakMap();
1331
- _schema$1 = new WeakMap();
1887
+ _schemaTables$2 = new WeakMap();
1888
+ _trace = new WeakMap();
1332
1889
  _insertRecordWithoutId = new WeakSet();
1333
- insertRecordWithoutId_fn = async function(object) {
1890
+ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1334
1891
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1335
1892
  const record = transformObjectLinks(object);
1336
1893
  const response = await insertRecord({
@@ -1339,17 +1896,15 @@ insertRecordWithoutId_fn = async function(object) {
1339
1896
  dbBranchName: "{dbBranch}",
1340
1897
  tableName: __privateGet$4(this, _table)
1341
1898
  },
1899
+ queryParams: { columns },
1342
1900
  body: record,
1343
1901
  ...fetchProps
1344
1902
  });
1345
- const finalObject = await this.read(response.id);
1346
- if (!finalObject) {
1347
- throw new Error("The server failed to save the record");
1348
- }
1349
- return finalObject;
1903
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1904
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1350
1905
  };
1351
1906
  _insertRecordWithId = new WeakSet();
1352
- insertRecordWithId_fn = async function(recordId, object) {
1907
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
1353
1908
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1354
1909
  const record = transformObjectLinks(object);
1355
1910
  const response = await insertRecordWithID({
@@ -1360,88 +1915,78 @@ insertRecordWithId_fn = async function(recordId, object) {
1360
1915
  recordId
1361
1916
  },
1362
1917
  body: record,
1363
- queryParams: { createOnly: true },
1918
+ queryParams: { createOnly: true, columns },
1364
1919
  ...fetchProps
1365
1920
  });
1366
- const finalObject = await this.read(response.id);
1367
- if (!finalObject) {
1368
- throw new Error("The server failed to save the record");
1369
- }
1370
- return finalObject;
1921
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1922
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1371
1923
  };
1372
1924
  _bulkInsertTableRecords = new WeakSet();
1373
- bulkInsertTableRecords_fn = async function(objects) {
1925
+ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1374
1926
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1375
1927
  const records = objects.map((object) => transformObjectLinks(object));
1376
1928
  const response = await bulkInsertTableRecords({
1377
1929
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1930
+ queryParams: { columns },
1378
1931
  body: { records },
1379
1932
  ...fetchProps
1380
1933
  });
1381
- const finalObjects = await this.any(...response.recordIDs.map((id) => this.filter("id", id))).getAll();
1382
- if (finalObjects.length !== objects.length) {
1383
- throw new Error("The server failed to save some records");
1934
+ if (!isResponseWithRecords(response)) {
1935
+ throw new Error("Request included columns but server didn't include them");
1384
1936
  }
1385
- return finalObjects;
1937
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1938
+ return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
1386
1939
  };
1387
1940
  _updateRecordWithID = new WeakSet();
1388
- updateRecordWithID_fn = async function(recordId, object) {
1941
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1389
1942
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1390
1943
  const record = transformObjectLinks(object);
1391
- const response = await updateRecordWithID({
1392
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1393
- body: record,
1394
- ...fetchProps
1395
- });
1396
- const item = await this.read(response.id);
1397
- if (!item)
1398
- throw new Error("The server failed to save the record");
1399
- return item;
1944
+ try {
1945
+ const response = await updateRecordWithID({
1946
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1947
+ queryParams: { columns },
1948
+ body: record,
1949
+ ...fetchProps
1950
+ });
1951
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1952
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1953
+ } catch (e) {
1954
+ if (isObject(e) && e.status === 404) {
1955
+ return null;
1956
+ }
1957
+ throw e;
1958
+ }
1400
1959
  };
1401
1960
  _upsertRecordWithID = new WeakSet();
1402
- upsertRecordWithID_fn = async function(recordId, object) {
1961
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1403
1962
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1404
1963
  const response = await upsertRecordWithID({
1405
1964
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1965
+ queryParams: { columns },
1406
1966
  body: object,
1407
1967
  ...fetchProps
1408
1968
  });
1409
- const item = await this.read(response.id);
1410
- if (!item)
1411
- throw new Error("The server failed to save the record");
1412
- return item;
1969
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1970
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1413
1971
  };
1414
1972
  _deleteRecord = new WeakSet();
1415
- deleteRecord_fn = async function(recordId) {
1973
+ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1416
1974
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1417
- await deleteRecord({
1418
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1419
- ...fetchProps
1420
- });
1421
- };
1422
- _invalidateCache = new WeakSet();
1423
- invalidateCache_fn = async function(recordId) {
1424
- await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1425
- const cacheItems = await __privateGet$4(this, _cache).getAll();
1426
- const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
1427
- for (const [key, value] of queries) {
1428
- const ids = getIds(value);
1429
- if (ids.includes(recordId))
1430
- await __privateGet$4(this, _cache).delete(key);
1975
+ try {
1976
+ const response = await deleteRecord({
1977
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1978
+ queryParams: { columns },
1979
+ ...fetchProps
1980
+ });
1981
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1982
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1983
+ } catch (e) {
1984
+ if (isObject(e) && e.status === 404) {
1985
+ return null;
1986
+ }
1987
+ throw e;
1431
1988
  }
1432
1989
  };
1433
- _setCacheRecord = new WeakSet();
1434
- setCacheRecord_fn = async function(record) {
1435
- if (!__privateGet$4(this, _cache).cacheRecords)
1436
- return;
1437
- await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
1438
- };
1439
- _getCacheRecord = new WeakSet();
1440
- getCacheRecord_fn = async function(recordId) {
1441
- if (!__privateGet$4(this, _cache).cacheRecords)
1442
- return null;
1443
- return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1444
- };
1445
1990
  _setCacheQuery = new WeakSet();
1446
1991
  setCacheQuery_fn = async function(query, meta, records) {
1447
1992
  await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
@@ -1453,22 +1998,22 @@ getCacheQuery_fn = async function(query) {
1453
1998
  if (!result)
1454
1999
  return null;
1455
2000
  const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
1456
- if (!ttl || ttl < 0)
1457
- return result;
2001
+ if (ttl < 0)
2002
+ return null;
1458
2003
  const hasExpired = result.date.getTime() + ttl < Date.now();
1459
2004
  return hasExpired ? null : result;
1460
2005
  };
1461
- _getSchema$1 = new WeakSet();
1462
- getSchema_fn$1 = async function() {
1463
- if (__privateGet$4(this, _schema$1))
1464
- return __privateGet$4(this, _schema$1);
2006
+ _getSchemaTables$1 = new WeakSet();
2007
+ getSchemaTables_fn$1 = async function() {
2008
+ if (__privateGet$4(this, _schemaTables$2))
2009
+ return __privateGet$4(this, _schemaTables$2);
1465
2010
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1466
2011
  const { schema } = await getBranchDetails({
1467
2012
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1468
2013
  ...fetchProps
1469
2014
  });
1470
- __privateSet$3(this, _schema$1, schema);
1471
- return schema;
2015
+ __privateSet$4(this, _schemaTables$2, schema.tables);
2016
+ return schema.tables;
1472
2017
  };
1473
2018
  const transformObjectLinks = (object) => {
1474
2019
  return Object.entries(object).reduce((acc, [key, value]) => {
@@ -1477,20 +2022,21 @@ const transformObjectLinks = (object) => {
1477
2022
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
1478
2023
  }, {});
1479
2024
  };
1480
- const initObject = (db, schema, table, object) => {
2025
+ const initObject = (db, schemaTables, table, object) => {
1481
2026
  const result = {};
1482
- Object.assign(result, object);
1483
- const { columns } = schema.tables.find(({ name }) => name === table) ?? {};
2027
+ const { xata, ...rest } = object ?? {};
2028
+ Object.assign(result, rest);
2029
+ const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
1484
2030
  if (!columns)
1485
2031
  console.error(`Table ${table} not found in schema`);
1486
2032
  for (const column of columns ?? []) {
1487
2033
  const value = result[column.name];
1488
2034
  switch (column.type) {
1489
2035
  case "datetime": {
1490
- const date = new Date(value);
1491
- if (isNaN(date.getTime())) {
2036
+ const date = value !== void 0 ? new Date(value) : void 0;
2037
+ if (date && isNaN(date.getTime())) {
1492
2038
  console.error(`Failed to parse date ${value} for field ${column.name}`);
1493
- } else {
2039
+ } else if (date) {
1494
2040
  result[column.name] = date;
1495
2041
  }
1496
2042
  break;
@@ -1499,36 +2045,54 @@ const initObject = (db, schema, table, object) => {
1499
2045
  const linkTable = column.link?.table;
1500
2046
  if (!linkTable) {
1501
2047
  console.error(`Failed to parse link for field ${column.name}`);
1502
- } else if (value && isObject(value)) {
1503
- result[column.name] = initObject(db, schema, linkTable, value);
2048
+ } else if (isObject(value)) {
2049
+ result[column.name] = initObject(db, schemaTables, linkTable, value);
2050
+ } else {
2051
+ result[column.name] = null;
1504
2052
  }
1505
2053
  break;
1506
2054
  }
2055
+ default:
2056
+ result[column.name] = value ?? null;
2057
+ if (column.notNull === true && value === null) {
2058
+ console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2059
+ }
2060
+ break;
1507
2061
  }
1508
2062
  }
1509
- result.read = function() {
1510
- return db[table].read(result["id"]);
2063
+ result.read = function(columns2) {
2064
+ return db[table].read(result["id"], columns2);
1511
2065
  };
1512
- result.update = function(data) {
1513
- return db[table].update(result["id"], data);
2066
+ result.update = function(data, columns2) {
2067
+ return db[table].update(result["id"], data, columns2);
1514
2068
  };
1515
2069
  result.delete = function() {
1516
2070
  return db[table].delete(result["id"]);
1517
2071
  };
1518
- for (const prop of ["read", "update", "delete"]) {
2072
+ result.getMetadata = function() {
2073
+ return xata;
2074
+ };
2075
+ for (const prop of ["read", "update", "delete", "getMetadata"]) {
1519
2076
  Object.defineProperty(result, prop, { enumerable: false });
1520
2077
  }
1521
2078
  Object.freeze(result);
1522
2079
  return result;
1523
2080
  };
1524
- function getIds(value) {
1525
- if (Array.isArray(value)) {
1526
- return value.map((item) => getIds(item)).flat();
1527
- }
1528
- if (!isObject(value))
1529
- return [];
1530
- const nestedIds = Object.values(value).map((item) => getIds(item)).flat();
1531
- return isString(value.id) ? [value.id, ...nestedIds] : nestedIds;
2081
+ function isResponseWithRecords(value) {
2082
+ return isObject(value) && Array.isArray(value.records);
2083
+ }
2084
+ function extractId(value) {
2085
+ if (isString(value))
2086
+ return value;
2087
+ if (isObject(value) && isString(value.id))
2088
+ return value.id;
2089
+ return void 0;
2090
+ }
2091
+ function cleanFilter(filter) {
2092
+ if (!filter)
2093
+ return void 0;
2094
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2095
+ return values.length > 0 ? filter : void 0;
1532
2096
  }
1533
2097
 
1534
2098
  var __accessCheck$3 = (obj, member, msg) => {
@@ -1544,7 +2108,7 @@ var __privateAdd$3 = (obj, member, value) => {
1544
2108
  throw TypeError("Cannot add the same private member more than once");
1545
2109
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1546
2110
  };
1547
- var __privateSet$2 = (obj, member, value, setter) => {
2111
+ var __privateSet$3 = (obj, member, value, setter) => {
1548
2112
  __accessCheck$3(obj, member, "write to private field");
1549
2113
  setter ? setter.call(obj, value) : member.set(obj, value);
1550
2114
  return value;
@@ -1553,9 +2117,8 @@ var _map;
1553
2117
  class SimpleCache {
1554
2118
  constructor(options = {}) {
1555
2119
  __privateAdd$3(this, _map, void 0);
1556
- __privateSet$2(this, _map, /* @__PURE__ */ new Map());
2120
+ __privateSet$3(this, _map, /* @__PURE__ */ new Map());
1557
2121
  this.capacity = options.max ?? 500;
1558
- this.cacheRecords = options.cacheRecords ?? true;
1559
2122
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
1560
2123
  }
1561
2124
  async getAll() {
@@ -1581,18 +2144,25 @@ class SimpleCache {
1581
2144
  }
1582
2145
  _map = new WeakMap();
1583
2146
 
1584
- const gt = (value) => ({ $gt: value });
1585
- const ge = (value) => ({ $ge: value });
1586
- const gte = (value) => ({ $ge: value });
1587
- const lt = (value) => ({ $lt: value });
1588
- const lte = (value) => ({ $le: value });
1589
- const le = (value) => ({ $le: value });
2147
+ const greaterThan = (value) => ({ $gt: value });
2148
+ const gt = greaterThan;
2149
+ const greaterThanEquals = (value) => ({ $ge: value });
2150
+ const greaterEquals = greaterThanEquals;
2151
+ const gte = greaterThanEquals;
2152
+ const ge = greaterThanEquals;
2153
+ const lessThan = (value) => ({ $lt: value });
2154
+ const lt = lessThan;
2155
+ const lessThanEquals = (value) => ({ $le: value });
2156
+ const lessEquals = lessThanEquals;
2157
+ const lte = lessThanEquals;
2158
+ const le = lessThanEquals;
1590
2159
  const exists = (column) => ({ $exists: column });
1591
2160
  const notExists = (column) => ({ $notExists: column });
1592
2161
  const startsWith = (value) => ({ $startsWith: value });
1593
2162
  const endsWith = (value) => ({ $endsWith: value });
1594
2163
  const pattern = (value) => ({ $pattern: value });
1595
2164
  const is = (value) => ({ $is: value });
2165
+ const equals = is;
1596
2166
  const isNot = (value) => ({ $isNot: value });
1597
2167
  const contains = (value) => ({ $contains: value });
1598
2168
  const includes = (value) => ({ $includes: value });
@@ -1613,31 +2183,42 @@ var __privateAdd$2 = (obj, member, value) => {
1613
2183
  throw TypeError("Cannot add the same private member more than once");
1614
2184
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1615
2185
  };
1616
- var _tables;
2186
+ var __privateSet$2 = (obj, member, value, setter) => {
2187
+ __accessCheck$2(obj, member, "write to private field");
2188
+ setter ? setter.call(obj, value) : member.set(obj, value);
2189
+ return value;
2190
+ };
2191
+ var _tables, _schemaTables$1;
1617
2192
  class SchemaPlugin extends XataPlugin {
1618
- constructor(tableNames) {
2193
+ constructor(schemaTables) {
1619
2194
  super();
1620
- this.tableNames = tableNames;
1621
2195
  __privateAdd$2(this, _tables, {});
2196
+ __privateAdd$2(this, _schemaTables$1, void 0);
2197
+ __privateSet$2(this, _schemaTables$1, schemaTables);
1622
2198
  }
1623
2199
  build(pluginOptions) {
1624
- const db = new Proxy({}, {
1625
- get: (_target, table) => {
1626
- if (!isString(table))
1627
- throw new Error("Invalid table name");
1628
- if (!__privateGet$2(this, _tables)[table]) {
1629
- __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
2200
+ const db = new Proxy(
2201
+ {},
2202
+ {
2203
+ get: (_target, table) => {
2204
+ if (!isString(table))
2205
+ throw new Error("Invalid table name");
2206
+ if (__privateGet$2(this, _tables)[table] === void 0) {
2207
+ __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
2208
+ }
2209
+ return __privateGet$2(this, _tables)[table];
1630
2210
  }
1631
- return __privateGet$2(this, _tables)[table];
1632
2211
  }
1633
- });
1634
- for (const table of this.tableNames ?? []) {
1635
- db[table] = new RestRepository({ db, pluginOptions, table });
2212
+ );
2213
+ const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
2214
+ for (const table of tableNames) {
2215
+ db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
1636
2216
  }
1637
2217
  return db;
1638
2218
  }
1639
2219
  }
1640
2220
  _tables = new WeakMap();
2221
+ _schemaTables$1 = new WeakMap();
1641
2222
 
1642
2223
  var __accessCheck$1 = (obj, member, msg) => {
1643
2224
  if (!member.has(obj))
@@ -1661,105 +2242,119 @@ var __privateMethod$1 = (obj, member, method) => {
1661
2242
  __accessCheck$1(obj, member, "access private method");
1662
2243
  return method;
1663
2244
  };
1664
- var _schema, _search, search_fn, _getSchema, getSchema_fn;
2245
+ var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
1665
2246
  class SearchPlugin extends XataPlugin {
1666
- constructor(db) {
2247
+ constructor(db, schemaTables) {
1667
2248
  super();
1668
2249
  this.db = db;
1669
2250
  __privateAdd$1(this, _search);
1670
- __privateAdd$1(this, _getSchema);
1671
- __privateAdd$1(this, _schema, void 0);
2251
+ __privateAdd$1(this, _getSchemaTables);
2252
+ __privateAdd$1(this, _schemaTables, void 0);
2253
+ __privateSet$1(this, _schemaTables, schemaTables);
1672
2254
  }
1673
2255
  build({ getFetchProps }) {
1674
2256
  return {
1675
2257
  all: async (query, options = {}) => {
1676
2258
  const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
1677
- const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
2259
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
1678
2260
  return records.map((record) => {
1679
2261
  const { table = "orphan" } = record.xata;
1680
- return { table, record: initObject(this.db, schema, table, record) };
2262
+ return { table, record: initObject(this.db, schemaTables, table, record) };
1681
2263
  });
1682
2264
  },
1683
2265
  byTable: async (query, options = {}) => {
1684
2266
  const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
1685
- const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
2267
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
1686
2268
  return records.reduce((acc, record) => {
1687
2269
  const { table = "orphan" } = record.xata;
1688
2270
  const items = acc[table] ?? [];
1689
- const item = initObject(this.db, schema, table, record);
2271
+ const item = initObject(this.db, schemaTables, table, record);
1690
2272
  return { ...acc, [table]: [...items, item] };
1691
2273
  }, {});
1692
2274
  }
1693
2275
  };
1694
2276
  }
1695
2277
  }
1696
- _schema = new WeakMap();
2278
+ _schemaTables = new WeakMap();
1697
2279
  _search = new WeakSet();
1698
2280
  search_fn = async function(query, options, getFetchProps) {
1699
2281
  const fetchProps = await getFetchProps();
1700
- const { tables, fuzziness } = options ?? {};
2282
+ const { tables, fuzziness, highlight, prefix } = options ?? {};
1701
2283
  const { records } = await searchBranch({
1702
2284
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1703
- body: { tables, query, fuzziness },
2285
+ body: { tables, query, fuzziness, prefix, highlight },
1704
2286
  ...fetchProps
1705
2287
  });
1706
2288
  return records;
1707
2289
  };
1708
- _getSchema = new WeakSet();
1709
- getSchema_fn = async function(getFetchProps) {
1710
- if (__privateGet$1(this, _schema))
1711
- return __privateGet$1(this, _schema);
2290
+ _getSchemaTables = new WeakSet();
2291
+ getSchemaTables_fn = async function(getFetchProps) {
2292
+ if (__privateGet$1(this, _schemaTables))
2293
+ return __privateGet$1(this, _schemaTables);
1712
2294
  const fetchProps = await getFetchProps();
1713
2295
  const { schema } = await getBranchDetails({
1714
2296
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1715
2297
  ...fetchProps
1716
2298
  });
1717
- __privateSet$1(this, _schema, schema);
1718
- return schema;
2299
+ __privateSet$1(this, _schemaTables, schema.tables);
2300
+ return schema.tables;
1719
2301
  };
1720
2302
 
1721
2303
  const isBranchStrategyBuilder = (strategy) => {
1722
2304
  return typeof strategy === "function";
1723
2305
  };
1724
2306
 
1725
- const envBranchNames = [
1726
- "XATA_BRANCH",
1727
- "VERCEL_GIT_COMMIT_REF",
1728
- "CF_PAGES_BRANCH",
1729
- "BRANCH"
1730
- ];
1731
- const defaultBranch = "main";
1732
2307
  async function getCurrentBranchName(options) {
1733
- const env = await getBranchByEnvVariable();
1734
- if (env)
1735
- return env;
1736
- const branch = await getGitBranch();
1737
- if (!branch)
1738
- return defaultBranch;
1739
- const details = await getDatabaseBranch(branch, options);
1740
- if (details)
1741
- return branch;
1742
- return defaultBranch;
2308
+ const { branch, envBranch } = getEnvironment();
2309
+ if (branch) {
2310
+ const details = await getDatabaseBranch(branch, options);
2311
+ if (details)
2312
+ return branch;
2313
+ console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
2314
+ }
2315
+ const gitBranch = envBranch || await getGitBranch();
2316
+ return resolveXataBranch(gitBranch, options);
1743
2317
  }
1744
2318
  async function getCurrentBranchDetails(options) {
1745
- const env = await getBranchByEnvVariable();
1746
- if (env)
1747
- return getDatabaseBranch(env, options);
1748
- const branch = await getGitBranch();
1749
- if (!branch)
1750
- return getDatabaseBranch(defaultBranch, options);
1751
- const details = await getDatabaseBranch(branch, options);
1752
- if (details)
1753
- return details;
1754
- return getDatabaseBranch(defaultBranch, options);
2319
+ const branch = await getCurrentBranchName(options);
2320
+ return getDatabaseBranch(branch, options);
2321
+ }
2322
+ async function resolveXataBranch(gitBranch, options) {
2323
+ const databaseURL = options?.databaseURL || getDatabaseURL();
2324
+ const apiKey = options?.apiKey || getAPIKey();
2325
+ if (!databaseURL)
2326
+ throw new Error(
2327
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2328
+ );
2329
+ if (!apiKey)
2330
+ throw new Error(
2331
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2332
+ );
2333
+ const [protocol, , host, , dbName] = databaseURL.split("/");
2334
+ const [workspace] = host.split(".");
2335
+ const { fallbackBranch } = getEnvironment();
2336
+ const { branch } = await resolveBranch({
2337
+ apiKey,
2338
+ apiUrl: databaseURL,
2339
+ fetchImpl: getFetchImplementation(options?.fetchImpl),
2340
+ workspacesApiUrl: `${protocol}//${host}`,
2341
+ pathParams: { dbName, workspace },
2342
+ queryParams: { gitBranch, fallbackBranch },
2343
+ trace: defaultTrace
2344
+ });
2345
+ return branch;
1755
2346
  }
1756
2347
  async function getDatabaseBranch(branch, options) {
1757
2348
  const databaseURL = options?.databaseURL || getDatabaseURL();
1758
2349
  const apiKey = options?.apiKey || getAPIKey();
1759
2350
  if (!databaseURL)
1760
- throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
2351
+ throw new Error(
2352
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
2353
+ );
1761
2354
  if (!apiKey)
1762
- throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
2355
+ throw new Error(
2356
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
2357
+ );
1763
2358
  const [protocol, , host, , database] = databaseURL.split("/");
1764
2359
  const [workspace] = host.split(".");
1765
2360
  const dbBranchName = `${database}:${branch}`;
@@ -1769,10 +2364,8 @@ async function getDatabaseBranch(branch, options) {
1769
2364
  apiUrl: databaseURL,
1770
2365
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1771
2366
  workspacesApiUrl: `${protocol}//${host}`,
1772
- pathParams: {
1773
- dbBranchName,
1774
- workspace
1775
- }
2367
+ pathParams: { dbBranchName, workspace },
2368
+ trace: defaultTrace
1776
2369
  });
1777
2370
  } catch (err) {
1778
2371
  if (isObject(err) && err.status === 404)
@@ -1780,21 +2373,10 @@ async function getDatabaseBranch(branch, options) {
1780
2373
  throw err;
1781
2374
  }
1782
2375
  }
1783
- function getBranchByEnvVariable() {
1784
- for (const name of envBranchNames) {
1785
- const value = getEnvVariable(name);
1786
- if (value) {
1787
- return value;
1788
- }
1789
- }
1790
- try {
1791
- return XATA_BRANCH;
1792
- } catch (err) {
1793
- }
1794
- }
1795
2376
  function getDatabaseURL() {
1796
2377
  try {
1797
- return getEnvVariable("XATA_DATABASE_URL") ?? XATA_DATABASE_URL;
2378
+ const { databaseURL } = getEnvironment();
2379
+ return databaseURL;
1798
2380
  } catch (err) {
1799
2381
  return void 0;
1800
2382
  }
@@ -1823,24 +2405,27 @@ var __privateMethod = (obj, member, method) => {
1823
2405
  return method;
1824
2406
  };
1825
2407
  const buildClient = (plugins) => {
1826
- var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
2408
+ var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
1827
2409
  return _a = class {
1828
- constructor(options = {}, tables) {
2410
+ constructor(options = {}, schemaTables) {
1829
2411
  __privateAdd(this, _parseOptions);
1830
2412
  __privateAdd(this, _getFetchProps);
1831
2413
  __privateAdd(this, _evaluateBranch);
1832
2414
  __privateAdd(this, _branch, void 0);
2415
+ __privateAdd(this, _options, void 0);
1833
2416
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
2417
+ __privateSet(this, _options, safeOptions);
1834
2418
  const pluginOptions = {
1835
2419
  getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
1836
- cache: safeOptions.cache
2420
+ cache: safeOptions.cache,
2421
+ trace: safeOptions.trace
1837
2422
  };
1838
- const db = new SchemaPlugin(tables).build(pluginOptions);
1839
- const search = new SearchPlugin(db).build(pluginOptions);
2423
+ const db = new SchemaPlugin(schemaTables).build(pluginOptions);
2424
+ const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
1840
2425
  this.db = db;
1841
2426
  this.search = search;
1842
2427
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
1843
- if (!namespace)
2428
+ if (namespace === void 0)
1844
2429
  continue;
1845
2430
  const result = namespace.build(pluginOptions);
1846
2431
  if (result instanceof Promise) {
@@ -1852,22 +2437,26 @@ const buildClient = (plugins) => {
1852
2437
  }
1853
2438
  }
1854
2439
  }
1855
- }, _branch = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
2440
+ async getConfig() {
2441
+ const databaseURL = __privateGet(this, _options).databaseURL;
2442
+ const branch = await __privateGet(this, _options).branch();
2443
+ return { databaseURL, branch };
2444
+ }
2445
+ }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
1856
2446
  const fetch = getFetchImplementation(options?.fetch);
1857
2447
  const databaseURL = options?.databaseURL || getDatabaseURL();
1858
2448
  const apiKey = options?.apiKey || getAPIKey();
1859
- const cache = options?.cache ?? new SimpleCache({ cacheRecords: false, defaultQueryTTL: 0 });
1860
- const branch = async () => options?.branch ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
1861
- if (!databaseURL || !apiKey) {
1862
- throw new Error("Options databaseURL and apiKey are required");
2449
+ const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
2450
+ const trace = options?.trace ?? defaultTrace;
2451
+ const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
2452
+ if (!apiKey) {
2453
+ throw new Error("Option apiKey is required");
1863
2454
  }
1864
- return { fetch, databaseURL, apiKey, branch, cache };
1865
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
1866
- fetch,
1867
- apiKey,
1868
- databaseURL,
1869
- branch
1870
- }) {
2455
+ if (!databaseURL) {
2456
+ throw new Error("Option databaseURL is required");
2457
+ }
2458
+ return { fetch, databaseURL, apiKey, branch, cache, trace };
2459
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
1871
2460
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
1872
2461
  if (!branchValue)
1873
2462
  throw new Error("Unable to resolve branch value");
@@ -1877,14 +2466,15 @@ const buildClient = (plugins) => {
1877
2466
  apiUrl: "",
1878
2467
  workspacesApiUrl: (path, params) => {
1879
2468
  const hasBranch = params.dbBranchName ?? params.branch;
1880
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
2469
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
1881
2470
  return databaseURL + newPath;
1882
- }
2471
+ },
2472
+ trace
1883
2473
  };
1884
2474
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
1885
2475
  if (__privateGet(this, _branch))
1886
2476
  return __privateGet(this, _branch);
1887
- if (!param)
2477
+ if (param === void 0)
1888
2478
  return void 0;
1889
2479
  const strategies = Array.isArray(param) ? [...param] : [param];
1890
2480
  const evaluateBranch = async (strategy) => {
@@ -1902,6 +2492,88 @@ const buildClient = (plugins) => {
1902
2492
  class BaseClient extends buildClient() {
1903
2493
  }
1904
2494
 
2495
+ const META = "__";
2496
+ const VALUE = "___";
2497
+ class Serializer {
2498
+ constructor() {
2499
+ this.classes = {};
2500
+ }
2501
+ add(clazz) {
2502
+ this.classes[clazz.name] = clazz;
2503
+ }
2504
+ toJSON(data) {
2505
+ function visit(obj) {
2506
+ if (Array.isArray(obj))
2507
+ return obj.map(visit);
2508
+ const type = typeof obj;
2509
+ if (type === "undefined")
2510
+ return { [META]: "undefined" };
2511
+ if (type === "bigint")
2512
+ return { [META]: "bigint", [VALUE]: obj.toString() };
2513
+ if (obj === null || type !== "object")
2514
+ return obj;
2515
+ const constructor = obj.constructor;
2516
+ const o = { [META]: constructor.name };
2517
+ for (const [key, value] of Object.entries(obj)) {
2518
+ o[key] = visit(value);
2519
+ }
2520
+ if (constructor === Date)
2521
+ o[VALUE] = obj.toISOString();
2522
+ if (constructor === Map)
2523
+ o[VALUE] = Object.fromEntries(obj);
2524
+ if (constructor === Set)
2525
+ o[VALUE] = [...obj];
2526
+ return o;
2527
+ }
2528
+ return JSON.stringify(visit(data));
2529
+ }
2530
+ fromJSON(json) {
2531
+ return JSON.parse(json, (key, value) => {
2532
+ if (value && typeof value === "object" && !Array.isArray(value)) {
2533
+ const { [META]: clazz, [VALUE]: val, ...rest } = value;
2534
+ const constructor = this.classes[clazz];
2535
+ if (constructor) {
2536
+ return Object.assign(Object.create(constructor.prototype), rest);
2537
+ }
2538
+ if (clazz === "Date")
2539
+ return new Date(val);
2540
+ if (clazz === "Set")
2541
+ return new Set(val);
2542
+ if (clazz === "Map")
2543
+ return new Map(Object.entries(val));
2544
+ if (clazz === "bigint")
2545
+ return BigInt(val);
2546
+ if (clazz === "undefined")
2547
+ return void 0;
2548
+ return rest;
2549
+ }
2550
+ return value;
2551
+ });
2552
+ }
2553
+ }
2554
+ const defaultSerializer = new Serializer();
2555
+ const serialize = (data) => {
2556
+ return defaultSerializer.toJSON(data);
2557
+ };
2558
+ const deserialize = (json) => {
2559
+ return defaultSerializer.fromJSON(json);
2560
+ };
2561
+
2562
+ function buildWorkerRunner(config) {
2563
+ return function xataWorker(name, _worker) {
2564
+ return async (...args) => {
2565
+ const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
2566
+ const result = await fetch(url, {
2567
+ method: "POST",
2568
+ headers: { "Content-Type": "application/json" },
2569
+ body: serialize({ args })
2570
+ });
2571
+ const text = await result.text();
2572
+ return deserialize(text);
2573
+ };
2574
+ };
2575
+ }
2576
+
1905
2577
  class XataError extends Error {
1906
2578
  constructor(message, status) {
1907
2579
  super(message);
@@ -1917,10 +2589,12 @@ exports.PAGINATION_MAX_OFFSET = PAGINATION_MAX_OFFSET;
1917
2589
  exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
1918
2590
  exports.Page = Page;
1919
2591
  exports.Query = Query;
2592
+ exports.RecordArray = RecordArray;
1920
2593
  exports.Repository = Repository;
1921
2594
  exports.RestRepository = RestRepository;
1922
2595
  exports.SchemaPlugin = SchemaPlugin;
1923
2596
  exports.SearchPlugin = SearchPlugin;
2597
+ exports.Serializer = Serializer;
1924
2598
  exports.SimpleCache = SimpleCache;
1925
2599
  exports.XataApiClient = XataApiClient;
1926
2600
  exports.XataApiPlugin = XataApiPlugin;
@@ -1929,12 +2603,18 @@ exports.XataPlugin = XataPlugin;
1929
2603
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
1930
2604
  exports.addGitBranchesEntry = addGitBranchesEntry;
1931
2605
  exports.addTableColumn = addTableColumn;
2606
+ exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
1932
2607
  exports.buildClient = buildClient;
2608
+ exports.buildWorkerRunner = buildWorkerRunner;
1933
2609
  exports.bulkInsertTableRecords = bulkInsertTableRecords;
1934
2610
  exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
2611
+ exports.compareBranchSchemas = compareBranchSchemas;
2612
+ exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
2613
+ exports.compareMigrationRequest = compareMigrationRequest;
1935
2614
  exports.contains = contains;
1936
2615
  exports.createBranch = createBranch;
1937
2616
  exports.createDatabase = createDatabase;
2617
+ exports.createMigrationRequest = createMigrationRequest;
1938
2618
  exports.createTable = createTable;
1939
2619
  exports.createUserAPIKey = createUserAPIKey;
1940
2620
  exports.createWorkspace = createWorkspace;
@@ -1946,7 +2626,9 @@ exports.deleteTable = deleteTable;
1946
2626
  exports.deleteUser = deleteUser;
1947
2627
  exports.deleteUserAPIKey = deleteUserAPIKey;
1948
2628
  exports.deleteWorkspace = deleteWorkspace;
2629
+ exports.deserialize = deserialize;
1949
2630
  exports.endsWith = endsWith;
2631
+ exports.equals = equals;
1950
2632
  exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
1951
2633
  exports.exists = exists;
1952
2634
  exports.ge = ge;
@@ -1956,13 +2638,17 @@ exports.getBranchList = getBranchList;
1956
2638
  exports.getBranchMetadata = getBranchMetadata;
1957
2639
  exports.getBranchMigrationHistory = getBranchMigrationHistory;
1958
2640
  exports.getBranchMigrationPlan = getBranchMigrationPlan;
2641
+ exports.getBranchSchemaHistory = getBranchSchemaHistory;
1959
2642
  exports.getBranchStats = getBranchStats;
1960
2643
  exports.getColumn = getColumn;
1961
2644
  exports.getCurrentBranchDetails = getCurrentBranchDetails;
1962
2645
  exports.getCurrentBranchName = getCurrentBranchName;
1963
2646
  exports.getDatabaseList = getDatabaseList;
2647
+ exports.getDatabaseMetadata = getDatabaseMetadata;
1964
2648
  exports.getDatabaseURL = getDatabaseURL;
1965
2649
  exports.getGitBranchesMapping = getGitBranchesMapping;
2650
+ exports.getMigrationRequest = getMigrationRequest;
2651
+ exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
1966
2652
  exports.getRecord = getRecord;
1967
2653
  exports.getTableColumns = getTableColumns;
1968
2654
  exports.getTableSchema = getTableSchema;
@@ -1971,6 +2657,9 @@ exports.getUserAPIKeys = getUserAPIKeys;
1971
2657
  exports.getWorkspace = getWorkspace;
1972
2658
  exports.getWorkspaceMembersList = getWorkspaceMembersList;
1973
2659
  exports.getWorkspacesList = getWorkspacesList;
2660
+ exports.greaterEquals = greaterEquals;
2661
+ exports.greaterThan = greaterThan;
2662
+ exports.greaterThanEquals = greaterThanEquals;
1974
2663
  exports.gt = gt;
1975
2664
  exports.gte = gte;
1976
2665
  exports.includes = includes;
@@ -1981,29 +2670,44 @@ exports.insertRecord = insertRecord;
1981
2670
  exports.insertRecordWithID = insertRecordWithID;
1982
2671
  exports.inviteWorkspaceMember = inviteWorkspaceMember;
1983
2672
  exports.is = is;
2673
+ exports.isCursorPaginationOptions = isCursorPaginationOptions;
1984
2674
  exports.isIdentifiable = isIdentifiable;
1985
2675
  exports.isNot = isNot;
1986
2676
  exports.isXataRecord = isXataRecord;
1987
2677
  exports.le = le;
2678
+ exports.lessEquals = lessEquals;
2679
+ exports.lessThan = lessThan;
2680
+ exports.lessThanEquals = lessThanEquals;
2681
+ exports.listMigrationRequests = listMigrationRequests;
2682
+ exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
1988
2683
  exports.lt = lt;
1989
2684
  exports.lte = lte;
2685
+ exports.mergeMigrationRequest = mergeMigrationRequest;
1990
2686
  exports.notExists = notExists;
1991
2687
  exports.operationsByTag = operationsByTag;
1992
2688
  exports.pattern = pattern;
2689
+ exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
1993
2690
  exports.queryTable = queryTable;
1994
2691
  exports.removeGitBranchesEntry = removeGitBranchesEntry;
1995
2692
  exports.removeWorkspaceMember = removeWorkspaceMember;
1996
2693
  exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
1997
2694
  exports.resolveBranch = resolveBranch;
1998
2695
  exports.searchBranch = searchBranch;
2696
+ exports.searchTable = searchTable;
2697
+ exports.serialize = serialize;
1999
2698
  exports.setTableSchema = setTableSchema;
2000
2699
  exports.startsWith = startsWith;
2700
+ exports.summarizeTable = summarizeTable;
2001
2701
  exports.updateBranchMetadata = updateBranchMetadata;
2702
+ exports.updateBranchSchema = updateBranchSchema;
2002
2703
  exports.updateColumn = updateColumn;
2704
+ exports.updateDatabaseMetadata = updateDatabaseMetadata;
2705
+ exports.updateMigrationRequest = updateMigrationRequest;
2003
2706
  exports.updateRecordWithID = updateRecordWithID;
2004
2707
  exports.updateTable = updateTable;
2005
2708
  exports.updateUser = updateUser;
2006
2709
  exports.updateWorkspace = updateWorkspace;
2710
+ exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
2007
2711
  exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
2008
2712
  exports.upsertRecordWithID = upsertRecordWithID;
2009
2713
  //# sourceMappingURL=index.cjs.map