@xata.io/client 0.0.0-alpha.vee88fdc → 0.0.0-alpha.veec3be2
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 +243 -0
- package/README.md +273 -1
- package/Usage.md +449 -0
- package/dist/index.cjs +1392 -520
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1983 -376
- package/dist/index.mjs +1339 -521
- 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,146 +29,149 @@ 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);
|
|
40
|
+
}
|
|
41
|
+
function toBase64(value) {
|
|
42
|
+
try {
|
|
43
|
+
return btoa(value);
|
|
44
|
+
} catch (err) {
|
|
45
|
+
const buf = Buffer;
|
|
46
|
+
return buf.from(value).toString("base64");
|
|
47
|
+
}
|
|
12
48
|
}
|
|
13
49
|
|
|
14
|
-
function
|
|
50
|
+
function getEnvironment() {
|
|
15
51
|
try {
|
|
16
|
-
if (isObject(process) &&
|
|
17
|
-
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
|
+
};
|
|
18
60
|
}
|
|
19
61
|
} catch (err) {
|
|
20
62
|
}
|
|
21
63
|
try {
|
|
22
|
-
if (isObject(Deno) &&
|
|
23
|
-
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
|
+
};
|
|
24
72
|
}
|
|
25
73
|
} catch (err) {
|
|
26
74
|
}
|
|
75
|
+
return {
|
|
76
|
+
apiKey: getGlobalApiKey(),
|
|
77
|
+
databaseURL: getGlobalDatabaseURL(),
|
|
78
|
+
branch: getGlobalBranch(),
|
|
79
|
+
envBranch: void 0,
|
|
80
|
+
fallbackBranch: getGlobalFallbackBranch()
|
|
81
|
+
};
|
|
27
82
|
}
|
|
28
|
-
|
|
83
|
+
function getGlobalApiKey() {
|
|
29
84
|
try {
|
|
30
|
-
return
|
|
85
|
+
return XATA_API_KEY;
|
|
31
86
|
} catch (err) {
|
|
87
|
+
return void 0;
|
|
32
88
|
}
|
|
89
|
+
}
|
|
90
|
+
function getGlobalDatabaseURL() {
|
|
33
91
|
try {
|
|
34
|
-
|
|
35
|
-
const process2 = Deno.run({
|
|
36
|
-
cmd: ["git", "branch", "--show-current"],
|
|
37
|
-
stdout: "piped",
|
|
38
|
-
stderr: "piped"
|
|
39
|
-
});
|
|
40
|
-
return new TextDecoder().decode(await process2.output()).trim();
|
|
41
|
-
}
|
|
92
|
+
return XATA_DATABASE_URL;
|
|
42
93
|
} catch (err) {
|
|
94
|
+
return void 0;
|
|
43
95
|
}
|
|
44
96
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
throw new Error(`The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`);
|
|
97
|
+
function getGlobalBranch() {
|
|
98
|
+
try {
|
|
99
|
+
return XATA_BRANCH;
|
|
100
|
+
} catch (err) {
|
|
101
|
+
return void 0;
|
|
51
102
|
}
|
|
52
|
-
return fetchImpl;
|
|
53
103
|
}
|
|
54
|
-
|
|
55
|
-
const envBranchNames = [
|
|
56
|
-
"XATA_BRANCH",
|
|
57
|
-
"VERCEL_GIT_COMMIT_REF",
|
|
58
|
-
"CF_PAGES_BRANCH",
|
|
59
|
-
"BRANCH"
|
|
60
|
-
];
|
|
61
|
-
const defaultBranch = "main";
|
|
62
|
-
async function getCurrentBranchName(options) {
|
|
63
|
-
const env = await getBranchByEnvVariable();
|
|
64
|
-
if (env)
|
|
65
|
-
return env;
|
|
66
|
-
const branch = await getGitBranch();
|
|
67
|
-
if (!branch)
|
|
68
|
-
return defaultBranch;
|
|
69
|
-
const details = await getDatabaseBranch(branch, options);
|
|
70
|
-
if (details)
|
|
71
|
-
return branch;
|
|
72
|
-
return defaultBranch;
|
|
73
|
-
}
|
|
74
|
-
async function getCurrentBranchDetails(options) {
|
|
75
|
-
const env = await getBranchByEnvVariable();
|
|
76
|
-
if (env)
|
|
77
|
-
return getDatabaseBranch(env, options);
|
|
78
|
-
const branch = await getGitBranch();
|
|
79
|
-
if (!branch)
|
|
80
|
-
return getDatabaseBranch(defaultBranch, options);
|
|
81
|
-
const details = await getDatabaseBranch(branch, options);
|
|
82
|
-
if (details)
|
|
83
|
-
return details;
|
|
84
|
-
return getDatabaseBranch(defaultBranch, options);
|
|
85
|
-
}
|
|
86
|
-
async function getDatabaseBranch(branch, options) {
|
|
87
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
88
|
-
const apiKey = options?.apiKey || getAPIKey();
|
|
89
|
-
if (!databaseURL)
|
|
90
|
-
throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
|
|
91
|
-
if (!apiKey)
|
|
92
|
-
throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
|
|
93
|
-
const [protocol, , host, , database] = databaseURL.split("/");
|
|
94
|
-
const [workspace] = host.split(".");
|
|
95
|
-
const dbBranchName = `${database}:${branch}`;
|
|
104
|
+
function getGlobalFallbackBranch() {
|
|
96
105
|
try {
|
|
97
|
-
return
|
|
98
|
-
apiKey,
|
|
99
|
-
apiUrl: databaseURL,
|
|
100
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
|
101
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
|
102
|
-
pathParams: {
|
|
103
|
-
dbBranchName,
|
|
104
|
-
workspace
|
|
105
|
-
}
|
|
106
|
-
});
|
|
106
|
+
return XATA_FALLBACK_BRANCH;
|
|
107
107
|
} catch (err) {
|
|
108
|
-
|
|
109
|
-
return null;
|
|
110
|
-
throw err;
|
|
108
|
+
return void 0;
|
|
111
109
|
}
|
|
112
110
|
}
|
|
113
|
-
function
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
}
|
|
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"] };
|
|
120
116
|
try {
|
|
121
|
-
|
|
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();
|
|
122
122
|
} catch (err) {
|
|
123
123
|
}
|
|
124
|
-
}
|
|
125
|
-
function getDatabaseURL() {
|
|
126
124
|
try {
|
|
127
|
-
|
|
125
|
+
if (isObject(Deno)) {
|
|
126
|
+
const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
|
127
|
+
return new TextDecoder().decode(await process2.output()).trim();
|
|
128
|
+
}
|
|
128
129
|
} catch (err) {
|
|
129
|
-
return void 0;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
+
|
|
132
133
|
function getAPIKey() {
|
|
133
134
|
try {
|
|
134
|
-
|
|
135
|
+
const { apiKey } = getEnvironment();
|
|
136
|
+
return apiKey;
|
|
135
137
|
} catch (err) {
|
|
136
138
|
return void 0;
|
|
137
139
|
}
|
|
138
140
|
}
|
|
139
141
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
function getFetchImplementation(userFetch) {
|
|
143
|
+
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
|
144
|
+
const fetchImpl = userFetch ?? globalFetch;
|
|
145
|
+
if (!fetchImpl) {
|
|
146
|
+
throw new Error(
|
|
147
|
+
`Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
return fetchImpl;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const VERSION = "0.0.0-alpha.veec3be2";
|
|
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) {
|
|
142
162
|
super(getMessage(data));
|
|
143
163
|
this.status = status;
|
|
144
164
|
this.errors = isBulkError(data) ? data.errors : void 0;
|
|
165
|
+
this.requestId = requestId;
|
|
145
166
|
if (data instanceof Error) {
|
|
146
167
|
this.stack = data.stack;
|
|
147
168
|
this.cause = data.cause;
|
|
148
169
|
}
|
|
149
170
|
}
|
|
171
|
+
toString() {
|
|
172
|
+
const error = super.toString();
|
|
173
|
+
return `[${this.status}] (${this.requestId ?? "Unknown"}): ${error}`;
|
|
174
|
+
}
|
|
150
175
|
}
|
|
151
176
|
function isBulkError(error) {
|
|
152
177
|
return isObject(error) && Array.isArray(error.errors);
|
|
@@ -169,9 +194,17 @@ function getMessage(data) {
|
|
|
169
194
|
}
|
|
170
195
|
|
|
171
196
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
172
|
-
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();
|
|
173
203
|
const queryString = query.length > 0 ? `?${query}` : "";
|
|
174
|
-
|
|
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;
|
|
175
208
|
};
|
|
176
209
|
function buildBaseUrl({
|
|
177
210
|
path,
|
|
@@ -179,10 +212,10 @@ function buildBaseUrl({
|
|
|
179
212
|
apiUrl,
|
|
180
213
|
pathParams
|
|
181
214
|
}) {
|
|
182
|
-
if (
|
|
215
|
+
if (pathParams?.workspace === void 0)
|
|
183
216
|
return `${apiUrl}${path}`;
|
|
184
217
|
const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
|
185
|
-
return url.replace("{workspaceId}", pathParams.workspace);
|
|
218
|
+
return url.replace("{workspaceId}", String(pathParams.workspace));
|
|
186
219
|
}
|
|
187
220
|
function hostHeader(url) {
|
|
188
221
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
|
@@ -199,32 +232,61 @@ async function fetch$1({
|
|
|
199
232
|
fetchImpl,
|
|
200
233
|
apiKey,
|
|
201
234
|
apiUrl,
|
|
202
|
-
workspacesApiUrl
|
|
235
|
+
workspacesApiUrl,
|
|
236
|
+
trace
|
|
203
237
|
}) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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) {
|
|
220
285
|
try {
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
return jsonResponse;
|
|
224
|
-
}
|
|
225
|
-
throw new FetcherError(response.status, jsonResponse);
|
|
286
|
+
const { host, protocol } = new URL(url);
|
|
287
|
+
return { host, protocol };
|
|
226
288
|
} catch (error) {
|
|
227
|
-
|
|
289
|
+
return {};
|
|
228
290
|
}
|
|
229
291
|
}
|
|
230
292
|
|
|
@@ -283,6 +345,7 @@ const removeWorkspaceMember = (variables) => fetch$1({
|
|
|
283
345
|
...variables
|
|
284
346
|
});
|
|
285
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 });
|
|
286
349
|
const cancelWorkspaceMemberInvite = (variables) => fetch$1({
|
|
287
350
|
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
|
288
351
|
method: "delete",
|
|
@@ -318,16 +381,42 @@ const deleteDatabase = (variables) => fetch$1({
|
|
|
318
381
|
method: "delete",
|
|
319
382
|
...variables
|
|
320
383
|
});
|
|
321
|
-
const
|
|
322
|
-
url: "/
|
|
384
|
+
const getDatabaseMetadata = (variables) => fetch$1({
|
|
385
|
+
url: "/dbs/{dbName}/metadata",
|
|
386
|
+
method: "get",
|
|
387
|
+
...variables
|
|
388
|
+
});
|
|
389
|
+
const updateDatabaseMetadata = (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}",
|
|
323
402
|
method: "get",
|
|
324
403
|
...variables
|
|
325
404
|
});
|
|
326
|
-
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({
|
|
327
415
|
url: "/db/{dbBranchName}",
|
|
328
|
-
method: "
|
|
416
|
+
method: "get",
|
|
329
417
|
...variables
|
|
330
418
|
});
|
|
419
|
+
const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
|
|
331
420
|
const deleteBranch = (variables) => fetch$1({
|
|
332
421
|
url: "/db/{dbBranchName}",
|
|
333
422
|
method: "delete",
|
|
@@ -346,6 +435,16 @@ const getBranchMetadata = (variables) => fetch$1({
|
|
|
346
435
|
const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
|
|
347
436
|
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
|
348
437
|
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
|
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 });
|
|
440
|
+
const updateBranchSchema = (variables) => fetch$1({
|
|
441
|
+
url: "/db/{dbBranchName}/schema/update",
|
|
442
|
+
method: "post",
|
|
443
|
+
...variables
|
|
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 });
|
|
447
|
+
const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
|
|
349
448
|
const getBranchStats = (variables) => fetch$1({
|
|
350
449
|
url: "/db/{dbBranchName}/stats",
|
|
351
450
|
method: "get",
|
|
@@ -401,11 +500,7 @@ const updateColumn = (variables) => fetch$1({
|
|
|
401
500
|
method: "patch",
|
|
402
501
|
...variables
|
|
403
502
|
});
|
|
404
|
-
const insertRecord = (variables) => fetch$1({
|
|
405
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data",
|
|
406
|
-
method: "post",
|
|
407
|
-
...variables
|
|
408
|
-
});
|
|
503
|
+
const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
|
|
409
504
|
const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
|
|
410
505
|
const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
|
|
411
506
|
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
|
@@ -425,6 +520,11 @@ const queryTable = (variables) => fetch$1({
|
|
|
425
520
|
method: "post",
|
|
426
521
|
...variables
|
|
427
522
|
});
|
|
523
|
+
const searchTable = (variables) => fetch$1({
|
|
524
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
|
525
|
+
method: "post",
|
|
526
|
+
...variables
|
|
527
|
+
});
|
|
428
528
|
const searchBranch = (variables) => fetch$1({
|
|
429
529
|
url: "/db/{dbBranchName}/search",
|
|
430
530
|
method: "post",
|
|
@@ -442,11 +542,22 @@ const operationsByTag = {
|
|
|
442
542
|
updateWorkspaceMemberRole,
|
|
443
543
|
removeWorkspaceMember,
|
|
444
544
|
inviteWorkspaceMember,
|
|
545
|
+
updateWorkspaceMemberInvite,
|
|
445
546
|
cancelWorkspaceMemberInvite,
|
|
446
547
|
resendWorkspaceMemberInvite,
|
|
447
548
|
acceptWorkspaceMemberInvite
|
|
448
549
|
},
|
|
449
|
-
database: {
|
|
550
|
+
database: {
|
|
551
|
+
getDatabaseList,
|
|
552
|
+
createDatabase,
|
|
553
|
+
deleteDatabase,
|
|
554
|
+
getDatabaseMetadata,
|
|
555
|
+
updateDatabaseMetadata,
|
|
556
|
+
getGitBranchesMapping,
|
|
557
|
+
addGitBranchesEntry,
|
|
558
|
+
removeGitBranchesEntry,
|
|
559
|
+
resolveBranch
|
|
560
|
+
},
|
|
450
561
|
branch: {
|
|
451
562
|
getBranchList,
|
|
452
563
|
getBranchDetails,
|
|
@@ -454,10 +565,28 @@ const operationsByTag = {
|
|
|
454
565
|
deleteBranch,
|
|
455
566
|
updateBranchMetadata,
|
|
456
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: {
|
|
457
581
|
getBranchMigrationHistory,
|
|
458
582
|
executeBranchMigrationPlan,
|
|
459
583
|
getBranchMigrationPlan,
|
|
460
|
-
|
|
584
|
+
compareBranchWithUserSchema,
|
|
585
|
+
compareBranchSchemas,
|
|
586
|
+
updateBranchSchema,
|
|
587
|
+
previewBranchSchemaEdit,
|
|
588
|
+
applyBranchSchemaEdit,
|
|
589
|
+
getBranchSchemaHistory
|
|
461
590
|
},
|
|
462
591
|
table: {
|
|
463
592
|
createTable,
|
|
@@ -480,14 +609,15 @@ const operationsByTag = {
|
|
|
480
609
|
getRecord,
|
|
481
610
|
bulkInsertTableRecords,
|
|
482
611
|
queryTable,
|
|
612
|
+
searchTable,
|
|
483
613
|
searchBranch
|
|
484
614
|
}
|
|
485
615
|
};
|
|
486
616
|
|
|
487
617
|
function getHostUrl(provider, type) {
|
|
488
|
-
if (
|
|
618
|
+
if (isHostProviderAlias(provider)) {
|
|
489
619
|
return providers[provider][type];
|
|
490
|
-
} else if (
|
|
620
|
+
} else if (isHostProviderBuilder(provider)) {
|
|
491
621
|
return provider[type];
|
|
492
622
|
}
|
|
493
623
|
throw new Error("Invalid API provider");
|
|
@@ -502,77 +632,89 @@ const providers = {
|
|
|
502
632
|
workspaces: "https://{workspaceId}.staging.xatabase.co"
|
|
503
633
|
}
|
|
504
634
|
};
|
|
505
|
-
function
|
|
635
|
+
function isHostProviderAlias(alias) {
|
|
506
636
|
return isString(alias) && Object.keys(providers).includes(alias);
|
|
507
637
|
}
|
|
508
|
-
function
|
|
638
|
+
function isHostProviderBuilder(builder) {
|
|
509
639
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
|
510
640
|
}
|
|
511
641
|
|
|
512
|
-
var __accessCheck$
|
|
642
|
+
var __accessCheck$7 = (obj, member, msg) => {
|
|
513
643
|
if (!member.has(obj))
|
|
514
644
|
throw TypeError("Cannot " + msg);
|
|
515
645
|
};
|
|
516
|
-
var __privateGet$
|
|
517
|
-
__accessCheck$
|
|
646
|
+
var __privateGet$7 = (obj, member, getter) => {
|
|
647
|
+
__accessCheck$7(obj, member, "read from private field");
|
|
518
648
|
return getter ? getter.call(obj) : member.get(obj);
|
|
519
649
|
};
|
|
520
|
-
var __privateAdd$
|
|
650
|
+
var __privateAdd$7 = (obj, member, value) => {
|
|
521
651
|
if (member.has(obj))
|
|
522
652
|
throw TypeError("Cannot add the same private member more than once");
|
|
523
653
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
524
654
|
};
|
|
525
|
-
var __privateSet$
|
|
526
|
-
__accessCheck$
|
|
655
|
+
var __privateSet$7 = (obj, member, value, setter) => {
|
|
656
|
+
__accessCheck$7(obj, member, "write to private field");
|
|
527
657
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
528
658
|
return value;
|
|
529
659
|
};
|
|
530
660
|
var _extraProps, _namespaces;
|
|
531
661
|
class XataApiClient {
|
|
532
662
|
constructor(options = {}) {
|
|
533
|
-
__privateAdd$
|
|
534
|
-
__privateAdd$
|
|
663
|
+
__privateAdd$7(this, _extraProps, void 0);
|
|
664
|
+
__privateAdd$7(this, _namespaces, {});
|
|
535
665
|
const provider = options.host ?? "production";
|
|
536
|
-
const apiKey = options
|
|
666
|
+
const apiKey = options.apiKey ?? getAPIKey();
|
|
667
|
+
const trace = options.trace ?? defaultTrace;
|
|
537
668
|
if (!apiKey) {
|
|
538
669
|
throw new Error("Could not resolve a valid apiKey");
|
|
539
670
|
}
|
|
540
|
-
__privateSet$
|
|
671
|
+
__privateSet$7(this, _extraProps, {
|
|
541
672
|
apiUrl: getHostUrl(provider, "main"),
|
|
542
673
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
|
543
674
|
fetchImpl: getFetchImplementation(options.fetch),
|
|
544
|
-
apiKey
|
|
675
|
+
apiKey,
|
|
676
|
+
trace
|
|
545
677
|
});
|
|
546
678
|
}
|
|
547
679
|
get user() {
|
|
548
|
-
if (!__privateGet$
|
|
549
|
-
__privateGet$
|
|
550
|
-
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;
|
|
551
683
|
}
|
|
552
684
|
get workspaces() {
|
|
553
|
-
if (!__privateGet$
|
|
554
|
-
__privateGet$
|
|
555
|
-
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;
|
|
556
688
|
}
|
|
557
689
|
get databases() {
|
|
558
|
-
if (!__privateGet$
|
|
559
|
-
__privateGet$
|
|
560
|
-
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;
|
|
561
693
|
}
|
|
562
694
|
get branches() {
|
|
563
|
-
if (!__privateGet$
|
|
564
|
-
__privateGet$
|
|
565
|
-
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;
|
|
566
698
|
}
|
|
567
699
|
get tables() {
|
|
568
|
-
if (!__privateGet$
|
|
569
|
-
__privateGet$
|
|
570
|
-
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;
|
|
571
703
|
}
|
|
572
704
|
get records() {
|
|
573
|
-
if (!__privateGet$
|
|
574
|
-
__privateGet$
|
|
575
|
-
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;
|
|
576
718
|
}
|
|
577
719
|
}
|
|
578
720
|
_extraProps = new WeakMap();
|
|
@@ -664,6 +806,13 @@ class WorkspaceApi {
|
|
|
664
806
|
...this.extraProps
|
|
665
807
|
});
|
|
666
808
|
}
|
|
809
|
+
updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
|
|
810
|
+
return operationsByTag.workspaces.updateWorkspaceMemberInvite({
|
|
811
|
+
pathParams: { workspaceId, inviteId },
|
|
812
|
+
body: { role },
|
|
813
|
+
...this.extraProps
|
|
814
|
+
});
|
|
815
|
+
}
|
|
667
816
|
cancelWorkspaceMemberInvite(workspaceId, inviteId) {
|
|
668
817
|
return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
|
|
669
818
|
pathParams: { workspaceId, inviteId },
|
|
@@ -706,6 +855,46 @@ class DatabaseApi {
|
|
|
706
855
|
...this.extraProps
|
|
707
856
|
});
|
|
708
857
|
}
|
|
858
|
+
getDatabaseMetadata(workspace, dbName) {
|
|
859
|
+
return operationsByTag.database.getDatabaseMetadata({
|
|
860
|
+
pathParams: { workspace, dbName },
|
|
861
|
+
...this.extraProps
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
updateDatabaseMetadata(workspace, dbName, options = {}) {
|
|
865
|
+
return operationsByTag.database.updateDatabaseMetadata({
|
|
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
|
+
}
|
|
709
898
|
}
|
|
710
899
|
class BranchApi {
|
|
711
900
|
constructor(extraProps) {
|
|
@@ -723,10 +912,10 @@ class BranchApi {
|
|
|
723
912
|
...this.extraProps
|
|
724
913
|
});
|
|
725
914
|
}
|
|
726
|
-
createBranch(workspace, database, branch, from
|
|
915
|
+
createBranch(workspace, database, branch, from, options = {}) {
|
|
727
916
|
return operationsByTag.branch.createBranch({
|
|
728
917
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
729
|
-
queryParams: { from },
|
|
918
|
+
queryParams: isString(from) ? { from } : void 0,
|
|
730
919
|
body: options,
|
|
731
920
|
...this.extraProps
|
|
732
921
|
});
|
|
@@ -750,27 +939,6 @@ class BranchApi {
|
|
|
750
939
|
...this.extraProps
|
|
751
940
|
});
|
|
752
941
|
}
|
|
753
|
-
getBranchMigrationHistory(workspace, database, branch, options = {}) {
|
|
754
|
-
return operationsByTag.branch.getBranchMigrationHistory({
|
|
755
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
756
|
-
body: options,
|
|
757
|
-
...this.extraProps
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
|
|
761
|
-
return operationsByTag.branch.executeBranchMigrationPlan({
|
|
762
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
763
|
-
body: migrationPlan,
|
|
764
|
-
...this.extraProps
|
|
765
|
-
});
|
|
766
|
-
}
|
|
767
|
-
getBranchMigrationPlan(workspace, database, branch, schema) {
|
|
768
|
-
return operationsByTag.branch.getBranchMigrationPlan({
|
|
769
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
770
|
-
body: schema,
|
|
771
|
-
...this.extraProps
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
942
|
getBranchStats(workspace, database, branch) {
|
|
775
943
|
return operationsByTag.branch.getBranchStats({
|
|
776
944
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
@@ -851,9 +1019,10 @@ class RecordsApi {
|
|
|
851
1019
|
constructor(extraProps) {
|
|
852
1020
|
this.extraProps = extraProps;
|
|
853
1021
|
}
|
|
854
|
-
insertRecord(workspace, database, branch, tableName, record) {
|
|
1022
|
+
insertRecord(workspace, database, branch, tableName, record, options = {}) {
|
|
855
1023
|
return operationsByTag.records.insertRecord({
|
|
856
1024
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1025
|
+
queryParams: options,
|
|
857
1026
|
body: record,
|
|
858
1027
|
...this.extraProps
|
|
859
1028
|
});
|
|
@@ -882,21 +1051,24 @@ class RecordsApi {
|
|
|
882
1051
|
...this.extraProps
|
|
883
1052
|
});
|
|
884
1053
|
}
|
|
885
|
-
deleteRecord(workspace, database, branch, tableName, recordId) {
|
|
1054
|
+
deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
|
886
1055
|
return operationsByTag.records.deleteRecord({
|
|
887
1056
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1057
|
+
queryParams: options,
|
|
888
1058
|
...this.extraProps
|
|
889
1059
|
});
|
|
890
1060
|
}
|
|
891
1061
|
getRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
|
892
1062
|
return operationsByTag.records.getRecord({
|
|
893
1063
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1064
|
+
queryParams: options,
|
|
894
1065
|
...this.extraProps
|
|
895
1066
|
});
|
|
896
1067
|
}
|
|
897
|
-
bulkInsertTableRecords(workspace, database, branch, tableName, records) {
|
|
1068
|
+
bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
|
|
898
1069
|
return operationsByTag.records.bulkInsertTableRecords({
|
|
899
1070
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1071
|
+
queryParams: options,
|
|
900
1072
|
body: { records },
|
|
901
1073
|
...this.extraProps
|
|
902
1074
|
});
|
|
@@ -908,6 +1080,13 @@ class RecordsApi {
|
|
|
908
1080
|
...this.extraProps
|
|
909
1081
|
});
|
|
910
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
|
+
}
|
|
911
1090
|
searchBranch(workspace, database, branch, query) {
|
|
912
1091
|
return operationsByTag.records.searchBranch({
|
|
913
1092
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
@@ -916,105 +1095,279 @@ class RecordsApi {
|
|
|
916
1095
|
});
|
|
917
1096
|
}
|
|
918
1097
|
}
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
const { fetchImpl, apiKey } = await options.getFetchProps();
|
|
923
|
-
return new XataApiClient({ fetch: fetchImpl, apiKey });
|
|
1098
|
+
class MigrationRequestsApi {
|
|
1099
|
+
constructor(extraProps) {
|
|
1100
|
+
this.extraProps = extraProps;
|
|
924
1101
|
}
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
if (!member.has(obj))
|
|
932
|
-
throw TypeError("Cannot " + msg);
|
|
933
|
-
};
|
|
934
|
-
var __privateGet$4 = (obj, member, getter) => {
|
|
935
|
-
__accessCheck$5(obj, member, "read from private field");
|
|
936
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
937
|
-
};
|
|
938
|
-
var __privateAdd$5 = (obj, member, value) => {
|
|
939
|
-
if (member.has(obj))
|
|
940
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
941
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
942
|
-
};
|
|
943
|
-
var __privateSet$3 = (obj, member, value, setter) => {
|
|
944
|
-
__accessCheck$5(obj, member, "write to private field");
|
|
945
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
946
|
-
return value;
|
|
947
|
-
};
|
|
948
|
-
var _query;
|
|
949
|
-
class Page {
|
|
950
|
-
constructor(query, meta, records = []) {
|
|
951
|
-
__privateAdd$5(this, _query, void 0);
|
|
952
|
-
__privateSet$3(this, _query, query);
|
|
953
|
-
this.meta = meta;
|
|
954
|
-
this.records = records;
|
|
1102
|
+
listMigrationRequests(workspace, database, options = {}) {
|
|
1103
|
+
return operationsByTag.migrationRequests.listMigrationRequests({
|
|
1104
|
+
pathParams: { workspace, dbName: database },
|
|
1105
|
+
body: options,
|
|
1106
|
+
...this.extraProps
|
|
1107
|
+
});
|
|
955
1108
|
}
|
|
956
|
-
|
|
957
|
-
return
|
|
1109
|
+
createMigrationRequest(workspace, database, options) {
|
|
1110
|
+
return operationsByTag.migrationRequests.createMigrationRequest({
|
|
1111
|
+
pathParams: { workspace, dbName: database },
|
|
1112
|
+
body: options,
|
|
1113
|
+
...this.extraProps
|
|
1114
|
+
});
|
|
958
1115
|
}
|
|
959
|
-
|
|
960
|
-
return
|
|
1116
|
+
getMigrationRequest(workspace, database, migrationRequest) {
|
|
1117
|
+
return operationsByTag.migrationRequests.getMigrationRequest({
|
|
1118
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1119
|
+
...this.extraProps
|
|
1120
|
+
});
|
|
961
1121
|
}
|
|
962
|
-
|
|
963
|
-
return
|
|
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
|
+
});
|
|
964
1128
|
}
|
|
965
|
-
|
|
966
|
-
return
|
|
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
|
+
});
|
|
967
1135
|
}
|
|
968
|
-
|
|
969
|
-
return
|
|
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
|
+
}
|
|
1223
|
+
|
|
1224
|
+
class XataApiPlugin {
|
|
1225
|
+
async build(options) {
|
|
1226
|
+
const { fetchImpl, apiKey } = await options.getFetchProps();
|
|
1227
|
+
return new XataApiClient({ fetch: fetchImpl, apiKey });
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
class XataPlugin {
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
|
1235
|
+
if (!member.has(obj))
|
|
1236
|
+
throw TypeError("Cannot " + msg);
|
|
1237
|
+
};
|
|
1238
|
+
var __privateGet$6 = (obj, member, getter) => {
|
|
1239
|
+
__accessCheck$6(obj, member, "read from private field");
|
|
1240
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
1241
|
+
};
|
|
1242
|
+
var __privateAdd$6 = (obj, member, value) => {
|
|
1243
|
+
if (member.has(obj))
|
|
1244
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
1245
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1246
|
+
};
|
|
1247
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
|
1248
|
+
__accessCheck$6(obj, member, "write to private field");
|
|
1249
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1250
|
+
return value;
|
|
1251
|
+
};
|
|
1252
|
+
var _query, _page;
|
|
1253
|
+
class Page {
|
|
1254
|
+
constructor(query, meta, records = []) {
|
|
1255
|
+
__privateAdd$6(this, _query, void 0);
|
|
1256
|
+
__privateSet$6(this, _query, query);
|
|
1257
|
+
this.meta = meta;
|
|
1258
|
+
this.records = new RecordArray(this, records);
|
|
1259
|
+
}
|
|
1260
|
+
async nextPage(size, offset) {
|
|
1261
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
|
1262
|
+
}
|
|
1263
|
+
async previousPage(size, offset) {
|
|
1264
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
|
1265
|
+
}
|
|
1266
|
+
async firstPage(size, offset) {
|
|
1267
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
|
|
1268
|
+
}
|
|
1269
|
+
async lastPage(size, offset) {
|
|
1270
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
|
|
1271
|
+
}
|
|
1272
|
+
hasNextPage() {
|
|
1273
|
+
return this.meta.page.more;
|
|
970
1274
|
}
|
|
971
1275
|
}
|
|
972
1276
|
_query = new WeakMap();
|
|
973
1277
|
const PAGINATION_MAX_SIZE = 200;
|
|
974
|
-
const PAGINATION_DEFAULT_SIZE =
|
|
1278
|
+
const PAGINATION_DEFAULT_SIZE = 20;
|
|
975
1279
|
const PAGINATION_MAX_OFFSET = 800;
|
|
976
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();
|
|
977
1328
|
|
|
978
|
-
var __accessCheck$
|
|
1329
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
979
1330
|
if (!member.has(obj))
|
|
980
1331
|
throw TypeError("Cannot " + msg);
|
|
981
1332
|
};
|
|
982
|
-
var __privateGet$
|
|
983
|
-
__accessCheck$
|
|
1333
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
1334
|
+
__accessCheck$5(obj, member, "read from private field");
|
|
984
1335
|
return getter ? getter.call(obj) : member.get(obj);
|
|
985
1336
|
};
|
|
986
|
-
var __privateAdd$
|
|
1337
|
+
var __privateAdd$5 = (obj, member, value) => {
|
|
987
1338
|
if (member.has(obj))
|
|
988
1339
|
throw TypeError("Cannot add the same private member more than once");
|
|
989
1340
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
990
1341
|
};
|
|
991
|
-
var __privateSet$
|
|
992
|
-
__accessCheck$
|
|
1342
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
|
1343
|
+
__accessCheck$5(obj, member, "write to private field");
|
|
993
1344
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
994
1345
|
return value;
|
|
995
1346
|
};
|
|
996
1347
|
var _table$1, _repository, _data;
|
|
997
1348
|
const _Query = class {
|
|
998
|
-
constructor(repository, table, data,
|
|
999
|
-
__privateAdd$
|
|
1000
|
-
__privateAdd$
|
|
1001
|
-
__privateAdd$
|
|
1349
|
+
constructor(repository, table, data, rawParent) {
|
|
1350
|
+
__privateAdd$5(this, _table$1, void 0);
|
|
1351
|
+
__privateAdd$5(this, _repository, void 0);
|
|
1352
|
+
__privateAdd$5(this, _data, { filter: {} });
|
|
1002
1353
|
this.meta = { page: { cursor: "start", more: true } };
|
|
1003
|
-
this.records = [];
|
|
1004
|
-
__privateSet$
|
|
1354
|
+
this.records = new RecordArray(this, []);
|
|
1355
|
+
__privateSet$5(this, _table$1, table);
|
|
1005
1356
|
if (repository) {
|
|
1006
|
-
__privateSet$
|
|
1357
|
+
__privateSet$5(this, _repository, repository);
|
|
1007
1358
|
} else {
|
|
1008
|
-
__privateSet$
|
|
1359
|
+
__privateSet$5(this, _repository, this);
|
|
1009
1360
|
}
|
|
1010
|
-
|
|
1011
|
-
__privateGet$
|
|
1012
|
-
__privateGet$
|
|
1013
|
-
__privateGet$
|
|
1014
|
-
__privateGet$
|
|
1015
|
-
__privateGet$
|
|
1016
|
-
__privateGet$
|
|
1017
|
-
__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;
|
|
1018
1371
|
this.any = this.any.bind(this);
|
|
1019
1372
|
this.all = this.all.bind(this);
|
|
1020
1373
|
this.not = this.not.bind(this);
|
|
@@ -1025,75 +1378,101 @@ const _Query = class {
|
|
|
1025
1378
|
Object.defineProperty(this, "repository", { enumerable: false });
|
|
1026
1379
|
}
|
|
1027
1380
|
getQueryOptions() {
|
|
1028
|
-
return __privateGet$
|
|
1381
|
+
return __privateGet$5(this, _data);
|
|
1382
|
+
}
|
|
1383
|
+
key() {
|
|
1384
|
+
const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$5(this, _data);
|
|
1385
|
+
const key = JSON.stringify({ columns, filter, sort, pagination });
|
|
1386
|
+
return toBase64(key);
|
|
1029
1387
|
}
|
|
1030
1388
|
any(...queries) {
|
|
1031
1389
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
1032
|
-
return new _Query(__privateGet$
|
|
1390
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
|
1033
1391
|
}
|
|
1034
1392
|
all(...queries) {
|
|
1035
1393
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
1036
|
-
return new _Query(__privateGet$
|
|
1394
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
|
1037
1395
|
}
|
|
1038
1396
|
not(...queries) {
|
|
1039
1397
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
1040
|
-
return new _Query(__privateGet$
|
|
1398
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
|
1041
1399
|
}
|
|
1042
1400
|
none(...queries) {
|
|
1043
1401
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
1044
|
-
return new _Query(__privateGet$
|
|
1402
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
|
1045
1403
|
}
|
|
1046
1404
|
filter(a, b) {
|
|
1047
1405
|
if (arguments.length === 1) {
|
|
1048
|
-
const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
|
|
1049
|
-
const $all = compact([__privateGet$
|
|
1050
|
-
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));
|
|
1051
1409
|
} else {
|
|
1052
|
-
const
|
|
1053
|
-
|
|
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));
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
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 };
|
|
1054
1419
|
}
|
|
1420
|
+
return value;
|
|
1055
1421
|
}
|
|
1056
|
-
sort(column, direction) {
|
|
1057
|
-
const originalSort = [__privateGet$
|
|
1422
|
+
sort(column, direction = "asc") {
|
|
1423
|
+
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
|
1058
1424
|
const sort = [...originalSort, { column, direction }];
|
|
1059
|
-
return new _Query(__privateGet$
|
|
1425
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
|
1060
1426
|
}
|
|
1061
1427
|
select(columns) {
|
|
1062
|
-
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
|
+
);
|
|
1063
1434
|
}
|
|
1064
1435
|
getPaginated(options = {}) {
|
|
1065
|
-
const query = new _Query(__privateGet$
|
|
1066
|
-
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);
|
|
1067
1438
|
}
|
|
1068
1439
|
async *[Symbol.asyncIterator]() {
|
|
1069
|
-
for await (const [record] of this.getIterator(1)) {
|
|
1440
|
+
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
|
1070
1441
|
yield record;
|
|
1071
1442
|
}
|
|
1072
1443
|
}
|
|
1073
|
-
async *getIterator(
|
|
1074
|
-
|
|
1075
|
-
let
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
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;
|
|
1081
1453
|
}
|
|
1082
1454
|
}
|
|
1083
1455
|
async getMany(options = {}) {
|
|
1084
|
-
const
|
|
1085
|
-
|
|
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;
|
|
1086
1461
|
}
|
|
1087
|
-
async getAll(
|
|
1462
|
+
async getAll(options = {}) {
|
|
1463
|
+
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
|
1088
1464
|
const results = [];
|
|
1089
|
-
for await (const page of this.getIterator(
|
|
1465
|
+
for await (const page of this.getIterator({ ...rest, batchSize })) {
|
|
1090
1466
|
results.push(...page);
|
|
1091
1467
|
}
|
|
1092
1468
|
return results;
|
|
1093
1469
|
}
|
|
1094
|
-
async
|
|
1095
|
-
const records = await this.getMany({ ...options,
|
|
1096
|
-
return records[0]
|
|
1470
|
+
async getFirst(options = {}) {
|
|
1471
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
|
1472
|
+
return records[0] ?? null;
|
|
1473
|
+
}
|
|
1474
|
+
cache(ttl) {
|
|
1475
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
|
1097
1476
|
}
|
|
1098
1477
|
nextPage(size, offset) {
|
|
1099
1478
|
return this.firstPage(size, offset);
|
|
@@ -1102,10 +1481,10 @@ const _Query = class {
|
|
|
1102
1481
|
return this.firstPage(size, offset);
|
|
1103
1482
|
}
|
|
1104
1483
|
firstPage(size, offset) {
|
|
1105
|
-
return this.getPaginated({
|
|
1484
|
+
return this.getPaginated({ pagination: { size, offset } });
|
|
1106
1485
|
}
|
|
1107
1486
|
lastPage(size, offset) {
|
|
1108
|
-
return this.getPaginated({
|
|
1487
|
+
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
|
1109
1488
|
}
|
|
1110
1489
|
hasNextPage() {
|
|
1111
1490
|
return this.meta.page.more;
|
|
@@ -1115,12 +1494,20 @@ let Query = _Query;
|
|
|
1115
1494
|
_table$1 = new WeakMap();
|
|
1116
1495
|
_repository = new WeakMap();
|
|
1117
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
|
+
}
|
|
1118
1503
|
|
|
1119
1504
|
function isIdentifiable(x) {
|
|
1120
1505
|
return isObject(x) && isString(x?.id);
|
|
1121
1506
|
}
|
|
1122
1507
|
function isXataRecord(x) {
|
|
1123
|
-
|
|
1508
|
+
const record = x;
|
|
1509
|
+
const metadata = record?.getMetadata();
|
|
1510
|
+
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
|
1124
1511
|
}
|
|
1125
1512
|
|
|
1126
1513
|
function isSortFilterString(value) {
|
|
@@ -1146,249 +1533,376 @@ function buildSortFilter(filter) {
|
|
|
1146
1533
|
}
|
|
1147
1534
|
}
|
|
1148
1535
|
|
|
1149
|
-
var __accessCheck$
|
|
1536
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
1150
1537
|
if (!member.has(obj))
|
|
1151
1538
|
throw TypeError("Cannot " + msg);
|
|
1152
1539
|
};
|
|
1153
|
-
var __privateGet$
|
|
1154
|
-
__accessCheck$
|
|
1540
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
1541
|
+
__accessCheck$4(obj, member, "read from private field");
|
|
1155
1542
|
return getter ? getter.call(obj) : member.get(obj);
|
|
1156
1543
|
};
|
|
1157
|
-
var __privateAdd$
|
|
1544
|
+
var __privateAdd$4 = (obj, member, value) => {
|
|
1158
1545
|
if (member.has(obj))
|
|
1159
1546
|
throw TypeError("Cannot add the same private member more than once");
|
|
1160
1547
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1161
1548
|
};
|
|
1162
|
-
var __privateSet$
|
|
1163
|
-
__accessCheck$
|
|
1549
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
1550
|
+
__accessCheck$4(obj, member, "write to private field");
|
|
1164
1551
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1165
1552
|
return value;
|
|
1166
1553
|
};
|
|
1167
1554
|
var __privateMethod$2 = (obj, member, method) => {
|
|
1168
|
-
__accessCheck$
|
|
1555
|
+
__accessCheck$4(obj, member, "access private method");
|
|
1169
1556
|
return method;
|
|
1170
1557
|
};
|
|
1171
|
-
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;
|
|
1172
1559
|
class Repository extends Query {
|
|
1173
1560
|
}
|
|
1174
1561
|
class RestRepository extends Query {
|
|
1175
1562
|
constructor(options) {
|
|
1176
|
-
super(
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
__privateAdd$
|
|
1182
|
-
__privateAdd$
|
|
1183
|
-
__privateAdd$
|
|
1184
|
-
__privateAdd$
|
|
1185
|
-
__privateAdd$
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
this
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
return
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
throw new Error("Invalid arguments for create method");
|
|
1209
|
-
}
|
|
1210
|
-
async read(recordId) {
|
|
1211
|
-
const fetchProps = await __privateGet$2(this, _getFetchProps).call(this);
|
|
1212
|
-
try {
|
|
1213
|
-
const response = await getRecord({
|
|
1214
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$2(this, _table), recordId },
|
|
1215
|
-
...fetchProps
|
|
1563
|
+
super(
|
|
1564
|
+
null,
|
|
1565
|
+
{ name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
|
|
1566
|
+
{}
|
|
1567
|
+
);
|
|
1568
|
+
__privateAdd$4(this, _insertRecordWithoutId);
|
|
1569
|
+
__privateAdd$4(this, _insertRecordWithId);
|
|
1570
|
+
__privateAdd$4(this, _bulkInsertTableRecords);
|
|
1571
|
+
__privateAdd$4(this, _updateRecordWithID);
|
|
1572
|
+
__privateAdd$4(this, _upsertRecordWithID);
|
|
1573
|
+
__privateAdd$4(this, _deleteRecord);
|
|
1574
|
+
__privateAdd$4(this, _setCacheQuery);
|
|
1575
|
+
__privateAdd$4(this, _getCacheQuery);
|
|
1576
|
+
__privateAdd$4(this, _getSchemaTables$1);
|
|
1577
|
+
__privateAdd$4(this, _table, void 0);
|
|
1578
|
+
__privateAdd$4(this, _getFetchProps, void 0);
|
|
1579
|
+
__privateAdd$4(this, _db, void 0);
|
|
1580
|
+
__privateAdd$4(this, _cache, void 0);
|
|
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
|
|
1216
1595
|
});
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
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);
|
|
1221
1605
|
}
|
|
1222
|
-
|
|
1223
|
-
|
|
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
|
+
});
|
|
1224
1624
|
}
|
|
1225
|
-
async
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
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);
|
|
1229
1638
|
}
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
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
|
+
});
|
|
1239
1664
|
}
|
|
1240
|
-
async
|
|
1241
|
-
|
|
1242
|
-
if (a
|
|
1243
|
-
|
|
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)));
|
|
1244
1675
|
}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
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
|
+
});
|
|
1254
1686
|
}
|
|
1255
|
-
async
|
|
1256
|
-
|
|
1257
|
-
if (
|
|
1258
|
-
|
|
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)));
|
|
1259
1697
|
}
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
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
|
+
});
|
|
1272
1727
|
}
|
|
1273
1728
|
async search(query, options = {}) {
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
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));
|
|
1279
1745
|
});
|
|
1280
|
-
return records.map((item) => initObject(this.db, __privateGet$2(this, _links), __privateGet$2(this, _table), item));
|
|
1281
1746
|
}
|
|
1282
1747
|
async query(query) {
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
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);
|
|
1295
1769
|
});
|
|
1296
|
-
const records = objects.map((record) => initObject(this.db, __privateGet$2(this, _links), __privateGet$2(this, _table), record));
|
|
1297
|
-
return new Page(query, meta, records);
|
|
1298
1770
|
}
|
|
1299
1771
|
}
|
|
1300
1772
|
_table = new WeakMap();
|
|
1301
|
-
_links = new WeakMap();
|
|
1302
1773
|
_getFetchProps = new WeakMap();
|
|
1774
|
+
_db = new WeakMap();
|
|
1775
|
+
_cache = new WeakMap();
|
|
1776
|
+
_schemaTables$2 = new WeakMap();
|
|
1777
|
+
_trace = new WeakMap();
|
|
1303
1778
|
_insertRecordWithoutId = new WeakSet();
|
|
1304
|
-
insertRecordWithoutId_fn = async function(object) {
|
|
1305
|
-
const fetchProps = await __privateGet$
|
|
1779
|
+
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1780
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1306
1781
|
const record = transformObjectLinks(object);
|
|
1307
1782
|
const response = await insertRecord({
|
|
1308
1783
|
pathParams: {
|
|
1309
1784
|
workspace: "{workspaceId}",
|
|
1310
1785
|
dbBranchName: "{dbBranch}",
|
|
1311
|
-
tableName: __privateGet$
|
|
1786
|
+
tableName: __privateGet$4(this, _table)
|
|
1312
1787
|
},
|
|
1788
|
+
queryParams: { columns },
|
|
1313
1789
|
body: record,
|
|
1314
1790
|
...fetchProps
|
|
1315
1791
|
});
|
|
1316
|
-
const
|
|
1317
|
-
|
|
1318
|
-
throw new Error("The server failed to save the record");
|
|
1319
|
-
}
|
|
1320
|
-
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);
|
|
1321
1794
|
};
|
|
1322
1795
|
_insertRecordWithId = new WeakSet();
|
|
1323
|
-
insertRecordWithId_fn = async function(recordId, object) {
|
|
1324
|
-
const fetchProps = await __privateGet$
|
|
1796
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
|
1797
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1325
1798
|
const record = transformObjectLinks(object);
|
|
1326
1799
|
const response = await insertRecordWithID({
|
|
1327
1800
|
pathParams: {
|
|
1328
1801
|
workspace: "{workspaceId}",
|
|
1329
1802
|
dbBranchName: "{dbBranch}",
|
|
1330
|
-
tableName: __privateGet$
|
|
1803
|
+
tableName: __privateGet$4(this, _table),
|
|
1331
1804
|
recordId
|
|
1332
1805
|
},
|
|
1333
1806
|
body: record,
|
|
1334
|
-
queryParams: { createOnly: true },
|
|
1807
|
+
queryParams: { createOnly: true, columns },
|
|
1335
1808
|
...fetchProps
|
|
1336
1809
|
});
|
|
1337
|
-
const
|
|
1338
|
-
|
|
1339
|
-
throw new Error("The server failed to save the record");
|
|
1340
|
-
}
|
|
1341
|
-
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);
|
|
1342
1812
|
};
|
|
1343
1813
|
_bulkInsertTableRecords = new WeakSet();
|
|
1344
|
-
bulkInsertTableRecords_fn = async function(objects) {
|
|
1345
|
-
const fetchProps = await __privateGet$
|
|
1814
|
+
bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
|
1815
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1346
1816
|
const records = objects.map((object) => transformObjectLinks(object));
|
|
1347
1817
|
const response = await bulkInsertTableRecords({
|
|
1348
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
|
1818
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
|
1819
|
+
queryParams: { columns },
|
|
1349
1820
|
body: { records },
|
|
1350
1821
|
...fetchProps
|
|
1351
1822
|
});
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
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");
|
|
1355
1825
|
}
|
|
1356
|
-
|
|
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));
|
|
1357
1828
|
};
|
|
1358
1829
|
_updateRecordWithID = new WeakSet();
|
|
1359
|
-
updateRecordWithID_fn = async function(recordId, object) {
|
|
1360
|
-
const fetchProps = await __privateGet$
|
|
1830
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
1831
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1361
1832
|
const record = transformObjectLinks(object);
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
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
|
+
}
|
|
1371
1848
|
};
|
|
1372
1849
|
_upsertRecordWithID = new WeakSet();
|
|
1373
|
-
upsertRecordWithID_fn = async function(recordId, object) {
|
|
1374
|
-
const fetchProps = await __privateGet$
|
|
1850
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
1851
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1375
1852
|
const response = await upsertRecordWithID({
|
|
1376
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
|
1853
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
|
1854
|
+
queryParams: { columns },
|
|
1377
1855
|
body: object,
|
|
1378
1856
|
...fetchProps
|
|
1379
1857
|
});
|
|
1380
|
-
const
|
|
1381
|
-
|
|
1382
|
-
throw new Error("The server failed to save the record");
|
|
1383
|
-
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);
|
|
1384
1860
|
};
|
|
1385
1861
|
_deleteRecord = new WeakSet();
|
|
1386
|
-
deleteRecord_fn = async function(recordId) {
|
|
1387
|
-
const fetchProps = await __privateGet$
|
|
1388
|
-
|
|
1389
|
-
|
|
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;
|
|
1877
|
+
}
|
|
1878
|
+
};
|
|
1879
|
+
_setCacheQuery = new WeakSet();
|
|
1880
|
+
setCacheQuery_fn = async function(query, meta, records) {
|
|
1881
|
+
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
|
1882
|
+
};
|
|
1883
|
+
_getCacheQuery = new WeakSet();
|
|
1884
|
+
getCacheQuery_fn = async function(query) {
|
|
1885
|
+
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
|
1886
|
+
const result = await __privateGet$4(this, _cache).get(key);
|
|
1887
|
+
if (!result)
|
|
1888
|
+
return null;
|
|
1889
|
+
const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
|
|
1890
|
+
if (ttl < 0)
|
|
1891
|
+
return null;
|
|
1892
|
+
const hasExpired = result.date.getTime() + ttl < Date.now();
|
|
1893
|
+
return hasExpired ? null : result;
|
|
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}" },
|
|
1390
1902
|
...fetchProps
|
|
1391
1903
|
});
|
|
1904
|
+
__privateSet$4(this, _schemaTables$2, schema.tables);
|
|
1905
|
+
return schema.tables;
|
|
1392
1906
|
};
|
|
1393
1907
|
const transformObjectLinks = (object) => {
|
|
1394
1908
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
|
@@ -1397,45 +1911,139 @@ const transformObjectLinks = (object) => {
|
|
|
1397
1911
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
|
1398
1912
|
}, {});
|
|
1399
1913
|
};
|
|
1400
|
-
const initObject = (db,
|
|
1914
|
+
const initObject = (db, schemaTables, table, object) => {
|
|
1401
1915
|
const result = {};
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
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
|
+
}
|
|
1409
1942
|
}
|
|
1410
1943
|
}
|
|
1411
|
-
result.read = function() {
|
|
1412
|
-
return db[table].read(result["id"]);
|
|
1944
|
+
result.read = function(columns2) {
|
|
1945
|
+
return db[table].read(result["id"], columns2);
|
|
1413
1946
|
};
|
|
1414
|
-
result.update = function(data) {
|
|
1415
|
-
return db[table].update(result["id"], data);
|
|
1947
|
+
result.update = function(data, columns2) {
|
|
1948
|
+
return db[table].update(result["id"], data, columns2);
|
|
1416
1949
|
};
|
|
1417
1950
|
result.delete = function() {
|
|
1418
1951
|
return db[table].delete(result["id"]);
|
|
1419
1952
|
};
|
|
1420
|
-
|
|
1953
|
+
result.getMetadata = function() {
|
|
1954
|
+
return xata;
|
|
1955
|
+
};
|
|
1956
|
+
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
|
1421
1957
|
Object.defineProperty(result, prop, { enumerable: false });
|
|
1422
1958
|
}
|
|
1423
1959
|
Object.freeze(result);
|
|
1424
1960
|
return result;
|
|
1425
1961
|
};
|
|
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;
|
|
1977
|
+
}
|
|
1426
1978
|
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1979
|
+
var __accessCheck$3 = (obj, member, msg) => {
|
|
1980
|
+
if (!member.has(obj))
|
|
1981
|
+
throw TypeError("Cannot " + msg);
|
|
1982
|
+
};
|
|
1983
|
+
var __privateGet$3 = (obj, member, getter) => {
|
|
1984
|
+
__accessCheck$3(obj, member, "read from private field");
|
|
1985
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
1986
|
+
};
|
|
1987
|
+
var __privateAdd$3 = (obj, member, value) => {
|
|
1988
|
+
if (member.has(obj))
|
|
1989
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
1990
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1991
|
+
};
|
|
1992
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
|
1993
|
+
__accessCheck$3(obj, member, "write to private field");
|
|
1994
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1995
|
+
return value;
|
|
1996
|
+
};
|
|
1997
|
+
var _map;
|
|
1998
|
+
class SimpleCache {
|
|
1999
|
+
constructor(options = {}) {
|
|
2000
|
+
__privateAdd$3(this, _map, void 0);
|
|
2001
|
+
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
|
2002
|
+
this.capacity = options.max ?? 500;
|
|
2003
|
+
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
|
2004
|
+
}
|
|
2005
|
+
async getAll() {
|
|
2006
|
+
return Object.fromEntries(__privateGet$3(this, _map));
|
|
2007
|
+
}
|
|
2008
|
+
async get(key) {
|
|
2009
|
+
return __privateGet$3(this, _map).get(key) ?? null;
|
|
2010
|
+
}
|
|
2011
|
+
async set(key, value) {
|
|
2012
|
+
await this.delete(key);
|
|
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;
|
|
2016
|
+
await this.delete(leastRecentlyUsed);
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
async delete(key) {
|
|
2020
|
+
__privateGet$3(this, _map).delete(key);
|
|
2021
|
+
}
|
|
2022
|
+
async clear() {
|
|
2023
|
+
return __privateGet$3(this, _map).clear();
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
_map = new WeakMap();
|
|
2027
|
+
|
|
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;
|
|
1433
2040
|
const exists = (column) => ({ $exists: column });
|
|
1434
2041
|
const notExists = (column) => ({ $notExists: column });
|
|
1435
2042
|
const startsWith = (value) => ({ $startsWith: value });
|
|
1436
2043
|
const endsWith = (value) => ({ $endsWith: value });
|
|
1437
2044
|
const pattern = (value) => ({ $pattern: value });
|
|
1438
2045
|
const is = (value) => ({ $is: value });
|
|
2046
|
+
const equals = is;
|
|
1439
2047
|
const isNot = (value) => ({ $isNot: value });
|
|
1440
2048
|
const contains = (value) => ({ $contains: value });
|
|
1441
2049
|
const includes = (value) => ({ $includes: value });
|
|
@@ -1447,7 +2055,7 @@ var __accessCheck$2 = (obj, member, msg) => {
|
|
|
1447
2055
|
if (!member.has(obj))
|
|
1448
2056
|
throw TypeError("Cannot " + msg);
|
|
1449
2057
|
};
|
|
1450
|
-
var __privateGet$
|
|
2058
|
+
var __privateGet$2 = (obj, member, getter) => {
|
|
1451
2059
|
__accessCheck$2(obj, member, "read from private field");
|
|
1452
2060
|
return getter ? getter.call(obj) : member.get(obj);
|
|
1453
2061
|
};
|
|
@@ -1456,88 +2064,205 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
|
1456
2064
|
throw TypeError("Cannot add the same private member more than once");
|
|
1457
2065
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1458
2066
|
};
|
|
1459
|
-
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;
|
|
1460
2073
|
class SchemaPlugin extends XataPlugin {
|
|
1461
|
-
constructor(
|
|
2074
|
+
constructor(schemaTables) {
|
|
1462
2075
|
super();
|
|
1463
|
-
this.links = links;
|
|
1464
2076
|
__privateAdd$2(this, _tables, {});
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
const db = new Proxy(
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
2077
|
+
__privateAdd$2(this, _schemaTables$1, void 0);
|
|
2078
|
+
__privateSet$2(this, _schemaTables$1, schemaTables);
|
|
2079
|
+
}
|
|
2080
|
+
build(pluginOptions) {
|
|
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];
|
|
2091
|
+
}
|
|
1476
2092
|
}
|
|
1477
|
-
|
|
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) });
|
|
2097
|
+
}
|
|
1478
2098
|
return db;
|
|
1479
2099
|
}
|
|
1480
2100
|
}
|
|
1481
2101
|
_tables = new WeakMap();
|
|
2102
|
+
_schemaTables$1 = new WeakMap();
|
|
1482
2103
|
|
|
1483
2104
|
var __accessCheck$1 = (obj, member, msg) => {
|
|
1484
2105
|
if (!member.has(obj))
|
|
1485
2106
|
throw TypeError("Cannot " + msg);
|
|
1486
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
|
+
};
|
|
1487
2112
|
var __privateAdd$1 = (obj, member, value) => {
|
|
1488
2113
|
if (member.has(obj))
|
|
1489
2114
|
throw TypeError("Cannot add the same private member more than once");
|
|
1490
2115
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1491
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
|
+
};
|
|
1492
2122
|
var __privateMethod$1 = (obj, member, method) => {
|
|
1493
2123
|
__accessCheck$1(obj, member, "access private method");
|
|
1494
2124
|
return method;
|
|
1495
2125
|
};
|
|
1496
|
-
var _search, search_fn;
|
|
2126
|
+
var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
|
|
1497
2127
|
class SearchPlugin extends XataPlugin {
|
|
1498
|
-
constructor(db,
|
|
2128
|
+
constructor(db, schemaTables) {
|
|
1499
2129
|
super();
|
|
1500
2130
|
this.db = db;
|
|
1501
|
-
this.links = links;
|
|
1502
2131
|
__privateAdd$1(this, _search);
|
|
2132
|
+
__privateAdd$1(this, _getSchemaTables);
|
|
2133
|
+
__privateAdd$1(this, _schemaTables, void 0);
|
|
2134
|
+
__privateSet$1(this, _schemaTables, schemaTables);
|
|
1503
2135
|
}
|
|
1504
2136
|
build({ getFetchProps }) {
|
|
1505
2137
|
return {
|
|
1506
2138
|
all: async (query, options = {}) => {
|
|
1507
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);
|
|
1508
2141
|
return records.map((record) => {
|
|
1509
2142
|
const { table = "orphan" } = record.xata;
|
|
1510
|
-
return { table, record: initObject(this.db,
|
|
2143
|
+
return { table, record: initObject(this.db, schemaTables, table, record) };
|
|
1511
2144
|
});
|
|
1512
2145
|
},
|
|
1513
2146
|
byTable: async (query, options = {}) => {
|
|
1514
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);
|
|
1515
2149
|
return records.reduce((acc, record) => {
|
|
1516
2150
|
const { table = "orphan" } = record.xata;
|
|
1517
2151
|
const items = acc[table] ?? [];
|
|
1518
|
-
const item = initObject(this.db,
|
|
2152
|
+
const item = initObject(this.db, schemaTables, table, record);
|
|
1519
2153
|
return { ...acc, [table]: [...items, item] };
|
|
1520
2154
|
}, {});
|
|
1521
2155
|
}
|
|
1522
2156
|
};
|
|
1523
2157
|
}
|
|
1524
2158
|
}
|
|
2159
|
+
_schemaTables = new WeakMap();
|
|
1525
2160
|
_search = new WeakSet();
|
|
1526
2161
|
search_fn = async function(query, options, getFetchProps) {
|
|
1527
2162
|
const fetchProps = await getFetchProps();
|
|
1528
|
-
const { tables, fuzziness } = options ?? {};
|
|
2163
|
+
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
|
1529
2164
|
const { records } = await searchBranch({
|
|
1530
2165
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
1531
|
-
body: { tables, query, fuzziness },
|
|
2166
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
|
1532
2167
|
...fetchProps
|
|
1533
2168
|
});
|
|
1534
2169
|
return records;
|
|
1535
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
|
+
};
|
|
1536
2183
|
|
|
1537
2184
|
const isBranchStrategyBuilder = (strategy) => {
|
|
1538
2185
|
return typeof strategy === "function";
|
|
1539
2186
|
};
|
|
1540
2187
|
|
|
2188
|
+
async function getCurrentBranchName(options) {
|
|
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);
|
|
2198
|
+
}
|
|
2199
|
+
async function getCurrentBranchDetails(options) {
|
|
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;
|
|
2227
|
+
}
|
|
2228
|
+
async function getDatabaseBranch(branch, options) {
|
|
2229
|
+
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
2230
|
+
const apiKey = options?.apiKey || getAPIKey();
|
|
2231
|
+
if (!databaseURL)
|
|
2232
|
+
throw new Error(
|
|
2233
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
|
2234
|
+
);
|
|
2235
|
+
if (!apiKey)
|
|
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
|
+
);
|
|
2239
|
+
const [protocol, , host, , database] = databaseURL.split("/");
|
|
2240
|
+
const [workspace] = host.split(".");
|
|
2241
|
+
const dbBranchName = `${database}:${branch}`;
|
|
2242
|
+
try {
|
|
2243
|
+
return await getBranchDetails({
|
|
2244
|
+
apiKey,
|
|
2245
|
+
apiUrl: databaseURL,
|
|
2246
|
+
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
|
2247
|
+
workspacesApiUrl: `${protocol}//${host}`,
|
|
2248
|
+
pathParams: { dbBranchName, workspace },
|
|
2249
|
+
trace: defaultTrace
|
|
2250
|
+
});
|
|
2251
|
+
} catch (err) {
|
|
2252
|
+
if (isObject(err) && err.status === 404)
|
|
2253
|
+
return null;
|
|
2254
|
+
throw err;
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
function getDatabaseURL() {
|
|
2258
|
+
try {
|
|
2259
|
+
const { databaseURL } = getEnvironment();
|
|
2260
|
+
return databaseURL;
|
|
2261
|
+
} catch (err) {
|
|
2262
|
+
return void 0;
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
|
|
1541
2266
|
var __accessCheck = (obj, member, msg) => {
|
|
1542
2267
|
if (!member.has(obj))
|
|
1543
2268
|
throw TypeError("Cannot " + msg);
|
|
@@ -1561,24 +2286,29 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1561
2286
|
return method;
|
|
1562
2287
|
};
|
|
1563
2288
|
const buildClient = (plugins) => {
|
|
1564
|
-
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;
|
|
1565
2290
|
return _a = class {
|
|
1566
|
-
constructor(options = {},
|
|
2291
|
+
constructor(options = {}, schemaTables) {
|
|
1567
2292
|
__privateAdd(this, _parseOptions);
|
|
1568
2293
|
__privateAdd(this, _getFetchProps);
|
|
1569
2294
|
__privateAdd(this, _evaluateBranch);
|
|
1570
2295
|
__privateAdd(this, _branch, void 0);
|
|
2296
|
+
__privateAdd(this, _options, void 0);
|
|
1571
2297
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
|
1572
|
-
|
|
1573
|
-
const
|
|
1574
|
-
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions)
|
|
1575
|
-
|
|
2298
|
+
__privateSet(this, _options, safeOptions);
|
|
2299
|
+
const pluginOptions = {
|
|
2300
|
+
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
|
2301
|
+
cache: safeOptions.cache,
|
|
2302
|
+
trace: safeOptions.trace
|
|
2303
|
+
};
|
|
2304
|
+
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
|
2305
|
+
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
|
1576
2306
|
this.db = db;
|
|
1577
2307
|
this.search = search;
|
|
1578
2308
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
|
1579
|
-
if (
|
|
2309
|
+
if (namespace === void 0)
|
|
1580
2310
|
continue;
|
|
1581
|
-
const result = namespace.build(
|
|
2311
|
+
const result = namespace.build(pluginOptions);
|
|
1582
2312
|
if (result instanceof Promise) {
|
|
1583
2313
|
void result.then((namespace2) => {
|
|
1584
2314
|
this[key] = namespace2;
|
|
@@ -1588,21 +2318,26 @@ const buildClient = (plugins) => {
|
|
|
1588
2318
|
}
|
|
1589
2319
|
}
|
|
1590
2320
|
}
|
|
1591
|
-
|
|
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) {
|
|
1592
2327
|
const fetch = getFetchImplementation(options?.fetch);
|
|
1593
2328
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
1594
2329
|
const apiKey = options?.apiKey || getAPIKey();
|
|
1595
|
-
const
|
|
1596
|
-
|
|
1597
|
-
|
|
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");
|
|
1598
2335
|
}
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
apiKey,
|
|
1603
|
-
|
|
1604
|
-
branch
|
|
1605
|
-
}) {
|
|
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 }) {
|
|
1606
2341
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
|
1607
2342
|
if (!branchValue)
|
|
1608
2343
|
throw new Error("Unable to resolve branch value");
|
|
@@ -1612,14 +2347,15 @@ const buildClient = (plugins) => {
|
|
|
1612
2347
|
apiUrl: "",
|
|
1613
2348
|
workspacesApiUrl: (path, params) => {
|
|
1614
2349
|
const hasBranch = params.dbBranchName ?? params.branch;
|
|
1615
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
|
|
2350
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
|
|
1616
2351
|
return databaseURL + newPath;
|
|
1617
|
-
}
|
|
2352
|
+
},
|
|
2353
|
+
trace
|
|
1618
2354
|
};
|
|
1619
2355
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
|
1620
2356
|
if (__privateGet(this, _branch))
|
|
1621
2357
|
return __privateGet(this, _branch);
|
|
1622
|
-
if (
|
|
2358
|
+
if (param === void 0)
|
|
1623
2359
|
return void 0;
|
|
1624
2360
|
const strategies = Array.isArray(param) ? [...param] : [param];
|
|
1625
2361
|
const evaluateBranch = async (strategy) => {
|
|
@@ -1637,6 +2373,88 @@ const buildClient = (plugins) => {
|
|
|
1637
2373
|
class BaseClient extends buildClient() {
|
|
1638
2374
|
}
|
|
1639
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
|
+
|
|
1640
2458
|
class XataError extends Error {
|
|
1641
2459
|
constructor(message, status) {
|
|
1642
2460
|
super(message);
|
|
@@ -1644,5 +2462,5 @@ class XataError extends Error {
|
|
|
1644
2462
|
}
|
|
1645
2463
|
}
|
|
1646
2464
|
|
|
1647
|
-
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, Repository, RestRepository, SchemaPlugin, SearchPlugin, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeWorkspaceMember, resendWorkspaceMemberInvite, searchBranch, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
|
|
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, pattern, previewBranchSchemaEdit, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
|
|
1648
2466
|
//# sourceMappingURL=index.mjs.map
|