@xata.io/client 0.0.0-alpha.vf27674a → 0.0.0-alpha.vf3111df
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 +152 -0
- package/README.md +273 -1
- package/Usage.md +449 -0
- package/dist/index.cjs +762 -398
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +886 -166
- package/dist/index.mjs +736 -398
- 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,48 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
+
function _interopNamespace(e) {
|
6
|
+
if (e && e.__esModule) return e;
|
7
|
+
var n = Object.create(null);
|
8
|
+
if (e) {
|
9
|
+
Object.keys(e).forEach(function (k) {
|
10
|
+
if (k !== 'default') {
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
13
|
+
enumerable: true,
|
14
|
+
get: function () { return e[k]; }
|
15
|
+
});
|
16
|
+
}
|
17
|
+
});
|
18
|
+
}
|
19
|
+
n["default"] = e;
|
20
|
+
return Object.freeze(n);
|
21
|
+
}
|
22
|
+
|
23
|
+
const defaultTrace = async (_name, fn, _options) => {
|
24
|
+
return await fn({
|
25
|
+
setAttributes: () => {
|
26
|
+
return;
|
27
|
+
},
|
28
|
+
onError: () => {
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
});
|
32
|
+
};
|
33
|
+
const TraceAttributes = {
|
34
|
+
VERSION: "xata.sdk.version",
|
35
|
+
TABLE: "xata.table",
|
36
|
+
HTTP_REQUEST_ID: "http.request_id",
|
37
|
+
HTTP_STATUS_CODE: "http.status_code",
|
38
|
+
HTTP_HOST: "http.host",
|
39
|
+
HTTP_SCHEME: "http.scheme",
|
40
|
+
HTTP_USER_AGENT: "http.user_agent",
|
41
|
+
HTTP_METHOD: "http.method",
|
42
|
+
HTTP_URL: "http.url",
|
43
|
+
HTTP_ROUTE: "http.route",
|
44
|
+
HTTP_TARGET: "http.target"
|
45
|
+
};
|
46
|
+
|
5
47
|
function notEmpty(value) {
|
6
48
|
return value !== null && value !== void 0;
|
7
49
|
}
|
@@ -11,46 +53,101 @@ function compact(arr) {
|
|
11
53
|
function isObject(value) {
|
12
54
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
13
55
|
}
|
56
|
+
function isDefined(value) {
|
57
|
+
return value !== null && value !== void 0;
|
58
|
+
}
|
14
59
|
function isString(value) {
|
15
|
-
return value
|
60
|
+
return isDefined(value) && typeof value === "string";
|
61
|
+
}
|
62
|
+
function isStringArray(value) {
|
63
|
+
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
16
64
|
}
|
17
65
|
function toBase64(value) {
|
18
66
|
try {
|
19
67
|
return btoa(value);
|
20
68
|
} catch (err) {
|
21
|
-
|
69
|
+
const buf = Buffer;
|
70
|
+
return buf.from(value).toString("base64");
|
22
71
|
}
|
23
72
|
}
|
24
73
|
|
25
|
-
function
|
74
|
+
function getEnvironment() {
|
26
75
|
try {
|
27
|
-
if (isObject(process) &&
|
28
|
-
return
|
76
|
+
if (isObject(process) && isObject(process.env)) {
|
77
|
+
return {
|
78
|
+
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
79
|
+
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
80
|
+
branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
|
81
|
+
envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
|
82
|
+
fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
|
83
|
+
};
|
29
84
|
}
|
30
85
|
} catch (err) {
|
31
86
|
}
|
32
87
|
try {
|
33
|
-
if (isObject(Deno) &&
|
34
|
-
return
|
88
|
+
if (isObject(Deno) && isObject(Deno.env)) {
|
89
|
+
return {
|
90
|
+
apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
|
91
|
+
databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
|
92
|
+
branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
|
93
|
+
envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
|
94
|
+
fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
|
95
|
+
};
|
35
96
|
}
|
36
97
|
} catch (err) {
|
37
98
|
}
|
99
|
+
return {
|
100
|
+
apiKey: getGlobalApiKey(),
|
101
|
+
databaseURL: getGlobalDatabaseURL(),
|
102
|
+
branch: getGlobalBranch(),
|
103
|
+
envBranch: void 0,
|
104
|
+
fallbackBranch: getGlobalFallbackBranch()
|
105
|
+
};
|
106
|
+
}
|
107
|
+
function getGlobalApiKey() {
|
108
|
+
try {
|
109
|
+
return XATA_API_KEY;
|
110
|
+
} catch (err) {
|
111
|
+
return void 0;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
function getGlobalDatabaseURL() {
|
115
|
+
try {
|
116
|
+
return XATA_DATABASE_URL;
|
117
|
+
} catch (err) {
|
118
|
+
return void 0;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
function getGlobalBranch() {
|
122
|
+
try {
|
123
|
+
return XATA_BRANCH;
|
124
|
+
} catch (err) {
|
125
|
+
return void 0;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
function getGlobalFallbackBranch() {
|
129
|
+
try {
|
130
|
+
return XATA_FALLBACK_BRANCH;
|
131
|
+
} catch (err) {
|
132
|
+
return void 0;
|
133
|
+
}
|
38
134
|
}
|
39
135
|
async function getGitBranch() {
|
136
|
+
const cmd = ["git", "branch", "--show-current"];
|
137
|
+
const fullCmd = cmd.join(" ");
|
138
|
+
const nodeModule = ["child", "process"].join("_");
|
139
|
+
const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
|
40
140
|
try {
|
41
141
|
if (typeof require === "function") {
|
42
|
-
|
43
|
-
return req("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
|
142
|
+
return require(nodeModule).execSync(fullCmd, execOptions).trim();
|
44
143
|
}
|
144
|
+
const { execSync } = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(nodeModule);
|
145
|
+
return execSync(fullCmd, execOptions).toString().trim();
|
45
146
|
} catch (err) {
|
46
147
|
}
|
47
148
|
try {
|
48
149
|
if (isObject(Deno)) {
|
49
|
-
const process2 = Deno.run({
|
50
|
-
cmd: ["git", "branch", "--show-current"],
|
51
|
-
stdout: "piped",
|
52
|
-
stderr: "piped"
|
53
|
-
});
|
150
|
+
const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
54
151
|
return new TextDecoder().decode(await process2.output()).trim();
|
55
152
|
}
|
56
153
|
} catch (err) {
|
@@ -59,7 +156,8 @@ async function getGitBranch() {
|
|
59
156
|
|
60
157
|
function getAPIKey() {
|
61
158
|
try {
|
62
|
-
|
159
|
+
const { apiKey } = getEnvironment();
|
160
|
+
return apiKey;
|
63
161
|
} catch (err) {
|
64
162
|
return void 0;
|
65
163
|
}
|
@@ -69,21 +167,35 @@ function getFetchImplementation(userFetch) {
|
|
69
167
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
70
168
|
const fetchImpl = userFetch ?? globalFetch;
|
71
169
|
if (!fetchImpl) {
|
72
|
-
throw new Error(
|
170
|
+
throw new Error(
|
171
|
+
`The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`
|
172
|
+
);
|
73
173
|
}
|
74
174
|
return fetchImpl;
|
75
175
|
}
|
76
176
|
|
77
|
-
|
78
|
-
|
177
|
+
const VERSION = "0.0.0-alpha.vf3111df";
|
178
|
+
|
179
|
+
class ErrorWithCause extends Error {
|
180
|
+
constructor(message, options) {
|
181
|
+
super(message, options);
|
182
|
+
}
|
183
|
+
}
|
184
|
+
class FetcherError extends ErrorWithCause {
|
185
|
+
constructor(status, data, requestId) {
|
79
186
|
super(getMessage(data));
|
80
187
|
this.status = status;
|
81
188
|
this.errors = isBulkError(data) ? data.errors : void 0;
|
189
|
+
this.requestId = requestId;
|
82
190
|
if (data instanceof Error) {
|
83
191
|
this.stack = data.stack;
|
84
192
|
this.cause = data.cause;
|
85
193
|
}
|
86
194
|
}
|
195
|
+
toString() {
|
196
|
+
const error = super.toString();
|
197
|
+
return `[${this.status}] (${this.requestId ?? "Unknown"}): ${error}`;
|
198
|
+
}
|
87
199
|
}
|
88
200
|
function isBulkError(error) {
|
89
201
|
return isObject(error) && Array.isArray(error.errors);
|
@@ -106,7 +218,12 @@ function getMessage(data) {
|
|
106
218
|
}
|
107
219
|
|
108
220
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
109
|
-
const
|
221
|
+
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
222
|
+
if (value === void 0 || value === null)
|
223
|
+
return acc;
|
224
|
+
return { ...acc, [key]: value };
|
225
|
+
}, {});
|
226
|
+
const query = new URLSearchParams(cleanQueryParams).toString();
|
110
227
|
const queryString = query.length > 0 ? `?${query}` : "";
|
111
228
|
return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
|
112
229
|
};
|
@@ -136,32 +253,62 @@ async function fetch$1({
|
|
136
253
|
fetchImpl,
|
137
254
|
apiKey,
|
138
255
|
apiUrl,
|
139
|
-
workspacesApiUrl
|
256
|
+
workspacesApiUrl,
|
257
|
+
trace
|
140
258
|
}) {
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
259
|
+
return trace(
|
260
|
+
`${method.toUpperCase()} ${path}`,
|
261
|
+
async ({ setAttributes, onError }) => {
|
262
|
+
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
263
|
+
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
264
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
265
|
+
setAttributes({
|
266
|
+
[TraceAttributes.HTTP_URL]: url,
|
267
|
+
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
268
|
+
});
|
269
|
+
const response = await fetchImpl(url, {
|
270
|
+
method: method.toUpperCase(),
|
271
|
+
body: body ? JSON.stringify(body) : void 0,
|
272
|
+
headers: {
|
273
|
+
"Content-Type": "application/json",
|
274
|
+
"User-Agent": `Xata client-ts/${VERSION}`,
|
275
|
+
...headers,
|
276
|
+
...hostHeader(fullUrl),
|
277
|
+
Authorization: `Bearer ${apiKey}`
|
278
|
+
}
|
279
|
+
});
|
280
|
+
if (response.status === 204) {
|
281
|
+
return {};
|
282
|
+
}
|
283
|
+
const { host, protocol } = parseUrl(response.url);
|
284
|
+
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
285
|
+
setAttributes({
|
286
|
+
[TraceAttributes.HTTP_REQUEST_ID]: requestId,
|
287
|
+
[TraceAttributes.HTTP_STATUS_CODE]: response.status,
|
288
|
+
[TraceAttributes.HTTP_HOST]: host,
|
289
|
+
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
290
|
+
});
|
291
|
+
try {
|
292
|
+
const jsonResponse = await response.json();
|
293
|
+
if (response.ok) {
|
294
|
+
return jsonResponse;
|
295
|
+
}
|
296
|
+
throw new FetcherError(response.status, jsonResponse, requestId);
|
297
|
+
} catch (error) {
|
298
|
+
const fetcherError = new FetcherError(response.status, error, requestId);
|
299
|
+
onError(fetcherError.message);
|
300
|
+
throw fetcherError;
|
301
|
+
}
|
302
|
+
},
|
303
|
+
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
304
|
+
);
|
305
|
+
}
|
306
|
+
function parseUrl(url) {
|
157
307
|
try {
|
158
|
-
const
|
159
|
-
|
160
|
-
return jsonResponse;
|
161
|
-
}
|
162
|
-
throw new FetcherError(response.status, jsonResponse);
|
308
|
+
const { host, protocol } = new URL(url);
|
309
|
+
return { host, protocol };
|
163
310
|
} catch (error) {
|
164
|
-
|
311
|
+
return {};
|
165
312
|
}
|
166
313
|
}
|
167
314
|
|
@@ -220,6 +367,7 @@ const removeWorkspaceMember = (variables) => fetch$1({
|
|
220
367
|
...variables
|
221
368
|
});
|
222
369
|
const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
|
370
|
+
const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
|
223
371
|
const cancelWorkspaceMemberInvite = (variables) => fetch$1({
|
224
372
|
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
225
373
|
method: "delete",
|
@@ -255,6 +403,11 @@ const deleteDatabase = (variables) => fetch$1({
|
|
255
403
|
method: "delete",
|
256
404
|
...variables
|
257
405
|
});
|
406
|
+
const getDatabaseMetadata = (variables) => fetch$1({
|
407
|
+
url: "/dbs/{dbName}/metadata",
|
408
|
+
method: "get",
|
409
|
+
...variables
|
410
|
+
});
|
258
411
|
const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
|
259
412
|
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
260
413
|
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
@@ -268,11 +421,7 @@ const getBranchDetails = (variables) => fetch$1({
|
|
268
421
|
method: "get",
|
269
422
|
...variables
|
270
423
|
});
|
271
|
-
const createBranch = (variables) => fetch$1({
|
272
|
-
url: "/db/{dbBranchName}",
|
273
|
-
method: "put",
|
274
|
-
...variables
|
275
|
-
});
|
424
|
+
const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
|
276
425
|
const deleteBranch = (variables) => fetch$1({
|
277
426
|
url: "/db/{dbBranchName}",
|
278
427
|
method: "delete",
|
@@ -346,11 +495,7 @@ const updateColumn = (variables) => fetch$1({
|
|
346
495
|
method: "patch",
|
347
496
|
...variables
|
348
497
|
});
|
349
|
-
const insertRecord = (variables) => fetch$1({
|
350
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data",
|
351
|
-
method: "post",
|
352
|
-
...variables
|
353
|
-
});
|
498
|
+
const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
|
354
499
|
const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
|
355
500
|
const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
|
356
501
|
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
@@ -370,6 +515,11 @@ const queryTable = (variables) => fetch$1({
|
|
370
515
|
method: "post",
|
371
516
|
...variables
|
372
517
|
});
|
518
|
+
const searchTable = (variables) => fetch$1({
|
519
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
520
|
+
method: "post",
|
521
|
+
...variables
|
522
|
+
});
|
373
523
|
const searchBranch = (variables) => fetch$1({
|
374
524
|
url: "/db/{dbBranchName}/search",
|
375
525
|
method: "post",
|
@@ -387,6 +537,7 @@ const operationsByTag = {
|
|
387
537
|
updateWorkspaceMemberRole,
|
388
538
|
removeWorkspaceMember,
|
389
539
|
inviteWorkspaceMember,
|
540
|
+
updateWorkspaceMemberInvite,
|
390
541
|
cancelWorkspaceMemberInvite,
|
391
542
|
resendWorkspaceMemberInvite,
|
392
543
|
acceptWorkspaceMemberInvite
|
@@ -395,6 +546,7 @@ const operationsByTag = {
|
|
395
546
|
getDatabaseList,
|
396
547
|
createDatabase,
|
397
548
|
deleteDatabase,
|
549
|
+
getDatabaseMetadata,
|
398
550
|
getGitBranchesMapping,
|
399
551
|
addGitBranchesEntry,
|
400
552
|
removeGitBranchesEntry,
|
@@ -433,6 +585,7 @@ const operationsByTag = {
|
|
433
585
|
getRecord,
|
434
586
|
bulkInsertTableRecords,
|
435
587
|
queryTable,
|
588
|
+
searchTable,
|
436
589
|
searchBranch
|
437
590
|
}
|
438
591
|
};
|
@@ -475,7 +628,7 @@ var __privateAdd$7 = (obj, member, value) => {
|
|
475
628
|
throw TypeError("Cannot add the same private member more than once");
|
476
629
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
477
630
|
};
|
478
|
-
var __privateSet$
|
631
|
+
var __privateSet$7 = (obj, member, value, setter) => {
|
479
632
|
__accessCheck$7(obj, member, "write to private field");
|
480
633
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
481
634
|
return value;
|
@@ -486,15 +639,17 @@ class XataApiClient {
|
|
486
639
|
__privateAdd$7(this, _extraProps, void 0);
|
487
640
|
__privateAdd$7(this, _namespaces, {});
|
488
641
|
const provider = options.host ?? "production";
|
489
|
-
const apiKey = options
|
642
|
+
const apiKey = options.apiKey ?? getAPIKey();
|
643
|
+
const trace = options.trace ?? defaultTrace;
|
490
644
|
if (!apiKey) {
|
491
645
|
throw new Error("Could not resolve a valid apiKey");
|
492
646
|
}
|
493
|
-
__privateSet$
|
647
|
+
__privateSet$7(this, _extraProps, {
|
494
648
|
apiUrl: getHostUrl(provider, "main"),
|
495
649
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
496
650
|
fetchImpl: getFetchImplementation(options.fetch),
|
497
|
-
apiKey
|
651
|
+
apiKey,
|
652
|
+
trace
|
498
653
|
});
|
499
654
|
}
|
500
655
|
get user() {
|
@@ -617,6 +772,13 @@ class WorkspaceApi {
|
|
617
772
|
...this.extraProps
|
618
773
|
});
|
619
774
|
}
|
775
|
+
updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
|
776
|
+
return operationsByTag.workspaces.updateWorkspaceMemberInvite({
|
777
|
+
pathParams: { workspaceId, inviteId },
|
778
|
+
body: { role },
|
779
|
+
...this.extraProps
|
780
|
+
});
|
781
|
+
}
|
620
782
|
cancelWorkspaceMemberInvite(workspaceId, inviteId) {
|
621
783
|
return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
|
622
784
|
pathParams: { workspaceId, inviteId },
|
@@ -659,6 +821,12 @@ class DatabaseApi {
|
|
659
821
|
...this.extraProps
|
660
822
|
});
|
661
823
|
}
|
824
|
+
getDatabaseMetadata(workspace, dbName) {
|
825
|
+
return operationsByTag.database.getDatabaseMetadata({
|
826
|
+
pathParams: { workspace, dbName },
|
827
|
+
...this.extraProps
|
828
|
+
});
|
829
|
+
}
|
662
830
|
getGitBranchesMapping(workspace, dbName) {
|
663
831
|
return operationsByTag.database.getGitBranchesMapping({
|
664
832
|
pathParams: { workspace, dbName },
|
@@ -679,10 +847,10 @@ class DatabaseApi {
|
|
679
847
|
...this.extraProps
|
680
848
|
});
|
681
849
|
}
|
682
|
-
resolveBranch(workspace, dbName, gitBranch) {
|
850
|
+
resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
|
683
851
|
return operationsByTag.database.resolveBranch({
|
684
852
|
pathParams: { workspace, dbName },
|
685
|
-
queryParams: { gitBranch },
|
853
|
+
queryParams: { gitBranch, fallbackBranch },
|
686
854
|
...this.extraProps
|
687
855
|
});
|
688
856
|
}
|
@@ -831,9 +999,10 @@ class RecordsApi {
|
|
831
999
|
constructor(extraProps) {
|
832
1000
|
this.extraProps = extraProps;
|
833
1001
|
}
|
834
|
-
insertRecord(workspace, database, branch, tableName, record) {
|
1002
|
+
insertRecord(workspace, database, branch, tableName, record, options = {}) {
|
835
1003
|
return operationsByTag.records.insertRecord({
|
836
1004
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1005
|
+
queryParams: options,
|
837
1006
|
body: record,
|
838
1007
|
...this.extraProps
|
839
1008
|
});
|
@@ -862,21 +1031,24 @@ class RecordsApi {
|
|
862
1031
|
...this.extraProps
|
863
1032
|
});
|
864
1033
|
}
|
865
|
-
deleteRecord(workspace, database, branch, tableName, recordId) {
|
1034
|
+
deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
866
1035
|
return operationsByTag.records.deleteRecord({
|
867
1036
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1037
|
+
queryParams: options,
|
868
1038
|
...this.extraProps
|
869
1039
|
});
|
870
1040
|
}
|
871
1041
|
getRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
872
1042
|
return operationsByTag.records.getRecord({
|
873
1043
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1044
|
+
queryParams: options,
|
874
1045
|
...this.extraProps
|
875
1046
|
});
|
876
1047
|
}
|
877
|
-
bulkInsertTableRecords(workspace, database, branch, tableName, records) {
|
1048
|
+
bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
|
878
1049
|
return operationsByTag.records.bulkInsertTableRecords({
|
879
1050
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1051
|
+
queryParams: options,
|
880
1052
|
body: { records },
|
881
1053
|
...this.extraProps
|
882
1054
|
});
|
@@ -888,6 +1060,13 @@ class RecordsApi {
|
|
888
1060
|
...this.extraProps
|
889
1061
|
});
|
890
1062
|
}
|
1063
|
+
searchTable(workspace, database, branch, tableName, query) {
|
1064
|
+
return operationsByTag.records.searchTable({
|
1065
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1066
|
+
body: query,
|
1067
|
+
...this.extraProps
|
1068
|
+
});
|
1069
|
+
}
|
891
1070
|
searchBranch(workspace, database, branch, query) {
|
892
1071
|
return operationsByTag.records.searchBranch({
|
893
1072
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
@@ -920,18 +1099,18 @@ var __privateAdd$6 = (obj, member, value) => {
|
|
920
1099
|
throw TypeError("Cannot add the same private member more than once");
|
921
1100
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
922
1101
|
};
|
923
|
-
var __privateSet$
|
1102
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
924
1103
|
__accessCheck$6(obj, member, "write to private field");
|
925
1104
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
926
1105
|
return value;
|
927
1106
|
};
|
928
|
-
var _query;
|
1107
|
+
var _query, _page;
|
929
1108
|
class Page {
|
930
1109
|
constructor(query, meta, records = []) {
|
931
1110
|
__privateAdd$6(this, _query, void 0);
|
932
|
-
__privateSet$
|
1111
|
+
__privateSet$6(this, _query, query);
|
933
1112
|
this.meta = meta;
|
934
|
-
this.records = records;
|
1113
|
+
this.records = new RecordArray(this, records);
|
935
1114
|
}
|
936
1115
|
async nextPage(size, offset) {
|
937
1116
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
@@ -951,9 +1130,56 @@ class Page {
|
|
951
1130
|
}
|
952
1131
|
_query = new WeakMap();
|
953
1132
|
const PAGINATION_MAX_SIZE = 200;
|
954
|
-
const PAGINATION_DEFAULT_SIZE =
|
1133
|
+
const PAGINATION_DEFAULT_SIZE = 20;
|
955
1134
|
const PAGINATION_MAX_OFFSET = 800;
|
956
1135
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
1136
|
+
function isCursorPaginationOptions(options) {
|
1137
|
+
return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
|
1138
|
+
}
|
1139
|
+
const _RecordArray = class extends Array {
|
1140
|
+
constructor(...args) {
|
1141
|
+
super(..._RecordArray.parseConstructorParams(...args));
|
1142
|
+
__privateAdd$6(this, _page, void 0);
|
1143
|
+
__privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
|
1144
|
+
}
|
1145
|
+
static parseConstructorParams(...args) {
|
1146
|
+
if (args.length === 1 && typeof args[0] === "number") {
|
1147
|
+
return new Array(args[0]);
|
1148
|
+
}
|
1149
|
+
if (args.length <= 2 && isObject(args[0]?.meta) && Array.isArray(args[1] ?? [])) {
|
1150
|
+
const result = args[1] ?? args[0].records ?? [];
|
1151
|
+
return new Array(...result);
|
1152
|
+
}
|
1153
|
+
return new Array(...args);
|
1154
|
+
}
|
1155
|
+
toArray() {
|
1156
|
+
return new Array(...this);
|
1157
|
+
}
|
1158
|
+
map(callbackfn, thisArg) {
|
1159
|
+
return this.toArray().map(callbackfn, thisArg);
|
1160
|
+
}
|
1161
|
+
async nextPage(size, offset) {
|
1162
|
+
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
1163
|
+
return new _RecordArray(newPage);
|
1164
|
+
}
|
1165
|
+
async previousPage(size, offset) {
|
1166
|
+
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
1167
|
+
return new _RecordArray(newPage);
|
1168
|
+
}
|
1169
|
+
async firstPage(size, offset) {
|
1170
|
+
const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
|
1171
|
+
return new _RecordArray(newPage);
|
1172
|
+
}
|
1173
|
+
async lastPage(size, offset) {
|
1174
|
+
const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
|
1175
|
+
return new _RecordArray(newPage);
|
1176
|
+
}
|
1177
|
+
hasNextPage() {
|
1178
|
+
return __privateGet$6(this, _page).meta.page.more;
|
1179
|
+
}
|
1180
|
+
};
|
1181
|
+
let RecordArray = _RecordArray;
|
1182
|
+
_page = new WeakMap();
|
957
1183
|
|
958
1184
|
var __accessCheck$5 = (obj, member, msg) => {
|
959
1185
|
if (!member.has(obj))
|
@@ -968,25 +1194,26 @@ var __privateAdd$5 = (obj, member, value) => {
|
|
968
1194
|
throw TypeError("Cannot add the same private member more than once");
|
969
1195
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
970
1196
|
};
|
971
|
-
var __privateSet$
|
1197
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
972
1198
|
__accessCheck$5(obj, member, "write to private field");
|
973
1199
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
974
1200
|
return value;
|
975
1201
|
};
|
976
1202
|
var _table$1, _repository, _data;
|
977
1203
|
const _Query = class {
|
978
|
-
constructor(repository, table, data,
|
1204
|
+
constructor(repository, table, data, rawParent) {
|
979
1205
|
__privateAdd$5(this, _table$1, void 0);
|
980
1206
|
__privateAdd$5(this, _repository, void 0);
|
981
1207
|
__privateAdd$5(this, _data, { filter: {} });
|
982
1208
|
this.meta = { page: { cursor: "start", more: true } };
|
983
|
-
this.records = [];
|
984
|
-
__privateSet$
|
1209
|
+
this.records = new RecordArray(this, []);
|
1210
|
+
__privateSet$5(this, _table$1, table);
|
985
1211
|
if (repository) {
|
986
|
-
__privateSet$
|
1212
|
+
__privateSet$5(this, _repository, repository);
|
987
1213
|
} else {
|
988
|
-
__privateSet$
|
1214
|
+
__privateSet$5(this, _repository, this);
|
989
1215
|
}
|
1216
|
+
const parent = cleanParent(data, rawParent);
|
990
1217
|
__privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
991
1218
|
__privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
|
992
1219
|
__privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
|
@@ -1039,13 +1266,18 @@ const _Query = class {
|
|
1039
1266
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1040
1267
|
}
|
1041
1268
|
}
|
1042
|
-
sort(column, direction) {
|
1269
|
+
sort(column, direction = "asc") {
|
1043
1270
|
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
1044
1271
|
const sort = [...originalSort, { column, direction }];
|
1045
1272
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
1046
1273
|
}
|
1047
1274
|
select(columns) {
|
1048
|
-
return new _Query(
|
1275
|
+
return new _Query(
|
1276
|
+
__privateGet$5(this, _repository),
|
1277
|
+
__privateGet$5(this, _table$1),
|
1278
|
+
{ columns },
|
1279
|
+
__privateGet$5(this, _data)
|
1280
|
+
);
|
1049
1281
|
}
|
1050
1282
|
getPaginated(options = {}) {
|
1051
1283
|
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
@@ -1058,18 +1290,21 @@ const _Query = class {
|
|
1058
1290
|
}
|
1059
1291
|
async *getIterator(options = {}) {
|
1060
1292
|
const { batchSize = 1 } = options;
|
1061
|
-
let
|
1062
|
-
let
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1293
|
+
let page = await this.getPaginated({ ...options, pagination: { size: batchSize, offset: 0 } });
|
1294
|
+
let more = page.hasNextPage();
|
1295
|
+
yield page.records;
|
1296
|
+
while (more) {
|
1297
|
+
page = await page.nextPage();
|
1298
|
+
more = page.hasNextPage();
|
1299
|
+
yield page.records;
|
1068
1300
|
}
|
1069
1301
|
}
|
1070
1302
|
async getMany(options = {}) {
|
1071
|
-
const
|
1072
|
-
|
1303
|
+
const page = await this.getPaginated(options);
|
1304
|
+
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
1305
|
+
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
1306
|
+
}
|
1307
|
+
return page.records;
|
1073
1308
|
}
|
1074
1309
|
async getAll(options = {}) {
|
1075
1310
|
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
@@ -1081,7 +1316,7 @@ const _Query = class {
|
|
1081
1316
|
}
|
1082
1317
|
async getFirst(options = {}) {
|
1083
1318
|
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1084
|
-
return records[0]
|
1319
|
+
return records[0] ?? null;
|
1085
1320
|
}
|
1086
1321
|
cache(ttl) {
|
1087
1322
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
@@ -1106,12 +1341,20 @@ let Query = _Query;
|
|
1106
1341
|
_table$1 = new WeakMap();
|
1107
1342
|
_repository = new WeakMap();
|
1108
1343
|
_data = new WeakMap();
|
1344
|
+
function cleanParent(data, parent) {
|
1345
|
+
if (isCursorPaginationOptions(data.pagination)) {
|
1346
|
+
return { ...parent, sorting: void 0, filter: void 0 };
|
1347
|
+
}
|
1348
|
+
return parent;
|
1349
|
+
}
|
1109
1350
|
|
1110
1351
|
function isIdentifiable(x) {
|
1111
1352
|
return isObject(x) && isString(x?.id);
|
1112
1353
|
}
|
1113
1354
|
function isXataRecord(x) {
|
1114
|
-
|
1355
|
+
const record = x;
|
1356
|
+
const metadata = record?.getMetadata();
|
1357
|
+
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
1115
1358
|
}
|
1116
1359
|
|
1117
1360
|
function isSortFilterString(value) {
|
@@ -1150,7 +1393,7 @@ var __privateAdd$4 = (obj, member, value) => {
|
|
1150
1393
|
throw TypeError("Cannot add the same private member more than once");
|
1151
1394
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1152
1395
|
};
|
1153
|
-
var __privateSet$
|
1396
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
1154
1397
|
__accessCheck$4(obj, member, "write to private field");
|
1155
1398
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1156
1399
|
return value;
|
@@ -1159,7 +1402,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
1159
1402
|
__accessCheck$4(obj, member, "access private method");
|
1160
1403
|
return method;
|
1161
1404
|
};
|
1162
|
-
var _table, _getFetchProps, _cache,
|
1405
|
+
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
|
1163
1406
|
class Repository extends Query {
|
1164
1407
|
}
|
1165
1408
|
class RestRepository extends Query {
|
@@ -1171,168 +1414,214 @@ class RestRepository extends Query {
|
|
1171
1414
|
__privateAdd$4(this, _updateRecordWithID);
|
1172
1415
|
__privateAdd$4(this, _upsertRecordWithID);
|
1173
1416
|
__privateAdd$4(this, _deleteRecord);
|
1174
|
-
__privateAdd$4(this, _invalidateCache);
|
1175
|
-
__privateAdd$4(this, _setCacheRecord);
|
1176
|
-
__privateAdd$4(this, _getCacheRecord);
|
1177
1417
|
__privateAdd$4(this, _setCacheQuery);
|
1178
1418
|
__privateAdd$4(this, _getCacheQuery);
|
1179
|
-
__privateAdd$4(this,
|
1419
|
+
__privateAdd$4(this, _getSchemaTables$1);
|
1180
1420
|
__privateAdd$4(this, _table, void 0);
|
1181
1421
|
__privateAdd$4(this, _getFetchProps, void 0);
|
1422
|
+
__privateAdd$4(this, _db, void 0);
|
1182
1423
|
__privateAdd$4(this, _cache, void 0);
|
1183
|
-
__privateAdd$4(this,
|
1184
|
-
|
1185
|
-
__privateSet$
|
1186
|
-
this
|
1187
|
-
__privateSet$
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
if (a === "")
|
1197
|
-
throw new Error("The id can't be empty");
|
1198
|
-
const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b);
|
1199
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1200
|
-
return record;
|
1201
|
-
}
|
1202
|
-
if (isObject(a) && isString(a.id)) {
|
1203
|
-
if (a.id === "")
|
1204
|
-
throw new Error("The id can't be empty");
|
1205
|
-
const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 });
|
1206
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1207
|
-
return record;
|
1208
|
-
}
|
1209
|
-
if (isObject(a)) {
|
1210
|
-
const record = await __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a);
|
1211
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1212
|
-
return record;
|
1213
|
-
}
|
1214
|
-
throw new Error("Invalid arguments for create method");
|
1215
|
-
}
|
1216
|
-
async read(recordId) {
|
1217
|
-
const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, recordId);
|
1218
|
-
if (cacheRecord)
|
1219
|
-
return cacheRecord;
|
1220
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1221
|
-
try {
|
1222
|
-
const response = await getRecord({
|
1223
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1224
|
-
...fetchProps
|
1424
|
+
__privateAdd$4(this, _schemaTables$2, void 0);
|
1425
|
+
__privateAdd$4(this, _trace, void 0);
|
1426
|
+
__privateSet$4(this, _table, options.table);
|
1427
|
+
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1428
|
+
__privateSet$4(this, _db, options.db);
|
1429
|
+
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
1430
|
+
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
1431
|
+
const trace = options.pluginOptions.trace ?? defaultTrace;
|
1432
|
+
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
1433
|
+
return trace(name, fn, {
|
1434
|
+
...options2,
|
1435
|
+
[TraceAttributes.TABLE]: __privateGet$4(this, _table),
|
1436
|
+
[TraceAttributes.VERSION]: VERSION
|
1225
1437
|
});
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1438
|
+
});
|
1439
|
+
}
|
1440
|
+
async create(a, b, c) {
|
1441
|
+
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
1442
|
+
if (Array.isArray(a)) {
|
1443
|
+
if (a.length === 0)
|
1444
|
+
return [];
|
1445
|
+
const columns = isStringArray(b) ? b : void 0;
|
1446
|
+
return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
|
1231
1447
|
}
|
1232
|
-
|
1233
|
-
|
1448
|
+
if (isString(a) && isObject(b)) {
|
1449
|
+
if (a === "")
|
1450
|
+
throw new Error("The id can't be empty");
|
1451
|
+
const columns = isStringArray(c) ? c : void 0;
|
1452
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
1453
|
+
}
|
1454
|
+
if (isObject(a) && isString(a.id)) {
|
1455
|
+
if (a.id === "")
|
1456
|
+
throw new Error("The id can't be empty");
|
1457
|
+
const columns = isStringArray(b) ? b : void 0;
|
1458
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1459
|
+
}
|
1460
|
+
if (isObject(a)) {
|
1461
|
+
const columns = isStringArray(b) ? b : void 0;
|
1462
|
+
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
1463
|
+
}
|
1464
|
+
throw new Error("Invalid arguments for create method");
|
1465
|
+
});
|
1234
1466
|
}
|
1235
|
-
async
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1467
|
+
async read(a, b) {
|
1468
|
+
return __privateGet$4(this, _trace).call(this, "read", async () => {
|
1469
|
+
const columns = isStringArray(b) ? b : ["*"];
|
1470
|
+
if (Array.isArray(a)) {
|
1471
|
+
if (a.length === 0)
|
1472
|
+
return [];
|
1473
|
+
const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
|
1474
|
+
const finalObjects = await this.getAll({ filter: { id: { $any: ids } }, columns });
|
1475
|
+
const dictionary = finalObjects.reduce((acc, object) => {
|
1476
|
+
acc[object.id] = object;
|
1477
|
+
return acc;
|
1478
|
+
}, {});
|
1479
|
+
return ids.map((id2) => dictionary[id2] ?? null);
|
1239
1480
|
}
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1481
|
+
const id = isString(a) ? a : a.id;
|
1482
|
+
if (isString(id)) {
|
1483
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1484
|
+
try {
|
1485
|
+
const response = await getRecord({
|
1486
|
+
pathParams: {
|
1487
|
+
workspace: "{workspaceId}",
|
1488
|
+
dbBranchName: "{dbBranch}",
|
1489
|
+
tableName: __privateGet$4(this, _table),
|
1490
|
+
recordId: id
|
1491
|
+
},
|
1492
|
+
queryParams: { columns },
|
1493
|
+
...fetchProps
|
1494
|
+
});
|
1495
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1496
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1497
|
+
} catch (e) {
|
1498
|
+
if (isObject(e) && e.status === 404) {
|
1499
|
+
return null;
|
1500
|
+
}
|
1501
|
+
throw e;
|
1502
|
+
}
|
1503
|
+
}
|
1504
|
+
return null;
|
1505
|
+
});
|
1255
1506
|
}
|
1256
|
-
async
|
1257
|
-
|
1258
|
-
if (a
|
1259
|
-
|
1507
|
+
async update(a, b, c) {
|
1508
|
+
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
1509
|
+
if (Array.isArray(a)) {
|
1510
|
+
if (a.length === 0)
|
1511
|
+
return [];
|
1512
|
+
if (a.length > 100) {
|
1513
|
+
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1514
|
+
}
|
1515
|
+
const columns = isStringArray(b) ? b : ["*"];
|
1516
|
+
return Promise.all(a.map((object) => this.update(object, columns)));
|
1260
1517
|
}
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1518
|
+
if (isString(a) && isObject(b)) {
|
1519
|
+
const columns = isStringArray(c) ? c : void 0;
|
1520
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
|
1521
|
+
}
|
1522
|
+
if (isObject(a) && isString(a.id)) {
|
1523
|
+
const columns = isStringArray(b) ? b : void 0;
|
1524
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1525
|
+
}
|
1526
|
+
throw new Error("Invalid arguments for update method");
|
1527
|
+
});
|
1528
|
+
}
|
1529
|
+
async createOrUpdate(a, b, c) {
|
1530
|
+
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
1531
|
+
if (Array.isArray(a)) {
|
1532
|
+
if (a.length === 0)
|
1533
|
+
return [];
|
1534
|
+
if (a.length > 100) {
|
1535
|
+
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1536
|
+
}
|
1537
|
+
const columns = isStringArray(b) ? b : ["*"];
|
1538
|
+
return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
|
1539
|
+
}
|
1540
|
+
if (isString(a) && isObject(b)) {
|
1541
|
+
const columns = isStringArray(c) ? c : void 0;
|
1542
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
|
1543
|
+
}
|
1544
|
+
if (isObject(a) && isString(a.id)) {
|
1545
|
+
const columns = isStringArray(c) ? c : void 0;
|
1546
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1547
|
+
}
|
1548
|
+
throw new Error("Invalid arguments for createOrUpdate method");
|
1549
|
+
});
|
1276
1550
|
}
|
1277
1551
|
async delete(a) {
|
1278
|
-
|
1279
|
-
if (a
|
1280
|
-
|
1552
|
+
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
1553
|
+
if (Array.isArray(a)) {
|
1554
|
+
if (a.length === 0)
|
1555
|
+
return;
|
1556
|
+
if (a.length > 100) {
|
1557
|
+
console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
|
1558
|
+
}
|
1559
|
+
await Promise.all(a.map((id) => this.delete(id)));
|
1560
|
+
return;
|
1281
1561
|
}
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
|
1293
|
-
return;
|
1294
|
-
}
|
1295
|
-
throw new Error("Invalid arguments for delete method");
|
1562
|
+
if (isString(a)) {
|
1563
|
+
await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
|
1564
|
+
return;
|
1565
|
+
}
|
1566
|
+
if (isObject(a) && isString(a.id)) {
|
1567
|
+
await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
|
1568
|
+
return;
|
1569
|
+
}
|
1570
|
+
throw new Error("Invalid arguments for delete method");
|
1571
|
+
});
|
1296
1572
|
}
|
1297
1573
|
async search(query, options = {}) {
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1574
|
+
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
1575
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1576
|
+
const { records } = await searchTable({
|
1577
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1578
|
+
body: {
|
1579
|
+
query,
|
1580
|
+
fuzziness: options.fuzziness,
|
1581
|
+
prefix: options.prefix,
|
1582
|
+
highlight: options.highlight,
|
1583
|
+
filter: options.filter,
|
1584
|
+
boosters: options.boosters
|
1585
|
+
},
|
1586
|
+
...fetchProps
|
1587
|
+
});
|
1588
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1589
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
1303
1590
|
});
|
1304
|
-
const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
|
1305
|
-
return records.map((item) => initObject(this.db, schema, __privateGet$4(this, _table), item));
|
1306
1591
|
}
|
1307
1592
|
async query(query) {
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1593
|
+
return __privateGet$4(this, _trace).call(this, "query", async () => {
|
1594
|
+
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
1595
|
+
if (cacheQuery)
|
1596
|
+
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
1597
|
+
const data = query.getQueryOptions();
|
1598
|
+
const body = {
|
1599
|
+
filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
|
1600
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1601
|
+
page: data.pagination,
|
1602
|
+
columns: data.columns
|
1603
|
+
};
|
1604
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1605
|
+
const { meta, records: objects } = await queryTable({
|
1606
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1607
|
+
body,
|
1608
|
+
...fetchProps
|
1609
|
+
});
|
1610
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1611
|
+
const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
|
1612
|
+
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1613
|
+
return new Page(query, meta, records);
|
1323
1614
|
});
|
1324
|
-
const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
|
1325
|
-
const records = objects.map((record) => initObject(this.db, schema, __privateGet$4(this, _table), record));
|
1326
|
-
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1327
|
-
return new Page(query, meta, records);
|
1328
1615
|
}
|
1329
1616
|
}
|
1330
1617
|
_table = new WeakMap();
|
1331
1618
|
_getFetchProps = new WeakMap();
|
1619
|
+
_db = new WeakMap();
|
1332
1620
|
_cache = new WeakMap();
|
1333
|
-
|
1621
|
+
_schemaTables$2 = new WeakMap();
|
1622
|
+
_trace = new WeakMap();
|
1334
1623
|
_insertRecordWithoutId = new WeakSet();
|
1335
|
-
insertRecordWithoutId_fn = async function(object) {
|
1624
|
+
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
1336
1625
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1337
1626
|
const record = transformObjectLinks(object);
|
1338
1627
|
const response = await insertRecord({
|
@@ -1341,17 +1630,15 @@ insertRecordWithoutId_fn = async function(object) {
|
|
1341
1630
|
dbBranchName: "{dbBranch}",
|
1342
1631
|
tableName: __privateGet$4(this, _table)
|
1343
1632
|
},
|
1633
|
+
queryParams: { columns },
|
1344
1634
|
body: record,
|
1345
1635
|
...fetchProps
|
1346
1636
|
});
|
1347
|
-
const
|
1348
|
-
|
1349
|
-
throw new Error("The server failed to save the record");
|
1350
|
-
}
|
1351
|
-
return finalObject;
|
1637
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1638
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1352
1639
|
};
|
1353
1640
|
_insertRecordWithId = new WeakSet();
|
1354
|
-
insertRecordWithId_fn = async function(recordId, object) {
|
1641
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
1355
1642
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1356
1643
|
const record = transformObjectLinks(object);
|
1357
1644
|
const response = await insertRecordWithID({
|
@@ -1362,56 +1649,52 @@ insertRecordWithId_fn = async function(recordId, object) {
|
|
1362
1649
|
recordId
|
1363
1650
|
},
|
1364
1651
|
body: record,
|
1365
|
-
queryParams: { createOnly: true },
|
1652
|
+
queryParams: { createOnly: true, columns },
|
1366
1653
|
...fetchProps
|
1367
1654
|
});
|
1368
|
-
const
|
1369
|
-
|
1370
|
-
throw new Error("The server failed to save the record");
|
1371
|
-
}
|
1372
|
-
return finalObject;
|
1655
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1656
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1373
1657
|
};
|
1374
1658
|
_bulkInsertTableRecords = new WeakSet();
|
1375
|
-
bulkInsertTableRecords_fn = async function(objects) {
|
1659
|
+
bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
1376
1660
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1377
1661
|
const records = objects.map((object) => transformObjectLinks(object));
|
1378
1662
|
const response = await bulkInsertTableRecords({
|
1379
1663
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1664
|
+
queryParams: { columns },
|
1380
1665
|
body: { records },
|
1381
1666
|
...fetchProps
|
1382
1667
|
});
|
1383
|
-
|
1384
|
-
|
1385
|
-
throw new Error("The server failed to save some records");
|
1668
|
+
if (!isResponseWithRecords(response)) {
|
1669
|
+
throw new Error("Request included columns but server didn't include them");
|
1386
1670
|
}
|
1387
|
-
|
1671
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1672
|
+
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
1388
1673
|
};
|
1389
1674
|
_updateRecordWithID = new WeakSet();
|
1390
|
-
updateRecordWithID_fn = async function(recordId, object) {
|
1675
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
1391
1676
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1392
1677
|
const record = transformObjectLinks(object);
|
1393
1678
|
const response = await updateRecordWithID({
|
1394
1679
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1680
|
+
queryParams: { columns },
|
1395
1681
|
body: record,
|
1396
1682
|
...fetchProps
|
1397
1683
|
});
|
1398
|
-
const
|
1399
|
-
|
1400
|
-
throw new Error("The server failed to save the record");
|
1401
|
-
return item;
|
1684
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1685
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1402
1686
|
};
|
1403
1687
|
_upsertRecordWithID = new WeakSet();
|
1404
|
-
upsertRecordWithID_fn = async function(recordId, object) {
|
1688
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
1405
1689
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1406
1690
|
const response = await upsertRecordWithID({
|
1407
1691
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1692
|
+
queryParams: { columns },
|
1408
1693
|
body: object,
|
1409
1694
|
...fetchProps
|
1410
1695
|
});
|
1411
|
-
const
|
1412
|
-
|
1413
|
-
throw new Error("The server failed to save the record");
|
1414
|
-
return item;
|
1696
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1697
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1415
1698
|
};
|
1416
1699
|
_deleteRecord = new WeakSet();
|
1417
1700
|
deleteRecord_fn = async function(recordId) {
|
@@ -1421,29 +1704,6 @@ deleteRecord_fn = async function(recordId) {
|
|
1421
1704
|
...fetchProps
|
1422
1705
|
});
|
1423
1706
|
};
|
1424
|
-
_invalidateCache = new WeakSet();
|
1425
|
-
invalidateCache_fn = async function(recordId) {
|
1426
|
-
await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
1427
|
-
const cacheItems = await __privateGet$4(this, _cache).getAll();
|
1428
|
-
const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
|
1429
|
-
for (const [key, value] of queries) {
|
1430
|
-
const ids = getIds(value);
|
1431
|
-
if (ids.includes(recordId))
|
1432
|
-
await __privateGet$4(this, _cache).delete(key);
|
1433
|
-
}
|
1434
|
-
};
|
1435
|
-
_setCacheRecord = new WeakSet();
|
1436
|
-
setCacheRecord_fn = async function(record) {
|
1437
|
-
if (!__privateGet$4(this, _cache).cacheRecords)
|
1438
|
-
return;
|
1439
|
-
await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
|
1440
|
-
};
|
1441
|
-
_getCacheRecord = new WeakSet();
|
1442
|
-
getCacheRecord_fn = async function(recordId) {
|
1443
|
-
if (!__privateGet$4(this, _cache).cacheRecords)
|
1444
|
-
return null;
|
1445
|
-
return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
1446
|
-
};
|
1447
1707
|
_setCacheQuery = new WeakSet();
|
1448
1708
|
setCacheQuery_fn = async function(query, meta, records) {
|
1449
1709
|
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
@@ -1460,17 +1720,17 @@ getCacheQuery_fn = async function(query) {
|
|
1460
1720
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
1461
1721
|
return hasExpired ? null : result;
|
1462
1722
|
};
|
1463
|
-
|
1464
|
-
|
1465
|
-
if (__privateGet$4(this,
|
1466
|
-
return __privateGet$4(this,
|
1723
|
+
_getSchemaTables$1 = new WeakSet();
|
1724
|
+
getSchemaTables_fn$1 = async function() {
|
1725
|
+
if (__privateGet$4(this, _schemaTables$2))
|
1726
|
+
return __privateGet$4(this, _schemaTables$2);
|
1467
1727
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1468
1728
|
const { schema } = await getBranchDetails({
|
1469
1729
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1470
1730
|
...fetchProps
|
1471
1731
|
});
|
1472
|
-
__privateSet$
|
1473
|
-
return schema;
|
1732
|
+
__privateSet$4(this, _schemaTables$2, schema.tables);
|
1733
|
+
return schema.tables;
|
1474
1734
|
};
|
1475
1735
|
const transformObjectLinks = (object) => {
|
1476
1736
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
@@ -1479,20 +1739,21 @@ const transformObjectLinks = (object) => {
|
|
1479
1739
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1480
1740
|
}, {});
|
1481
1741
|
};
|
1482
|
-
const initObject = (db,
|
1742
|
+
const initObject = (db, schemaTables, table, object) => {
|
1483
1743
|
const result = {};
|
1484
|
-
|
1485
|
-
|
1744
|
+
const { xata, ...rest } = object ?? {};
|
1745
|
+
Object.assign(result, rest);
|
1746
|
+
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
1486
1747
|
if (!columns)
|
1487
1748
|
console.error(`Table ${table} not found in schema`);
|
1488
1749
|
for (const column of columns ?? []) {
|
1489
1750
|
const value = result[column.name];
|
1490
1751
|
switch (column.type) {
|
1491
1752
|
case "datetime": {
|
1492
|
-
const date = new Date(value);
|
1493
|
-
if (isNaN(date.getTime())) {
|
1753
|
+
const date = value !== void 0 ? new Date(value) : void 0;
|
1754
|
+
if (date && isNaN(date.getTime())) {
|
1494
1755
|
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
1495
|
-
} else {
|
1756
|
+
} else if (date) {
|
1496
1757
|
result[column.name] = date;
|
1497
1758
|
}
|
1498
1759
|
break;
|
@@ -1501,36 +1762,33 @@ const initObject = (db, schema, table, object) => {
|
|
1501
1762
|
const linkTable = column.link?.table;
|
1502
1763
|
if (!linkTable) {
|
1503
1764
|
console.error(`Failed to parse link for field ${column.name}`);
|
1504
|
-
} else if (
|
1505
|
-
result[column.name] = initObject(db,
|
1765
|
+
} else if (isObject(value)) {
|
1766
|
+
result[column.name] = initObject(db, schemaTables, linkTable, value);
|
1506
1767
|
}
|
1507
1768
|
break;
|
1508
1769
|
}
|
1509
1770
|
}
|
1510
1771
|
}
|
1511
|
-
result.read = function() {
|
1512
|
-
return db[table].read(result["id"]);
|
1772
|
+
result.read = function(columns2) {
|
1773
|
+
return db[table].read(result["id"], columns2);
|
1513
1774
|
};
|
1514
|
-
result.update = function(data) {
|
1515
|
-
return db[table].update(result["id"], data);
|
1775
|
+
result.update = function(data, columns2) {
|
1776
|
+
return db[table].update(result["id"], data, columns2);
|
1516
1777
|
};
|
1517
1778
|
result.delete = function() {
|
1518
1779
|
return db[table].delete(result["id"]);
|
1519
1780
|
};
|
1520
|
-
|
1781
|
+
result.getMetadata = function() {
|
1782
|
+
return xata;
|
1783
|
+
};
|
1784
|
+
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
1521
1785
|
Object.defineProperty(result, prop, { enumerable: false });
|
1522
1786
|
}
|
1523
1787
|
Object.freeze(result);
|
1524
1788
|
return result;
|
1525
1789
|
};
|
1526
|
-
function
|
1527
|
-
|
1528
|
-
return value.map((item) => getIds(item)).flat();
|
1529
|
-
}
|
1530
|
-
if (!isObject(value))
|
1531
|
-
return [];
|
1532
|
-
const nestedIds = Object.values(value).map((item) => getIds(item)).flat();
|
1533
|
-
return isString(value.id) ? [value.id, ...nestedIds] : nestedIds;
|
1790
|
+
function isResponseWithRecords(value) {
|
1791
|
+
return isObject(value) && Array.isArray(value.records);
|
1534
1792
|
}
|
1535
1793
|
|
1536
1794
|
var __accessCheck$3 = (obj, member, msg) => {
|
@@ -1546,7 +1804,7 @@ var __privateAdd$3 = (obj, member, value) => {
|
|
1546
1804
|
throw TypeError("Cannot add the same private member more than once");
|
1547
1805
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1548
1806
|
};
|
1549
|
-
var __privateSet$
|
1807
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
1550
1808
|
__accessCheck$3(obj, member, "write to private field");
|
1551
1809
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1552
1810
|
return value;
|
@@ -1555,9 +1813,8 @@ var _map;
|
|
1555
1813
|
class SimpleCache {
|
1556
1814
|
constructor(options = {}) {
|
1557
1815
|
__privateAdd$3(this, _map, void 0);
|
1558
|
-
__privateSet$
|
1816
|
+
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
1559
1817
|
this.capacity = options.max ?? 500;
|
1560
|
-
this.cacheRecords = options.cacheRecords ?? true;
|
1561
1818
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
1562
1819
|
}
|
1563
1820
|
async getAll() {
|
@@ -1615,31 +1872,42 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
1615
1872
|
throw TypeError("Cannot add the same private member more than once");
|
1616
1873
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1617
1874
|
};
|
1618
|
-
var
|
1875
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
1876
|
+
__accessCheck$2(obj, member, "write to private field");
|
1877
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
1878
|
+
return value;
|
1879
|
+
};
|
1880
|
+
var _tables, _schemaTables$1;
|
1619
1881
|
class SchemaPlugin extends XataPlugin {
|
1620
|
-
constructor(
|
1882
|
+
constructor(schemaTables) {
|
1621
1883
|
super();
|
1622
|
-
this.tableNames = tableNames;
|
1623
1884
|
__privateAdd$2(this, _tables, {});
|
1885
|
+
__privateAdd$2(this, _schemaTables$1, void 0);
|
1886
|
+
__privateSet$2(this, _schemaTables$1, schemaTables);
|
1624
1887
|
}
|
1625
1888
|
build(pluginOptions) {
|
1626
|
-
const db = new Proxy(
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1889
|
+
const db = new Proxy(
|
1890
|
+
{},
|
1891
|
+
{
|
1892
|
+
get: (_target, table) => {
|
1893
|
+
if (!isString(table))
|
1894
|
+
throw new Error("Invalid table name");
|
1895
|
+
if (__privateGet$2(this, _tables)[table] === void 0) {
|
1896
|
+
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
1897
|
+
}
|
1898
|
+
return __privateGet$2(this, _tables)[table];
|
1632
1899
|
}
|
1633
|
-
return __privateGet$2(this, _tables)[table];
|
1634
1900
|
}
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1901
|
+
);
|
1902
|
+
const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
|
1903
|
+
for (const table of tableNames) {
|
1904
|
+
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
1638
1905
|
}
|
1639
1906
|
return db;
|
1640
1907
|
}
|
1641
1908
|
}
|
1642
1909
|
_tables = new WeakMap();
|
1910
|
+
_schemaTables$1 = new WeakMap();
|
1643
1911
|
|
1644
1912
|
var __accessCheck$1 = (obj, member, msg) => {
|
1645
1913
|
if (!member.has(obj))
|
@@ -1663,105 +1931,119 @@ var __privateMethod$1 = (obj, member, method) => {
|
|
1663
1931
|
__accessCheck$1(obj, member, "access private method");
|
1664
1932
|
return method;
|
1665
1933
|
};
|
1666
|
-
var
|
1934
|
+
var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
|
1667
1935
|
class SearchPlugin extends XataPlugin {
|
1668
|
-
constructor(db) {
|
1936
|
+
constructor(db, schemaTables) {
|
1669
1937
|
super();
|
1670
1938
|
this.db = db;
|
1671
1939
|
__privateAdd$1(this, _search);
|
1672
|
-
__privateAdd$1(this,
|
1673
|
-
__privateAdd$1(this,
|
1940
|
+
__privateAdd$1(this, _getSchemaTables);
|
1941
|
+
__privateAdd$1(this, _schemaTables, void 0);
|
1942
|
+
__privateSet$1(this, _schemaTables, schemaTables);
|
1674
1943
|
}
|
1675
1944
|
build({ getFetchProps }) {
|
1676
1945
|
return {
|
1677
1946
|
all: async (query, options = {}) => {
|
1678
1947
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1679
|
-
const
|
1948
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1680
1949
|
return records.map((record) => {
|
1681
1950
|
const { table = "orphan" } = record.xata;
|
1682
|
-
return { table, record: initObject(this.db,
|
1951
|
+
return { table, record: initObject(this.db, schemaTables, table, record) };
|
1683
1952
|
});
|
1684
1953
|
},
|
1685
1954
|
byTable: async (query, options = {}) => {
|
1686
1955
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1687
|
-
const
|
1956
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1688
1957
|
return records.reduce((acc, record) => {
|
1689
1958
|
const { table = "orphan" } = record.xata;
|
1690
1959
|
const items = acc[table] ?? [];
|
1691
|
-
const item = initObject(this.db,
|
1960
|
+
const item = initObject(this.db, schemaTables, table, record);
|
1692
1961
|
return { ...acc, [table]: [...items, item] };
|
1693
1962
|
}, {});
|
1694
1963
|
}
|
1695
1964
|
};
|
1696
1965
|
}
|
1697
1966
|
}
|
1698
|
-
|
1967
|
+
_schemaTables = new WeakMap();
|
1699
1968
|
_search = new WeakSet();
|
1700
1969
|
search_fn = async function(query, options, getFetchProps) {
|
1701
1970
|
const fetchProps = await getFetchProps();
|
1702
|
-
const { tables, fuzziness } = options ?? {};
|
1971
|
+
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
1703
1972
|
const { records } = await searchBranch({
|
1704
1973
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1705
|
-
body: { tables, query, fuzziness },
|
1974
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
1706
1975
|
...fetchProps
|
1707
1976
|
});
|
1708
1977
|
return records;
|
1709
1978
|
};
|
1710
|
-
|
1711
|
-
|
1712
|
-
if (__privateGet$1(this,
|
1713
|
-
return __privateGet$1(this,
|
1979
|
+
_getSchemaTables = new WeakSet();
|
1980
|
+
getSchemaTables_fn = async function(getFetchProps) {
|
1981
|
+
if (__privateGet$1(this, _schemaTables))
|
1982
|
+
return __privateGet$1(this, _schemaTables);
|
1714
1983
|
const fetchProps = await getFetchProps();
|
1715
1984
|
const { schema } = await getBranchDetails({
|
1716
1985
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1717
1986
|
...fetchProps
|
1718
1987
|
});
|
1719
|
-
__privateSet$1(this,
|
1720
|
-
return schema;
|
1988
|
+
__privateSet$1(this, _schemaTables, schema.tables);
|
1989
|
+
return schema.tables;
|
1721
1990
|
};
|
1722
1991
|
|
1723
1992
|
const isBranchStrategyBuilder = (strategy) => {
|
1724
1993
|
return typeof strategy === "function";
|
1725
1994
|
};
|
1726
1995
|
|
1727
|
-
const envBranchNames = [
|
1728
|
-
"XATA_BRANCH",
|
1729
|
-
"VERCEL_GIT_COMMIT_REF",
|
1730
|
-
"CF_PAGES_BRANCH",
|
1731
|
-
"BRANCH"
|
1732
|
-
];
|
1733
|
-
const defaultBranch = "main";
|
1734
1996
|
async function getCurrentBranchName(options) {
|
1735
|
-
const
|
1736
|
-
if (
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
return void 0;
|
1997
|
+
const { branch, envBranch } = getEnvironment();
|
1998
|
+
if (branch) {
|
1999
|
+
const details = await getDatabaseBranch(branch, options);
|
2000
|
+
if (details)
|
2001
|
+
return branch;
|
2002
|
+
console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
|
2003
|
+
}
|
2004
|
+
const gitBranch = envBranch || await getGitBranch();
|
2005
|
+
return resolveXataBranch(gitBranch, options);
|
1745
2006
|
}
|
1746
2007
|
async function getCurrentBranchDetails(options) {
|
1747
|
-
const
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
2008
|
+
const branch = await getCurrentBranchName(options);
|
2009
|
+
return getDatabaseBranch(branch, options);
|
2010
|
+
}
|
2011
|
+
async function resolveXataBranch(gitBranch, options) {
|
2012
|
+
const databaseURL = options?.databaseURL || getDatabaseURL();
|
2013
|
+
const apiKey = options?.apiKey || getAPIKey();
|
2014
|
+
if (!databaseURL)
|
2015
|
+
throw new Error(
|
2016
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
2017
|
+
);
|
2018
|
+
if (!apiKey)
|
2019
|
+
throw new Error(
|
2020
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2021
|
+
);
|
2022
|
+
const [protocol, , host, , dbName] = databaseURL.split("/");
|
2023
|
+
const [workspace] = host.split(".");
|
2024
|
+
const { fallbackBranch } = getEnvironment();
|
2025
|
+
const { branch } = await resolveBranch({
|
2026
|
+
apiKey,
|
2027
|
+
apiUrl: databaseURL,
|
2028
|
+
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2029
|
+
workspacesApiUrl: `${protocol}//${host}`,
|
2030
|
+
pathParams: { dbName, workspace },
|
2031
|
+
queryParams: { gitBranch, fallbackBranch },
|
2032
|
+
trace: defaultTrace
|
2033
|
+
});
|
2034
|
+
return branch;
|
1757
2035
|
}
|
1758
2036
|
async function getDatabaseBranch(branch, options) {
|
1759
2037
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1760
2038
|
const apiKey = options?.apiKey || getAPIKey();
|
1761
2039
|
if (!databaseURL)
|
1762
|
-
throw new Error(
|
2040
|
+
throw new Error(
|
2041
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
2042
|
+
);
|
1763
2043
|
if (!apiKey)
|
1764
|
-
throw new Error(
|
2044
|
+
throw new Error(
|
2045
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2046
|
+
);
|
1765
2047
|
const [protocol, , host, , database] = databaseURL.split("/");
|
1766
2048
|
const [workspace] = host.split(".");
|
1767
2049
|
const dbBranchName = `${database}:${branch}`;
|
@@ -1771,10 +2053,8 @@ async function getDatabaseBranch(branch, options) {
|
|
1771
2053
|
apiUrl: databaseURL,
|
1772
2054
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1773
2055
|
workspacesApiUrl: `${protocol}//${host}`,
|
1774
|
-
pathParams: {
|
1775
|
-
|
1776
|
-
workspace
|
1777
|
-
}
|
2056
|
+
pathParams: { dbBranchName, workspace },
|
2057
|
+
trace: defaultTrace
|
1778
2058
|
});
|
1779
2059
|
} catch (err) {
|
1780
2060
|
if (isObject(err) && err.status === 404)
|
@@ -1782,21 +2062,10 @@ async function getDatabaseBranch(branch, options) {
|
|
1782
2062
|
throw err;
|
1783
2063
|
}
|
1784
2064
|
}
|
1785
|
-
function getBranchByEnvVariable() {
|
1786
|
-
for (const name of envBranchNames) {
|
1787
|
-
const value = getEnvVariable(name);
|
1788
|
-
if (value) {
|
1789
|
-
return value;
|
1790
|
-
}
|
1791
|
-
}
|
1792
|
-
try {
|
1793
|
-
return XATA_BRANCH;
|
1794
|
-
} catch (err) {
|
1795
|
-
}
|
1796
|
-
}
|
1797
2065
|
function getDatabaseURL() {
|
1798
2066
|
try {
|
1799
|
-
|
2067
|
+
const { databaseURL } = getEnvironment();
|
2068
|
+
return databaseURL;
|
1800
2069
|
} catch (err) {
|
1801
2070
|
return void 0;
|
1802
2071
|
}
|
@@ -1825,24 +2094,27 @@ var __privateMethod = (obj, member, method) => {
|
|
1825
2094
|
return method;
|
1826
2095
|
};
|
1827
2096
|
const buildClient = (plugins) => {
|
1828
|
-
var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
2097
|
+
var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
1829
2098
|
return _a = class {
|
1830
|
-
constructor(options = {},
|
2099
|
+
constructor(options = {}, schemaTables) {
|
1831
2100
|
__privateAdd(this, _parseOptions);
|
1832
2101
|
__privateAdd(this, _getFetchProps);
|
1833
2102
|
__privateAdd(this, _evaluateBranch);
|
1834
2103
|
__privateAdd(this, _branch, void 0);
|
2104
|
+
__privateAdd(this, _options, void 0);
|
1835
2105
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
2106
|
+
__privateSet(this, _options, safeOptions);
|
1836
2107
|
const pluginOptions = {
|
1837
2108
|
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
1838
|
-
cache: safeOptions.cache
|
2109
|
+
cache: safeOptions.cache,
|
2110
|
+
trace: safeOptions.trace
|
1839
2111
|
};
|
1840
|
-
const db = new SchemaPlugin(
|
1841
|
-
const search = new SearchPlugin(db).build(pluginOptions);
|
2112
|
+
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
2113
|
+
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
1842
2114
|
this.db = db;
|
1843
2115
|
this.search = search;
|
1844
2116
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
1845
|
-
if (
|
2117
|
+
if (namespace === void 0)
|
1846
2118
|
continue;
|
1847
2119
|
const result = namespace.build(pluginOptions);
|
1848
2120
|
if (result instanceof Promise) {
|
@@ -1854,22 +2126,23 @@ const buildClient = (plugins) => {
|
|
1854
2126
|
}
|
1855
2127
|
}
|
1856
2128
|
}
|
1857
|
-
|
2129
|
+
async getConfig() {
|
2130
|
+
const databaseURL = __privateGet(this, _options).databaseURL;
|
2131
|
+
const branch = await __privateGet(this, _options).branch();
|
2132
|
+
return { databaseURL, branch };
|
2133
|
+
}
|
2134
|
+
}, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
1858
2135
|
const fetch = getFetchImplementation(options?.fetch);
|
1859
2136
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1860
2137
|
const apiKey = options?.apiKey || getAPIKey();
|
1861
|
-
const cache = options?.cache ?? new SimpleCache({
|
1862
|
-
const
|
2138
|
+
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
2139
|
+
const trace = options?.trace ?? defaultTrace;
|
2140
|
+
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
1863
2141
|
if (!databaseURL || !apiKey) {
|
1864
2142
|
throw new Error("Options databaseURL and apiKey are required");
|
1865
2143
|
}
|
1866
|
-
return { fetch, databaseURL, apiKey, branch, cache };
|
1867
|
-
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
|
1868
|
-
fetch,
|
1869
|
-
apiKey,
|
1870
|
-
databaseURL,
|
1871
|
-
branch
|
1872
|
-
}) {
|
2144
|
+
return { fetch, databaseURL, apiKey, branch, cache, trace };
|
2145
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
|
1873
2146
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
1874
2147
|
if (!branchValue)
|
1875
2148
|
throw new Error("Unable to resolve branch value");
|
@@ -1881,12 +2154,13 @@ const buildClient = (plugins) => {
|
|
1881
2154
|
const hasBranch = params.dbBranchName ?? params.branch;
|
1882
2155
|
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
|
1883
2156
|
return databaseURL + newPath;
|
1884
|
-
}
|
2157
|
+
},
|
2158
|
+
trace
|
1885
2159
|
};
|
1886
2160
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
1887
2161
|
if (__privateGet(this, _branch))
|
1888
2162
|
return __privateGet(this, _branch);
|
1889
|
-
if (
|
2163
|
+
if (param === void 0)
|
1890
2164
|
return void 0;
|
1891
2165
|
const strategies = Array.isArray(param) ? [...param] : [param];
|
1892
2166
|
const evaluateBranch = async (strategy) => {
|
@@ -1904,6 +2178,88 @@ const buildClient = (plugins) => {
|
|
1904
2178
|
class BaseClient extends buildClient() {
|
1905
2179
|
}
|
1906
2180
|
|
2181
|
+
const META = "__";
|
2182
|
+
const VALUE = "___";
|
2183
|
+
class Serializer {
|
2184
|
+
constructor() {
|
2185
|
+
this.classes = {};
|
2186
|
+
}
|
2187
|
+
add(clazz) {
|
2188
|
+
this.classes[clazz.name] = clazz;
|
2189
|
+
}
|
2190
|
+
toJSON(data) {
|
2191
|
+
function visit(obj) {
|
2192
|
+
if (Array.isArray(obj))
|
2193
|
+
return obj.map(visit);
|
2194
|
+
const type = typeof obj;
|
2195
|
+
if (type === "undefined")
|
2196
|
+
return { [META]: "undefined" };
|
2197
|
+
if (type === "bigint")
|
2198
|
+
return { [META]: "bigint", [VALUE]: obj.toString() };
|
2199
|
+
if (obj === null || type !== "object")
|
2200
|
+
return obj;
|
2201
|
+
const constructor = obj.constructor;
|
2202
|
+
const o = { [META]: constructor.name };
|
2203
|
+
for (const [key, value] of Object.entries(obj)) {
|
2204
|
+
o[key] = visit(value);
|
2205
|
+
}
|
2206
|
+
if (constructor === Date)
|
2207
|
+
o[VALUE] = obj.toISOString();
|
2208
|
+
if (constructor === Map)
|
2209
|
+
o[VALUE] = Object.fromEntries(obj);
|
2210
|
+
if (constructor === Set)
|
2211
|
+
o[VALUE] = [...obj];
|
2212
|
+
return o;
|
2213
|
+
}
|
2214
|
+
return JSON.stringify(visit(data));
|
2215
|
+
}
|
2216
|
+
fromJSON(json) {
|
2217
|
+
return JSON.parse(json, (key, value) => {
|
2218
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
2219
|
+
const { [META]: clazz, [VALUE]: val, ...rest } = value;
|
2220
|
+
const constructor = this.classes[clazz];
|
2221
|
+
if (constructor) {
|
2222
|
+
return Object.assign(Object.create(constructor.prototype), rest);
|
2223
|
+
}
|
2224
|
+
if (clazz === "Date")
|
2225
|
+
return new Date(val);
|
2226
|
+
if (clazz === "Set")
|
2227
|
+
return new Set(val);
|
2228
|
+
if (clazz === "Map")
|
2229
|
+
return new Map(Object.entries(val));
|
2230
|
+
if (clazz === "bigint")
|
2231
|
+
return BigInt(val);
|
2232
|
+
if (clazz === "undefined")
|
2233
|
+
return void 0;
|
2234
|
+
return rest;
|
2235
|
+
}
|
2236
|
+
return value;
|
2237
|
+
});
|
2238
|
+
}
|
2239
|
+
}
|
2240
|
+
const defaultSerializer = new Serializer();
|
2241
|
+
const serialize = (data) => {
|
2242
|
+
return defaultSerializer.toJSON(data);
|
2243
|
+
};
|
2244
|
+
const deserialize = (json) => {
|
2245
|
+
return defaultSerializer.fromJSON(json);
|
2246
|
+
};
|
2247
|
+
|
2248
|
+
function buildWorkerRunner(config) {
|
2249
|
+
return function xataWorker(name, _worker) {
|
2250
|
+
return async (...args) => {
|
2251
|
+
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
2252
|
+
const result = await fetch(url, {
|
2253
|
+
method: "POST",
|
2254
|
+
headers: { "Content-Type": "application/json" },
|
2255
|
+
body: serialize({ args })
|
2256
|
+
});
|
2257
|
+
const text = await result.text();
|
2258
|
+
return deserialize(text);
|
2259
|
+
};
|
2260
|
+
};
|
2261
|
+
}
|
2262
|
+
|
1907
2263
|
class XataError extends Error {
|
1908
2264
|
constructor(message, status) {
|
1909
2265
|
super(message);
|
@@ -1919,10 +2275,12 @@ exports.PAGINATION_MAX_OFFSET = PAGINATION_MAX_OFFSET;
|
|
1919
2275
|
exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
|
1920
2276
|
exports.Page = Page;
|
1921
2277
|
exports.Query = Query;
|
2278
|
+
exports.RecordArray = RecordArray;
|
1922
2279
|
exports.Repository = Repository;
|
1923
2280
|
exports.RestRepository = RestRepository;
|
1924
2281
|
exports.SchemaPlugin = SchemaPlugin;
|
1925
2282
|
exports.SearchPlugin = SearchPlugin;
|
2283
|
+
exports.Serializer = Serializer;
|
1926
2284
|
exports.SimpleCache = SimpleCache;
|
1927
2285
|
exports.XataApiClient = XataApiClient;
|
1928
2286
|
exports.XataApiPlugin = XataApiPlugin;
|
@@ -1932,6 +2290,7 @@ exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
|
1932
2290
|
exports.addGitBranchesEntry = addGitBranchesEntry;
|
1933
2291
|
exports.addTableColumn = addTableColumn;
|
1934
2292
|
exports.buildClient = buildClient;
|
2293
|
+
exports.buildWorkerRunner = buildWorkerRunner;
|
1935
2294
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
1936
2295
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
1937
2296
|
exports.contains = contains;
|
@@ -1940,7 +2299,6 @@ exports.createDatabase = createDatabase;
|
|
1940
2299
|
exports.createTable = createTable;
|
1941
2300
|
exports.createUserAPIKey = createUserAPIKey;
|
1942
2301
|
exports.createWorkspace = createWorkspace;
|
1943
|
-
exports.defaultBranch = defaultBranch;
|
1944
2302
|
exports.deleteBranch = deleteBranch;
|
1945
2303
|
exports.deleteColumn = deleteColumn;
|
1946
2304
|
exports.deleteDatabase = deleteDatabase;
|
@@ -1949,6 +2307,7 @@ exports.deleteTable = deleteTable;
|
|
1949
2307
|
exports.deleteUser = deleteUser;
|
1950
2308
|
exports.deleteUserAPIKey = deleteUserAPIKey;
|
1951
2309
|
exports.deleteWorkspace = deleteWorkspace;
|
2310
|
+
exports.deserialize = deserialize;
|
1952
2311
|
exports.endsWith = endsWith;
|
1953
2312
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
1954
2313
|
exports.exists = exists;
|
@@ -1964,6 +2323,7 @@ exports.getColumn = getColumn;
|
|
1964
2323
|
exports.getCurrentBranchDetails = getCurrentBranchDetails;
|
1965
2324
|
exports.getCurrentBranchName = getCurrentBranchName;
|
1966
2325
|
exports.getDatabaseList = getDatabaseList;
|
2326
|
+
exports.getDatabaseMetadata = getDatabaseMetadata;
|
1967
2327
|
exports.getDatabaseURL = getDatabaseURL;
|
1968
2328
|
exports.getGitBranchesMapping = getGitBranchesMapping;
|
1969
2329
|
exports.getRecord = getRecord;
|
@@ -1984,6 +2344,7 @@ exports.insertRecord = insertRecord;
|
|
1984
2344
|
exports.insertRecordWithID = insertRecordWithID;
|
1985
2345
|
exports.inviteWorkspaceMember = inviteWorkspaceMember;
|
1986
2346
|
exports.is = is;
|
2347
|
+
exports.isCursorPaginationOptions = isCursorPaginationOptions;
|
1987
2348
|
exports.isIdentifiable = isIdentifiable;
|
1988
2349
|
exports.isNot = isNot;
|
1989
2350
|
exports.isXataRecord = isXataRecord;
|
@@ -1999,6 +2360,8 @@ exports.removeWorkspaceMember = removeWorkspaceMember;
|
|
1999
2360
|
exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
|
2000
2361
|
exports.resolveBranch = resolveBranch;
|
2001
2362
|
exports.searchBranch = searchBranch;
|
2363
|
+
exports.searchTable = searchTable;
|
2364
|
+
exports.serialize = serialize;
|
2002
2365
|
exports.setTableSchema = setTableSchema;
|
2003
2366
|
exports.startsWith = startsWith;
|
2004
2367
|
exports.updateBranchMetadata = updateBranchMetadata;
|
@@ -2007,6 +2370,7 @@ exports.updateRecordWithID = updateRecordWithID;
|
|
2007
2370
|
exports.updateTable = updateTable;
|
2008
2371
|
exports.updateUser = updateUser;
|
2009
2372
|
exports.updateWorkspace = updateWorkspace;
|
2373
|
+
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
2010
2374
|
exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
|
2011
2375
|
exports.upsertRecordWithID = upsertRecordWithID;
|
2012
2376
|
//# sourceMappingURL=index.cjs.map
|