@xata.io/client 0.0.0-alpha.ved00a04 → 0.0.0-alpha.ved155c7
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 +230 -0
- package/README.md +273 -1
- package/Usage.md +449 -0
- package/dist/index.cjs +1215 -520
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1874 -372
- package/dist/index.mjs +1165 -520
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -4
- package/tsconfig.json +1 -0
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
const defaultTrace = async (_name, fn, _options) => {
|
|
2
|
+
return await fn({
|
|
3
|
+
setAttributes: () => {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
});
|
|
7
|
+
};
|
|
8
|
+
const TraceAttributes = {
|
|
9
|
+
KIND: "xata.trace.kind",
|
|
10
|
+
VERSION: "xata.sdk.version",
|
|
11
|
+
TABLE: "xata.table",
|
|
12
|
+
HTTP_REQUEST_ID: "http.request_id",
|
|
13
|
+
HTTP_STATUS_CODE: "http.status_code",
|
|
14
|
+
HTTP_HOST: "http.host",
|
|
15
|
+
HTTP_SCHEME: "http.scheme",
|
|
16
|
+
HTTP_USER_AGENT: "http.user_agent",
|
|
17
|
+
HTTP_METHOD: "http.method",
|
|
18
|
+
HTTP_URL: "http.url",
|
|
19
|
+
HTTP_ROUTE: "http.route",
|
|
20
|
+
HTTP_TARGET: "http.target"
|
|
21
|
+
};
|
|
22
|
+
|
|
1
23
|
function notEmpty(value) {
|
|
2
24
|
return value !== null && value !== void 0;
|
|
3
25
|
}
|
|
@@ -7,43 +29,101 @@ function compact(arr) {
|
|
|
7
29
|
function isObject(value) {
|
|
8
30
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
9
31
|
}
|
|
32
|
+
function isDefined(value) {
|
|
33
|
+
return value !== null && value !== void 0;
|
|
34
|
+
}
|
|
10
35
|
function isString(value) {
|
|
11
|
-
return value
|
|
36
|
+
return isDefined(value) && typeof value === "string";
|
|
37
|
+
}
|
|
38
|
+
function isStringArray(value) {
|
|
39
|
+
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
|
12
40
|
}
|
|
13
41
|
function toBase64(value) {
|
|
14
42
|
try {
|
|
15
43
|
return btoa(value);
|
|
16
44
|
} catch (err) {
|
|
17
|
-
|
|
45
|
+
const buf = Buffer;
|
|
46
|
+
return buf.from(value).toString("base64");
|
|
18
47
|
}
|
|
19
48
|
}
|
|
20
49
|
|
|
21
|
-
function
|
|
50
|
+
function getEnvironment() {
|
|
22
51
|
try {
|
|
23
|
-
if (isObject(process) &&
|
|
24
|
-
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
|
+
};
|
|
25
60
|
}
|
|
26
61
|
} catch (err) {
|
|
27
62
|
}
|
|
28
63
|
try {
|
|
29
|
-
if (isObject(Deno) &&
|
|
30
|
-
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
|
+
};
|
|
31
72
|
}
|
|
32
73
|
} catch (err) {
|
|
33
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
|
+
}
|
|
34
110
|
}
|
|
35
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"] };
|
|
36
116
|
try {
|
|
37
|
-
|
|
117
|
+
if (typeof require === "function") {
|
|
118
|
+
return require(nodeModule).execSync(fullCmd, execOptions).trim();
|
|
119
|
+
}
|
|
120
|
+
const { execSync } = await import(nodeModule);
|
|
121
|
+
return execSync(fullCmd, execOptions).toString().trim();
|
|
38
122
|
} catch (err) {
|
|
39
123
|
}
|
|
40
124
|
try {
|
|
41
125
|
if (isObject(Deno)) {
|
|
42
|
-
const process2 = Deno.run({
|
|
43
|
-
cmd: ["git", "branch", "--show-current"],
|
|
44
|
-
stdout: "piped",
|
|
45
|
-
stderr: "piped"
|
|
46
|
-
});
|
|
126
|
+
const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
|
47
127
|
return new TextDecoder().decode(await process2.output()).trim();
|
|
48
128
|
}
|
|
49
129
|
} catch (err) {
|
|
@@ -52,7 +132,8 @@ async function getGitBranch() {
|
|
|
52
132
|
|
|
53
133
|
function getAPIKey() {
|
|
54
134
|
try {
|
|
55
|
-
|
|
135
|
+
const { apiKey } = getEnvironment();
|
|
136
|
+
return apiKey;
|
|
56
137
|
} catch (err) {
|
|
57
138
|
return void 0;
|
|
58
139
|
}
|
|
@@ -62,21 +143,35 @@ function getFetchImplementation(userFetch) {
|
|
|
62
143
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
|
63
144
|
const fetchImpl = userFetch ?? globalFetch;
|
|
64
145
|
if (!fetchImpl) {
|
|
65
|
-
throw new Error(
|
|
146
|
+
throw new Error(
|
|
147
|
+
`Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
|
|
148
|
+
);
|
|
66
149
|
}
|
|
67
150
|
return fetchImpl;
|
|
68
151
|
}
|
|
69
152
|
|
|
70
|
-
|
|
71
|
-
|
|
153
|
+
const VERSION = "0.0.0-alpha.ved155c7";
|
|
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) {
|
|
72
162
|
super(getMessage(data));
|
|
73
163
|
this.status = status;
|
|
74
164
|
this.errors = isBulkError(data) ? data.errors : void 0;
|
|
165
|
+
this.requestId = requestId;
|
|
75
166
|
if (data instanceof Error) {
|
|
76
167
|
this.stack = data.stack;
|
|
77
168
|
this.cause = data.cause;
|
|
78
169
|
}
|
|
79
170
|
}
|
|
171
|
+
toString() {
|
|
172
|
+
const error = super.toString();
|
|
173
|
+
return `[${this.status}] (${this.requestId ?? "Unknown"}): ${error}`;
|
|
174
|
+
}
|
|
80
175
|
}
|
|
81
176
|
function isBulkError(error) {
|
|
82
177
|
return isObject(error) && Array.isArray(error.errors);
|
|
@@ -99,9 +194,17 @@ function getMessage(data) {
|
|
|
99
194
|
}
|
|
100
195
|
|
|
101
196
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
102
|
-
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();
|
|
103
203
|
const queryString = query.length > 0 ? `?${query}` : "";
|
|
104
|
-
|
|
204
|
+
const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
|
|
205
|
+
return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
|
|
206
|
+
}, {});
|
|
207
|
+
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
|
105
208
|
};
|
|
106
209
|
function buildBaseUrl({
|
|
107
210
|
path,
|
|
@@ -109,10 +212,10 @@ function buildBaseUrl({
|
|
|
109
212
|
apiUrl,
|
|
110
213
|
pathParams
|
|
111
214
|
}) {
|
|
112
|
-
if (
|
|
215
|
+
if (pathParams?.workspace === void 0)
|
|
113
216
|
return `${apiUrl}${path}`;
|
|
114
217
|
const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
|
115
|
-
return url.replace("{workspaceId}", pathParams.workspace);
|
|
218
|
+
return url.replace("{workspaceId}", String(pathParams.workspace));
|
|
116
219
|
}
|
|
117
220
|
function hostHeader(url) {
|
|
118
221
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
|
@@ -129,32 +232,61 @@ async function fetch$1({
|
|
|
129
232
|
fetchImpl,
|
|
130
233
|
apiKey,
|
|
131
234
|
apiUrl,
|
|
132
|
-
workspacesApiUrl
|
|
235
|
+
workspacesApiUrl,
|
|
236
|
+
trace
|
|
133
237
|
}) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
238
|
+
return trace(
|
|
239
|
+
`${method.toUpperCase()} ${path}`,
|
|
240
|
+
async ({ setAttributes }) => {
|
|
241
|
+
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
|
242
|
+
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
|
243
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
|
244
|
+
setAttributes({
|
|
245
|
+
[TraceAttributes.HTTP_URL]: url,
|
|
246
|
+
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
|
247
|
+
});
|
|
248
|
+
const response = await fetchImpl(url, {
|
|
249
|
+
method: method.toUpperCase(),
|
|
250
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
251
|
+
headers: {
|
|
252
|
+
"Content-Type": "application/json",
|
|
253
|
+
"User-Agent": `Xata client-ts/${VERSION}`,
|
|
254
|
+
...headers,
|
|
255
|
+
...hostHeader(fullUrl),
|
|
256
|
+
Authorization: `Bearer ${apiKey}`
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
if (response.status === 204) {
|
|
260
|
+
return {};
|
|
261
|
+
}
|
|
262
|
+
const { host, protocol } = parseUrl(response.url);
|
|
263
|
+
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
|
264
|
+
setAttributes({
|
|
265
|
+
[TraceAttributes.KIND]: "http",
|
|
266
|
+
[TraceAttributes.HTTP_REQUEST_ID]: requestId,
|
|
267
|
+
[TraceAttributes.HTTP_STATUS_CODE]: response.status,
|
|
268
|
+
[TraceAttributes.HTTP_HOST]: host,
|
|
269
|
+
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
|
270
|
+
});
|
|
271
|
+
try {
|
|
272
|
+
const jsonResponse = await response.json();
|
|
273
|
+
if (response.ok) {
|
|
274
|
+
return jsonResponse;
|
|
275
|
+
}
|
|
276
|
+
throw new FetcherError(response.status, jsonResponse, requestId);
|
|
277
|
+
} catch (error) {
|
|
278
|
+
throw new FetcherError(response.status, error, requestId);
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
function parseUrl(url) {
|
|
150
285
|
try {
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
return jsonResponse;
|
|
154
|
-
}
|
|
155
|
-
throw new FetcherError(response.status, jsonResponse);
|
|
286
|
+
const { host, protocol } = new URL(url);
|
|
287
|
+
return { host, protocol };
|
|
156
288
|
} catch (error) {
|
|
157
|
-
|
|
289
|
+
return {};
|
|
158
290
|
}
|
|
159
291
|
}
|
|
160
292
|
|
|
@@ -213,6 +345,7 @@ const removeWorkspaceMember = (variables) => fetch$1({
|
|
|
213
345
|
...variables
|
|
214
346
|
});
|
|
215
347
|
const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
|
|
348
|
+
const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
|
|
216
349
|
const cancelWorkspaceMemberInvite = (variables) => fetch$1({
|
|
217
350
|
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
|
218
351
|
method: "delete",
|
|
@@ -248,16 +381,42 @@ const deleteDatabase = (variables) => fetch$1({
|
|
|
248
381
|
method: "delete",
|
|
249
382
|
...variables
|
|
250
383
|
});
|
|
251
|
-
const
|
|
252
|
-
url: "/
|
|
384
|
+
const getDatabaseMetadata = (variables) => fetch$1({
|
|
385
|
+
url: "/dbs/{dbName}/metadata",
|
|
386
|
+
method: "get",
|
|
387
|
+
...variables
|
|
388
|
+
});
|
|
389
|
+
const patchDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
|
|
390
|
+
const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
|
|
391
|
+
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
|
392
|
+
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
|
393
|
+
const resolveBranch = (variables) => fetch$1({
|
|
394
|
+
url: "/dbs/{dbName}/resolveBranch",
|
|
395
|
+
method: "get",
|
|
396
|
+
...variables
|
|
397
|
+
});
|
|
398
|
+
const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
|
|
399
|
+
const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
|
|
400
|
+
const getMigrationRequest = (variables) => fetch$1({
|
|
401
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
|
253
402
|
method: "get",
|
|
254
403
|
...variables
|
|
255
404
|
});
|
|
256
|
-
const
|
|
405
|
+
const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
|
|
406
|
+
const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
|
|
407
|
+
const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
|
|
408
|
+
const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
|
|
409
|
+
const mergeMigrationRequest = (variables) => fetch$1({
|
|
410
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
|
411
|
+
method: "post",
|
|
412
|
+
...variables
|
|
413
|
+
});
|
|
414
|
+
const getBranchDetails = (variables) => fetch$1({
|
|
257
415
|
url: "/db/{dbBranchName}",
|
|
258
|
-
method: "
|
|
416
|
+
method: "get",
|
|
259
417
|
...variables
|
|
260
418
|
});
|
|
419
|
+
const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
|
|
261
420
|
const deleteBranch = (variables) => fetch$1({
|
|
262
421
|
url: "/db/{dbBranchName}",
|
|
263
422
|
method: "delete",
|
|
@@ -276,16 +435,15 @@ const getBranchMetadata = (variables) => fetch$1({
|
|
|
276
435
|
const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
|
|
277
436
|
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
|
278
437
|
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
method: "post",
|
|
282
|
-
...variables
|
|
283
|
-
});
|
|
438
|
+
const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
|
|
439
|
+
const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
|
|
284
440
|
const updateBranchSchema = (variables) => fetch$1({
|
|
285
441
|
url: "/db/{dbBranchName}/schema/update",
|
|
286
442
|
method: "post",
|
|
287
443
|
...variables
|
|
288
444
|
});
|
|
445
|
+
const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
|
|
446
|
+
const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
|
|
289
447
|
const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
|
|
290
448
|
const getBranchStats = (variables) => fetch$1({
|
|
291
449
|
url: "/db/{dbBranchName}/stats",
|
|
@@ -342,11 +500,7 @@ const updateColumn = (variables) => fetch$1({
|
|
|
342
500
|
method: "patch",
|
|
343
501
|
...variables
|
|
344
502
|
});
|
|
345
|
-
const insertRecord = (variables) => fetch$1({
|
|
346
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data",
|
|
347
|
-
method: "post",
|
|
348
|
-
...variables
|
|
349
|
-
});
|
|
503
|
+
const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
|
|
350
504
|
const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
|
|
351
505
|
const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
|
|
352
506
|
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
|
@@ -366,6 +520,11 @@ const queryTable = (variables) => fetch$1({
|
|
|
366
520
|
method: "post",
|
|
367
521
|
...variables
|
|
368
522
|
});
|
|
523
|
+
const searchTable = (variables) => fetch$1({
|
|
524
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
|
525
|
+
method: "post",
|
|
526
|
+
...variables
|
|
527
|
+
});
|
|
369
528
|
const searchBranch = (variables) => fetch$1({
|
|
370
529
|
url: "/db/{dbBranchName}/search",
|
|
371
530
|
method: "post",
|
|
@@ -383,11 +542,22 @@ const operationsByTag = {
|
|
|
383
542
|
updateWorkspaceMemberRole,
|
|
384
543
|
removeWorkspaceMember,
|
|
385
544
|
inviteWorkspaceMember,
|
|
545
|
+
updateWorkspaceMemberInvite,
|
|
386
546
|
cancelWorkspaceMemberInvite,
|
|
387
547
|
resendWorkspaceMemberInvite,
|
|
388
548
|
acceptWorkspaceMemberInvite
|
|
389
549
|
},
|
|
390
|
-
database: {
|
|
550
|
+
database: {
|
|
551
|
+
getDatabaseList,
|
|
552
|
+
createDatabase,
|
|
553
|
+
deleteDatabase,
|
|
554
|
+
getDatabaseMetadata,
|
|
555
|
+
patchDatabaseMetadata,
|
|
556
|
+
getGitBranchesMapping,
|
|
557
|
+
addGitBranchesEntry,
|
|
558
|
+
removeGitBranchesEntry,
|
|
559
|
+
resolveBranch
|
|
560
|
+
},
|
|
391
561
|
branch: {
|
|
392
562
|
getBranchList,
|
|
393
563
|
getBranchDetails,
|
|
@@ -395,13 +565,28 @@ const operationsByTag = {
|
|
|
395
565
|
deleteBranch,
|
|
396
566
|
updateBranchMetadata,
|
|
397
567
|
getBranchMetadata,
|
|
568
|
+
getBranchStats
|
|
569
|
+
},
|
|
570
|
+
migrationRequests: {
|
|
571
|
+
listMigrationRequests,
|
|
572
|
+
createMigrationRequest,
|
|
573
|
+
getMigrationRequest,
|
|
574
|
+
updateMigrationRequest,
|
|
575
|
+
listMigrationRequestsCommits,
|
|
576
|
+
compareMigrationRequest,
|
|
577
|
+
getMigrationRequestIsMerged,
|
|
578
|
+
mergeMigrationRequest
|
|
579
|
+
},
|
|
580
|
+
branchSchema: {
|
|
398
581
|
getBranchMigrationHistory,
|
|
399
582
|
executeBranchMigrationPlan,
|
|
400
583
|
getBranchMigrationPlan,
|
|
401
|
-
|
|
584
|
+
compareBranchWithUserSchema,
|
|
585
|
+
compareBranchSchemas,
|
|
402
586
|
updateBranchSchema,
|
|
403
|
-
|
|
404
|
-
|
|
587
|
+
previewBranchSchemaEdit,
|
|
588
|
+
applyBranchSchemaEdit,
|
|
589
|
+
getBranchSchemaHistory
|
|
405
590
|
},
|
|
406
591
|
table: {
|
|
407
592
|
createTable,
|
|
@@ -424,14 +609,15 @@ const operationsByTag = {
|
|
|
424
609
|
getRecord,
|
|
425
610
|
bulkInsertTableRecords,
|
|
426
611
|
queryTable,
|
|
612
|
+
searchTable,
|
|
427
613
|
searchBranch
|
|
428
614
|
}
|
|
429
615
|
};
|
|
430
616
|
|
|
431
617
|
function getHostUrl(provider, type) {
|
|
432
|
-
if (
|
|
618
|
+
if (isHostProviderAlias(provider)) {
|
|
433
619
|
return providers[provider][type];
|
|
434
|
-
} else if (
|
|
620
|
+
} else if (isHostProviderBuilder(provider)) {
|
|
435
621
|
return provider[type];
|
|
436
622
|
}
|
|
437
623
|
throw new Error("Invalid API provider");
|
|
@@ -446,10 +632,10 @@ const providers = {
|
|
|
446
632
|
workspaces: "https://{workspaceId}.staging.xatabase.co"
|
|
447
633
|
}
|
|
448
634
|
};
|
|
449
|
-
function
|
|
635
|
+
function isHostProviderAlias(alias) {
|
|
450
636
|
return isString(alias) && Object.keys(providers).includes(alias);
|
|
451
637
|
}
|
|
452
|
-
function
|
|
638
|
+
function isHostProviderBuilder(builder) {
|
|
453
639
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
|
454
640
|
}
|
|
455
641
|
|
|
@@ -457,7 +643,7 @@ var __accessCheck$7 = (obj, member, msg) => {
|
|
|
457
643
|
if (!member.has(obj))
|
|
458
644
|
throw TypeError("Cannot " + msg);
|
|
459
645
|
};
|
|
460
|
-
var __privateGet$
|
|
646
|
+
var __privateGet$7 = (obj, member, getter) => {
|
|
461
647
|
__accessCheck$7(obj, member, "read from private field");
|
|
462
648
|
return getter ? getter.call(obj) : member.get(obj);
|
|
463
649
|
};
|
|
@@ -466,7 +652,7 @@ var __privateAdd$7 = (obj, member, value) => {
|
|
|
466
652
|
throw TypeError("Cannot add the same private member more than once");
|
|
467
653
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
468
654
|
};
|
|
469
|
-
var __privateSet$
|
|
655
|
+
var __privateSet$7 = (obj, member, value, setter) => {
|
|
470
656
|
__accessCheck$7(obj, member, "write to private field");
|
|
471
657
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
472
658
|
return value;
|
|
@@ -477,46 +663,58 @@ class XataApiClient {
|
|
|
477
663
|
__privateAdd$7(this, _extraProps, void 0);
|
|
478
664
|
__privateAdd$7(this, _namespaces, {});
|
|
479
665
|
const provider = options.host ?? "production";
|
|
480
|
-
const apiKey = options
|
|
666
|
+
const apiKey = options.apiKey ?? getAPIKey();
|
|
667
|
+
const trace = options.trace ?? defaultTrace;
|
|
481
668
|
if (!apiKey) {
|
|
482
669
|
throw new Error("Could not resolve a valid apiKey");
|
|
483
670
|
}
|
|
484
|
-
__privateSet$
|
|
671
|
+
__privateSet$7(this, _extraProps, {
|
|
485
672
|
apiUrl: getHostUrl(provider, "main"),
|
|
486
673
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
|
487
674
|
fetchImpl: getFetchImplementation(options.fetch),
|
|
488
|
-
apiKey
|
|
675
|
+
apiKey,
|
|
676
|
+
trace
|
|
489
677
|
});
|
|
490
678
|
}
|
|
491
679
|
get user() {
|
|
492
|
-
if (!__privateGet$
|
|
493
|
-
__privateGet$
|
|
494
|
-
return __privateGet$
|
|
680
|
+
if (!__privateGet$7(this, _namespaces).user)
|
|
681
|
+
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
|
682
|
+
return __privateGet$7(this, _namespaces).user;
|
|
495
683
|
}
|
|
496
684
|
get workspaces() {
|
|
497
|
-
if (!__privateGet$
|
|
498
|
-
__privateGet$
|
|
499
|
-
return __privateGet$
|
|
685
|
+
if (!__privateGet$7(this, _namespaces).workspaces)
|
|
686
|
+
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
|
687
|
+
return __privateGet$7(this, _namespaces).workspaces;
|
|
500
688
|
}
|
|
501
689
|
get databases() {
|
|
502
|
-
if (!__privateGet$
|
|
503
|
-
__privateGet$
|
|
504
|
-
return __privateGet$
|
|
690
|
+
if (!__privateGet$7(this, _namespaces).databases)
|
|
691
|
+
__privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
|
|
692
|
+
return __privateGet$7(this, _namespaces).databases;
|
|
505
693
|
}
|
|
506
694
|
get branches() {
|
|
507
|
-
if (!__privateGet$
|
|
508
|
-
__privateGet$
|
|
509
|
-
return __privateGet$
|
|
695
|
+
if (!__privateGet$7(this, _namespaces).branches)
|
|
696
|
+
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
|
697
|
+
return __privateGet$7(this, _namespaces).branches;
|
|
510
698
|
}
|
|
511
699
|
get tables() {
|
|
512
|
-
if (!__privateGet$
|
|
513
|
-
__privateGet$
|
|
514
|
-
return __privateGet$
|
|
700
|
+
if (!__privateGet$7(this, _namespaces).tables)
|
|
701
|
+
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
|
702
|
+
return __privateGet$7(this, _namespaces).tables;
|
|
515
703
|
}
|
|
516
704
|
get records() {
|
|
517
|
-
if (!__privateGet$
|
|
518
|
-
__privateGet$
|
|
519
|
-
return __privateGet$
|
|
705
|
+
if (!__privateGet$7(this, _namespaces).records)
|
|
706
|
+
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
|
707
|
+
return __privateGet$7(this, _namespaces).records;
|
|
708
|
+
}
|
|
709
|
+
get migrationRequests() {
|
|
710
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
|
711
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
|
712
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
|
713
|
+
}
|
|
714
|
+
get branchSchema() {
|
|
715
|
+
if (!__privateGet$7(this, _namespaces).branchSchema)
|
|
716
|
+
__privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
|
|
717
|
+
return __privateGet$7(this, _namespaces).branchSchema;
|
|
520
718
|
}
|
|
521
719
|
}
|
|
522
720
|
_extraProps = new WeakMap();
|
|
@@ -608,6 +806,13 @@ class WorkspaceApi {
|
|
|
608
806
|
...this.extraProps
|
|
609
807
|
});
|
|
610
808
|
}
|
|
809
|
+
updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
|
|
810
|
+
return operationsByTag.workspaces.updateWorkspaceMemberInvite({
|
|
811
|
+
pathParams: { workspaceId, inviteId },
|
|
812
|
+
body: { role },
|
|
813
|
+
...this.extraProps
|
|
814
|
+
});
|
|
815
|
+
}
|
|
611
816
|
cancelWorkspaceMemberInvite(workspaceId, inviteId) {
|
|
612
817
|
return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
|
|
613
818
|
pathParams: { workspaceId, inviteId },
|
|
@@ -650,6 +855,46 @@ class DatabaseApi {
|
|
|
650
855
|
...this.extraProps
|
|
651
856
|
});
|
|
652
857
|
}
|
|
858
|
+
getDatabaseMetadata(workspace, dbName) {
|
|
859
|
+
return operationsByTag.database.getDatabaseMetadata({
|
|
860
|
+
pathParams: { workspace, dbName },
|
|
861
|
+
...this.extraProps
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
patchDatabaseMetadata(workspace, dbName, options = {}) {
|
|
865
|
+
return operationsByTag.database.patchDatabaseMetadata({
|
|
866
|
+
pathParams: { workspace, dbName },
|
|
867
|
+
body: options,
|
|
868
|
+
...this.extraProps
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
getGitBranchesMapping(workspace, dbName) {
|
|
872
|
+
return operationsByTag.database.getGitBranchesMapping({
|
|
873
|
+
pathParams: { workspace, dbName },
|
|
874
|
+
...this.extraProps
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
addGitBranchesEntry(workspace, dbName, body) {
|
|
878
|
+
return operationsByTag.database.addGitBranchesEntry({
|
|
879
|
+
pathParams: { workspace, dbName },
|
|
880
|
+
body,
|
|
881
|
+
...this.extraProps
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
removeGitBranchesEntry(workspace, dbName, gitBranch) {
|
|
885
|
+
return operationsByTag.database.removeGitBranchesEntry({
|
|
886
|
+
pathParams: { workspace, dbName },
|
|
887
|
+
queryParams: { gitBranch },
|
|
888
|
+
...this.extraProps
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
|
|
892
|
+
return operationsByTag.database.resolveBranch({
|
|
893
|
+
pathParams: { workspace, dbName },
|
|
894
|
+
queryParams: { gitBranch, fallbackBranch },
|
|
895
|
+
...this.extraProps
|
|
896
|
+
});
|
|
897
|
+
}
|
|
653
898
|
}
|
|
654
899
|
class BranchApi {
|
|
655
900
|
constructor(extraProps) {
|
|
@@ -667,10 +912,10 @@ class BranchApi {
|
|
|
667
912
|
...this.extraProps
|
|
668
913
|
});
|
|
669
914
|
}
|
|
670
|
-
createBranch(workspace, database, branch, from
|
|
915
|
+
createBranch(workspace, database, branch, from, options = {}) {
|
|
671
916
|
return operationsByTag.branch.createBranch({
|
|
672
917
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
673
|
-
queryParams: { from },
|
|
918
|
+
queryParams: isString(from) ? { from } : void 0,
|
|
674
919
|
body: options,
|
|
675
920
|
...this.extraProps
|
|
676
921
|
});
|
|
@@ -694,27 +939,6 @@ class BranchApi {
|
|
|
694
939
|
...this.extraProps
|
|
695
940
|
});
|
|
696
941
|
}
|
|
697
|
-
getBranchMigrationHistory(workspace, database, branch, options = {}) {
|
|
698
|
-
return operationsByTag.branch.getBranchMigrationHistory({
|
|
699
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
700
|
-
body: options,
|
|
701
|
-
...this.extraProps
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
|
|
705
|
-
return operationsByTag.branch.executeBranchMigrationPlan({
|
|
706
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
707
|
-
body: migrationPlan,
|
|
708
|
-
...this.extraProps
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
getBranchMigrationPlan(workspace, database, branch, schema) {
|
|
712
|
-
return operationsByTag.branch.getBranchMigrationPlan({
|
|
713
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
714
|
-
body: schema,
|
|
715
|
-
...this.extraProps
|
|
716
|
-
});
|
|
717
|
-
}
|
|
718
942
|
getBranchStats(workspace, database, branch) {
|
|
719
943
|
return operationsByTag.branch.getBranchStats({
|
|
720
944
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
@@ -795,9 +1019,10 @@ class RecordsApi {
|
|
|
795
1019
|
constructor(extraProps) {
|
|
796
1020
|
this.extraProps = extraProps;
|
|
797
1021
|
}
|
|
798
|
-
insertRecord(workspace, database, branch, tableName, record) {
|
|
1022
|
+
insertRecord(workspace, database, branch, tableName, record, options = {}) {
|
|
799
1023
|
return operationsByTag.records.insertRecord({
|
|
800
1024
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1025
|
+
queryParams: options,
|
|
801
1026
|
body: record,
|
|
802
1027
|
...this.extraProps
|
|
803
1028
|
});
|
|
@@ -826,21 +1051,24 @@ class RecordsApi {
|
|
|
826
1051
|
...this.extraProps
|
|
827
1052
|
});
|
|
828
1053
|
}
|
|
829
|
-
deleteRecord(workspace, database, branch, tableName, recordId) {
|
|
1054
|
+
deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
|
830
1055
|
return operationsByTag.records.deleteRecord({
|
|
831
1056
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1057
|
+
queryParams: options,
|
|
832
1058
|
...this.extraProps
|
|
833
1059
|
});
|
|
834
1060
|
}
|
|
835
1061
|
getRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
|
836
1062
|
return operationsByTag.records.getRecord({
|
|
837
1063
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1064
|
+
queryParams: options,
|
|
838
1065
|
...this.extraProps
|
|
839
1066
|
});
|
|
840
1067
|
}
|
|
841
|
-
bulkInsertTableRecords(workspace, database, branch, tableName, records) {
|
|
1068
|
+
bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
|
|
842
1069
|
return operationsByTag.records.bulkInsertTableRecords({
|
|
843
1070
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1071
|
+
queryParams: options,
|
|
844
1072
|
body: { records },
|
|
845
1073
|
...this.extraProps
|
|
846
1074
|
});
|
|
@@ -852,6 +1080,13 @@ class RecordsApi {
|
|
|
852
1080
|
...this.extraProps
|
|
853
1081
|
});
|
|
854
1082
|
}
|
|
1083
|
+
searchTable(workspace, database, branch, tableName, query) {
|
|
1084
|
+
return operationsByTag.records.searchTable({
|
|
1085
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1086
|
+
body: query,
|
|
1087
|
+
...this.extraProps
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
855
1090
|
searchBranch(workspace, database, branch, query) {
|
|
856
1091
|
return operationsByTag.records.searchBranch({
|
|
857
1092
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
@@ -860,6 +1095,131 @@ class RecordsApi {
|
|
|
860
1095
|
});
|
|
861
1096
|
}
|
|
862
1097
|
}
|
|
1098
|
+
class MigrationRequestsApi {
|
|
1099
|
+
constructor(extraProps) {
|
|
1100
|
+
this.extraProps = extraProps;
|
|
1101
|
+
}
|
|
1102
|
+
listMigrationRequests(workspace, database, options = {}) {
|
|
1103
|
+
return operationsByTag.migrationRequests.listMigrationRequests({
|
|
1104
|
+
pathParams: { workspace, dbName: database },
|
|
1105
|
+
body: options,
|
|
1106
|
+
...this.extraProps
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
createMigrationRequest(workspace, database, options) {
|
|
1110
|
+
return operationsByTag.migrationRequests.createMigrationRequest({
|
|
1111
|
+
pathParams: { workspace, dbName: database },
|
|
1112
|
+
body: options,
|
|
1113
|
+
...this.extraProps
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
getMigrationRequest(workspace, database, migrationRequest) {
|
|
1117
|
+
return operationsByTag.migrationRequests.getMigrationRequest({
|
|
1118
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1119
|
+
...this.extraProps
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
updateMigrationRequest(workspace, database, migrationRequest, options) {
|
|
1123
|
+
return operationsByTag.migrationRequests.updateMigrationRequest({
|
|
1124
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1125
|
+
body: options,
|
|
1126
|
+
...this.extraProps
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
|
|
1130
|
+
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
|
1131
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1132
|
+
body: options,
|
|
1133
|
+
...this.extraProps
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
compareMigrationRequest(workspace, database, migrationRequest) {
|
|
1137
|
+
return operationsByTag.migrationRequests.compareMigrationRequest({
|
|
1138
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1139
|
+
...this.extraProps
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
getMigrationRequestIsMerged(workspace, database, migrationRequest) {
|
|
1143
|
+
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
|
1144
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1145
|
+
...this.extraProps
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
mergeMigrationRequest(workspace, database, migrationRequest) {
|
|
1149
|
+
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
|
1150
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1151
|
+
...this.extraProps
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
class BranchSchemaApi {
|
|
1156
|
+
constructor(extraProps) {
|
|
1157
|
+
this.extraProps = extraProps;
|
|
1158
|
+
}
|
|
1159
|
+
getBranchMigrationHistory(workspace, database, branch, options = {}) {
|
|
1160
|
+
return operationsByTag.branchSchema.getBranchMigrationHistory({
|
|
1161
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1162
|
+
body: options,
|
|
1163
|
+
...this.extraProps
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
|
|
1167
|
+
return operationsByTag.branchSchema.executeBranchMigrationPlan({
|
|
1168
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1169
|
+
body: migrationPlan,
|
|
1170
|
+
...this.extraProps
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
getBranchMigrationPlan(workspace, database, branch, schema) {
|
|
1174
|
+
return operationsByTag.branchSchema.getBranchMigrationPlan({
|
|
1175
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1176
|
+
body: schema,
|
|
1177
|
+
...this.extraProps
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
compareBranchWithUserSchema(workspace, database, branch, schema) {
|
|
1181
|
+
return operationsByTag.branchSchema.compareBranchWithUserSchema({
|
|
1182
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1183
|
+
body: { schema },
|
|
1184
|
+
...this.extraProps
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
compareBranchSchemas(workspace, database, branch, branchName, schema) {
|
|
1188
|
+
return operationsByTag.branchSchema.compareBranchSchemas({
|
|
1189
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
|
|
1190
|
+
body: { schema },
|
|
1191
|
+
...this.extraProps
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
updateBranchSchema(workspace, database, branch, migration) {
|
|
1195
|
+
return operationsByTag.branchSchema.updateBranchSchema({
|
|
1196
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1197
|
+
body: migration,
|
|
1198
|
+
...this.extraProps
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
previewBranchSchemaEdit(workspace, database, branch, migration) {
|
|
1202
|
+
return operationsByTag.branchSchema.previewBranchSchemaEdit({
|
|
1203
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1204
|
+
body: migration,
|
|
1205
|
+
...this.extraProps
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
applyBranchSchemaEdit(workspace, database, branch, edits) {
|
|
1209
|
+
return operationsByTag.branchSchema.applyBranchSchemaEdit({
|
|
1210
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1211
|
+
body: { edits },
|
|
1212
|
+
...this.extraProps
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
getBranchSchemaHistory(workspace, database, branch, options = {}) {
|
|
1216
|
+
return operationsByTag.branchSchema.getBranchSchemaHistory({
|
|
1217
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1218
|
+
body: options,
|
|
1219
|
+
...this.extraProps
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
863
1223
|
|
|
864
1224
|
class XataApiPlugin {
|
|
865
1225
|
async build(options) {
|
|
@@ -875,7 +1235,7 @@ var __accessCheck$6 = (obj, member, msg) => {
|
|
|
875
1235
|
if (!member.has(obj))
|
|
876
1236
|
throw TypeError("Cannot " + msg);
|
|
877
1237
|
};
|
|
878
|
-
var __privateGet$
|
|
1238
|
+
var __privateGet$6 = (obj, member, getter) => {
|
|
879
1239
|
__accessCheck$6(obj, member, "read from private field");
|
|
880
1240
|
return getter ? getter.call(obj) : member.get(obj);
|
|
881
1241
|
};
|
|
@@ -884,30 +1244,30 @@ var __privateAdd$6 = (obj, member, value) => {
|
|
|
884
1244
|
throw TypeError("Cannot add the same private member more than once");
|
|
885
1245
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
886
1246
|
};
|
|
887
|
-
var __privateSet$
|
|
1247
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
|
888
1248
|
__accessCheck$6(obj, member, "write to private field");
|
|
889
1249
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
890
1250
|
return value;
|
|
891
1251
|
};
|
|
892
|
-
var _query;
|
|
1252
|
+
var _query, _page;
|
|
893
1253
|
class Page {
|
|
894
1254
|
constructor(query, meta, records = []) {
|
|
895
1255
|
__privateAdd$6(this, _query, void 0);
|
|
896
|
-
__privateSet$
|
|
1256
|
+
__privateSet$6(this, _query, query);
|
|
897
1257
|
this.meta = meta;
|
|
898
|
-
this.records = records;
|
|
1258
|
+
this.records = new RecordArray(this, records);
|
|
899
1259
|
}
|
|
900
1260
|
async nextPage(size, offset) {
|
|
901
|
-
return __privateGet$
|
|
1261
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
|
902
1262
|
}
|
|
903
1263
|
async previousPage(size, offset) {
|
|
904
|
-
return __privateGet$
|
|
1264
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
|
905
1265
|
}
|
|
906
1266
|
async firstPage(size, offset) {
|
|
907
|
-
return __privateGet$
|
|
1267
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
|
|
908
1268
|
}
|
|
909
1269
|
async lastPage(size, offset) {
|
|
910
|
-
return __privateGet$
|
|
1270
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
|
|
911
1271
|
}
|
|
912
1272
|
hasNextPage() {
|
|
913
1273
|
return this.meta.page.more;
|
|
@@ -915,15 +1275,62 @@ class Page {
|
|
|
915
1275
|
}
|
|
916
1276
|
_query = new WeakMap();
|
|
917
1277
|
const PAGINATION_MAX_SIZE = 200;
|
|
918
|
-
const PAGINATION_DEFAULT_SIZE =
|
|
1278
|
+
const PAGINATION_DEFAULT_SIZE = 20;
|
|
919
1279
|
const PAGINATION_MAX_OFFSET = 800;
|
|
920
1280
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
|
1281
|
+
function isCursorPaginationOptions(options) {
|
|
1282
|
+
return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
|
|
1283
|
+
}
|
|
1284
|
+
const _RecordArray = class extends Array {
|
|
1285
|
+
constructor(...args) {
|
|
1286
|
+
super(..._RecordArray.parseConstructorParams(...args));
|
|
1287
|
+
__privateAdd$6(this, _page, void 0);
|
|
1288
|
+
__privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
|
|
1289
|
+
}
|
|
1290
|
+
static parseConstructorParams(...args) {
|
|
1291
|
+
if (args.length === 1 && typeof args[0] === "number") {
|
|
1292
|
+
return new Array(args[0]);
|
|
1293
|
+
}
|
|
1294
|
+
if (args.length <= 2 && isObject(args[0]?.meta) && Array.isArray(args[1] ?? [])) {
|
|
1295
|
+
const result = args[1] ?? args[0].records ?? [];
|
|
1296
|
+
return new Array(...result);
|
|
1297
|
+
}
|
|
1298
|
+
return new Array(...args);
|
|
1299
|
+
}
|
|
1300
|
+
toArray() {
|
|
1301
|
+
return new Array(...this);
|
|
1302
|
+
}
|
|
1303
|
+
map(callbackfn, thisArg) {
|
|
1304
|
+
return this.toArray().map(callbackfn, thisArg);
|
|
1305
|
+
}
|
|
1306
|
+
async nextPage(size, offset) {
|
|
1307
|
+
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
|
1308
|
+
return new _RecordArray(newPage);
|
|
1309
|
+
}
|
|
1310
|
+
async previousPage(size, offset) {
|
|
1311
|
+
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
|
1312
|
+
return new _RecordArray(newPage);
|
|
1313
|
+
}
|
|
1314
|
+
async firstPage(size, offset) {
|
|
1315
|
+
const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
|
|
1316
|
+
return new _RecordArray(newPage);
|
|
1317
|
+
}
|
|
1318
|
+
async lastPage(size, offset) {
|
|
1319
|
+
const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
|
|
1320
|
+
return new _RecordArray(newPage);
|
|
1321
|
+
}
|
|
1322
|
+
hasNextPage() {
|
|
1323
|
+
return __privateGet$6(this, _page).meta.page.more;
|
|
1324
|
+
}
|
|
1325
|
+
};
|
|
1326
|
+
let RecordArray = _RecordArray;
|
|
1327
|
+
_page = new WeakMap();
|
|
921
1328
|
|
|
922
1329
|
var __accessCheck$5 = (obj, member, msg) => {
|
|
923
1330
|
if (!member.has(obj))
|
|
924
1331
|
throw TypeError("Cannot " + msg);
|
|
925
1332
|
};
|
|
926
|
-
var __privateGet$
|
|
1333
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
927
1334
|
__accessCheck$5(obj, member, "read from private field");
|
|
928
1335
|
return getter ? getter.call(obj) : member.get(obj);
|
|
929
1336
|
};
|
|
@@ -932,34 +1339,35 @@ var __privateAdd$5 = (obj, member, value) => {
|
|
|
932
1339
|
throw TypeError("Cannot add the same private member more than once");
|
|
933
1340
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
934
1341
|
};
|
|
935
|
-
var __privateSet$
|
|
1342
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
|
936
1343
|
__accessCheck$5(obj, member, "write to private field");
|
|
937
1344
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
938
1345
|
return value;
|
|
939
1346
|
};
|
|
940
1347
|
var _table$1, _repository, _data;
|
|
941
1348
|
const _Query = class {
|
|
942
|
-
constructor(repository, table, data,
|
|
1349
|
+
constructor(repository, table, data, rawParent) {
|
|
943
1350
|
__privateAdd$5(this, _table$1, void 0);
|
|
944
1351
|
__privateAdd$5(this, _repository, void 0);
|
|
945
1352
|
__privateAdd$5(this, _data, { filter: {} });
|
|
946
1353
|
this.meta = { page: { cursor: "start", more: true } };
|
|
947
|
-
this.records = [];
|
|
948
|
-
__privateSet$
|
|
1354
|
+
this.records = new RecordArray(this, []);
|
|
1355
|
+
__privateSet$5(this, _table$1, table);
|
|
949
1356
|
if (repository) {
|
|
950
|
-
__privateSet$
|
|
1357
|
+
__privateSet$5(this, _repository, repository);
|
|
951
1358
|
} else {
|
|
952
|
-
__privateSet$
|
|
1359
|
+
__privateSet$5(this, _repository, this);
|
|
953
1360
|
}
|
|
954
|
-
|
|
955
|
-
__privateGet$
|
|
956
|
-
__privateGet$
|
|
957
|
-
__privateGet$
|
|
958
|
-
__privateGet$
|
|
959
|
-
__privateGet$
|
|
960
|
-
__privateGet$
|
|
961
|
-
__privateGet$
|
|
962
|
-
__privateGet$
|
|
1361
|
+
const parent = cleanParent(data, rawParent);
|
|
1362
|
+
__privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
|
1363
|
+
__privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
|
|
1364
|
+
__privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
|
|
1365
|
+
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
|
1366
|
+
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
|
1367
|
+
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
|
1368
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
|
|
1369
|
+
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
|
1370
|
+
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
|
963
1371
|
this.any = this.any.bind(this);
|
|
964
1372
|
this.all = this.all.bind(this);
|
|
965
1373
|
this.not = this.not.bind(this);
|
|
@@ -970,83 +1378,101 @@ const _Query = class {
|
|
|
970
1378
|
Object.defineProperty(this, "repository", { enumerable: false });
|
|
971
1379
|
}
|
|
972
1380
|
getQueryOptions() {
|
|
973
|
-
return __privateGet$
|
|
1381
|
+
return __privateGet$5(this, _data);
|
|
974
1382
|
}
|
|
975
1383
|
key() {
|
|
976
|
-
const { columns = [], filter = {}, sort = [],
|
|
977
|
-
const key = JSON.stringify({ columns, filter, sort,
|
|
1384
|
+
const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$5(this, _data);
|
|
1385
|
+
const key = JSON.stringify({ columns, filter, sort, pagination });
|
|
978
1386
|
return toBase64(key);
|
|
979
1387
|
}
|
|
980
1388
|
any(...queries) {
|
|
981
1389
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
982
|
-
return new _Query(__privateGet$
|
|
1390
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
|
983
1391
|
}
|
|
984
1392
|
all(...queries) {
|
|
985
1393
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
986
|
-
return new _Query(__privateGet$
|
|
1394
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
|
987
1395
|
}
|
|
988
1396
|
not(...queries) {
|
|
989
1397
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
990
|
-
return new _Query(__privateGet$
|
|
1398
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
|
991
1399
|
}
|
|
992
1400
|
none(...queries) {
|
|
993
1401
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
994
|
-
return new _Query(__privateGet$
|
|
1402
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
|
995
1403
|
}
|
|
996
1404
|
filter(a, b) {
|
|
997
1405
|
if (arguments.length === 1) {
|
|
998
|
-
const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
|
|
999
|
-
const $all = compact([__privateGet$
|
|
1000
|
-
return new _Query(__privateGet$
|
|
1406
|
+
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({ [column]: constraint }));
|
|
1407
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
|
1408
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
|
1001
1409
|
} else {
|
|
1002
|
-
const
|
|
1003
|
-
|
|
1410
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.defaultFilter(a, b) }] : void 0;
|
|
1411
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
|
1412
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
|
1004
1413
|
}
|
|
1005
1414
|
}
|
|
1006
|
-
|
|
1007
|
-
const
|
|
1415
|
+
defaultFilter(column, value) {
|
|
1416
|
+
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
|
1417
|
+
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
|
1418
|
+
return { $includes: value };
|
|
1419
|
+
}
|
|
1420
|
+
return value;
|
|
1421
|
+
}
|
|
1422
|
+
sort(column, direction = "asc") {
|
|
1423
|
+
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
|
1008
1424
|
const sort = [...originalSort, { column, direction }];
|
|
1009
|
-
return new _Query(__privateGet$
|
|
1425
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
|
1010
1426
|
}
|
|
1011
1427
|
select(columns) {
|
|
1012
|
-
return new _Query(
|
|
1428
|
+
return new _Query(
|
|
1429
|
+
__privateGet$5(this, _repository),
|
|
1430
|
+
__privateGet$5(this, _table$1),
|
|
1431
|
+
{ columns },
|
|
1432
|
+
__privateGet$5(this, _data)
|
|
1433
|
+
);
|
|
1013
1434
|
}
|
|
1014
1435
|
getPaginated(options = {}) {
|
|
1015
|
-
const query = new _Query(__privateGet$
|
|
1016
|
-
return __privateGet$
|
|
1436
|
+
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
|
1437
|
+
return __privateGet$5(this, _repository).query(query);
|
|
1017
1438
|
}
|
|
1018
1439
|
async *[Symbol.asyncIterator]() {
|
|
1019
|
-
for await (const [record] of this.getIterator(1)) {
|
|
1440
|
+
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
|
1020
1441
|
yield record;
|
|
1021
1442
|
}
|
|
1022
1443
|
}
|
|
1023
|
-
async *getIterator(
|
|
1024
|
-
|
|
1025
|
-
let
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1444
|
+
async *getIterator(options = {}) {
|
|
1445
|
+
const { batchSize = 1 } = options;
|
|
1446
|
+
let page = await this.getPaginated({ ...options, pagination: { size: batchSize, offset: 0 } });
|
|
1447
|
+
let more = page.hasNextPage();
|
|
1448
|
+
yield page.records;
|
|
1449
|
+
while (more) {
|
|
1450
|
+
page = await page.nextPage();
|
|
1451
|
+
more = page.hasNextPage();
|
|
1452
|
+
yield page.records;
|
|
1031
1453
|
}
|
|
1032
1454
|
}
|
|
1033
1455
|
async getMany(options = {}) {
|
|
1034
|
-
const
|
|
1035
|
-
|
|
1456
|
+
const page = await this.getPaginated(options);
|
|
1457
|
+
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
|
1458
|
+
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
|
1459
|
+
}
|
|
1460
|
+
return page.records;
|
|
1036
1461
|
}
|
|
1037
|
-
async getAll(
|
|
1462
|
+
async getAll(options = {}) {
|
|
1463
|
+
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
|
1038
1464
|
const results = [];
|
|
1039
|
-
for await (const page of this.getIterator(
|
|
1465
|
+
for await (const page of this.getIterator({ ...rest, batchSize })) {
|
|
1040
1466
|
results.push(...page);
|
|
1041
1467
|
}
|
|
1042
1468
|
return results;
|
|
1043
1469
|
}
|
|
1044
1470
|
async getFirst(options = {}) {
|
|
1045
|
-
const records = await this.getMany({ ...options,
|
|
1046
|
-
return records[0]
|
|
1471
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
|
1472
|
+
return records[0] ?? null;
|
|
1047
1473
|
}
|
|
1048
1474
|
cache(ttl) {
|
|
1049
|
-
return new _Query(__privateGet$
|
|
1475
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
|
1050
1476
|
}
|
|
1051
1477
|
nextPage(size, offset) {
|
|
1052
1478
|
return this.firstPage(size, offset);
|
|
@@ -1055,10 +1481,10 @@ const _Query = class {
|
|
|
1055
1481
|
return this.firstPage(size, offset);
|
|
1056
1482
|
}
|
|
1057
1483
|
firstPage(size, offset) {
|
|
1058
|
-
return this.getPaginated({
|
|
1484
|
+
return this.getPaginated({ pagination: { size, offset } });
|
|
1059
1485
|
}
|
|
1060
1486
|
lastPage(size, offset) {
|
|
1061
|
-
return this.getPaginated({
|
|
1487
|
+
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
|
1062
1488
|
}
|
|
1063
1489
|
hasNextPage() {
|
|
1064
1490
|
return this.meta.page.more;
|
|
@@ -1068,12 +1494,20 @@ let Query = _Query;
|
|
|
1068
1494
|
_table$1 = new WeakMap();
|
|
1069
1495
|
_repository = new WeakMap();
|
|
1070
1496
|
_data = new WeakMap();
|
|
1497
|
+
function cleanParent(data, parent) {
|
|
1498
|
+
if (isCursorPaginationOptions(data.pagination)) {
|
|
1499
|
+
return { ...parent, sorting: void 0, filter: void 0 };
|
|
1500
|
+
}
|
|
1501
|
+
return parent;
|
|
1502
|
+
}
|
|
1071
1503
|
|
|
1072
1504
|
function isIdentifiable(x) {
|
|
1073
1505
|
return isObject(x) && isString(x?.id);
|
|
1074
1506
|
}
|
|
1075
1507
|
function isXataRecord(x) {
|
|
1076
|
-
|
|
1508
|
+
const record = x;
|
|
1509
|
+
const metadata = record?.getMetadata();
|
|
1510
|
+
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
|
1077
1511
|
}
|
|
1078
1512
|
|
|
1079
1513
|
function isSortFilterString(value) {
|
|
@@ -1103,7 +1537,7 @@ var __accessCheck$4 = (obj, member, msg) => {
|
|
|
1103
1537
|
if (!member.has(obj))
|
|
1104
1538
|
throw TypeError("Cannot " + msg);
|
|
1105
1539
|
};
|
|
1106
|
-
var __privateGet$
|
|
1540
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
1107
1541
|
__accessCheck$4(obj, member, "read from private field");
|
|
1108
1542
|
return getter ? getter.call(obj) : member.get(obj);
|
|
1109
1543
|
};
|
|
@@ -1112,7 +1546,7 @@ var __privateAdd$4 = (obj, member, value) => {
|
|
|
1112
1546
|
throw TypeError("Cannot add the same private member more than once");
|
|
1113
1547
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1114
1548
|
};
|
|
1115
|
-
var __privateSet$
|
|
1549
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
1116
1550
|
__accessCheck$4(obj, member, "write to private field");
|
|
1117
1551
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1118
1552
|
return value;
|
|
@@ -1121,304 +1555,355 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
|
1121
1555
|
__accessCheck$4(obj, member, "access private method");
|
|
1122
1556
|
return method;
|
|
1123
1557
|
};
|
|
1124
|
-
var _table,
|
|
1558
|
+
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;
|
|
1125
1559
|
class Repository extends Query {
|
|
1126
1560
|
}
|
|
1127
1561
|
class RestRepository extends Query {
|
|
1128
1562
|
constructor(options) {
|
|
1129
|
-
super(
|
|
1563
|
+
super(
|
|
1564
|
+
null,
|
|
1565
|
+
{ name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
|
|
1566
|
+
{}
|
|
1567
|
+
);
|
|
1130
1568
|
__privateAdd$4(this, _insertRecordWithoutId);
|
|
1131
1569
|
__privateAdd$4(this, _insertRecordWithId);
|
|
1132
1570
|
__privateAdd$4(this, _bulkInsertTableRecords);
|
|
1133
1571
|
__privateAdd$4(this, _updateRecordWithID);
|
|
1134
1572
|
__privateAdd$4(this, _upsertRecordWithID);
|
|
1135
1573
|
__privateAdd$4(this, _deleteRecord);
|
|
1136
|
-
__privateAdd$4(this, _invalidateCache);
|
|
1137
|
-
__privateAdd$4(this, _setCacheRecord);
|
|
1138
|
-
__privateAdd$4(this, _getCacheRecord);
|
|
1139
1574
|
__privateAdd$4(this, _setCacheQuery);
|
|
1140
1575
|
__privateAdd$4(this, _getCacheQuery);
|
|
1576
|
+
__privateAdd$4(this, _getSchemaTables$1);
|
|
1141
1577
|
__privateAdd$4(this, _table, void 0);
|
|
1142
|
-
__privateAdd$4(this, _links, void 0);
|
|
1143
1578
|
__privateAdd$4(this, _getFetchProps, void 0);
|
|
1579
|
+
__privateAdd$4(this, _db, void 0);
|
|
1144
1580
|
__privateAdd$4(this, _cache, void 0);
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
__privateSet$
|
|
1148
|
-
this
|
|
1149
|
-
__privateSet$
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
throw new Error("The id can't be empty");
|
|
1160
|
-
const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b);
|
|
1161
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
|
1162
|
-
return record;
|
|
1163
|
-
}
|
|
1164
|
-
if (isObject(a) && isString(a.id)) {
|
|
1165
|
-
if (a.id === "")
|
|
1166
|
-
throw new Error("The id can't be empty");
|
|
1167
|
-
const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 });
|
|
1168
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
|
1169
|
-
return record;
|
|
1170
|
-
}
|
|
1171
|
-
if (isObject(a)) {
|
|
1172
|
-
const record = await __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a);
|
|
1173
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
|
1174
|
-
return record;
|
|
1175
|
-
}
|
|
1176
|
-
throw new Error("Invalid arguments for create method");
|
|
1177
|
-
}
|
|
1178
|
-
async read(recordId) {
|
|
1179
|
-
const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, recordId);
|
|
1180
|
-
if (cacheRecord)
|
|
1181
|
-
return cacheRecord;
|
|
1182
|
-
const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
|
|
1183
|
-
try {
|
|
1184
|
-
const response = await getRecord({
|
|
1185
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table), recordId },
|
|
1186
|
-
...fetchProps
|
|
1581
|
+
__privateAdd$4(this, _schemaTables$2, void 0);
|
|
1582
|
+
__privateAdd$4(this, _trace, void 0);
|
|
1583
|
+
__privateSet$4(this, _table, options.table);
|
|
1584
|
+
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
|
1585
|
+
__privateSet$4(this, _db, options.db);
|
|
1586
|
+
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
|
1587
|
+
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
|
1588
|
+
const trace = options.pluginOptions.trace ?? defaultTrace;
|
|
1589
|
+
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
|
1590
|
+
return trace(name, fn, {
|
|
1591
|
+
...options2,
|
|
1592
|
+
[TraceAttributes.TABLE]: __privateGet$4(this, _table),
|
|
1593
|
+
[TraceAttributes.KIND]: "sdk-operation",
|
|
1594
|
+
[TraceAttributes.VERSION]: VERSION
|
|
1187
1595
|
});
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1598
|
+
async create(a, b, c) {
|
|
1599
|
+
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
|
1600
|
+
if (Array.isArray(a)) {
|
|
1601
|
+
if (a.length === 0)
|
|
1602
|
+
return [];
|
|
1603
|
+
const columns = isStringArray(b) ? b : void 0;
|
|
1604
|
+
return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
|
|
1192
1605
|
}
|
|
1193
|
-
|
|
1194
|
-
|
|
1606
|
+
if (isString(a) && isObject(b)) {
|
|
1607
|
+
if (a === "")
|
|
1608
|
+
throw new Error("The id can't be empty");
|
|
1609
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
1610
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
|
1611
|
+
}
|
|
1612
|
+
if (isObject(a) && isString(a.id)) {
|
|
1613
|
+
if (a.id === "")
|
|
1614
|
+
throw new Error("The id can't be empty");
|
|
1615
|
+
const columns = isStringArray(b) ? b : void 0;
|
|
1616
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
|
1617
|
+
}
|
|
1618
|
+
if (isObject(a)) {
|
|
1619
|
+
const columns = isStringArray(b) ? b : void 0;
|
|
1620
|
+
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
|
1621
|
+
}
|
|
1622
|
+
throw new Error("Invalid arguments for create method");
|
|
1623
|
+
});
|
|
1195
1624
|
}
|
|
1196
|
-
async
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1625
|
+
async read(a, b) {
|
|
1626
|
+
return __privateGet$4(this, _trace).call(this, "read", async () => {
|
|
1627
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
1628
|
+
if (Array.isArray(a)) {
|
|
1629
|
+
if (a.length === 0)
|
|
1630
|
+
return [];
|
|
1631
|
+
const ids = a.map((item) => extractId(item));
|
|
1632
|
+
const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
|
|
1633
|
+
const dictionary = finalObjects.reduce((acc, object) => {
|
|
1634
|
+
acc[object.id] = object;
|
|
1635
|
+
return acc;
|
|
1636
|
+
}, {});
|
|
1637
|
+
return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
|
|
1200
1638
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1639
|
+
const id = extractId(a);
|
|
1640
|
+
if (id) {
|
|
1641
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1642
|
+
try {
|
|
1643
|
+
const response = await getRecord({
|
|
1644
|
+
pathParams: {
|
|
1645
|
+
workspace: "{workspaceId}",
|
|
1646
|
+
dbBranchName: "{dbBranch}",
|
|
1647
|
+
tableName: __privateGet$4(this, _table),
|
|
1648
|
+
recordId: id
|
|
1649
|
+
},
|
|
1650
|
+
queryParams: { columns },
|
|
1651
|
+
...fetchProps
|
|
1652
|
+
});
|
|
1653
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1654
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1655
|
+
} catch (e) {
|
|
1656
|
+
if (isObject(e) && e.status === 404) {
|
|
1657
|
+
return null;
|
|
1658
|
+
}
|
|
1659
|
+
throw e;
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
return null;
|
|
1663
|
+
});
|
|
1216
1664
|
}
|
|
1217
|
-
async
|
|
1218
|
-
|
|
1219
|
-
if (a
|
|
1220
|
-
|
|
1665
|
+
async update(a, b, c) {
|
|
1666
|
+
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
|
1667
|
+
if (Array.isArray(a)) {
|
|
1668
|
+
if (a.length === 0)
|
|
1669
|
+
return [];
|
|
1670
|
+
if (a.length > 100) {
|
|
1671
|
+
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
|
1672
|
+
}
|
|
1673
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
1674
|
+
return Promise.all(a.map((object) => this.update(object, columns)));
|
|
1221
1675
|
}
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
|
|
1233
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
|
1234
|
-
return record;
|
|
1235
|
-
}
|
|
1236
|
-
throw new Error("Invalid arguments for createOrUpdate method");
|
|
1676
|
+
if (isString(a) && isObject(b)) {
|
|
1677
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
1678
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
|
|
1679
|
+
}
|
|
1680
|
+
if (isObject(a) && isString(a.id)) {
|
|
1681
|
+
const columns = isStringArray(b) ? b : void 0;
|
|
1682
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
|
1683
|
+
}
|
|
1684
|
+
throw new Error("Invalid arguments for update method");
|
|
1685
|
+
});
|
|
1237
1686
|
}
|
|
1238
|
-
async
|
|
1239
|
-
|
|
1240
|
-
if (a
|
|
1241
|
-
|
|
1687
|
+
async createOrUpdate(a, b, c) {
|
|
1688
|
+
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
|
1689
|
+
if (Array.isArray(a)) {
|
|
1690
|
+
if (a.length === 0)
|
|
1691
|
+
return [];
|
|
1692
|
+
if (a.length > 100) {
|
|
1693
|
+
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
|
1694
|
+
}
|
|
1695
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
1696
|
+
return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
|
|
1242
1697
|
}
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1698
|
+
if (isString(a) && isObject(b)) {
|
|
1699
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
1700
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
|
|
1701
|
+
}
|
|
1702
|
+
if (isObject(a) && isString(a.id)) {
|
|
1703
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
1704
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
|
1705
|
+
}
|
|
1706
|
+
throw new Error("Invalid arguments for createOrUpdate method");
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
async delete(a, b) {
|
|
1710
|
+
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
|
1711
|
+
if (Array.isArray(a)) {
|
|
1712
|
+
if (a.length === 0)
|
|
1713
|
+
return [];
|
|
1714
|
+
if (a.length > 100) {
|
|
1715
|
+
console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
|
|
1716
|
+
}
|
|
1717
|
+
return Promise.all(a.map((id) => this.delete(id, b)));
|
|
1718
|
+
}
|
|
1719
|
+
if (isString(a)) {
|
|
1720
|
+
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
|
|
1721
|
+
}
|
|
1722
|
+
if (isObject(a) && isString(a.id)) {
|
|
1723
|
+
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
|
|
1724
|
+
}
|
|
1725
|
+
throw new Error("Invalid arguments for delete method");
|
|
1726
|
+
});
|
|
1257
1727
|
}
|
|
1258
1728
|
async search(query, options = {}) {
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1729
|
+
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
|
1730
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1731
|
+
const { records } = await searchTable({
|
|
1732
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
|
1733
|
+
body: {
|
|
1734
|
+
query,
|
|
1735
|
+
fuzziness: options.fuzziness,
|
|
1736
|
+
prefix: options.prefix,
|
|
1737
|
+
highlight: options.highlight,
|
|
1738
|
+
filter: options.filter,
|
|
1739
|
+
boosters: options.boosters
|
|
1740
|
+
},
|
|
1741
|
+
...fetchProps
|
|
1742
|
+
});
|
|
1743
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1744
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
|
1264
1745
|
});
|
|
1265
|
-
return records.map((item) => initObject(this.db, __privateGet$3(this, _links), __privateGet$3(this, _table), item));
|
|
1266
1746
|
}
|
|
1267
1747
|
async query(query) {
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1748
|
+
return __privateGet$4(this, _trace).call(this, "query", async () => {
|
|
1749
|
+
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
|
1750
|
+
if (cacheQuery)
|
|
1751
|
+
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
|
1752
|
+
const data = query.getQueryOptions();
|
|
1753
|
+
const body = {
|
|
1754
|
+
filter: cleanFilter(data.filter),
|
|
1755
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
|
1756
|
+
page: data.pagination,
|
|
1757
|
+
columns: data.columns
|
|
1758
|
+
};
|
|
1759
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1760
|
+
const { meta, records: objects } = await queryTable({
|
|
1761
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
|
1762
|
+
body,
|
|
1763
|
+
...fetchProps
|
|
1764
|
+
});
|
|
1765
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1766
|
+
const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
|
|
1767
|
+
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
|
1768
|
+
return new Page(query, meta, records);
|
|
1283
1769
|
});
|
|
1284
|
-
const records = objects.map((record) => initObject(this.db, __privateGet$3(this, _links), __privateGet$3(this, _table), record));
|
|
1285
|
-
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
|
1286
|
-
return new Page(query, meta, records);
|
|
1287
1770
|
}
|
|
1288
1771
|
}
|
|
1289
1772
|
_table = new WeakMap();
|
|
1290
|
-
_links = new WeakMap();
|
|
1291
1773
|
_getFetchProps = new WeakMap();
|
|
1774
|
+
_db = new WeakMap();
|
|
1292
1775
|
_cache = new WeakMap();
|
|
1776
|
+
_schemaTables$2 = new WeakMap();
|
|
1777
|
+
_trace = new WeakMap();
|
|
1293
1778
|
_insertRecordWithoutId = new WeakSet();
|
|
1294
|
-
insertRecordWithoutId_fn = async function(object) {
|
|
1295
|
-
const fetchProps = await __privateGet$
|
|
1779
|
+
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1780
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1296
1781
|
const record = transformObjectLinks(object);
|
|
1297
1782
|
const response = await insertRecord({
|
|
1298
1783
|
pathParams: {
|
|
1299
1784
|
workspace: "{workspaceId}",
|
|
1300
1785
|
dbBranchName: "{dbBranch}",
|
|
1301
|
-
tableName: __privateGet$
|
|
1786
|
+
tableName: __privateGet$4(this, _table)
|
|
1302
1787
|
},
|
|
1788
|
+
queryParams: { columns },
|
|
1303
1789
|
body: record,
|
|
1304
1790
|
...fetchProps
|
|
1305
1791
|
});
|
|
1306
|
-
const
|
|
1307
|
-
|
|
1308
|
-
throw new Error("The server failed to save the record");
|
|
1309
|
-
}
|
|
1310
|
-
return finalObject;
|
|
1792
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1793
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1311
1794
|
};
|
|
1312
1795
|
_insertRecordWithId = new WeakSet();
|
|
1313
|
-
insertRecordWithId_fn = async function(recordId, object) {
|
|
1314
|
-
const fetchProps = await __privateGet$
|
|
1796
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
|
1797
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1315
1798
|
const record = transformObjectLinks(object);
|
|
1316
1799
|
const response = await insertRecordWithID({
|
|
1317
1800
|
pathParams: {
|
|
1318
1801
|
workspace: "{workspaceId}",
|
|
1319
1802
|
dbBranchName: "{dbBranch}",
|
|
1320
|
-
tableName: __privateGet$
|
|
1803
|
+
tableName: __privateGet$4(this, _table),
|
|
1321
1804
|
recordId
|
|
1322
1805
|
},
|
|
1323
1806
|
body: record,
|
|
1324
|
-
queryParams: { createOnly: true },
|
|
1807
|
+
queryParams: { createOnly: true, columns },
|
|
1325
1808
|
...fetchProps
|
|
1326
1809
|
});
|
|
1327
|
-
const
|
|
1328
|
-
|
|
1329
|
-
throw new Error("The server failed to save the record");
|
|
1330
|
-
}
|
|
1331
|
-
return finalObject;
|
|
1810
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1811
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1332
1812
|
};
|
|
1333
1813
|
_bulkInsertTableRecords = new WeakSet();
|
|
1334
|
-
bulkInsertTableRecords_fn = async function(objects) {
|
|
1335
|
-
const fetchProps = await __privateGet$
|
|
1814
|
+
bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
|
1815
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1336
1816
|
const records = objects.map((object) => transformObjectLinks(object));
|
|
1337
1817
|
const response = await bulkInsertTableRecords({
|
|
1338
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
|
1818
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
|
1819
|
+
queryParams: { columns },
|
|
1339
1820
|
body: { records },
|
|
1340
1821
|
...fetchProps
|
|
1341
1822
|
});
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
throw new Error("The server failed to save some records");
|
|
1823
|
+
if (!isResponseWithRecords(response)) {
|
|
1824
|
+
throw new Error("Request included columns but server didn't include them");
|
|
1345
1825
|
}
|
|
1346
|
-
|
|
1826
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1827
|
+
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
|
1347
1828
|
};
|
|
1348
1829
|
_updateRecordWithID = new WeakSet();
|
|
1349
|
-
updateRecordWithID_fn = async function(recordId, object) {
|
|
1350
|
-
const fetchProps = await __privateGet$
|
|
1830
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
1831
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1351
1832
|
const record = transformObjectLinks(object);
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1833
|
+
try {
|
|
1834
|
+
const response = await updateRecordWithID({
|
|
1835
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
|
1836
|
+
queryParams: { columns },
|
|
1837
|
+
body: record,
|
|
1838
|
+
...fetchProps
|
|
1839
|
+
});
|
|
1840
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1841
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1842
|
+
} catch (e) {
|
|
1843
|
+
if (isObject(e) && e.status === 404) {
|
|
1844
|
+
return null;
|
|
1845
|
+
}
|
|
1846
|
+
throw e;
|
|
1847
|
+
}
|
|
1361
1848
|
};
|
|
1362
1849
|
_upsertRecordWithID = new WeakSet();
|
|
1363
|
-
upsertRecordWithID_fn = async function(recordId, object) {
|
|
1364
|
-
const fetchProps = await __privateGet$
|
|
1850
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
1851
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1365
1852
|
const response = await upsertRecordWithID({
|
|
1366
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
|
1853
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
|
1854
|
+
queryParams: { columns },
|
|
1367
1855
|
body: object,
|
|
1368
1856
|
...fetchProps
|
|
1369
1857
|
});
|
|
1370
|
-
const
|
|
1371
|
-
|
|
1372
|
-
throw new Error("The server failed to save the record");
|
|
1373
|
-
return item;
|
|
1858
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1859
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1374
1860
|
};
|
|
1375
1861
|
_deleteRecord = new WeakSet();
|
|
1376
|
-
deleteRecord_fn = async function(recordId) {
|
|
1377
|
-
const fetchProps = await __privateGet$
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
await __privateGet$3(this, _cache).delete(key);
|
|
1862
|
+
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
1863
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1864
|
+
try {
|
|
1865
|
+
const response = await deleteRecord({
|
|
1866
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
|
1867
|
+
queryParams: { columns },
|
|
1868
|
+
...fetchProps
|
|
1869
|
+
});
|
|
1870
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1871
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1872
|
+
} catch (e) {
|
|
1873
|
+
if (isObject(e) && e.status === 404) {
|
|
1874
|
+
return null;
|
|
1875
|
+
}
|
|
1876
|
+
throw e;
|
|
1392
1877
|
}
|
|
1393
1878
|
};
|
|
1394
|
-
_setCacheRecord = new WeakSet();
|
|
1395
|
-
setCacheRecord_fn = async function(record) {
|
|
1396
|
-
if (!__privateGet$3(this, _cache).cacheRecords)
|
|
1397
|
-
return;
|
|
1398
|
-
await __privateGet$3(this, _cache).set(`rec_${__privateGet$3(this, _table)}:${record.id}`, record);
|
|
1399
|
-
};
|
|
1400
|
-
_getCacheRecord = new WeakSet();
|
|
1401
|
-
getCacheRecord_fn = async function(recordId) {
|
|
1402
|
-
if (!__privateGet$3(this, _cache).cacheRecords)
|
|
1403
|
-
return null;
|
|
1404
|
-
return __privateGet$3(this, _cache).get(`rec_${__privateGet$3(this, _table)}:${recordId}`);
|
|
1405
|
-
};
|
|
1406
1879
|
_setCacheQuery = new WeakSet();
|
|
1407
1880
|
setCacheQuery_fn = async function(query, meta, records) {
|
|
1408
|
-
await __privateGet$
|
|
1881
|
+
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
|
1409
1882
|
};
|
|
1410
1883
|
_getCacheQuery = new WeakSet();
|
|
1411
1884
|
getCacheQuery_fn = async function(query) {
|
|
1412
|
-
const key = `query_${__privateGet$
|
|
1413
|
-
const result = await __privateGet$
|
|
1885
|
+
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
|
1886
|
+
const result = await __privateGet$4(this, _cache).get(key);
|
|
1414
1887
|
if (!result)
|
|
1415
1888
|
return null;
|
|
1416
|
-
const { cache: ttl = __privateGet$
|
|
1417
|
-
if (
|
|
1418
|
-
return
|
|
1889
|
+
const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
|
|
1890
|
+
if (ttl < 0)
|
|
1891
|
+
return null;
|
|
1419
1892
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
|
1420
1893
|
return hasExpired ? null : result;
|
|
1421
1894
|
};
|
|
1895
|
+
_getSchemaTables$1 = new WeakSet();
|
|
1896
|
+
getSchemaTables_fn$1 = async function() {
|
|
1897
|
+
if (__privateGet$4(this, _schemaTables$2))
|
|
1898
|
+
return __privateGet$4(this, _schemaTables$2);
|
|
1899
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1900
|
+
const { schema } = await getBranchDetails({
|
|
1901
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
1902
|
+
...fetchProps
|
|
1903
|
+
});
|
|
1904
|
+
__privateSet$4(this, _schemaTables$2, schema.tables);
|
|
1905
|
+
return schema.tables;
|
|
1906
|
+
};
|
|
1422
1907
|
const transformObjectLinks = (object) => {
|
|
1423
1908
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
|
1424
1909
|
if (key === "xata")
|
|
@@ -1426,47 +1911,76 @@ const transformObjectLinks = (object) => {
|
|
|
1426
1911
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
|
1427
1912
|
}, {});
|
|
1428
1913
|
};
|
|
1429
|
-
const initObject = (db,
|
|
1914
|
+
const initObject = (db, schemaTables, table, object) => {
|
|
1430
1915
|
const result = {};
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1916
|
+
const { xata, ...rest } = object ?? {};
|
|
1917
|
+
Object.assign(result, rest);
|
|
1918
|
+
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
|
1919
|
+
if (!columns)
|
|
1920
|
+
console.error(`Table ${table} not found in schema`);
|
|
1921
|
+
for (const column of columns ?? []) {
|
|
1922
|
+
const value = result[column.name];
|
|
1923
|
+
switch (column.type) {
|
|
1924
|
+
case "datetime": {
|
|
1925
|
+
const date = value !== void 0 ? new Date(value) : void 0;
|
|
1926
|
+
if (date && isNaN(date.getTime())) {
|
|
1927
|
+
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
|
1928
|
+
} else if (date) {
|
|
1929
|
+
result[column.name] = date;
|
|
1930
|
+
}
|
|
1931
|
+
break;
|
|
1932
|
+
}
|
|
1933
|
+
case "link": {
|
|
1934
|
+
const linkTable = column.link?.table;
|
|
1935
|
+
if (!linkTable) {
|
|
1936
|
+
console.error(`Failed to parse link for field ${column.name}`);
|
|
1937
|
+
} else if (isObject(value)) {
|
|
1938
|
+
result[column.name] = initObject(db, schemaTables, linkTable, value);
|
|
1939
|
+
}
|
|
1940
|
+
break;
|
|
1941
|
+
}
|
|
1438
1942
|
}
|
|
1439
1943
|
}
|
|
1440
|
-
result.read = function() {
|
|
1441
|
-
return db[table].read(result["id"]);
|
|
1944
|
+
result.read = function(columns2) {
|
|
1945
|
+
return db[table].read(result["id"], columns2);
|
|
1442
1946
|
};
|
|
1443
|
-
result.update = function(data) {
|
|
1444
|
-
return db[table].update(result["id"], data);
|
|
1947
|
+
result.update = function(data, columns2) {
|
|
1948
|
+
return db[table].update(result["id"], data, columns2);
|
|
1445
1949
|
};
|
|
1446
1950
|
result.delete = function() {
|
|
1447
1951
|
return db[table].delete(result["id"]);
|
|
1448
1952
|
};
|
|
1449
|
-
|
|
1953
|
+
result.getMetadata = function() {
|
|
1954
|
+
return xata;
|
|
1955
|
+
};
|
|
1956
|
+
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
|
1450
1957
|
Object.defineProperty(result, prop, { enumerable: false });
|
|
1451
1958
|
}
|
|
1452
1959
|
Object.freeze(result);
|
|
1453
1960
|
return result;
|
|
1454
1961
|
};
|
|
1455
|
-
function
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
if (
|
|
1460
|
-
return
|
|
1461
|
-
|
|
1462
|
-
|
|
1962
|
+
function isResponseWithRecords(value) {
|
|
1963
|
+
return isObject(value) && Array.isArray(value.records);
|
|
1964
|
+
}
|
|
1965
|
+
function extractId(value) {
|
|
1966
|
+
if (isString(value))
|
|
1967
|
+
return value;
|
|
1968
|
+
if (isObject(value) && isString(value.id))
|
|
1969
|
+
return value.id;
|
|
1970
|
+
return void 0;
|
|
1971
|
+
}
|
|
1972
|
+
function cleanFilter(filter) {
|
|
1973
|
+
if (!filter)
|
|
1974
|
+
return void 0;
|
|
1975
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
|
1976
|
+
return values.length > 0 ? filter : void 0;
|
|
1463
1977
|
}
|
|
1464
1978
|
|
|
1465
1979
|
var __accessCheck$3 = (obj, member, msg) => {
|
|
1466
1980
|
if (!member.has(obj))
|
|
1467
1981
|
throw TypeError("Cannot " + msg);
|
|
1468
1982
|
};
|
|
1469
|
-
var __privateGet$
|
|
1983
|
+
var __privateGet$3 = (obj, member, getter) => {
|
|
1470
1984
|
__accessCheck$3(obj, member, "read from private field");
|
|
1471
1985
|
return getter ? getter.call(obj) : member.get(obj);
|
|
1472
1986
|
};
|
|
@@ -1475,7 +1989,7 @@ var __privateAdd$3 = (obj, member, value) => {
|
|
|
1475
1989
|
throw TypeError("Cannot add the same private member more than once");
|
|
1476
1990
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1477
1991
|
};
|
|
1478
|
-
var __privateSet$
|
|
1992
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
|
1479
1993
|
__accessCheck$3(obj, member, "write to private field");
|
|
1480
1994
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1481
1995
|
return value;
|
|
@@ -1484,46 +1998,52 @@ var _map;
|
|
|
1484
1998
|
class SimpleCache {
|
|
1485
1999
|
constructor(options = {}) {
|
|
1486
2000
|
__privateAdd$3(this, _map, void 0);
|
|
1487
|
-
__privateSet$
|
|
2001
|
+
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
|
1488
2002
|
this.capacity = options.max ?? 500;
|
|
1489
|
-
this.cacheRecords = options.cacheRecords ?? true;
|
|
1490
2003
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
|
1491
2004
|
}
|
|
1492
2005
|
async getAll() {
|
|
1493
|
-
return Object.fromEntries(__privateGet$
|
|
2006
|
+
return Object.fromEntries(__privateGet$3(this, _map));
|
|
1494
2007
|
}
|
|
1495
2008
|
async get(key) {
|
|
1496
|
-
return __privateGet$
|
|
2009
|
+
return __privateGet$3(this, _map).get(key) ?? null;
|
|
1497
2010
|
}
|
|
1498
2011
|
async set(key, value) {
|
|
1499
2012
|
await this.delete(key);
|
|
1500
|
-
__privateGet$
|
|
1501
|
-
if (__privateGet$
|
|
1502
|
-
const leastRecentlyUsed = __privateGet$
|
|
2013
|
+
__privateGet$3(this, _map).set(key, value);
|
|
2014
|
+
if (__privateGet$3(this, _map).size > this.capacity) {
|
|
2015
|
+
const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
|
|
1503
2016
|
await this.delete(leastRecentlyUsed);
|
|
1504
2017
|
}
|
|
1505
2018
|
}
|
|
1506
2019
|
async delete(key) {
|
|
1507
|
-
__privateGet$
|
|
2020
|
+
__privateGet$3(this, _map).delete(key);
|
|
1508
2021
|
}
|
|
1509
2022
|
async clear() {
|
|
1510
|
-
return __privateGet$
|
|
2023
|
+
return __privateGet$3(this, _map).clear();
|
|
1511
2024
|
}
|
|
1512
2025
|
}
|
|
1513
2026
|
_map = new WeakMap();
|
|
1514
2027
|
|
|
1515
|
-
const
|
|
1516
|
-
const
|
|
1517
|
-
const
|
|
1518
|
-
const
|
|
1519
|
-
const
|
|
1520
|
-
const
|
|
2028
|
+
const greaterThan = (value) => ({ $gt: value });
|
|
2029
|
+
const gt = greaterThan;
|
|
2030
|
+
const greaterThanEquals = (value) => ({ $ge: value });
|
|
2031
|
+
const greaterEquals = greaterThanEquals;
|
|
2032
|
+
const gte = greaterThanEquals;
|
|
2033
|
+
const ge = greaterThanEquals;
|
|
2034
|
+
const lessThan = (value) => ({ $lt: value });
|
|
2035
|
+
const lt = lessThan;
|
|
2036
|
+
const lessThanEquals = (value) => ({ $le: value });
|
|
2037
|
+
const lessEquals = lessThanEquals;
|
|
2038
|
+
const lte = lessThanEquals;
|
|
2039
|
+
const le = lessThanEquals;
|
|
1521
2040
|
const exists = (column) => ({ $exists: column });
|
|
1522
2041
|
const notExists = (column) => ({ $notExists: column });
|
|
1523
2042
|
const startsWith = (value) => ({ $startsWith: value });
|
|
1524
2043
|
const endsWith = (value) => ({ $endsWith: value });
|
|
1525
2044
|
const pattern = (value) => ({ $pattern: value });
|
|
1526
2045
|
const is = (value) => ({ $is: value });
|
|
2046
|
+
const equals = is;
|
|
1527
2047
|
const isNot = (value) => ({ $isNot: value });
|
|
1528
2048
|
const contains = (value) => ({ $contains: value });
|
|
1529
2049
|
const includes = (value) => ({ $includes: value });
|
|
@@ -1535,7 +2055,7 @@ var __accessCheck$2 = (obj, member, msg) => {
|
|
|
1535
2055
|
if (!member.has(obj))
|
|
1536
2056
|
throw TypeError("Cannot " + msg);
|
|
1537
2057
|
};
|
|
1538
|
-
var __privateGet$
|
|
2058
|
+
var __privateGet$2 = (obj, member, getter) => {
|
|
1539
2059
|
__accessCheck$2(obj, member, "read from private field");
|
|
1540
2060
|
return getter ? getter.call(obj) : member.get(obj);
|
|
1541
2061
|
};
|
|
@@ -1544,130 +2064,178 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
|
1544
2064
|
throw TypeError("Cannot add the same private member more than once");
|
|
1545
2065
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1546
2066
|
};
|
|
1547
|
-
var
|
|
2067
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
|
2068
|
+
__accessCheck$2(obj, member, "write to private field");
|
|
2069
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
2070
|
+
return value;
|
|
2071
|
+
};
|
|
2072
|
+
var _tables, _schemaTables$1;
|
|
1548
2073
|
class SchemaPlugin extends XataPlugin {
|
|
1549
|
-
constructor(
|
|
2074
|
+
constructor(schemaTables) {
|
|
1550
2075
|
super();
|
|
1551
|
-
this.links = links;
|
|
1552
|
-
this.tableNames = tableNames;
|
|
1553
2076
|
__privateAdd$2(this, _tables, {});
|
|
2077
|
+
__privateAdd$2(this, _schemaTables$1, void 0);
|
|
2078
|
+
__privateSet$2(this, _schemaTables$1, schemaTables);
|
|
1554
2079
|
}
|
|
1555
2080
|
build(pluginOptions) {
|
|
1556
|
-
const
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
__privateGet$
|
|
2081
|
+
const db = new Proxy(
|
|
2082
|
+
{},
|
|
2083
|
+
{
|
|
2084
|
+
get: (_target, table) => {
|
|
2085
|
+
if (!isString(table))
|
|
2086
|
+
throw new Error("Invalid table name");
|
|
2087
|
+
if (__privateGet$2(this, _tables)[table] === void 0) {
|
|
2088
|
+
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
|
2089
|
+
}
|
|
2090
|
+
return __privateGet$2(this, _tables)[table];
|
|
1563
2091
|
}
|
|
1564
|
-
return __privateGet$1(this, _tables)[table];
|
|
1565
2092
|
}
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
2093
|
+
);
|
|
2094
|
+
const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
|
|
2095
|
+
for (const table of tableNames) {
|
|
2096
|
+
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
|
1569
2097
|
}
|
|
1570
2098
|
return db;
|
|
1571
2099
|
}
|
|
1572
2100
|
}
|
|
1573
2101
|
_tables = new WeakMap();
|
|
2102
|
+
_schemaTables$1 = new WeakMap();
|
|
1574
2103
|
|
|
1575
2104
|
var __accessCheck$1 = (obj, member, msg) => {
|
|
1576
2105
|
if (!member.has(obj))
|
|
1577
2106
|
throw TypeError("Cannot " + msg);
|
|
1578
2107
|
};
|
|
2108
|
+
var __privateGet$1 = (obj, member, getter) => {
|
|
2109
|
+
__accessCheck$1(obj, member, "read from private field");
|
|
2110
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
2111
|
+
};
|
|
1579
2112
|
var __privateAdd$1 = (obj, member, value) => {
|
|
1580
2113
|
if (member.has(obj))
|
|
1581
2114
|
throw TypeError("Cannot add the same private member more than once");
|
|
1582
2115
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1583
2116
|
};
|
|
2117
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
|
2118
|
+
__accessCheck$1(obj, member, "write to private field");
|
|
2119
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
2120
|
+
return value;
|
|
2121
|
+
};
|
|
1584
2122
|
var __privateMethod$1 = (obj, member, method) => {
|
|
1585
2123
|
__accessCheck$1(obj, member, "access private method");
|
|
1586
2124
|
return method;
|
|
1587
2125
|
};
|
|
1588
|
-
var _search, search_fn;
|
|
2126
|
+
var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
|
|
1589
2127
|
class SearchPlugin extends XataPlugin {
|
|
1590
|
-
constructor(db,
|
|
2128
|
+
constructor(db, schemaTables) {
|
|
1591
2129
|
super();
|
|
1592
2130
|
this.db = db;
|
|
1593
|
-
this.links = links;
|
|
1594
2131
|
__privateAdd$1(this, _search);
|
|
2132
|
+
__privateAdd$1(this, _getSchemaTables);
|
|
2133
|
+
__privateAdd$1(this, _schemaTables, void 0);
|
|
2134
|
+
__privateSet$1(this, _schemaTables, schemaTables);
|
|
1595
2135
|
}
|
|
1596
2136
|
build({ getFetchProps }) {
|
|
1597
2137
|
return {
|
|
1598
2138
|
all: async (query, options = {}) => {
|
|
1599
2139
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
|
2140
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
|
1600
2141
|
return records.map((record) => {
|
|
1601
2142
|
const { table = "orphan" } = record.xata;
|
|
1602
|
-
return { table, record: initObject(this.db,
|
|
2143
|
+
return { table, record: initObject(this.db, schemaTables, table, record) };
|
|
1603
2144
|
});
|
|
1604
2145
|
},
|
|
1605
2146
|
byTable: async (query, options = {}) => {
|
|
1606
2147
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
|
2148
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
|
1607
2149
|
return records.reduce((acc, record) => {
|
|
1608
2150
|
const { table = "orphan" } = record.xata;
|
|
1609
2151
|
const items = acc[table] ?? [];
|
|
1610
|
-
const item = initObject(this.db,
|
|
2152
|
+
const item = initObject(this.db, schemaTables, table, record);
|
|
1611
2153
|
return { ...acc, [table]: [...items, item] };
|
|
1612
2154
|
}, {});
|
|
1613
2155
|
}
|
|
1614
2156
|
};
|
|
1615
2157
|
}
|
|
1616
2158
|
}
|
|
2159
|
+
_schemaTables = new WeakMap();
|
|
1617
2160
|
_search = new WeakSet();
|
|
1618
2161
|
search_fn = async function(query, options, getFetchProps) {
|
|
1619
2162
|
const fetchProps = await getFetchProps();
|
|
1620
|
-
const { tables, fuzziness } = options ?? {};
|
|
2163
|
+
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
|
1621
2164
|
const { records } = await searchBranch({
|
|
1622
2165
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
1623
|
-
body: { tables, query, fuzziness },
|
|
2166
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
|
1624
2167
|
...fetchProps
|
|
1625
2168
|
});
|
|
1626
2169
|
return records;
|
|
1627
2170
|
};
|
|
2171
|
+
_getSchemaTables = new WeakSet();
|
|
2172
|
+
getSchemaTables_fn = async function(getFetchProps) {
|
|
2173
|
+
if (__privateGet$1(this, _schemaTables))
|
|
2174
|
+
return __privateGet$1(this, _schemaTables);
|
|
2175
|
+
const fetchProps = await getFetchProps();
|
|
2176
|
+
const { schema } = await getBranchDetails({
|
|
2177
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
2178
|
+
...fetchProps
|
|
2179
|
+
});
|
|
2180
|
+
__privateSet$1(this, _schemaTables, schema.tables);
|
|
2181
|
+
return schema.tables;
|
|
2182
|
+
};
|
|
1628
2183
|
|
|
1629
2184
|
const isBranchStrategyBuilder = (strategy) => {
|
|
1630
2185
|
return typeof strategy === "function";
|
|
1631
2186
|
};
|
|
1632
2187
|
|
|
1633
|
-
const envBranchNames = [
|
|
1634
|
-
"XATA_BRANCH",
|
|
1635
|
-
"VERCEL_GIT_COMMIT_REF",
|
|
1636
|
-
"CF_PAGES_BRANCH",
|
|
1637
|
-
"BRANCH"
|
|
1638
|
-
];
|
|
1639
|
-
const defaultBranch = "main";
|
|
1640
2188
|
async function getCurrentBranchName(options) {
|
|
1641
|
-
const
|
|
1642
|
-
if (
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
return defaultBranch;
|
|
2189
|
+
const { branch, envBranch } = getEnvironment();
|
|
2190
|
+
if (branch) {
|
|
2191
|
+
const details = await getDatabaseBranch(branch, options);
|
|
2192
|
+
if (details)
|
|
2193
|
+
return branch;
|
|
2194
|
+
console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
|
|
2195
|
+
}
|
|
2196
|
+
const gitBranch = envBranch || await getGitBranch();
|
|
2197
|
+
return resolveXataBranch(gitBranch, options);
|
|
1651
2198
|
}
|
|
1652
2199
|
async function getCurrentBranchDetails(options) {
|
|
1653
|
-
const
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
2200
|
+
const branch = await getCurrentBranchName(options);
|
|
2201
|
+
return getDatabaseBranch(branch, options);
|
|
2202
|
+
}
|
|
2203
|
+
async function resolveXataBranch(gitBranch, options) {
|
|
2204
|
+
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
2205
|
+
const apiKey = options?.apiKey || getAPIKey();
|
|
2206
|
+
if (!databaseURL)
|
|
2207
|
+
throw new Error(
|
|
2208
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
|
2209
|
+
);
|
|
2210
|
+
if (!apiKey)
|
|
2211
|
+
throw new Error(
|
|
2212
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
|
2213
|
+
);
|
|
2214
|
+
const [protocol, , host, , dbName] = databaseURL.split("/");
|
|
2215
|
+
const [workspace] = host.split(".");
|
|
2216
|
+
const { fallbackBranch } = getEnvironment();
|
|
2217
|
+
const { branch } = await resolveBranch({
|
|
2218
|
+
apiKey,
|
|
2219
|
+
apiUrl: databaseURL,
|
|
2220
|
+
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
|
2221
|
+
workspacesApiUrl: `${protocol}//${host}`,
|
|
2222
|
+
pathParams: { dbName, workspace },
|
|
2223
|
+
queryParams: { gitBranch, fallbackBranch },
|
|
2224
|
+
trace: defaultTrace
|
|
2225
|
+
});
|
|
2226
|
+
return branch;
|
|
1663
2227
|
}
|
|
1664
2228
|
async function getDatabaseBranch(branch, options) {
|
|
1665
2229
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
1666
2230
|
const apiKey = options?.apiKey || getAPIKey();
|
|
1667
2231
|
if (!databaseURL)
|
|
1668
|
-
throw new Error(
|
|
2232
|
+
throw new Error(
|
|
2233
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
|
2234
|
+
);
|
|
1669
2235
|
if (!apiKey)
|
|
1670
|
-
throw new Error(
|
|
2236
|
+
throw new Error(
|
|
2237
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
|
2238
|
+
);
|
|
1671
2239
|
const [protocol, , host, , database] = databaseURL.split("/");
|
|
1672
2240
|
const [workspace] = host.split(".");
|
|
1673
2241
|
const dbBranchName = `${database}:${branch}`;
|
|
@@ -1677,10 +2245,8 @@ async function getDatabaseBranch(branch, options) {
|
|
|
1677
2245
|
apiUrl: databaseURL,
|
|
1678
2246
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
|
1679
2247
|
workspacesApiUrl: `${protocol}//${host}`,
|
|
1680
|
-
pathParams: {
|
|
1681
|
-
|
|
1682
|
-
workspace
|
|
1683
|
-
}
|
|
2248
|
+
pathParams: { dbBranchName, workspace },
|
|
2249
|
+
trace: defaultTrace
|
|
1684
2250
|
});
|
|
1685
2251
|
} catch (err) {
|
|
1686
2252
|
if (isObject(err) && err.status === 404)
|
|
@@ -1688,21 +2254,10 @@ async function getDatabaseBranch(branch, options) {
|
|
|
1688
2254
|
throw err;
|
|
1689
2255
|
}
|
|
1690
2256
|
}
|
|
1691
|
-
function getBranchByEnvVariable() {
|
|
1692
|
-
for (const name of envBranchNames) {
|
|
1693
|
-
const value = getEnvVariable(name);
|
|
1694
|
-
if (value) {
|
|
1695
|
-
return value;
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
try {
|
|
1699
|
-
return XATA_BRANCH;
|
|
1700
|
-
} catch (err) {
|
|
1701
|
-
}
|
|
1702
|
-
}
|
|
1703
2257
|
function getDatabaseURL() {
|
|
1704
2258
|
try {
|
|
1705
|
-
|
|
2259
|
+
const { databaseURL } = getEnvironment();
|
|
2260
|
+
return databaseURL;
|
|
1706
2261
|
} catch (err) {
|
|
1707
2262
|
return void 0;
|
|
1708
2263
|
}
|
|
@@ -1731,24 +2286,27 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1731
2286
|
return method;
|
|
1732
2287
|
};
|
|
1733
2288
|
const buildClient = (plugins) => {
|
|
1734
|
-
var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
|
2289
|
+
var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
|
1735
2290
|
return _a = class {
|
|
1736
|
-
constructor(options = {},
|
|
2291
|
+
constructor(options = {}, schemaTables) {
|
|
1737
2292
|
__privateAdd(this, _parseOptions);
|
|
1738
2293
|
__privateAdd(this, _getFetchProps);
|
|
1739
2294
|
__privateAdd(this, _evaluateBranch);
|
|
1740
2295
|
__privateAdd(this, _branch, void 0);
|
|
2296
|
+
__privateAdd(this, _options, void 0);
|
|
1741
2297
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
|
2298
|
+
__privateSet(this, _options, safeOptions);
|
|
1742
2299
|
const pluginOptions = {
|
|
1743
2300
|
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
|
1744
|
-
cache: safeOptions.cache
|
|
2301
|
+
cache: safeOptions.cache,
|
|
2302
|
+
trace: safeOptions.trace
|
|
1745
2303
|
};
|
|
1746
|
-
const db = new SchemaPlugin(
|
|
1747
|
-
const search = new SearchPlugin(db,
|
|
2304
|
+
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
|
2305
|
+
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
|
1748
2306
|
this.db = db;
|
|
1749
2307
|
this.search = search;
|
|
1750
2308
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
|
1751
|
-
if (
|
|
2309
|
+
if (namespace === void 0)
|
|
1752
2310
|
continue;
|
|
1753
2311
|
const result = namespace.build(pluginOptions);
|
|
1754
2312
|
if (result instanceof Promise) {
|
|
@@ -1760,22 +2318,26 @@ const buildClient = (plugins) => {
|
|
|
1760
2318
|
}
|
|
1761
2319
|
}
|
|
1762
2320
|
}
|
|
1763
|
-
|
|
2321
|
+
async getConfig() {
|
|
2322
|
+
const databaseURL = __privateGet(this, _options).databaseURL;
|
|
2323
|
+
const branch = await __privateGet(this, _options).branch();
|
|
2324
|
+
return { databaseURL, branch };
|
|
2325
|
+
}
|
|
2326
|
+
}, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
|
1764
2327
|
const fetch = getFetchImplementation(options?.fetch);
|
|
1765
2328
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
1766
2329
|
const apiKey = options?.apiKey || getAPIKey();
|
|
1767
|
-
const cache = options?.cache ?? new SimpleCache({
|
|
1768
|
-
const
|
|
1769
|
-
|
|
1770
|
-
|
|
2330
|
+
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
|
2331
|
+
const trace = options?.trace ?? defaultTrace;
|
|
2332
|
+
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
|
2333
|
+
if (!apiKey) {
|
|
2334
|
+
throw new Error("Option apiKey is required");
|
|
1771
2335
|
}
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
apiKey,
|
|
1776
|
-
|
|
1777
|
-
branch
|
|
1778
|
-
}) {
|
|
2336
|
+
if (!databaseURL) {
|
|
2337
|
+
throw new Error("Option databaseURL is required");
|
|
2338
|
+
}
|
|
2339
|
+
return { fetch, databaseURL, apiKey, branch, cache, trace };
|
|
2340
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
|
|
1779
2341
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
|
1780
2342
|
if (!branchValue)
|
|
1781
2343
|
throw new Error("Unable to resolve branch value");
|
|
@@ -1785,14 +2347,15 @@ const buildClient = (plugins) => {
|
|
|
1785
2347
|
apiUrl: "",
|
|
1786
2348
|
workspacesApiUrl: (path, params) => {
|
|
1787
2349
|
const hasBranch = params.dbBranchName ?? params.branch;
|
|
1788
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
|
|
2350
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
|
|
1789
2351
|
return databaseURL + newPath;
|
|
1790
|
-
}
|
|
2352
|
+
},
|
|
2353
|
+
trace
|
|
1791
2354
|
};
|
|
1792
2355
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
|
1793
2356
|
if (__privateGet(this, _branch))
|
|
1794
2357
|
return __privateGet(this, _branch);
|
|
1795
|
-
if (
|
|
2358
|
+
if (param === void 0)
|
|
1796
2359
|
return void 0;
|
|
1797
2360
|
const strategies = Array.isArray(param) ? [...param] : [param];
|
|
1798
2361
|
const evaluateBranch = async (strategy) => {
|
|
@@ -1810,6 +2373,88 @@ const buildClient = (plugins) => {
|
|
|
1810
2373
|
class BaseClient extends buildClient() {
|
|
1811
2374
|
}
|
|
1812
2375
|
|
|
2376
|
+
const META = "__";
|
|
2377
|
+
const VALUE = "___";
|
|
2378
|
+
class Serializer {
|
|
2379
|
+
constructor() {
|
|
2380
|
+
this.classes = {};
|
|
2381
|
+
}
|
|
2382
|
+
add(clazz) {
|
|
2383
|
+
this.classes[clazz.name] = clazz;
|
|
2384
|
+
}
|
|
2385
|
+
toJSON(data) {
|
|
2386
|
+
function visit(obj) {
|
|
2387
|
+
if (Array.isArray(obj))
|
|
2388
|
+
return obj.map(visit);
|
|
2389
|
+
const type = typeof obj;
|
|
2390
|
+
if (type === "undefined")
|
|
2391
|
+
return { [META]: "undefined" };
|
|
2392
|
+
if (type === "bigint")
|
|
2393
|
+
return { [META]: "bigint", [VALUE]: obj.toString() };
|
|
2394
|
+
if (obj === null || type !== "object")
|
|
2395
|
+
return obj;
|
|
2396
|
+
const constructor = obj.constructor;
|
|
2397
|
+
const o = { [META]: constructor.name };
|
|
2398
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
2399
|
+
o[key] = visit(value);
|
|
2400
|
+
}
|
|
2401
|
+
if (constructor === Date)
|
|
2402
|
+
o[VALUE] = obj.toISOString();
|
|
2403
|
+
if (constructor === Map)
|
|
2404
|
+
o[VALUE] = Object.fromEntries(obj);
|
|
2405
|
+
if (constructor === Set)
|
|
2406
|
+
o[VALUE] = [...obj];
|
|
2407
|
+
return o;
|
|
2408
|
+
}
|
|
2409
|
+
return JSON.stringify(visit(data));
|
|
2410
|
+
}
|
|
2411
|
+
fromJSON(json) {
|
|
2412
|
+
return JSON.parse(json, (key, value) => {
|
|
2413
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
2414
|
+
const { [META]: clazz, [VALUE]: val, ...rest } = value;
|
|
2415
|
+
const constructor = this.classes[clazz];
|
|
2416
|
+
if (constructor) {
|
|
2417
|
+
return Object.assign(Object.create(constructor.prototype), rest);
|
|
2418
|
+
}
|
|
2419
|
+
if (clazz === "Date")
|
|
2420
|
+
return new Date(val);
|
|
2421
|
+
if (clazz === "Set")
|
|
2422
|
+
return new Set(val);
|
|
2423
|
+
if (clazz === "Map")
|
|
2424
|
+
return new Map(Object.entries(val));
|
|
2425
|
+
if (clazz === "bigint")
|
|
2426
|
+
return BigInt(val);
|
|
2427
|
+
if (clazz === "undefined")
|
|
2428
|
+
return void 0;
|
|
2429
|
+
return rest;
|
|
2430
|
+
}
|
|
2431
|
+
return value;
|
|
2432
|
+
});
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
const defaultSerializer = new Serializer();
|
|
2436
|
+
const serialize = (data) => {
|
|
2437
|
+
return defaultSerializer.toJSON(data);
|
|
2438
|
+
};
|
|
2439
|
+
const deserialize = (json) => {
|
|
2440
|
+
return defaultSerializer.fromJSON(json);
|
|
2441
|
+
};
|
|
2442
|
+
|
|
2443
|
+
function buildWorkerRunner(config) {
|
|
2444
|
+
return function xataWorker(name, _worker) {
|
|
2445
|
+
return async (...args) => {
|
|
2446
|
+
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
|
2447
|
+
const result = await fetch(url, {
|
|
2448
|
+
method: "POST",
|
|
2449
|
+
headers: { "Content-Type": "application/json" },
|
|
2450
|
+
body: serialize({ args })
|
|
2451
|
+
});
|
|
2452
|
+
const text = await result.text();
|
|
2453
|
+
return deserialize(text);
|
|
2454
|
+
};
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
|
|
1813
2458
|
class XataError extends Error {
|
|
1814
2459
|
constructor(message, status) {
|
|
1815
2460
|
super(message);
|
|
@@ -1817,5 +2462,5 @@ class XataError extends Error {
|
|
|
1817
2462
|
}
|
|
1818
2463
|
}
|
|
1819
2464
|
|
|
1820
|
-
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, Repository, RestRepository, SchemaPlugin, SearchPlugin, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite,
|
|
2465
|
+
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, applyBranchSchemaEdit, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequests, listMigrationRequestsCommits, lt, lte, mergeMigrationRequest, notExists, operationsByTag, patchDatabaseMetadata, pattern, previewBranchSchemaEdit, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, updateBranchMetadata, updateBranchSchema, updateColumn, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
|
|
1821
2466
|
//# sourceMappingURL=index.mjs.map
|