@xata.io/client 0.0.0-alpha.vea30e82 → 0.0.0-alpha.vec92b09

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.
Files changed (71) hide show
  1. package/.eslintrc.cjs +1 -2
  2. package/CHANGELOG.md +164 -0
  3. package/README.md +271 -1
  4. package/Usage.md +395 -0
  5. package/dist/index.cjs +2157 -0
  6. package/dist/index.cjs.map +1 -0
  7. package/dist/index.d.ts +3805 -7
  8. package/dist/index.mjs +2054 -0
  9. package/dist/index.mjs.map +1 -0
  10. package/package.json +14 -6
  11. package/rollup.config.js +29 -0
  12. package/tsconfig.json +6 -4
  13. package/dist/api/client.d.ts +0 -95
  14. package/dist/api/client.js +0 -251
  15. package/dist/api/components.d.ts +0 -1437
  16. package/dist/api/components.js +0 -998
  17. package/dist/api/fetcher.d.ts +0 -40
  18. package/dist/api/fetcher.js +0 -79
  19. package/dist/api/index.d.ts +0 -12
  20. package/dist/api/index.js +0 -40
  21. package/dist/api/parameters.d.ts +0 -16
  22. package/dist/api/parameters.js +0 -2
  23. package/dist/api/providers.d.ts +0 -8
  24. package/dist/api/providers.js +0 -30
  25. package/dist/api/responses.d.ts +0 -50
  26. package/dist/api/responses.js +0 -2
  27. package/dist/api/schemas.d.ts +0 -311
  28. package/dist/api/schemas.js +0 -2
  29. package/dist/client.d.ts +0 -27
  30. package/dist/client.js +0 -131
  31. package/dist/index.js +0 -30
  32. package/dist/plugins.d.ts +0 -7
  33. package/dist/plugins.js +0 -6
  34. package/dist/schema/filters.d.ts +0 -96
  35. package/dist/schema/filters.js +0 -2
  36. package/dist/schema/filters.spec.d.ts +0 -1
  37. package/dist/schema/filters.spec.js +0 -177
  38. package/dist/schema/index.d.ts +0 -23
  39. package/dist/schema/index.js +0 -50
  40. package/dist/schema/operators.d.ts +0 -74
  41. package/dist/schema/operators.js +0 -93
  42. package/dist/schema/pagination.d.ts +0 -83
  43. package/dist/schema/pagination.js +0 -93
  44. package/dist/schema/query.d.ts +0 -118
  45. package/dist/schema/query.js +0 -242
  46. package/dist/schema/record.d.ts +0 -66
  47. package/dist/schema/record.js +0 -13
  48. package/dist/schema/repository.d.ts +0 -135
  49. package/dist/schema/repository.js +0 -283
  50. package/dist/schema/selection.d.ts +0 -25
  51. package/dist/schema/selection.js +0 -2
  52. package/dist/schema/selection.spec.d.ts +0 -1
  53. package/dist/schema/selection.spec.js +0 -204
  54. package/dist/schema/sorting.d.ts +0 -22
  55. package/dist/schema/sorting.js +0 -35
  56. package/dist/schema/sorting.spec.d.ts +0 -1
  57. package/dist/schema/sorting.spec.js +0 -11
  58. package/dist/search/index.d.ts +0 -34
  59. package/dist/search/index.js +0 -55
  60. package/dist/util/branches.d.ts +0 -5
  61. package/dist/util/branches.js +0 -7
  62. package/dist/util/config.d.ts +0 -11
  63. package/dist/util/config.js +0 -121
  64. package/dist/util/environment.d.ts +0 -5
  65. package/dist/util/environment.js +0 -68
  66. package/dist/util/fetch.d.ts +0 -2
  67. package/dist/util/fetch.js +0 -13
  68. package/dist/util/lang.d.ts +0 -5
  69. package/dist/util/lang.js +0 -22
  70. package/dist/util/types.d.ts +0 -25
  71. package/dist/util/types.js +0 -2
package/dist/index.cjs ADDED
@@ -0,0 +1,2157 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function notEmpty(value) {
6
+ return value !== null && value !== void 0;
7
+ }
8
+ function compact(arr) {
9
+ return arr.filter(notEmpty);
10
+ }
11
+ function isObject(value) {
12
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
13
+ }
14
+ function isDefined(value) {
15
+ return value !== null && value !== void 0;
16
+ }
17
+ function isString(value) {
18
+ return isDefined(value) && typeof value === "string";
19
+ }
20
+ function toBase64(value) {
21
+ try {
22
+ return btoa(value);
23
+ } catch (err) {
24
+ const buf = Buffer;
25
+ return buf.from(value).toString("base64");
26
+ }
27
+ }
28
+
29
+ function getEnvVariable(name) {
30
+ try {
31
+ if (isObject(process) && isString(process?.env?.[name])) {
32
+ return process.env[name];
33
+ }
34
+ } catch (err) {
35
+ }
36
+ try {
37
+ if (isObject(Deno) && isString(Deno?.env?.get(name))) {
38
+ return Deno.env.get(name);
39
+ }
40
+ } catch (err) {
41
+ }
42
+ }
43
+ async function getGitBranch() {
44
+ try {
45
+ if (typeof require === "function") {
46
+ const req = require;
47
+ return req("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
48
+ }
49
+ } catch (err) {
50
+ }
51
+ try {
52
+ if (isObject(Deno)) {
53
+ const process2 = Deno.run({
54
+ cmd: ["git", "branch", "--show-current"],
55
+ stdout: "piped",
56
+ stderr: "piped"
57
+ });
58
+ return new TextDecoder().decode(await process2.output()).trim();
59
+ }
60
+ } catch (err) {
61
+ }
62
+ }
63
+
64
+ function getAPIKey() {
65
+ try {
66
+ return getEnvVariable("XATA_API_KEY") ?? XATA_API_KEY;
67
+ } catch (err) {
68
+ return void 0;
69
+ }
70
+ }
71
+
72
+ function getFetchImplementation(userFetch) {
73
+ const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
74
+ const fetchImpl = userFetch ?? globalFetch;
75
+ if (!fetchImpl) {
76
+ throw new Error(`The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`);
77
+ }
78
+ return fetchImpl;
79
+ }
80
+
81
+ const VERSION = "0.0.0-alpha.vec92b09";
82
+
83
+ class ErrorWithCause extends Error {
84
+ constructor(message, options) {
85
+ super(message, options);
86
+ }
87
+ }
88
+ class FetcherError extends ErrorWithCause {
89
+ constructor(status, data, requestId) {
90
+ super(getMessage(data));
91
+ this.status = status;
92
+ this.errors = isBulkError(data) ? data.errors : void 0;
93
+ this.requestId = requestId;
94
+ if (data instanceof Error) {
95
+ this.stack = data.stack;
96
+ this.cause = data.cause;
97
+ }
98
+ }
99
+ toString() {
100
+ const error = super.toString();
101
+ return `[${this.status}] (${this.requestId ?? "Unknown"}): ${error}`;
102
+ }
103
+ }
104
+ function isBulkError(error) {
105
+ return isObject(error) && Array.isArray(error.errors);
106
+ }
107
+ function isErrorWithMessage(error) {
108
+ return isObject(error) && isString(error.message);
109
+ }
110
+ function getMessage(data) {
111
+ if (data instanceof Error) {
112
+ return data.message;
113
+ } else if (isString(data)) {
114
+ return data;
115
+ } else if (isErrorWithMessage(data)) {
116
+ return data.message;
117
+ } else if (isBulkError(data)) {
118
+ return "Bulk operation failed";
119
+ } else {
120
+ return "Unexpected error";
121
+ }
122
+ }
123
+
124
+ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
125
+ const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
126
+ if (value === void 0 || value === null)
127
+ return acc;
128
+ return { ...acc, [key]: value };
129
+ }, {});
130
+ const query = new URLSearchParams(cleanQueryParams).toString();
131
+ const queryString = query.length > 0 ? `?${query}` : "";
132
+ return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
133
+ };
134
+ function buildBaseUrl({
135
+ path,
136
+ workspacesApiUrl,
137
+ apiUrl,
138
+ pathParams
139
+ }) {
140
+ if (!pathParams?.workspace)
141
+ return `${apiUrl}${path}`;
142
+ const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
143
+ return url.replace("{workspaceId}", pathParams.workspace);
144
+ }
145
+ function hostHeader(url) {
146
+ const pattern = /.*:\/\/(?<host>[^/]+).*/;
147
+ const { groups } = pattern.exec(url) ?? {};
148
+ return groups?.host ? { Host: groups.host } : {};
149
+ }
150
+ async function fetch$1({
151
+ url: path,
152
+ method,
153
+ body,
154
+ headers,
155
+ pathParams,
156
+ queryParams,
157
+ fetchImpl,
158
+ apiKey,
159
+ apiUrl,
160
+ workspacesApiUrl
161
+ }) {
162
+ const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
163
+ const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
164
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
165
+ const response = await fetchImpl(url, {
166
+ method: method.toUpperCase(),
167
+ body: body ? JSON.stringify(body) : void 0,
168
+ headers: {
169
+ "Content-Type": "application/json",
170
+ "User-Agent": `Xata client-ts/${VERSION}`,
171
+ ...headers,
172
+ ...hostHeader(fullUrl),
173
+ Authorization: `Bearer ${apiKey}`
174
+ }
175
+ });
176
+ if (response.status === 204) {
177
+ return {};
178
+ }
179
+ const requestId = response.headers?.get("x-request-id") ?? void 0;
180
+ try {
181
+ const jsonResponse = await response.json();
182
+ if (response.ok) {
183
+ return jsonResponse;
184
+ }
185
+ throw new FetcherError(response.status, jsonResponse, requestId);
186
+ } catch (error) {
187
+ throw new FetcherError(response.status, error, requestId);
188
+ }
189
+ }
190
+
191
+ const getUser = (variables) => fetch$1({ url: "/user", method: "get", ...variables });
192
+ const updateUser = (variables) => fetch$1({ url: "/user", method: "put", ...variables });
193
+ const deleteUser = (variables) => fetch$1({ url: "/user", method: "delete", ...variables });
194
+ const getUserAPIKeys = (variables) => fetch$1({
195
+ url: "/user/keys",
196
+ method: "get",
197
+ ...variables
198
+ });
199
+ const createUserAPIKey = (variables) => fetch$1({
200
+ url: "/user/keys/{keyName}",
201
+ method: "post",
202
+ ...variables
203
+ });
204
+ const deleteUserAPIKey = (variables) => fetch$1({
205
+ url: "/user/keys/{keyName}",
206
+ method: "delete",
207
+ ...variables
208
+ });
209
+ const createWorkspace = (variables) => fetch$1({
210
+ url: "/workspaces",
211
+ method: "post",
212
+ ...variables
213
+ });
214
+ const getWorkspacesList = (variables) => fetch$1({
215
+ url: "/workspaces",
216
+ method: "get",
217
+ ...variables
218
+ });
219
+ const getWorkspace = (variables) => fetch$1({
220
+ url: "/workspaces/{workspaceId}",
221
+ method: "get",
222
+ ...variables
223
+ });
224
+ const updateWorkspace = (variables) => fetch$1({
225
+ url: "/workspaces/{workspaceId}",
226
+ method: "put",
227
+ ...variables
228
+ });
229
+ const deleteWorkspace = (variables) => fetch$1({
230
+ url: "/workspaces/{workspaceId}",
231
+ method: "delete",
232
+ ...variables
233
+ });
234
+ const getWorkspaceMembersList = (variables) => fetch$1({
235
+ url: "/workspaces/{workspaceId}/members",
236
+ method: "get",
237
+ ...variables
238
+ });
239
+ const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
240
+ const removeWorkspaceMember = (variables) => fetch$1({
241
+ url: "/workspaces/{workspaceId}/members/{userId}",
242
+ method: "delete",
243
+ ...variables
244
+ });
245
+ const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
246
+ const cancelWorkspaceMemberInvite = (variables) => fetch$1({
247
+ url: "/workspaces/{workspaceId}/invites/{inviteId}",
248
+ method: "delete",
249
+ ...variables
250
+ });
251
+ const resendWorkspaceMemberInvite = (variables) => fetch$1({
252
+ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
253
+ method: "post",
254
+ ...variables
255
+ });
256
+ const acceptWorkspaceMemberInvite = (variables) => fetch$1({
257
+ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
258
+ method: "post",
259
+ ...variables
260
+ });
261
+ const getDatabaseList = (variables) => fetch$1({
262
+ url: "/dbs",
263
+ method: "get",
264
+ ...variables
265
+ });
266
+ const getBranchList = (variables) => fetch$1({
267
+ url: "/dbs/{dbName}",
268
+ method: "get",
269
+ ...variables
270
+ });
271
+ const createDatabase = (variables) => fetch$1({
272
+ url: "/dbs/{dbName}",
273
+ method: "put",
274
+ ...variables
275
+ });
276
+ const deleteDatabase = (variables) => fetch$1({
277
+ url: "/dbs/{dbName}",
278
+ method: "delete",
279
+ ...variables
280
+ });
281
+ const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
282
+ const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
283
+ const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
284
+ const resolveBranch = (variables) => fetch$1({
285
+ url: "/dbs/{dbName}/resolveBranch",
286
+ method: "get",
287
+ ...variables
288
+ });
289
+ const getBranchDetails = (variables) => fetch$1({
290
+ url: "/db/{dbBranchName}",
291
+ method: "get",
292
+ ...variables
293
+ });
294
+ const createBranch = (variables) => fetch$1({
295
+ url: "/db/{dbBranchName}",
296
+ method: "put",
297
+ ...variables
298
+ });
299
+ const deleteBranch = (variables) => fetch$1({
300
+ url: "/db/{dbBranchName}",
301
+ method: "delete",
302
+ ...variables
303
+ });
304
+ const updateBranchMetadata = (variables) => fetch$1({
305
+ url: "/db/{dbBranchName}/metadata",
306
+ method: "put",
307
+ ...variables
308
+ });
309
+ const getBranchMetadata = (variables) => fetch$1({
310
+ url: "/db/{dbBranchName}/metadata",
311
+ method: "get",
312
+ ...variables
313
+ });
314
+ const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
315
+ const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
316
+ const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
317
+ const getBranchStats = (variables) => fetch$1({
318
+ url: "/db/{dbBranchName}/stats",
319
+ method: "get",
320
+ ...variables
321
+ });
322
+ const createTable = (variables) => fetch$1({
323
+ url: "/db/{dbBranchName}/tables/{tableName}",
324
+ method: "put",
325
+ ...variables
326
+ });
327
+ const deleteTable = (variables) => fetch$1({
328
+ url: "/db/{dbBranchName}/tables/{tableName}",
329
+ method: "delete",
330
+ ...variables
331
+ });
332
+ const updateTable = (variables) => fetch$1({
333
+ url: "/db/{dbBranchName}/tables/{tableName}",
334
+ method: "patch",
335
+ ...variables
336
+ });
337
+ const getTableSchema = (variables) => fetch$1({
338
+ url: "/db/{dbBranchName}/tables/{tableName}/schema",
339
+ method: "get",
340
+ ...variables
341
+ });
342
+ const setTableSchema = (variables) => fetch$1({
343
+ url: "/db/{dbBranchName}/tables/{tableName}/schema",
344
+ method: "put",
345
+ ...variables
346
+ });
347
+ const getTableColumns = (variables) => fetch$1({
348
+ url: "/db/{dbBranchName}/tables/{tableName}/columns",
349
+ method: "get",
350
+ ...variables
351
+ });
352
+ const addTableColumn = (variables) => fetch$1({
353
+ url: "/db/{dbBranchName}/tables/{tableName}/columns",
354
+ method: "post",
355
+ ...variables
356
+ });
357
+ const getColumn = (variables) => fetch$1({
358
+ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
359
+ method: "get",
360
+ ...variables
361
+ });
362
+ const deleteColumn = (variables) => fetch$1({
363
+ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
364
+ method: "delete",
365
+ ...variables
366
+ });
367
+ const updateColumn = (variables) => fetch$1({
368
+ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
369
+ method: "patch",
370
+ ...variables
371
+ });
372
+ const insertRecord = (variables) => fetch$1({
373
+ url: "/db/{dbBranchName}/tables/{tableName}/data",
374
+ method: "post",
375
+ ...variables
376
+ });
377
+ const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
378
+ const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
379
+ const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
380
+ const deleteRecord = (variables) => fetch$1({
381
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
382
+ method: "delete",
383
+ ...variables
384
+ });
385
+ const getRecord = (variables) => fetch$1({
386
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
387
+ method: "get",
388
+ ...variables
389
+ });
390
+ const bulkInsertTableRecords = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables });
391
+ const queryTable = (variables) => fetch$1({
392
+ url: "/db/{dbBranchName}/tables/{tableName}/query",
393
+ method: "post",
394
+ ...variables
395
+ });
396
+ const searchTable = (variables) => fetch$1({
397
+ url: "/db/{dbBranchName}/tables/{tableName}/search",
398
+ method: "post",
399
+ ...variables
400
+ });
401
+ const searchBranch = (variables) => fetch$1({
402
+ url: "/db/{dbBranchName}/search",
403
+ method: "post",
404
+ ...variables
405
+ });
406
+ const operationsByTag = {
407
+ users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
408
+ workspaces: {
409
+ createWorkspace,
410
+ getWorkspacesList,
411
+ getWorkspace,
412
+ updateWorkspace,
413
+ deleteWorkspace,
414
+ getWorkspaceMembersList,
415
+ updateWorkspaceMemberRole,
416
+ removeWorkspaceMember,
417
+ inviteWorkspaceMember,
418
+ cancelWorkspaceMemberInvite,
419
+ resendWorkspaceMemberInvite,
420
+ acceptWorkspaceMemberInvite
421
+ },
422
+ database: {
423
+ getDatabaseList,
424
+ createDatabase,
425
+ deleteDatabase,
426
+ getGitBranchesMapping,
427
+ addGitBranchesEntry,
428
+ removeGitBranchesEntry,
429
+ resolveBranch
430
+ },
431
+ branch: {
432
+ getBranchList,
433
+ getBranchDetails,
434
+ createBranch,
435
+ deleteBranch,
436
+ updateBranchMetadata,
437
+ getBranchMetadata,
438
+ getBranchMigrationHistory,
439
+ executeBranchMigrationPlan,
440
+ getBranchMigrationPlan,
441
+ getBranchStats
442
+ },
443
+ table: {
444
+ createTable,
445
+ deleteTable,
446
+ updateTable,
447
+ getTableSchema,
448
+ setTableSchema,
449
+ getTableColumns,
450
+ addTableColumn,
451
+ getColumn,
452
+ deleteColumn,
453
+ updateColumn
454
+ },
455
+ records: {
456
+ insertRecord,
457
+ insertRecordWithID,
458
+ updateRecordWithID,
459
+ upsertRecordWithID,
460
+ deleteRecord,
461
+ getRecord,
462
+ bulkInsertTableRecords,
463
+ queryTable,
464
+ searchTable,
465
+ searchBranch
466
+ }
467
+ };
468
+
469
+ function getHostUrl(provider, type) {
470
+ if (isValidAlias(provider)) {
471
+ return providers[provider][type];
472
+ } else if (isValidBuilder(provider)) {
473
+ return provider[type];
474
+ }
475
+ throw new Error("Invalid API provider");
476
+ }
477
+ const providers = {
478
+ production: {
479
+ main: "https://api.xata.io",
480
+ workspaces: "https://{workspaceId}.xata.sh"
481
+ },
482
+ staging: {
483
+ main: "https://staging.xatabase.co",
484
+ workspaces: "https://{workspaceId}.staging.xatabase.co"
485
+ }
486
+ };
487
+ function isValidAlias(alias) {
488
+ return isString(alias) && Object.keys(providers).includes(alias);
489
+ }
490
+ function isValidBuilder(builder) {
491
+ return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
492
+ }
493
+
494
+ var __accessCheck$7 = (obj, member, msg) => {
495
+ if (!member.has(obj))
496
+ throw TypeError("Cannot " + msg);
497
+ };
498
+ var __privateGet$7 = (obj, member, getter) => {
499
+ __accessCheck$7(obj, member, "read from private field");
500
+ return getter ? getter.call(obj) : member.get(obj);
501
+ };
502
+ var __privateAdd$7 = (obj, member, value) => {
503
+ if (member.has(obj))
504
+ throw TypeError("Cannot add the same private member more than once");
505
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
506
+ };
507
+ var __privateSet$6 = (obj, member, value, setter) => {
508
+ __accessCheck$7(obj, member, "write to private field");
509
+ setter ? setter.call(obj, value) : member.set(obj, value);
510
+ return value;
511
+ };
512
+ var _extraProps, _namespaces;
513
+ class XataApiClient {
514
+ constructor(options = {}) {
515
+ __privateAdd$7(this, _extraProps, void 0);
516
+ __privateAdd$7(this, _namespaces, {});
517
+ const provider = options.host ?? "production";
518
+ const apiKey = options?.apiKey ?? getAPIKey();
519
+ if (!apiKey) {
520
+ throw new Error("Could not resolve a valid apiKey");
521
+ }
522
+ __privateSet$6(this, _extraProps, {
523
+ apiUrl: getHostUrl(provider, "main"),
524
+ workspacesApiUrl: getHostUrl(provider, "workspaces"),
525
+ fetchImpl: getFetchImplementation(options.fetch),
526
+ apiKey
527
+ });
528
+ }
529
+ get user() {
530
+ if (!__privateGet$7(this, _namespaces).user)
531
+ __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
532
+ return __privateGet$7(this, _namespaces).user;
533
+ }
534
+ get workspaces() {
535
+ if (!__privateGet$7(this, _namespaces).workspaces)
536
+ __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
537
+ return __privateGet$7(this, _namespaces).workspaces;
538
+ }
539
+ get databases() {
540
+ if (!__privateGet$7(this, _namespaces).databases)
541
+ __privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
542
+ return __privateGet$7(this, _namespaces).databases;
543
+ }
544
+ get branches() {
545
+ if (!__privateGet$7(this, _namespaces).branches)
546
+ __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
547
+ return __privateGet$7(this, _namespaces).branches;
548
+ }
549
+ get tables() {
550
+ if (!__privateGet$7(this, _namespaces).tables)
551
+ __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
552
+ return __privateGet$7(this, _namespaces).tables;
553
+ }
554
+ get records() {
555
+ if (!__privateGet$7(this, _namespaces).records)
556
+ __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
557
+ return __privateGet$7(this, _namespaces).records;
558
+ }
559
+ }
560
+ _extraProps = new WeakMap();
561
+ _namespaces = new WeakMap();
562
+ class UserApi {
563
+ constructor(extraProps) {
564
+ this.extraProps = extraProps;
565
+ }
566
+ getUser() {
567
+ return operationsByTag.users.getUser({ ...this.extraProps });
568
+ }
569
+ updateUser(user) {
570
+ return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
571
+ }
572
+ deleteUser() {
573
+ return operationsByTag.users.deleteUser({ ...this.extraProps });
574
+ }
575
+ getUserAPIKeys() {
576
+ return operationsByTag.users.getUserAPIKeys({ ...this.extraProps });
577
+ }
578
+ createUserAPIKey(keyName) {
579
+ return operationsByTag.users.createUserAPIKey({
580
+ pathParams: { keyName },
581
+ ...this.extraProps
582
+ });
583
+ }
584
+ deleteUserAPIKey(keyName) {
585
+ return operationsByTag.users.deleteUserAPIKey({
586
+ pathParams: { keyName },
587
+ ...this.extraProps
588
+ });
589
+ }
590
+ }
591
+ class WorkspaceApi {
592
+ constructor(extraProps) {
593
+ this.extraProps = extraProps;
594
+ }
595
+ createWorkspace(workspaceMeta) {
596
+ return operationsByTag.workspaces.createWorkspace({
597
+ body: workspaceMeta,
598
+ ...this.extraProps
599
+ });
600
+ }
601
+ getWorkspacesList() {
602
+ return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
603
+ }
604
+ getWorkspace(workspaceId) {
605
+ return operationsByTag.workspaces.getWorkspace({
606
+ pathParams: { workspaceId },
607
+ ...this.extraProps
608
+ });
609
+ }
610
+ updateWorkspace(workspaceId, workspaceMeta) {
611
+ return operationsByTag.workspaces.updateWorkspace({
612
+ pathParams: { workspaceId },
613
+ body: workspaceMeta,
614
+ ...this.extraProps
615
+ });
616
+ }
617
+ deleteWorkspace(workspaceId) {
618
+ return operationsByTag.workspaces.deleteWorkspace({
619
+ pathParams: { workspaceId },
620
+ ...this.extraProps
621
+ });
622
+ }
623
+ getWorkspaceMembersList(workspaceId) {
624
+ return operationsByTag.workspaces.getWorkspaceMembersList({
625
+ pathParams: { workspaceId },
626
+ ...this.extraProps
627
+ });
628
+ }
629
+ updateWorkspaceMemberRole(workspaceId, userId, role) {
630
+ return operationsByTag.workspaces.updateWorkspaceMemberRole({
631
+ pathParams: { workspaceId, userId },
632
+ body: { role },
633
+ ...this.extraProps
634
+ });
635
+ }
636
+ removeWorkspaceMember(workspaceId, userId) {
637
+ return operationsByTag.workspaces.removeWorkspaceMember({
638
+ pathParams: { workspaceId, userId },
639
+ ...this.extraProps
640
+ });
641
+ }
642
+ inviteWorkspaceMember(workspaceId, email, role) {
643
+ return operationsByTag.workspaces.inviteWorkspaceMember({
644
+ pathParams: { workspaceId },
645
+ body: { email, role },
646
+ ...this.extraProps
647
+ });
648
+ }
649
+ cancelWorkspaceMemberInvite(workspaceId, inviteId) {
650
+ return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
651
+ pathParams: { workspaceId, inviteId },
652
+ ...this.extraProps
653
+ });
654
+ }
655
+ resendWorkspaceMemberInvite(workspaceId, inviteId) {
656
+ return operationsByTag.workspaces.resendWorkspaceMemberInvite({
657
+ pathParams: { workspaceId, inviteId },
658
+ ...this.extraProps
659
+ });
660
+ }
661
+ acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
662
+ return operationsByTag.workspaces.acceptWorkspaceMemberInvite({
663
+ pathParams: { workspaceId, inviteKey },
664
+ ...this.extraProps
665
+ });
666
+ }
667
+ }
668
+ class DatabaseApi {
669
+ constructor(extraProps) {
670
+ this.extraProps = extraProps;
671
+ }
672
+ getDatabaseList(workspace) {
673
+ return operationsByTag.database.getDatabaseList({
674
+ pathParams: { workspace },
675
+ ...this.extraProps
676
+ });
677
+ }
678
+ createDatabase(workspace, dbName, options = {}) {
679
+ return operationsByTag.database.createDatabase({
680
+ pathParams: { workspace, dbName },
681
+ body: options,
682
+ ...this.extraProps
683
+ });
684
+ }
685
+ deleteDatabase(workspace, dbName) {
686
+ return operationsByTag.database.deleteDatabase({
687
+ pathParams: { workspace, dbName },
688
+ ...this.extraProps
689
+ });
690
+ }
691
+ getGitBranchesMapping(workspace, dbName) {
692
+ return operationsByTag.database.getGitBranchesMapping({
693
+ pathParams: { workspace, dbName },
694
+ ...this.extraProps
695
+ });
696
+ }
697
+ addGitBranchesEntry(workspace, dbName, body) {
698
+ return operationsByTag.database.addGitBranchesEntry({
699
+ pathParams: { workspace, dbName },
700
+ body,
701
+ ...this.extraProps
702
+ });
703
+ }
704
+ removeGitBranchesEntry(workspace, dbName, gitBranch) {
705
+ return operationsByTag.database.removeGitBranchesEntry({
706
+ pathParams: { workspace, dbName },
707
+ queryParams: { gitBranch },
708
+ ...this.extraProps
709
+ });
710
+ }
711
+ resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
712
+ return operationsByTag.database.resolveBranch({
713
+ pathParams: { workspace, dbName },
714
+ queryParams: { gitBranch, fallbackBranch },
715
+ ...this.extraProps
716
+ });
717
+ }
718
+ }
719
+ class BranchApi {
720
+ constructor(extraProps) {
721
+ this.extraProps = extraProps;
722
+ }
723
+ getBranchList(workspace, dbName) {
724
+ return operationsByTag.branch.getBranchList({
725
+ pathParams: { workspace, dbName },
726
+ ...this.extraProps
727
+ });
728
+ }
729
+ getBranchDetails(workspace, database, branch) {
730
+ return operationsByTag.branch.getBranchDetails({
731
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
732
+ ...this.extraProps
733
+ });
734
+ }
735
+ createBranch(workspace, database, branch, from, options = {}) {
736
+ return operationsByTag.branch.createBranch({
737
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
738
+ queryParams: isString(from) ? { from } : void 0,
739
+ body: options,
740
+ ...this.extraProps
741
+ });
742
+ }
743
+ deleteBranch(workspace, database, branch) {
744
+ return operationsByTag.branch.deleteBranch({
745
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
746
+ ...this.extraProps
747
+ });
748
+ }
749
+ updateBranchMetadata(workspace, database, branch, metadata = {}) {
750
+ return operationsByTag.branch.updateBranchMetadata({
751
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
752
+ body: metadata,
753
+ ...this.extraProps
754
+ });
755
+ }
756
+ getBranchMetadata(workspace, database, branch) {
757
+ return operationsByTag.branch.getBranchMetadata({
758
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
759
+ ...this.extraProps
760
+ });
761
+ }
762
+ getBranchMigrationHistory(workspace, database, branch, options = {}) {
763
+ return operationsByTag.branch.getBranchMigrationHistory({
764
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
765
+ body: options,
766
+ ...this.extraProps
767
+ });
768
+ }
769
+ executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
770
+ return operationsByTag.branch.executeBranchMigrationPlan({
771
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
772
+ body: migrationPlan,
773
+ ...this.extraProps
774
+ });
775
+ }
776
+ getBranchMigrationPlan(workspace, database, branch, schema) {
777
+ return operationsByTag.branch.getBranchMigrationPlan({
778
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
779
+ body: schema,
780
+ ...this.extraProps
781
+ });
782
+ }
783
+ getBranchStats(workspace, database, branch) {
784
+ return operationsByTag.branch.getBranchStats({
785
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
786
+ ...this.extraProps
787
+ });
788
+ }
789
+ }
790
+ class TableApi {
791
+ constructor(extraProps) {
792
+ this.extraProps = extraProps;
793
+ }
794
+ createTable(workspace, database, branch, tableName) {
795
+ return operationsByTag.table.createTable({
796
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
797
+ ...this.extraProps
798
+ });
799
+ }
800
+ deleteTable(workspace, database, branch, tableName) {
801
+ return operationsByTag.table.deleteTable({
802
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
803
+ ...this.extraProps
804
+ });
805
+ }
806
+ updateTable(workspace, database, branch, tableName, options) {
807
+ return operationsByTag.table.updateTable({
808
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
809
+ body: options,
810
+ ...this.extraProps
811
+ });
812
+ }
813
+ getTableSchema(workspace, database, branch, tableName) {
814
+ return operationsByTag.table.getTableSchema({
815
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
816
+ ...this.extraProps
817
+ });
818
+ }
819
+ setTableSchema(workspace, database, branch, tableName, options) {
820
+ return operationsByTag.table.setTableSchema({
821
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
822
+ body: options,
823
+ ...this.extraProps
824
+ });
825
+ }
826
+ getTableColumns(workspace, database, branch, tableName) {
827
+ return operationsByTag.table.getTableColumns({
828
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
829
+ ...this.extraProps
830
+ });
831
+ }
832
+ addTableColumn(workspace, database, branch, tableName, column) {
833
+ return operationsByTag.table.addTableColumn({
834
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
835
+ body: column,
836
+ ...this.extraProps
837
+ });
838
+ }
839
+ getColumn(workspace, database, branch, tableName, columnName) {
840
+ return operationsByTag.table.getColumn({
841
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
842
+ ...this.extraProps
843
+ });
844
+ }
845
+ deleteColumn(workspace, database, branch, tableName, columnName) {
846
+ return operationsByTag.table.deleteColumn({
847
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
848
+ ...this.extraProps
849
+ });
850
+ }
851
+ updateColumn(workspace, database, branch, tableName, columnName, options) {
852
+ return operationsByTag.table.updateColumn({
853
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
854
+ body: options,
855
+ ...this.extraProps
856
+ });
857
+ }
858
+ }
859
+ class RecordsApi {
860
+ constructor(extraProps) {
861
+ this.extraProps = extraProps;
862
+ }
863
+ insertRecord(workspace, database, branch, tableName, record) {
864
+ return operationsByTag.records.insertRecord({
865
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
866
+ body: record,
867
+ ...this.extraProps
868
+ });
869
+ }
870
+ insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
871
+ return operationsByTag.records.insertRecordWithID({
872
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
873
+ queryParams: options,
874
+ body: record,
875
+ ...this.extraProps
876
+ });
877
+ }
878
+ updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
879
+ return operationsByTag.records.updateRecordWithID({
880
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
881
+ queryParams: options,
882
+ body: record,
883
+ ...this.extraProps
884
+ });
885
+ }
886
+ upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
887
+ return operationsByTag.records.upsertRecordWithID({
888
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
889
+ queryParams: options,
890
+ body: record,
891
+ ...this.extraProps
892
+ });
893
+ }
894
+ deleteRecord(workspace, database, branch, tableName, recordId) {
895
+ return operationsByTag.records.deleteRecord({
896
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
897
+ ...this.extraProps
898
+ });
899
+ }
900
+ getRecord(workspace, database, branch, tableName, recordId, options = {}) {
901
+ return operationsByTag.records.getRecord({
902
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
903
+ ...this.extraProps
904
+ });
905
+ }
906
+ bulkInsertTableRecords(workspace, database, branch, tableName, records) {
907
+ return operationsByTag.records.bulkInsertTableRecords({
908
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
909
+ body: { records },
910
+ ...this.extraProps
911
+ });
912
+ }
913
+ queryTable(workspace, database, branch, tableName, query) {
914
+ return operationsByTag.records.queryTable({
915
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
916
+ body: query,
917
+ ...this.extraProps
918
+ });
919
+ }
920
+ searchTable(workspace, database, branch, tableName, query) {
921
+ return operationsByTag.records.searchTable({
922
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
923
+ body: query,
924
+ ...this.extraProps
925
+ });
926
+ }
927
+ searchBranch(workspace, database, branch, query) {
928
+ return operationsByTag.records.searchBranch({
929
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
930
+ body: query,
931
+ ...this.extraProps
932
+ });
933
+ }
934
+ }
935
+
936
+ class XataApiPlugin {
937
+ async build(options) {
938
+ const { fetchImpl, apiKey } = await options.getFetchProps();
939
+ return new XataApiClient({ fetch: fetchImpl, apiKey });
940
+ }
941
+ }
942
+
943
+ class XataPlugin {
944
+ }
945
+
946
+ var __accessCheck$6 = (obj, member, msg) => {
947
+ if (!member.has(obj))
948
+ throw TypeError("Cannot " + msg);
949
+ };
950
+ var __privateGet$6 = (obj, member, getter) => {
951
+ __accessCheck$6(obj, member, "read from private field");
952
+ return getter ? getter.call(obj) : member.get(obj);
953
+ };
954
+ var __privateAdd$6 = (obj, member, value) => {
955
+ if (member.has(obj))
956
+ throw TypeError("Cannot add the same private member more than once");
957
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
958
+ };
959
+ var __privateSet$5 = (obj, member, value, setter) => {
960
+ __accessCheck$6(obj, member, "write to private field");
961
+ setter ? setter.call(obj, value) : member.set(obj, value);
962
+ return value;
963
+ };
964
+ var _query, _page;
965
+ class Page {
966
+ constructor(query, meta, records = []) {
967
+ __privateAdd$6(this, _query, void 0);
968
+ __privateSet$5(this, _query, query);
969
+ this.meta = meta;
970
+ this.records = new RecordArray(this, records);
971
+ }
972
+ async nextPage(size, offset) {
973
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
974
+ }
975
+ async previousPage(size, offset) {
976
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
977
+ }
978
+ async firstPage(size, offset) {
979
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
980
+ }
981
+ async lastPage(size, offset) {
982
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
983
+ }
984
+ hasNextPage() {
985
+ return this.meta.page.more;
986
+ }
987
+ }
988
+ _query = new WeakMap();
989
+ const PAGINATION_MAX_SIZE = 200;
990
+ const PAGINATION_DEFAULT_SIZE = 20;
991
+ const PAGINATION_MAX_OFFSET = 800;
992
+ const PAGINATION_DEFAULT_OFFSET = 0;
993
+ function isCursorPaginationOptions(options) {
994
+ return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
995
+ }
996
+ const _RecordArray = class extends Array {
997
+ constructor(page, overrideRecords) {
998
+ super(..._RecordArray.parseConstructorParams(page, overrideRecords));
999
+ __privateAdd$6(this, _page, void 0);
1000
+ __privateSet$5(this, _page, page);
1001
+ }
1002
+ static parseConstructorParams(...args) {
1003
+ if (args.length === 1 && typeof args[0] === "number") {
1004
+ return new Array(args[0]);
1005
+ }
1006
+ if (args.length <= 2 && isObject(args[0]?.meta) && Array.isArray(args[1] ?? [])) {
1007
+ const result = args[1] ?? args[0].records ?? [];
1008
+ return new Array(...result);
1009
+ }
1010
+ return new Array(...args);
1011
+ }
1012
+ async nextPage(size, offset) {
1013
+ const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
1014
+ return new _RecordArray(newPage);
1015
+ }
1016
+ async previousPage(size, offset) {
1017
+ const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
1018
+ return new _RecordArray(newPage);
1019
+ }
1020
+ async firstPage(size, offset) {
1021
+ const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
1022
+ return new _RecordArray(newPage);
1023
+ }
1024
+ async lastPage(size, offset) {
1025
+ const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
1026
+ return new _RecordArray(newPage);
1027
+ }
1028
+ hasNextPage() {
1029
+ return __privateGet$6(this, _page).meta.page.more;
1030
+ }
1031
+ };
1032
+ let RecordArray = _RecordArray;
1033
+ _page = new WeakMap();
1034
+
1035
+ var __accessCheck$5 = (obj, member, msg) => {
1036
+ if (!member.has(obj))
1037
+ throw TypeError("Cannot " + msg);
1038
+ };
1039
+ var __privateGet$5 = (obj, member, getter) => {
1040
+ __accessCheck$5(obj, member, "read from private field");
1041
+ return getter ? getter.call(obj) : member.get(obj);
1042
+ };
1043
+ var __privateAdd$5 = (obj, member, value) => {
1044
+ if (member.has(obj))
1045
+ throw TypeError("Cannot add the same private member more than once");
1046
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1047
+ };
1048
+ var __privateSet$4 = (obj, member, value, setter) => {
1049
+ __accessCheck$5(obj, member, "write to private field");
1050
+ setter ? setter.call(obj, value) : member.set(obj, value);
1051
+ return value;
1052
+ };
1053
+ var _table$1, _repository, _data;
1054
+ const _Query = class {
1055
+ constructor(repository, table, data, rawParent) {
1056
+ __privateAdd$5(this, _table$1, void 0);
1057
+ __privateAdd$5(this, _repository, void 0);
1058
+ __privateAdd$5(this, _data, { filter: {} });
1059
+ this.meta = { page: { cursor: "start", more: true } };
1060
+ this.records = new RecordArray(this, []);
1061
+ __privateSet$4(this, _table$1, table);
1062
+ if (repository) {
1063
+ __privateSet$4(this, _repository, repository);
1064
+ } else {
1065
+ __privateSet$4(this, _repository, this);
1066
+ }
1067
+ const parent = cleanParent(data, rawParent);
1068
+ __privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
1069
+ __privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
1070
+ __privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
1071
+ __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
1072
+ __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
1073
+ __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
1074
+ __privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
1075
+ __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
1076
+ __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
1077
+ this.any = this.any.bind(this);
1078
+ this.all = this.all.bind(this);
1079
+ this.not = this.not.bind(this);
1080
+ this.filter = this.filter.bind(this);
1081
+ this.sort = this.sort.bind(this);
1082
+ this.none = this.none.bind(this);
1083
+ Object.defineProperty(this, "table", { enumerable: false });
1084
+ Object.defineProperty(this, "repository", { enumerable: false });
1085
+ }
1086
+ getQueryOptions() {
1087
+ return __privateGet$5(this, _data);
1088
+ }
1089
+ key() {
1090
+ const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$5(this, _data);
1091
+ const key = JSON.stringify({ columns, filter, sort, pagination });
1092
+ return toBase64(key);
1093
+ }
1094
+ any(...queries) {
1095
+ const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
1096
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
1097
+ }
1098
+ all(...queries) {
1099
+ const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
1100
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1101
+ }
1102
+ not(...queries) {
1103
+ const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
1104
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
1105
+ }
1106
+ none(...queries) {
1107
+ const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
1108
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
1109
+ }
1110
+ filter(a, b) {
1111
+ if (arguments.length === 1) {
1112
+ const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
1113
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1114
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1115
+ } else {
1116
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
1117
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1118
+ }
1119
+ }
1120
+ sort(column, direction) {
1121
+ const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1122
+ const sort = [...originalSort, { column, direction }];
1123
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
1124
+ }
1125
+ select(columns) {
1126
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { columns }, __privateGet$5(this, _data));
1127
+ }
1128
+ getPaginated(options = {}) {
1129
+ const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
1130
+ return __privateGet$5(this, _repository).query(query);
1131
+ }
1132
+ async *[Symbol.asyncIterator]() {
1133
+ for await (const [record] of this.getIterator({ batchSize: 1 })) {
1134
+ yield record;
1135
+ }
1136
+ }
1137
+ async *getIterator(options = {}) {
1138
+ const { batchSize = 1 } = options;
1139
+ let page = await this.getPaginated({ ...options, pagination: { size: batchSize, offset: 0 } });
1140
+ let more = page.hasNextPage();
1141
+ yield page.records;
1142
+ while (more) {
1143
+ page = await page.nextPage();
1144
+ more = page.hasNextPage();
1145
+ yield page.records;
1146
+ }
1147
+ }
1148
+ async getMany(options = {}) {
1149
+ const page = await this.getPaginated(options);
1150
+ if (page.hasNextPage() && options.pagination?.size === void 0) {
1151
+ console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
1152
+ }
1153
+ return page.records;
1154
+ }
1155
+ async getAll(options = {}) {
1156
+ const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
1157
+ const results = [];
1158
+ for await (const page of this.getIterator({ ...rest, batchSize })) {
1159
+ results.push(...page);
1160
+ }
1161
+ return results;
1162
+ }
1163
+ async getFirst(options = {}) {
1164
+ const records = await this.getMany({ ...options, pagination: { size: 1 } });
1165
+ return records[0] ?? null;
1166
+ }
1167
+ cache(ttl) {
1168
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1169
+ }
1170
+ nextPage(size, offset) {
1171
+ return this.firstPage(size, offset);
1172
+ }
1173
+ previousPage(size, offset) {
1174
+ return this.firstPage(size, offset);
1175
+ }
1176
+ firstPage(size, offset) {
1177
+ return this.getPaginated({ pagination: { size, offset } });
1178
+ }
1179
+ lastPage(size, offset) {
1180
+ return this.getPaginated({ pagination: { size, offset, before: "end" } });
1181
+ }
1182
+ hasNextPage() {
1183
+ return this.meta.page.more;
1184
+ }
1185
+ };
1186
+ let Query = _Query;
1187
+ _table$1 = new WeakMap();
1188
+ _repository = new WeakMap();
1189
+ _data = new WeakMap();
1190
+ function cleanParent(data, parent) {
1191
+ if (isCursorPaginationOptions(data.pagination)) {
1192
+ return { ...parent, sorting: void 0, filter: void 0 };
1193
+ }
1194
+ return parent;
1195
+ }
1196
+
1197
+ function isIdentifiable(x) {
1198
+ return isObject(x) && isString(x?.id);
1199
+ }
1200
+ function isXataRecord(x) {
1201
+ const record = x;
1202
+ const metadata = record?.getMetadata();
1203
+ return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
1204
+ }
1205
+
1206
+ function isSortFilterString(value) {
1207
+ return isString(value);
1208
+ }
1209
+ function isSortFilterBase(filter) {
1210
+ return isObject(filter) && Object.values(filter).every((value) => value === "asc" || value === "desc");
1211
+ }
1212
+ function isSortFilterObject(filter) {
1213
+ return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
1214
+ }
1215
+ function buildSortFilter(filter) {
1216
+ if (isSortFilterString(filter)) {
1217
+ return { [filter]: "asc" };
1218
+ } else if (Array.isArray(filter)) {
1219
+ return filter.map((item) => buildSortFilter(item));
1220
+ } else if (isSortFilterBase(filter)) {
1221
+ return filter;
1222
+ } else if (isSortFilterObject(filter)) {
1223
+ return { [filter.column]: filter.direction ?? "asc" };
1224
+ } else {
1225
+ throw new Error(`Invalid sort filter: ${filter}`);
1226
+ }
1227
+ }
1228
+
1229
+ var __accessCheck$4 = (obj, member, msg) => {
1230
+ if (!member.has(obj))
1231
+ throw TypeError("Cannot " + msg);
1232
+ };
1233
+ var __privateGet$4 = (obj, member, getter) => {
1234
+ __accessCheck$4(obj, member, "read from private field");
1235
+ return getter ? getter.call(obj) : member.get(obj);
1236
+ };
1237
+ var __privateAdd$4 = (obj, member, value) => {
1238
+ if (member.has(obj))
1239
+ throw TypeError("Cannot add the same private member more than once");
1240
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1241
+ };
1242
+ var __privateSet$3 = (obj, member, value, setter) => {
1243
+ __accessCheck$4(obj, member, "write to private field");
1244
+ setter ? setter.call(obj, value) : member.set(obj, value);
1245
+ return value;
1246
+ };
1247
+ var __privateMethod$2 = (obj, member, method) => {
1248
+ __accessCheck$4(obj, member, "access private method");
1249
+ return method;
1250
+ };
1251
+ var _table, _getFetchProps, _cache, _schema$1, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _invalidateCache, invalidateCache_fn, _setCacheRecord, setCacheRecord_fn, _getCacheRecord, getCacheRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchema$1, getSchema_fn$1;
1252
+ class Repository extends Query {
1253
+ }
1254
+ class RestRepository extends Query {
1255
+ constructor(options) {
1256
+ super(null, options.table, {});
1257
+ __privateAdd$4(this, _insertRecordWithoutId);
1258
+ __privateAdd$4(this, _insertRecordWithId);
1259
+ __privateAdd$4(this, _bulkInsertTableRecords);
1260
+ __privateAdd$4(this, _updateRecordWithID);
1261
+ __privateAdd$4(this, _upsertRecordWithID);
1262
+ __privateAdd$4(this, _deleteRecord);
1263
+ __privateAdd$4(this, _invalidateCache);
1264
+ __privateAdd$4(this, _setCacheRecord);
1265
+ __privateAdd$4(this, _getCacheRecord);
1266
+ __privateAdd$4(this, _setCacheQuery);
1267
+ __privateAdd$4(this, _getCacheQuery);
1268
+ __privateAdd$4(this, _getSchema$1);
1269
+ __privateAdd$4(this, _table, void 0);
1270
+ __privateAdd$4(this, _getFetchProps, void 0);
1271
+ __privateAdd$4(this, _cache, void 0);
1272
+ __privateAdd$4(this, _schema$1, void 0);
1273
+ __privateSet$3(this, _table, options.table);
1274
+ __privateSet$3(this, _getFetchProps, options.pluginOptions.getFetchProps);
1275
+ this.db = options.db;
1276
+ __privateSet$3(this, _cache, options.pluginOptions.cache);
1277
+ }
1278
+ async create(a, b) {
1279
+ if (Array.isArray(a)) {
1280
+ if (a.length === 0)
1281
+ return [];
1282
+ const [itemsWithoutIds, itemsWithIds, order] = a.reduce(([accWithoutIds, accWithIds, accOrder], item) => {
1283
+ const condition = isString(item.id);
1284
+ accOrder.push(condition);
1285
+ if (condition) {
1286
+ accWithIds.push(item);
1287
+ } else {
1288
+ accWithoutIds.push(item);
1289
+ }
1290
+ return [accWithoutIds, accWithIds, accOrder];
1291
+ }, [[], [], []]);
1292
+ const recordsWithoutId = await __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, itemsWithoutIds);
1293
+ await Promise.all(recordsWithoutId.map((record) => __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record)));
1294
+ if (itemsWithIds.length > 100) {
1295
+ console.warn("Bulk create operation with id is not optimized in the Xata API yet, this request might be slow");
1296
+ }
1297
+ const recordsWithId = await Promise.all(itemsWithIds.map((object) => this.create(object)));
1298
+ return order.map((condition) => {
1299
+ if (condition) {
1300
+ return recordsWithId.shift();
1301
+ } else {
1302
+ return recordsWithoutId.shift();
1303
+ }
1304
+ }).filter((record) => !!record);
1305
+ }
1306
+ if (isString(a) && isObject(b)) {
1307
+ if (a === "")
1308
+ throw new Error("The id can't be empty");
1309
+ const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b);
1310
+ await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1311
+ return record;
1312
+ }
1313
+ if (isObject(a) && isString(a.id)) {
1314
+ if (a.id === "")
1315
+ throw new Error("The id can't be empty");
1316
+ const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 });
1317
+ await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1318
+ return record;
1319
+ }
1320
+ if (isObject(a)) {
1321
+ const record = await __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a);
1322
+ await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1323
+ return record;
1324
+ }
1325
+ throw new Error("Invalid arguments for create method");
1326
+ }
1327
+ async read(a) {
1328
+ if (Array.isArray(a)) {
1329
+ if (a.length === 0)
1330
+ return [];
1331
+ const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
1332
+ return this.getAll({ filter: { id: { $any: ids } } });
1333
+ }
1334
+ const id = isString(a) ? a : a.id;
1335
+ if (isString(id)) {
1336
+ const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, id);
1337
+ if (cacheRecord)
1338
+ return cacheRecord;
1339
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1340
+ try {
1341
+ const response = await getRecord({
1342
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: id },
1343
+ ...fetchProps
1344
+ });
1345
+ const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1346
+ return initObject(this.db, schema, __privateGet$4(this, _table), response);
1347
+ } catch (e) {
1348
+ if (isObject(e) && e.status === 404) {
1349
+ return null;
1350
+ }
1351
+ throw e;
1352
+ }
1353
+ }
1354
+ }
1355
+ async update(a, b) {
1356
+ if (Array.isArray(a)) {
1357
+ if (a.length === 0)
1358
+ return [];
1359
+ if (a.length > 100) {
1360
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1361
+ }
1362
+ return Promise.all(a.map((object) => this.update(object)));
1363
+ }
1364
+ if (isString(a) && isObject(b)) {
1365
+ await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1366
+ const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b);
1367
+ await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1368
+ return record;
1369
+ }
1370
+ if (isObject(a) && isString(a.id)) {
1371
+ await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1372
+ const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1373
+ await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1374
+ return record;
1375
+ }
1376
+ throw new Error("Invalid arguments for update method");
1377
+ }
1378
+ async createOrUpdate(a, b) {
1379
+ if (Array.isArray(a)) {
1380
+ if (a.length === 0)
1381
+ return [];
1382
+ if (a.length > 100) {
1383
+ console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1384
+ }
1385
+ return Promise.all(a.map((object) => this.createOrUpdate(object)));
1386
+ }
1387
+ if (isString(a) && isObject(b)) {
1388
+ await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1389
+ const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b);
1390
+ await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1391
+ return record;
1392
+ }
1393
+ if (isObject(a) && isString(a.id)) {
1394
+ await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1395
+ const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1396
+ await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1397
+ return record;
1398
+ }
1399
+ throw new Error("Invalid arguments for createOrUpdate method");
1400
+ }
1401
+ async delete(a) {
1402
+ if (Array.isArray(a)) {
1403
+ if (a.length === 0)
1404
+ return;
1405
+ if (a.length > 100) {
1406
+ console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1407
+ }
1408
+ await Promise.all(a.map((id) => this.delete(id)));
1409
+ return;
1410
+ }
1411
+ if (isString(a)) {
1412
+ await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
1413
+ await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1414
+ return;
1415
+ }
1416
+ if (isObject(a) && isString(a.id)) {
1417
+ await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
1418
+ await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1419
+ return;
1420
+ }
1421
+ throw new Error("Invalid arguments for delete method");
1422
+ }
1423
+ async search(query, options = {}) {
1424
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1425
+ const { records } = await searchTable({
1426
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1427
+ body: {
1428
+ query,
1429
+ fuzziness: options.fuzziness,
1430
+ prefix: options.prefix,
1431
+ highlight: options.highlight,
1432
+ filter: options.filter,
1433
+ boosters: options.boosters
1434
+ },
1435
+ ...fetchProps
1436
+ });
1437
+ const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1438
+ return records.map((item) => initObject(this.db, schema, __privateGet$4(this, _table), item));
1439
+ }
1440
+ async query(query) {
1441
+ const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
1442
+ if (cacheQuery)
1443
+ return new Page(query, cacheQuery.meta, cacheQuery.records);
1444
+ const data = query.getQueryOptions();
1445
+ const body = {
1446
+ filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1447
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1448
+ page: data.pagination,
1449
+ columns: data.columns
1450
+ };
1451
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1452
+ const { meta, records: objects } = await queryTable({
1453
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1454
+ body,
1455
+ ...fetchProps
1456
+ });
1457
+ const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1458
+ const records = objects.map((record) => initObject(this.db, schema, __privateGet$4(this, _table), record));
1459
+ await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1460
+ return new Page(query, meta, records);
1461
+ }
1462
+ }
1463
+ _table = new WeakMap();
1464
+ _getFetchProps = new WeakMap();
1465
+ _cache = new WeakMap();
1466
+ _schema$1 = new WeakMap();
1467
+ _insertRecordWithoutId = new WeakSet();
1468
+ insertRecordWithoutId_fn = async function(object) {
1469
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1470
+ const record = transformObjectLinks(object);
1471
+ const response = await insertRecord({
1472
+ pathParams: {
1473
+ workspace: "{workspaceId}",
1474
+ dbBranchName: "{dbBranch}",
1475
+ tableName: __privateGet$4(this, _table)
1476
+ },
1477
+ body: record,
1478
+ ...fetchProps
1479
+ });
1480
+ const finalObject = await this.read(response.id);
1481
+ if (!finalObject) {
1482
+ throw new Error("The server failed to save the record");
1483
+ }
1484
+ return finalObject;
1485
+ };
1486
+ _insertRecordWithId = new WeakSet();
1487
+ insertRecordWithId_fn = async function(recordId, object) {
1488
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1489
+ const record = transformObjectLinks(object);
1490
+ const response = await insertRecordWithID({
1491
+ pathParams: {
1492
+ workspace: "{workspaceId}",
1493
+ dbBranchName: "{dbBranch}",
1494
+ tableName: __privateGet$4(this, _table),
1495
+ recordId
1496
+ },
1497
+ body: record,
1498
+ queryParams: { createOnly: true },
1499
+ ...fetchProps
1500
+ });
1501
+ const finalObject = await this.read(response.id);
1502
+ if (!finalObject) {
1503
+ throw new Error("The server failed to save the record");
1504
+ }
1505
+ return finalObject;
1506
+ };
1507
+ _bulkInsertTableRecords = new WeakSet();
1508
+ bulkInsertTableRecords_fn = async function(objects) {
1509
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1510
+ const records = objects.map((object) => transformObjectLinks(object));
1511
+ const response = await bulkInsertTableRecords({
1512
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1513
+ body: { records },
1514
+ ...fetchProps
1515
+ });
1516
+ const finalObjects = await this.read(response.recordIDs);
1517
+ if (finalObjects.length !== objects.length) {
1518
+ throw new Error("The server failed to save some records");
1519
+ }
1520
+ return finalObjects;
1521
+ };
1522
+ _updateRecordWithID = new WeakSet();
1523
+ updateRecordWithID_fn = async function(recordId, object) {
1524
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1525
+ const record = transformObjectLinks(object);
1526
+ const response = await updateRecordWithID({
1527
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1528
+ body: record,
1529
+ ...fetchProps
1530
+ });
1531
+ const item = await this.read(response.id);
1532
+ if (!item)
1533
+ throw new Error("The server failed to save the record");
1534
+ return item;
1535
+ };
1536
+ _upsertRecordWithID = new WeakSet();
1537
+ upsertRecordWithID_fn = async function(recordId, object) {
1538
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1539
+ const response = await upsertRecordWithID({
1540
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1541
+ body: object,
1542
+ ...fetchProps
1543
+ });
1544
+ const item = await this.read(response.id);
1545
+ if (!item)
1546
+ throw new Error("The server failed to save the record");
1547
+ return item;
1548
+ };
1549
+ _deleteRecord = new WeakSet();
1550
+ deleteRecord_fn = async function(recordId) {
1551
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1552
+ await deleteRecord({
1553
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1554
+ ...fetchProps
1555
+ });
1556
+ };
1557
+ _invalidateCache = new WeakSet();
1558
+ invalidateCache_fn = async function(recordId) {
1559
+ await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1560
+ const cacheItems = await __privateGet$4(this, _cache).getAll();
1561
+ const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
1562
+ for (const [key, value] of queries) {
1563
+ const ids = getIds(value);
1564
+ if (ids.includes(recordId))
1565
+ await __privateGet$4(this, _cache).delete(key);
1566
+ }
1567
+ };
1568
+ _setCacheRecord = new WeakSet();
1569
+ setCacheRecord_fn = async function(record) {
1570
+ if (!__privateGet$4(this, _cache).cacheRecords)
1571
+ return;
1572
+ await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
1573
+ };
1574
+ _getCacheRecord = new WeakSet();
1575
+ getCacheRecord_fn = async function(recordId) {
1576
+ if (!__privateGet$4(this, _cache).cacheRecords)
1577
+ return null;
1578
+ return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1579
+ };
1580
+ _setCacheQuery = new WeakSet();
1581
+ setCacheQuery_fn = async function(query, meta, records) {
1582
+ await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
1583
+ };
1584
+ _getCacheQuery = new WeakSet();
1585
+ getCacheQuery_fn = async function(query) {
1586
+ const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
1587
+ const result = await __privateGet$4(this, _cache).get(key);
1588
+ if (!result)
1589
+ return null;
1590
+ const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
1591
+ if (ttl < 0)
1592
+ return null;
1593
+ const hasExpired = result.date.getTime() + ttl < Date.now();
1594
+ return hasExpired ? null : result;
1595
+ };
1596
+ _getSchema$1 = new WeakSet();
1597
+ getSchema_fn$1 = async function() {
1598
+ if (__privateGet$4(this, _schema$1))
1599
+ return __privateGet$4(this, _schema$1);
1600
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1601
+ const { schema } = await getBranchDetails({
1602
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1603
+ ...fetchProps
1604
+ });
1605
+ __privateSet$3(this, _schema$1, schema);
1606
+ return schema;
1607
+ };
1608
+ const transformObjectLinks = (object) => {
1609
+ return Object.entries(object).reduce((acc, [key, value]) => {
1610
+ if (key === "xata")
1611
+ return acc;
1612
+ return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
1613
+ }, {});
1614
+ };
1615
+ const initObject = (db, schema, table, object) => {
1616
+ const result = {};
1617
+ const { xata, ...rest } = object ?? {};
1618
+ Object.assign(result, rest);
1619
+ const { columns } = schema.tables.find(({ name }) => name === table) ?? {};
1620
+ if (!columns)
1621
+ console.error(`Table ${table} not found in schema`);
1622
+ for (const column of columns ?? []) {
1623
+ const value = result[column.name];
1624
+ switch (column.type) {
1625
+ case "datetime": {
1626
+ const date = value !== void 0 ? new Date(value) : void 0;
1627
+ if (date && isNaN(date.getTime())) {
1628
+ console.error(`Failed to parse date ${value} for field ${column.name}`);
1629
+ } else if (date) {
1630
+ result[column.name] = date;
1631
+ }
1632
+ break;
1633
+ }
1634
+ case "link": {
1635
+ const linkTable = column.link?.table;
1636
+ if (!linkTable) {
1637
+ console.error(`Failed to parse link for field ${column.name}`);
1638
+ } else if (isObject(value)) {
1639
+ result[column.name] = initObject(db, schema, linkTable, value);
1640
+ }
1641
+ break;
1642
+ }
1643
+ }
1644
+ }
1645
+ result.read = function() {
1646
+ return db[table].read(result["id"]);
1647
+ };
1648
+ result.update = function(data) {
1649
+ return db[table].update(result["id"], data);
1650
+ };
1651
+ result.delete = function() {
1652
+ return db[table].delete(result["id"]);
1653
+ };
1654
+ result.getMetadata = function() {
1655
+ return xata;
1656
+ };
1657
+ for (const prop of ["read", "update", "delete", "getMetadata"]) {
1658
+ Object.defineProperty(result, prop, { enumerable: false });
1659
+ }
1660
+ Object.freeze(result);
1661
+ return result;
1662
+ };
1663
+ function getIds(value) {
1664
+ if (Array.isArray(value)) {
1665
+ return value.map((item) => getIds(item)).flat();
1666
+ }
1667
+ if (!isObject(value))
1668
+ return [];
1669
+ const nestedIds = Object.values(value).map((item) => getIds(item)).flat();
1670
+ return isString(value.id) ? [value.id, ...nestedIds] : nestedIds;
1671
+ }
1672
+
1673
+ var __accessCheck$3 = (obj, member, msg) => {
1674
+ if (!member.has(obj))
1675
+ throw TypeError("Cannot " + msg);
1676
+ };
1677
+ var __privateGet$3 = (obj, member, getter) => {
1678
+ __accessCheck$3(obj, member, "read from private field");
1679
+ return getter ? getter.call(obj) : member.get(obj);
1680
+ };
1681
+ var __privateAdd$3 = (obj, member, value) => {
1682
+ if (member.has(obj))
1683
+ throw TypeError("Cannot add the same private member more than once");
1684
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1685
+ };
1686
+ var __privateSet$2 = (obj, member, value, setter) => {
1687
+ __accessCheck$3(obj, member, "write to private field");
1688
+ setter ? setter.call(obj, value) : member.set(obj, value);
1689
+ return value;
1690
+ };
1691
+ var _map;
1692
+ class SimpleCache {
1693
+ constructor(options = {}) {
1694
+ __privateAdd$3(this, _map, void 0);
1695
+ __privateSet$2(this, _map, /* @__PURE__ */ new Map());
1696
+ this.capacity = options.max ?? 500;
1697
+ this.cacheRecords = options.cacheRecords ?? true;
1698
+ this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
1699
+ }
1700
+ async getAll() {
1701
+ return Object.fromEntries(__privateGet$3(this, _map));
1702
+ }
1703
+ async get(key) {
1704
+ return __privateGet$3(this, _map).get(key) ?? null;
1705
+ }
1706
+ async set(key, value) {
1707
+ await this.delete(key);
1708
+ __privateGet$3(this, _map).set(key, value);
1709
+ if (__privateGet$3(this, _map).size > this.capacity) {
1710
+ const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
1711
+ await this.delete(leastRecentlyUsed);
1712
+ }
1713
+ }
1714
+ async delete(key) {
1715
+ __privateGet$3(this, _map).delete(key);
1716
+ }
1717
+ async clear() {
1718
+ return __privateGet$3(this, _map).clear();
1719
+ }
1720
+ }
1721
+ _map = new WeakMap();
1722
+
1723
+ const gt = (value) => ({ $gt: value });
1724
+ const ge = (value) => ({ $ge: value });
1725
+ const gte = (value) => ({ $ge: value });
1726
+ const lt = (value) => ({ $lt: value });
1727
+ const lte = (value) => ({ $le: value });
1728
+ const le = (value) => ({ $le: value });
1729
+ const exists = (column) => ({ $exists: column });
1730
+ const notExists = (column) => ({ $notExists: column });
1731
+ const startsWith = (value) => ({ $startsWith: value });
1732
+ const endsWith = (value) => ({ $endsWith: value });
1733
+ const pattern = (value) => ({ $pattern: value });
1734
+ const is = (value) => ({ $is: value });
1735
+ const isNot = (value) => ({ $isNot: value });
1736
+ const contains = (value) => ({ $contains: value });
1737
+ const includes = (value) => ({ $includes: value });
1738
+ const includesAll = (value) => ({ $includesAll: value });
1739
+ const includesNone = (value) => ({ $includesNone: value });
1740
+ const includesAny = (value) => ({ $includesAny: value });
1741
+
1742
+ var __accessCheck$2 = (obj, member, msg) => {
1743
+ if (!member.has(obj))
1744
+ throw TypeError("Cannot " + msg);
1745
+ };
1746
+ var __privateGet$2 = (obj, member, getter) => {
1747
+ __accessCheck$2(obj, member, "read from private field");
1748
+ return getter ? getter.call(obj) : member.get(obj);
1749
+ };
1750
+ var __privateAdd$2 = (obj, member, value) => {
1751
+ if (member.has(obj))
1752
+ throw TypeError("Cannot add the same private member more than once");
1753
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1754
+ };
1755
+ var _tables;
1756
+ class SchemaPlugin extends XataPlugin {
1757
+ constructor(tableNames) {
1758
+ super();
1759
+ this.tableNames = tableNames;
1760
+ __privateAdd$2(this, _tables, {});
1761
+ }
1762
+ build(pluginOptions) {
1763
+ const db = new Proxy({}, {
1764
+ get: (_target, table) => {
1765
+ if (!isString(table))
1766
+ throw new Error("Invalid table name");
1767
+ if (__privateGet$2(this, _tables)[table] === void 0) {
1768
+ __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
1769
+ }
1770
+ return __privateGet$2(this, _tables)[table];
1771
+ }
1772
+ });
1773
+ for (const table of this.tableNames ?? []) {
1774
+ db[table] = new RestRepository({ db, pluginOptions, table });
1775
+ }
1776
+ return db;
1777
+ }
1778
+ }
1779
+ _tables = new WeakMap();
1780
+
1781
+ var __accessCheck$1 = (obj, member, msg) => {
1782
+ if (!member.has(obj))
1783
+ throw TypeError("Cannot " + msg);
1784
+ };
1785
+ var __privateGet$1 = (obj, member, getter) => {
1786
+ __accessCheck$1(obj, member, "read from private field");
1787
+ return getter ? getter.call(obj) : member.get(obj);
1788
+ };
1789
+ var __privateAdd$1 = (obj, member, value) => {
1790
+ if (member.has(obj))
1791
+ throw TypeError("Cannot add the same private member more than once");
1792
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1793
+ };
1794
+ var __privateSet$1 = (obj, member, value, setter) => {
1795
+ __accessCheck$1(obj, member, "write to private field");
1796
+ setter ? setter.call(obj, value) : member.set(obj, value);
1797
+ return value;
1798
+ };
1799
+ var __privateMethod$1 = (obj, member, method) => {
1800
+ __accessCheck$1(obj, member, "access private method");
1801
+ return method;
1802
+ };
1803
+ var _schema, _search, search_fn, _getSchema, getSchema_fn;
1804
+ class SearchPlugin extends XataPlugin {
1805
+ constructor(db) {
1806
+ super();
1807
+ this.db = db;
1808
+ __privateAdd$1(this, _search);
1809
+ __privateAdd$1(this, _getSchema);
1810
+ __privateAdd$1(this, _schema, void 0);
1811
+ }
1812
+ build({ getFetchProps }) {
1813
+ return {
1814
+ all: async (query, options = {}) => {
1815
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
1816
+ const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
1817
+ return records.map((record) => {
1818
+ const { table = "orphan" } = record.xata;
1819
+ return { table, record: initObject(this.db, schema, table, record) };
1820
+ });
1821
+ },
1822
+ byTable: async (query, options = {}) => {
1823
+ const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
1824
+ const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
1825
+ return records.reduce((acc, record) => {
1826
+ const { table = "orphan" } = record.xata;
1827
+ const items = acc[table] ?? [];
1828
+ const item = initObject(this.db, schema, table, record);
1829
+ return { ...acc, [table]: [...items, item] };
1830
+ }, {});
1831
+ }
1832
+ };
1833
+ }
1834
+ }
1835
+ _schema = new WeakMap();
1836
+ _search = new WeakSet();
1837
+ search_fn = async function(query, options, getFetchProps) {
1838
+ const fetchProps = await getFetchProps();
1839
+ const { tables, fuzziness, highlight, prefix } = options ?? {};
1840
+ const { records } = await searchBranch({
1841
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1842
+ body: { tables, query, fuzziness, prefix, highlight },
1843
+ ...fetchProps
1844
+ });
1845
+ return records;
1846
+ };
1847
+ _getSchema = new WeakSet();
1848
+ getSchema_fn = async function(getFetchProps) {
1849
+ if (__privateGet$1(this, _schema))
1850
+ return __privateGet$1(this, _schema);
1851
+ const fetchProps = await getFetchProps();
1852
+ const { schema } = await getBranchDetails({
1853
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1854
+ ...fetchProps
1855
+ });
1856
+ __privateSet$1(this, _schema, schema);
1857
+ return schema;
1858
+ };
1859
+
1860
+ const isBranchStrategyBuilder = (strategy) => {
1861
+ return typeof strategy === "function";
1862
+ };
1863
+
1864
+ const envBranchNames = [
1865
+ "XATA_BRANCH",
1866
+ "VERCEL_GIT_COMMIT_REF",
1867
+ "CF_PAGES_BRANCH",
1868
+ "BRANCH"
1869
+ ];
1870
+ async function getCurrentBranchName(options) {
1871
+ const env = getBranchByEnvVariable();
1872
+ if (env) {
1873
+ const details = await getDatabaseBranch(env, options);
1874
+ if (details)
1875
+ return env;
1876
+ console.warn(`Branch ${env} not found in Xata. Ignoring...`);
1877
+ }
1878
+ const gitBranch = await getGitBranch();
1879
+ return resolveXataBranch(gitBranch, options);
1880
+ }
1881
+ async function getCurrentBranchDetails(options) {
1882
+ const branch = await getCurrentBranchName(options);
1883
+ return getDatabaseBranch(branch, options);
1884
+ }
1885
+ async function resolveXataBranch(gitBranch, options) {
1886
+ const databaseURL = options?.databaseURL || getDatabaseURL();
1887
+ const apiKey = options?.apiKey || getAPIKey();
1888
+ if (!databaseURL)
1889
+ throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
1890
+ if (!apiKey)
1891
+ throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
1892
+ const [protocol, , host, , dbName] = databaseURL.split("/");
1893
+ const [workspace] = host.split(".");
1894
+ const { branch } = await resolveBranch({
1895
+ apiKey,
1896
+ apiUrl: databaseURL,
1897
+ fetchImpl: getFetchImplementation(options?.fetchImpl),
1898
+ workspacesApiUrl: `${protocol}//${host}`,
1899
+ pathParams: { dbName, workspace },
1900
+ queryParams: { gitBranch, fallbackBranch: getEnvVariable("XATA_FALLBACK_BRANCH") }
1901
+ });
1902
+ return branch;
1903
+ }
1904
+ async function getDatabaseBranch(branch, options) {
1905
+ const databaseURL = options?.databaseURL || getDatabaseURL();
1906
+ const apiKey = options?.apiKey || getAPIKey();
1907
+ if (!databaseURL)
1908
+ throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
1909
+ if (!apiKey)
1910
+ throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
1911
+ const [protocol, , host, , database] = databaseURL.split("/");
1912
+ const [workspace] = host.split(".");
1913
+ const dbBranchName = `${database}:${branch}`;
1914
+ try {
1915
+ return await getBranchDetails({
1916
+ apiKey,
1917
+ apiUrl: databaseURL,
1918
+ fetchImpl: getFetchImplementation(options?.fetchImpl),
1919
+ workspacesApiUrl: `${protocol}//${host}`,
1920
+ pathParams: { dbBranchName, workspace }
1921
+ });
1922
+ } catch (err) {
1923
+ if (isObject(err) && err.status === 404)
1924
+ return null;
1925
+ throw err;
1926
+ }
1927
+ }
1928
+ function getBranchByEnvVariable() {
1929
+ for (const name of envBranchNames) {
1930
+ const value = getEnvVariable(name);
1931
+ if (value) {
1932
+ return value;
1933
+ }
1934
+ }
1935
+ try {
1936
+ return XATA_BRANCH;
1937
+ } catch (err) {
1938
+ }
1939
+ }
1940
+ function getDatabaseURL() {
1941
+ try {
1942
+ return getEnvVariable("XATA_DATABASE_URL") ?? XATA_DATABASE_URL;
1943
+ } catch (err) {
1944
+ return void 0;
1945
+ }
1946
+ }
1947
+
1948
+ var __accessCheck = (obj, member, msg) => {
1949
+ if (!member.has(obj))
1950
+ throw TypeError("Cannot " + msg);
1951
+ };
1952
+ var __privateGet = (obj, member, getter) => {
1953
+ __accessCheck(obj, member, "read from private field");
1954
+ return getter ? getter.call(obj) : member.get(obj);
1955
+ };
1956
+ var __privateAdd = (obj, member, value) => {
1957
+ if (member.has(obj))
1958
+ throw TypeError("Cannot add the same private member more than once");
1959
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1960
+ };
1961
+ var __privateSet = (obj, member, value, setter) => {
1962
+ __accessCheck(obj, member, "write to private field");
1963
+ setter ? setter.call(obj, value) : member.set(obj, value);
1964
+ return value;
1965
+ };
1966
+ var __privateMethod = (obj, member, method) => {
1967
+ __accessCheck(obj, member, "access private method");
1968
+ return method;
1969
+ };
1970
+ const buildClient = (plugins) => {
1971
+ var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
1972
+ return _a = class {
1973
+ constructor(options = {}, tables) {
1974
+ __privateAdd(this, _parseOptions);
1975
+ __privateAdd(this, _getFetchProps);
1976
+ __privateAdd(this, _evaluateBranch);
1977
+ __privateAdd(this, _branch, void 0);
1978
+ const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
1979
+ const pluginOptions = {
1980
+ getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
1981
+ cache: safeOptions.cache
1982
+ };
1983
+ const db = new SchemaPlugin(tables).build(pluginOptions);
1984
+ const search = new SearchPlugin(db).build(pluginOptions);
1985
+ this.db = db;
1986
+ this.search = search;
1987
+ for (const [key, namespace] of Object.entries(plugins ?? {})) {
1988
+ if (namespace === void 0)
1989
+ continue;
1990
+ const result = namespace.build(pluginOptions);
1991
+ if (result instanceof Promise) {
1992
+ void result.then((namespace2) => {
1993
+ this[key] = namespace2;
1994
+ });
1995
+ } else {
1996
+ this[key] = result;
1997
+ }
1998
+ }
1999
+ }
2000
+ }, _branch = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
2001
+ const fetch = getFetchImplementation(options?.fetch);
2002
+ const databaseURL = options?.databaseURL || getDatabaseURL();
2003
+ const apiKey = options?.apiKey || getAPIKey();
2004
+ const cache = options?.cache ?? new SimpleCache({ cacheRecords: false, defaultQueryTTL: 0 });
2005
+ const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
2006
+ if (!databaseURL || !apiKey) {
2007
+ throw new Error("Options databaseURL and apiKey are required");
2008
+ }
2009
+ return { fetch, databaseURL, apiKey, branch, cache };
2010
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
2011
+ fetch,
2012
+ apiKey,
2013
+ databaseURL,
2014
+ branch
2015
+ }) {
2016
+ const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2017
+ if (!branchValue)
2018
+ throw new Error("Unable to resolve branch value");
2019
+ return {
2020
+ fetchImpl: fetch,
2021
+ apiKey,
2022
+ apiUrl: "",
2023
+ workspacesApiUrl: (path, params) => {
2024
+ const hasBranch = params.dbBranchName ?? params.branch;
2025
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
2026
+ return databaseURL + newPath;
2027
+ }
2028
+ };
2029
+ }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
2030
+ if (__privateGet(this, _branch))
2031
+ return __privateGet(this, _branch);
2032
+ if (param === void 0)
2033
+ return void 0;
2034
+ const strategies = Array.isArray(param) ? [...param] : [param];
2035
+ const evaluateBranch = async (strategy) => {
2036
+ return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
2037
+ };
2038
+ for await (const strategy of strategies) {
2039
+ const branch = await evaluateBranch(strategy);
2040
+ if (branch) {
2041
+ __privateSet(this, _branch, branch);
2042
+ return branch;
2043
+ }
2044
+ }
2045
+ }, _a;
2046
+ };
2047
+ class BaseClient extends buildClient() {
2048
+ }
2049
+
2050
+ class XataError extends Error {
2051
+ constructor(message, status) {
2052
+ super(message);
2053
+ this.status = status;
2054
+ }
2055
+ }
2056
+
2057
+ exports.BaseClient = BaseClient;
2058
+ exports.Operations = operationsByTag;
2059
+ exports.PAGINATION_DEFAULT_OFFSET = PAGINATION_DEFAULT_OFFSET;
2060
+ exports.PAGINATION_DEFAULT_SIZE = PAGINATION_DEFAULT_SIZE;
2061
+ exports.PAGINATION_MAX_OFFSET = PAGINATION_MAX_OFFSET;
2062
+ exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
2063
+ exports.Page = Page;
2064
+ exports.Query = Query;
2065
+ exports.RecordArray = RecordArray;
2066
+ exports.Repository = Repository;
2067
+ exports.RestRepository = RestRepository;
2068
+ exports.SchemaPlugin = SchemaPlugin;
2069
+ exports.SearchPlugin = SearchPlugin;
2070
+ exports.SimpleCache = SimpleCache;
2071
+ exports.XataApiClient = XataApiClient;
2072
+ exports.XataApiPlugin = XataApiPlugin;
2073
+ exports.XataError = XataError;
2074
+ exports.XataPlugin = XataPlugin;
2075
+ exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
2076
+ exports.addGitBranchesEntry = addGitBranchesEntry;
2077
+ exports.addTableColumn = addTableColumn;
2078
+ exports.buildClient = buildClient;
2079
+ exports.bulkInsertTableRecords = bulkInsertTableRecords;
2080
+ exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
2081
+ exports.contains = contains;
2082
+ exports.createBranch = createBranch;
2083
+ exports.createDatabase = createDatabase;
2084
+ exports.createTable = createTable;
2085
+ exports.createUserAPIKey = createUserAPIKey;
2086
+ exports.createWorkspace = createWorkspace;
2087
+ exports.deleteBranch = deleteBranch;
2088
+ exports.deleteColumn = deleteColumn;
2089
+ exports.deleteDatabase = deleteDatabase;
2090
+ exports.deleteRecord = deleteRecord;
2091
+ exports.deleteTable = deleteTable;
2092
+ exports.deleteUser = deleteUser;
2093
+ exports.deleteUserAPIKey = deleteUserAPIKey;
2094
+ exports.deleteWorkspace = deleteWorkspace;
2095
+ exports.endsWith = endsWith;
2096
+ exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
2097
+ exports.exists = exists;
2098
+ exports.ge = ge;
2099
+ exports.getAPIKey = getAPIKey;
2100
+ exports.getBranchDetails = getBranchDetails;
2101
+ exports.getBranchList = getBranchList;
2102
+ exports.getBranchMetadata = getBranchMetadata;
2103
+ exports.getBranchMigrationHistory = getBranchMigrationHistory;
2104
+ exports.getBranchMigrationPlan = getBranchMigrationPlan;
2105
+ exports.getBranchStats = getBranchStats;
2106
+ exports.getColumn = getColumn;
2107
+ exports.getCurrentBranchDetails = getCurrentBranchDetails;
2108
+ exports.getCurrentBranchName = getCurrentBranchName;
2109
+ exports.getDatabaseList = getDatabaseList;
2110
+ exports.getDatabaseURL = getDatabaseURL;
2111
+ exports.getGitBranchesMapping = getGitBranchesMapping;
2112
+ exports.getRecord = getRecord;
2113
+ exports.getTableColumns = getTableColumns;
2114
+ exports.getTableSchema = getTableSchema;
2115
+ exports.getUser = getUser;
2116
+ exports.getUserAPIKeys = getUserAPIKeys;
2117
+ exports.getWorkspace = getWorkspace;
2118
+ exports.getWorkspaceMembersList = getWorkspaceMembersList;
2119
+ exports.getWorkspacesList = getWorkspacesList;
2120
+ exports.gt = gt;
2121
+ exports.gte = gte;
2122
+ exports.includes = includes;
2123
+ exports.includesAll = includesAll;
2124
+ exports.includesAny = includesAny;
2125
+ exports.includesNone = includesNone;
2126
+ exports.insertRecord = insertRecord;
2127
+ exports.insertRecordWithID = insertRecordWithID;
2128
+ exports.inviteWorkspaceMember = inviteWorkspaceMember;
2129
+ exports.is = is;
2130
+ exports.isCursorPaginationOptions = isCursorPaginationOptions;
2131
+ exports.isIdentifiable = isIdentifiable;
2132
+ exports.isNot = isNot;
2133
+ exports.isXataRecord = isXataRecord;
2134
+ exports.le = le;
2135
+ exports.lt = lt;
2136
+ exports.lte = lte;
2137
+ exports.notExists = notExists;
2138
+ exports.operationsByTag = operationsByTag;
2139
+ exports.pattern = pattern;
2140
+ exports.queryTable = queryTable;
2141
+ exports.removeGitBranchesEntry = removeGitBranchesEntry;
2142
+ exports.removeWorkspaceMember = removeWorkspaceMember;
2143
+ exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
2144
+ exports.resolveBranch = resolveBranch;
2145
+ exports.searchBranch = searchBranch;
2146
+ exports.searchTable = searchTable;
2147
+ exports.setTableSchema = setTableSchema;
2148
+ exports.startsWith = startsWith;
2149
+ exports.updateBranchMetadata = updateBranchMetadata;
2150
+ exports.updateColumn = updateColumn;
2151
+ exports.updateRecordWithID = updateRecordWithID;
2152
+ exports.updateTable = updateTable;
2153
+ exports.updateUser = updateUser;
2154
+ exports.updateWorkspace = updateWorkspace;
2155
+ exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
2156
+ exports.upsertRecordWithID = upsertRecordWithID;
2157
+ //# sourceMappingURL=index.cjs.map