@xata.io/client 0.0.0-alpha.vfee45b2 → 0.0.0-alpha.vff4bc47
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/CHANGELOG.md +278 -0
- package/README.md +273 -1
- package/Usage.md +451 -0
- package/dist/index.cjs +2201 -803
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5194 -1210
- package/dist/index.mjs +2160 -803
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -5
- /package/{rollup.config.js → rollup.config.mjs} +0 -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
|
}
|
@@ -13,43 +35,128 @@ function isDefined(value) {
|
|
13
35
|
function isString(value) {
|
14
36
|
return isDefined(value) && typeof value === "string";
|
15
37
|
}
|
38
|
+
function isStringArray(value) {
|
39
|
+
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
40
|
+
}
|
41
|
+
function isNumber(value) {
|
42
|
+
return isDefined(value) && typeof value === "number";
|
43
|
+
}
|
16
44
|
function toBase64(value) {
|
17
45
|
try {
|
18
46
|
return btoa(value);
|
19
47
|
} catch (err) {
|
20
|
-
|
48
|
+
const buf = Buffer;
|
49
|
+
return buf.from(value).toString("base64");
|
21
50
|
}
|
22
51
|
}
|
52
|
+
function deepMerge(a, b) {
|
53
|
+
const result = { ...a };
|
54
|
+
for (const [key, value] of Object.entries(b)) {
|
55
|
+
if (isObject(value) && isObject(result[key])) {
|
56
|
+
result[key] = deepMerge(result[key], value);
|
57
|
+
} else {
|
58
|
+
result[key] = value;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
return result;
|
62
|
+
}
|
23
63
|
|
24
|
-
function
|
64
|
+
function getEnvironment() {
|
25
65
|
try {
|
26
|
-
if (isObject(process) &&
|
27
|
-
return
|
66
|
+
if (isObject(process) && isObject(process.env)) {
|
67
|
+
return {
|
68
|
+
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
69
|
+
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
70
|
+
branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
|
71
|
+
envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
|
72
|
+
fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
|
73
|
+
};
|
28
74
|
}
|
29
75
|
} catch (err) {
|
30
76
|
}
|
31
77
|
try {
|
32
|
-
if (isObject(Deno) &&
|
33
|
-
return
|
78
|
+
if (isObject(Deno) && isObject(Deno.env)) {
|
79
|
+
return {
|
80
|
+
apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
|
81
|
+
databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
|
82
|
+
branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
|
83
|
+
envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
|
84
|
+
fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
|
85
|
+
};
|
34
86
|
}
|
35
87
|
} catch (err) {
|
36
88
|
}
|
89
|
+
return {
|
90
|
+
apiKey: getGlobalApiKey(),
|
91
|
+
databaseURL: getGlobalDatabaseURL(),
|
92
|
+
branch: getGlobalBranch(),
|
93
|
+
envBranch: void 0,
|
94
|
+
fallbackBranch: getGlobalFallbackBranch()
|
95
|
+
};
|
96
|
+
}
|
97
|
+
function getEnableBrowserVariable() {
|
98
|
+
try {
|
99
|
+
if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
|
100
|
+
return process.env.XATA_ENABLE_BROWSER === "true";
|
101
|
+
}
|
102
|
+
} catch (err) {
|
103
|
+
}
|
104
|
+
try {
|
105
|
+
if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
|
106
|
+
return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
|
107
|
+
}
|
108
|
+
} catch (err) {
|
109
|
+
}
|
110
|
+
try {
|
111
|
+
return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
|
112
|
+
} catch (err) {
|
113
|
+
return void 0;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
function getGlobalApiKey() {
|
117
|
+
try {
|
118
|
+
return XATA_API_KEY;
|
119
|
+
} catch (err) {
|
120
|
+
return void 0;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
function getGlobalDatabaseURL() {
|
124
|
+
try {
|
125
|
+
return XATA_DATABASE_URL;
|
126
|
+
} catch (err) {
|
127
|
+
return void 0;
|
128
|
+
}
|
129
|
+
}
|
130
|
+
function getGlobalBranch() {
|
131
|
+
try {
|
132
|
+
return XATA_BRANCH;
|
133
|
+
} catch (err) {
|
134
|
+
return void 0;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
function getGlobalFallbackBranch() {
|
138
|
+
try {
|
139
|
+
return XATA_FALLBACK_BRANCH;
|
140
|
+
} catch (err) {
|
141
|
+
return void 0;
|
142
|
+
}
|
37
143
|
}
|
38
144
|
async function getGitBranch() {
|
145
|
+
const cmd = ["git", "branch", "--show-current"];
|
146
|
+
const fullCmd = cmd.join(" ");
|
147
|
+
const nodeModule = ["child", "process"].join("_");
|
148
|
+
const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
|
39
149
|
try {
|
40
150
|
if (typeof require === "function") {
|
41
|
-
|
42
|
-
return req("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
|
151
|
+
return require(nodeModule).execSync(fullCmd, execOptions).trim();
|
43
152
|
}
|
153
|
+
const { execSync } = await import(nodeModule);
|
154
|
+
return execSync(fullCmd, execOptions).toString().trim();
|
44
155
|
} catch (err) {
|
45
156
|
}
|
46
157
|
try {
|
47
158
|
if (isObject(Deno)) {
|
48
|
-
const process2 = Deno.run({
|
49
|
-
cmd: ["git", "branch", "--show-current"],
|
50
|
-
stdout: "piped",
|
51
|
-
stderr: "piped"
|
52
|
-
});
|
159
|
+
const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
53
160
|
return new TextDecoder().decode(await process2.output()).trim();
|
54
161
|
}
|
55
162
|
} catch (err) {
|
@@ -58,7 +165,8 @@ async function getGitBranch() {
|
|
58
165
|
|
59
166
|
function getAPIKey() {
|
60
167
|
try {
|
61
|
-
|
168
|
+
const { apiKey } = getEnvironment();
|
169
|
+
return apiKey;
|
62
170
|
} catch (err) {
|
63
171
|
return void 0;
|
64
172
|
}
|
@@ -68,26 +176,35 @@ function getFetchImplementation(userFetch) {
|
|
68
176
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
69
177
|
const fetchImpl = userFetch ?? globalFetch;
|
70
178
|
if (!fetchImpl) {
|
71
|
-
throw new Error(
|
179
|
+
throw new Error(
|
180
|
+
`Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
|
181
|
+
);
|
72
182
|
}
|
73
183
|
return fetchImpl;
|
74
184
|
}
|
75
185
|
|
186
|
+
const VERSION = "0.0.0-alpha.vff4bc47";
|
187
|
+
|
76
188
|
class ErrorWithCause extends Error {
|
77
189
|
constructor(message, options) {
|
78
190
|
super(message, options);
|
79
191
|
}
|
80
192
|
}
|
81
193
|
class FetcherError extends ErrorWithCause {
|
82
|
-
constructor(status, data) {
|
194
|
+
constructor(status, data, requestId) {
|
83
195
|
super(getMessage(data));
|
84
196
|
this.status = status;
|
85
197
|
this.errors = isBulkError(data) ? data.errors : void 0;
|
198
|
+
this.requestId = requestId;
|
86
199
|
if (data instanceof Error) {
|
87
200
|
this.stack = data.stack;
|
88
201
|
this.cause = data.cause;
|
89
202
|
}
|
90
203
|
}
|
204
|
+
toString() {
|
205
|
+
const error = super.toString();
|
206
|
+
return `[${this.status}] (${this.requestId ?? "Unknown"}): ${error}`;
|
207
|
+
}
|
91
208
|
}
|
92
209
|
function isBulkError(error) {
|
93
210
|
return isObject(error) && Array.isArray(error.errors);
|
@@ -110,20 +227,31 @@ function getMessage(data) {
|
|
110
227
|
}
|
111
228
|
|
112
229
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
113
|
-
const
|
230
|
+
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
231
|
+
if (value === void 0 || value === null)
|
232
|
+
return acc;
|
233
|
+
return { ...acc, [key]: value };
|
234
|
+
}, {});
|
235
|
+
const query = new URLSearchParams(cleanQueryParams).toString();
|
114
236
|
const queryString = query.length > 0 ? `?${query}` : "";
|
115
|
-
|
237
|
+
const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
|
238
|
+
return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
|
239
|
+
}, {});
|
240
|
+
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
116
241
|
};
|
117
242
|
function buildBaseUrl({
|
243
|
+
endpoint,
|
118
244
|
path,
|
119
245
|
workspacesApiUrl,
|
120
246
|
apiUrl,
|
121
|
-
pathParams
|
247
|
+
pathParams = {}
|
122
248
|
}) {
|
123
|
-
if (
|
124
|
-
|
125
|
-
|
126
|
-
|
249
|
+
if (endpoint === "dataPlane") {
|
250
|
+
const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
251
|
+
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
252
|
+
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
253
|
+
}
|
254
|
+
return `${apiUrl}${path}`;
|
127
255
|
}
|
128
256
|
function hostHeader(url) {
|
129
257
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
@@ -139,275 +267,231 @@ async function fetch$1({
|
|
139
267
|
queryParams,
|
140
268
|
fetchImpl,
|
141
269
|
apiKey,
|
270
|
+
endpoint,
|
142
271
|
apiUrl,
|
143
|
-
workspacesApiUrl
|
272
|
+
workspacesApiUrl,
|
273
|
+
trace,
|
274
|
+
signal,
|
275
|
+
clientID,
|
276
|
+
sessionID,
|
277
|
+
fetchOptions = {}
|
144
278
|
}) {
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
279
|
+
return trace(
|
280
|
+
`${method.toUpperCase()} ${path}`,
|
281
|
+
async ({ setAttributes }) => {
|
282
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
283
|
+
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
284
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
285
|
+
setAttributes({
|
286
|
+
[TraceAttributes.HTTP_URL]: url,
|
287
|
+
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
288
|
+
});
|
289
|
+
const response = await fetchImpl(url, {
|
290
|
+
...fetchOptions,
|
291
|
+
method: method.toUpperCase(),
|
292
|
+
body: body ? JSON.stringify(body) : void 0,
|
293
|
+
headers: {
|
294
|
+
"Content-Type": "application/json",
|
295
|
+
"User-Agent": `Xata client-ts/${VERSION}`,
|
296
|
+
"X-Xata-Client-ID": clientID ?? "",
|
297
|
+
"X-Xata-Session-ID": sessionID ?? "",
|
298
|
+
...headers,
|
299
|
+
...hostHeader(fullUrl),
|
300
|
+
Authorization: `Bearer ${apiKey}`
|
301
|
+
},
|
302
|
+
signal
|
303
|
+
});
|
304
|
+
if (response.status === 204) {
|
305
|
+
return {};
|
306
|
+
}
|
307
|
+
const { host, protocol } = parseUrl(response.url);
|
308
|
+
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
309
|
+
setAttributes({
|
310
|
+
[TraceAttributes.KIND]: "http",
|
311
|
+
[TraceAttributes.HTTP_REQUEST_ID]: requestId,
|
312
|
+
[TraceAttributes.HTTP_STATUS_CODE]: response.status,
|
313
|
+
[TraceAttributes.HTTP_HOST]: host,
|
314
|
+
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
315
|
+
});
|
316
|
+
try {
|
317
|
+
const jsonResponse = await response.json();
|
318
|
+
if (response.ok) {
|
319
|
+
return jsonResponse;
|
320
|
+
}
|
321
|
+
throw new FetcherError(response.status, jsonResponse, requestId);
|
322
|
+
} catch (error) {
|
323
|
+
throw new FetcherError(response.status, error, requestId);
|
324
|
+
}
|
325
|
+
},
|
326
|
+
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
327
|
+
);
|
328
|
+
}
|
329
|
+
function parseUrl(url) {
|
161
330
|
try {
|
162
|
-
const
|
163
|
-
|
164
|
-
return jsonResponse;
|
165
|
-
}
|
166
|
-
throw new FetcherError(response.status, jsonResponse);
|
331
|
+
const { host, protocol } = new URL(url);
|
332
|
+
return { host, protocol };
|
167
333
|
} catch (error) {
|
168
|
-
|
334
|
+
return {};
|
169
335
|
}
|
170
336
|
}
|
171
337
|
|
172
|
-
const
|
173
|
-
|
174
|
-
const
|
175
|
-
const
|
176
|
-
url: "/user/keys",
|
177
|
-
method: "get",
|
178
|
-
...variables
|
179
|
-
});
|
180
|
-
const createUserAPIKey = (variables) => fetch$1({
|
181
|
-
url: "/user/keys/{keyName}",
|
182
|
-
method: "post",
|
183
|
-
...variables
|
184
|
-
});
|
185
|
-
const deleteUserAPIKey = (variables) => fetch$1({
|
186
|
-
url: "/user/keys/{keyName}",
|
187
|
-
method: "delete",
|
188
|
-
...variables
|
189
|
-
});
|
190
|
-
const createWorkspace = (variables) => fetch$1({
|
191
|
-
url: "/workspaces",
|
192
|
-
method: "post",
|
193
|
-
...variables
|
194
|
-
});
|
195
|
-
const getWorkspacesList = (variables) => fetch$1({
|
196
|
-
url: "/workspaces",
|
197
|
-
method: "get",
|
198
|
-
...variables
|
199
|
-
});
|
200
|
-
const getWorkspace = (variables) => fetch$1({
|
201
|
-
url: "/workspaces/{workspaceId}",
|
202
|
-
method: "get",
|
203
|
-
...variables
|
204
|
-
});
|
205
|
-
const updateWorkspace = (variables) => fetch$1({
|
206
|
-
url: "/workspaces/{workspaceId}",
|
207
|
-
method: "put",
|
208
|
-
...variables
|
209
|
-
});
|
210
|
-
const deleteWorkspace = (variables) => fetch$1({
|
211
|
-
url: "/workspaces/{workspaceId}",
|
212
|
-
method: "delete",
|
213
|
-
...variables
|
214
|
-
});
|
215
|
-
const getWorkspaceMembersList = (variables) => fetch$1({
|
216
|
-
url: "/workspaces/{workspaceId}/members",
|
217
|
-
method: "get",
|
218
|
-
...variables
|
219
|
-
});
|
220
|
-
const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
|
221
|
-
const removeWorkspaceMember = (variables) => fetch$1({
|
222
|
-
url: "/workspaces/{workspaceId}/members/{userId}",
|
223
|
-
method: "delete",
|
224
|
-
...variables
|
225
|
-
});
|
226
|
-
const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
|
227
|
-
const cancelWorkspaceMemberInvite = (variables) => fetch$1({
|
228
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
229
|
-
method: "delete",
|
230
|
-
...variables
|
231
|
-
});
|
232
|
-
const resendWorkspaceMemberInvite = (variables) => fetch$1({
|
233
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
|
234
|
-
method: "post",
|
235
|
-
...variables
|
236
|
-
});
|
237
|
-
const acceptWorkspaceMemberInvite = (variables) => fetch$1({
|
238
|
-
url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
|
239
|
-
method: "post",
|
240
|
-
...variables
|
241
|
-
});
|
242
|
-
const getDatabaseList = (variables) => fetch$1({
|
243
|
-
url: "/dbs",
|
244
|
-
method: "get",
|
245
|
-
...variables
|
246
|
-
});
|
247
|
-
const getBranchList = (variables) => fetch$1({
|
248
|
-
url: "/dbs/{dbName}",
|
249
|
-
method: "get",
|
250
|
-
...variables
|
251
|
-
});
|
252
|
-
const createDatabase = (variables) => fetch$1({
|
253
|
-
url: "/dbs/{dbName}",
|
254
|
-
method: "put",
|
255
|
-
...variables
|
256
|
-
});
|
257
|
-
const deleteDatabase = (variables) => fetch$1({
|
338
|
+
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
339
|
+
|
340
|
+
const dEPRECATEDgetDatabaseList = (variables, signal) => dataPlaneFetch({ url: "/dbs", method: "get", ...variables, signal });
|
341
|
+
const getBranchList = (variables, signal) => dataPlaneFetch({
|
258
342
|
url: "/dbs/{dbName}",
|
259
|
-
method: "delete",
|
260
|
-
...variables
|
261
|
-
});
|
262
|
-
const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
|
263
|
-
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
264
|
-
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
265
|
-
const resolveBranch = (variables) => fetch$1({
|
266
|
-
url: "/dbs/{dbName}/resolveBranch",
|
267
343
|
method: "get",
|
268
|
-
...variables
|
344
|
+
...variables,
|
345
|
+
signal
|
269
346
|
});
|
270
|
-
const
|
347
|
+
const dEPRECATEDcreateDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
|
348
|
+
const dEPRECATEDdeleteDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "delete", ...variables, signal });
|
349
|
+
const dEPRECATEDgetDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "get", ...variables, signal });
|
350
|
+
const dEPRECATEDupdateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
|
351
|
+
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
271
352
|
url: "/db/{dbBranchName}",
|
272
353
|
method: "get",
|
273
|
-
...variables
|
354
|
+
...variables,
|
355
|
+
signal
|
274
356
|
});
|
275
|
-
const createBranch = (variables) =>
|
276
|
-
|
277
|
-
method: "put",
|
278
|
-
...variables
|
279
|
-
});
|
280
|
-
const deleteBranch = (variables) => fetch$1({
|
357
|
+
const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
|
358
|
+
const deleteBranch = (variables, signal) => dataPlaneFetch({
|
281
359
|
url: "/db/{dbBranchName}",
|
282
360
|
method: "delete",
|
283
|
-
...variables
|
361
|
+
...variables,
|
362
|
+
signal
|
284
363
|
});
|
285
|
-
const updateBranchMetadata = (variables) =>
|
364
|
+
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
286
365
|
url: "/db/{dbBranchName}/metadata",
|
287
366
|
method: "put",
|
288
|
-
...variables
|
367
|
+
...variables,
|
368
|
+
signal
|
289
369
|
});
|
290
|
-
const getBranchMetadata = (variables) =>
|
370
|
+
const getBranchMetadata = (variables, signal) => dataPlaneFetch({
|
291
371
|
url: "/db/{dbBranchName}/metadata",
|
292
372
|
method: "get",
|
293
|
-
...variables
|
373
|
+
...variables,
|
374
|
+
signal
|
294
375
|
});
|
295
|
-
const
|
296
|
-
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
297
|
-
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
298
|
-
const getBranchStats = (variables) => fetch$1({
|
376
|
+
const getBranchStats = (variables, signal) => dataPlaneFetch({
|
299
377
|
url: "/db/{dbBranchName}/stats",
|
300
378
|
method: "get",
|
301
|
-
...variables
|
379
|
+
...variables,
|
380
|
+
signal
|
302
381
|
});
|
303
|
-
const
|
382
|
+
const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
|
383
|
+
const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
|
384
|
+
const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
|
385
|
+
const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
|
386
|
+
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
387
|
+
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
388
|
+
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
389
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
390
|
+
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
391
|
+
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
392
|
+
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
393
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
394
|
+
method: "get",
|
395
|
+
...variables,
|
396
|
+
signal
|
397
|
+
});
|
398
|
+
const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
|
399
|
+
const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
|
400
|
+
const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
|
401
|
+
const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
|
402
|
+
const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
|
403
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
404
|
+
method: "post",
|
405
|
+
...variables,
|
406
|
+
signal
|
407
|
+
});
|
408
|
+
const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
|
409
|
+
const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
|
410
|
+
const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
|
411
|
+
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
412
|
+
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
413
|
+
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
414
|
+
const createTable = (variables, signal) => dataPlaneFetch({
|
304
415
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
305
416
|
method: "put",
|
306
|
-
...variables
|
417
|
+
...variables,
|
418
|
+
signal
|
307
419
|
});
|
308
|
-
const deleteTable = (variables) =>
|
420
|
+
const deleteTable = (variables, signal) => dataPlaneFetch({
|
309
421
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
310
422
|
method: "delete",
|
311
|
-
...variables
|
423
|
+
...variables,
|
424
|
+
signal
|
312
425
|
});
|
313
|
-
const updateTable = (variables) =>
|
314
|
-
|
315
|
-
method: "patch",
|
316
|
-
...variables
|
317
|
-
});
|
318
|
-
const getTableSchema = (variables) => fetch$1({
|
426
|
+
const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
|
427
|
+
const getTableSchema = (variables, signal) => dataPlaneFetch({
|
319
428
|
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
320
429
|
method: "get",
|
321
|
-
...variables
|
430
|
+
...variables,
|
431
|
+
signal
|
322
432
|
});
|
323
|
-
const setTableSchema = (variables) =>
|
324
|
-
|
325
|
-
method: "put",
|
326
|
-
...variables
|
327
|
-
});
|
328
|
-
const getTableColumns = (variables) => fetch$1({
|
433
|
+
const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
|
434
|
+
const getTableColumns = (variables, signal) => dataPlaneFetch({
|
329
435
|
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
330
436
|
method: "get",
|
331
|
-
...variables
|
332
|
-
|
333
|
-
const addTableColumn = (variables) => fetch$1({
|
334
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
335
|
-
method: "post",
|
336
|
-
...variables
|
437
|
+
...variables,
|
438
|
+
signal
|
337
439
|
});
|
338
|
-
const
|
440
|
+
const addTableColumn = (variables, signal) => dataPlaneFetch(
|
441
|
+
{ url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
|
442
|
+
);
|
443
|
+
const getColumn = (variables, signal) => dataPlaneFetch({
|
339
444
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
340
445
|
method: "get",
|
341
|
-
...variables
|
342
|
-
|
343
|
-
const deleteColumn = (variables) => fetch$1({
|
344
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
345
|
-
method: "delete",
|
346
|
-
...variables
|
446
|
+
...variables,
|
447
|
+
signal
|
347
448
|
});
|
348
|
-
const updateColumn = (variables) =>
|
449
|
+
const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
|
450
|
+
const deleteColumn = (variables, signal) => dataPlaneFetch({
|
349
451
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
350
|
-
method: "patch",
|
351
|
-
...variables
|
352
|
-
});
|
353
|
-
const insertRecord = (variables) => fetch$1({
|
354
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data",
|
355
|
-
method: "post",
|
356
|
-
...variables
|
357
|
-
});
|
358
|
-
const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
|
359
|
-
const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
|
360
|
-
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
361
|
-
const deleteRecord = (variables) => fetch$1({
|
362
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
363
452
|
method: "delete",
|
364
|
-
...variables
|
453
|
+
...variables,
|
454
|
+
signal
|
365
455
|
});
|
366
|
-
const
|
456
|
+
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
457
|
+
const getRecord = (variables, signal) => dataPlaneFetch({
|
367
458
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
368
459
|
method: "get",
|
369
|
-
...variables
|
460
|
+
...variables,
|
461
|
+
signal
|
370
462
|
});
|
371
|
-
const
|
372
|
-
const
|
463
|
+
const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
|
464
|
+
const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
|
465
|
+
const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
|
466
|
+
const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
|
467
|
+
const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
|
468
|
+
const queryTable = (variables, signal) => dataPlaneFetch({
|
373
469
|
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
374
470
|
method: "post",
|
375
|
-
...variables
|
471
|
+
...variables,
|
472
|
+
signal
|
376
473
|
});
|
377
|
-
const
|
378
|
-
url: "/db/{dbBranchName}/
|
474
|
+
const searchBranch = (variables, signal) => dataPlaneFetch({
|
475
|
+
url: "/db/{dbBranchName}/search",
|
379
476
|
method: "post",
|
380
|
-
...variables
|
477
|
+
...variables,
|
478
|
+
signal
|
381
479
|
});
|
382
|
-
const
|
383
|
-
url: "/db/{dbBranchName}/search",
|
480
|
+
const searchTable = (variables, signal) => dataPlaneFetch({
|
481
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
384
482
|
method: "post",
|
385
|
-
...variables
|
483
|
+
...variables,
|
484
|
+
signal
|
386
485
|
});
|
387
|
-
const
|
388
|
-
|
389
|
-
|
390
|
-
createWorkspace,
|
391
|
-
getWorkspacesList,
|
392
|
-
getWorkspace,
|
393
|
-
updateWorkspace,
|
394
|
-
deleteWorkspace,
|
395
|
-
getWorkspaceMembersList,
|
396
|
-
updateWorkspaceMemberRole,
|
397
|
-
removeWorkspaceMember,
|
398
|
-
inviteWorkspaceMember,
|
399
|
-
cancelWorkspaceMemberInvite,
|
400
|
-
resendWorkspaceMemberInvite,
|
401
|
-
acceptWorkspaceMemberInvite
|
402
|
-
},
|
486
|
+
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
487
|
+
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
488
|
+
const operationsByTag$2 = {
|
403
489
|
database: {
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
removeGitBranchesEntry,
|
410
|
-
resolveBranch
|
490
|
+
dEPRECATEDgetDatabaseList,
|
491
|
+
dEPRECATEDcreateDatabase,
|
492
|
+
dEPRECATEDdeleteDatabase,
|
493
|
+
dEPRECATEDgetDatabaseMetadata,
|
494
|
+
dEPRECATEDupdateDatabaseMetadata
|
411
495
|
},
|
412
496
|
branch: {
|
413
497
|
getBranchList,
|
@@ -416,10 +500,42 @@ const operationsByTag = {
|
|
416
500
|
deleteBranch,
|
417
501
|
updateBranchMetadata,
|
418
502
|
getBranchMetadata,
|
503
|
+
getBranchStats,
|
504
|
+
getGitBranchesMapping,
|
505
|
+
addGitBranchesEntry,
|
506
|
+
removeGitBranchesEntry,
|
507
|
+
resolveBranch
|
508
|
+
},
|
509
|
+
migrations: {
|
419
510
|
getBranchMigrationHistory,
|
420
|
-
executeBranchMigrationPlan,
|
421
511
|
getBranchMigrationPlan,
|
422
|
-
|
512
|
+
executeBranchMigrationPlan,
|
513
|
+
getBranchSchemaHistory,
|
514
|
+
compareBranchWithUserSchema,
|
515
|
+
compareBranchSchemas,
|
516
|
+
updateBranchSchema,
|
517
|
+
previewBranchSchemaEdit,
|
518
|
+
applyBranchSchemaEdit
|
519
|
+
},
|
520
|
+
records: {
|
521
|
+
branchTransaction,
|
522
|
+
insertRecord,
|
523
|
+
getRecord,
|
524
|
+
insertRecordWithID,
|
525
|
+
updateRecordWithID,
|
526
|
+
upsertRecordWithID,
|
527
|
+
deleteRecord,
|
528
|
+
bulkInsertTableRecords
|
529
|
+
},
|
530
|
+
migrationRequests: {
|
531
|
+
queryMigrationRequests,
|
532
|
+
createMigrationRequest,
|
533
|
+
getMigrationRequest,
|
534
|
+
updateMigrationRequest,
|
535
|
+
listMigrationRequestsCommits,
|
536
|
+
compareMigrationRequest,
|
537
|
+
getMigrationRequestIsMerged,
|
538
|
+
mergeMigrationRequest
|
423
539
|
},
|
424
540
|
table: {
|
425
541
|
createTable,
|
@@ -430,27 +546,150 @@ const operationsByTag = {
|
|
430
546
|
getTableColumns,
|
431
547
|
addTableColumn,
|
432
548
|
getColumn,
|
433
|
-
|
434
|
-
|
549
|
+
updateColumn,
|
550
|
+
deleteColumn
|
435
551
|
},
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
552
|
+
searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
|
553
|
+
};
|
554
|
+
|
555
|
+
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
556
|
+
|
557
|
+
const getUser = (variables, signal) => controlPlaneFetch({
|
558
|
+
url: "/user",
|
559
|
+
method: "get",
|
560
|
+
...variables,
|
561
|
+
signal
|
562
|
+
});
|
563
|
+
const updateUser = (variables, signal) => controlPlaneFetch({
|
564
|
+
url: "/user",
|
565
|
+
method: "put",
|
566
|
+
...variables,
|
567
|
+
signal
|
568
|
+
});
|
569
|
+
const deleteUser = (variables, signal) => controlPlaneFetch({
|
570
|
+
url: "/user",
|
571
|
+
method: "delete",
|
572
|
+
...variables,
|
573
|
+
signal
|
574
|
+
});
|
575
|
+
const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
|
576
|
+
url: "/user/keys",
|
577
|
+
method: "get",
|
578
|
+
...variables,
|
579
|
+
signal
|
580
|
+
});
|
581
|
+
const createUserAPIKey = (variables, signal) => controlPlaneFetch({
|
582
|
+
url: "/user/keys/{keyName}",
|
583
|
+
method: "post",
|
584
|
+
...variables,
|
585
|
+
signal
|
586
|
+
});
|
587
|
+
const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
588
|
+
url: "/user/keys/{keyName}",
|
589
|
+
method: "delete",
|
590
|
+
...variables,
|
591
|
+
signal
|
592
|
+
});
|
593
|
+
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
594
|
+
url: "/workspaces",
|
595
|
+
method: "get",
|
596
|
+
...variables,
|
597
|
+
signal
|
598
|
+
});
|
599
|
+
const createWorkspace = (variables, signal) => controlPlaneFetch({
|
600
|
+
url: "/workspaces",
|
601
|
+
method: "post",
|
602
|
+
...variables,
|
603
|
+
signal
|
604
|
+
});
|
605
|
+
const getWorkspace = (variables, signal) => controlPlaneFetch({
|
606
|
+
url: "/workspaces/{workspaceId}",
|
607
|
+
method: "get",
|
608
|
+
...variables,
|
609
|
+
signal
|
610
|
+
});
|
611
|
+
const updateWorkspace = (variables, signal) => controlPlaneFetch({
|
612
|
+
url: "/workspaces/{workspaceId}",
|
613
|
+
method: "put",
|
614
|
+
...variables,
|
615
|
+
signal
|
616
|
+
});
|
617
|
+
const deleteWorkspace = (variables, signal) => controlPlaneFetch({
|
618
|
+
url: "/workspaces/{workspaceId}",
|
619
|
+
method: "delete",
|
620
|
+
...variables,
|
621
|
+
signal
|
622
|
+
});
|
623
|
+
const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
|
624
|
+
const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
|
625
|
+
const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
626
|
+
url: "/workspaces/{workspaceId}/members/{userId}",
|
627
|
+
method: "delete",
|
628
|
+
...variables,
|
629
|
+
signal
|
630
|
+
});
|
631
|
+
const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
|
632
|
+
const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
|
633
|
+
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
634
|
+
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
635
|
+
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
636
|
+
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
637
|
+
url: "/workspaces/{workspaceId}/dbs",
|
638
|
+
method: "get",
|
639
|
+
...variables,
|
640
|
+
signal
|
641
|
+
});
|
642
|
+
const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
|
643
|
+
const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
644
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
645
|
+
method: "delete",
|
646
|
+
...variables,
|
647
|
+
signal
|
648
|
+
});
|
649
|
+
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
650
|
+
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
651
|
+
const listRegions = (variables, signal) => controlPlaneFetch({
|
652
|
+
url: "/workspaces/{workspaceId}/regions",
|
653
|
+
method: "get",
|
654
|
+
...variables,
|
655
|
+
signal
|
656
|
+
});
|
657
|
+
const operationsByTag$1 = {
|
658
|
+
users: { getUser, updateUser, deleteUser },
|
659
|
+
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
660
|
+
workspaces: {
|
661
|
+
getWorkspacesList,
|
662
|
+
createWorkspace,
|
663
|
+
getWorkspace,
|
664
|
+
updateWorkspace,
|
665
|
+
deleteWorkspace,
|
666
|
+
getWorkspaceMembersList,
|
667
|
+
updateWorkspaceMemberRole,
|
668
|
+
removeWorkspaceMember
|
669
|
+
},
|
670
|
+
invites: {
|
671
|
+
inviteWorkspaceMember,
|
672
|
+
updateWorkspaceMemberInvite,
|
673
|
+
cancelWorkspaceMemberInvite,
|
674
|
+
acceptWorkspaceMemberInvite,
|
675
|
+
resendWorkspaceMemberInvite
|
676
|
+
},
|
677
|
+
databases: {
|
678
|
+
getDatabaseList,
|
679
|
+
createDatabase,
|
680
|
+
deleteDatabase,
|
681
|
+
getDatabaseMetadata,
|
682
|
+
updateDatabaseMetadata,
|
683
|
+
listRegions
|
447
684
|
}
|
448
685
|
};
|
449
686
|
|
687
|
+
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
688
|
+
|
450
689
|
function getHostUrl(provider, type) {
|
451
|
-
if (
|
690
|
+
if (isHostProviderAlias(provider)) {
|
452
691
|
return providers[provider][type];
|
453
|
-
} else if (
|
692
|
+
} else if (isHostProviderBuilder(provider)) {
|
454
693
|
return provider[type];
|
455
694
|
}
|
456
695
|
throw new Error("Invalid API provider");
|
@@ -458,19 +697,38 @@ function getHostUrl(provider, type) {
|
|
458
697
|
const providers = {
|
459
698
|
production: {
|
460
699
|
main: "https://api.xata.io",
|
461
|
-
workspaces: "https://{workspaceId}.xata.sh"
|
700
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
462
701
|
},
|
463
702
|
staging: {
|
464
703
|
main: "https://staging.xatabase.co",
|
465
|
-
workspaces: "https://{workspaceId}.staging.xatabase.co"
|
704
|
+
workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
|
466
705
|
}
|
467
706
|
};
|
468
|
-
function
|
707
|
+
function isHostProviderAlias(alias) {
|
469
708
|
return isString(alias) && Object.keys(providers).includes(alias);
|
470
709
|
}
|
471
|
-
function
|
710
|
+
function isHostProviderBuilder(builder) {
|
472
711
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
473
712
|
}
|
713
|
+
function parseProviderString(provider = "production") {
|
714
|
+
if (isHostProviderAlias(provider)) {
|
715
|
+
return provider;
|
716
|
+
}
|
717
|
+
const [main, workspaces] = provider.split(",");
|
718
|
+
if (!main || !workspaces)
|
719
|
+
return null;
|
720
|
+
return { main, workspaces };
|
721
|
+
}
|
722
|
+
function parseWorkspacesUrlParts(url) {
|
723
|
+
if (!isString(url))
|
724
|
+
return null;
|
725
|
+
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
|
726
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
|
727
|
+
const match = url.match(regex) || url.match(regexStaging);
|
728
|
+
if (!match)
|
729
|
+
return null;
|
730
|
+
return { workspace: match[1], region: match[2] ?? "eu-west-1" };
|
731
|
+
}
|
474
732
|
|
475
733
|
var __accessCheck$7 = (obj, member, msg) => {
|
476
734
|
if (!member.has(obj))
|
@@ -485,7 +743,7 @@ var __privateAdd$7 = (obj, member, value) => {
|
|
485
743
|
throw TypeError("Cannot add the same private member more than once");
|
486
744
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
487
745
|
};
|
488
|
-
var __privateSet$
|
746
|
+
var __privateSet$7 = (obj, member, value, setter) => {
|
489
747
|
__accessCheck$7(obj, member, "write to private field");
|
490
748
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
491
749
|
return value;
|
@@ -496,15 +754,17 @@ class XataApiClient {
|
|
496
754
|
__privateAdd$7(this, _extraProps, void 0);
|
497
755
|
__privateAdd$7(this, _namespaces, {});
|
498
756
|
const provider = options.host ?? "production";
|
499
|
-
const apiKey = options
|
757
|
+
const apiKey = options.apiKey ?? getAPIKey();
|
758
|
+
const trace = options.trace ?? defaultTrace;
|
500
759
|
if (!apiKey) {
|
501
760
|
throw new Error("Could not resolve a valid apiKey");
|
502
761
|
}
|
503
|
-
__privateSet$
|
762
|
+
__privateSet$7(this, _extraProps, {
|
504
763
|
apiUrl: getHostUrl(provider, "main"),
|
505
764
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
506
765
|
fetchImpl: getFetchImplementation(options.fetch),
|
507
|
-
apiKey
|
766
|
+
apiKey,
|
767
|
+
trace
|
508
768
|
});
|
509
769
|
}
|
510
770
|
get user() {
|
@@ -512,21 +772,41 @@ class XataApiClient {
|
|
512
772
|
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
513
773
|
return __privateGet$7(this, _namespaces).user;
|
514
774
|
}
|
775
|
+
get authentication() {
|
776
|
+
if (!__privateGet$7(this, _namespaces).authentication)
|
777
|
+
__privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
|
778
|
+
return __privateGet$7(this, _namespaces).authentication;
|
779
|
+
}
|
515
780
|
get workspaces() {
|
516
781
|
if (!__privateGet$7(this, _namespaces).workspaces)
|
517
782
|
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
518
783
|
return __privateGet$7(this, _namespaces).workspaces;
|
519
784
|
}
|
520
|
-
get
|
521
|
-
if (!__privateGet$7(this, _namespaces).
|
522
|
-
__privateGet$7(this, _namespaces).
|
523
|
-
return __privateGet$7(this, _namespaces).
|
785
|
+
get invites() {
|
786
|
+
if (!__privateGet$7(this, _namespaces).invites)
|
787
|
+
__privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
|
788
|
+
return __privateGet$7(this, _namespaces).invites;
|
789
|
+
}
|
790
|
+
get database() {
|
791
|
+
if (!__privateGet$7(this, _namespaces).database)
|
792
|
+
__privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
|
793
|
+
return __privateGet$7(this, _namespaces).database;
|
524
794
|
}
|
525
795
|
get branches() {
|
526
796
|
if (!__privateGet$7(this, _namespaces).branches)
|
527
797
|
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
528
798
|
return __privateGet$7(this, _namespaces).branches;
|
529
799
|
}
|
800
|
+
get migrations() {
|
801
|
+
if (!__privateGet$7(this, _namespaces).migrations)
|
802
|
+
__privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
|
803
|
+
return __privateGet$7(this, _namespaces).migrations;
|
804
|
+
}
|
805
|
+
get migrationRequests() {
|
806
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
807
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
808
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
809
|
+
}
|
530
810
|
get tables() {
|
531
811
|
if (!__privateGet$7(this, _namespaces).tables)
|
532
812
|
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
@@ -537,6 +817,11 @@ class XataApiClient {
|
|
537
817
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
538
818
|
return __privateGet$7(this, _namespaces).records;
|
539
819
|
}
|
820
|
+
get searchAndFilter() {
|
821
|
+
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
822
|
+
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
823
|
+
return __privateGet$7(this, _namespaces).searchAndFilter;
|
824
|
+
}
|
540
825
|
}
|
541
826
|
_extraProps = new WeakMap();
|
542
827
|
_namespaces = new WeakMap();
|
@@ -547,24 +832,29 @@ class UserApi {
|
|
547
832
|
getUser() {
|
548
833
|
return operationsByTag.users.getUser({ ...this.extraProps });
|
549
834
|
}
|
550
|
-
updateUser(user) {
|
835
|
+
updateUser({ user }) {
|
551
836
|
return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
|
552
837
|
}
|
553
838
|
deleteUser() {
|
554
839
|
return operationsByTag.users.deleteUser({ ...this.extraProps });
|
555
840
|
}
|
841
|
+
}
|
842
|
+
class AuthenticationApi {
|
843
|
+
constructor(extraProps) {
|
844
|
+
this.extraProps = extraProps;
|
845
|
+
}
|
556
846
|
getUserAPIKeys() {
|
557
|
-
return operationsByTag.
|
847
|
+
return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
|
558
848
|
}
|
559
|
-
createUserAPIKey(
|
560
|
-
return operationsByTag.
|
561
|
-
pathParams: { keyName },
|
849
|
+
createUserAPIKey({ name }) {
|
850
|
+
return operationsByTag.authentication.createUserAPIKey({
|
851
|
+
pathParams: { keyName: name },
|
562
852
|
...this.extraProps
|
563
853
|
});
|
564
854
|
}
|
565
|
-
deleteUserAPIKey(
|
566
|
-
return operationsByTag.
|
567
|
-
pathParams: { keyName },
|
855
|
+
deleteUserAPIKey({ name }) {
|
856
|
+
return operationsByTag.authentication.deleteUserAPIKey({
|
857
|
+
pathParams: { keyName: name },
|
568
858
|
...this.extraProps
|
569
859
|
});
|
570
860
|
}
|
@@ -573,342 +863,897 @@ class WorkspaceApi {
|
|
573
863
|
constructor(extraProps) {
|
574
864
|
this.extraProps = extraProps;
|
575
865
|
}
|
576
|
-
|
866
|
+
getWorkspacesList() {
|
867
|
+
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
868
|
+
}
|
869
|
+
createWorkspace({ data }) {
|
577
870
|
return operationsByTag.workspaces.createWorkspace({
|
578
|
-
body:
|
871
|
+
body: data,
|
579
872
|
...this.extraProps
|
580
873
|
});
|
581
874
|
}
|
582
|
-
|
583
|
-
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
584
|
-
}
|
585
|
-
getWorkspace(workspaceId) {
|
875
|
+
getWorkspace({ workspace }) {
|
586
876
|
return operationsByTag.workspaces.getWorkspace({
|
587
|
-
pathParams: { workspaceId },
|
877
|
+
pathParams: { workspaceId: workspace },
|
588
878
|
...this.extraProps
|
589
879
|
});
|
590
880
|
}
|
591
|
-
updateWorkspace(
|
881
|
+
updateWorkspace({
|
882
|
+
workspace,
|
883
|
+
update
|
884
|
+
}) {
|
592
885
|
return operationsByTag.workspaces.updateWorkspace({
|
593
|
-
pathParams: { workspaceId },
|
594
|
-
body:
|
886
|
+
pathParams: { workspaceId: workspace },
|
887
|
+
body: update,
|
595
888
|
...this.extraProps
|
596
889
|
});
|
597
890
|
}
|
598
|
-
deleteWorkspace(
|
891
|
+
deleteWorkspace({ workspace }) {
|
599
892
|
return operationsByTag.workspaces.deleteWorkspace({
|
600
|
-
pathParams: { workspaceId },
|
893
|
+
pathParams: { workspaceId: workspace },
|
601
894
|
...this.extraProps
|
602
895
|
});
|
603
896
|
}
|
604
|
-
getWorkspaceMembersList(
|
897
|
+
getWorkspaceMembersList({ workspace }) {
|
605
898
|
return operationsByTag.workspaces.getWorkspaceMembersList({
|
606
|
-
pathParams: { workspaceId },
|
899
|
+
pathParams: { workspaceId: workspace },
|
607
900
|
...this.extraProps
|
608
901
|
});
|
609
902
|
}
|
610
|
-
updateWorkspaceMemberRole(
|
903
|
+
updateWorkspaceMemberRole({
|
904
|
+
workspace,
|
905
|
+
user,
|
906
|
+
role
|
907
|
+
}) {
|
611
908
|
return operationsByTag.workspaces.updateWorkspaceMemberRole({
|
612
|
-
pathParams: { workspaceId, userId },
|
909
|
+
pathParams: { workspaceId: workspace, userId: user },
|
613
910
|
body: { role },
|
614
911
|
...this.extraProps
|
615
912
|
});
|
616
913
|
}
|
617
|
-
removeWorkspaceMember(
|
914
|
+
removeWorkspaceMember({
|
915
|
+
workspace,
|
916
|
+
user
|
917
|
+
}) {
|
618
918
|
return operationsByTag.workspaces.removeWorkspaceMember({
|
619
|
-
pathParams: { workspaceId, userId },
|
919
|
+
pathParams: { workspaceId: workspace, userId: user },
|
620
920
|
...this.extraProps
|
621
921
|
});
|
622
922
|
}
|
623
|
-
|
624
|
-
|
625
|
-
|
923
|
+
}
|
924
|
+
class InvitesApi {
|
925
|
+
constructor(extraProps) {
|
926
|
+
this.extraProps = extraProps;
|
927
|
+
}
|
928
|
+
inviteWorkspaceMember({
|
929
|
+
workspace,
|
930
|
+
email,
|
931
|
+
role
|
932
|
+
}) {
|
933
|
+
return operationsByTag.invites.inviteWorkspaceMember({
|
934
|
+
pathParams: { workspaceId: workspace },
|
626
935
|
body: { email, role },
|
627
936
|
...this.extraProps
|
628
937
|
});
|
629
938
|
}
|
630
|
-
|
631
|
-
|
632
|
-
|
939
|
+
updateWorkspaceMemberInvite({
|
940
|
+
workspace,
|
941
|
+
invite,
|
942
|
+
role
|
943
|
+
}) {
|
944
|
+
return operationsByTag.invites.updateWorkspaceMemberInvite({
|
945
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
946
|
+
body: { role },
|
947
|
+
...this.extraProps
|
948
|
+
});
|
949
|
+
}
|
950
|
+
cancelWorkspaceMemberInvite({
|
951
|
+
workspace,
|
952
|
+
invite
|
953
|
+
}) {
|
954
|
+
return operationsByTag.invites.cancelWorkspaceMemberInvite({
|
955
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
633
956
|
...this.extraProps
|
634
957
|
});
|
635
958
|
}
|
636
|
-
|
637
|
-
|
638
|
-
|
959
|
+
acceptWorkspaceMemberInvite({
|
960
|
+
workspace,
|
961
|
+
key
|
962
|
+
}) {
|
963
|
+
return operationsByTag.invites.acceptWorkspaceMemberInvite({
|
964
|
+
pathParams: { workspaceId: workspace, inviteKey: key },
|
639
965
|
...this.extraProps
|
640
966
|
});
|
641
967
|
}
|
642
|
-
|
643
|
-
|
644
|
-
|
968
|
+
resendWorkspaceMemberInvite({
|
969
|
+
workspace,
|
970
|
+
invite
|
971
|
+
}) {
|
972
|
+
return operationsByTag.invites.resendWorkspaceMemberInvite({
|
973
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
645
974
|
...this.extraProps
|
646
975
|
});
|
647
976
|
}
|
648
977
|
}
|
649
|
-
class
|
978
|
+
class BranchApi {
|
650
979
|
constructor(extraProps) {
|
651
980
|
this.extraProps = extraProps;
|
652
981
|
}
|
653
|
-
|
654
|
-
|
655
|
-
|
982
|
+
getBranchList({
|
983
|
+
workspace,
|
984
|
+
region,
|
985
|
+
database
|
986
|
+
}) {
|
987
|
+
return operationsByTag.branch.getBranchList({
|
988
|
+
pathParams: { workspace, region, dbName: database },
|
989
|
+
...this.extraProps
|
990
|
+
});
|
991
|
+
}
|
992
|
+
getBranchDetails({
|
993
|
+
workspace,
|
994
|
+
region,
|
995
|
+
database,
|
996
|
+
branch
|
997
|
+
}) {
|
998
|
+
return operationsByTag.branch.getBranchDetails({
|
999
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
656
1000
|
...this.extraProps
|
657
1001
|
});
|
658
1002
|
}
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
1003
|
+
createBranch({
|
1004
|
+
workspace,
|
1005
|
+
region,
|
1006
|
+
database,
|
1007
|
+
branch,
|
1008
|
+
from,
|
1009
|
+
metadata
|
1010
|
+
}) {
|
1011
|
+
return operationsByTag.branch.createBranch({
|
1012
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1013
|
+
body: { from, metadata },
|
663
1014
|
...this.extraProps
|
664
1015
|
});
|
665
1016
|
}
|
666
|
-
|
667
|
-
|
668
|
-
|
1017
|
+
deleteBranch({
|
1018
|
+
workspace,
|
1019
|
+
region,
|
1020
|
+
database,
|
1021
|
+
branch
|
1022
|
+
}) {
|
1023
|
+
return operationsByTag.branch.deleteBranch({
|
1024
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
669
1025
|
...this.extraProps
|
670
1026
|
});
|
671
1027
|
}
|
672
|
-
|
673
|
-
|
674
|
-
|
1028
|
+
updateBranchMetadata({
|
1029
|
+
workspace,
|
1030
|
+
region,
|
1031
|
+
database,
|
1032
|
+
branch,
|
1033
|
+
metadata
|
1034
|
+
}) {
|
1035
|
+
return operationsByTag.branch.updateBranchMetadata({
|
1036
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1037
|
+
body: metadata,
|
675
1038
|
...this.extraProps
|
676
1039
|
});
|
677
1040
|
}
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
1041
|
+
getBranchMetadata({
|
1042
|
+
workspace,
|
1043
|
+
region,
|
1044
|
+
database,
|
1045
|
+
branch
|
1046
|
+
}) {
|
1047
|
+
return operationsByTag.branch.getBranchMetadata({
|
1048
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
682
1049
|
...this.extraProps
|
683
1050
|
});
|
684
1051
|
}
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
1052
|
+
getBranchStats({
|
1053
|
+
workspace,
|
1054
|
+
region,
|
1055
|
+
database,
|
1056
|
+
branch
|
1057
|
+
}) {
|
1058
|
+
return operationsByTag.branch.getBranchStats({
|
1059
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
689
1060
|
...this.extraProps
|
690
1061
|
});
|
691
1062
|
}
|
692
|
-
|
693
|
-
|
694
|
-
|
1063
|
+
getGitBranchesMapping({
|
1064
|
+
workspace,
|
1065
|
+
region,
|
1066
|
+
database
|
1067
|
+
}) {
|
1068
|
+
return operationsByTag.branch.getGitBranchesMapping({
|
1069
|
+
pathParams: { workspace, region, dbName: database },
|
1070
|
+
...this.extraProps
|
1071
|
+
});
|
1072
|
+
}
|
1073
|
+
addGitBranchesEntry({
|
1074
|
+
workspace,
|
1075
|
+
region,
|
1076
|
+
database,
|
1077
|
+
gitBranch,
|
1078
|
+
xataBranch
|
1079
|
+
}) {
|
1080
|
+
return operationsByTag.branch.addGitBranchesEntry({
|
1081
|
+
pathParams: { workspace, region, dbName: database },
|
1082
|
+
body: { gitBranch, xataBranch },
|
1083
|
+
...this.extraProps
|
1084
|
+
});
|
1085
|
+
}
|
1086
|
+
removeGitBranchesEntry({
|
1087
|
+
workspace,
|
1088
|
+
region,
|
1089
|
+
database,
|
1090
|
+
gitBranch
|
1091
|
+
}) {
|
1092
|
+
return operationsByTag.branch.removeGitBranchesEntry({
|
1093
|
+
pathParams: { workspace, region, dbName: database },
|
695
1094
|
queryParams: { gitBranch },
|
696
1095
|
...this.extraProps
|
697
1096
|
});
|
698
1097
|
}
|
1098
|
+
resolveBranch({
|
1099
|
+
workspace,
|
1100
|
+
region,
|
1101
|
+
database,
|
1102
|
+
gitBranch,
|
1103
|
+
fallbackBranch
|
1104
|
+
}) {
|
1105
|
+
return operationsByTag.branch.resolveBranch({
|
1106
|
+
pathParams: { workspace, region, dbName: database },
|
1107
|
+
queryParams: { gitBranch, fallbackBranch },
|
1108
|
+
...this.extraProps
|
1109
|
+
});
|
1110
|
+
}
|
699
1111
|
}
|
700
|
-
class
|
1112
|
+
class TableApi {
|
701
1113
|
constructor(extraProps) {
|
702
1114
|
this.extraProps = extraProps;
|
703
1115
|
}
|
704
|
-
|
705
|
-
|
706
|
-
|
1116
|
+
createTable({
|
1117
|
+
workspace,
|
1118
|
+
region,
|
1119
|
+
database,
|
1120
|
+
branch,
|
1121
|
+
table
|
1122
|
+
}) {
|
1123
|
+
return operationsByTag.table.createTable({
|
1124
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
707
1125
|
...this.extraProps
|
708
1126
|
});
|
709
1127
|
}
|
710
|
-
|
711
|
-
|
712
|
-
|
1128
|
+
deleteTable({
|
1129
|
+
workspace,
|
1130
|
+
region,
|
1131
|
+
database,
|
1132
|
+
branch,
|
1133
|
+
table
|
1134
|
+
}) {
|
1135
|
+
return operationsByTag.table.deleteTable({
|
1136
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
713
1137
|
...this.extraProps
|
714
1138
|
});
|
715
1139
|
}
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
1140
|
+
updateTable({
|
1141
|
+
workspace,
|
1142
|
+
region,
|
1143
|
+
database,
|
1144
|
+
branch,
|
1145
|
+
table,
|
1146
|
+
update
|
1147
|
+
}) {
|
1148
|
+
return operationsByTag.table.updateTable({
|
1149
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1150
|
+
body: update,
|
721
1151
|
...this.extraProps
|
722
1152
|
});
|
723
1153
|
}
|
724
|
-
|
725
|
-
|
726
|
-
|
1154
|
+
getTableSchema({
|
1155
|
+
workspace,
|
1156
|
+
region,
|
1157
|
+
database,
|
1158
|
+
branch,
|
1159
|
+
table
|
1160
|
+
}) {
|
1161
|
+
return operationsByTag.table.getTableSchema({
|
1162
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
727
1163
|
...this.extraProps
|
728
1164
|
});
|
729
1165
|
}
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
1166
|
+
setTableSchema({
|
1167
|
+
workspace,
|
1168
|
+
region,
|
1169
|
+
database,
|
1170
|
+
branch,
|
1171
|
+
table,
|
1172
|
+
schema
|
1173
|
+
}) {
|
1174
|
+
return operationsByTag.table.setTableSchema({
|
1175
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1176
|
+
body: schema,
|
734
1177
|
...this.extraProps
|
735
1178
|
});
|
736
1179
|
}
|
737
|
-
|
738
|
-
|
739
|
-
|
1180
|
+
getTableColumns({
|
1181
|
+
workspace,
|
1182
|
+
region,
|
1183
|
+
database,
|
1184
|
+
branch,
|
1185
|
+
table
|
1186
|
+
}) {
|
1187
|
+
return operationsByTag.table.getTableColumns({
|
1188
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
740
1189
|
...this.extraProps
|
741
1190
|
});
|
742
1191
|
}
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
1192
|
+
addTableColumn({
|
1193
|
+
workspace,
|
1194
|
+
region,
|
1195
|
+
database,
|
1196
|
+
branch,
|
1197
|
+
table,
|
1198
|
+
column
|
1199
|
+
}) {
|
1200
|
+
return operationsByTag.table.addTableColumn({
|
1201
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1202
|
+
body: column,
|
747
1203
|
...this.extraProps
|
748
1204
|
});
|
749
1205
|
}
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
1206
|
+
getColumn({
|
1207
|
+
workspace,
|
1208
|
+
region,
|
1209
|
+
database,
|
1210
|
+
branch,
|
1211
|
+
table,
|
1212
|
+
column
|
1213
|
+
}) {
|
1214
|
+
return operationsByTag.table.getColumn({
|
1215
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
754
1216
|
...this.extraProps
|
755
1217
|
});
|
756
1218
|
}
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
1219
|
+
updateColumn({
|
1220
|
+
workspace,
|
1221
|
+
region,
|
1222
|
+
database,
|
1223
|
+
branch,
|
1224
|
+
table,
|
1225
|
+
column,
|
1226
|
+
update
|
1227
|
+
}) {
|
1228
|
+
return operationsByTag.table.updateColumn({
|
1229
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1230
|
+
body: update,
|
761
1231
|
...this.extraProps
|
762
1232
|
});
|
763
1233
|
}
|
764
|
-
|
765
|
-
|
766
|
-
|
1234
|
+
deleteColumn({
|
1235
|
+
workspace,
|
1236
|
+
region,
|
1237
|
+
database,
|
1238
|
+
branch,
|
1239
|
+
table,
|
1240
|
+
column
|
1241
|
+
}) {
|
1242
|
+
return operationsByTag.table.deleteColumn({
|
1243
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
767
1244
|
...this.extraProps
|
768
1245
|
});
|
769
1246
|
}
|
770
1247
|
}
|
771
|
-
class
|
1248
|
+
class RecordsApi {
|
772
1249
|
constructor(extraProps) {
|
773
1250
|
this.extraProps = extraProps;
|
774
1251
|
}
|
775
|
-
|
776
|
-
|
777
|
-
|
1252
|
+
insertRecord({
|
1253
|
+
workspace,
|
1254
|
+
region,
|
1255
|
+
database,
|
1256
|
+
branch,
|
1257
|
+
table,
|
1258
|
+
record,
|
1259
|
+
columns
|
1260
|
+
}) {
|
1261
|
+
return operationsByTag.records.insertRecord({
|
1262
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1263
|
+
queryParams: { columns },
|
1264
|
+
body: record,
|
778
1265
|
...this.extraProps
|
779
1266
|
});
|
780
1267
|
}
|
781
|
-
|
782
|
-
|
783
|
-
|
1268
|
+
getRecord({
|
1269
|
+
workspace,
|
1270
|
+
region,
|
1271
|
+
database,
|
1272
|
+
branch,
|
1273
|
+
table,
|
1274
|
+
id,
|
1275
|
+
columns
|
1276
|
+
}) {
|
1277
|
+
return operationsByTag.records.getRecord({
|
1278
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1279
|
+
queryParams: { columns },
|
784
1280
|
...this.extraProps
|
785
1281
|
});
|
786
1282
|
}
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
1283
|
+
insertRecordWithID({
|
1284
|
+
workspace,
|
1285
|
+
region,
|
1286
|
+
database,
|
1287
|
+
branch,
|
1288
|
+
table,
|
1289
|
+
id,
|
1290
|
+
record,
|
1291
|
+
columns,
|
1292
|
+
createOnly,
|
1293
|
+
ifVersion
|
1294
|
+
}) {
|
1295
|
+
return operationsByTag.records.insertRecordWithID({
|
1296
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1297
|
+
queryParams: { columns, createOnly, ifVersion },
|
1298
|
+
body: record,
|
791
1299
|
...this.extraProps
|
792
1300
|
});
|
793
1301
|
}
|
794
|
-
|
795
|
-
|
796
|
-
|
1302
|
+
updateRecordWithID({
|
1303
|
+
workspace,
|
1304
|
+
region,
|
1305
|
+
database,
|
1306
|
+
branch,
|
1307
|
+
table,
|
1308
|
+
id,
|
1309
|
+
record,
|
1310
|
+
columns,
|
1311
|
+
ifVersion
|
1312
|
+
}) {
|
1313
|
+
return operationsByTag.records.updateRecordWithID({
|
1314
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1315
|
+
queryParams: { columns, ifVersion },
|
1316
|
+
body: record,
|
797
1317
|
...this.extraProps
|
798
1318
|
});
|
799
1319
|
}
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
1320
|
+
upsertRecordWithID({
|
1321
|
+
workspace,
|
1322
|
+
region,
|
1323
|
+
database,
|
1324
|
+
branch,
|
1325
|
+
table,
|
1326
|
+
id,
|
1327
|
+
record,
|
1328
|
+
columns,
|
1329
|
+
ifVersion
|
1330
|
+
}) {
|
1331
|
+
return operationsByTag.records.upsertRecordWithID({
|
1332
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1333
|
+
queryParams: { columns, ifVersion },
|
1334
|
+
body: record,
|
804
1335
|
...this.extraProps
|
805
1336
|
});
|
806
1337
|
}
|
807
|
-
|
808
|
-
|
809
|
-
|
1338
|
+
deleteRecord({
|
1339
|
+
workspace,
|
1340
|
+
region,
|
1341
|
+
database,
|
1342
|
+
branch,
|
1343
|
+
table,
|
1344
|
+
id,
|
1345
|
+
columns
|
1346
|
+
}) {
|
1347
|
+
return operationsByTag.records.deleteRecord({
|
1348
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1349
|
+
queryParams: { columns },
|
1350
|
+
...this.extraProps
|
1351
|
+
});
|
1352
|
+
}
|
1353
|
+
bulkInsertTableRecords({
|
1354
|
+
workspace,
|
1355
|
+
region,
|
1356
|
+
database,
|
1357
|
+
branch,
|
1358
|
+
table,
|
1359
|
+
records,
|
1360
|
+
columns
|
1361
|
+
}) {
|
1362
|
+
return operationsByTag.records.bulkInsertTableRecords({
|
1363
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1364
|
+
queryParams: { columns },
|
1365
|
+
body: { records },
|
1366
|
+
...this.extraProps
|
1367
|
+
});
|
1368
|
+
}
|
1369
|
+
branchTransaction({
|
1370
|
+
workspace,
|
1371
|
+
region,
|
1372
|
+
database,
|
1373
|
+
branch,
|
1374
|
+
operations
|
1375
|
+
}) {
|
1376
|
+
return operationsByTag.records.branchTransaction({
|
1377
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1378
|
+
body: { operations },
|
1379
|
+
...this.extraProps
|
1380
|
+
});
|
1381
|
+
}
|
1382
|
+
}
|
1383
|
+
class SearchAndFilterApi {
|
1384
|
+
constructor(extraProps) {
|
1385
|
+
this.extraProps = extraProps;
|
1386
|
+
}
|
1387
|
+
queryTable({
|
1388
|
+
workspace,
|
1389
|
+
region,
|
1390
|
+
database,
|
1391
|
+
branch,
|
1392
|
+
table,
|
1393
|
+
filter,
|
1394
|
+
sort,
|
1395
|
+
page,
|
1396
|
+
columns,
|
1397
|
+
consistency
|
1398
|
+
}) {
|
1399
|
+
return operationsByTag.searchAndFilter.queryTable({
|
1400
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1401
|
+
body: { filter, sort, page, columns, consistency },
|
1402
|
+
...this.extraProps
|
1403
|
+
});
|
1404
|
+
}
|
1405
|
+
searchTable({
|
1406
|
+
workspace,
|
1407
|
+
region,
|
1408
|
+
database,
|
1409
|
+
branch,
|
1410
|
+
table,
|
1411
|
+
query,
|
1412
|
+
fuzziness,
|
1413
|
+
target,
|
1414
|
+
prefix,
|
1415
|
+
filter,
|
1416
|
+
highlight,
|
1417
|
+
boosters
|
1418
|
+
}) {
|
1419
|
+
return operationsByTag.searchAndFilter.searchTable({
|
1420
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1421
|
+
body: { query, fuzziness, target, prefix, filter, highlight, boosters },
|
1422
|
+
...this.extraProps
|
1423
|
+
});
|
1424
|
+
}
|
1425
|
+
searchBranch({
|
1426
|
+
workspace,
|
1427
|
+
region,
|
1428
|
+
database,
|
1429
|
+
branch,
|
1430
|
+
tables,
|
1431
|
+
query,
|
1432
|
+
fuzziness,
|
1433
|
+
prefix,
|
1434
|
+
highlight
|
1435
|
+
}) {
|
1436
|
+
return operationsByTag.searchAndFilter.searchBranch({
|
1437
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1438
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
1439
|
+
...this.extraProps
|
1440
|
+
});
|
1441
|
+
}
|
1442
|
+
summarizeTable({
|
1443
|
+
workspace,
|
1444
|
+
region,
|
1445
|
+
database,
|
1446
|
+
branch,
|
1447
|
+
table,
|
1448
|
+
filter,
|
1449
|
+
columns,
|
1450
|
+
summaries,
|
1451
|
+
sort,
|
1452
|
+
summariesFilter,
|
1453
|
+
page,
|
1454
|
+
consistency
|
1455
|
+
}) {
|
1456
|
+
return operationsByTag.searchAndFilter.summarizeTable({
|
1457
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1458
|
+
body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
|
1459
|
+
...this.extraProps
|
1460
|
+
});
|
1461
|
+
}
|
1462
|
+
aggregateTable({
|
1463
|
+
workspace,
|
1464
|
+
region,
|
1465
|
+
database,
|
1466
|
+
branch,
|
1467
|
+
table,
|
1468
|
+
filter,
|
1469
|
+
aggs
|
1470
|
+
}) {
|
1471
|
+
return operationsByTag.searchAndFilter.aggregateTable({
|
1472
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1473
|
+
body: { filter, aggs },
|
1474
|
+
...this.extraProps
|
1475
|
+
});
|
1476
|
+
}
|
1477
|
+
}
|
1478
|
+
class MigrationRequestsApi {
|
1479
|
+
constructor(extraProps) {
|
1480
|
+
this.extraProps = extraProps;
|
1481
|
+
}
|
1482
|
+
queryMigrationRequests({
|
1483
|
+
workspace,
|
1484
|
+
region,
|
1485
|
+
database,
|
1486
|
+
filter,
|
1487
|
+
sort,
|
1488
|
+
page,
|
1489
|
+
columns
|
1490
|
+
}) {
|
1491
|
+
return operationsByTag.migrationRequests.queryMigrationRequests({
|
1492
|
+
pathParams: { workspace, region, dbName: database },
|
1493
|
+
body: { filter, sort, page, columns },
|
1494
|
+
...this.extraProps
|
1495
|
+
});
|
1496
|
+
}
|
1497
|
+
createMigrationRequest({
|
1498
|
+
workspace,
|
1499
|
+
region,
|
1500
|
+
database,
|
1501
|
+
migration
|
1502
|
+
}) {
|
1503
|
+
return operationsByTag.migrationRequests.createMigrationRequest({
|
1504
|
+
pathParams: { workspace, region, dbName: database },
|
1505
|
+
body: migration,
|
1506
|
+
...this.extraProps
|
1507
|
+
});
|
1508
|
+
}
|
1509
|
+
getMigrationRequest({
|
1510
|
+
workspace,
|
1511
|
+
region,
|
1512
|
+
database,
|
1513
|
+
migrationRequest
|
1514
|
+
}) {
|
1515
|
+
return operationsByTag.migrationRequests.getMigrationRequest({
|
1516
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1517
|
+
...this.extraProps
|
1518
|
+
});
|
1519
|
+
}
|
1520
|
+
updateMigrationRequest({
|
1521
|
+
workspace,
|
1522
|
+
region,
|
1523
|
+
database,
|
1524
|
+
migrationRequest,
|
1525
|
+
update
|
1526
|
+
}) {
|
1527
|
+
return operationsByTag.migrationRequests.updateMigrationRequest({
|
1528
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1529
|
+
body: update,
|
1530
|
+
...this.extraProps
|
1531
|
+
});
|
1532
|
+
}
|
1533
|
+
listMigrationRequestsCommits({
|
1534
|
+
workspace,
|
1535
|
+
region,
|
1536
|
+
database,
|
1537
|
+
migrationRequest,
|
1538
|
+
page
|
1539
|
+
}) {
|
1540
|
+
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
1541
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1542
|
+
body: { page },
|
1543
|
+
...this.extraProps
|
1544
|
+
});
|
1545
|
+
}
|
1546
|
+
compareMigrationRequest({
|
1547
|
+
workspace,
|
1548
|
+
region,
|
1549
|
+
database,
|
1550
|
+
migrationRequest
|
1551
|
+
}) {
|
1552
|
+
return operationsByTag.migrationRequests.compareMigrationRequest({
|
1553
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1554
|
+
...this.extraProps
|
1555
|
+
});
|
1556
|
+
}
|
1557
|
+
getMigrationRequestIsMerged({
|
1558
|
+
workspace,
|
1559
|
+
region,
|
1560
|
+
database,
|
1561
|
+
migrationRequest
|
1562
|
+
}) {
|
1563
|
+
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
1564
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1565
|
+
...this.extraProps
|
1566
|
+
});
|
1567
|
+
}
|
1568
|
+
mergeMigrationRequest({
|
1569
|
+
workspace,
|
1570
|
+
region,
|
1571
|
+
database,
|
1572
|
+
migrationRequest
|
1573
|
+
}) {
|
1574
|
+
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
1575
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1576
|
+
...this.extraProps
|
1577
|
+
});
|
1578
|
+
}
|
1579
|
+
}
|
1580
|
+
class MigrationsApi {
|
1581
|
+
constructor(extraProps) {
|
1582
|
+
this.extraProps = extraProps;
|
1583
|
+
}
|
1584
|
+
getBranchMigrationHistory({
|
1585
|
+
workspace,
|
1586
|
+
region,
|
1587
|
+
database,
|
1588
|
+
branch,
|
1589
|
+
limit,
|
1590
|
+
startFrom
|
1591
|
+
}) {
|
1592
|
+
return operationsByTag.migrations.getBranchMigrationHistory({
|
1593
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1594
|
+
body: { limit, startFrom },
|
810
1595
|
...this.extraProps
|
811
1596
|
});
|
812
1597
|
}
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
1598
|
+
getBranchMigrationPlan({
|
1599
|
+
workspace,
|
1600
|
+
region,
|
1601
|
+
database,
|
1602
|
+
branch,
|
1603
|
+
schema
|
1604
|
+
}) {
|
1605
|
+
return operationsByTag.migrations.getBranchMigrationPlan({
|
1606
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1607
|
+
body: schema,
|
817
1608
|
...this.extraProps
|
818
1609
|
});
|
819
1610
|
}
|
820
|
-
|
821
|
-
|
822
|
-
|
1611
|
+
executeBranchMigrationPlan({
|
1612
|
+
workspace,
|
1613
|
+
region,
|
1614
|
+
database,
|
1615
|
+
branch,
|
1616
|
+
plan
|
1617
|
+
}) {
|
1618
|
+
return operationsByTag.migrations.executeBranchMigrationPlan({
|
1619
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1620
|
+
body: plan,
|
823
1621
|
...this.extraProps
|
824
1622
|
});
|
825
1623
|
}
|
826
|
-
|
827
|
-
|
828
|
-
|
1624
|
+
getBranchSchemaHistory({
|
1625
|
+
workspace,
|
1626
|
+
region,
|
1627
|
+
database,
|
1628
|
+
branch,
|
1629
|
+
page
|
1630
|
+
}) {
|
1631
|
+
return operationsByTag.migrations.getBranchSchemaHistory({
|
1632
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1633
|
+
body: { page },
|
829
1634
|
...this.extraProps
|
830
1635
|
});
|
831
1636
|
}
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
1637
|
+
compareBranchWithUserSchema({
|
1638
|
+
workspace,
|
1639
|
+
region,
|
1640
|
+
database,
|
1641
|
+
branch,
|
1642
|
+
schema
|
1643
|
+
}) {
|
1644
|
+
return operationsByTag.migrations.compareBranchWithUserSchema({
|
1645
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1646
|
+
body: { schema },
|
836
1647
|
...this.extraProps
|
837
1648
|
});
|
838
1649
|
}
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
1650
|
+
compareBranchSchemas({
|
1651
|
+
workspace,
|
1652
|
+
region,
|
1653
|
+
database,
|
1654
|
+
branch,
|
1655
|
+
compare,
|
1656
|
+
schema
|
1657
|
+
}) {
|
1658
|
+
return operationsByTag.migrations.compareBranchSchemas({
|
1659
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
1660
|
+
body: { schema },
|
848
1661
|
...this.extraProps
|
849
1662
|
});
|
850
1663
|
}
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
1664
|
+
updateBranchSchema({
|
1665
|
+
workspace,
|
1666
|
+
region,
|
1667
|
+
database,
|
1668
|
+
branch,
|
1669
|
+
migration
|
1670
|
+
}) {
|
1671
|
+
return operationsByTag.migrations.updateBranchSchema({
|
1672
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1673
|
+
body: migration,
|
856
1674
|
...this.extraProps
|
857
1675
|
});
|
858
1676
|
}
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
1677
|
+
previewBranchSchemaEdit({
|
1678
|
+
workspace,
|
1679
|
+
region,
|
1680
|
+
database,
|
1681
|
+
branch,
|
1682
|
+
data
|
1683
|
+
}) {
|
1684
|
+
return operationsByTag.migrations.previewBranchSchemaEdit({
|
1685
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1686
|
+
body: data,
|
864
1687
|
...this.extraProps
|
865
1688
|
});
|
866
1689
|
}
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
1690
|
+
applyBranchSchemaEdit({
|
1691
|
+
workspace,
|
1692
|
+
region,
|
1693
|
+
database,
|
1694
|
+
branch,
|
1695
|
+
edits
|
1696
|
+
}) {
|
1697
|
+
return operationsByTag.migrations.applyBranchSchemaEdit({
|
1698
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1699
|
+
body: { edits },
|
872
1700
|
...this.extraProps
|
873
1701
|
});
|
874
1702
|
}
|
875
|
-
|
876
|
-
|
877
|
-
|
1703
|
+
}
|
1704
|
+
class DatabaseApi {
|
1705
|
+
constructor(extraProps) {
|
1706
|
+
this.extraProps = extraProps;
|
1707
|
+
}
|
1708
|
+
getDatabaseList({ workspace }) {
|
1709
|
+
return operationsByTag.databases.getDatabaseList({
|
1710
|
+
pathParams: { workspaceId: workspace },
|
878
1711
|
...this.extraProps
|
879
1712
|
});
|
880
1713
|
}
|
881
|
-
|
882
|
-
|
883
|
-
|
1714
|
+
createDatabase({
|
1715
|
+
workspace,
|
1716
|
+
database,
|
1717
|
+
data
|
1718
|
+
}) {
|
1719
|
+
return operationsByTag.databases.createDatabase({
|
1720
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1721
|
+
body: data,
|
884
1722
|
...this.extraProps
|
885
1723
|
});
|
886
1724
|
}
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
1725
|
+
deleteDatabase({
|
1726
|
+
workspace,
|
1727
|
+
database
|
1728
|
+
}) {
|
1729
|
+
return operationsByTag.databases.deleteDatabase({
|
1730
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
891
1731
|
...this.extraProps
|
892
1732
|
});
|
893
1733
|
}
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
1734
|
+
getDatabaseMetadata({
|
1735
|
+
workspace,
|
1736
|
+
database
|
1737
|
+
}) {
|
1738
|
+
return operationsByTag.databases.getDatabaseMetadata({
|
1739
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
898
1740
|
...this.extraProps
|
899
1741
|
});
|
900
1742
|
}
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
1743
|
+
updateDatabaseMetadata({
|
1744
|
+
workspace,
|
1745
|
+
database,
|
1746
|
+
metadata
|
1747
|
+
}) {
|
1748
|
+
return operationsByTag.databases.updateDatabaseMetadata({
|
1749
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1750
|
+
body: metadata,
|
905
1751
|
...this.extraProps
|
906
1752
|
});
|
907
1753
|
}
|
908
|
-
|
909
|
-
return operationsByTag.
|
910
|
-
pathParams: {
|
911
|
-
body: query,
|
1754
|
+
listRegions({ workspace }) {
|
1755
|
+
return operationsByTag.databases.listRegions({
|
1756
|
+
pathParams: { workspaceId: workspace },
|
912
1757
|
...this.extraProps
|
913
1758
|
});
|
914
1759
|
}
|
@@ -924,6 +1769,20 @@ class XataApiPlugin {
|
|
924
1769
|
class XataPlugin {
|
925
1770
|
}
|
926
1771
|
|
1772
|
+
function generateUUID() {
|
1773
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
1774
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
1775
|
+
return v.toString(16);
|
1776
|
+
});
|
1777
|
+
}
|
1778
|
+
|
1779
|
+
function cleanFilter(filter) {
|
1780
|
+
if (!filter)
|
1781
|
+
return void 0;
|
1782
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
1783
|
+
return values.length > 0 ? filter : void 0;
|
1784
|
+
}
|
1785
|
+
|
927
1786
|
var __accessCheck$6 = (obj, member, msg) => {
|
928
1787
|
if (!member.has(obj))
|
929
1788
|
throw TypeError("Cannot " + msg);
|
@@ -937,18 +1796,18 @@ var __privateAdd$6 = (obj, member, value) => {
|
|
937
1796
|
throw TypeError("Cannot add the same private member more than once");
|
938
1797
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
939
1798
|
};
|
940
|
-
var __privateSet$
|
1799
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
941
1800
|
__accessCheck$6(obj, member, "write to private field");
|
942
1801
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
943
1802
|
return value;
|
944
1803
|
};
|
945
|
-
var _query;
|
1804
|
+
var _query, _page;
|
946
1805
|
class Page {
|
947
1806
|
constructor(query, meta, records = []) {
|
948
1807
|
__privateAdd$6(this, _query, void 0);
|
949
|
-
__privateSet$
|
1808
|
+
__privateSet$6(this, _query, query);
|
950
1809
|
this.meta = meta;
|
951
|
-
this.records = records;
|
1810
|
+
this.records = new RecordArray(this, records);
|
952
1811
|
}
|
953
1812
|
async nextPage(size, offset) {
|
954
1813
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
@@ -956,11 +1815,11 @@ class Page {
|
|
956
1815
|
async previousPage(size, offset) {
|
957
1816
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
958
1817
|
}
|
959
|
-
async
|
960
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
1818
|
+
async startPage(size, offset) {
|
1819
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
961
1820
|
}
|
962
|
-
async
|
963
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
1821
|
+
async endPage(size, offset) {
|
1822
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
964
1823
|
}
|
965
1824
|
hasNextPage() {
|
966
1825
|
return this.meta.page.more;
|
@@ -968,12 +1827,56 @@ class Page {
|
|
968
1827
|
}
|
969
1828
|
_query = new WeakMap();
|
970
1829
|
const PAGINATION_MAX_SIZE = 200;
|
971
|
-
const PAGINATION_DEFAULT_SIZE =
|
1830
|
+
const PAGINATION_DEFAULT_SIZE = 20;
|
972
1831
|
const PAGINATION_MAX_OFFSET = 800;
|
973
1832
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
974
1833
|
function isCursorPaginationOptions(options) {
|
975
|
-
return isDefined(options) && (isDefined(options.
|
1834
|
+
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
976
1835
|
}
|
1836
|
+
const _RecordArray = class extends Array {
|
1837
|
+
constructor(...args) {
|
1838
|
+
super(..._RecordArray.parseConstructorParams(...args));
|
1839
|
+
__privateAdd$6(this, _page, void 0);
|
1840
|
+
__privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
|
1841
|
+
}
|
1842
|
+
static parseConstructorParams(...args) {
|
1843
|
+
if (args.length === 1 && typeof args[0] === "number") {
|
1844
|
+
return new Array(args[0]);
|
1845
|
+
}
|
1846
|
+
if (args.length <= 2 && isObject(args[0]?.meta) && Array.isArray(args[1] ?? [])) {
|
1847
|
+
const result = args[1] ?? args[0].records ?? [];
|
1848
|
+
return new Array(...result);
|
1849
|
+
}
|
1850
|
+
return new Array(...args);
|
1851
|
+
}
|
1852
|
+
toArray() {
|
1853
|
+
return new Array(...this);
|
1854
|
+
}
|
1855
|
+
map(callbackfn, thisArg) {
|
1856
|
+
return this.toArray().map(callbackfn, thisArg);
|
1857
|
+
}
|
1858
|
+
async nextPage(size, offset) {
|
1859
|
+
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
1860
|
+
return new _RecordArray(newPage);
|
1861
|
+
}
|
1862
|
+
async previousPage(size, offset) {
|
1863
|
+
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
1864
|
+
return new _RecordArray(newPage);
|
1865
|
+
}
|
1866
|
+
async startPage(size, offset) {
|
1867
|
+
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
1868
|
+
return new _RecordArray(newPage);
|
1869
|
+
}
|
1870
|
+
async endPage(size, offset) {
|
1871
|
+
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
1872
|
+
return new _RecordArray(newPage);
|
1873
|
+
}
|
1874
|
+
hasNextPage() {
|
1875
|
+
return __privateGet$6(this, _page).meta.page.more;
|
1876
|
+
}
|
1877
|
+
};
|
1878
|
+
let RecordArray = _RecordArray;
|
1879
|
+
_page = new WeakMap();
|
977
1880
|
|
978
1881
|
var __accessCheck$5 = (obj, member, msg) => {
|
979
1882
|
if (!member.has(obj))
|
@@ -988,24 +1891,29 @@ var __privateAdd$5 = (obj, member, value) => {
|
|
988
1891
|
throw TypeError("Cannot add the same private member more than once");
|
989
1892
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
990
1893
|
};
|
991
|
-
var __privateSet$
|
1894
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
992
1895
|
__accessCheck$5(obj, member, "write to private field");
|
993
1896
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
994
1897
|
return value;
|
995
1898
|
};
|
996
|
-
var
|
1899
|
+
var __privateMethod$3 = (obj, member, method) => {
|
1900
|
+
__accessCheck$5(obj, member, "access private method");
|
1901
|
+
return method;
|
1902
|
+
};
|
1903
|
+
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
997
1904
|
const _Query = class {
|
998
1905
|
constructor(repository, table, data, rawParent) {
|
1906
|
+
__privateAdd$5(this, _cleanFilterConstraint);
|
999
1907
|
__privateAdd$5(this, _table$1, void 0);
|
1000
1908
|
__privateAdd$5(this, _repository, void 0);
|
1001
1909
|
__privateAdd$5(this, _data, { filter: {} });
|
1002
1910
|
this.meta = { page: { cursor: "start", more: true } };
|
1003
|
-
this.records = [];
|
1004
|
-
__privateSet$
|
1911
|
+
this.records = new RecordArray(this, []);
|
1912
|
+
__privateSet$5(this, _table$1, table);
|
1005
1913
|
if (repository) {
|
1006
|
-
__privateSet$
|
1914
|
+
__privateSet$5(this, _repository, repository);
|
1007
1915
|
} else {
|
1008
|
-
__privateSet$
|
1916
|
+
__privateSet$5(this, _repository, this);
|
1009
1917
|
}
|
1010
1918
|
const parent = cleanParent(data, rawParent);
|
1011
1919
|
__privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
@@ -1014,9 +1922,10 @@ const _Query = class {
|
|
1014
1922
|
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
1015
1923
|
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
1016
1924
|
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
1017
|
-
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns
|
1925
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
|
1018
1926
|
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
1019
1927
|
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
1928
|
+
__privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
|
1020
1929
|
this.any = this.any.bind(this);
|
1021
1930
|
this.all = this.all.bind(this);
|
1022
1931
|
this.not = this.not.bind(this);
|
@@ -1052,21 +1961,29 @@ const _Query = class {
|
|
1052
1961
|
}
|
1053
1962
|
filter(a, b) {
|
1054
1963
|
if (arguments.length === 1) {
|
1055
|
-
const constraints = Object.entries(a).map(([column, constraint]) => ({
|
1964
|
+
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
1965
|
+
[column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
|
1966
|
+
}));
|
1056
1967
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1057
1968
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1058
1969
|
} else {
|
1059
|
-
const
|
1970
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
|
1971
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1060
1972
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1061
1973
|
}
|
1062
1974
|
}
|
1063
|
-
sort(column, direction) {
|
1975
|
+
sort(column, direction = "asc") {
|
1064
1976
|
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
1065
1977
|
const sort = [...originalSort, { column, direction }];
|
1066
1978
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
1067
1979
|
}
|
1068
1980
|
select(columns) {
|
1069
|
-
return new _Query(
|
1981
|
+
return new _Query(
|
1982
|
+
__privateGet$5(this, _repository),
|
1983
|
+
__privateGet$5(this, _table$1),
|
1984
|
+
{ columns },
|
1985
|
+
__privateGet$5(this, _data)
|
1986
|
+
);
|
1070
1987
|
}
|
1071
1988
|
getPaginated(options = {}) {
|
1072
1989
|
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
@@ -1089,8 +2006,20 @@ const _Query = class {
|
|
1089
2006
|
}
|
1090
2007
|
}
|
1091
2008
|
async getMany(options = {}) {
|
1092
|
-
const {
|
1093
|
-
|
2009
|
+
const { pagination = {}, ...rest } = options;
|
2010
|
+
const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
|
2011
|
+
const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
|
2012
|
+
let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
|
2013
|
+
const results = [...page.records];
|
2014
|
+
while (page.hasNextPage() && results.length < size) {
|
2015
|
+
page = await page.nextPage();
|
2016
|
+
results.push(...page.records);
|
2017
|
+
}
|
2018
|
+
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
2019
|
+
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
2020
|
+
}
|
2021
|
+
const array = new RecordArray(page, results.slice(0, size));
|
2022
|
+
return array;
|
1094
2023
|
}
|
1095
2024
|
async getAll(options = {}) {
|
1096
2025
|
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
@@ -1104,19 +2033,35 @@ const _Query = class {
|
|
1104
2033
|
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1105
2034
|
return records[0] ?? null;
|
1106
2035
|
}
|
2036
|
+
async getFirstOrThrow(options = {}) {
|
2037
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
2038
|
+
if (records[0] === void 0)
|
2039
|
+
throw new Error("No results found.");
|
2040
|
+
return records[0];
|
2041
|
+
}
|
2042
|
+
async summarize(params = {}) {
|
2043
|
+
const { summaries, summariesFilter, ...options } = params;
|
2044
|
+
const query = new _Query(
|
2045
|
+
__privateGet$5(this, _repository),
|
2046
|
+
__privateGet$5(this, _table$1),
|
2047
|
+
options,
|
2048
|
+
__privateGet$5(this, _data)
|
2049
|
+
);
|
2050
|
+
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
2051
|
+
}
|
1107
2052
|
cache(ttl) {
|
1108
2053
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1109
2054
|
}
|
1110
2055
|
nextPage(size, offset) {
|
1111
|
-
return this.
|
2056
|
+
return this.startPage(size, offset);
|
1112
2057
|
}
|
1113
2058
|
previousPage(size, offset) {
|
1114
|
-
return this.
|
2059
|
+
return this.startPage(size, offset);
|
1115
2060
|
}
|
1116
|
-
|
2061
|
+
startPage(size, offset) {
|
1117
2062
|
return this.getPaginated({ pagination: { size, offset } });
|
1118
2063
|
}
|
1119
|
-
|
2064
|
+
endPage(size, offset) {
|
1120
2065
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
1121
2066
|
}
|
1122
2067
|
hasNextPage() {
|
@@ -1127,9 +2072,20 @@ let Query = _Query;
|
|
1127
2072
|
_table$1 = new WeakMap();
|
1128
2073
|
_repository = new WeakMap();
|
1129
2074
|
_data = new WeakMap();
|
2075
|
+
_cleanFilterConstraint = new WeakSet();
|
2076
|
+
cleanFilterConstraint_fn = function(column, value) {
|
2077
|
+
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
2078
|
+
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
2079
|
+
return { $includes: value };
|
2080
|
+
}
|
2081
|
+
if (columnType === "link" && isObject(value) && isString(value.id)) {
|
2082
|
+
return value.id;
|
2083
|
+
}
|
2084
|
+
return value;
|
2085
|
+
};
|
1130
2086
|
function cleanParent(data, parent) {
|
1131
2087
|
if (isCursorPaginationOptions(data.pagination)) {
|
1132
|
-
return { ...parent,
|
2088
|
+
return { ...parent, sort: void 0, filter: void 0 };
|
1133
2089
|
}
|
1134
2090
|
return parent;
|
1135
2091
|
}
|
@@ -1138,7 +2094,9 @@ function isIdentifiable(x) {
|
|
1138
2094
|
return isObject(x) && isString(x?.id);
|
1139
2095
|
}
|
1140
2096
|
function isXataRecord(x) {
|
1141
|
-
|
2097
|
+
const record = x;
|
2098
|
+
const metadata = record?.getMetadata();
|
2099
|
+
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
1142
2100
|
}
|
1143
2101
|
|
1144
2102
|
function isSortFilterString(value) {
|
@@ -1177,7 +2135,7 @@ var __privateAdd$4 = (obj, member, value) => {
|
|
1177
2135
|
throw TypeError("Cannot add the same private member more than once");
|
1178
2136
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1179
2137
|
};
|
1180
|
-
var __privateSet$
|
2138
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
1181
2139
|
__accessCheck$4(obj, member, "write to private field");
|
1182
2140
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1183
2141
|
return value;
|
@@ -1186,294 +2144,532 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
1186
2144
|
__accessCheck$4(obj, member, "access private method");
|
1187
2145
|
return method;
|
1188
2146
|
};
|
1189
|
-
var _table, _getFetchProps, _cache,
|
2147
|
+
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _updateRecords, updateRecords_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _deleteRecords, deleteRecords_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
|
1190
2148
|
class Repository extends Query {
|
1191
2149
|
}
|
1192
2150
|
class RestRepository extends Query {
|
1193
2151
|
constructor(options) {
|
1194
|
-
super(
|
2152
|
+
super(
|
2153
|
+
null,
|
2154
|
+
{ name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
|
2155
|
+
{}
|
2156
|
+
);
|
1195
2157
|
__privateAdd$4(this, _insertRecordWithoutId);
|
1196
2158
|
__privateAdd$4(this, _insertRecordWithId);
|
1197
2159
|
__privateAdd$4(this, _bulkInsertTableRecords);
|
1198
2160
|
__privateAdd$4(this, _updateRecordWithID);
|
2161
|
+
__privateAdd$4(this, _updateRecords);
|
1199
2162
|
__privateAdd$4(this, _upsertRecordWithID);
|
1200
2163
|
__privateAdd$4(this, _deleteRecord);
|
1201
|
-
__privateAdd$4(this,
|
1202
|
-
__privateAdd$4(this, _setCacheRecord);
|
1203
|
-
__privateAdd$4(this, _getCacheRecord);
|
2164
|
+
__privateAdd$4(this, _deleteRecords);
|
1204
2165
|
__privateAdd$4(this, _setCacheQuery);
|
1205
2166
|
__privateAdd$4(this, _getCacheQuery);
|
1206
|
-
__privateAdd$4(this,
|
2167
|
+
__privateAdd$4(this, _getSchemaTables$1);
|
1207
2168
|
__privateAdd$4(this, _table, void 0);
|
1208
2169
|
__privateAdd$4(this, _getFetchProps, void 0);
|
2170
|
+
__privateAdd$4(this, _db, void 0);
|
1209
2171
|
__privateAdd$4(this, _cache, void 0);
|
1210
|
-
__privateAdd$4(this,
|
1211
|
-
|
1212
|
-
__privateSet$
|
1213
|
-
this
|
1214
|
-
__privateSet$
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
}
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
return record;
|
1228
|
-
}
|
1229
|
-
if (isObject(a) && isString(a.id)) {
|
1230
|
-
if (a.id === "")
|
1231
|
-
throw new Error("The id can't be empty");
|
1232
|
-
const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 });
|
1233
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1234
|
-
return record;
|
1235
|
-
}
|
1236
|
-
if (isObject(a)) {
|
1237
|
-
const record = await __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a);
|
1238
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1239
|
-
return record;
|
1240
|
-
}
|
1241
|
-
throw new Error("Invalid arguments for create method");
|
1242
|
-
}
|
1243
|
-
async read(recordId) {
|
1244
|
-
const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, recordId);
|
1245
|
-
if (cacheRecord)
|
1246
|
-
return cacheRecord;
|
1247
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1248
|
-
try {
|
1249
|
-
const response = await getRecord({
|
1250
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1251
|
-
...fetchProps
|
2172
|
+
__privateAdd$4(this, _schemaTables$2, void 0);
|
2173
|
+
__privateAdd$4(this, _trace, void 0);
|
2174
|
+
__privateSet$4(this, _table, options.table);
|
2175
|
+
__privateSet$4(this, _db, options.db);
|
2176
|
+
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
2177
|
+
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
2178
|
+
__privateSet$4(this, _getFetchProps, async () => {
|
2179
|
+
const props = await options.pluginOptions.getFetchProps();
|
2180
|
+
return { ...props, sessionID: generateUUID() };
|
2181
|
+
});
|
2182
|
+
const trace = options.pluginOptions.trace ?? defaultTrace;
|
2183
|
+
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
2184
|
+
return trace(name, fn, {
|
2185
|
+
...options2,
|
2186
|
+
[TraceAttributes.TABLE]: __privateGet$4(this, _table),
|
2187
|
+
[TraceAttributes.KIND]: "sdk-operation",
|
2188
|
+
[TraceAttributes.VERSION]: VERSION
|
1252
2189
|
});
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
2190
|
+
});
|
2191
|
+
}
|
2192
|
+
async create(a, b, c, d) {
|
2193
|
+
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
2194
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2195
|
+
if (Array.isArray(a)) {
|
2196
|
+
if (a.length === 0)
|
2197
|
+
return [];
|
2198
|
+
const columns = isStringArray(b) ? b : void 0;
|
2199
|
+
return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
|
1258
2200
|
}
|
1259
|
-
|
1260
|
-
|
2201
|
+
if (isString(a) && isObject(b)) {
|
2202
|
+
if (a === "")
|
2203
|
+
throw new Error("The id can't be empty");
|
2204
|
+
const columns = isStringArray(c) ? c : void 0;
|
2205
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
2206
|
+
}
|
2207
|
+
if (isObject(a) && isString(a.id)) {
|
2208
|
+
if (a.id === "")
|
2209
|
+
throw new Error("The id can't be empty");
|
2210
|
+
const columns = isStringArray(b) ? b : void 0;
|
2211
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
2212
|
+
}
|
2213
|
+
if (isObject(a)) {
|
2214
|
+
const columns = isStringArray(b) ? b : void 0;
|
2215
|
+
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
2216
|
+
}
|
2217
|
+
throw new Error("Invalid arguments for create method");
|
2218
|
+
});
|
1261
2219
|
}
|
1262
|
-
async
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
2220
|
+
async read(a, b) {
|
2221
|
+
return __privateGet$4(this, _trace).call(this, "read", async () => {
|
2222
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2223
|
+
if (Array.isArray(a)) {
|
2224
|
+
if (a.length === 0)
|
2225
|
+
return [];
|
2226
|
+
const ids = a.map((item) => extractId(item));
|
2227
|
+
const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
|
2228
|
+
const dictionary = finalObjects.reduce((acc, object) => {
|
2229
|
+
acc[object.id] = object;
|
2230
|
+
return acc;
|
2231
|
+
}, {});
|
2232
|
+
return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
|
1266
2233
|
}
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
2234
|
+
const id = extractId(a);
|
2235
|
+
if (id) {
|
2236
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2237
|
+
try {
|
2238
|
+
const response = await getRecord({
|
2239
|
+
pathParams: {
|
2240
|
+
workspace: "{workspaceId}",
|
2241
|
+
dbBranchName: "{dbBranch}",
|
2242
|
+
region: "{region}",
|
2243
|
+
tableName: __privateGet$4(this, _table),
|
2244
|
+
recordId: id
|
2245
|
+
},
|
2246
|
+
queryParams: { columns },
|
2247
|
+
...fetchProps
|
2248
|
+
});
|
2249
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2250
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2251
|
+
} catch (e) {
|
2252
|
+
if (isObject(e) && e.status === 404) {
|
2253
|
+
return null;
|
2254
|
+
}
|
2255
|
+
throw e;
|
2256
|
+
}
|
2257
|
+
}
|
2258
|
+
return null;
|
2259
|
+
});
|
1282
2260
|
}
|
1283
|
-
async
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
2261
|
+
async readOrThrow(a, b) {
|
2262
|
+
return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
|
2263
|
+
const result = await this.read(a, b);
|
2264
|
+
if (Array.isArray(result)) {
|
2265
|
+
const missingIds = compact(
|
2266
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2267
|
+
);
|
2268
|
+
if (missingIds.length > 0) {
|
2269
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
2270
|
+
}
|
2271
|
+
return result;
|
1287
2272
|
}
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
return record;
|
1295
|
-
}
|
1296
|
-
if (isObject(a) && isString(a.id)) {
|
1297
|
-
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
|
1298
|
-
const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
|
1299
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1300
|
-
return record;
|
1301
|
-
}
|
1302
|
-
throw new Error("Invalid arguments for createOrUpdate method");
|
2273
|
+
if (result === null) {
|
2274
|
+
const id = extractId(a) ?? "unknown";
|
2275
|
+
throw new Error(`Record with id ${id} not found`);
|
2276
|
+
}
|
2277
|
+
return result;
|
2278
|
+
});
|
1303
2279
|
}
|
1304
|
-
async
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
2280
|
+
async update(a, b, c, d) {
|
2281
|
+
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
2282
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2283
|
+
if (Array.isArray(a)) {
|
2284
|
+
if (a.length === 0)
|
2285
|
+
return [];
|
2286
|
+
const existing = await this.read(a, ["id"]);
|
2287
|
+
const updates = a.filter((_item, index) => existing[index] !== null);
|
2288
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
|
2289
|
+
ifVersion,
|
2290
|
+
upsert: false
|
2291
|
+
});
|
2292
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2293
|
+
const result = await this.read(a, columns);
|
2294
|
+
return result;
|
1308
2295
|
}
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
2296
|
+
if (isString(a) && isObject(b)) {
|
2297
|
+
const columns = isStringArray(c) ? c : void 0;
|
2298
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
2299
|
+
}
|
2300
|
+
if (isObject(a) && isString(a.id)) {
|
2301
|
+
const columns = isStringArray(b) ? b : void 0;
|
2302
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
2303
|
+
}
|
2304
|
+
throw new Error("Invalid arguments for update method");
|
2305
|
+
});
|
2306
|
+
}
|
2307
|
+
async updateOrThrow(a, b, c, d) {
|
2308
|
+
return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
|
2309
|
+
const result = await this.update(a, b, c, d);
|
2310
|
+
if (Array.isArray(result)) {
|
2311
|
+
const missingIds = compact(
|
2312
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2313
|
+
);
|
2314
|
+
if (missingIds.length > 0) {
|
2315
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
2316
|
+
}
|
2317
|
+
return result;
|
2318
|
+
}
|
2319
|
+
if (result === null) {
|
2320
|
+
const id = extractId(a) ?? "unknown";
|
2321
|
+
throw new Error(`Record with id ${id} not found`);
|
2322
|
+
}
|
2323
|
+
return result;
|
2324
|
+
});
|
2325
|
+
}
|
2326
|
+
async createOrUpdate(a, b, c, d) {
|
2327
|
+
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
2328
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2329
|
+
if (Array.isArray(a)) {
|
2330
|
+
if (a.length === 0)
|
2331
|
+
return [];
|
2332
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
|
2333
|
+
ifVersion,
|
2334
|
+
upsert: true
|
2335
|
+
});
|
2336
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2337
|
+
const result = await this.read(a, columns);
|
2338
|
+
return result;
|
2339
|
+
}
|
2340
|
+
if (isString(a) && isObject(b)) {
|
2341
|
+
const columns = isStringArray(c) ? c : void 0;
|
2342
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
2343
|
+
}
|
2344
|
+
if (isObject(a) && isString(a.id)) {
|
2345
|
+
const columns = isStringArray(c) ? c : void 0;
|
2346
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
2347
|
+
}
|
2348
|
+
throw new Error("Invalid arguments for createOrUpdate method");
|
2349
|
+
});
|
2350
|
+
}
|
2351
|
+
async createOrReplace(a, b, c, d) {
|
2352
|
+
return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
|
2353
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2354
|
+
if (Array.isArray(a)) {
|
2355
|
+
if (a.length === 0)
|
2356
|
+
return [];
|
2357
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2358
|
+
return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
|
2359
|
+
}
|
2360
|
+
if (isString(a) && isObject(b)) {
|
2361
|
+
const columns = isStringArray(c) ? c : void 0;
|
2362
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
2363
|
+
}
|
2364
|
+
if (isObject(a) && isString(a.id)) {
|
2365
|
+
const columns = isStringArray(c) ? c : void 0;
|
2366
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
2367
|
+
}
|
2368
|
+
throw new Error("Invalid arguments for createOrReplace method");
|
2369
|
+
});
|
2370
|
+
}
|
2371
|
+
async delete(a, b) {
|
2372
|
+
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
2373
|
+
if (Array.isArray(a)) {
|
2374
|
+
if (a.length === 0)
|
2375
|
+
return [];
|
2376
|
+
const ids = a.map((o) => {
|
2377
|
+
if (isString(o))
|
2378
|
+
return o;
|
2379
|
+
if (isString(o.id))
|
2380
|
+
return o.id;
|
2381
|
+
throw new Error("Invalid arguments for delete method");
|
2382
|
+
});
|
2383
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2384
|
+
const result = await this.read(a, columns);
|
2385
|
+
await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
|
2386
|
+
return result;
|
2387
|
+
}
|
2388
|
+
if (isString(a)) {
|
2389
|
+
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
|
2390
|
+
}
|
2391
|
+
if (isObject(a) && isString(a.id)) {
|
2392
|
+
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
|
2393
|
+
}
|
2394
|
+
throw new Error("Invalid arguments for delete method");
|
2395
|
+
});
|
2396
|
+
}
|
2397
|
+
async deleteOrThrow(a, b) {
|
2398
|
+
return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
|
2399
|
+
const result = await this.delete(a, b);
|
2400
|
+
if (Array.isArray(result)) {
|
2401
|
+
const missingIds = compact(
|
2402
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2403
|
+
);
|
2404
|
+
if (missingIds.length > 0) {
|
2405
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
2406
|
+
}
|
2407
|
+
return result;
|
2408
|
+
} else if (result === null) {
|
2409
|
+
const id = extractId(a) ?? "unknown";
|
2410
|
+
throw new Error(`Record with id ${id} not found`);
|
2411
|
+
}
|
2412
|
+
return result;
|
2413
|
+
});
|
1323
2414
|
}
|
1324
2415
|
async search(query, options = {}) {
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
2416
|
+
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
2417
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2418
|
+
const { records } = await searchTable({
|
2419
|
+
pathParams: {
|
2420
|
+
workspace: "{workspaceId}",
|
2421
|
+
dbBranchName: "{dbBranch}",
|
2422
|
+
region: "{region}",
|
2423
|
+
tableName: __privateGet$4(this, _table)
|
2424
|
+
},
|
2425
|
+
body: {
|
2426
|
+
query,
|
2427
|
+
fuzziness: options.fuzziness,
|
2428
|
+
prefix: options.prefix,
|
2429
|
+
highlight: options.highlight,
|
2430
|
+
filter: options.filter,
|
2431
|
+
boosters: options.boosters
|
2432
|
+
},
|
2433
|
+
...fetchProps
|
2434
|
+
});
|
2435
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2436
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
2437
|
+
});
|
2438
|
+
}
|
2439
|
+
async aggregate(aggs, filter) {
|
2440
|
+
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
2441
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2442
|
+
const result = await aggregateTable({
|
2443
|
+
pathParams: {
|
2444
|
+
workspace: "{workspaceId}",
|
2445
|
+
dbBranchName: "{dbBranch}",
|
2446
|
+
region: "{region}",
|
2447
|
+
tableName: __privateGet$4(this, _table)
|
2448
|
+
},
|
2449
|
+
body: { aggs, filter },
|
2450
|
+
...fetchProps
|
2451
|
+
});
|
2452
|
+
return result;
|
1334
2453
|
});
|
1335
|
-
const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
|
1336
|
-
return records.map((item) => initObject(this.db, schema, __privateGet$4(this, _table), item));
|
1337
2454
|
}
|
1338
2455
|
async query(query) {
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
2456
|
+
return __privateGet$4(this, _trace).call(this, "query", async () => {
|
2457
|
+
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
2458
|
+
if (cacheQuery)
|
2459
|
+
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
2460
|
+
const data = query.getQueryOptions();
|
2461
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2462
|
+
const { meta, records: objects } = await queryTable({
|
2463
|
+
pathParams: {
|
2464
|
+
workspace: "{workspaceId}",
|
2465
|
+
dbBranchName: "{dbBranch}",
|
2466
|
+
region: "{region}",
|
2467
|
+
tableName: __privateGet$4(this, _table)
|
2468
|
+
},
|
2469
|
+
body: {
|
2470
|
+
filter: cleanFilter(data.filter),
|
2471
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2472
|
+
page: data.pagination,
|
2473
|
+
columns: data.columns ?? ["*"]
|
2474
|
+
},
|
2475
|
+
fetchOptions: data.fetchOptions,
|
2476
|
+
...fetchProps
|
2477
|
+
});
|
2478
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2479
|
+
const records = objects.map(
|
2480
|
+
(record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
|
2481
|
+
);
|
2482
|
+
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
2483
|
+
return new Page(query, meta, records);
|
2484
|
+
});
|
2485
|
+
}
|
2486
|
+
async summarizeTable(query, summaries, summariesFilter) {
|
2487
|
+
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
2488
|
+
const data = query.getQueryOptions();
|
2489
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2490
|
+
const result = await summarizeTable({
|
2491
|
+
pathParams: {
|
2492
|
+
workspace: "{workspaceId}",
|
2493
|
+
dbBranchName: "{dbBranch}",
|
2494
|
+
region: "{region}",
|
2495
|
+
tableName: __privateGet$4(this, _table)
|
2496
|
+
},
|
2497
|
+
body: {
|
2498
|
+
filter: cleanFilter(data.filter),
|
2499
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2500
|
+
columns: data.columns,
|
2501
|
+
page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
|
2502
|
+
summaries,
|
2503
|
+
summariesFilter
|
2504
|
+
},
|
2505
|
+
...fetchProps
|
2506
|
+
});
|
2507
|
+
return result;
|
1354
2508
|
});
|
1355
|
-
const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
|
1356
|
-
const records = objects.map((record) => initObject(this.db, schema, __privateGet$4(this, _table), record));
|
1357
|
-
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1358
|
-
return new Page(query, meta, records);
|
1359
2509
|
}
|
1360
2510
|
}
|
1361
2511
|
_table = new WeakMap();
|
1362
2512
|
_getFetchProps = new WeakMap();
|
2513
|
+
_db = new WeakMap();
|
1363
2514
|
_cache = new WeakMap();
|
1364
|
-
|
2515
|
+
_schemaTables$2 = new WeakMap();
|
2516
|
+
_trace = new WeakMap();
|
1365
2517
|
_insertRecordWithoutId = new WeakSet();
|
1366
|
-
insertRecordWithoutId_fn = async function(object) {
|
2518
|
+
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
1367
2519
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1368
2520
|
const record = transformObjectLinks(object);
|
1369
2521
|
const response = await insertRecord({
|
1370
2522
|
pathParams: {
|
1371
2523
|
workspace: "{workspaceId}",
|
1372
2524
|
dbBranchName: "{dbBranch}",
|
2525
|
+
region: "{region}",
|
1373
2526
|
tableName: __privateGet$4(this, _table)
|
1374
2527
|
},
|
2528
|
+
queryParams: { columns },
|
1375
2529
|
body: record,
|
1376
2530
|
...fetchProps
|
1377
2531
|
});
|
1378
|
-
const
|
1379
|
-
|
1380
|
-
throw new Error("The server failed to save the record");
|
1381
|
-
}
|
1382
|
-
return finalObject;
|
2532
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2533
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1383
2534
|
};
|
1384
2535
|
_insertRecordWithId = new WeakSet();
|
1385
|
-
insertRecordWithId_fn = async function(recordId, object) {
|
2536
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
1386
2537
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1387
2538
|
const record = transformObjectLinks(object);
|
1388
2539
|
const response = await insertRecordWithID({
|
1389
2540
|
pathParams: {
|
1390
2541
|
workspace: "{workspaceId}",
|
1391
2542
|
dbBranchName: "{dbBranch}",
|
2543
|
+
region: "{region}",
|
1392
2544
|
tableName: __privateGet$4(this, _table),
|
1393
2545
|
recordId
|
1394
2546
|
},
|
1395
2547
|
body: record,
|
1396
|
-
queryParams: { createOnly
|
2548
|
+
queryParams: { createOnly, columns, ifVersion },
|
1397
2549
|
...fetchProps
|
1398
2550
|
});
|
1399
|
-
const
|
1400
|
-
|
1401
|
-
throw new Error("The server failed to save the record");
|
1402
|
-
}
|
1403
|
-
return finalObject;
|
2551
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2552
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1404
2553
|
};
|
1405
2554
|
_bulkInsertTableRecords = new WeakSet();
|
1406
|
-
bulkInsertTableRecords_fn = async function(objects) {
|
2555
|
+
bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
1407
2556
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1408
2557
|
const records = objects.map((object) => transformObjectLinks(object));
|
1409
2558
|
const response = await bulkInsertTableRecords({
|
1410
|
-
pathParams: {
|
2559
|
+
pathParams: {
|
2560
|
+
workspace: "{workspaceId}",
|
2561
|
+
dbBranchName: "{dbBranch}",
|
2562
|
+
region: "{region}",
|
2563
|
+
tableName: __privateGet$4(this, _table)
|
2564
|
+
},
|
2565
|
+
queryParams: { columns },
|
1411
2566
|
body: { records },
|
1412
2567
|
...fetchProps
|
1413
2568
|
});
|
1414
|
-
|
1415
|
-
|
1416
|
-
throw new Error("The server failed to save some records");
|
2569
|
+
if (!isResponseWithRecords(response)) {
|
2570
|
+
throw new Error("Request included columns but server didn't include them");
|
1417
2571
|
}
|
1418
|
-
|
2572
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2573
|
+
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
|
1419
2574
|
};
|
1420
2575
|
_updateRecordWithID = new WeakSet();
|
1421
|
-
updateRecordWithID_fn = async function(recordId, object) {
|
2576
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
1422
2577
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1423
2578
|
const record = transformObjectLinks(object);
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
2579
|
+
try {
|
2580
|
+
const response = await updateRecordWithID({
|
2581
|
+
pathParams: {
|
2582
|
+
workspace: "{workspaceId}",
|
2583
|
+
dbBranchName: "{dbBranch}",
|
2584
|
+
region: "{region}",
|
2585
|
+
tableName: __privateGet$4(this, _table),
|
2586
|
+
recordId
|
2587
|
+
},
|
2588
|
+
queryParams: { columns, ifVersion },
|
2589
|
+
body: record,
|
2590
|
+
...fetchProps
|
2591
|
+
});
|
2592
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2593
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2594
|
+
} catch (e) {
|
2595
|
+
if (isObject(e) && e.status === 404) {
|
2596
|
+
return null;
|
2597
|
+
}
|
2598
|
+
}
|
2599
|
+
};
|
2600
|
+
_updateRecords = new WeakSet();
|
2601
|
+
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
2602
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2603
|
+
const operations = objects.map(({ id, ...fields }) => ({
|
2604
|
+
update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields }
|
2605
|
+
}));
|
2606
|
+
const { results } = await branchTransaction({
|
2607
|
+
pathParams: {
|
2608
|
+
workspace: "{workspaceId}",
|
2609
|
+
dbBranchName: "{dbBranch}",
|
2610
|
+
region: "{region}"
|
2611
|
+
},
|
2612
|
+
body: { operations },
|
1427
2613
|
...fetchProps
|
1428
2614
|
});
|
1429
|
-
|
1430
|
-
if (!item)
|
1431
|
-
throw new Error("The server failed to save the record");
|
1432
|
-
return item;
|
2615
|
+
return results;
|
1433
2616
|
};
|
1434
2617
|
_upsertRecordWithID = new WeakSet();
|
1435
|
-
upsertRecordWithID_fn = async function(recordId, object) {
|
2618
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
1436
2619
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1437
2620
|
const response = await upsertRecordWithID({
|
1438
|
-
pathParams: {
|
2621
|
+
pathParams: {
|
2622
|
+
workspace: "{workspaceId}",
|
2623
|
+
dbBranchName: "{dbBranch}",
|
2624
|
+
region: "{region}",
|
2625
|
+
tableName: __privateGet$4(this, _table),
|
2626
|
+
recordId
|
2627
|
+
},
|
2628
|
+
queryParams: { columns, ifVersion },
|
1439
2629
|
body: object,
|
1440
2630
|
...fetchProps
|
1441
2631
|
});
|
1442
|
-
const
|
1443
|
-
|
1444
|
-
throw new Error("The server failed to save the record");
|
1445
|
-
return item;
|
2632
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2633
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1446
2634
|
};
|
1447
2635
|
_deleteRecord = new WeakSet();
|
1448
|
-
deleteRecord_fn = async function(recordId) {
|
2636
|
+
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
2637
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2638
|
+
try {
|
2639
|
+
const response = await deleteRecord({
|
2640
|
+
pathParams: {
|
2641
|
+
workspace: "{workspaceId}",
|
2642
|
+
dbBranchName: "{dbBranch}",
|
2643
|
+
region: "{region}",
|
2644
|
+
tableName: __privateGet$4(this, _table),
|
2645
|
+
recordId
|
2646
|
+
},
|
2647
|
+
queryParams: { columns },
|
2648
|
+
...fetchProps
|
2649
|
+
});
|
2650
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2651
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2652
|
+
} catch (e) {
|
2653
|
+
if (isObject(e) && e.status === 404) {
|
2654
|
+
return null;
|
2655
|
+
}
|
2656
|
+
throw e;
|
2657
|
+
}
|
2658
|
+
};
|
2659
|
+
_deleteRecords = new WeakSet();
|
2660
|
+
deleteRecords_fn = async function(recordIds) {
|
1449
2661
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1450
|
-
|
1451
|
-
|
2662
|
+
const operations = recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } }));
|
2663
|
+
const { results } = await branchTransaction({
|
2664
|
+
pathParams: {
|
2665
|
+
workspace: "{workspaceId}",
|
2666
|
+
dbBranchName: "{dbBranch}",
|
2667
|
+
region: "{region}"
|
2668
|
+
},
|
2669
|
+
body: { operations },
|
1452
2670
|
...fetchProps
|
1453
2671
|
});
|
1454
|
-
|
1455
|
-
_invalidateCache = new WeakSet();
|
1456
|
-
invalidateCache_fn = async function(recordId) {
|
1457
|
-
await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
1458
|
-
const cacheItems = await __privateGet$4(this, _cache).getAll();
|
1459
|
-
const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
|
1460
|
-
for (const [key, value] of queries) {
|
1461
|
-
const ids = getIds(value);
|
1462
|
-
if (ids.includes(recordId))
|
1463
|
-
await __privateGet$4(this, _cache).delete(key);
|
1464
|
-
}
|
1465
|
-
};
|
1466
|
-
_setCacheRecord = new WeakSet();
|
1467
|
-
setCacheRecord_fn = async function(record) {
|
1468
|
-
if (!__privateGet$4(this, _cache).cacheRecords)
|
1469
|
-
return;
|
1470
|
-
await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
|
1471
|
-
};
|
1472
|
-
_getCacheRecord = new WeakSet();
|
1473
|
-
getCacheRecord_fn = async function(recordId) {
|
1474
|
-
if (!__privateGet$4(this, _cache).cacheRecords)
|
1475
|
-
return null;
|
1476
|
-
return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
2672
|
+
return results;
|
1477
2673
|
};
|
1478
2674
|
_setCacheQuery = new WeakSet();
|
1479
2675
|
setCacheQuery_fn = async function(query, meta, records) {
|
@@ -1491,17 +2687,17 @@ getCacheQuery_fn = async function(query) {
|
|
1491
2687
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
1492
2688
|
return hasExpired ? null : result;
|
1493
2689
|
};
|
1494
|
-
|
1495
|
-
|
1496
|
-
if (__privateGet$4(this,
|
1497
|
-
return __privateGet$4(this,
|
2690
|
+
_getSchemaTables$1 = new WeakSet();
|
2691
|
+
getSchemaTables_fn$1 = async function() {
|
2692
|
+
if (__privateGet$4(this, _schemaTables$2))
|
2693
|
+
return __privateGet$4(this, _schemaTables$2);
|
1498
2694
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1499
2695
|
const { schema } = await getBranchDetails({
|
1500
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2696
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
1501
2697
|
...fetchProps
|
1502
2698
|
});
|
1503
|
-
__privateSet$
|
1504
|
-
return schema;
|
2699
|
+
__privateSet$4(this, _schemaTables$2, schema.tables);
|
2700
|
+
return schema.tables;
|
1505
2701
|
};
|
1506
2702
|
const transformObjectLinks = (object) => {
|
1507
2703
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
@@ -1510,20 +2706,23 @@ const transformObjectLinks = (object) => {
|
|
1510
2706
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1511
2707
|
}, {});
|
1512
2708
|
};
|
1513
|
-
const initObject = (db,
|
2709
|
+
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
1514
2710
|
const result = {};
|
1515
|
-
|
1516
|
-
|
2711
|
+
const { xata, ...rest } = object ?? {};
|
2712
|
+
Object.assign(result, rest);
|
2713
|
+
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
1517
2714
|
if (!columns)
|
1518
2715
|
console.error(`Table ${table} not found in schema`);
|
1519
2716
|
for (const column of columns ?? []) {
|
2717
|
+
if (!isValidColumn(selectedColumns, column))
|
2718
|
+
continue;
|
1520
2719
|
const value = result[column.name];
|
1521
2720
|
switch (column.type) {
|
1522
2721
|
case "datetime": {
|
1523
|
-
const date = new Date(value);
|
1524
|
-
if (isNaN(date.getTime())) {
|
2722
|
+
const date = value !== void 0 ? new Date(value) : void 0;
|
2723
|
+
if (date && isNaN(date.getTime())) {
|
1525
2724
|
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
1526
|
-
} else {
|
2725
|
+
} else if (date) {
|
1527
2726
|
result[column.name] = date;
|
1528
2727
|
}
|
1529
2728
|
break;
|
@@ -1533,35 +2732,81 @@ const initObject = (db, schema, table, object) => {
|
|
1533
2732
|
if (!linkTable) {
|
1534
2733
|
console.error(`Failed to parse link for field ${column.name}`);
|
1535
2734
|
} else if (isObject(value)) {
|
1536
|
-
|
2735
|
+
const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
|
2736
|
+
if (item === column.name) {
|
2737
|
+
return [...acc, "*"];
|
2738
|
+
}
|
2739
|
+
if (item.startsWith(`${column.name}.`)) {
|
2740
|
+
const [, ...path] = item.split(".");
|
2741
|
+
return [...acc, path.join(".")];
|
2742
|
+
}
|
2743
|
+
return acc;
|
2744
|
+
}, []);
|
2745
|
+
result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
|
2746
|
+
} else {
|
2747
|
+
result[column.name] = null;
|
1537
2748
|
}
|
1538
2749
|
break;
|
1539
2750
|
}
|
2751
|
+
default:
|
2752
|
+
result[column.name] = value ?? null;
|
2753
|
+
if (column.notNull === true && value === null) {
|
2754
|
+
console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
|
2755
|
+
}
|
2756
|
+
break;
|
1540
2757
|
}
|
1541
2758
|
}
|
1542
|
-
result.read = function() {
|
1543
|
-
return db[table].read(result["id"]);
|
2759
|
+
result.read = function(columns2) {
|
2760
|
+
return db[table].read(result["id"], columns2);
|
1544
2761
|
};
|
1545
|
-
result.update = function(data) {
|
1546
|
-
|
2762
|
+
result.update = function(data, b, c) {
|
2763
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2764
|
+
const ifVersion = parseIfVersion(b, c);
|
2765
|
+
return db[table].update(result["id"], data, columns2, { ifVersion });
|
2766
|
+
};
|
2767
|
+
result.replace = function(data, b, c) {
|
2768
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2769
|
+
const ifVersion = parseIfVersion(b, c);
|
2770
|
+
return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
|
1547
2771
|
};
|
1548
2772
|
result.delete = function() {
|
1549
2773
|
return db[table].delete(result["id"]);
|
1550
2774
|
};
|
1551
|
-
|
2775
|
+
result.getMetadata = function() {
|
2776
|
+
return xata;
|
2777
|
+
};
|
2778
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
|
1552
2779
|
Object.defineProperty(result, prop, { enumerable: false });
|
1553
2780
|
}
|
1554
2781
|
Object.freeze(result);
|
1555
2782
|
return result;
|
1556
2783
|
};
|
1557
|
-
function
|
1558
|
-
|
1559
|
-
|
2784
|
+
function isResponseWithRecords(value) {
|
2785
|
+
return isObject(value) && Array.isArray(value.records);
|
2786
|
+
}
|
2787
|
+
function extractId(value) {
|
2788
|
+
if (isString(value))
|
2789
|
+
return value;
|
2790
|
+
if (isObject(value) && isString(value.id))
|
2791
|
+
return value.id;
|
2792
|
+
return void 0;
|
2793
|
+
}
|
2794
|
+
function isValidColumn(columns, column) {
|
2795
|
+
if (columns.includes("*"))
|
2796
|
+
return true;
|
2797
|
+
if (column.type === "link") {
|
2798
|
+
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
2799
|
+
return linkColumns.length > 0;
|
2800
|
+
}
|
2801
|
+
return columns.includes(column.name);
|
2802
|
+
}
|
2803
|
+
function parseIfVersion(...args) {
|
2804
|
+
for (const arg of args) {
|
2805
|
+
if (isObject(arg) && isNumber(arg.ifVersion)) {
|
2806
|
+
return arg.ifVersion;
|
2807
|
+
}
|
1560
2808
|
}
|
1561
|
-
|
1562
|
-
return [];
|
1563
|
-
const nestedIds = Object.values(value).map((item) => getIds(item)).flat();
|
1564
|
-
return isString(value.id) ? [value.id, ...nestedIds] : nestedIds;
|
2809
|
+
return void 0;
|
1565
2810
|
}
|
1566
2811
|
|
1567
2812
|
var __accessCheck$3 = (obj, member, msg) => {
|
@@ -1577,7 +2822,7 @@ var __privateAdd$3 = (obj, member, value) => {
|
|
1577
2822
|
throw TypeError("Cannot add the same private member more than once");
|
1578
2823
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1579
2824
|
};
|
1580
|
-
var __privateSet$
|
2825
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
1581
2826
|
__accessCheck$3(obj, member, "write to private field");
|
1582
2827
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1583
2828
|
return value;
|
@@ -1586,9 +2831,8 @@ var _map;
|
|
1586
2831
|
class SimpleCache {
|
1587
2832
|
constructor(options = {}) {
|
1588
2833
|
__privateAdd$3(this, _map, void 0);
|
1589
|
-
__privateSet$
|
2834
|
+
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
1590
2835
|
this.capacity = options.max ?? 500;
|
1591
|
-
this.cacheRecords = options.cacheRecords ?? true;
|
1592
2836
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
1593
2837
|
}
|
1594
2838
|
async getAll() {
|
@@ -1614,18 +2858,25 @@ class SimpleCache {
|
|
1614
2858
|
}
|
1615
2859
|
_map = new WeakMap();
|
1616
2860
|
|
1617
|
-
const
|
1618
|
-
const
|
1619
|
-
const
|
1620
|
-
const
|
1621
|
-
const
|
1622
|
-
const
|
2861
|
+
const greaterThan = (value) => ({ $gt: value });
|
2862
|
+
const gt = greaterThan;
|
2863
|
+
const greaterThanEquals = (value) => ({ $ge: value });
|
2864
|
+
const greaterEquals = greaterThanEquals;
|
2865
|
+
const gte = greaterThanEquals;
|
2866
|
+
const ge = greaterThanEquals;
|
2867
|
+
const lessThan = (value) => ({ $lt: value });
|
2868
|
+
const lt = lessThan;
|
2869
|
+
const lessThanEquals = (value) => ({ $le: value });
|
2870
|
+
const lessEquals = lessThanEquals;
|
2871
|
+
const lte = lessThanEquals;
|
2872
|
+
const le = lessThanEquals;
|
1623
2873
|
const exists = (column) => ({ $exists: column });
|
1624
2874
|
const notExists = (column) => ({ $notExists: column });
|
1625
2875
|
const startsWith = (value) => ({ $startsWith: value });
|
1626
2876
|
const endsWith = (value) => ({ $endsWith: value });
|
1627
2877
|
const pattern = (value) => ({ $pattern: value });
|
1628
2878
|
const is = (value) => ({ $is: value });
|
2879
|
+
const equals = is;
|
1629
2880
|
const isNot = (value) => ({ $isNot: value });
|
1630
2881
|
const contains = (value) => ({ $contains: value });
|
1631
2882
|
const includes = (value) => ({ $includes: value });
|
@@ -1646,31 +2897,42 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
1646
2897
|
throw TypeError("Cannot add the same private member more than once");
|
1647
2898
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1648
2899
|
};
|
1649
|
-
var
|
2900
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
2901
|
+
__accessCheck$2(obj, member, "write to private field");
|
2902
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
2903
|
+
return value;
|
2904
|
+
};
|
2905
|
+
var _tables, _schemaTables$1;
|
1650
2906
|
class SchemaPlugin extends XataPlugin {
|
1651
|
-
constructor(
|
2907
|
+
constructor(schemaTables) {
|
1652
2908
|
super();
|
1653
|
-
this.tableNames = tableNames;
|
1654
2909
|
__privateAdd$2(this, _tables, {});
|
2910
|
+
__privateAdd$2(this, _schemaTables$1, void 0);
|
2911
|
+
__privateSet$2(this, _schemaTables$1, schemaTables);
|
1655
2912
|
}
|
1656
2913
|
build(pluginOptions) {
|
1657
|
-
const db = new Proxy(
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
2914
|
+
const db = new Proxy(
|
2915
|
+
{},
|
2916
|
+
{
|
2917
|
+
get: (_target, table) => {
|
2918
|
+
if (!isString(table))
|
2919
|
+
throw new Error("Invalid table name");
|
2920
|
+
if (__privateGet$2(this, _tables)[table] === void 0) {
|
2921
|
+
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
2922
|
+
}
|
2923
|
+
return __privateGet$2(this, _tables)[table];
|
1663
2924
|
}
|
1664
|
-
return __privateGet$2(this, _tables)[table];
|
1665
2925
|
}
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
2926
|
+
);
|
2927
|
+
const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
|
2928
|
+
for (const table of tableNames) {
|
2929
|
+
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
1669
2930
|
}
|
1670
2931
|
return db;
|
1671
2932
|
}
|
1672
2933
|
}
|
1673
2934
|
_tables = new WeakMap();
|
2935
|
+
_schemaTables$1 = new WeakMap();
|
1674
2936
|
|
1675
2937
|
var __accessCheck$1 = (obj, member, msg) => {
|
1676
2938
|
if (!member.has(obj))
|
@@ -1694,82 +2956,77 @@ var __privateMethod$1 = (obj, member, method) => {
|
|
1694
2956
|
__accessCheck$1(obj, member, "access private method");
|
1695
2957
|
return method;
|
1696
2958
|
};
|
1697
|
-
var
|
2959
|
+
var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
|
1698
2960
|
class SearchPlugin extends XataPlugin {
|
1699
|
-
constructor(db) {
|
2961
|
+
constructor(db, schemaTables) {
|
1700
2962
|
super();
|
1701
2963
|
this.db = db;
|
1702
2964
|
__privateAdd$1(this, _search);
|
1703
|
-
__privateAdd$1(this,
|
1704
|
-
__privateAdd$1(this,
|
2965
|
+
__privateAdd$1(this, _getSchemaTables);
|
2966
|
+
__privateAdd$1(this, _schemaTables, void 0);
|
2967
|
+
__privateSet$1(this, _schemaTables, schemaTables);
|
1705
2968
|
}
|
1706
2969
|
build({ getFetchProps }) {
|
1707
2970
|
return {
|
1708
2971
|
all: async (query, options = {}) => {
|
1709
2972
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1710
|
-
const
|
2973
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1711
2974
|
return records.map((record) => {
|
1712
2975
|
const { table = "orphan" } = record.xata;
|
1713
|
-
return { table, record: initObject(this.db,
|
2976
|
+
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
1714
2977
|
});
|
1715
2978
|
},
|
1716
2979
|
byTable: async (query, options = {}) => {
|
1717
2980
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1718
|
-
const
|
2981
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1719
2982
|
return records.reduce((acc, record) => {
|
1720
2983
|
const { table = "orphan" } = record.xata;
|
1721
2984
|
const items = acc[table] ?? [];
|
1722
|
-
const item = initObject(this.db,
|
2985
|
+
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
1723
2986
|
return { ...acc, [table]: [...items, item] };
|
1724
2987
|
}, {});
|
1725
2988
|
}
|
1726
2989
|
};
|
1727
2990
|
}
|
1728
2991
|
}
|
1729
|
-
|
2992
|
+
_schemaTables = new WeakMap();
|
1730
2993
|
_search = new WeakSet();
|
1731
2994
|
search_fn = async function(query, options, getFetchProps) {
|
1732
2995
|
const fetchProps = await getFetchProps();
|
1733
|
-
const { tables, fuzziness } = options ?? {};
|
2996
|
+
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
1734
2997
|
const { records } = await searchBranch({
|
1735
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1736
|
-
body: { tables, query, fuzziness },
|
2998
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2999
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
1737
3000
|
...fetchProps
|
1738
3001
|
});
|
1739
3002
|
return records;
|
1740
3003
|
};
|
1741
|
-
|
1742
|
-
|
1743
|
-
if (__privateGet$1(this,
|
1744
|
-
return __privateGet$1(this,
|
3004
|
+
_getSchemaTables = new WeakSet();
|
3005
|
+
getSchemaTables_fn = async function(getFetchProps) {
|
3006
|
+
if (__privateGet$1(this, _schemaTables))
|
3007
|
+
return __privateGet$1(this, _schemaTables);
|
1745
3008
|
const fetchProps = await getFetchProps();
|
1746
3009
|
const { schema } = await getBranchDetails({
|
1747
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
3010
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
1748
3011
|
...fetchProps
|
1749
3012
|
});
|
1750
|
-
__privateSet$1(this,
|
1751
|
-
return schema;
|
3013
|
+
__privateSet$1(this, _schemaTables, schema.tables);
|
3014
|
+
return schema.tables;
|
1752
3015
|
};
|
1753
3016
|
|
1754
3017
|
const isBranchStrategyBuilder = (strategy) => {
|
1755
3018
|
return typeof strategy === "function";
|
1756
3019
|
};
|
1757
3020
|
|
1758
|
-
const envBranchNames = [
|
1759
|
-
"XATA_BRANCH",
|
1760
|
-
"VERCEL_GIT_COMMIT_REF",
|
1761
|
-
"CF_PAGES_BRANCH",
|
1762
|
-
"BRANCH"
|
1763
|
-
];
|
1764
3021
|
async function getCurrentBranchName(options) {
|
1765
|
-
const
|
1766
|
-
if (
|
1767
|
-
const details = await getDatabaseBranch(
|
3022
|
+
const { branch, envBranch } = getEnvironment();
|
3023
|
+
if (branch) {
|
3024
|
+
const details = await getDatabaseBranch(branch, options);
|
1768
3025
|
if (details)
|
1769
|
-
return
|
1770
|
-
console.warn(`Branch ${
|
3026
|
+
return branch;
|
3027
|
+
console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
|
1771
3028
|
}
|
1772
|
-
const gitBranch = await getGitBranch();
|
3029
|
+
const gitBranch = envBranch || await getGitBranch();
|
1773
3030
|
return resolveXataBranch(gitBranch, options);
|
1774
3031
|
}
|
1775
3032
|
async function getCurrentBranchDetails(options) {
|
@@ -1780,18 +3037,27 @@ async function resolveXataBranch(gitBranch, options) {
|
|
1780
3037
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1781
3038
|
const apiKey = options?.apiKey || getAPIKey();
|
1782
3039
|
if (!databaseURL)
|
1783
|
-
throw new Error(
|
3040
|
+
throw new Error(
|
3041
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
3042
|
+
);
|
1784
3043
|
if (!apiKey)
|
1785
|
-
throw new Error(
|
3044
|
+
throw new Error(
|
3045
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
3046
|
+
);
|
1786
3047
|
const [protocol, , host, , dbName] = databaseURL.split("/");
|
1787
|
-
const
|
3048
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
3049
|
+
if (!urlParts)
|
3050
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3051
|
+
const { workspace, region } = urlParts;
|
3052
|
+
const { fallbackBranch } = getEnvironment();
|
1788
3053
|
const { branch } = await resolveBranch({
|
1789
3054
|
apiKey,
|
1790
3055
|
apiUrl: databaseURL,
|
1791
3056
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1792
3057
|
workspacesApiUrl: `${protocol}//${host}`,
|
1793
|
-
pathParams: { dbName, workspace },
|
1794
|
-
queryParams: { gitBranch, fallbackBranch
|
3058
|
+
pathParams: { dbName, workspace, region },
|
3059
|
+
queryParams: { gitBranch, fallbackBranch },
|
3060
|
+
trace: defaultTrace
|
1795
3061
|
});
|
1796
3062
|
return branch;
|
1797
3063
|
}
|
@@ -1799,22 +3065,26 @@ async function getDatabaseBranch(branch, options) {
|
|
1799
3065
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1800
3066
|
const apiKey = options?.apiKey || getAPIKey();
|
1801
3067
|
if (!databaseURL)
|
1802
|
-
throw new Error(
|
3068
|
+
throw new Error(
|
3069
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
3070
|
+
);
|
1803
3071
|
if (!apiKey)
|
1804
|
-
throw new Error(
|
3072
|
+
throw new Error(
|
3073
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
3074
|
+
);
|
1805
3075
|
const [protocol, , host, , database] = databaseURL.split("/");
|
1806
|
-
const
|
1807
|
-
|
3076
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
3077
|
+
if (!urlParts)
|
3078
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3079
|
+
const { workspace, region } = urlParts;
|
1808
3080
|
try {
|
1809
3081
|
return await getBranchDetails({
|
1810
3082
|
apiKey,
|
1811
3083
|
apiUrl: databaseURL,
|
1812
3084
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1813
3085
|
workspacesApiUrl: `${protocol}//${host}`,
|
1814
|
-
pathParams: {
|
1815
|
-
|
1816
|
-
workspace
|
1817
|
-
}
|
3086
|
+
pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
|
3087
|
+
trace: defaultTrace
|
1818
3088
|
});
|
1819
3089
|
} catch (err) {
|
1820
3090
|
if (isObject(err) && err.status === 404)
|
@@ -1822,21 +3092,10 @@ async function getDatabaseBranch(branch, options) {
|
|
1822
3092
|
throw err;
|
1823
3093
|
}
|
1824
3094
|
}
|
1825
|
-
function getBranchByEnvVariable() {
|
1826
|
-
for (const name of envBranchNames) {
|
1827
|
-
const value = getEnvVariable(name);
|
1828
|
-
if (value) {
|
1829
|
-
return value;
|
1830
|
-
}
|
1831
|
-
}
|
1832
|
-
try {
|
1833
|
-
return XATA_BRANCH;
|
1834
|
-
} catch (err) {
|
1835
|
-
}
|
1836
|
-
}
|
1837
3095
|
function getDatabaseURL() {
|
1838
3096
|
try {
|
1839
|
-
|
3097
|
+
const { databaseURL } = getEnvironment();
|
3098
|
+
return databaseURL;
|
1840
3099
|
} catch (err) {
|
1841
3100
|
return void 0;
|
1842
3101
|
}
|
@@ -1865,20 +3124,23 @@ var __privateMethod = (obj, member, method) => {
|
|
1865
3124
|
return method;
|
1866
3125
|
};
|
1867
3126
|
const buildClient = (plugins) => {
|
1868
|
-
var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
3127
|
+
var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
1869
3128
|
return _a = class {
|
1870
|
-
constructor(options = {},
|
3129
|
+
constructor(options = {}, schemaTables) {
|
1871
3130
|
__privateAdd(this, _parseOptions);
|
1872
3131
|
__privateAdd(this, _getFetchProps);
|
1873
3132
|
__privateAdd(this, _evaluateBranch);
|
1874
3133
|
__privateAdd(this, _branch, void 0);
|
3134
|
+
__privateAdd(this, _options, void 0);
|
1875
3135
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
3136
|
+
__privateSet(this, _options, safeOptions);
|
1876
3137
|
const pluginOptions = {
|
1877
3138
|
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
1878
|
-
cache: safeOptions.cache
|
3139
|
+
cache: safeOptions.cache,
|
3140
|
+
trace: safeOptions.trace
|
1879
3141
|
};
|
1880
|
-
const db = new SchemaPlugin(
|
1881
|
-
const search = new SearchPlugin(db).build(pluginOptions);
|
3142
|
+
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
3143
|
+
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
1882
3144
|
this.db = db;
|
1883
3145
|
this.search = search;
|
1884
3146
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
@@ -1894,22 +3156,33 @@ const buildClient = (plugins) => {
|
|
1894
3156
|
}
|
1895
3157
|
}
|
1896
3158
|
}
|
1897
|
-
|
3159
|
+
async getConfig() {
|
3160
|
+
const databaseURL = __privateGet(this, _options).databaseURL;
|
3161
|
+
const branch = await __privateGet(this, _options).branch();
|
3162
|
+
return { databaseURL, branch };
|
3163
|
+
}
|
3164
|
+
}, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
3165
|
+
const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
|
3166
|
+
const isBrowser = typeof window !== "undefined";
|
3167
|
+
if (isBrowser && !enableBrowser) {
|
3168
|
+
throw new Error(
|
3169
|
+
"You are trying to use Xata from the browser, which is potentially a non-secure environment. If you understand the security concerns, such as leaking your credentials, pass `enableBrowser: true` to the client options to remove this error."
|
3170
|
+
);
|
3171
|
+
}
|
1898
3172
|
const fetch = getFetchImplementation(options?.fetch);
|
1899
3173
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1900
3174
|
const apiKey = options?.apiKey || getAPIKey();
|
1901
|
-
const cache = options?.cache ?? new SimpleCache({
|
3175
|
+
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
3176
|
+
const trace = options?.trace ?? defaultTrace;
|
1902
3177
|
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
1903
|
-
if (!
|
1904
|
-
throw new Error("
|
3178
|
+
if (!apiKey) {
|
3179
|
+
throw new Error("Option apiKey is required");
|
1905
3180
|
}
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
apiKey,
|
1910
|
-
|
1911
|
-
branch
|
1912
|
-
}) {
|
3181
|
+
if (!databaseURL) {
|
3182
|
+
throw new Error("Option databaseURL is required");
|
3183
|
+
}
|
3184
|
+
return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser };
|
3185
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
|
1913
3186
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
1914
3187
|
if (!branchValue)
|
1915
3188
|
throw new Error("Unable to resolve branch value");
|
@@ -1919,9 +3192,11 @@ const buildClient = (plugins) => {
|
|
1919
3192
|
apiUrl: "",
|
1920
3193
|
workspacesApiUrl: (path, params) => {
|
1921
3194
|
const hasBranch = params.dbBranchName ?? params.branch;
|
1922
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
|
3195
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
|
1923
3196
|
return databaseURL + newPath;
|
1924
|
-
}
|
3197
|
+
},
|
3198
|
+
trace,
|
3199
|
+
clientID
|
1925
3200
|
};
|
1926
3201
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
1927
3202
|
if (__privateGet(this, _branch))
|
@@ -1944,6 +3219,88 @@ const buildClient = (plugins) => {
|
|
1944
3219
|
class BaseClient extends buildClient() {
|
1945
3220
|
}
|
1946
3221
|
|
3222
|
+
const META = "__";
|
3223
|
+
const VALUE = "___";
|
3224
|
+
class Serializer {
|
3225
|
+
constructor() {
|
3226
|
+
this.classes = {};
|
3227
|
+
}
|
3228
|
+
add(clazz) {
|
3229
|
+
this.classes[clazz.name] = clazz;
|
3230
|
+
}
|
3231
|
+
toJSON(data) {
|
3232
|
+
function visit(obj) {
|
3233
|
+
if (Array.isArray(obj))
|
3234
|
+
return obj.map(visit);
|
3235
|
+
const type = typeof obj;
|
3236
|
+
if (type === "undefined")
|
3237
|
+
return { [META]: "undefined" };
|
3238
|
+
if (type === "bigint")
|
3239
|
+
return { [META]: "bigint", [VALUE]: obj.toString() };
|
3240
|
+
if (obj === null || type !== "object")
|
3241
|
+
return obj;
|
3242
|
+
const constructor = obj.constructor;
|
3243
|
+
const o = { [META]: constructor.name };
|
3244
|
+
for (const [key, value] of Object.entries(obj)) {
|
3245
|
+
o[key] = visit(value);
|
3246
|
+
}
|
3247
|
+
if (constructor === Date)
|
3248
|
+
o[VALUE] = obj.toISOString();
|
3249
|
+
if (constructor === Map)
|
3250
|
+
o[VALUE] = Object.fromEntries(obj);
|
3251
|
+
if (constructor === Set)
|
3252
|
+
o[VALUE] = [...obj];
|
3253
|
+
return o;
|
3254
|
+
}
|
3255
|
+
return JSON.stringify(visit(data));
|
3256
|
+
}
|
3257
|
+
fromJSON(json) {
|
3258
|
+
return JSON.parse(json, (key, value) => {
|
3259
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
3260
|
+
const { [META]: clazz, [VALUE]: val, ...rest } = value;
|
3261
|
+
const constructor = this.classes[clazz];
|
3262
|
+
if (constructor) {
|
3263
|
+
return Object.assign(Object.create(constructor.prototype), rest);
|
3264
|
+
}
|
3265
|
+
if (clazz === "Date")
|
3266
|
+
return new Date(val);
|
3267
|
+
if (clazz === "Set")
|
3268
|
+
return new Set(val);
|
3269
|
+
if (clazz === "Map")
|
3270
|
+
return new Map(Object.entries(val));
|
3271
|
+
if (clazz === "bigint")
|
3272
|
+
return BigInt(val);
|
3273
|
+
if (clazz === "undefined")
|
3274
|
+
return void 0;
|
3275
|
+
return rest;
|
3276
|
+
}
|
3277
|
+
return value;
|
3278
|
+
});
|
3279
|
+
}
|
3280
|
+
}
|
3281
|
+
const defaultSerializer = new Serializer();
|
3282
|
+
const serialize = (data) => {
|
3283
|
+
return defaultSerializer.toJSON(data);
|
3284
|
+
};
|
3285
|
+
const deserialize = (json) => {
|
3286
|
+
return defaultSerializer.fromJSON(json);
|
3287
|
+
};
|
3288
|
+
|
3289
|
+
function buildWorkerRunner(config) {
|
3290
|
+
return function xataWorker(name, _worker) {
|
3291
|
+
return async (...args) => {
|
3292
|
+
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
3293
|
+
const result = await fetch(url, {
|
3294
|
+
method: "POST",
|
3295
|
+
headers: { "Content-Type": "application/json" },
|
3296
|
+
body: serialize({ args })
|
3297
|
+
});
|
3298
|
+
const text = await result.text();
|
3299
|
+
return deserialize(text);
|
3300
|
+
};
|
3301
|
+
};
|
3302
|
+
}
|
3303
|
+
|
1947
3304
|
class XataError extends Error {
|
1948
3305
|
constructor(message, status) {
|
1949
3306
|
super(message);
|
@@ -1951,5 +3308,5 @@ class XataError extends Error {
|
|
1951
3308
|
}
|
1952
3309
|
}
|
1953
3310
|
|
1954
|
-
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, Repository, RestRepository, SchemaPlugin, SearchPlugin, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, 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, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
|
3311
|
+
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, aggregateTable, applyBranchSchemaEdit, branchTransaction, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, dEPRECATEDcreateDatabase, dEPRECATEDdeleteDatabase, dEPRECATEDgetDatabaseList, dEPRECATEDgetDatabaseMetadata, dEPRECATEDupdateDatabaseMetadata, 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, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
|
1955
3312
|
//# sourceMappingURL=index.mjs.map
|