@xata.io/client 0.0.0-alpha.vf231460 → 0.0.0-alpha.vf28813b
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/.eslintrc.cjs +1 -2
- package/CHANGELOG.md +176 -0
- package/README.md +271 -1
- package/Usage.md +428 -0
- package/dist/index.cjs +774 -330
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1097 -245
- package/dist/index.mjs +747 -331
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -4
- package/tsconfig.json +1 -0
package/dist/index.cjs
CHANGED
@@ -2,6 +2,24 @@
|
|
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
|
+
|
5
23
|
function notEmpty(value) {
|
6
24
|
return value !== null && value !== void 0;
|
7
25
|
}
|
@@ -11,36 +29,101 @@ function compact(arr) {
|
|
11
29
|
function isObject(value) {
|
12
30
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
13
31
|
}
|
32
|
+
function isDefined(value) {
|
33
|
+
return value !== null && value !== void 0;
|
34
|
+
}
|
14
35
|
function isString(value) {
|
15
|
-
return value
|
36
|
+
return isDefined(value) && typeof value === "string";
|
37
|
+
}
|
38
|
+
function isStringArray(value) {
|
39
|
+
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
40
|
+
}
|
41
|
+
function toBase64(value) {
|
42
|
+
try {
|
43
|
+
return btoa(value);
|
44
|
+
} catch (err) {
|
45
|
+
const buf = Buffer;
|
46
|
+
return buf.from(value).toString("base64");
|
47
|
+
}
|
16
48
|
}
|
17
49
|
|
18
|
-
function
|
50
|
+
function getEnvironment() {
|
19
51
|
try {
|
20
|
-
if (isObject(process) &&
|
21
|
-
return
|
52
|
+
if (isObject(process) && isObject(process.env)) {
|
53
|
+
return {
|
54
|
+
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
55
|
+
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
56
|
+
branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
|
57
|
+
envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
|
58
|
+
fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
|
59
|
+
};
|
22
60
|
}
|
23
61
|
} catch (err) {
|
24
62
|
}
|
25
63
|
try {
|
26
|
-
if (isObject(Deno) &&
|
27
|
-
return
|
64
|
+
if (isObject(Deno) && isObject(Deno.env)) {
|
65
|
+
return {
|
66
|
+
apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
|
67
|
+
databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
|
68
|
+
branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
|
69
|
+
envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
|
70
|
+
fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
|
71
|
+
};
|
28
72
|
}
|
29
73
|
} catch (err) {
|
30
74
|
}
|
75
|
+
return {
|
76
|
+
apiKey: getGlobalApiKey(),
|
77
|
+
databaseURL: getGlobalDatabaseURL(),
|
78
|
+
branch: getGlobalBranch(),
|
79
|
+
envBranch: void 0,
|
80
|
+
fallbackBranch: getGlobalFallbackBranch()
|
81
|
+
};
|
82
|
+
}
|
83
|
+
function getGlobalApiKey() {
|
84
|
+
try {
|
85
|
+
return XATA_API_KEY;
|
86
|
+
} catch (err) {
|
87
|
+
return void 0;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
function getGlobalDatabaseURL() {
|
91
|
+
try {
|
92
|
+
return XATA_DATABASE_URL;
|
93
|
+
} catch (err) {
|
94
|
+
return void 0;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
function getGlobalBranch() {
|
98
|
+
try {
|
99
|
+
return XATA_BRANCH;
|
100
|
+
} catch (err) {
|
101
|
+
return void 0;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
function getGlobalFallbackBranch() {
|
105
|
+
try {
|
106
|
+
return XATA_FALLBACK_BRANCH;
|
107
|
+
} catch (err) {
|
108
|
+
return void 0;
|
109
|
+
}
|
31
110
|
}
|
32
111
|
async function getGitBranch() {
|
112
|
+
const cmd = ["git", "branch", "--show-current"];
|
113
|
+
const fullCmd = cmd.join(" ");
|
114
|
+
const nodeModule = ["child", "process"].join("_");
|
115
|
+
const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
|
33
116
|
try {
|
34
|
-
|
117
|
+
if (typeof require === "function") {
|
118
|
+
return require(nodeModule).execSync(fullCmd, execOptions).trim();
|
119
|
+
}
|
120
|
+
const { execSync } = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(nodeModule);
|
121
|
+
return execSync(fullCmd, execOptions).toString().trim();
|
35
122
|
} catch (err) {
|
36
123
|
}
|
37
124
|
try {
|
38
125
|
if (isObject(Deno)) {
|
39
|
-
const process2 = Deno.run({
|
40
|
-
cmd: ["git", "branch", "--show-current"],
|
41
|
-
stdout: "piped",
|
42
|
-
stderr: "piped"
|
43
|
-
});
|
126
|
+
const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
44
127
|
return new TextDecoder().decode(await process2.output()).trim();
|
45
128
|
}
|
46
129
|
} catch (err) {
|
@@ -49,7 +132,8 @@ async function getGitBranch() {
|
|
49
132
|
|
50
133
|
function getAPIKey() {
|
51
134
|
try {
|
52
|
-
|
135
|
+
const { apiKey } = getEnvironment();
|
136
|
+
return apiKey;
|
53
137
|
} catch (err) {
|
54
138
|
return void 0;
|
55
139
|
}
|
@@ -59,21 +143,35 @@ function getFetchImplementation(userFetch) {
|
|
59
143
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
60
144
|
const fetchImpl = userFetch ?? globalFetch;
|
61
145
|
if (!fetchImpl) {
|
62
|
-
throw new Error(
|
146
|
+
throw new Error(
|
147
|
+
`The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`
|
148
|
+
);
|
63
149
|
}
|
64
150
|
return fetchImpl;
|
65
151
|
}
|
66
152
|
|
67
|
-
|
68
|
-
|
153
|
+
const VERSION = "0.0.0-alpha.vf28813b";
|
154
|
+
|
155
|
+
class ErrorWithCause extends Error {
|
156
|
+
constructor(message, options) {
|
157
|
+
super(message, options);
|
158
|
+
}
|
159
|
+
}
|
160
|
+
class FetcherError extends ErrorWithCause {
|
161
|
+
constructor(status, data, requestId) {
|
69
162
|
super(getMessage(data));
|
70
163
|
this.status = status;
|
71
164
|
this.errors = isBulkError(data) ? data.errors : void 0;
|
165
|
+
this.requestId = requestId;
|
72
166
|
if (data instanceof Error) {
|
73
167
|
this.stack = data.stack;
|
74
168
|
this.cause = data.cause;
|
75
169
|
}
|
76
170
|
}
|
171
|
+
toString() {
|
172
|
+
const error = super.toString();
|
173
|
+
return `[${this.status}] (${this.requestId ?? "Unknown"}): ${error}`;
|
174
|
+
}
|
77
175
|
}
|
78
176
|
function isBulkError(error) {
|
79
177
|
return isObject(error) && Array.isArray(error.errors);
|
@@ -96,7 +194,12 @@ function getMessage(data) {
|
|
96
194
|
}
|
97
195
|
|
98
196
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
99
|
-
const
|
197
|
+
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
198
|
+
if (value === void 0 || value === null)
|
199
|
+
return acc;
|
200
|
+
return { ...acc, [key]: value };
|
201
|
+
}, {});
|
202
|
+
const query = new URLSearchParams(cleanQueryParams).toString();
|
100
203
|
const queryString = query.length > 0 ? `?${query}` : "";
|
101
204
|
return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
|
102
205
|
};
|
@@ -136,6 +239,7 @@ async function fetch$1({
|
|
136
239
|
body: body ? JSON.stringify(body) : void 0,
|
137
240
|
headers: {
|
138
241
|
"Content-Type": "application/json",
|
242
|
+
"User-Agent": `Xata client-ts/${VERSION}`,
|
139
243
|
...headers,
|
140
244
|
...hostHeader(fullUrl),
|
141
245
|
Authorization: `Bearer ${apiKey}`
|
@@ -144,14 +248,15 @@ async function fetch$1({
|
|
144
248
|
if (response.status === 204) {
|
145
249
|
return {};
|
146
250
|
}
|
251
|
+
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
147
252
|
try {
|
148
253
|
const jsonResponse = await response.json();
|
149
254
|
if (response.ok) {
|
150
255
|
return jsonResponse;
|
151
256
|
}
|
152
|
-
throw new FetcherError(response.status, jsonResponse);
|
257
|
+
throw new FetcherError(response.status, jsonResponse, requestId);
|
153
258
|
} catch (error) {
|
154
|
-
throw new FetcherError(response.status, error);
|
259
|
+
throw new FetcherError(response.status, error, requestId);
|
155
260
|
}
|
156
261
|
}
|
157
262
|
|
@@ -210,6 +315,7 @@ const removeWorkspaceMember = (variables) => fetch$1({
|
|
210
315
|
...variables
|
211
316
|
});
|
212
317
|
const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
|
318
|
+
const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
|
213
319
|
const cancelWorkspaceMemberInvite = (variables) => fetch$1({
|
214
320
|
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
215
321
|
method: "delete",
|
@@ -245,16 +351,25 @@ const deleteDatabase = (variables) => fetch$1({
|
|
245
351
|
method: "delete",
|
246
352
|
...variables
|
247
353
|
});
|
248
|
-
const
|
249
|
-
url: "/
|
354
|
+
const getDatabaseMetadata = (variables) => fetch$1({
|
355
|
+
url: "/dbs/{dbName}/metadata",
|
250
356
|
method: "get",
|
251
357
|
...variables
|
252
358
|
});
|
253
|
-
const
|
359
|
+
const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
|
360
|
+
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
361
|
+
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
362
|
+
const resolveBranch = (variables) => fetch$1({
|
363
|
+
url: "/dbs/{dbName}/resolveBranch",
|
364
|
+
method: "get",
|
365
|
+
...variables
|
366
|
+
});
|
367
|
+
const getBranchDetails = (variables) => fetch$1({
|
254
368
|
url: "/db/{dbBranchName}",
|
255
|
-
method: "
|
369
|
+
method: "get",
|
256
370
|
...variables
|
257
371
|
});
|
372
|
+
const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
|
258
373
|
const deleteBranch = (variables) => fetch$1({
|
259
374
|
url: "/db/{dbBranchName}",
|
260
375
|
method: "delete",
|
@@ -328,11 +443,7 @@ const updateColumn = (variables) => fetch$1({
|
|
328
443
|
method: "patch",
|
329
444
|
...variables
|
330
445
|
});
|
331
|
-
const insertRecord = (variables) => fetch$1({
|
332
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data",
|
333
|
-
method: "post",
|
334
|
-
...variables
|
335
|
-
});
|
446
|
+
const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
|
336
447
|
const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
|
337
448
|
const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
|
338
449
|
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
@@ -352,6 +463,11 @@ const queryTable = (variables) => fetch$1({
|
|
352
463
|
method: "post",
|
353
464
|
...variables
|
354
465
|
});
|
466
|
+
const searchTable = (variables) => fetch$1({
|
467
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
468
|
+
method: "post",
|
469
|
+
...variables
|
470
|
+
});
|
355
471
|
const searchBranch = (variables) => fetch$1({
|
356
472
|
url: "/db/{dbBranchName}/search",
|
357
473
|
method: "post",
|
@@ -369,13 +485,23 @@ const operationsByTag = {
|
|
369
485
|
updateWorkspaceMemberRole,
|
370
486
|
removeWorkspaceMember,
|
371
487
|
inviteWorkspaceMember,
|
488
|
+
updateWorkspaceMemberInvite,
|
372
489
|
cancelWorkspaceMemberInvite,
|
373
490
|
resendWorkspaceMemberInvite,
|
374
491
|
acceptWorkspaceMemberInvite
|
375
492
|
},
|
376
|
-
database: {
|
493
|
+
database: {
|
494
|
+
getDatabaseList,
|
495
|
+
createDatabase,
|
496
|
+
deleteDatabase,
|
497
|
+
getGitBranchesMapping,
|
498
|
+
addGitBranchesEntry,
|
499
|
+
removeGitBranchesEntry,
|
500
|
+
resolveBranch
|
501
|
+
},
|
377
502
|
branch: {
|
378
503
|
getBranchList,
|
504
|
+
getDatabaseMetadata,
|
379
505
|
getBranchDetails,
|
380
506
|
createBranch,
|
381
507
|
deleteBranch,
|
@@ -407,6 +533,7 @@ const operationsByTag = {
|
|
407
533
|
getRecord,
|
408
534
|
bulkInsertTableRecords,
|
409
535
|
queryTable,
|
536
|
+
searchTable,
|
410
537
|
searchBranch
|
411
538
|
}
|
412
539
|
};
|
@@ -436,35 +563,35 @@ function isValidBuilder(builder) {
|
|
436
563
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
437
564
|
}
|
438
565
|
|
439
|
-
var __accessCheck$
|
566
|
+
var __accessCheck$7 = (obj, member, msg) => {
|
440
567
|
if (!member.has(obj))
|
441
568
|
throw TypeError("Cannot " + msg);
|
442
569
|
};
|
443
|
-
var __privateGet$
|
444
|
-
__accessCheck$
|
570
|
+
var __privateGet$7 = (obj, member, getter) => {
|
571
|
+
__accessCheck$7(obj, member, "read from private field");
|
445
572
|
return getter ? getter.call(obj) : member.get(obj);
|
446
573
|
};
|
447
|
-
var __privateAdd$
|
574
|
+
var __privateAdd$7 = (obj, member, value) => {
|
448
575
|
if (member.has(obj))
|
449
576
|
throw TypeError("Cannot add the same private member more than once");
|
450
577
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
451
578
|
};
|
452
|
-
var __privateSet$
|
453
|
-
__accessCheck$
|
579
|
+
var __privateSet$7 = (obj, member, value, setter) => {
|
580
|
+
__accessCheck$7(obj, member, "write to private field");
|
454
581
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
455
582
|
return value;
|
456
583
|
};
|
457
584
|
var _extraProps, _namespaces;
|
458
585
|
class XataApiClient {
|
459
586
|
constructor(options = {}) {
|
460
|
-
__privateAdd$
|
461
|
-
__privateAdd$
|
587
|
+
__privateAdd$7(this, _extraProps, void 0);
|
588
|
+
__privateAdd$7(this, _namespaces, {});
|
462
589
|
const provider = options.host ?? "production";
|
463
590
|
const apiKey = options?.apiKey ?? getAPIKey();
|
464
591
|
if (!apiKey) {
|
465
592
|
throw new Error("Could not resolve a valid apiKey");
|
466
593
|
}
|
467
|
-
__privateSet$
|
594
|
+
__privateSet$7(this, _extraProps, {
|
468
595
|
apiUrl: getHostUrl(provider, "main"),
|
469
596
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
470
597
|
fetchImpl: getFetchImplementation(options.fetch),
|
@@ -472,34 +599,34 @@ class XataApiClient {
|
|
472
599
|
});
|
473
600
|
}
|
474
601
|
get user() {
|
475
|
-
if (!__privateGet$
|
476
|
-
__privateGet$
|
477
|
-
return __privateGet$
|
602
|
+
if (!__privateGet$7(this, _namespaces).user)
|
603
|
+
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
604
|
+
return __privateGet$7(this, _namespaces).user;
|
478
605
|
}
|
479
606
|
get workspaces() {
|
480
|
-
if (!__privateGet$
|
481
|
-
__privateGet$
|
482
|
-
return __privateGet$
|
607
|
+
if (!__privateGet$7(this, _namespaces).workspaces)
|
608
|
+
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
609
|
+
return __privateGet$7(this, _namespaces).workspaces;
|
483
610
|
}
|
484
611
|
get databases() {
|
485
|
-
if (!__privateGet$
|
486
|
-
__privateGet$
|
487
|
-
return __privateGet$
|
612
|
+
if (!__privateGet$7(this, _namespaces).databases)
|
613
|
+
__privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
|
614
|
+
return __privateGet$7(this, _namespaces).databases;
|
488
615
|
}
|
489
616
|
get branches() {
|
490
|
-
if (!__privateGet$
|
491
|
-
__privateGet$
|
492
|
-
return __privateGet$
|
617
|
+
if (!__privateGet$7(this, _namespaces).branches)
|
618
|
+
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
619
|
+
return __privateGet$7(this, _namespaces).branches;
|
493
620
|
}
|
494
621
|
get tables() {
|
495
|
-
if (!__privateGet$
|
496
|
-
__privateGet$
|
497
|
-
return __privateGet$
|
622
|
+
if (!__privateGet$7(this, _namespaces).tables)
|
623
|
+
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
624
|
+
return __privateGet$7(this, _namespaces).tables;
|
498
625
|
}
|
499
626
|
get records() {
|
500
|
-
if (!__privateGet$
|
501
|
-
__privateGet$
|
502
|
-
return __privateGet$
|
627
|
+
if (!__privateGet$7(this, _namespaces).records)
|
628
|
+
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
629
|
+
return __privateGet$7(this, _namespaces).records;
|
503
630
|
}
|
504
631
|
}
|
505
632
|
_extraProps = new WeakMap();
|
@@ -591,6 +718,13 @@ class WorkspaceApi {
|
|
591
718
|
...this.extraProps
|
592
719
|
});
|
593
720
|
}
|
721
|
+
updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
|
722
|
+
return operationsByTag.workspaces.updateWorkspaceMemberInvite({
|
723
|
+
pathParams: { workspaceId, inviteId },
|
724
|
+
body: { role },
|
725
|
+
...this.extraProps
|
726
|
+
});
|
727
|
+
}
|
594
728
|
cancelWorkspaceMemberInvite(workspaceId, inviteId) {
|
595
729
|
return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
|
596
730
|
pathParams: { workspaceId, inviteId },
|
@@ -633,6 +767,33 @@ class DatabaseApi {
|
|
633
767
|
...this.extraProps
|
634
768
|
});
|
635
769
|
}
|
770
|
+
getGitBranchesMapping(workspace, dbName) {
|
771
|
+
return operationsByTag.database.getGitBranchesMapping({
|
772
|
+
pathParams: { workspace, dbName },
|
773
|
+
...this.extraProps
|
774
|
+
});
|
775
|
+
}
|
776
|
+
addGitBranchesEntry(workspace, dbName, body) {
|
777
|
+
return operationsByTag.database.addGitBranchesEntry({
|
778
|
+
pathParams: { workspace, dbName },
|
779
|
+
body,
|
780
|
+
...this.extraProps
|
781
|
+
});
|
782
|
+
}
|
783
|
+
removeGitBranchesEntry(workspace, dbName, gitBranch) {
|
784
|
+
return operationsByTag.database.removeGitBranchesEntry({
|
785
|
+
pathParams: { workspace, dbName },
|
786
|
+
queryParams: { gitBranch },
|
787
|
+
...this.extraProps
|
788
|
+
});
|
789
|
+
}
|
790
|
+
resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
|
791
|
+
return operationsByTag.database.resolveBranch({
|
792
|
+
pathParams: { workspace, dbName },
|
793
|
+
queryParams: { gitBranch, fallbackBranch },
|
794
|
+
...this.extraProps
|
795
|
+
});
|
796
|
+
}
|
636
797
|
}
|
637
798
|
class BranchApi {
|
638
799
|
constructor(extraProps) {
|
@@ -650,10 +811,10 @@ class BranchApi {
|
|
650
811
|
...this.extraProps
|
651
812
|
});
|
652
813
|
}
|
653
|
-
createBranch(workspace, database, branch, from
|
814
|
+
createBranch(workspace, database, branch, from, options = {}) {
|
654
815
|
return operationsByTag.branch.createBranch({
|
655
816
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
656
|
-
queryParams: { from },
|
817
|
+
queryParams: isString(from) ? { from } : void 0,
|
657
818
|
body: options,
|
658
819
|
...this.extraProps
|
659
820
|
});
|
@@ -778,9 +939,10 @@ class RecordsApi {
|
|
778
939
|
constructor(extraProps) {
|
779
940
|
this.extraProps = extraProps;
|
780
941
|
}
|
781
|
-
insertRecord(workspace, database, branch, tableName, record) {
|
942
|
+
insertRecord(workspace, database, branch, tableName, record, options = {}) {
|
782
943
|
return operationsByTag.records.insertRecord({
|
783
944
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
945
|
+
queryParams: options,
|
784
946
|
body: record,
|
785
947
|
...this.extraProps
|
786
948
|
});
|
@@ -809,21 +971,24 @@ class RecordsApi {
|
|
809
971
|
...this.extraProps
|
810
972
|
});
|
811
973
|
}
|
812
|
-
deleteRecord(workspace, database, branch, tableName, recordId) {
|
974
|
+
deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
813
975
|
return operationsByTag.records.deleteRecord({
|
814
976
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
977
|
+
queryParams: options,
|
815
978
|
...this.extraProps
|
816
979
|
});
|
817
980
|
}
|
818
981
|
getRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
819
982
|
return operationsByTag.records.getRecord({
|
820
983
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
984
|
+
queryParams: options,
|
821
985
|
...this.extraProps
|
822
986
|
});
|
823
987
|
}
|
824
|
-
bulkInsertTableRecords(workspace, database, branch, tableName, records) {
|
988
|
+
bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
|
825
989
|
return operationsByTag.records.bulkInsertTableRecords({
|
826
990
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
991
|
+
queryParams: options,
|
827
992
|
body: { records },
|
828
993
|
...this.extraProps
|
829
994
|
});
|
@@ -835,6 +1000,13 @@ class RecordsApi {
|
|
835
1000
|
...this.extraProps
|
836
1001
|
});
|
837
1002
|
}
|
1003
|
+
searchTable(workspace, database, branch, tableName, query) {
|
1004
|
+
return operationsByTag.records.searchTable({
|
1005
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1006
|
+
body: query,
|
1007
|
+
...this.extraProps
|
1008
|
+
});
|
1009
|
+
}
|
838
1010
|
searchBranch(workspace, database, branch, query) {
|
839
1011
|
return operationsByTag.records.searchBranch({
|
840
1012
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
@@ -854,43 +1026,43 @@ class XataApiPlugin {
|
|
854
1026
|
class XataPlugin {
|
855
1027
|
}
|
856
1028
|
|
857
|
-
var __accessCheck$
|
1029
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
858
1030
|
if (!member.has(obj))
|
859
1031
|
throw TypeError("Cannot " + msg);
|
860
1032
|
};
|
861
|
-
var __privateGet$
|
862
|
-
__accessCheck$
|
1033
|
+
var __privateGet$6 = (obj, member, getter) => {
|
1034
|
+
__accessCheck$6(obj, member, "read from private field");
|
863
1035
|
return getter ? getter.call(obj) : member.get(obj);
|
864
1036
|
};
|
865
|
-
var __privateAdd$
|
1037
|
+
var __privateAdd$6 = (obj, member, value) => {
|
866
1038
|
if (member.has(obj))
|
867
1039
|
throw TypeError("Cannot add the same private member more than once");
|
868
1040
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
869
1041
|
};
|
870
|
-
var __privateSet$
|
871
|
-
__accessCheck$
|
1042
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
1043
|
+
__accessCheck$6(obj, member, "write to private field");
|
872
1044
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
873
1045
|
return value;
|
874
1046
|
};
|
875
|
-
var _query;
|
1047
|
+
var _query, _page;
|
876
1048
|
class Page {
|
877
1049
|
constructor(query, meta, records = []) {
|
878
|
-
__privateAdd$
|
879
|
-
__privateSet$
|
1050
|
+
__privateAdd$6(this, _query, void 0);
|
1051
|
+
__privateSet$6(this, _query, query);
|
880
1052
|
this.meta = meta;
|
881
|
-
this.records = records;
|
1053
|
+
this.records = new RecordArray(this, records);
|
882
1054
|
}
|
883
1055
|
async nextPage(size, offset) {
|
884
|
-
return __privateGet$
|
1056
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
885
1057
|
}
|
886
1058
|
async previousPage(size, offset) {
|
887
|
-
return __privateGet$
|
1059
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
888
1060
|
}
|
889
1061
|
async firstPage(size, offset) {
|
890
|
-
return __privateGet$
|
1062
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
|
891
1063
|
}
|
892
1064
|
async lastPage(size, offset) {
|
893
|
-
return __privateGet$
|
1065
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
|
894
1066
|
}
|
895
1067
|
hasNextPage() {
|
896
1068
|
return this.meta.page.more;
|
@@ -898,50 +1070,99 @@ class Page {
|
|
898
1070
|
}
|
899
1071
|
_query = new WeakMap();
|
900
1072
|
const PAGINATION_MAX_SIZE = 200;
|
901
|
-
const PAGINATION_DEFAULT_SIZE =
|
1073
|
+
const PAGINATION_DEFAULT_SIZE = 20;
|
902
1074
|
const PAGINATION_MAX_OFFSET = 800;
|
903
1075
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
1076
|
+
function isCursorPaginationOptions(options) {
|
1077
|
+
return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
|
1078
|
+
}
|
1079
|
+
const _RecordArray = class extends Array {
|
1080
|
+
constructor(...args) {
|
1081
|
+
super(..._RecordArray.parseConstructorParams(...args));
|
1082
|
+
__privateAdd$6(this, _page, void 0);
|
1083
|
+
__privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
|
1084
|
+
}
|
1085
|
+
static parseConstructorParams(...args) {
|
1086
|
+
if (args.length === 1 && typeof args[0] === "number") {
|
1087
|
+
return new Array(args[0]);
|
1088
|
+
}
|
1089
|
+
if (args.length <= 2 && isObject(args[0]?.meta) && Array.isArray(args[1] ?? [])) {
|
1090
|
+
const result = args[1] ?? args[0].records ?? [];
|
1091
|
+
return new Array(...result);
|
1092
|
+
}
|
1093
|
+
return new Array(...args);
|
1094
|
+
}
|
1095
|
+
toArray() {
|
1096
|
+
return new Array(...this);
|
1097
|
+
}
|
1098
|
+
map(callbackfn, thisArg) {
|
1099
|
+
return this.toArray().map(callbackfn, thisArg);
|
1100
|
+
}
|
1101
|
+
async nextPage(size, offset) {
|
1102
|
+
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
1103
|
+
return new _RecordArray(newPage);
|
1104
|
+
}
|
1105
|
+
async previousPage(size, offset) {
|
1106
|
+
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
1107
|
+
return new _RecordArray(newPage);
|
1108
|
+
}
|
1109
|
+
async firstPage(size, offset) {
|
1110
|
+
const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
|
1111
|
+
return new _RecordArray(newPage);
|
1112
|
+
}
|
1113
|
+
async lastPage(size, offset) {
|
1114
|
+
const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
|
1115
|
+
return new _RecordArray(newPage);
|
1116
|
+
}
|
1117
|
+
hasNextPage() {
|
1118
|
+
return __privateGet$6(this, _page).meta.page.more;
|
1119
|
+
}
|
1120
|
+
};
|
1121
|
+
let RecordArray = _RecordArray;
|
1122
|
+
_page = new WeakMap();
|
904
1123
|
|
905
|
-
var __accessCheck$
|
1124
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
906
1125
|
if (!member.has(obj))
|
907
1126
|
throw TypeError("Cannot " + msg);
|
908
1127
|
};
|
909
|
-
var __privateGet$
|
910
|
-
__accessCheck$
|
1128
|
+
var __privateGet$5 = (obj, member, getter) => {
|
1129
|
+
__accessCheck$5(obj, member, "read from private field");
|
911
1130
|
return getter ? getter.call(obj) : member.get(obj);
|
912
1131
|
};
|
913
|
-
var __privateAdd$
|
1132
|
+
var __privateAdd$5 = (obj, member, value) => {
|
914
1133
|
if (member.has(obj))
|
915
1134
|
throw TypeError("Cannot add the same private member more than once");
|
916
1135
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
917
1136
|
};
|
918
|
-
var __privateSet$
|
919
|
-
__accessCheck$
|
1137
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
1138
|
+
__accessCheck$5(obj, member, "write to private field");
|
920
1139
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
921
1140
|
return value;
|
922
1141
|
};
|
923
1142
|
var _table$1, _repository, _data;
|
924
1143
|
const _Query = class {
|
925
|
-
constructor(repository, table, data,
|
926
|
-
__privateAdd$
|
927
|
-
__privateAdd$
|
928
|
-
__privateAdd$
|
1144
|
+
constructor(repository, table, data, rawParent) {
|
1145
|
+
__privateAdd$5(this, _table$1, void 0);
|
1146
|
+
__privateAdd$5(this, _repository, void 0);
|
1147
|
+
__privateAdd$5(this, _data, { filter: {} });
|
929
1148
|
this.meta = { page: { cursor: "start", more: true } };
|
930
|
-
this.records = [];
|
931
|
-
__privateSet$
|
1149
|
+
this.records = new RecordArray(this, []);
|
1150
|
+
__privateSet$5(this, _table$1, table);
|
932
1151
|
if (repository) {
|
933
|
-
__privateSet$
|
1152
|
+
__privateSet$5(this, _repository, repository);
|
934
1153
|
} else {
|
935
|
-
__privateSet$
|
1154
|
+
__privateSet$5(this, _repository, this);
|
936
1155
|
}
|
937
|
-
|
938
|
-
__privateGet$
|
939
|
-
__privateGet$
|
940
|
-
__privateGet$
|
941
|
-
__privateGet$
|
942
|
-
__privateGet$
|
943
|
-
__privateGet$
|
944
|
-
__privateGet$
|
1156
|
+
const parent = cleanParent(data, rawParent);
|
1157
|
+
__privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
1158
|
+
__privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
|
1159
|
+
__privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
|
1160
|
+
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
1161
|
+
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
1162
|
+
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
1163
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
|
1164
|
+
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
1165
|
+
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
945
1166
|
this.any = this.any.bind(this);
|
946
1167
|
this.all = this.all.bind(this);
|
947
1168
|
this.not = this.not.bind(this);
|
@@ -952,75 +1173,93 @@ const _Query = class {
|
|
952
1173
|
Object.defineProperty(this, "repository", { enumerable: false });
|
953
1174
|
}
|
954
1175
|
getQueryOptions() {
|
955
|
-
return __privateGet$
|
1176
|
+
return __privateGet$5(this, _data);
|
1177
|
+
}
|
1178
|
+
key() {
|
1179
|
+
const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$5(this, _data);
|
1180
|
+
const key = JSON.stringify({ columns, filter, sort, pagination });
|
1181
|
+
return toBase64(key);
|
956
1182
|
}
|
957
1183
|
any(...queries) {
|
958
1184
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
959
|
-
return new _Query(__privateGet$
|
1185
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
960
1186
|
}
|
961
1187
|
all(...queries) {
|
962
1188
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
963
|
-
return new _Query(__privateGet$
|
1189
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
964
1190
|
}
|
965
1191
|
not(...queries) {
|
966
1192
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
967
|
-
return new _Query(__privateGet$
|
1193
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
968
1194
|
}
|
969
1195
|
none(...queries) {
|
970
1196
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
971
|
-
return new _Query(__privateGet$
|
1197
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
972
1198
|
}
|
973
1199
|
filter(a, b) {
|
974
1200
|
if (arguments.length === 1) {
|
975
1201
|
const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
|
976
|
-
const $all = compact([__privateGet$
|
977
|
-
return new _Query(__privateGet$
|
1202
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1203
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
978
1204
|
} else {
|
979
|
-
const $all = compact([__privateGet$
|
980
|
-
return new _Query(__privateGet$
|
1205
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
|
1206
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
981
1207
|
}
|
982
1208
|
}
|
983
1209
|
sort(column, direction) {
|
984
|
-
const originalSort = [__privateGet$
|
1210
|
+
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
985
1211
|
const sort = [...originalSort, { column, direction }];
|
986
|
-
return new _Query(__privateGet$
|
1212
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
987
1213
|
}
|
988
1214
|
select(columns) {
|
989
|
-
return new _Query(
|
1215
|
+
return new _Query(
|
1216
|
+
__privateGet$5(this, _repository),
|
1217
|
+
__privateGet$5(this, _table$1),
|
1218
|
+
{ columns },
|
1219
|
+
__privateGet$5(this, _data)
|
1220
|
+
);
|
990
1221
|
}
|
991
1222
|
getPaginated(options = {}) {
|
992
|
-
const query = new _Query(__privateGet$
|
993
|
-
return __privateGet$
|
1223
|
+
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
1224
|
+
return __privateGet$5(this, _repository).query(query);
|
994
1225
|
}
|
995
1226
|
async *[Symbol.asyncIterator]() {
|
996
|
-
for await (const [record] of this.getIterator(1)) {
|
1227
|
+
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
997
1228
|
yield record;
|
998
1229
|
}
|
999
1230
|
}
|
1000
|
-
async *getIterator(
|
1001
|
-
|
1002
|
-
let
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1231
|
+
async *getIterator(options = {}) {
|
1232
|
+
const { batchSize = 1 } = options;
|
1233
|
+
let page = await this.getPaginated({ ...options, pagination: { size: batchSize, offset: 0 } });
|
1234
|
+
let more = page.hasNextPage();
|
1235
|
+
yield page.records;
|
1236
|
+
while (more) {
|
1237
|
+
page = await page.nextPage();
|
1238
|
+
more = page.hasNextPage();
|
1239
|
+
yield page.records;
|
1008
1240
|
}
|
1009
1241
|
}
|
1010
1242
|
async getMany(options = {}) {
|
1011
|
-
const
|
1012
|
-
|
1243
|
+
const page = await this.getPaginated(options);
|
1244
|
+
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
1245
|
+
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
1246
|
+
}
|
1247
|
+
return page.records;
|
1013
1248
|
}
|
1014
|
-
async getAll(
|
1249
|
+
async getAll(options = {}) {
|
1250
|
+
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
1015
1251
|
const results = [];
|
1016
|
-
for await (const page of this.getIterator(
|
1252
|
+
for await (const page of this.getIterator({ ...rest, batchSize })) {
|
1017
1253
|
results.push(...page);
|
1018
1254
|
}
|
1019
1255
|
return results;
|
1020
1256
|
}
|
1021
|
-
async
|
1022
|
-
const records = await this.getMany({ ...options,
|
1023
|
-
return records[0]
|
1257
|
+
async getFirst(options = {}) {
|
1258
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1259
|
+
return records[0] ?? null;
|
1260
|
+
}
|
1261
|
+
cache(ttl) {
|
1262
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1024
1263
|
}
|
1025
1264
|
nextPage(size, offset) {
|
1026
1265
|
return this.firstPage(size, offset);
|
@@ -1029,10 +1268,10 @@ const _Query = class {
|
|
1029
1268
|
return this.firstPage(size, offset);
|
1030
1269
|
}
|
1031
1270
|
firstPage(size, offset) {
|
1032
|
-
return this.getPaginated({
|
1271
|
+
return this.getPaginated({ pagination: { size, offset } });
|
1033
1272
|
}
|
1034
1273
|
lastPage(size, offset) {
|
1035
|
-
return this.getPaginated({
|
1274
|
+
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
1036
1275
|
}
|
1037
1276
|
hasNextPage() {
|
1038
1277
|
return this.meta.page.more;
|
@@ -1042,12 +1281,20 @@ let Query = _Query;
|
|
1042
1281
|
_table$1 = new WeakMap();
|
1043
1282
|
_repository = new WeakMap();
|
1044
1283
|
_data = new WeakMap();
|
1284
|
+
function cleanParent(data, parent) {
|
1285
|
+
if (isCursorPaginationOptions(data.pagination)) {
|
1286
|
+
return { ...parent, sorting: void 0, filter: void 0 };
|
1287
|
+
}
|
1288
|
+
return parent;
|
1289
|
+
}
|
1045
1290
|
|
1046
1291
|
function isIdentifiable(x) {
|
1047
1292
|
return isObject(x) && isString(x?.id);
|
1048
1293
|
}
|
1049
1294
|
function isXataRecord(x) {
|
1050
|
-
|
1295
|
+
const record = x;
|
1296
|
+
const metadata = record?.getMetadata();
|
1297
|
+
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
1051
1298
|
}
|
1052
1299
|
|
1053
1300
|
function isSortFilterString(value) {
|
@@ -1073,250 +1320,327 @@ function buildSortFilter(filter) {
|
|
1073
1320
|
}
|
1074
1321
|
}
|
1075
1322
|
|
1076
|
-
var __accessCheck$
|
1323
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
1077
1324
|
if (!member.has(obj))
|
1078
1325
|
throw TypeError("Cannot " + msg);
|
1079
1326
|
};
|
1080
|
-
var __privateGet$
|
1081
|
-
__accessCheck$
|
1327
|
+
var __privateGet$4 = (obj, member, getter) => {
|
1328
|
+
__accessCheck$4(obj, member, "read from private field");
|
1082
1329
|
return getter ? getter.call(obj) : member.get(obj);
|
1083
1330
|
};
|
1084
|
-
var __privateAdd$
|
1331
|
+
var __privateAdd$4 = (obj, member, value) => {
|
1085
1332
|
if (member.has(obj))
|
1086
1333
|
throw TypeError("Cannot add the same private member more than once");
|
1087
1334
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1088
1335
|
};
|
1089
|
-
var __privateSet$
|
1090
|
-
__accessCheck$
|
1336
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
1337
|
+
__accessCheck$4(obj, member, "write to private field");
|
1091
1338
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1092
1339
|
return value;
|
1093
1340
|
};
|
1094
1341
|
var __privateMethod$2 = (obj, member, method) => {
|
1095
|
-
__accessCheck$
|
1342
|
+
__accessCheck$4(obj, member, "access private method");
|
1096
1343
|
return method;
|
1097
1344
|
};
|
1098
|
-
var _table,
|
1345
|
+
var _table, _getFetchProps, _cache, _schemaTables$2, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
|
1099
1346
|
class Repository extends Query {
|
1100
1347
|
}
|
1101
1348
|
class RestRepository extends Query {
|
1102
1349
|
constructor(options) {
|
1103
1350
|
super(null, options.table, {});
|
1104
|
-
__privateAdd$
|
1105
|
-
__privateAdd$
|
1106
|
-
__privateAdd$
|
1107
|
-
__privateAdd$
|
1108
|
-
__privateAdd$
|
1109
|
-
__privateAdd$
|
1110
|
-
__privateAdd$
|
1111
|
-
__privateAdd$
|
1112
|
-
__privateAdd$
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1351
|
+
__privateAdd$4(this, _insertRecordWithoutId);
|
1352
|
+
__privateAdd$4(this, _insertRecordWithId);
|
1353
|
+
__privateAdd$4(this, _bulkInsertTableRecords);
|
1354
|
+
__privateAdd$4(this, _updateRecordWithID);
|
1355
|
+
__privateAdd$4(this, _upsertRecordWithID);
|
1356
|
+
__privateAdd$4(this, _deleteRecord);
|
1357
|
+
__privateAdd$4(this, _setCacheQuery);
|
1358
|
+
__privateAdd$4(this, _getCacheQuery);
|
1359
|
+
__privateAdd$4(this, _getSchemaTables$1);
|
1360
|
+
__privateAdd$4(this, _table, void 0);
|
1361
|
+
__privateAdd$4(this, _getFetchProps, void 0);
|
1362
|
+
__privateAdd$4(this, _cache, void 0);
|
1363
|
+
__privateAdd$4(this, _schemaTables$2, void 0);
|
1364
|
+
__privateSet$4(this, _table, options.table);
|
1365
|
+
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1116
1366
|
this.db = options.db;
|
1367
|
+
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
1368
|
+
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
1117
1369
|
}
|
1118
|
-
async create(a, b) {
|
1370
|
+
async create(a, b, c) {
|
1119
1371
|
if (Array.isArray(a)) {
|
1120
|
-
|
1372
|
+
if (a.length === 0)
|
1373
|
+
return [];
|
1374
|
+
const columns = isStringArray(b) ? b : void 0;
|
1375
|
+
return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
|
1121
1376
|
}
|
1122
1377
|
if (isString(a) && isObject(b)) {
|
1123
1378
|
if (a === "")
|
1124
1379
|
throw new Error("The id can't be empty");
|
1125
|
-
|
1380
|
+
const columns = isStringArray(c) ? c : void 0;
|
1381
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
1126
1382
|
}
|
1127
1383
|
if (isObject(a) && isString(a.id)) {
|
1128
1384
|
if (a.id === "")
|
1129
1385
|
throw new Error("The id can't be empty");
|
1130
|
-
|
1386
|
+
const columns = isStringArray(b) ? b : void 0;
|
1387
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1131
1388
|
}
|
1132
1389
|
if (isObject(a)) {
|
1133
|
-
|
1390
|
+
const columns = isStringArray(b) ? b : void 0;
|
1391
|
+
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
1134
1392
|
}
|
1135
1393
|
throw new Error("Invalid arguments for create method");
|
1136
1394
|
}
|
1137
|
-
async read(
|
1138
|
-
const
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
});
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1395
|
+
async read(a, b) {
|
1396
|
+
const columns = isStringArray(b) ? b : ["*"];
|
1397
|
+
if (Array.isArray(a)) {
|
1398
|
+
if (a.length === 0)
|
1399
|
+
return [];
|
1400
|
+
const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
|
1401
|
+
const finalObjects = await this.getAll({ filter: { id: { $any: ids } }, columns });
|
1402
|
+
const dictionary = finalObjects.reduce((acc, object) => {
|
1403
|
+
acc[object.id] = object;
|
1404
|
+
return acc;
|
1405
|
+
}, {});
|
1406
|
+
return ids.map((id2) => dictionary[id2] ?? null);
|
1407
|
+
}
|
1408
|
+
const id = isString(a) ? a : a.id;
|
1409
|
+
if (isString(id)) {
|
1410
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1411
|
+
try {
|
1412
|
+
const response = await getRecord({
|
1413
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: id },
|
1414
|
+
queryParams: { columns },
|
1415
|
+
...fetchProps
|
1416
|
+
});
|
1417
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1418
|
+
return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
|
1419
|
+
} catch (e) {
|
1420
|
+
if (isObject(e) && e.status === 404) {
|
1421
|
+
return null;
|
1422
|
+
}
|
1423
|
+
throw e;
|
1148
1424
|
}
|
1149
|
-
throw e;
|
1150
1425
|
}
|
1426
|
+
return null;
|
1151
1427
|
}
|
1152
|
-
async update(a, b) {
|
1428
|
+
async update(a, b, c) {
|
1153
1429
|
if (Array.isArray(a)) {
|
1430
|
+
if (a.length === 0)
|
1431
|
+
return [];
|
1154
1432
|
if (a.length > 100) {
|
1155
1433
|
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1156
1434
|
}
|
1157
|
-
|
1435
|
+
const columns = isStringArray(b) ? b : ["*"];
|
1436
|
+
return Promise.all(a.map((object) => this.update(object, columns)));
|
1158
1437
|
}
|
1159
1438
|
if (isString(a) && isObject(b)) {
|
1160
|
-
|
1439
|
+
const columns = isStringArray(c) ? c : void 0;
|
1440
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
|
1161
1441
|
}
|
1162
1442
|
if (isObject(a) && isString(a.id)) {
|
1163
|
-
|
1443
|
+
const columns = isStringArray(b) ? b : void 0;
|
1444
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1164
1445
|
}
|
1165
1446
|
throw new Error("Invalid arguments for update method");
|
1166
1447
|
}
|
1167
|
-
async createOrUpdate(a, b) {
|
1448
|
+
async createOrUpdate(a, b, c) {
|
1168
1449
|
if (Array.isArray(a)) {
|
1450
|
+
if (a.length === 0)
|
1451
|
+
return [];
|
1169
1452
|
if (a.length > 100) {
|
1170
1453
|
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1171
1454
|
}
|
1172
|
-
|
1455
|
+
const columns = isStringArray(b) ? b : ["*"];
|
1456
|
+
return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
|
1173
1457
|
}
|
1174
1458
|
if (isString(a) && isObject(b)) {
|
1175
|
-
|
1459
|
+
const columns = isStringArray(c) ? c : void 0;
|
1460
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
|
1176
1461
|
}
|
1177
1462
|
if (isObject(a) && isString(a.id)) {
|
1178
|
-
|
1463
|
+
const columns = isStringArray(c) ? c : void 0;
|
1464
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1179
1465
|
}
|
1180
1466
|
throw new Error("Invalid arguments for createOrUpdate method");
|
1181
1467
|
}
|
1182
|
-
async delete(
|
1183
|
-
if (Array.isArray(
|
1184
|
-
if (
|
1468
|
+
async delete(a) {
|
1469
|
+
if (Array.isArray(a)) {
|
1470
|
+
if (a.length === 0)
|
1471
|
+
return;
|
1472
|
+
if (a.length > 100) {
|
1185
1473
|
console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
|
1186
1474
|
}
|
1187
|
-
await Promise.all(
|
1475
|
+
await Promise.all(a.map((id) => this.delete(id)));
|
1188
1476
|
return;
|
1189
1477
|
}
|
1190
|
-
if (isString(
|
1191
|
-
await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this,
|
1478
|
+
if (isString(a)) {
|
1479
|
+
await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
|
1192
1480
|
return;
|
1193
1481
|
}
|
1194
|
-
if (isObject(
|
1195
|
-
await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this,
|
1482
|
+
if (isObject(a) && isString(a.id)) {
|
1483
|
+
await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
|
1196
1484
|
return;
|
1197
1485
|
}
|
1198
1486
|
throw new Error("Invalid arguments for delete method");
|
1199
1487
|
}
|
1200
1488
|
async search(query, options = {}) {
|
1201
|
-
const fetchProps = await __privateGet$
|
1202
|
-
const { records } = await
|
1203
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1204
|
-
body: {
|
1489
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1490
|
+
const { records } = await searchTable({
|
1491
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1492
|
+
body: {
|
1493
|
+
query,
|
1494
|
+
fuzziness: options.fuzziness,
|
1495
|
+
prefix: options.prefix,
|
1496
|
+
highlight: options.highlight,
|
1497
|
+
filter: options.filter,
|
1498
|
+
boosters: options.boosters
|
1499
|
+
},
|
1205
1500
|
...fetchProps
|
1206
1501
|
});
|
1207
|
-
|
1502
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1503
|
+
return records.map((item) => initObject(this.db, schemaTables, __privateGet$4(this, _table), item));
|
1208
1504
|
}
|
1209
1505
|
async query(query) {
|
1506
|
+
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
1507
|
+
if (cacheQuery)
|
1508
|
+
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
1210
1509
|
const data = query.getQueryOptions();
|
1211
1510
|
const body = {
|
1212
1511
|
filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
|
1213
|
-
sort: data.sort ? buildSortFilter(data.sort) : void 0,
|
1214
|
-
page: data.
|
1512
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1513
|
+
page: data.pagination,
|
1215
1514
|
columns: data.columns
|
1216
1515
|
};
|
1217
|
-
const fetchProps = await __privateGet$
|
1516
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1218
1517
|
const { meta, records: objects } = await queryTable({
|
1219
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1518
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1220
1519
|
body,
|
1221
1520
|
...fetchProps
|
1222
1521
|
});
|
1223
|
-
const
|
1522
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1523
|
+
const records = objects.map((record) => initObject(this.db, schemaTables, __privateGet$4(this, _table), record));
|
1524
|
+
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1224
1525
|
return new Page(query, meta, records);
|
1225
1526
|
}
|
1226
1527
|
}
|
1227
1528
|
_table = new WeakMap();
|
1228
|
-
_links = new WeakMap();
|
1229
1529
|
_getFetchProps = new WeakMap();
|
1530
|
+
_cache = new WeakMap();
|
1531
|
+
_schemaTables$2 = new WeakMap();
|
1230
1532
|
_insertRecordWithoutId = new WeakSet();
|
1231
|
-
insertRecordWithoutId_fn = async function(object) {
|
1232
|
-
const fetchProps = await __privateGet$
|
1533
|
+
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
1534
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1233
1535
|
const record = transformObjectLinks(object);
|
1234
1536
|
const response = await insertRecord({
|
1235
1537
|
pathParams: {
|
1236
1538
|
workspace: "{workspaceId}",
|
1237
1539
|
dbBranchName: "{dbBranch}",
|
1238
|
-
tableName: __privateGet$
|
1540
|
+
tableName: __privateGet$4(this, _table)
|
1239
1541
|
},
|
1542
|
+
queryParams: { columns },
|
1240
1543
|
body: record,
|
1241
1544
|
...fetchProps
|
1242
1545
|
});
|
1243
|
-
const
|
1244
|
-
|
1245
|
-
throw new Error("The server failed to save the record");
|
1246
|
-
}
|
1247
|
-
return finalObject;
|
1546
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1547
|
+
return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
|
1248
1548
|
};
|
1249
1549
|
_insertRecordWithId = new WeakSet();
|
1250
|
-
insertRecordWithId_fn = async function(recordId, object) {
|
1251
|
-
const fetchProps = await __privateGet$
|
1550
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
1551
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1252
1552
|
const record = transformObjectLinks(object);
|
1253
1553
|
const response = await insertRecordWithID({
|
1254
1554
|
pathParams: {
|
1255
1555
|
workspace: "{workspaceId}",
|
1256
1556
|
dbBranchName: "{dbBranch}",
|
1257
|
-
tableName: __privateGet$
|
1557
|
+
tableName: __privateGet$4(this, _table),
|
1258
1558
|
recordId
|
1259
1559
|
},
|
1260
1560
|
body: record,
|
1261
|
-
queryParams: { createOnly: true },
|
1561
|
+
queryParams: { createOnly: true, columns },
|
1262
1562
|
...fetchProps
|
1263
1563
|
});
|
1264
|
-
const
|
1265
|
-
|
1266
|
-
throw new Error("The server failed to save the record");
|
1267
|
-
}
|
1268
|
-
return finalObject;
|
1564
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1565
|
+
return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
|
1269
1566
|
};
|
1270
1567
|
_bulkInsertTableRecords = new WeakSet();
|
1271
|
-
bulkInsertTableRecords_fn = async function(objects) {
|
1272
|
-
const fetchProps = await __privateGet$
|
1568
|
+
bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
1569
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1273
1570
|
const records = objects.map((object) => transformObjectLinks(object));
|
1274
1571
|
const response = await bulkInsertTableRecords({
|
1275
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1572
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1573
|
+
queryParams: { columns },
|
1276
1574
|
body: { records },
|
1277
1575
|
...fetchProps
|
1278
1576
|
});
|
1279
|
-
|
1280
|
-
|
1281
|
-
throw new Error("The server failed to save some records");
|
1577
|
+
if (!isResponseWithRecords(response)) {
|
1578
|
+
throw new Error("Request included columns but server didn't include them");
|
1282
1579
|
}
|
1283
|
-
|
1580
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1581
|
+
return response.records?.map((item) => initObject(this.db, schemaTables, __privateGet$4(this, _table), item));
|
1284
1582
|
};
|
1285
1583
|
_updateRecordWithID = new WeakSet();
|
1286
|
-
updateRecordWithID_fn = async function(recordId, object) {
|
1287
|
-
const fetchProps = await __privateGet$
|
1584
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
1585
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1288
1586
|
const record = transformObjectLinks(object);
|
1289
1587
|
const response = await updateRecordWithID({
|
1290
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1588
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1589
|
+
queryParams: { columns },
|
1291
1590
|
body: record,
|
1292
1591
|
...fetchProps
|
1293
1592
|
});
|
1294
|
-
const
|
1295
|
-
|
1296
|
-
throw new Error("The server failed to save the record");
|
1297
|
-
return item;
|
1593
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1594
|
+
return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
|
1298
1595
|
};
|
1299
1596
|
_upsertRecordWithID = new WeakSet();
|
1300
|
-
upsertRecordWithID_fn = async function(recordId, object) {
|
1301
|
-
const fetchProps = await __privateGet$
|
1597
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
1598
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1302
1599
|
const response = await upsertRecordWithID({
|
1303
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1600
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1601
|
+
queryParams: { columns },
|
1304
1602
|
body: object,
|
1305
1603
|
...fetchProps
|
1306
1604
|
});
|
1307
|
-
const
|
1308
|
-
|
1309
|
-
throw new Error("The server failed to save the record");
|
1310
|
-
return item;
|
1605
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1606
|
+
return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
|
1311
1607
|
};
|
1312
1608
|
_deleteRecord = new WeakSet();
|
1313
1609
|
deleteRecord_fn = async function(recordId) {
|
1314
|
-
const fetchProps = await __privateGet$
|
1610
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1315
1611
|
await deleteRecord({
|
1316
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1612
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1317
1613
|
...fetchProps
|
1318
1614
|
});
|
1319
1615
|
};
|
1616
|
+
_setCacheQuery = new WeakSet();
|
1617
|
+
setCacheQuery_fn = async function(query, meta, records) {
|
1618
|
+
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
1619
|
+
};
|
1620
|
+
_getCacheQuery = new WeakSet();
|
1621
|
+
getCacheQuery_fn = async function(query) {
|
1622
|
+
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
1623
|
+
const result = await __privateGet$4(this, _cache).get(key);
|
1624
|
+
if (!result)
|
1625
|
+
return null;
|
1626
|
+
const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
|
1627
|
+
if (ttl < 0)
|
1628
|
+
return null;
|
1629
|
+
const hasExpired = result.date.getTime() + ttl < Date.now();
|
1630
|
+
return hasExpired ? null : result;
|
1631
|
+
};
|
1632
|
+
_getSchemaTables$1 = new WeakSet();
|
1633
|
+
getSchemaTables_fn$1 = async function() {
|
1634
|
+
if (__privateGet$4(this, _schemaTables$2))
|
1635
|
+
return __privateGet$4(this, _schemaTables$2);
|
1636
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1637
|
+
const { schema } = await getBranchDetails({
|
1638
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1639
|
+
...fetchProps
|
1640
|
+
});
|
1641
|
+
__privateSet$4(this, _schemaTables$2, schema.tables);
|
1642
|
+
return schema.tables;
|
1643
|
+
};
|
1320
1644
|
const transformObjectLinks = (object) => {
|
1321
1645
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
1322
1646
|
if (key === "xata")
|
@@ -1324,32 +1648,106 @@ const transformObjectLinks = (object) => {
|
|
1324
1648
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1325
1649
|
}, {});
|
1326
1650
|
};
|
1327
|
-
const initObject = (db,
|
1651
|
+
const initObject = (db, schemaTables, table, object) => {
|
1328
1652
|
const result = {};
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1653
|
+
const { xata, ...rest } = object ?? {};
|
1654
|
+
Object.assign(result, rest);
|
1655
|
+
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
1656
|
+
if (!columns)
|
1657
|
+
console.error(`Table ${table} not found in schema`);
|
1658
|
+
for (const column of columns ?? []) {
|
1659
|
+
const value = result[column.name];
|
1660
|
+
switch (column.type) {
|
1661
|
+
case "datetime": {
|
1662
|
+
const date = value !== void 0 ? new Date(value) : void 0;
|
1663
|
+
if (date && isNaN(date.getTime())) {
|
1664
|
+
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
1665
|
+
} else if (date) {
|
1666
|
+
result[column.name] = date;
|
1667
|
+
}
|
1668
|
+
break;
|
1669
|
+
}
|
1670
|
+
case "link": {
|
1671
|
+
const linkTable = column.link?.table;
|
1672
|
+
if (!linkTable) {
|
1673
|
+
console.error(`Failed to parse link for field ${column.name}`);
|
1674
|
+
} else if (isObject(value)) {
|
1675
|
+
result[column.name] = initObject(db, schemaTables, linkTable, value);
|
1676
|
+
}
|
1677
|
+
break;
|
1678
|
+
}
|
1336
1679
|
}
|
1337
1680
|
}
|
1338
|
-
result.read = function() {
|
1339
|
-
return db[table].read(result["id"]);
|
1681
|
+
result.read = function(columns2) {
|
1682
|
+
return db[table].read(result["id"], columns2);
|
1340
1683
|
};
|
1341
|
-
result.update = function(data) {
|
1342
|
-
return db[table].update(result["id"], data);
|
1684
|
+
result.update = function(data, columns2) {
|
1685
|
+
return db[table].update(result["id"], data, columns2);
|
1343
1686
|
};
|
1344
1687
|
result.delete = function() {
|
1345
1688
|
return db[table].delete(result["id"]);
|
1346
1689
|
};
|
1347
|
-
|
1690
|
+
result.getMetadata = function() {
|
1691
|
+
return xata;
|
1692
|
+
};
|
1693
|
+
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
1348
1694
|
Object.defineProperty(result, prop, { enumerable: false });
|
1349
1695
|
}
|
1350
1696
|
Object.freeze(result);
|
1351
1697
|
return result;
|
1352
1698
|
};
|
1699
|
+
function isResponseWithRecords(value) {
|
1700
|
+
return isObject(value) && Array.isArray(value.records);
|
1701
|
+
}
|
1702
|
+
|
1703
|
+
var __accessCheck$3 = (obj, member, msg) => {
|
1704
|
+
if (!member.has(obj))
|
1705
|
+
throw TypeError("Cannot " + msg);
|
1706
|
+
};
|
1707
|
+
var __privateGet$3 = (obj, member, getter) => {
|
1708
|
+
__accessCheck$3(obj, member, "read from private field");
|
1709
|
+
return getter ? getter.call(obj) : member.get(obj);
|
1710
|
+
};
|
1711
|
+
var __privateAdd$3 = (obj, member, value) => {
|
1712
|
+
if (member.has(obj))
|
1713
|
+
throw TypeError("Cannot add the same private member more than once");
|
1714
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1715
|
+
};
|
1716
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
1717
|
+
__accessCheck$3(obj, member, "write to private field");
|
1718
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
1719
|
+
return value;
|
1720
|
+
};
|
1721
|
+
var _map;
|
1722
|
+
class SimpleCache {
|
1723
|
+
constructor(options = {}) {
|
1724
|
+
__privateAdd$3(this, _map, void 0);
|
1725
|
+
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
1726
|
+
this.capacity = options.max ?? 500;
|
1727
|
+
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
1728
|
+
}
|
1729
|
+
async getAll() {
|
1730
|
+
return Object.fromEntries(__privateGet$3(this, _map));
|
1731
|
+
}
|
1732
|
+
async get(key) {
|
1733
|
+
return __privateGet$3(this, _map).get(key) ?? null;
|
1734
|
+
}
|
1735
|
+
async set(key, value) {
|
1736
|
+
await this.delete(key);
|
1737
|
+
__privateGet$3(this, _map).set(key, value);
|
1738
|
+
if (__privateGet$3(this, _map).size > this.capacity) {
|
1739
|
+
const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
|
1740
|
+
await this.delete(leastRecentlyUsed);
|
1741
|
+
}
|
1742
|
+
}
|
1743
|
+
async delete(key) {
|
1744
|
+
__privateGet$3(this, _map).delete(key);
|
1745
|
+
}
|
1746
|
+
async clear() {
|
1747
|
+
return __privateGet$3(this, _map).clear();
|
1748
|
+
}
|
1749
|
+
}
|
1750
|
+
_map = new WeakMap();
|
1353
1751
|
|
1354
1752
|
const gt = (value) => ({ $gt: value });
|
1355
1753
|
const ge = (value) => ({ $ge: value });
|
@@ -1374,7 +1772,7 @@ var __accessCheck$2 = (obj, member, msg) => {
|
|
1374
1772
|
if (!member.has(obj))
|
1375
1773
|
throw TypeError("Cannot " + msg);
|
1376
1774
|
};
|
1377
|
-
var __privateGet$
|
1775
|
+
var __privateGet$2 = (obj, member, getter) => {
|
1378
1776
|
__accessCheck$2(obj, member, "read from private field");
|
1379
1777
|
return getter ? getter.call(obj) : member.get(obj);
|
1380
1778
|
};
|
@@ -1383,130 +1781,177 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
1383
1781
|
throw TypeError("Cannot add the same private member more than once");
|
1384
1782
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1385
1783
|
};
|
1386
|
-
var
|
1784
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
1785
|
+
__accessCheck$2(obj, member, "write to private field");
|
1786
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
1787
|
+
return value;
|
1788
|
+
};
|
1789
|
+
var _tables, _schemaTables$1;
|
1387
1790
|
class SchemaPlugin extends XataPlugin {
|
1388
|
-
constructor(
|
1791
|
+
constructor(schemaTables) {
|
1389
1792
|
super();
|
1390
|
-
this.links = links;
|
1391
|
-
this.tableNames = tableNames;
|
1392
1793
|
__privateAdd$2(this, _tables, {});
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
const db = new Proxy(
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1794
|
+
__privateAdd$2(this, _schemaTables$1, void 0);
|
1795
|
+
__privateSet$2(this, _schemaTables$1, schemaTables);
|
1796
|
+
}
|
1797
|
+
build(pluginOptions) {
|
1798
|
+
const db = new Proxy(
|
1799
|
+
{},
|
1800
|
+
{
|
1801
|
+
get: (_target, table) => {
|
1802
|
+
if (!isString(table))
|
1803
|
+
throw new Error("Invalid table name");
|
1804
|
+
if (__privateGet$2(this, _tables)[table] === void 0) {
|
1805
|
+
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
1806
|
+
}
|
1807
|
+
return __privateGet$2(this, _tables)[table];
|
1808
|
+
}
|
1404
1809
|
}
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1810
|
+
);
|
1811
|
+
const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
|
1812
|
+
for (const table of tableNames) {
|
1813
|
+
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
1408
1814
|
}
|
1409
1815
|
return db;
|
1410
1816
|
}
|
1411
1817
|
}
|
1412
1818
|
_tables = new WeakMap();
|
1819
|
+
_schemaTables$1 = new WeakMap();
|
1413
1820
|
|
1414
1821
|
var __accessCheck$1 = (obj, member, msg) => {
|
1415
1822
|
if (!member.has(obj))
|
1416
1823
|
throw TypeError("Cannot " + msg);
|
1417
1824
|
};
|
1825
|
+
var __privateGet$1 = (obj, member, getter) => {
|
1826
|
+
__accessCheck$1(obj, member, "read from private field");
|
1827
|
+
return getter ? getter.call(obj) : member.get(obj);
|
1828
|
+
};
|
1418
1829
|
var __privateAdd$1 = (obj, member, value) => {
|
1419
1830
|
if (member.has(obj))
|
1420
1831
|
throw TypeError("Cannot add the same private member more than once");
|
1421
1832
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1422
1833
|
};
|
1834
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
1835
|
+
__accessCheck$1(obj, member, "write to private field");
|
1836
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
1837
|
+
return value;
|
1838
|
+
};
|
1423
1839
|
var __privateMethod$1 = (obj, member, method) => {
|
1424
1840
|
__accessCheck$1(obj, member, "access private method");
|
1425
1841
|
return method;
|
1426
1842
|
};
|
1427
|
-
var _search, search_fn;
|
1843
|
+
var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
|
1428
1844
|
class SearchPlugin extends XataPlugin {
|
1429
|
-
constructor(db,
|
1845
|
+
constructor(db, schemaTables) {
|
1430
1846
|
super();
|
1431
1847
|
this.db = db;
|
1432
|
-
this.links = links;
|
1433
1848
|
__privateAdd$1(this, _search);
|
1849
|
+
__privateAdd$1(this, _getSchemaTables);
|
1850
|
+
__privateAdd$1(this, _schemaTables, void 0);
|
1851
|
+
__privateSet$1(this, _schemaTables, schemaTables);
|
1434
1852
|
}
|
1435
1853
|
build({ getFetchProps }) {
|
1436
1854
|
return {
|
1437
1855
|
all: async (query, options = {}) => {
|
1438
1856
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1857
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1439
1858
|
return records.map((record) => {
|
1440
1859
|
const { table = "orphan" } = record.xata;
|
1441
|
-
return { table, record: initObject(this.db,
|
1860
|
+
return { table, record: initObject(this.db, schemaTables, table, record) };
|
1442
1861
|
});
|
1443
1862
|
},
|
1444
1863
|
byTable: async (query, options = {}) => {
|
1445
1864
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1865
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1446
1866
|
return records.reduce((acc, record) => {
|
1447
1867
|
const { table = "orphan" } = record.xata;
|
1448
1868
|
const items = acc[table] ?? [];
|
1449
|
-
const item = initObject(this.db,
|
1869
|
+
const item = initObject(this.db, schemaTables, table, record);
|
1450
1870
|
return { ...acc, [table]: [...items, item] };
|
1451
1871
|
}, {});
|
1452
1872
|
}
|
1453
1873
|
};
|
1454
1874
|
}
|
1455
1875
|
}
|
1876
|
+
_schemaTables = new WeakMap();
|
1456
1877
|
_search = new WeakSet();
|
1457
1878
|
search_fn = async function(query, options, getFetchProps) {
|
1458
1879
|
const fetchProps = await getFetchProps();
|
1459
|
-
const { tables, fuzziness } = options ?? {};
|
1880
|
+
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
1460
1881
|
const { records } = await searchBranch({
|
1461
1882
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1462
|
-
body: { tables, query, fuzziness },
|
1883
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
1463
1884
|
...fetchProps
|
1464
1885
|
});
|
1465
1886
|
return records;
|
1466
1887
|
};
|
1888
|
+
_getSchemaTables = new WeakSet();
|
1889
|
+
getSchemaTables_fn = async function(getFetchProps) {
|
1890
|
+
if (__privateGet$1(this, _schemaTables))
|
1891
|
+
return __privateGet$1(this, _schemaTables);
|
1892
|
+
const fetchProps = await getFetchProps();
|
1893
|
+
const { schema } = await getBranchDetails({
|
1894
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1895
|
+
...fetchProps
|
1896
|
+
});
|
1897
|
+
__privateSet$1(this, _schemaTables, schema.tables);
|
1898
|
+
return schema.tables;
|
1899
|
+
};
|
1467
1900
|
|
1468
1901
|
const isBranchStrategyBuilder = (strategy) => {
|
1469
1902
|
return typeof strategy === "function";
|
1470
1903
|
};
|
1471
1904
|
|
1472
|
-
const envBranchNames = [
|
1473
|
-
"XATA_BRANCH",
|
1474
|
-
"VERCEL_GIT_COMMIT_REF",
|
1475
|
-
"CF_PAGES_BRANCH",
|
1476
|
-
"BRANCH"
|
1477
|
-
];
|
1478
|
-
const defaultBranch = "main";
|
1479
1905
|
async function getCurrentBranchName(options) {
|
1480
|
-
const
|
1481
|
-
if (
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
return defaultBranch;
|
1906
|
+
const { branch, envBranch } = getEnvironment();
|
1907
|
+
if (branch) {
|
1908
|
+
const details = await getDatabaseBranch(branch, options);
|
1909
|
+
if (details)
|
1910
|
+
return branch;
|
1911
|
+
console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
|
1912
|
+
}
|
1913
|
+
const gitBranch = envBranch || await getGitBranch();
|
1914
|
+
return resolveXataBranch(gitBranch, options);
|
1490
1915
|
}
|
1491
1916
|
async function getCurrentBranchDetails(options) {
|
1492
|
-
const
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1917
|
+
const branch = await getCurrentBranchName(options);
|
1918
|
+
return getDatabaseBranch(branch, options);
|
1919
|
+
}
|
1920
|
+
async function resolveXataBranch(gitBranch, options) {
|
1921
|
+
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1922
|
+
const apiKey = options?.apiKey || getAPIKey();
|
1923
|
+
if (!databaseURL)
|
1924
|
+
throw new Error(
|
1925
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
1926
|
+
);
|
1927
|
+
if (!apiKey)
|
1928
|
+
throw new Error(
|
1929
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
1930
|
+
);
|
1931
|
+
const [protocol, , host, , dbName] = databaseURL.split("/");
|
1932
|
+
const [workspace] = host.split(".");
|
1933
|
+
const { fallbackBranch } = getEnvironment();
|
1934
|
+
const { branch } = await resolveBranch({
|
1935
|
+
apiKey,
|
1936
|
+
apiUrl: databaseURL,
|
1937
|
+
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1938
|
+
workspacesApiUrl: `${protocol}//${host}`,
|
1939
|
+
pathParams: { dbName, workspace },
|
1940
|
+
queryParams: { gitBranch, fallbackBranch }
|
1941
|
+
});
|
1942
|
+
return branch;
|
1502
1943
|
}
|
1503
1944
|
async function getDatabaseBranch(branch, options) {
|
1504
1945
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1505
1946
|
const apiKey = options?.apiKey || getAPIKey();
|
1506
1947
|
if (!databaseURL)
|
1507
|
-
throw new Error(
|
1948
|
+
throw new Error(
|
1949
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
1950
|
+
);
|
1508
1951
|
if (!apiKey)
|
1509
|
-
throw new Error(
|
1952
|
+
throw new Error(
|
1953
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
1954
|
+
);
|
1510
1955
|
const [protocol, , host, , database] = databaseURL.split("/");
|
1511
1956
|
const [workspace] = host.split(".");
|
1512
1957
|
const dbBranchName = `${database}:${branch}`;
|
@@ -1516,10 +1961,7 @@ async function getDatabaseBranch(branch, options) {
|
|
1516
1961
|
apiUrl: databaseURL,
|
1517
1962
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1518
1963
|
workspacesApiUrl: `${protocol}//${host}`,
|
1519
|
-
pathParams: {
|
1520
|
-
dbBranchName,
|
1521
|
-
workspace
|
1522
|
-
}
|
1964
|
+
pathParams: { dbBranchName, workspace }
|
1523
1965
|
});
|
1524
1966
|
} catch (err) {
|
1525
1967
|
if (isObject(err) && err.status === 404)
|
@@ -1527,21 +1969,10 @@ async function getDatabaseBranch(branch, options) {
|
|
1527
1969
|
throw err;
|
1528
1970
|
}
|
1529
1971
|
}
|
1530
|
-
function getBranchByEnvVariable() {
|
1531
|
-
for (const name of envBranchNames) {
|
1532
|
-
const value = getEnvVariable(name);
|
1533
|
-
if (value) {
|
1534
|
-
return value;
|
1535
|
-
}
|
1536
|
-
}
|
1537
|
-
try {
|
1538
|
-
return XATA_BRANCH;
|
1539
|
-
} catch (err) {
|
1540
|
-
}
|
1541
|
-
}
|
1542
1972
|
function getDatabaseURL() {
|
1543
1973
|
try {
|
1544
|
-
|
1974
|
+
const { databaseURL } = getEnvironment();
|
1975
|
+
return databaseURL;
|
1545
1976
|
} catch (err) {
|
1546
1977
|
return void 0;
|
1547
1978
|
}
|
@@ -1572,22 +2003,24 @@ var __privateMethod = (obj, member, method) => {
|
|
1572
2003
|
const buildClient = (plugins) => {
|
1573
2004
|
var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
1574
2005
|
return _a = class {
|
1575
|
-
constructor(options = {},
|
2006
|
+
constructor(options = {}, schemaTables) {
|
1576
2007
|
__privateAdd(this, _parseOptions);
|
1577
2008
|
__privateAdd(this, _getFetchProps);
|
1578
2009
|
__privateAdd(this, _evaluateBranch);
|
1579
2010
|
__privateAdd(this, _branch, void 0);
|
1580
2011
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
1581
|
-
const
|
1582
|
-
|
1583
|
-
|
1584
|
-
}
|
2012
|
+
const pluginOptions = {
|
2013
|
+
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
2014
|
+
cache: safeOptions.cache
|
2015
|
+
};
|
2016
|
+
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
2017
|
+
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
1585
2018
|
this.db = db;
|
1586
2019
|
this.search = search;
|
1587
2020
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
1588
|
-
if (
|
2021
|
+
if (namespace === void 0)
|
1589
2022
|
continue;
|
1590
|
-
const result = namespace.build(
|
2023
|
+
const result = namespace.build(pluginOptions);
|
1591
2024
|
if (result instanceof Promise) {
|
1592
2025
|
void result.then((namespace2) => {
|
1593
2026
|
this[key] = namespace2;
|
@@ -1601,11 +2034,12 @@ const buildClient = (plugins) => {
|
|
1601
2034
|
const fetch = getFetchImplementation(options?.fetch);
|
1602
2035
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1603
2036
|
const apiKey = options?.apiKey || getAPIKey();
|
1604
|
-
const
|
2037
|
+
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
2038
|
+
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
1605
2039
|
if (!databaseURL || !apiKey) {
|
1606
2040
|
throw new Error("Options databaseURL and apiKey are required");
|
1607
2041
|
}
|
1608
|
-
return { fetch, databaseURL, apiKey, branch };
|
2042
|
+
return { fetch, databaseURL, apiKey, branch, cache };
|
1609
2043
|
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
|
1610
2044
|
fetch,
|
1611
2045
|
apiKey,
|
@@ -1628,7 +2062,7 @@ const buildClient = (plugins) => {
|
|
1628
2062
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
1629
2063
|
if (__privateGet(this, _branch))
|
1630
2064
|
return __privateGet(this, _branch);
|
1631
|
-
if (
|
2065
|
+
if (param === void 0)
|
1632
2066
|
return void 0;
|
1633
2067
|
const strategies = Array.isArray(param) ? [...param] : [param];
|
1634
2068
|
const evaluateBranch = async (strategy) => {
|
@@ -1661,15 +2095,18 @@ exports.PAGINATION_MAX_OFFSET = PAGINATION_MAX_OFFSET;
|
|
1661
2095
|
exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
|
1662
2096
|
exports.Page = Page;
|
1663
2097
|
exports.Query = Query;
|
2098
|
+
exports.RecordArray = RecordArray;
|
1664
2099
|
exports.Repository = Repository;
|
1665
2100
|
exports.RestRepository = RestRepository;
|
1666
2101
|
exports.SchemaPlugin = SchemaPlugin;
|
1667
2102
|
exports.SearchPlugin = SearchPlugin;
|
2103
|
+
exports.SimpleCache = SimpleCache;
|
1668
2104
|
exports.XataApiClient = XataApiClient;
|
1669
2105
|
exports.XataApiPlugin = XataApiPlugin;
|
1670
2106
|
exports.XataError = XataError;
|
1671
2107
|
exports.XataPlugin = XataPlugin;
|
1672
2108
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
2109
|
+
exports.addGitBranchesEntry = addGitBranchesEntry;
|
1673
2110
|
exports.addTableColumn = addTableColumn;
|
1674
2111
|
exports.buildClient = buildClient;
|
1675
2112
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
@@ -1703,7 +2140,9 @@ exports.getColumn = getColumn;
|
|
1703
2140
|
exports.getCurrentBranchDetails = getCurrentBranchDetails;
|
1704
2141
|
exports.getCurrentBranchName = getCurrentBranchName;
|
1705
2142
|
exports.getDatabaseList = getDatabaseList;
|
2143
|
+
exports.getDatabaseMetadata = getDatabaseMetadata;
|
1706
2144
|
exports.getDatabaseURL = getDatabaseURL;
|
2145
|
+
exports.getGitBranchesMapping = getGitBranchesMapping;
|
1707
2146
|
exports.getRecord = getRecord;
|
1708
2147
|
exports.getTableColumns = getTableColumns;
|
1709
2148
|
exports.getTableSchema = getTableSchema;
|
@@ -1722,6 +2161,7 @@ exports.insertRecord = insertRecord;
|
|
1722
2161
|
exports.insertRecordWithID = insertRecordWithID;
|
1723
2162
|
exports.inviteWorkspaceMember = inviteWorkspaceMember;
|
1724
2163
|
exports.is = is;
|
2164
|
+
exports.isCursorPaginationOptions = isCursorPaginationOptions;
|
1725
2165
|
exports.isIdentifiable = isIdentifiable;
|
1726
2166
|
exports.isNot = isNot;
|
1727
2167
|
exports.isXataRecord = isXataRecord;
|
@@ -1732,9 +2172,12 @@ exports.notExists = notExists;
|
|
1732
2172
|
exports.operationsByTag = operationsByTag;
|
1733
2173
|
exports.pattern = pattern;
|
1734
2174
|
exports.queryTable = queryTable;
|
2175
|
+
exports.removeGitBranchesEntry = removeGitBranchesEntry;
|
1735
2176
|
exports.removeWorkspaceMember = removeWorkspaceMember;
|
1736
2177
|
exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
|
2178
|
+
exports.resolveBranch = resolveBranch;
|
1737
2179
|
exports.searchBranch = searchBranch;
|
2180
|
+
exports.searchTable = searchTable;
|
1738
2181
|
exports.setTableSchema = setTableSchema;
|
1739
2182
|
exports.startsWith = startsWith;
|
1740
2183
|
exports.updateBranchMetadata = updateBranchMetadata;
|
@@ -1743,6 +2186,7 @@ exports.updateRecordWithID = updateRecordWithID;
|
|
1743
2186
|
exports.updateTable = updateTable;
|
1744
2187
|
exports.updateUser = updateUser;
|
1745
2188
|
exports.updateWorkspace = updateWorkspace;
|
2189
|
+
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
1746
2190
|
exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
|
1747
2191
|
exports.upsertRecordWithID = upsertRecordWithID;
|
1748
2192
|
//# sourceMappingURL=index.cjs.map
|