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