@xata.io/client 0.0.0-alpha.vf0e0021 → 0.0.0-alpha.vf0fa187
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +3 -2
- package/.turbo/turbo-add-version.log +4 -0
- package/.turbo/turbo-build.log +13 -0
- package/CHANGELOG.md +162 -0
- package/README.md +3 -269
- package/dist/index.cjs +1633 -714
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4186 -2407
- package/dist/index.mjs +1621 -690
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -8
- package/rollup.config.mjs +44 -0
- package/Usage.md +0 -451
- package/rollup.config.js +0 -29
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const defaultTrace = async (
|
|
1
|
+
const defaultTrace = async (name, fn, _options) => {
|
|
2
2
|
return await fn({
|
|
3
|
+
name,
|
|
3
4
|
setAttributes: () => {
|
|
4
5
|
return;
|
|
5
6
|
}
|
|
@@ -38,6 +39,21 @@ function isString(value) {
|
|
|
38
39
|
function isStringArray(value) {
|
|
39
40
|
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
|
40
41
|
}
|
|
42
|
+
function isNumber(value) {
|
|
43
|
+
return isDefined(value) && typeof value === "number";
|
|
44
|
+
}
|
|
45
|
+
function parseNumber(value) {
|
|
46
|
+
if (isNumber(value)) {
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
if (isString(value)) {
|
|
50
|
+
const parsed = Number(value);
|
|
51
|
+
if (!Number.isNaN(parsed)) {
|
|
52
|
+
return parsed;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
41
57
|
function toBase64(value) {
|
|
42
58
|
try {
|
|
43
59
|
return btoa(value);
|
|
@@ -46,10 +62,31 @@ function toBase64(value) {
|
|
|
46
62
|
return buf.from(value).toString("base64");
|
|
47
63
|
}
|
|
48
64
|
}
|
|
65
|
+
function deepMerge(a, b) {
|
|
66
|
+
const result = { ...a };
|
|
67
|
+
for (const [key, value] of Object.entries(b)) {
|
|
68
|
+
if (isObject(value) && isObject(result[key])) {
|
|
69
|
+
result[key] = deepMerge(result[key], value);
|
|
70
|
+
} else {
|
|
71
|
+
result[key] = value;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
function chunk(array, chunkSize) {
|
|
77
|
+
const result = [];
|
|
78
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
79
|
+
result.push(array.slice(i, i + chunkSize));
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
async function timeout(ms) {
|
|
84
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
85
|
+
}
|
|
49
86
|
|
|
50
87
|
function getEnvironment() {
|
|
51
88
|
try {
|
|
52
|
-
if (
|
|
89
|
+
if (isDefined(process) && isDefined(process.env)) {
|
|
53
90
|
return {
|
|
54
91
|
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
|
55
92
|
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
|
@@ -80,6 +117,25 @@ function getEnvironment() {
|
|
|
80
117
|
fallbackBranch: getGlobalFallbackBranch()
|
|
81
118
|
};
|
|
82
119
|
}
|
|
120
|
+
function getEnableBrowserVariable() {
|
|
121
|
+
try {
|
|
122
|
+
if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
|
|
123
|
+
return process.env.XATA_ENABLE_BROWSER === "true";
|
|
124
|
+
}
|
|
125
|
+
} catch (err) {
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
|
|
129
|
+
return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
|
|
130
|
+
}
|
|
131
|
+
} catch (err) {
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
|
|
135
|
+
} catch (err) {
|
|
136
|
+
return void 0;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
83
139
|
function getGlobalApiKey() {
|
|
84
140
|
try {
|
|
85
141
|
return XATA_API_KEY;
|
|
@@ -114,9 +170,6 @@ async function getGitBranch() {
|
|
|
114
170
|
const nodeModule = ["child", "process"].join("_");
|
|
115
171
|
const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
|
|
116
172
|
try {
|
|
117
|
-
if (typeof require === "function") {
|
|
118
|
-
return require(nodeModule).execSync(fullCmd, execOptions).trim();
|
|
119
|
-
}
|
|
120
173
|
const { execSync } = await import(nodeModule);
|
|
121
174
|
return execSync(fullCmd, execOptions).toString().trim();
|
|
122
175
|
} catch (err) {
|
|
@@ -139,6 +192,29 @@ function getAPIKey() {
|
|
|
139
192
|
}
|
|
140
193
|
}
|
|
141
194
|
|
|
195
|
+
var __accessCheck$8 = (obj, member, msg) => {
|
|
196
|
+
if (!member.has(obj))
|
|
197
|
+
throw TypeError("Cannot " + msg);
|
|
198
|
+
};
|
|
199
|
+
var __privateGet$8 = (obj, member, getter) => {
|
|
200
|
+
__accessCheck$8(obj, member, "read from private field");
|
|
201
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
202
|
+
};
|
|
203
|
+
var __privateAdd$8 = (obj, member, value) => {
|
|
204
|
+
if (member.has(obj))
|
|
205
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
206
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
207
|
+
};
|
|
208
|
+
var __privateSet$8 = (obj, member, value, setter) => {
|
|
209
|
+
__accessCheck$8(obj, member, "write to private field");
|
|
210
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
211
|
+
return value;
|
|
212
|
+
};
|
|
213
|
+
var __privateMethod$4 = (obj, member, method) => {
|
|
214
|
+
__accessCheck$8(obj, member, "access private method");
|
|
215
|
+
return method;
|
|
216
|
+
};
|
|
217
|
+
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
|
142
218
|
function getFetchImplementation(userFetch) {
|
|
143
219
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
|
144
220
|
const fetchImpl = userFetch ?? globalFetch;
|
|
@@ -149,8 +225,81 @@ function getFetchImplementation(userFetch) {
|
|
|
149
225
|
}
|
|
150
226
|
return fetchImpl;
|
|
151
227
|
}
|
|
228
|
+
class ApiRequestPool {
|
|
229
|
+
constructor(concurrency = 10) {
|
|
230
|
+
__privateAdd$8(this, _enqueue);
|
|
231
|
+
__privateAdd$8(this, _fetch, void 0);
|
|
232
|
+
__privateAdd$8(this, _queue, void 0);
|
|
233
|
+
__privateAdd$8(this, _concurrency, void 0);
|
|
234
|
+
__privateSet$8(this, _queue, []);
|
|
235
|
+
__privateSet$8(this, _concurrency, concurrency);
|
|
236
|
+
this.running = 0;
|
|
237
|
+
this.started = 0;
|
|
238
|
+
}
|
|
239
|
+
setFetch(fetch2) {
|
|
240
|
+
__privateSet$8(this, _fetch, fetch2);
|
|
241
|
+
}
|
|
242
|
+
getFetch() {
|
|
243
|
+
if (!__privateGet$8(this, _fetch)) {
|
|
244
|
+
throw new Error("Fetch not set");
|
|
245
|
+
}
|
|
246
|
+
return __privateGet$8(this, _fetch);
|
|
247
|
+
}
|
|
248
|
+
request(url, options) {
|
|
249
|
+
const start = new Date();
|
|
250
|
+
const fetch2 = this.getFetch();
|
|
251
|
+
const runRequest = async (stalled = false) => {
|
|
252
|
+
const response = await fetch2(url, options);
|
|
253
|
+
if (response.status === 429) {
|
|
254
|
+
const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
|
|
255
|
+
await timeout(rateLimitReset * 1e3);
|
|
256
|
+
return await runRequest(true);
|
|
257
|
+
}
|
|
258
|
+
if (stalled) {
|
|
259
|
+
const stalledTime = new Date().getTime() - start.getTime();
|
|
260
|
+
console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
|
|
261
|
+
}
|
|
262
|
+
return response;
|
|
263
|
+
};
|
|
264
|
+
return __privateMethod$4(this, _enqueue, enqueue_fn).call(this, async () => {
|
|
265
|
+
return await runRequest();
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
_fetch = new WeakMap();
|
|
270
|
+
_queue = new WeakMap();
|
|
271
|
+
_concurrency = new WeakMap();
|
|
272
|
+
_enqueue = new WeakSet();
|
|
273
|
+
enqueue_fn = function(task) {
|
|
274
|
+
const promise = new Promise((resolve) => __privateGet$8(this, _queue).push(resolve)).finally(() => {
|
|
275
|
+
this.started--;
|
|
276
|
+
this.running++;
|
|
277
|
+
}).then(() => task()).finally(() => {
|
|
278
|
+
this.running--;
|
|
279
|
+
const next = __privateGet$8(this, _queue).shift();
|
|
280
|
+
if (next !== void 0) {
|
|
281
|
+
this.started++;
|
|
282
|
+
next();
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
if (this.running + this.started < __privateGet$8(this, _concurrency)) {
|
|
286
|
+
const next = __privateGet$8(this, _queue).shift();
|
|
287
|
+
if (next !== void 0) {
|
|
288
|
+
this.started++;
|
|
289
|
+
next();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return promise;
|
|
293
|
+
};
|
|
152
294
|
|
|
153
|
-
|
|
295
|
+
function generateUUID() {
|
|
296
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
297
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
298
|
+
return v.toString(16);
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const VERSION = "0.22.0";
|
|
154
303
|
|
|
155
304
|
class ErrorWithCause extends Error {
|
|
156
305
|
constructor(message, options) {
|
|
@@ -161,7 +310,7 @@ class FetcherError extends ErrorWithCause {
|
|
|
161
310
|
constructor(status, data, requestId) {
|
|
162
311
|
super(getMessage(data));
|
|
163
312
|
this.status = status;
|
|
164
|
-
this.errors = isBulkError(data) ? data.errors :
|
|
313
|
+
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
|
165
314
|
this.requestId = requestId;
|
|
166
315
|
if (data instanceof Error) {
|
|
167
316
|
this.stack = data.stack;
|
|
@@ -193,6 +342,7 @@ function getMessage(data) {
|
|
|
193
342
|
}
|
|
194
343
|
}
|
|
195
344
|
|
|
345
|
+
const pool = new ApiRequestPool();
|
|
196
346
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
197
347
|
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
|
198
348
|
if (value === void 0 || value === null)
|
|
@@ -207,58 +357,77 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
|
207
357
|
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
|
208
358
|
};
|
|
209
359
|
function buildBaseUrl({
|
|
360
|
+
endpoint,
|
|
210
361
|
path,
|
|
211
362
|
workspacesApiUrl,
|
|
212
363
|
apiUrl,
|
|
213
|
-
pathParams
|
|
364
|
+
pathParams = {}
|
|
214
365
|
}) {
|
|
215
|
-
if (
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
366
|
+
if (endpoint === "dataPlane") {
|
|
367
|
+
const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
|
368
|
+
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
|
369
|
+
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
|
370
|
+
}
|
|
371
|
+
return `${apiUrl}${path}`;
|
|
219
372
|
}
|
|
220
373
|
function hostHeader(url) {
|
|
221
374
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
|
222
375
|
const { groups } = pattern.exec(url) ?? {};
|
|
223
376
|
return groups?.host ? { Host: groups.host } : {};
|
|
224
377
|
}
|
|
378
|
+
const defaultClientID = generateUUID();
|
|
225
379
|
async function fetch$1({
|
|
226
380
|
url: path,
|
|
227
381
|
method,
|
|
228
382
|
body,
|
|
229
|
-
headers,
|
|
383
|
+
headers: customHeaders,
|
|
230
384
|
pathParams,
|
|
231
385
|
queryParams,
|
|
232
386
|
fetchImpl,
|
|
233
387
|
apiKey,
|
|
388
|
+
endpoint,
|
|
234
389
|
apiUrl,
|
|
235
390
|
workspacesApiUrl,
|
|
236
|
-
trace
|
|
391
|
+
trace,
|
|
392
|
+
signal,
|
|
393
|
+
clientID,
|
|
394
|
+
sessionID,
|
|
395
|
+
clientName,
|
|
396
|
+
fetchOptions = {}
|
|
237
397
|
}) {
|
|
238
|
-
|
|
398
|
+
pool.setFetch(fetchImpl);
|
|
399
|
+
return await trace(
|
|
239
400
|
`${method.toUpperCase()} ${path}`,
|
|
240
401
|
async ({ setAttributes }) => {
|
|
241
|
-
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
|
402
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
|
242
403
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
|
243
404
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
|
244
405
|
setAttributes({
|
|
245
406
|
[TraceAttributes.HTTP_URL]: url,
|
|
246
407
|
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
|
247
408
|
});
|
|
248
|
-
const
|
|
409
|
+
const xataAgent = compact([
|
|
410
|
+
["client", "TS_SDK"],
|
|
411
|
+
["version", VERSION],
|
|
412
|
+
isDefined(clientName) ? ["service", clientName] : void 0
|
|
413
|
+
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
|
414
|
+
const headers = {
|
|
415
|
+
"Accept-Encoding": "identity",
|
|
416
|
+
"Content-Type": "application/json",
|
|
417
|
+
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
|
418
|
+
"X-Xata-Session-ID": sessionID ?? generateUUID(),
|
|
419
|
+
"X-Xata-Agent": xataAgent,
|
|
420
|
+
...customHeaders,
|
|
421
|
+
...hostHeader(fullUrl),
|
|
422
|
+
Authorization: `Bearer ${apiKey}`
|
|
423
|
+
};
|
|
424
|
+
const response = await pool.request(url, {
|
|
425
|
+
...fetchOptions,
|
|
249
426
|
method: method.toUpperCase(),
|
|
250
427
|
body: body ? JSON.stringify(body) : void 0,
|
|
251
|
-
headers
|
|
252
|
-
|
|
253
|
-
"User-Agent": `Xata client-ts/${VERSION}`,
|
|
254
|
-
...headers,
|
|
255
|
-
...hostHeader(fullUrl),
|
|
256
|
-
Authorization: `Bearer ${apiKey}`
|
|
257
|
-
}
|
|
428
|
+
headers,
|
|
429
|
+
signal
|
|
258
430
|
});
|
|
259
|
-
if (response.status === 204) {
|
|
260
|
-
return {};
|
|
261
|
-
}
|
|
262
431
|
const { host, protocol } = parseUrl(response.url);
|
|
263
432
|
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
|
264
433
|
setAttributes({
|
|
@@ -268,6 +437,12 @@ async function fetch$1({
|
|
|
268
437
|
[TraceAttributes.HTTP_HOST]: host,
|
|
269
438
|
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
|
270
439
|
});
|
|
440
|
+
if (response.status === 204) {
|
|
441
|
+
return {};
|
|
442
|
+
}
|
|
443
|
+
if (response.status === 429) {
|
|
444
|
+
throw new FetcherError(response.status, "Rate limit exceeded", requestId);
|
|
445
|
+
}
|
|
271
446
|
try {
|
|
272
447
|
const jsonResponse = await response.json();
|
|
273
448
|
if (response.ok) {
|
|
@@ -290,294 +465,152 @@ function parseUrl(url) {
|
|
|
290
465
|
}
|
|
291
466
|
}
|
|
292
467
|
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
const
|
|
296
|
-
const getUserAPIKeys = (variables) => fetch$1({
|
|
297
|
-
url: "/user/keys",
|
|
298
|
-
method: "get",
|
|
299
|
-
...variables
|
|
300
|
-
});
|
|
301
|
-
const createUserAPIKey = (variables) => fetch$1({
|
|
302
|
-
url: "/user/keys/{keyName}",
|
|
303
|
-
method: "post",
|
|
304
|
-
...variables
|
|
305
|
-
});
|
|
306
|
-
const deleteUserAPIKey = (variables) => fetch$1({
|
|
307
|
-
url: "/user/keys/{keyName}",
|
|
308
|
-
method: "delete",
|
|
309
|
-
...variables
|
|
310
|
-
});
|
|
311
|
-
const createWorkspace = (variables) => fetch$1({
|
|
312
|
-
url: "/workspaces",
|
|
313
|
-
method: "post",
|
|
314
|
-
...variables
|
|
315
|
-
});
|
|
316
|
-
const getWorkspacesList = (variables) => fetch$1({
|
|
317
|
-
url: "/workspaces",
|
|
318
|
-
method: "get",
|
|
319
|
-
...variables
|
|
320
|
-
});
|
|
321
|
-
const getWorkspace = (variables) => fetch$1({
|
|
322
|
-
url: "/workspaces/{workspaceId}",
|
|
323
|
-
method: "get",
|
|
324
|
-
...variables
|
|
325
|
-
});
|
|
326
|
-
const updateWorkspace = (variables) => fetch$1({
|
|
327
|
-
url: "/workspaces/{workspaceId}",
|
|
328
|
-
method: "put",
|
|
329
|
-
...variables
|
|
330
|
-
});
|
|
331
|
-
const deleteWorkspace = (variables) => fetch$1({
|
|
332
|
-
url: "/workspaces/{workspaceId}",
|
|
333
|
-
method: "delete",
|
|
334
|
-
...variables
|
|
335
|
-
});
|
|
336
|
-
const getWorkspaceMembersList = (variables) => fetch$1({
|
|
337
|
-
url: "/workspaces/{workspaceId}/members",
|
|
338
|
-
method: "get",
|
|
339
|
-
...variables
|
|
340
|
-
});
|
|
341
|
-
const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
|
|
342
|
-
const removeWorkspaceMember = (variables) => fetch$1({
|
|
343
|
-
url: "/workspaces/{workspaceId}/members/{userId}",
|
|
344
|
-
method: "delete",
|
|
345
|
-
...variables
|
|
346
|
-
});
|
|
347
|
-
const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
|
|
348
|
-
const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
|
|
349
|
-
const cancelWorkspaceMemberInvite = (variables) => fetch$1({
|
|
350
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
|
351
|
-
method: "delete",
|
|
352
|
-
...variables
|
|
353
|
-
});
|
|
354
|
-
const resendWorkspaceMemberInvite = (variables) => fetch$1({
|
|
355
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
|
|
356
|
-
method: "post",
|
|
357
|
-
...variables
|
|
358
|
-
});
|
|
359
|
-
const acceptWorkspaceMemberInvite = (variables) => fetch$1({
|
|
360
|
-
url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
|
|
361
|
-
method: "post",
|
|
362
|
-
...variables
|
|
363
|
-
});
|
|
364
|
-
const getDatabaseList = (variables) => fetch$1({
|
|
365
|
-
url: "/dbs",
|
|
366
|
-
method: "get",
|
|
367
|
-
...variables
|
|
368
|
-
});
|
|
369
|
-
const getBranchList = (variables) => fetch$1({
|
|
370
|
-
url: "/dbs/{dbName}",
|
|
371
|
-
method: "get",
|
|
372
|
-
...variables
|
|
373
|
-
});
|
|
374
|
-
const createDatabase = (variables) => fetch$1({
|
|
375
|
-
url: "/dbs/{dbName}",
|
|
376
|
-
method: "put",
|
|
377
|
-
...variables
|
|
378
|
-
});
|
|
379
|
-
const deleteDatabase = (variables) => fetch$1({
|
|
468
|
+
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
|
469
|
+
|
|
470
|
+
const getBranchList = (variables, signal) => dataPlaneFetch({
|
|
380
471
|
url: "/dbs/{dbName}",
|
|
381
|
-
method: "delete",
|
|
382
|
-
...variables
|
|
383
|
-
});
|
|
384
|
-
const getDatabaseMetadata = (variables) => fetch$1({
|
|
385
|
-
url: "/dbs/{dbName}/metadata",
|
|
386
|
-
method: "get",
|
|
387
|
-
...variables
|
|
388
|
-
});
|
|
389
|
-
const updateDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
|
|
390
|
-
const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
|
|
391
|
-
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
|
392
|
-
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
|
393
|
-
const resolveBranch = (variables) => fetch$1({
|
|
394
|
-
url: "/dbs/{dbName}/resolveBranch",
|
|
395
|
-
method: "get",
|
|
396
|
-
...variables
|
|
397
|
-
});
|
|
398
|
-
const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
|
|
399
|
-
const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
|
|
400
|
-
const getMigrationRequest = (variables) => fetch$1({
|
|
401
|
-
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
|
402
472
|
method: "get",
|
|
403
|
-
...variables
|
|
473
|
+
...variables,
|
|
474
|
+
signal
|
|
404
475
|
});
|
|
405
|
-
const
|
|
406
|
-
const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
|
|
407
|
-
const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
|
|
408
|
-
const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
|
|
409
|
-
const mergeMigrationRequest = (variables) => fetch$1({
|
|
410
|
-
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
|
411
|
-
method: "post",
|
|
412
|
-
...variables
|
|
413
|
-
});
|
|
414
|
-
const getBranchDetails = (variables) => fetch$1({
|
|
476
|
+
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
|
415
477
|
url: "/db/{dbBranchName}",
|
|
416
478
|
method: "get",
|
|
417
|
-
...variables
|
|
479
|
+
...variables,
|
|
480
|
+
signal
|
|
418
481
|
});
|
|
419
|
-
const createBranch = (variables) =>
|
|
420
|
-
const deleteBranch = (variables) =>
|
|
482
|
+
const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
|
|
483
|
+
const deleteBranch = (variables, signal) => dataPlaneFetch({
|
|
421
484
|
url: "/db/{dbBranchName}",
|
|
422
485
|
method: "delete",
|
|
423
|
-
...variables
|
|
486
|
+
...variables,
|
|
487
|
+
signal
|
|
424
488
|
});
|
|
425
|
-
const updateBranchMetadata = (variables) =>
|
|
489
|
+
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
|
426
490
|
url: "/db/{dbBranchName}/metadata",
|
|
427
491
|
method: "put",
|
|
428
|
-
...variables
|
|
492
|
+
...variables,
|
|
493
|
+
signal
|
|
429
494
|
});
|
|
430
|
-
const getBranchMetadata = (variables) =>
|
|
495
|
+
const getBranchMetadata = (variables, signal) => dataPlaneFetch({
|
|
431
496
|
url: "/db/{dbBranchName}/metadata",
|
|
432
497
|
method: "get",
|
|
433
|
-
...variables
|
|
498
|
+
...variables,
|
|
499
|
+
signal
|
|
434
500
|
});
|
|
435
|
-
const
|
|
436
|
-
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
|
437
|
-
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
|
438
|
-
const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
|
|
439
|
-
const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
|
|
440
|
-
const updateBranchSchema = (variables) => fetch$1({
|
|
441
|
-
url: "/db/{dbBranchName}/schema/update",
|
|
442
|
-
method: "post",
|
|
443
|
-
...variables
|
|
444
|
-
});
|
|
445
|
-
const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
|
|
446
|
-
const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
|
|
447
|
-
const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
|
|
448
|
-
const getBranchStats = (variables) => fetch$1({
|
|
501
|
+
const getBranchStats = (variables, signal) => dataPlaneFetch({
|
|
449
502
|
url: "/db/{dbBranchName}/stats",
|
|
450
503
|
method: "get",
|
|
451
|
-
...variables
|
|
504
|
+
...variables,
|
|
505
|
+
signal
|
|
506
|
+
});
|
|
507
|
+
const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
|
|
508
|
+
const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
|
|
509
|
+
const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
|
|
510
|
+
const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
|
|
511
|
+
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
|
512
|
+
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
|
513
|
+
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
|
514
|
+
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
|
515
|
+
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
|
516
|
+
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
|
517
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
|
518
|
+
method: "get",
|
|
519
|
+
...variables,
|
|
520
|
+
signal
|
|
452
521
|
});
|
|
453
|
-
const
|
|
522
|
+
const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
|
|
523
|
+
const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
|
|
524
|
+
const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
|
|
525
|
+
const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
|
|
526
|
+
const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
|
|
527
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
|
528
|
+
method: "post",
|
|
529
|
+
...variables,
|
|
530
|
+
signal
|
|
531
|
+
});
|
|
532
|
+
const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
|
|
533
|
+
const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
|
|
534
|
+
const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
|
|
535
|
+
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
|
536
|
+
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
|
537
|
+
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
|
538
|
+
const createTable = (variables, signal) => dataPlaneFetch({
|
|
454
539
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
|
455
540
|
method: "put",
|
|
456
|
-
...variables
|
|
541
|
+
...variables,
|
|
542
|
+
signal
|
|
457
543
|
});
|
|
458
|
-
const deleteTable = (variables) =>
|
|
544
|
+
const deleteTable = (variables, signal) => dataPlaneFetch({
|
|
459
545
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
|
460
546
|
method: "delete",
|
|
461
|
-
...variables
|
|
462
|
-
|
|
463
|
-
const updateTable = (variables) => fetch$1({
|
|
464
|
-
url: "/db/{dbBranchName}/tables/{tableName}",
|
|
465
|
-
method: "patch",
|
|
466
|
-
...variables
|
|
547
|
+
...variables,
|
|
548
|
+
signal
|
|
467
549
|
});
|
|
468
|
-
const
|
|
550
|
+
const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
|
|
551
|
+
const getTableSchema = (variables, signal) => dataPlaneFetch({
|
|
469
552
|
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
|
470
553
|
method: "get",
|
|
471
|
-
...variables
|
|
554
|
+
...variables,
|
|
555
|
+
signal
|
|
472
556
|
});
|
|
473
|
-
const setTableSchema = (variables) =>
|
|
474
|
-
|
|
475
|
-
method: "put",
|
|
476
|
-
...variables
|
|
477
|
-
});
|
|
478
|
-
const getTableColumns = (variables) => fetch$1({
|
|
557
|
+
const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
|
|
558
|
+
const getTableColumns = (variables, signal) => dataPlaneFetch({
|
|
479
559
|
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
|
480
560
|
method: "get",
|
|
481
|
-
...variables
|
|
561
|
+
...variables,
|
|
562
|
+
signal
|
|
482
563
|
});
|
|
483
|
-
const addTableColumn = (variables) =>
|
|
484
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
});
|
|
488
|
-
const getColumn = (variables) => fetch$1({
|
|
564
|
+
const addTableColumn = (variables, signal) => dataPlaneFetch(
|
|
565
|
+
{ url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
|
|
566
|
+
);
|
|
567
|
+
const getColumn = (variables, signal) => dataPlaneFetch({
|
|
489
568
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
|
490
569
|
method: "get",
|
|
491
|
-
...variables
|
|
492
|
-
|
|
493
|
-
const deleteColumn = (variables) => fetch$1({
|
|
494
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
|
495
|
-
method: "delete",
|
|
496
|
-
...variables
|
|
570
|
+
...variables,
|
|
571
|
+
signal
|
|
497
572
|
});
|
|
498
|
-
const updateColumn = (variables) =>
|
|
573
|
+
const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
|
|
574
|
+
const deleteColumn = (variables, signal) => dataPlaneFetch({
|
|
499
575
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
|
500
|
-
method: "patch",
|
|
501
|
-
...variables
|
|
502
|
-
});
|
|
503
|
-
const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
|
|
504
|
-
const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
|
|
505
|
-
const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
|
|
506
|
-
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
|
507
|
-
const deleteRecord = (variables) => fetch$1({
|
|
508
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
|
509
576
|
method: "delete",
|
|
510
|
-
...variables
|
|
577
|
+
...variables,
|
|
578
|
+
signal
|
|
511
579
|
});
|
|
512
|
-
const
|
|
580
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
|
581
|
+
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
|
582
|
+
const getRecord = (variables, signal) => dataPlaneFetch({
|
|
513
583
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
|
514
584
|
method: "get",
|
|
515
|
-
...variables
|
|
585
|
+
...variables,
|
|
586
|
+
signal
|
|
516
587
|
});
|
|
517
|
-
const
|
|
518
|
-
const
|
|
588
|
+
const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
|
|
589
|
+
const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
|
|
590
|
+
const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
|
|
591
|
+
const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
|
|
592
|
+
const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
|
|
593
|
+
const queryTable = (variables, signal) => dataPlaneFetch({
|
|
519
594
|
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
|
520
595
|
method: "post",
|
|
521
|
-
...variables
|
|
596
|
+
...variables,
|
|
597
|
+
signal
|
|
522
598
|
});
|
|
523
|
-
const
|
|
524
|
-
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
|
525
|
-
method: "post",
|
|
526
|
-
...variables
|
|
527
|
-
});
|
|
528
|
-
const searchBranch = (variables) => fetch$1({
|
|
599
|
+
const searchBranch = (variables, signal) => dataPlaneFetch({
|
|
529
600
|
url: "/db/{dbBranchName}/search",
|
|
530
601
|
method: "post",
|
|
531
|
-
...variables
|
|
602
|
+
...variables,
|
|
603
|
+
signal
|
|
532
604
|
});
|
|
533
|
-
const
|
|
534
|
-
url: "/db/{dbBranchName}/tables/{tableName}/
|
|
605
|
+
const searchTable = (variables, signal) => dataPlaneFetch({
|
|
606
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
|
535
607
|
method: "post",
|
|
536
|
-
...variables
|
|
537
|
-
|
|
538
|
-
const cPgetDatabaseList = (variables) => fetch$1({
|
|
539
|
-
url: "/workspaces/{workspaceId}/dbs",
|
|
540
|
-
method: "get",
|
|
541
|
-
...variables
|
|
542
|
-
});
|
|
543
|
-
const cPcreateDatabase = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables });
|
|
544
|
-
const cPdeleteDatabase = (variables) => fetch$1({
|
|
545
|
-
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
|
546
|
-
method: "delete",
|
|
547
|
-
...variables
|
|
608
|
+
...variables,
|
|
609
|
+
signal
|
|
548
610
|
});
|
|
549
|
-
const
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
const cPupdateCPDatabaseMetadata = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "patch", ...variables });
|
|
553
|
-
const operationsByTag = {
|
|
554
|
-
users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
|
555
|
-
workspaces: {
|
|
556
|
-
createWorkspace,
|
|
557
|
-
getWorkspacesList,
|
|
558
|
-
getWorkspace,
|
|
559
|
-
updateWorkspace,
|
|
560
|
-
deleteWorkspace,
|
|
561
|
-
getWorkspaceMembersList,
|
|
562
|
-
updateWorkspaceMemberRole,
|
|
563
|
-
removeWorkspaceMember,
|
|
564
|
-
inviteWorkspaceMember,
|
|
565
|
-
updateWorkspaceMemberInvite,
|
|
566
|
-
cancelWorkspaceMemberInvite,
|
|
567
|
-
resendWorkspaceMemberInvite,
|
|
568
|
-
acceptWorkspaceMemberInvite
|
|
569
|
-
},
|
|
570
|
-
database: {
|
|
571
|
-
getDatabaseList,
|
|
572
|
-
createDatabase,
|
|
573
|
-
deleteDatabase,
|
|
574
|
-
getDatabaseMetadata,
|
|
575
|
-
updateDatabaseMetadata,
|
|
576
|
-
getGitBranchesMapping,
|
|
577
|
-
addGitBranchesEntry,
|
|
578
|
-
removeGitBranchesEntry,
|
|
579
|
-
resolveBranch
|
|
580
|
-
},
|
|
611
|
+
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
|
612
|
+
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
|
613
|
+
const operationsByTag$2 = {
|
|
581
614
|
branch: {
|
|
582
615
|
getBranchList,
|
|
583
616
|
getBranchDetails,
|
|
@@ -585,10 +618,25 @@ const operationsByTag = {
|
|
|
585
618
|
deleteBranch,
|
|
586
619
|
updateBranchMetadata,
|
|
587
620
|
getBranchMetadata,
|
|
588
|
-
getBranchStats
|
|
621
|
+
getBranchStats,
|
|
622
|
+
getGitBranchesMapping,
|
|
623
|
+
addGitBranchesEntry,
|
|
624
|
+
removeGitBranchesEntry,
|
|
625
|
+
resolveBranch
|
|
626
|
+
},
|
|
627
|
+
migrations: {
|
|
628
|
+
getBranchMigrationHistory,
|
|
629
|
+
getBranchMigrationPlan,
|
|
630
|
+
executeBranchMigrationPlan,
|
|
631
|
+
getBranchSchemaHistory,
|
|
632
|
+
compareBranchWithUserSchema,
|
|
633
|
+
compareBranchSchemas,
|
|
634
|
+
updateBranchSchema,
|
|
635
|
+
previewBranchSchemaEdit,
|
|
636
|
+
applyBranchSchemaEdit
|
|
589
637
|
},
|
|
590
638
|
migrationRequests: {
|
|
591
|
-
|
|
639
|
+
queryMigrationRequests,
|
|
592
640
|
createMigrationRequest,
|
|
593
641
|
getMigrationRequest,
|
|
594
642
|
updateMigrationRequest,
|
|
@@ -597,17 +645,6 @@ const operationsByTag = {
|
|
|
597
645
|
getMigrationRequestIsMerged,
|
|
598
646
|
mergeMigrationRequest
|
|
599
647
|
},
|
|
600
|
-
branchSchema: {
|
|
601
|
-
getBranchMigrationHistory,
|
|
602
|
-
executeBranchMigrationPlan,
|
|
603
|
-
getBranchMigrationPlan,
|
|
604
|
-
compareBranchWithUserSchema,
|
|
605
|
-
compareBranchSchemas,
|
|
606
|
-
updateBranchSchema,
|
|
607
|
-
previewBranchSchemaEdit,
|
|
608
|
-
applyBranchSchemaEdit,
|
|
609
|
-
getBranchSchemaHistory
|
|
610
|
-
},
|
|
611
648
|
table: {
|
|
612
649
|
createTable,
|
|
613
650
|
deleteTable,
|
|
@@ -617,31 +654,162 @@ const operationsByTag = {
|
|
|
617
654
|
getTableColumns,
|
|
618
655
|
addTableColumn,
|
|
619
656
|
getColumn,
|
|
620
|
-
|
|
621
|
-
|
|
657
|
+
updateColumn,
|
|
658
|
+
deleteColumn
|
|
622
659
|
},
|
|
623
660
|
records: {
|
|
661
|
+
branchTransaction,
|
|
624
662
|
insertRecord,
|
|
663
|
+
getRecord,
|
|
625
664
|
insertRecordWithID,
|
|
626
665
|
updateRecordWithID,
|
|
627
666
|
upsertRecordWithID,
|
|
628
667
|
deleteRecord,
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
668
|
+
bulkInsertTableRecords
|
|
669
|
+
},
|
|
670
|
+
searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
|
674
|
+
|
|
675
|
+
const getUser = (variables, signal) => controlPlaneFetch({
|
|
676
|
+
url: "/user",
|
|
677
|
+
method: "get",
|
|
678
|
+
...variables,
|
|
679
|
+
signal
|
|
680
|
+
});
|
|
681
|
+
const updateUser = (variables, signal) => controlPlaneFetch({
|
|
682
|
+
url: "/user",
|
|
683
|
+
method: "put",
|
|
684
|
+
...variables,
|
|
685
|
+
signal
|
|
686
|
+
});
|
|
687
|
+
const deleteUser = (variables, signal) => controlPlaneFetch({
|
|
688
|
+
url: "/user",
|
|
689
|
+
method: "delete",
|
|
690
|
+
...variables,
|
|
691
|
+
signal
|
|
692
|
+
});
|
|
693
|
+
const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
|
|
694
|
+
url: "/user/keys",
|
|
695
|
+
method: "get",
|
|
696
|
+
...variables,
|
|
697
|
+
signal
|
|
698
|
+
});
|
|
699
|
+
const createUserAPIKey = (variables, signal) => controlPlaneFetch({
|
|
700
|
+
url: "/user/keys/{keyName}",
|
|
701
|
+
method: "post",
|
|
702
|
+
...variables,
|
|
703
|
+
signal
|
|
704
|
+
});
|
|
705
|
+
const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
|
706
|
+
url: "/user/keys/{keyName}",
|
|
707
|
+
method: "delete",
|
|
708
|
+
...variables,
|
|
709
|
+
signal
|
|
710
|
+
});
|
|
711
|
+
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
|
712
|
+
url: "/workspaces",
|
|
713
|
+
method: "get",
|
|
714
|
+
...variables,
|
|
715
|
+
signal
|
|
716
|
+
});
|
|
717
|
+
const createWorkspace = (variables, signal) => controlPlaneFetch({
|
|
718
|
+
url: "/workspaces",
|
|
719
|
+
method: "post",
|
|
720
|
+
...variables,
|
|
721
|
+
signal
|
|
722
|
+
});
|
|
723
|
+
const getWorkspace = (variables, signal) => controlPlaneFetch({
|
|
724
|
+
url: "/workspaces/{workspaceId}",
|
|
725
|
+
method: "get",
|
|
726
|
+
...variables,
|
|
727
|
+
signal
|
|
728
|
+
});
|
|
729
|
+
const updateWorkspace = (variables, signal) => controlPlaneFetch({
|
|
730
|
+
url: "/workspaces/{workspaceId}",
|
|
731
|
+
method: "put",
|
|
732
|
+
...variables,
|
|
733
|
+
signal
|
|
734
|
+
});
|
|
735
|
+
const deleteWorkspace = (variables, signal) => controlPlaneFetch({
|
|
736
|
+
url: "/workspaces/{workspaceId}",
|
|
737
|
+
method: "delete",
|
|
738
|
+
...variables,
|
|
739
|
+
signal
|
|
740
|
+
});
|
|
741
|
+
const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
|
|
742
|
+
const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
|
|
743
|
+
const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
|
744
|
+
url: "/workspaces/{workspaceId}/members/{userId}",
|
|
745
|
+
method: "delete",
|
|
746
|
+
...variables,
|
|
747
|
+
signal
|
|
748
|
+
});
|
|
749
|
+
const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
|
|
750
|
+
const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
|
|
751
|
+
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
|
752
|
+
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
|
753
|
+
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
|
754
|
+
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
|
755
|
+
url: "/workspaces/{workspaceId}/dbs",
|
|
756
|
+
method: "get",
|
|
757
|
+
...variables,
|
|
758
|
+
signal
|
|
759
|
+
});
|
|
760
|
+
const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
|
|
761
|
+
const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
|
762
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
|
763
|
+
method: "delete",
|
|
764
|
+
...variables,
|
|
765
|
+
signal
|
|
766
|
+
});
|
|
767
|
+
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
|
768
|
+
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
|
769
|
+
const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
|
|
770
|
+
const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
|
|
771
|
+
const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
|
|
772
|
+
const listRegions = (variables, signal) => controlPlaneFetch({
|
|
773
|
+
url: "/workspaces/{workspaceId}/regions",
|
|
774
|
+
method: "get",
|
|
775
|
+
...variables,
|
|
776
|
+
signal
|
|
777
|
+
});
|
|
778
|
+
const operationsByTag$1 = {
|
|
779
|
+
users: { getUser, updateUser, deleteUser },
|
|
780
|
+
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
|
781
|
+
workspaces: {
|
|
782
|
+
getWorkspacesList,
|
|
783
|
+
createWorkspace,
|
|
784
|
+
getWorkspace,
|
|
785
|
+
updateWorkspace,
|
|
786
|
+
deleteWorkspace,
|
|
787
|
+
getWorkspaceMembersList,
|
|
788
|
+
updateWorkspaceMemberRole,
|
|
789
|
+
removeWorkspaceMember
|
|
790
|
+
},
|
|
791
|
+
invites: {
|
|
792
|
+
inviteWorkspaceMember,
|
|
793
|
+
updateWorkspaceMemberInvite,
|
|
794
|
+
cancelWorkspaceMemberInvite,
|
|
795
|
+
acceptWorkspaceMemberInvite,
|
|
796
|
+
resendWorkspaceMemberInvite
|
|
635
797
|
},
|
|
636
798
|
databases: {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
799
|
+
getDatabaseList,
|
|
800
|
+
createDatabase,
|
|
801
|
+
deleteDatabase,
|
|
802
|
+
getDatabaseMetadata,
|
|
803
|
+
updateDatabaseMetadata,
|
|
804
|
+
getDatabaseGithubSettings,
|
|
805
|
+
updateDatabaseGithubSettings,
|
|
806
|
+
deleteDatabaseGithubSettings,
|
|
807
|
+
listRegions
|
|
642
808
|
}
|
|
643
809
|
};
|
|
644
810
|
|
|
811
|
+
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
|
812
|
+
|
|
645
813
|
function getHostUrl(provider, type) {
|
|
646
814
|
if (isHostProviderAlias(provider)) {
|
|
647
815
|
return providers[provider][type];
|
|
@@ -653,11 +821,11 @@ function getHostUrl(provider, type) {
|
|
|
653
821
|
const providers = {
|
|
654
822
|
production: {
|
|
655
823
|
main: "https://api.xata.io",
|
|
656
|
-
workspaces: "https://{workspaceId}.xata.sh"
|
|
824
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
|
657
825
|
},
|
|
658
826
|
staging: {
|
|
659
827
|
main: "https://staging.xatabase.co",
|
|
660
|
-
workspaces: "https://{workspaceId}.staging.xatabase.co"
|
|
828
|
+
workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
|
|
661
829
|
}
|
|
662
830
|
};
|
|
663
831
|
function isHostProviderAlias(alias) {
|
|
@@ -666,6 +834,26 @@ function isHostProviderAlias(alias) {
|
|
|
666
834
|
function isHostProviderBuilder(builder) {
|
|
667
835
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
|
668
836
|
}
|
|
837
|
+
function parseProviderString(provider = "production") {
|
|
838
|
+
if (isHostProviderAlias(provider)) {
|
|
839
|
+
return provider;
|
|
840
|
+
}
|
|
841
|
+
const [main, workspaces] = provider.split(",");
|
|
842
|
+
if (!main || !workspaces)
|
|
843
|
+
return null;
|
|
844
|
+
return { main, workspaces };
|
|
845
|
+
}
|
|
846
|
+
function parseWorkspacesUrlParts(url) {
|
|
847
|
+
if (!isString(url))
|
|
848
|
+
return null;
|
|
849
|
+
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
|
850
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))\.xatabase\.co.*/;
|
|
851
|
+
const regexDev = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))\.xata\.tech.*/;
|
|
852
|
+
const match = url.match(regex) || url.match(regexStaging) || url.match(regexDev);
|
|
853
|
+
if (!match)
|
|
854
|
+
return null;
|
|
855
|
+
return { workspace: match[1], region: match[2] };
|
|
856
|
+
}
|
|
669
857
|
|
|
670
858
|
var __accessCheck$7 = (obj, member, msg) => {
|
|
671
859
|
if (!member.has(obj))
|
|
@@ -693,6 +881,7 @@ class XataApiClient {
|
|
|
693
881
|
const provider = options.host ?? "production";
|
|
694
882
|
const apiKey = options.apiKey ?? getAPIKey();
|
|
695
883
|
const trace = options.trace ?? defaultTrace;
|
|
884
|
+
const clientID = generateUUID();
|
|
696
885
|
if (!apiKey) {
|
|
697
886
|
throw new Error("Could not resolve a valid apiKey");
|
|
698
887
|
}
|
|
@@ -701,7 +890,9 @@ class XataApiClient {
|
|
|
701
890
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
|
702
891
|
fetchImpl: getFetchImplementation(options.fetch),
|
|
703
892
|
apiKey,
|
|
704
|
-
trace
|
|
893
|
+
trace,
|
|
894
|
+
clientName: options.clientName,
|
|
895
|
+
clientID
|
|
705
896
|
});
|
|
706
897
|
}
|
|
707
898
|
get user() {
|
|
@@ -709,21 +900,41 @@ class XataApiClient {
|
|
|
709
900
|
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
|
710
901
|
return __privateGet$7(this, _namespaces).user;
|
|
711
902
|
}
|
|
903
|
+
get authentication() {
|
|
904
|
+
if (!__privateGet$7(this, _namespaces).authentication)
|
|
905
|
+
__privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
|
|
906
|
+
return __privateGet$7(this, _namespaces).authentication;
|
|
907
|
+
}
|
|
712
908
|
get workspaces() {
|
|
713
909
|
if (!__privateGet$7(this, _namespaces).workspaces)
|
|
714
910
|
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
|
715
911
|
return __privateGet$7(this, _namespaces).workspaces;
|
|
716
912
|
}
|
|
717
|
-
get
|
|
718
|
-
if (!__privateGet$7(this, _namespaces).
|
|
719
|
-
__privateGet$7(this, _namespaces).
|
|
720
|
-
return __privateGet$7(this, _namespaces).
|
|
913
|
+
get invites() {
|
|
914
|
+
if (!__privateGet$7(this, _namespaces).invites)
|
|
915
|
+
__privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
|
|
916
|
+
return __privateGet$7(this, _namespaces).invites;
|
|
917
|
+
}
|
|
918
|
+
get database() {
|
|
919
|
+
if (!__privateGet$7(this, _namespaces).database)
|
|
920
|
+
__privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
|
|
921
|
+
return __privateGet$7(this, _namespaces).database;
|
|
721
922
|
}
|
|
722
923
|
get branches() {
|
|
723
924
|
if (!__privateGet$7(this, _namespaces).branches)
|
|
724
925
|
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
|
725
926
|
return __privateGet$7(this, _namespaces).branches;
|
|
726
927
|
}
|
|
928
|
+
get migrations() {
|
|
929
|
+
if (!__privateGet$7(this, _namespaces).migrations)
|
|
930
|
+
__privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
|
|
931
|
+
return __privateGet$7(this, _namespaces).migrations;
|
|
932
|
+
}
|
|
933
|
+
get migrationRequests() {
|
|
934
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
|
935
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
|
936
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
|
937
|
+
}
|
|
727
938
|
get tables() {
|
|
728
939
|
if (!__privateGet$7(this, _namespaces).tables)
|
|
729
940
|
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
|
@@ -734,15 +945,10 @@ class XataApiClient {
|
|
|
734
945
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
|
735
946
|
return __privateGet$7(this, _namespaces).records;
|
|
736
947
|
}
|
|
737
|
-
get
|
|
738
|
-
if (!__privateGet$7(this, _namespaces).
|
|
739
|
-
__privateGet$7(this, _namespaces).
|
|
740
|
-
return __privateGet$7(this, _namespaces).
|
|
741
|
-
}
|
|
742
|
-
get branchSchema() {
|
|
743
|
-
if (!__privateGet$7(this, _namespaces).branchSchema)
|
|
744
|
-
__privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
|
|
745
|
-
return __privateGet$7(this, _namespaces).branchSchema;
|
|
948
|
+
get searchAndFilter() {
|
|
949
|
+
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
|
950
|
+
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
|
951
|
+
return __privateGet$7(this, _namespaces).searchAndFilter;
|
|
746
952
|
}
|
|
747
953
|
}
|
|
748
954
|
_extraProps = new WeakMap();
|
|
@@ -754,24 +960,29 @@ class UserApi {
|
|
|
754
960
|
getUser() {
|
|
755
961
|
return operationsByTag.users.getUser({ ...this.extraProps });
|
|
756
962
|
}
|
|
757
|
-
updateUser(user) {
|
|
963
|
+
updateUser({ user }) {
|
|
758
964
|
return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
|
|
759
965
|
}
|
|
760
966
|
deleteUser() {
|
|
761
967
|
return operationsByTag.users.deleteUser({ ...this.extraProps });
|
|
762
968
|
}
|
|
969
|
+
}
|
|
970
|
+
class AuthenticationApi {
|
|
971
|
+
constructor(extraProps) {
|
|
972
|
+
this.extraProps = extraProps;
|
|
973
|
+
}
|
|
763
974
|
getUserAPIKeys() {
|
|
764
|
-
return operationsByTag.
|
|
975
|
+
return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
|
|
765
976
|
}
|
|
766
|
-
createUserAPIKey(
|
|
767
|
-
return operationsByTag.
|
|
768
|
-
pathParams: { keyName },
|
|
977
|
+
createUserAPIKey({ name }) {
|
|
978
|
+
return operationsByTag.authentication.createUserAPIKey({
|
|
979
|
+
pathParams: { keyName: name },
|
|
769
980
|
...this.extraProps
|
|
770
981
|
});
|
|
771
982
|
}
|
|
772
|
-
deleteUserAPIKey(
|
|
773
|
-
return operationsByTag.
|
|
774
|
-
pathParams: { keyName },
|
|
983
|
+
deleteUserAPIKey({ name }) {
|
|
984
|
+
return operationsByTag.authentication.deleteUserAPIKey({
|
|
985
|
+
pathParams: { keyName: name },
|
|
775
986
|
...this.extraProps
|
|
776
987
|
});
|
|
777
988
|
}
|
|
@@ -780,196 +991,248 @@ class WorkspaceApi {
|
|
|
780
991
|
constructor(extraProps) {
|
|
781
992
|
this.extraProps = extraProps;
|
|
782
993
|
}
|
|
783
|
-
|
|
994
|
+
getWorkspacesList() {
|
|
995
|
+
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
|
996
|
+
}
|
|
997
|
+
createWorkspace({ data }) {
|
|
784
998
|
return operationsByTag.workspaces.createWorkspace({
|
|
785
|
-
body:
|
|
999
|
+
body: data,
|
|
786
1000
|
...this.extraProps
|
|
787
1001
|
});
|
|
788
1002
|
}
|
|
789
|
-
|
|
790
|
-
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
|
791
|
-
}
|
|
792
|
-
getWorkspace(workspaceId) {
|
|
1003
|
+
getWorkspace({ workspace }) {
|
|
793
1004
|
return operationsByTag.workspaces.getWorkspace({
|
|
794
|
-
pathParams: { workspaceId },
|
|
1005
|
+
pathParams: { workspaceId: workspace },
|
|
795
1006
|
...this.extraProps
|
|
796
1007
|
});
|
|
797
1008
|
}
|
|
798
|
-
updateWorkspace(
|
|
1009
|
+
updateWorkspace({
|
|
1010
|
+
workspace,
|
|
1011
|
+
update
|
|
1012
|
+
}) {
|
|
799
1013
|
return operationsByTag.workspaces.updateWorkspace({
|
|
800
|
-
pathParams: { workspaceId },
|
|
801
|
-
body:
|
|
1014
|
+
pathParams: { workspaceId: workspace },
|
|
1015
|
+
body: update,
|
|
802
1016
|
...this.extraProps
|
|
803
1017
|
});
|
|
804
1018
|
}
|
|
805
|
-
deleteWorkspace(
|
|
1019
|
+
deleteWorkspace({ workspace }) {
|
|
806
1020
|
return operationsByTag.workspaces.deleteWorkspace({
|
|
807
|
-
pathParams: { workspaceId },
|
|
1021
|
+
pathParams: { workspaceId: workspace },
|
|
808
1022
|
...this.extraProps
|
|
809
1023
|
});
|
|
810
1024
|
}
|
|
811
|
-
getWorkspaceMembersList(
|
|
1025
|
+
getWorkspaceMembersList({ workspace }) {
|
|
812
1026
|
return operationsByTag.workspaces.getWorkspaceMembersList({
|
|
813
|
-
pathParams: { workspaceId },
|
|
1027
|
+
pathParams: { workspaceId: workspace },
|
|
814
1028
|
...this.extraProps
|
|
815
1029
|
});
|
|
816
1030
|
}
|
|
817
|
-
updateWorkspaceMemberRole(
|
|
1031
|
+
updateWorkspaceMemberRole({
|
|
1032
|
+
workspace,
|
|
1033
|
+
user,
|
|
1034
|
+
role
|
|
1035
|
+
}) {
|
|
818
1036
|
return operationsByTag.workspaces.updateWorkspaceMemberRole({
|
|
819
|
-
pathParams: { workspaceId, userId },
|
|
1037
|
+
pathParams: { workspaceId: workspace, userId: user },
|
|
820
1038
|
body: { role },
|
|
821
1039
|
...this.extraProps
|
|
822
1040
|
});
|
|
823
1041
|
}
|
|
824
|
-
removeWorkspaceMember(
|
|
1042
|
+
removeWorkspaceMember({
|
|
1043
|
+
workspace,
|
|
1044
|
+
user
|
|
1045
|
+
}) {
|
|
825
1046
|
return operationsByTag.workspaces.removeWorkspaceMember({
|
|
826
|
-
pathParams: { workspaceId, userId },
|
|
1047
|
+
pathParams: { workspaceId: workspace, userId: user },
|
|
827
1048
|
...this.extraProps
|
|
828
1049
|
});
|
|
829
1050
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
1051
|
+
}
|
|
1052
|
+
class InvitesApi {
|
|
1053
|
+
constructor(extraProps) {
|
|
1054
|
+
this.extraProps = extraProps;
|
|
1055
|
+
}
|
|
1056
|
+
inviteWorkspaceMember({
|
|
1057
|
+
workspace,
|
|
1058
|
+
email,
|
|
1059
|
+
role
|
|
1060
|
+
}) {
|
|
1061
|
+
return operationsByTag.invites.inviteWorkspaceMember({
|
|
1062
|
+
pathParams: { workspaceId: workspace },
|
|
833
1063
|
body: { email, role },
|
|
834
1064
|
...this.extraProps
|
|
835
1065
|
});
|
|
836
1066
|
}
|
|
837
|
-
updateWorkspaceMemberInvite(
|
|
838
|
-
|
|
839
|
-
|
|
1067
|
+
updateWorkspaceMemberInvite({
|
|
1068
|
+
workspace,
|
|
1069
|
+
invite,
|
|
1070
|
+
role
|
|
1071
|
+
}) {
|
|
1072
|
+
return operationsByTag.invites.updateWorkspaceMemberInvite({
|
|
1073
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
|
840
1074
|
body: { role },
|
|
841
1075
|
...this.extraProps
|
|
842
1076
|
});
|
|
843
1077
|
}
|
|
844
|
-
cancelWorkspaceMemberInvite(
|
|
845
|
-
|
|
846
|
-
|
|
1078
|
+
cancelWorkspaceMemberInvite({
|
|
1079
|
+
workspace,
|
|
1080
|
+
invite
|
|
1081
|
+
}) {
|
|
1082
|
+
return operationsByTag.invites.cancelWorkspaceMemberInvite({
|
|
1083
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
|
847
1084
|
...this.extraProps
|
|
848
1085
|
});
|
|
849
1086
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
1087
|
+
acceptWorkspaceMemberInvite({
|
|
1088
|
+
workspace,
|
|
1089
|
+
key
|
|
1090
|
+
}) {
|
|
1091
|
+
return operationsByTag.invites.acceptWorkspaceMemberInvite({
|
|
1092
|
+
pathParams: { workspaceId: workspace, inviteKey: key },
|
|
853
1093
|
...this.extraProps
|
|
854
1094
|
});
|
|
855
1095
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
1096
|
+
resendWorkspaceMemberInvite({
|
|
1097
|
+
workspace,
|
|
1098
|
+
invite
|
|
1099
|
+
}) {
|
|
1100
|
+
return operationsByTag.invites.resendWorkspaceMemberInvite({
|
|
1101
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
|
859
1102
|
...this.extraProps
|
|
860
1103
|
});
|
|
861
1104
|
}
|
|
862
1105
|
}
|
|
863
|
-
class
|
|
1106
|
+
class BranchApi {
|
|
864
1107
|
constructor(extraProps) {
|
|
865
1108
|
this.extraProps = extraProps;
|
|
866
1109
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
return operationsByTag.database.createDatabase({
|
|
875
|
-
pathParams: { workspace, dbName },
|
|
876
|
-
body: options,
|
|
877
|
-
...this.extraProps
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
deleteDatabase(workspace, dbName) {
|
|
881
|
-
return operationsByTag.database.deleteDatabase({
|
|
882
|
-
pathParams: { workspace, dbName },
|
|
883
|
-
...this.extraProps
|
|
884
|
-
});
|
|
885
|
-
}
|
|
886
|
-
getDatabaseMetadata(workspace, dbName) {
|
|
887
|
-
return operationsByTag.database.getDatabaseMetadata({
|
|
888
|
-
pathParams: { workspace, dbName },
|
|
889
|
-
...this.extraProps
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
updateDatabaseMetadata(workspace, dbName, options = {}) {
|
|
893
|
-
return operationsByTag.database.updateDatabaseMetadata({
|
|
894
|
-
pathParams: { workspace, dbName },
|
|
895
|
-
body: options,
|
|
896
|
-
...this.extraProps
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
getGitBranchesMapping(workspace, dbName) {
|
|
900
|
-
return operationsByTag.database.getGitBranchesMapping({
|
|
901
|
-
pathParams: { workspace, dbName },
|
|
1110
|
+
getBranchList({
|
|
1111
|
+
workspace,
|
|
1112
|
+
region,
|
|
1113
|
+
database
|
|
1114
|
+
}) {
|
|
1115
|
+
return operationsByTag.branch.getBranchList({
|
|
1116
|
+
pathParams: { workspace, region, dbName: database },
|
|
902
1117
|
...this.extraProps
|
|
903
1118
|
});
|
|
904
1119
|
}
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
1120
|
+
getBranchDetails({
|
|
1121
|
+
workspace,
|
|
1122
|
+
region,
|
|
1123
|
+
database,
|
|
1124
|
+
branch
|
|
1125
|
+
}) {
|
|
1126
|
+
return operationsByTag.branch.getBranchDetails({
|
|
1127
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
909
1128
|
...this.extraProps
|
|
910
1129
|
});
|
|
911
1130
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
1131
|
+
createBranch({
|
|
1132
|
+
workspace,
|
|
1133
|
+
region,
|
|
1134
|
+
database,
|
|
1135
|
+
branch,
|
|
1136
|
+
from,
|
|
1137
|
+
metadata
|
|
1138
|
+
}) {
|
|
1139
|
+
return operationsByTag.branch.createBranch({
|
|
1140
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1141
|
+
body: { from, metadata },
|
|
916
1142
|
...this.extraProps
|
|
917
1143
|
});
|
|
918
1144
|
}
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
1145
|
+
deleteBranch({
|
|
1146
|
+
workspace,
|
|
1147
|
+
region,
|
|
1148
|
+
database,
|
|
1149
|
+
branch
|
|
1150
|
+
}) {
|
|
1151
|
+
return operationsByTag.branch.deleteBranch({
|
|
1152
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
923
1153
|
...this.extraProps
|
|
924
1154
|
});
|
|
925
1155
|
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1156
|
+
updateBranchMetadata({
|
|
1157
|
+
workspace,
|
|
1158
|
+
region,
|
|
1159
|
+
database,
|
|
1160
|
+
branch,
|
|
1161
|
+
metadata
|
|
1162
|
+
}) {
|
|
1163
|
+
return operationsByTag.branch.updateBranchMetadata({
|
|
1164
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1165
|
+
body: metadata,
|
|
934
1166
|
...this.extraProps
|
|
935
1167
|
});
|
|
936
1168
|
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
1169
|
+
getBranchMetadata({
|
|
1170
|
+
workspace,
|
|
1171
|
+
region,
|
|
1172
|
+
database,
|
|
1173
|
+
branch
|
|
1174
|
+
}) {
|
|
1175
|
+
return operationsByTag.branch.getBranchMetadata({
|
|
1176
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
940
1177
|
...this.extraProps
|
|
941
1178
|
});
|
|
942
1179
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
1180
|
+
getBranchStats({
|
|
1181
|
+
workspace,
|
|
1182
|
+
region,
|
|
1183
|
+
database,
|
|
1184
|
+
branch
|
|
1185
|
+
}) {
|
|
1186
|
+
return operationsByTag.branch.getBranchStats({
|
|
1187
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
948
1188
|
...this.extraProps
|
|
949
1189
|
});
|
|
950
1190
|
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
1191
|
+
getGitBranchesMapping({
|
|
1192
|
+
workspace,
|
|
1193
|
+
region,
|
|
1194
|
+
database
|
|
1195
|
+
}) {
|
|
1196
|
+
return operationsByTag.branch.getGitBranchesMapping({
|
|
1197
|
+
pathParams: { workspace, region, dbName: database },
|
|
954
1198
|
...this.extraProps
|
|
955
1199
|
});
|
|
956
1200
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1201
|
+
addGitBranchesEntry({
|
|
1202
|
+
workspace,
|
|
1203
|
+
region,
|
|
1204
|
+
database,
|
|
1205
|
+
gitBranch,
|
|
1206
|
+
xataBranch
|
|
1207
|
+
}) {
|
|
1208
|
+
return operationsByTag.branch.addGitBranchesEntry({
|
|
1209
|
+
pathParams: { workspace, region, dbName: database },
|
|
1210
|
+
body: { gitBranch, xataBranch },
|
|
961
1211
|
...this.extraProps
|
|
962
1212
|
});
|
|
963
1213
|
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
1214
|
+
removeGitBranchesEntry({
|
|
1215
|
+
workspace,
|
|
1216
|
+
region,
|
|
1217
|
+
database,
|
|
1218
|
+
gitBranch
|
|
1219
|
+
}) {
|
|
1220
|
+
return operationsByTag.branch.removeGitBranchesEntry({
|
|
1221
|
+
pathParams: { workspace, region, dbName: database },
|
|
1222
|
+
queryParams: { gitBranch },
|
|
967
1223
|
...this.extraProps
|
|
968
1224
|
});
|
|
969
1225
|
}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1226
|
+
resolveBranch({
|
|
1227
|
+
workspace,
|
|
1228
|
+
region,
|
|
1229
|
+
database,
|
|
1230
|
+
gitBranch,
|
|
1231
|
+
fallbackBranch
|
|
1232
|
+
}) {
|
|
1233
|
+
return operationsByTag.branch.resolveBranch({
|
|
1234
|
+
pathParams: { workspace, region, dbName: database },
|
|
1235
|
+
queryParams: { gitBranch, fallbackBranch },
|
|
973
1236
|
...this.extraProps
|
|
974
1237
|
});
|
|
975
1238
|
}
|
|
@@ -978,67 +1241,134 @@ class TableApi {
|
|
|
978
1241
|
constructor(extraProps) {
|
|
979
1242
|
this.extraProps = extraProps;
|
|
980
1243
|
}
|
|
981
|
-
createTable(
|
|
1244
|
+
createTable({
|
|
1245
|
+
workspace,
|
|
1246
|
+
region,
|
|
1247
|
+
database,
|
|
1248
|
+
branch,
|
|
1249
|
+
table
|
|
1250
|
+
}) {
|
|
982
1251
|
return operationsByTag.table.createTable({
|
|
983
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1252
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
984
1253
|
...this.extraProps
|
|
985
1254
|
});
|
|
986
1255
|
}
|
|
987
|
-
deleteTable(
|
|
1256
|
+
deleteTable({
|
|
1257
|
+
workspace,
|
|
1258
|
+
region,
|
|
1259
|
+
database,
|
|
1260
|
+
branch,
|
|
1261
|
+
table
|
|
1262
|
+
}) {
|
|
988
1263
|
return operationsByTag.table.deleteTable({
|
|
989
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1264
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
990
1265
|
...this.extraProps
|
|
991
1266
|
});
|
|
992
1267
|
}
|
|
993
|
-
updateTable(
|
|
1268
|
+
updateTable({
|
|
1269
|
+
workspace,
|
|
1270
|
+
region,
|
|
1271
|
+
database,
|
|
1272
|
+
branch,
|
|
1273
|
+
table,
|
|
1274
|
+
update
|
|
1275
|
+
}) {
|
|
994
1276
|
return operationsByTag.table.updateTable({
|
|
995
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
996
|
-
body:
|
|
1277
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1278
|
+
body: update,
|
|
997
1279
|
...this.extraProps
|
|
998
1280
|
});
|
|
999
1281
|
}
|
|
1000
|
-
getTableSchema(
|
|
1282
|
+
getTableSchema({
|
|
1283
|
+
workspace,
|
|
1284
|
+
region,
|
|
1285
|
+
database,
|
|
1286
|
+
branch,
|
|
1287
|
+
table
|
|
1288
|
+
}) {
|
|
1001
1289
|
return operationsByTag.table.getTableSchema({
|
|
1002
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1290
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1003
1291
|
...this.extraProps
|
|
1004
1292
|
});
|
|
1005
1293
|
}
|
|
1006
|
-
setTableSchema(
|
|
1294
|
+
setTableSchema({
|
|
1295
|
+
workspace,
|
|
1296
|
+
region,
|
|
1297
|
+
database,
|
|
1298
|
+
branch,
|
|
1299
|
+
table,
|
|
1300
|
+
schema
|
|
1301
|
+
}) {
|
|
1007
1302
|
return operationsByTag.table.setTableSchema({
|
|
1008
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1009
|
-
body:
|
|
1303
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1304
|
+
body: schema,
|
|
1010
1305
|
...this.extraProps
|
|
1011
1306
|
});
|
|
1012
1307
|
}
|
|
1013
|
-
getTableColumns(
|
|
1308
|
+
getTableColumns({
|
|
1309
|
+
workspace,
|
|
1310
|
+
region,
|
|
1311
|
+
database,
|
|
1312
|
+
branch,
|
|
1313
|
+
table
|
|
1314
|
+
}) {
|
|
1014
1315
|
return operationsByTag.table.getTableColumns({
|
|
1015
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1316
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1016
1317
|
...this.extraProps
|
|
1017
1318
|
});
|
|
1018
1319
|
}
|
|
1019
|
-
addTableColumn(
|
|
1320
|
+
addTableColumn({
|
|
1321
|
+
workspace,
|
|
1322
|
+
region,
|
|
1323
|
+
database,
|
|
1324
|
+
branch,
|
|
1325
|
+
table,
|
|
1326
|
+
column
|
|
1327
|
+
}) {
|
|
1020
1328
|
return operationsByTag.table.addTableColumn({
|
|
1021
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1329
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1022
1330
|
body: column,
|
|
1023
1331
|
...this.extraProps
|
|
1024
1332
|
});
|
|
1025
1333
|
}
|
|
1026
|
-
getColumn(
|
|
1334
|
+
getColumn({
|
|
1335
|
+
workspace,
|
|
1336
|
+
region,
|
|
1337
|
+
database,
|
|
1338
|
+
branch,
|
|
1339
|
+
table,
|
|
1340
|
+
column
|
|
1341
|
+
}) {
|
|
1027
1342
|
return operationsByTag.table.getColumn({
|
|
1028
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
|
|
1343
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
|
1029
1344
|
...this.extraProps
|
|
1030
1345
|
});
|
|
1031
1346
|
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1347
|
+
updateColumn({
|
|
1348
|
+
workspace,
|
|
1349
|
+
region,
|
|
1350
|
+
database,
|
|
1351
|
+
branch,
|
|
1352
|
+
table,
|
|
1353
|
+
column,
|
|
1354
|
+
update
|
|
1355
|
+
}) {
|
|
1356
|
+
return operationsByTag.table.updateColumn({
|
|
1357
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
|
1358
|
+
body: update,
|
|
1035
1359
|
...this.extraProps
|
|
1036
1360
|
});
|
|
1037
1361
|
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1362
|
+
deleteColumn({
|
|
1363
|
+
workspace,
|
|
1364
|
+
region,
|
|
1365
|
+
database,
|
|
1366
|
+
branch,
|
|
1367
|
+
table,
|
|
1368
|
+
column
|
|
1369
|
+
}) {
|
|
1370
|
+
return operationsByTag.table.deleteColumn({
|
|
1371
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
|
1042
1372
|
...this.extraProps
|
|
1043
1373
|
});
|
|
1044
1374
|
}
|
|
@@ -1047,85 +1377,228 @@ class RecordsApi {
|
|
|
1047
1377
|
constructor(extraProps) {
|
|
1048
1378
|
this.extraProps = extraProps;
|
|
1049
1379
|
}
|
|
1050
|
-
insertRecord(
|
|
1380
|
+
insertRecord({
|
|
1381
|
+
workspace,
|
|
1382
|
+
region,
|
|
1383
|
+
database,
|
|
1384
|
+
branch,
|
|
1385
|
+
table,
|
|
1386
|
+
record,
|
|
1387
|
+
columns
|
|
1388
|
+
}) {
|
|
1051
1389
|
return operationsByTag.records.insertRecord({
|
|
1052
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1053
|
-
queryParams:
|
|
1390
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1391
|
+
queryParams: { columns },
|
|
1054
1392
|
body: record,
|
|
1055
1393
|
...this.extraProps
|
|
1056
1394
|
});
|
|
1057
1395
|
}
|
|
1058
|
-
|
|
1396
|
+
getRecord({
|
|
1397
|
+
workspace,
|
|
1398
|
+
region,
|
|
1399
|
+
database,
|
|
1400
|
+
branch,
|
|
1401
|
+
table,
|
|
1402
|
+
id,
|
|
1403
|
+
columns
|
|
1404
|
+
}) {
|
|
1405
|
+
return operationsByTag.records.getRecord({
|
|
1406
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1407
|
+
queryParams: { columns },
|
|
1408
|
+
...this.extraProps
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
insertRecordWithID({
|
|
1412
|
+
workspace,
|
|
1413
|
+
region,
|
|
1414
|
+
database,
|
|
1415
|
+
branch,
|
|
1416
|
+
table,
|
|
1417
|
+
id,
|
|
1418
|
+
record,
|
|
1419
|
+
columns,
|
|
1420
|
+
createOnly,
|
|
1421
|
+
ifVersion
|
|
1422
|
+
}) {
|
|
1059
1423
|
return operationsByTag.records.insertRecordWithID({
|
|
1060
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1061
|
-
queryParams:
|
|
1424
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1425
|
+
queryParams: { columns, createOnly, ifVersion },
|
|
1062
1426
|
body: record,
|
|
1063
1427
|
...this.extraProps
|
|
1064
1428
|
});
|
|
1065
1429
|
}
|
|
1066
|
-
updateRecordWithID(
|
|
1430
|
+
updateRecordWithID({
|
|
1431
|
+
workspace,
|
|
1432
|
+
region,
|
|
1433
|
+
database,
|
|
1434
|
+
branch,
|
|
1435
|
+
table,
|
|
1436
|
+
id,
|
|
1437
|
+
record,
|
|
1438
|
+
columns,
|
|
1439
|
+
ifVersion
|
|
1440
|
+
}) {
|
|
1067
1441
|
return operationsByTag.records.updateRecordWithID({
|
|
1068
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1069
|
-
queryParams:
|
|
1442
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1443
|
+
queryParams: { columns, ifVersion },
|
|
1070
1444
|
body: record,
|
|
1071
1445
|
...this.extraProps
|
|
1072
1446
|
});
|
|
1073
1447
|
}
|
|
1074
|
-
upsertRecordWithID(
|
|
1448
|
+
upsertRecordWithID({
|
|
1449
|
+
workspace,
|
|
1450
|
+
region,
|
|
1451
|
+
database,
|
|
1452
|
+
branch,
|
|
1453
|
+
table,
|
|
1454
|
+
id,
|
|
1455
|
+
record,
|
|
1456
|
+
columns,
|
|
1457
|
+
ifVersion
|
|
1458
|
+
}) {
|
|
1075
1459
|
return operationsByTag.records.upsertRecordWithID({
|
|
1076
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1077
|
-
queryParams:
|
|
1460
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1461
|
+
queryParams: { columns, ifVersion },
|
|
1078
1462
|
body: record,
|
|
1079
1463
|
...this.extraProps
|
|
1080
1464
|
});
|
|
1081
1465
|
}
|
|
1082
|
-
deleteRecord(
|
|
1466
|
+
deleteRecord({
|
|
1467
|
+
workspace,
|
|
1468
|
+
region,
|
|
1469
|
+
database,
|
|
1470
|
+
branch,
|
|
1471
|
+
table,
|
|
1472
|
+
id,
|
|
1473
|
+
columns
|
|
1474
|
+
}) {
|
|
1083
1475
|
return operationsByTag.records.deleteRecord({
|
|
1084
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1085
|
-
queryParams:
|
|
1086
|
-
...this.extraProps
|
|
1087
|
-
});
|
|
1088
|
-
}
|
|
1089
|
-
getRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
|
1090
|
-
return operationsByTag.records.getRecord({
|
|
1091
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1092
|
-
queryParams: options,
|
|
1476
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1477
|
+
queryParams: { columns },
|
|
1093
1478
|
...this.extraProps
|
|
1094
1479
|
});
|
|
1095
1480
|
}
|
|
1096
|
-
bulkInsertTableRecords(
|
|
1481
|
+
bulkInsertTableRecords({
|
|
1482
|
+
workspace,
|
|
1483
|
+
region,
|
|
1484
|
+
database,
|
|
1485
|
+
branch,
|
|
1486
|
+
table,
|
|
1487
|
+
records,
|
|
1488
|
+
columns
|
|
1489
|
+
}) {
|
|
1097
1490
|
return operationsByTag.records.bulkInsertTableRecords({
|
|
1098
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1099
|
-
queryParams:
|
|
1491
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1492
|
+
queryParams: { columns },
|
|
1100
1493
|
body: { records },
|
|
1101
1494
|
...this.extraProps
|
|
1102
1495
|
});
|
|
1103
1496
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
body: query,
|
|
1497
|
+
branchTransaction({
|
|
1498
|
+
workspace,
|
|
1499
|
+
region,
|
|
1500
|
+
database,
|
|
1501
|
+
branch,
|
|
1502
|
+
operations
|
|
1503
|
+
}) {
|
|
1504
|
+
return operationsByTag.records.branchTransaction({
|
|
1505
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1506
|
+
body: { operations },
|
|
1115
1507
|
...this.extraProps
|
|
1116
1508
|
});
|
|
1117
1509
|
}
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
...this.extraProps
|
|
1123
|
-
});
|
|
1510
|
+
}
|
|
1511
|
+
class SearchAndFilterApi {
|
|
1512
|
+
constructor(extraProps) {
|
|
1513
|
+
this.extraProps = extraProps;
|
|
1124
1514
|
}
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1515
|
+
queryTable({
|
|
1516
|
+
workspace,
|
|
1517
|
+
region,
|
|
1518
|
+
database,
|
|
1519
|
+
branch,
|
|
1520
|
+
table,
|
|
1521
|
+
filter,
|
|
1522
|
+
sort,
|
|
1523
|
+
page,
|
|
1524
|
+
columns,
|
|
1525
|
+
consistency
|
|
1526
|
+
}) {
|
|
1527
|
+
return operationsByTag.searchAndFilter.queryTable({
|
|
1528
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1529
|
+
body: { filter, sort, page, columns, consistency },
|
|
1530
|
+
...this.extraProps
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
searchTable({
|
|
1534
|
+
workspace,
|
|
1535
|
+
region,
|
|
1536
|
+
database,
|
|
1537
|
+
branch,
|
|
1538
|
+
table,
|
|
1539
|
+
query,
|
|
1540
|
+
fuzziness,
|
|
1541
|
+
target,
|
|
1542
|
+
prefix,
|
|
1543
|
+
filter,
|
|
1544
|
+
highlight,
|
|
1545
|
+
boosters
|
|
1546
|
+
}) {
|
|
1547
|
+
return operationsByTag.searchAndFilter.searchTable({
|
|
1548
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1549
|
+
body: { query, fuzziness, target, prefix, filter, highlight, boosters },
|
|
1550
|
+
...this.extraProps
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
searchBranch({
|
|
1554
|
+
workspace,
|
|
1555
|
+
region,
|
|
1556
|
+
database,
|
|
1557
|
+
branch,
|
|
1558
|
+
tables,
|
|
1559
|
+
query,
|
|
1560
|
+
fuzziness,
|
|
1561
|
+
prefix,
|
|
1562
|
+
highlight
|
|
1563
|
+
}) {
|
|
1564
|
+
return operationsByTag.searchAndFilter.searchBranch({
|
|
1565
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1566
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
|
1567
|
+
...this.extraProps
|
|
1568
|
+
});
|
|
1569
|
+
}
|
|
1570
|
+
summarizeTable({
|
|
1571
|
+
workspace,
|
|
1572
|
+
region,
|
|
1573
|
+
database,
|
|
1574
|
+
branch,
|
|
1575
|
+
table,
|
|
1576
|
+
filter,
|
|
1577
|
+
columns,
|
|
1578
|
+
summaries,
|
|
1579
|
+
sort,
|
|
1580
|
+
summariesFilter,
|
|
1581
|
+
page,
|
|
1582
|
+
consistency
|
|
1583
|
+
}) {
|
|
1584
|
+
return operationsByTag.searchAndFilter.summarizeTable({
|
|
1585
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1586
|
+
body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
|
|
1587
|
+
...this.extraProps
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
aggregateTable({
|
|
1591
|
+
workspace,
|
|
1592
|
+
region,
|
|
1593
|
+
database,
|
|
1594
|
+
branch,
|
|
1595
|
+
table,
|
|
1596
|
+
filter,
|
|
1597
|
+
aggs
|
|
1598
|
+
}) {
|
|
1599
|
+
return operationsByTag.searchAndFilter.aggregateTable({
|
|
1600
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1601
|
+
body: { filter, aggs },
|
|
1129
1602
|
...this.extraProps
|
|
1130
1603
|
});
|
|
1131
1604
|
}
|
|
@@ -1134,123 +1607,310 @@ class MigrationRequestsApi {
|
|
|
1134
1607
|
constructor(extraProps) {
|
|
1135
1608
|
this.extraProps = extraProps;
|
|
1136
1609
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1610
|
+
queryMigrationRequests({
|
|
1611
|
+
workspace,
|
|
1612
|
+
region,
|
|
1613
|
+
database,
|
|
1614
|
+
filter,
|
|
1615
|
+
sort,
|
|
1616
|
+
page,
|
|
1617
|
+
columns
|
|
1618
|
+
}) {
|
|
1619
|
+
return operationsByTag.migrationRequests.queryMigrationRequests({
|
|
1620
|
+
pathParams: { workspace, region, dbName: database },
|
|
1621
|
+
body: { filter, sort, page, columns },
|
|
1622
|
+
...this.extraProps
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
createMigrationRequest({
|
|
1626
|
+
workspace,
|
|
1627
|
+
region,
|
|
1628
|
+
database,
|
|
1629
|
+
migration
|
|
1630
|
+
}) {
|
|
1145
1631
|
return operationsByTag.migrationRequests.createMigrationRequest({
|
|
1146
|
-
pathParams: { workspace, dbName: database },
|
|
1147
|
-
body:
|
|
1632
|
+
pathParams: { workspace, region, dbName: database },
|
|
1633
|
+
body: migration,
|
|
1148
1634
|
...this.extraProps
|
|
1149
1635
|
});
|
|
1150
1636
|
}
|
|
1151
|
-
getMigrationRequest(
|
|
1637
|
+
getMigrationRequest({
|
|
1638
|
+
workspace,
|
|
1639
|
+
region,
|
|
1640
|
+
database,
|
|
1641
|
+
migrationRequest
|
|
1642
|
+
}) {
|
|
1152
1643
|
return operationsByTag.migrationRequests.getMigrationRequest({
|
|
1153
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1644
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
1154
1645
|
...this.extraProps
|
|
1155
1646
|
});
|
|
1156
1647
|
}
|
|
1157
|
-
updateMigrationRequest(
|
|
1648
|
+
updateMigrationRequest({
|
|
1649
|
+
workspace,
|
|
1650
|
+
region,
|
|
1651
|
+
database,
|
|
1652
|
+
migrationRequest,
|
|
1653
|
+
update
|
|
1654
|
+
}) {
|
|
1158
1655
|
return operationsByTag.migrationRequests.updateMigrationRequest({
|
|
1159
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1160
|
-
body:
|
|
1656
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
1657
|
+
body: update,
|
|
1161
1658
|
...this.extraProps
|
|
1162
1659
|
});
|
|
1163
1660
|
}
|
|
1164
|
-
listMigrationRequestsCommits(
|
|
1661
|
+
listMigrationRequestsCommits({
|
|
1662
|
+
workspace,
|
|
1663
|
+
region,
|
|
1664
|
+
database,
|
|
1665
|
+
migrationRequest,
|
|
1666
|
+
page
|
|
1667
|
+
}) {
|
|
1165
1668
|
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
|
1166
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1167
|
-
body:
|
|
1669
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
1670
|
+
body: { page },
|
|
1168
1671
|
...this.extraProps
|
|
1169
1672
|
});
|
|
1170
1673
|
}
|
|
1171
|
-
compareMigrationRequest(
|
|
1674
|
+
compareMigrationRequest({
|
|
1675
|
+
workspace,
|
|
1676
|
+
region,
|
|
1677
|
+
database,
|
|
1678
|
+
migrationRequest
|
|
1679
|
+
}) {
|
|
1172
1680
|
return operationsByTag.migrationRequests.compareMigrationRequest({
|
|
1173
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1681
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
1174
1682
|
...this.extraProps
|
|
1175
1683
|
});
|
|
1176
1684
|
}
|
|
1177
|
-
getMigrationRequestIsMerged(
|
|
1685
|
+
getMigrationRequestIsMerged({
|
|
1686
|
+
workspace,
|
|
1687
|
+
region,
|
|
1688
|
+
database,
|
|
1689
|
+
migrationRequest
|
|
1690
|
+
}) {
|
|
1178
1691
|
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
|
1179
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1692
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
1180
1693
|
...this.extraProps
|
|
1181
1694
|
});
|
|
1182
1695
|
}
|
|
1183
|
-
mergeMigrationRequest(
|
|
1696
|
+
mergeMigrationRequest({
|
|
1697
|
+
workspace,
|
|
1698
|
+
region,
|
|
1699
|
+
database,
|
|
1700
|
+
migrationRequest
|
|
1701
|
+
}) {
|
|
1184
1702
|
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
|
1185
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1703
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
1186
1704
|
...this.extraProps
|
|
1187
1705
|
});
|
|
1188
1706
|
}
|
|
1189
1707
|
}
|
|
1190
|
-
class
|
|
1708
|
+
class MigrationsApi {
|
|
1191
1709
|
constructor(extraProps) {
|
|
1192
1710
|
this.extraProps = extraProps;
|
|
1193
1711
|
}
|
|
1194
|
-
getBranchMigrationHistory(
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1712
|
+
getBranchMigrationHistory({
|
|
1713
|
+
workspace,
|
|
1714
|
+
region,
|
|
1715
|
+
database,
|
|
1716
|
+
branch,
|
|
1717
|
+
limit,
|
|
1718
|
+
startFrom
|
|
1719
|
+
}) {
|
|
1720
|
+
return operationsByTag.migrations.getBranchMigrationHistory({
|
|
1721
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1722
|
+
body: { limit, startFrom },
|
|
1723
|
+
...this.extraProps
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
getBranchMigrationPlan({
|
|
1727
|
+
workspace,
|
|
1728
|
+
region,
|
|
1729
|
+
database,
|
|
1730
|
+
branch,
|
|
1731
|
+
schema
|
|
1732
|
+
}) {
|
|
1733
|
+
return operationsByTag.migrations.getBranchMigrationPlan({
|
|
1734
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1735
|
+
body: schema,
|
|
1198
1736
|
...this.extraProps
|
|
1199
1737
|
});
|
|
1200
1738
|
}
|
|
1201
|
-
executeBranchMigrationPlan(
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1739
|
+
executeBranchMigrationPlan({
|
|
1740
|
+
workspace,
|
|
1741
|
+
region,
|
|
1742
|
+
database,
|
|
1743
|
+
branch,
|
|
1744
|
+
plan
|
|
1745
|
+
}) {
|
|
1746
|
+
return operationsByTag.migrations.executeBranchMigrationPlan({
|
|
1747
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1748
|
+
body: plan,
|
|
1205
1749
|
...this.extraProps
|
|
1206
1750
|
});
|
|
1207
1751
|
}
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1752
|
+
getBranchSchemaHistory({
|
|
1753
|
+
workspace,
|
|
1754
|
+
region,
|
|
1755
|
+
database,
|
|
1756
|
+
branch,
|
|
1757
|
+
page
|
|
1758
|
+
}) {
|
|
1759
|
+
return operationsByTag.migrations.getBranchSchemaHistory({
|
|
1760
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1761
|
+
body: { page },
|
|
1212
1762
|
...this.extraProps
|
|
1213
1763
|
});
|
|
1214
1764
|
}
|
|
1215
|
-
compareBranchWithUserSchema(
|
|
1216
|
-
|
|
1217
|
-
|
|
1765
|
+
compareBranchWithUserSchema({
|
|
1766
|
+
workspace,
|
|
1767
|
+
region,
|
|
1768
|
+
database,
|
|
1769
|
+
branch,
|
|
1770
|
+
schema
|
|
1771
|
+
}) {
|
|
1772
|
+
return operationsByTag.migrations.compareBranchWithUserSchema({
|
|
1773
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1218
1774
|
body: { schema },
|
|
1219
1775
|
...this.extraProps
|
|
1220
1776
|
});
|
|
1221
1777
|
}
|
|
1222
|
-
compareBranchSchemas(
|
|
1223
|
-
|
|
1224
|
-
|
|
1778
|
+
compareBranchSchemas({
|
|
1779
|
+
workspace,
|
|
1780
|
+
region,
|
|
1781
|
+
database,
|
|
1782
|
+
branch,
|
|
1783
|
+
compare,
|
|
1784
|
+
schema
|
|
1785
|
+
}) {
|
|
1786
|
+
return operationsByTag.migrations.compareBranchSchemas({
|
|
1787
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
|
1225
1788
|
body: { schema },
|
|
1226
1789
|
...this.extraProps
|
|
1227
1790
|
});
|
|
1228
1791
|
}
|
|
1229
|
-
updateBranchSchema(
|
|
1230
|
-
|
|
1231
|
-
|
|
1792
|
+
updateBranchSchema({
|
|
1793
|
+
workspace,
|
|
1794
|
+
region,
|
|
1795
|
+
database,
|
|
1796
|
+
branch,
|
|
1797
|
+
migration
|
|
1798
|
+
}) {
|
|
1799
|
+
return operationsByTag.migrations.updateBranchSchema({
|
|
1800
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1232
1801
|
body: migration,
|
|
1233
1802
|
...this.extraProps
|
|
1234
1803
|
});
|
|
1235
1804
|
}
|
|
1236
|
-
previewBranchSchemaEdit(
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1805
|
+
previewBranchSchemaEdit({
|
|
1806
|
+
workspace,
|
|
1807
|
+
region,
|
|
1808
|
+
database,
|
|
1809
|
+
branch,
|
|
1810
|
+
data
|
|
1811
|
+
}) {
|
|
1812
|
+
return operationsByTag.migrations.previewBranchSchemaEdit({
|
|
1813
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1814
|
+
body: data,
|
|
1240
1815
|
...this.extraProps
|
|
1241
1816
|
});
|
|
1242
1817
|
}
|
|
1243
|
-
applyBranchSchemaEdit(
|
|
1244
|
-
|
|
1245
|
-
|
|
1818
|
+
applyBranchSchemaEdit({
|
|
1819
|
+
workspace,
|
|
1820
|
+
region,
|
|
1821
|
+
database,
|
|
1822
|
+
branch,
|
|
1823
|
+
edits
|
|
1824
|
+
}) {
|
|
1825
|
+
return operationsByTag.migrations.applyBranchSchemaEdit({
|
|
1826
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1246
1827
|
body: { edits },
|
|
1247
1828
|
...this.extraProps
|
|
1248
1829
|
});
|
|
1249
1830
|
}
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1831
|
+
}
|
|
1832
|
+
class DatabaseApi {
|
|
1833
|
+
constructor(extraProps) {
|
|
1834
|
+
this.extraProps = extraProps;
|
|
1835
|
+
}
|
|
1836
|
+
getDatabaseList({ workspace }) {
|
|
1837
|
+
return operationsByTag.databases.getDatabaseList({
|
|
1838
|
+
pathParams: { workspaceId: workspace },
|
|
1839
|
+
...this.extraProps
|
|
1840
|
+
});
|
|
1841
|
+
}
|
|
1842
|
+
createDatabase({
|
|
1843
|
+
workspace,
|
|
1844
|
+
database,
|
|
1845
|
+
data
|
|
1846
|
+
}) {
|
|
1847
|
+
return operationsByTag.databases.createDatabase({
|
|
1848
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
1849
|
+
body: data,
|
|
1850
|
+
...this.extraProps
|
|
1851
|
+
});
|
|
1852
|
+
}
|
|
1853
|
+
deleteDatabase({
|
|
1854
|
+
workspace,
|
|
1855
|
+
database
|
|
1856
|
+
}) {
|
|
1857
|
+
return operationsByTag.databases.deleteDatabase({
|
|
1858
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
1859
|
+
...this.extraProps
|
|
1860
|
+
});
|
|
1861
|
+
}
|
|
1862
|
+
getDatabaseMetadata({
|
|
1863
|
+
workspace,
|
|
1864
|
+
database
|
|
1865
|
+
}) {
|
|
1866
|
+
return operationsByTag.databases.getDatabaseMetadata({
|
|
1867
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
1868
|
+
...this.extraProps
|
|
1869
|
+
});
|
|
1870
|
+
}
|
|
1871
|
+
updateDatabaseMetadata({
|
|
1872
|
+
workspace,
|
|
1873
|
+
database,
|
|
1874
|
+
metadata
|
|
1875
|
+
}) {
|
|
1876
|
+
return operationsByTag.databases.updateDatabaseMetadata({
|
|
1877
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
1878
|
+
body: metadata,
|
|
1879
|
+
...this.extraProps
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1882
|
+
getDatabaseGithubSettings({
|
|
1883
|
+
workspace,
|
|
1884
|
+
database
|
|
1885
|
+
}) {
|
|
1886
|
+
return operationsByTag.databases.getDatabaseGithubSettings({
|
|
1887
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
1888
|
+
...this.extraProps
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
updateDatabaseGithubSettings({
|
|
1892
|
+
workspace,
|
|
1893
|
+
database,
|
|
1894
|
+
settings
|
|
1895
|
+
}) {
|
|
1896
|
+
return operationsByTag.databases.updateDatabaseGithubSettings({
|
|
1897
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
1898
|
+
body: settings,
|
|
1899
|
+
...this.extraProps
|
|
1900
|
+
});
|
|
1901
|
+
}
|
|
1902
|
+
deleteDatabaseGithubSettings({
|
|
1903
|
+
workspace,
|
|
1904
|
+
database
|
|
1905
|
+
}) {
|
|
1906
|
+
return operationsByTag.databases.deleteDatabaseGithubSettings({
|
|
1907
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
1908
|
+
...this.extraProps
|
|
1909
|
+
});
|
|
1910
|
+
}
|
|
1911
|
+
listRegions({ workspace }) {
|
|
1912
|
+
return operationsByTag.databases.listRegions({
|
|
1913
|
+
pathParams: { workspaceId: workspace },
|
|
1254
1914
|
...this.extraProps
|
|
1255
1915
|
});
|
|
1256
1916
|
}
|
|
@@ -1266,6 +1926,13 @@ class XataApiPlugin {
|
|
|
1266
1926
|
class XataPlugin {
|
|
1267
1927
|
}
|
|
1268
1928
|
|
|
1929
|
+
function cleanFilter(filter) {
|
|
1930
|
+
if (!filter)
|
|
1931
|
+
return void 0;
|
|
1932
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
|
1933
|
+
return values.length > 0 ? filter : void 0;
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1269
1936
|
var __accessCheck$6 = (obj, member, msg) => {
|
|
1270
1937
|
if (!member.has(obj))
|
|
1271
1938
|
throw TypeError("Cannot " + msg);
|
|
@@ -1298,11 +1965,11 @@ class Page {
|
|
|
1298
1965
|
async previousPage(size, offset) {
|
|
1299
1966
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
|
1300
1967
|
}
|
|
1301
|
-
async
|
|
1302
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
|
1968
|
+
async startPage(size, offset) {
|
|
1969
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
|
1303
1970
|
}
|
|
1304
|
-
async
|
|
1305
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
|
1971
|
+
async endPage(size, offset) {
|
|
1972
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
|
1306
1973
|
}
|
|
1307
1974
|
hasNextPage() {
|
|
1308
1975
|
return this.meta.page.more;
|
|
@@ -1314,7 +1981,7 @@ const PAGINATION_DEFAULT_SIZE = 20;
|
|
|
1314
1981
|
const PAGINATION_MAX_OFFSET = 800;
|
|
1315
1982
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
|
1316
1983
|
function isCursorPaginationOptions(options) {
|
|
1317
|
-
return isDefined(options) && (isDefined(options.
|
|
1984
|
+
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
|
1318
1985
|
}
|
|
1319
1986
|
const _RecordArray = class extends Array {
|
|
1320
1987
|
constructor(...args) {
|
|
@@ -1335,6 +2002,12 @@ const _RecordArray = class extends Array {
|
|
|
1335
2002
|
toArray() {
|
|
1336
2003
|
return new Array(...this);
|
|
1337
2004
|
}
|
|
2005
|
+
toSerializable() {
|
|
2006
|
+
return JSON.parse(this.toString());
|
|
2007
|
+
}
|
|
2008
|
+
toString() {
|
|
2009
|
+
return JSON.stringify(this.toArray());
|
|
2010
|
+
}
|
|
1338
2011
|
map(callbackfn, thisArg) {
|
|
1339
2012
|
return this.toArray().map(callbackfn, thisArg);
|
|
1340
2013
|
}
|
|
@@ -1346,12 +2019,12 @@ const _RecordArray = class extends Array {
|
|
|
1346
2019
|
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
|
1347
2020
|
return new _RecordArray(newPage);
|
|
1348
2021
|
}
|
|
1349
|
-
async
|
|
1350
|
-
const newPage = await __privateGet$6(this, _page).
|
|
2022
|
+
async startPage(size, offset) {
|
|
2023
|
+
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
|
1351
2024
|
return new _RecordArray(newPage);
|
|
1352
2025
|
}
|
|
1353
|
-
async
|
|
1354
|
-
const newPage = await __privateGet$6(this, _page).
|
|
2026
|
+
async endPage(size, offset) {
|
|
2027
|
+
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
|
1355
2028
|
return new _RecordArray(newPage);
|
|
1356
2029
|
}
|
|
1357
2030
|
hasNextPage() {
|
|
@@ -1405,9 +2078,11 @@ const _Query = class {
|
|
|
1405
2078
|
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
|
1406
2079
|
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
|
1407
2080
|
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
|
1408
|
-
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns
|
|
2081
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
|
|
2082
|
+
__privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
|
|
1409
2083
|
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
|
1410
2084
|
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
|
2085
|
+
__privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
|
|
1411
2086
|
this.any = this.any.bind(this);
|
|
1412
2087
|
this.all = this.all.bind(this);
|
|
1413
2088
|
this.not = this.not.bind(this);
|
|
@@ -1521,19 +2196,29 @@ const _Query = class {
|
|
|
1521
2196
|
throw new Error("No results found.");
|
|
1522
2197
|
return records[0];
|
|
1523
2198
|
}
|
|
2199
|
+
async summarize(params = {}) {
|
|
2200
|
+
const { summaries, summariesFilter, ...options } = params;
|
|
2201
|
+
const query = new _Query(
|
|
2202
|
+
__privateGet$5(this, _repository),
|
|
2203
|
+
__privateGet$5(this, _table$1),
|
|
2204
|
+
options,
|
|
2205
|
+
__privateGet$5(this, _data)
|
|
2206
|
+
);
|
|
2207
|
+
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
|
2208
|
+
}
|
|
1524
2209
|
cache(ttl) {
|
|
1525
2210
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
|
1526
2211
|
}
|
|
1527
2212
|
nextPage(size, offset) {
|
|
1528
|
-
return this.
|
|
2213
|
+
return this.startPage(size, offset);
|
|
1529
2214
|
}
|
|
1530
2215
|
previousPage(size, offset) {
|
|
1531
|
-
return this.
|
|
2216
|
+
return this.startPage(size, offset);
|
|
1532
2217
|
}
|
|
1533
|
-
|
|
2218
|
+
startPage(size, offset) {
|
|
1534
2219
|
return this.getPaginated({ pagination: { size, offset } });
|
|
1535
2220
|
}
|
|
1536
|
-
|
|
2221
|
+
endPage(size, offset) {
|
|
1537
2222
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
|
1538
2223
|
}
|
|
1539
2224
|
hasNextPage() {
|
|
@@ -1557,7 +2242,7 @@ cleanFilterConstraint_fn = function(column, value) {
|
|
|
1557
2242
|
};
|
|
1558
2243
|
function cleanParent(data, parent) {
|
|
1559
2244
|
if (isCursorPaginationOptions(data.pagination)) {
|
|
1560
|
-
return { ...parent,
|
|
2245
|
+
return { ...parent, sort: void 0, filter: void 0 };
|
|
1561
2246
|
}
|
|
1562
2247
|
return parent;
|
|
1563
2248
|
}
|
|
@@ -1616,7 +2301,8 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
|
1616
2301
|
__accessCheck$4(obj, member, "access private method");
|
|
1617
2302
|
return method;
|
|
1618
2303
|
};
|
|
1619
|
-
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn,
|
|
2304
|
+
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _insertRecords, insertRecords_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;
|
|
2305
|
+
const BULK_OPERATION_MAX_SIZE = 1e3;
|
|
1620
2306
|
class Repository extends Query {
|
|
1621
2307
|
}
|
|
1622
2308
|
class RestRepository extends Query {
|
|
@@ -1628,10 +2314,12 @@ class RestRepository extends Query {
|
|
|
1628
2314
|
);
|
|
1629
2315
|
__privateAdd$4(this, _insertRecordWithoutId);
|
|
1630
2316
|
__privateAdd$4(this, _insertRecordWithId);
|
|
1631
|
-
__privateAdd$4(this,
|
|
2317
|
+
__privateAdd$4(this, _insertRecords);
|
|
1632
2318
|
__privateAdd$4(this, _updateRecordWithID);
|
|
2319
|
+
__privateAdd$4(this, _updateRecords);
|
|
1633
2320
|
__privateAdd$4(this, _upsertRecordWithID);
|
|
1634
2321
|
__privateAdd$4(this, _deleteRecord);
|
|
2322
|
+
__privateAdd$4(this, _deleteRecords);
|
|
1635
2323
|
__privateAdd$4(this, _setCacheQuery);
|
|
1636
2324
|
__privateAdd$4(this, _getCacheQuery);
|
|
1637
2325
|
__privateAdd$4(this, _getSchemaTables$1);
|
|
@@ -1642,10 +2330,13 @@ class RestRepository extends Query {
|
|
|
1642
2330
|
__privateAdd$4(this, _schemaTables$2, void 0);
|
|
1643
2331
|
__privateAdd$4(this, _trace, void 0);
|
|
1644
2332
|
__privateSet$4(this, _table, options.table);
|
|
1645
|
-
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
|
1646
2333
|
__privateSet$4(this, _db, options.db);
|
|
1647
2334
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
|
1648
2335
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
|
2336
|
+
__privateSet$4(this, _getFetchProps, async () => {
|
|
2337
|
+
const props = await options.pluginOptions.getFetchProps();
|
|
2338
|
+
return { ...props, sessionID: generateUUID() };
|
|
2339
|
+
});
|
|
1649
2340
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
|
1650
2341
|
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
|
1651
2342
|
return trace(name, fn, {
|
|
@@ -1656,25 +2347,28 @@ class RestRepository extends Query {
|
|
|
1656
2347
|
});
|
|
1657
2348
|
});
|
|
1658
2349
|
}
|
|
1659
|
-
async create(a, b, c) {
|
|
2350
|
+
async create(a, b, c, d) {
|
|
1660
2351
|
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
|
2352
|
+
const ifVersion = parseIfVersion(b, c, d);
|
|
1661
2353
|
if (Array.isArray(a)) {
|
|
1662
2354
|
if (a.length === 0)
|
|
1663
2355
|
return [];
|
|
1664
|
-
const
|
|
1665
|
-
|
|
2356
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
|
2357
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
2358
|
+
const result = await this.read(ids, columns);
|
|
2359
|
+
return result;
|
|
1666
2360
|
}
|
|
1667
2361
|
if (isString(a) && isObject(b)) {
|
|
1668
2362
|
if (a === "")
|
|
1669
2363
|
throw new Error("The id can't be empty");
|
|
1670
2364
|
const columns = isStringArray(c) ? c : void 0;
|
|
1671
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
|
2365
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
|
1672
2366
|
}
|
|
1673
2367
|
if (isObject(a) && isString(a.id)) {
|
|
1674
2368
|
if (a.id === "")
|
|
1675
2369
|
throw new Error("The id can't be empty");
|
|
1676
2370
|
const columns = isStringArray(b) ? b : void 0;
|
|
1677
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
|
2371
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
|
1678
2372
|
}
|
|
1679
2373
|
if (isObject(a)) {
|
|
1680
2374
|
const columns = isStringArray(b) ? b : void 0;
|
|
@@ -1705,6 +2399,7 @@ class RestRepository extends Query {
|
|
|
1705
2399
|
pathParams: {
|
|
1706
2400
|
workspace: "{workspaceId}",
|
|
1707
2401
|
dbBranchName: "{dbBranch}",
|
|
2402
|
+
region: "{region}",
|
|
1708
2403
|
tableName: __privateGet$4(this, _table),
|
|
1709
2404
|
recordId: id
|
|
1710
2405
|
},
|
|
@@ -1742,31 +2437,42 @@ class RestRepository extends Query {
|
|
|
1742
2437
|
return result;
|
|
1743
2438
|
});
|
|
1744
2439
|
}
|
|
1745
|
-
async update(a, b, c) {
|
|
2440
|
+
async update(a, b, c, d) {
|
|
1746
2441
|
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
|
2442
|
+
const ifVersion = parseIfVersion(b, c, d);
|
|
1747
2443
|
if (Array.isArray(a)) {
|
|
1748
2444
|
if (a.length === 0)
|
|
1749
2445
|
return [];
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
2446
|
+
const existing = await this.read(a, ["id"]);
|
|
2447
|
+
const updates = a.filter((_item, index) => existing[index] !== null);
|
|
2448
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
|
|
2449
|
+
ifVersion,
|
|
2450
|
+
upsert: false
|
|
2451
|
+
});
|
|
1753
2452
|
const columns = isStringArray(b) ? b : ["*"];
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
if (isString(a) && isObject(b)) {
|
|
1757
|
-
const columns = isStringArray(c) ? c : void 0;
|
|
1758
|
-
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
|
|
2453
|
+
const result = await this.read(a, columns);
|
|
2454
|
+
return result;
|
|
1759
2455
|
}
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
2456
|
+
try {
|
|
2457
|
+
if (isString(a) && isObject(b)) {
|
|
2458
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
2459
|
+
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
|
2460
|
+
}
|
|
2461
|
+
if (isObject(a) && isString(a.id)) {
|
|
2462
|
+
const columns = isStringArray(b) ? b : void 0;
|
|
2463
|
+
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
|
2464
|
+
}
|
|
2465
|
+
} catch (error) {
|
|
2466
|
+
if (error.status === 422)
|
|
2467
|
+
return null;
|
|
2468
|
+
throw error;
|
|
1763
2469
|
}
|
|
1764
2470
|
throw new Error("Invalid arguments for update method");
|
|
1765
2471
|
});
|
|
1766
2472
|
}
|
|
1767
|
-
async updateOrThrow(a, b, c) {
|
|
2473
|
+
async updateOrThrow(a, b, c, d) {
|
|
1768
2474
|
return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
|
|
1769
|
-
const result = await this.update(a, b, c);
|
|
2475
|
+
const result = await this.update(a, b, c, d);
|
|
1770
2476
|
if (Array.isArray(result)) {
|
|
1771
2477
|
const missingIds = compact(
|
|
1772
2478
|
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
|
@@ -1783,37 +2489,69 @@ class RestRepository extends Query {
|
|
|
1783
2489
|
return result;
|
|
1784
2490
|
});
|
|
1785
2491
|
}
|
|
1786
|
-
async createOrUpdate(a, b, c) {
|
|
2492
|
+
async createOrUpdate(a, b, c, d) {
|
|
1787
2493
|
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
|
2494
|
+
const ifVersion = parseIfVersion(b, c, d);
|
|
1788
2495
|
if (Array.isArray(a)) {
|
|
1789
2496
|
if (a.length === 0)
|
|
1790
2497
|
return [];
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
2498
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
|
|
2499
|
+
ifVersion,
|
|
2500
|
+
upsert: true
|
|
2501
|
+
});
|
|
1794
2502
|
const columns = isStringArray(b) ? b : ["*"];
|
|
1795
|
-
|
|
2503
|
+
const result = await this.read(a, columns);
|
|
2504
|
+
return result;
|
|
1796
2505
|
}
|
|
1797
2506
|
if (isString(a) && isObject(b)) {
|
|
1798
2507
|
const columns = isStringArray(c) ? c : void 0;
|
|
1799
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
|
|
2508
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
|
1800
2509
|
}
|
|
1801
2510
|
if (isObject(a) && isString(a.id)) {
|
|
1802
2511
|
const columns = isStringArray(c) ? c : void 0;
|
|
1803
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
|
2512
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
|
1804
2513
|
}
|
|
1805
2514
|
throw new Error("Invalid arguments for createOrUpdate method");
|
|
1806
2515
|
});
|
|
1807
2516
|
}
|
|
2517
|
+
async createOrReplace(a, b, c, d) {
|
|
2518
|
+
return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
|
|
2519
|
+
const ifVersion = parseIfVersion(b, c, d);
|
|
2520
|
+
if (Array.isArray(a)) {
|
|
2521
|
+
if (a.length === 0)
|
|
2522
|
+
return [];
|
|
2523
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
|
2524
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
2525
|
+
const result = await this.read(ids, columns);
|
|
2526
|
+
return result;
|
|
2527
|
+
}
|
|
2528
|
+
if (isString(a) && isObject(b)) {
|
|
2529
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
2530
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
|
2531
|
+
}
|
|
2532
|
+
if (isObject(a) && isString(a.id)) {
|
|
2533
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
2534
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
|
2535
|
+
}
|
|
2536
|
+
throw new Error("Invalid arguments for createOrReplace method");
|
|
2537
|
+
});
|
|
2538
|
+
}
|
|
1808
2539
|
async delete(a, b) {
|
|
1809
2540
|
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
|
1810
2541
|
if (Array.isArray(a)) {
|
|
1811
2542
|
if (a.length === 0)
|
|
1812
2543
|
return [];
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
2544
|
+
const ids = a.map((o) => {
|
|
2545
|
+
if (isString(o))
|
|
2546
|
+
return o;
|
|
2547
|
+
if (isString(o.id))
|
|
2548
|
+
return o.id;
|
|
2549
|
+
throw new Error("Invalid arguments for delete method");
|
|
2550
|
+
});
|
|
2551
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
2552
|
+
const result = await this.read(a, columns);
|
|
2553
|
+
await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
|
|
2554
|
+
return result;
|
|
1817
2555
|
}
|
|
1818
2556
|
if (isString(a)) {
|
|
1819
2557
|
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
|
|
@@ -1846,14 +2584,21 @@ class RestRepository extends Query {
|
|
|
1846
2584
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
|
1847
2585
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1848
2586
|
const { records } = await searchTable({
|
|
1849
|
-
pathParams: {
|
|
2587
|
+
pathParams: {
|
|
2588
|
+
workspace: "{workspaceId}",
|
|
2589
|
+
dbBranchName: "{dbBranch}",
|
|
2590
|
+
region: "{region}",
|
|
2591
|
+
tableName: __privateGet$4(this, _table)
|
|
2592
|
+
},
|
|
1850
2593
|
body: {
|
|
1851
2594
|
query,
|
|
1852
2595
|
fuzziness: options.fuzziness,
|
|
1853
2596
|
prefix: options.prefix,
|
|
1854
2597
|
highlight: options.highlight,
|
|
1855
2598
|
filter: options.filter,
|
|
1856
|
-
boosters: options.boosters
|
|
2599
|
+
boosters: options.boosters,
|
|
2600
|
+
page: options.page,
|
|
2601
|
+
target: options.target
|
|
1857
2602
|
},
|
|
1858
2603
|
...fetchProps
|
|
1859
2604
|
});
|
|
@@ -1861,22 +2606,44 @@ class RestRepository extends Query {
|
|
|
1861
2606
|
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
|
1862
2607
|
});
|
|
1863
2608
|
}
|
|
2609
|
+
async aggregate(aggs, filter) {
|
|
2610
|
+
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
|
2611
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2612
|
+
const result = await aggregateTable({
|
|
2613
|
+
pathParams: {
|
|
2614
|
+
workspace: "{workspaceId}",
|
|
2615
|
+
dbBranchName: "{dbBranch}",
|
|
2616
|
+
region: "{region}",
|
|
2617
|
+
tableName: __privateGet$4(this, _table)
|
|
2618
|
+
},
|
|
2619
|
+
body: { aggs, filter },
|
|
2620
|
+
...fetchProps
|
|
2621
|
+
});
|
|
2622
|
+
return result;
|
|
2623
|
+
});
|
|
2624
|
+
}
|
|
1864
2625
|
async query(query) {
|
|
1865
2626
|
return __privateGet$4(this, _trace).call(this, "query", async () => {
|
|
1866
2627
|
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
|
1867
2628
|
if (cacheQuery)
|
|
1868
2629
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
|
1869
2630
|
const data = query.getQueryOptions();
|
|
1870
|
-
const body = {
|
|
1871
|
-
filter: cleanFilter(data.filter),
|
|
1872
|
-
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
|
1873
|
-
page: data.pagination,
|
|
1874
|
-
columns: data.columns
|
|
1875
|
-
};
|
|
1876
2631
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1877
2632
|
const { meta, records: objects } = await queryTable({
|
|
1878
|
-
pathParams: {
|
|
1879
|
-
|
|
2633
|
+
pathParams: {
|
|
2634
|
+
workspace: "{workspaceId}",
|
|
2635
|
+
dbBranchName: "{dbBranch}",
|
|
2636
|
+
region: "{region}",
|
|
2637
|
+
tableName: __privateGet$4(this, _table)
|
|
2638
|
+
},
|
|
2639
|
+
body: {
|
|
2640
|
+
filter: cleanFilter(data.filter),
|
|
2641
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
|
2642
|
+
page: data.pagination,
|
|
2643
|
+
columns: data.columns ?? ["*"],
|
|
2644
|
+
consistency: data.consistency
|
|
2645
|
+
},
|
|
2646
|
+
fetchOptions: data.fetchOptions,
|
|
1880
2647
|
...fetchProps
|
|
1881
2648
|
});
|
|
1882
2649
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
@@ -1887,6 +2654,31 @@ class RestRepository extends Query {
|
|
|
1887
2654
|
return new Page(query, meta, records);
|
|
1888
2655
|
});
|
|
1889
2656
|
}
|
|
2657
|
+
async summarizeTable(query, summaries, summariesFilter) {
|
|
2658
|
+
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
|
2659
|
+
const data = query.getQueryOptions();
|
|
2660
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2661
|
+
const result = await summarizeTable({
|
|
2662
|
+
pathParams: {
|
|
2663
|
+
workspace: "{workspaceId}",
|
|
2664
|
+
dbBranchName: "{dbBranch}",
|
|
2665
|
+
region: "{region}",
|
|
2666
|
+
tableName: __privateGet$4(this, _table)
|
|
2667
|
+
},
|
|
2668
|
+
body: {
|
|
2669
|
+
filter: cleanFilter(data.filter),
|
|
2670
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
|
2671
|
+
columns: data.columns,
|
|
2672
|
+
consistency: data.consistency,
|
|
2673
|
+
page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
|
|
2674
|
+
summaries,
|
|
2675
|
+
summariesFilter
|
|
2676
|
+
},
|
|
2677
|
+
...fetchProps
|
|
2678
|
+
});
|
|
2679
|
+
return result;
|
|
2680
|
+
});
|
|
2681
|
+
}
|
|
1890
2682
|
}
|
|
1891
2683
|
_table = new WeakMap();
|
|
1892
2684
|
_getFetchProps = new WeakMap();
|
|
@@ -1902,6 +2694,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
|
1902
2694
|
pathParams: {
|
|
1903
2695
|
workspace: "{workspaceId}",
|
|
1904
2696
|
dbBranchName: "{dbBranch}",
|
|
2697
|
+
region: "{region}",
|
|
1905
2698
|
tableName: __privateGet$4(this, _table)
|
|
1906
2699
|
},
|
|
1907
2700
|
queryParams: { columns },
|
|
@@ -1912,47 +2705,68 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
|
1912
2705
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
1913
2706
|
};
|
|
1914
2707
|
_insertRecordWithId = new WeakSet();
|
|
1915
|
-
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
|
2708
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
|
1916
2709
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1917
2710
|
const record = transformObjectLinks(object);
|
|
1918
2711
|
const response = await insertRecordWithID({
|
|
1919
2712
|
pathParams: {
|
|
1920
2713
|
workspace: "{workspaceId}",
|
|
1921
2714
|
dbBranchName: "{dbBranch}",
|
|
2715
|
+
region: "{region}",
|
|
1922
2716
|
tableName: __privateGet$4(this, _table),
|
|
1923
2717
|
recordId
|
|
1924
2718
|
},
|
|
1925
2719
|
body: record,
|
|
1926
|
-
queryParams: { createOnly
|
|
2720
|
+
queryParams: { createOnly, columns, ifVersion },
|
|
1927
2721
|
...fetchProps
|
|
1928
2722
|
});
|
|
1929
2723
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1930
2724
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
1931
2725
|
};
|
|
1932
|
-
|
|
1933
|
-
|
|
2726
|
+
_insertRecords = new WeakSet();
|
|
2727
|
+
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
|
1934
2728
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1935
|
-
const
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
2729
|
+
const chunkedOperations = chunk(
|
|
2730
|
+
objects.map((object) => ({
|
|
2731
|
+
insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
|
|
2732
|
+
})),
|
|
2733
|
+
BULK_OPERATION_MAX_SIZE
|
|
2734
|
+
);
|
|
2735
|
+
const ids = [];
|
|
2736
|
+
for (const operations of chunkedOperations) {
|
|
2737
|
+
const { results } = await branchTransaction({
|
|
2738
|
+
pathParams: {
|
|
2739
|
+
workspace: "{workspaceId}",
|
|
2740
|
+
dbBranchName: "{dbBranch}",
|
|
2741
|
+
region: "{region}"
|
|
2742
|
+
},
|
|
2743
|
+
body: { operations },
|
|
2744
|
+
...fetchProps
|
|
2745
|
+
});
|
|
2746
|
+
for (const result of results) {
|
|
2747
|
+
if (result.operation === "insert") {
|
|
2748
|
+
ids.push(result.id);
|
|
2749
|
+
} else {
|
|
2750
|
+
ids.push(null);
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
1944
2753
|
}
|
|
1945
|
-
|
|
1946
|
-
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
|
|
2754
|
+
return ids;
|
|
1947
2755
|
};
|
|
1948
2756
|
_updateRecordWithID = new WeakSet();
|
|
1949
|
-
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
2757
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
|
1950
2758
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1951
|
-
const record = transformObjectLinks(object);
|
|
2759
|
+
const { id: _id, ...record } = transformObjectLinks(object);
|
|
1952
2760
|
try {
|
|
1953
2761
|
const response = await updateRecordWithID({
|
|
1954
|
-
pathParams: {
|
|
1955
|
-
|
|
2762
|
+
pathParams: {
|
|
2763
|
+
workspace: "{workspaceId}",
|
|
2764
|
+
dbBranchName: "{dbBranch}",
|
|
2765
|
+
region: "{region}",
|
|
2766
|
+
tableName: __privateGet$4(this, _table),
|
|
2767
|
+
recordId
|
|
2768
|
+
},
|
|
2769
|
+
queryParams: { columns, ifVersion },
|
|
1956
2770
|
body: record,
|
|
1957
2771
|
...fetchProps
|
|
1958
2772
|
});
|
|
@@ -1965,12 +2779,48 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
|
1965
2779
|
throw e;
|
|
1966
2780
|
}
|
|
1967
2781
|
};
|
|
2782
|
+
_updateRecords = new WeakSet();
|
|
2783
|
+
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
|
2784
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2785
|
+
const chunkedOperations = chunk(
|
|
2786
|
+
objects.map(({ id, ...object }) => ({
|
|
2787
|
+
update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
|
|
2788
|
+
})),
|
|
2789
|
+
BULK_OPERATION_MAX_SIZE
|
|
2790
|
+
);
|
|
2791
|
+
const ids = [];
|
|
2792
|
+
for (const operations of chunkedOperations) {
|
|
2793
|
+
const { results } = await branchTransaction({
|
|
2794
|
+
pathParams: {
|
|
2795
|
+
workspace: "{workspaceId}",
|
|
2796
|
+
dbBranchName: "{dbBranch}",
|
|
2797
|
+
region: "{region}"
|
|
2798
|
+
},
|
|
2799
|
+
body: { operations },
|
|
2800
|
+
...fetchProps
|
|
2801
|
+
});
|
|
2802
|
+
for (const result of results) {
|
|
2803
|
+
if (result.operation === "update") {
|
|
2804
|
+
ids.push(result.id);
|
|
2805
|
+
} else {
|
|
2806
|
+
ids.push(null);
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
return ids;
|
|
2811
|
+
};
|
|
1968
2812
|
_upsertRecordWithID = new WeakSet();
|
|
1969
|
-
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
2813
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
|
1970
2814
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1971
2815
|
const response = await upsertRecordWithID({
|
|
1972
|
-
pathParams: {
|
|
1973
|
-
|
|
2816
|
+
pathParams: {
|
|
2817
|
+
workspace: "{workspaceId}",
|
|
2818
|
+
dbBranchName: "{dbBranch}",
|
|
2819
|
+
region: "{region}",
|
|
2820
|
+
tableName: __privateGet$4(this, _table),
|
|
2821
|
+
recordId
|
|
2822
|
+
},
|
|
2823
|
+
queryParams: { columns, ifVersion },
|
|
1974
2824
|
body: object,
|
|
1975
2825
|
...fetchProps
|
|
1976
2826
|
});
|
|
@@ -1982,7 +2832,13 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
|
1982
2832
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1983
2833
|
try {
|
|
1984
2834
|
const response = await deleteRecord({
|
|
1985
|
-
pathParams: {
|
|
2835
|
+
pathParams: {
|
|
2836
|
+
workspace: "{workspaceId}",
|
|
2837
|
+
dbBranchName: "{dbBranch}",
|
|
2838
|
+
region: "{region}",
|
|
2839
|
+
tableName: __privateGet$4(this, _table),
|
|
2840
|
+
recordId
|
|
2841
|
+
},
|
|
1986
2842
|
queryParams: { columns },
|
|
1987
2843
|
...fetchProps
|
|
1988
2844
|
});
|
|
@@ -1995,6 +2851,25 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
|
1995
2851
|
throw e;
|
|
1996
2852
|
}
|
|
1997
2853
|
};
|
|
2854
|
+
_deleteRecords = new WeakSet();
|
|
2855
|
+
deleteRecords_fn = async function(recordIds) {
|
|
2856
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2857
|
+
const chunkedOperations = chunk(
|
|
2858
|
+
recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
|
2859
|
+
BULK_OPERATION_MAX_SIZE
|
|
2860
|
+
);
|
|
2861
|
+
for (const operations of chunkedOperations) {
|
|
2862
|
+
await branchTransaction({
|
|
2863
|
+
pathParams: {
|
|
2864
|
+
workspace: "{workspaceId}",
|
|
2865
|
+
dbBranchName: "{dbBranch}",
|
|
2866
|
+
region: "{region}"
|
|
2867
|
+
},
|
|
2868
|
+
body: { operations },
|
|
2869
|
+
...fetchProps
|
|
2870
|
+
});
|
|
2871
|
+
}
|
|
2872
|
+
};
|
|
1998
2873
|
_setCacheQuery = new WeakSet();
|
|
1999
2874
|
setCacheQuery_fn = async function(query, meta, records) {
|
|
2000
2875
|
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
|
@@ -2017,7 +2892,7 @@ getSchemaTables_fn$1 = async function() {
|
|
|
2017
2892
|
return __privateGet$4(this, _schemaTables$2);
|
|
2018
2893
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2019
2894
|
const { schema } = await getBranchDetails({
|
|
2020
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
2895
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
2021
2896
|
...fetchProps
|
|
2022
2897
|
});
|
|
2023
2898
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
|
@@ -2031,23 +2906,23 @@ const transformObjectLinks = (object) => {
|
|
|
2031
2906
|
}, {});
|
|
2032
2907
|
};
|
|
2033
2908
|
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2034
|
-
const
|
|
2909
|
+
const data = {};
|
|
2035
2910
|
const { xata, ...rest } = object ?? {};
|
|
2036
|
-
Object.assign(
|
|
2911
|
+
Object.assign(data, rest);
|
|
2037
2912
|
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
|
2038
2913
|
if (!columns)
|
|
2039
2914
|
console.error(`Table ${table} not found in schema`);
|
|
2040
2915
|
for (const column of columns ?? []) {
|
|
2041
2916
|
if (!isValidColumn(selectedColumns, column))
|
|
2042
2917
|
continue;
|
|
2043
|
-
const value =
|
|
2918
|
+
const value = data[column.name];
|
|
2044
2919
|
switch (column.type) {
|
|
2045
2920
|
case "datetime": {
|
|
2046
|
-
const date = value !== void 0 ? new Date(value) :
|
|
2047
|
-
if (date && isNaN(date.getTime())) {
|
|
2921
|
+
const date = value !== void 0 ? new Date(value) : null;
|
|
2922
|
+
if (date !== null && isNaN(date.getTime())) {
|
|
2048
2923
|
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
|
2049
|
-
} else
|
|
2050
|
-
|
|
2924
|
+
} else {
|
|
2925
|
+
data[column.name] = date;
|
|
2051
2926
|
}
|
|
2052
2927
|
break;
|
|
2053
2928
|
}
|
|
@@ -2066,41 +2941,52 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
|
2066
2941
|
}
|
|
2067
2942
|
return acc;
|
|
2068
2943
|
}, []);
|
|
2069
|
-
|
|
2944
|
+
data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
|
|
2070
2945
|
} else {
|
|
2071
|
-
|
|
2946
|
+
data[column.name] = null;
|
|
2072
2947
|
}
|
|
2073
2948
|
break;
|
|
2074
2949
|
}
|
|
2075
2950
|
default:
|
|
2076
|
-
|
|
2951
|
+
data[column.name] = value ?? null;
|
|
2077
2952
|
if (column.notNull === true && value === null) {
|
|
2078
2953
|
console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
|
|
2079
2954
|
}
|
|
2080
2955
|
break;
|
|
2081
2956
|
}
|
|
2082
2957
|
}
|
|
2083
|
-
|
|
2084
|
-
|
|
2958
|
+
const record = { ...data };
|
|
2959
|
+
record.read = function(columns2) {
|
|
2960
|
+
return db[table].read(record["id"], columns2);
|
|
2961
|
+
};
|
|
2962
|
+
record.update = function(data2, b, c) {
|
|
2963
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
|
2964
|
+
const ifVersion = parseIfVersion(b, c);
|
|
2965
|
+
return db[table].update(record["id"], data2, columns2, { ifVersion });
|
|
2085
2966
|
};
|
|
2086
|
-
|
|
2087
|
-
|
|
2967
|
+
record.replace = function(data2, b, c) {
|
|
2968
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
|
2969
|
+
const ifVersion = parseIfVersion(b, c);
|
|
2970
|
+
return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
|
|
2088
2971
|
};
|
|
2089
|
-
|
|
2090
|
-
return db[table].delete(
|
|
2972
|
+
record.delete = function() {
|
|
2973
|
+
return db[table].delete(record["id"]);
|
|
2091
2974
|
};
|
|
2092
|
-
|
|
2975
|
+
record.getMetadata = function() {
|
|
2093
2976
|
return xata;
|
|
2094
2977
|
};
|
|
2095
|
-
|
|
2096
|
-
|
|
2978
|
+
record.toSerializable = function() {
|
|
2979
|
+
return JSON.parse(JSON.stringify(transformObjectLinks(data)));
|
|
2980
|
+
};
|
|
2981
|
+
record.toString = function() {
|
|
2982
|
+
return JSON.stringify(transformObjectLinks(data));
|
|
2983
|
+
};
|
|
2984
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
|
2985
|
+
Object.defineProperty(record, prop, { enumerable: false });
|
|
2097
2986
|
}
|
|
2098
|
-
Object.freeze(
|
|
2099
|
-
return
|
|
2987
|
+
Object.freeze(record);
|
|
2988
|
+
return record;
|
|
2100
2989
|
};
|
|
2101
|
-
function isResponseWithRecords(value) {
|
|
2102
|
-
return isObject(value) && Array.isArray(value.records);
|
|
2103
|
-
}
|
|
2104
2990
|
function extractId(value) {
|
|
2105
2991
|
if (isString(value))
|
|
2106
2992
|
return value;
|
|
@@ -2108,12 +2994,6 @@ function extractId(value) {
|
|
|
2108
2994
|
return value.id;
|
|
2109
2995
|
return void 0;
|
|
2110
2996
|
}
|
|
2111
|
-
function cleanFilter(filter) {
|
|
2112
|
-
if (!filter)
|
|
2113
|
-
return void 0;
|
|
2114
|
-
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
|
2115
|
-
return values.length > 0 ? filter : void 0;
|
|
2116
|
-
}
|
|
2117
2997
|
function isValidColumn(columns, column) {
|
|
2118
2998
|
if (columns.includes("*"))
|
|
2119
2999
|
return true;
|
|
@@ -2123,6 +3003,14 @@ function isValidColumn(columns, column) {
|
|
|
2123
3003
|
}
|
|
2124
3004
|
return columns.includes(column.name);
|
|
2125
3005
|
}
|
|
3006
|
+
function parseIfVersion(...args) {
|
|
3007
|
+
for (const arg of args) {
|
|
3008
|
+
if (isObject(arg) && isNumber(arg.ifVersion)) {
|
|
3009
|
+
return arg.ifVersion;
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
return void 0;
|
|
3013
|
+
}
|
|
2126
3014
|
|
|
2127
3015
|
var __accessCheck$3 = (obj, member, msg) => {
|
|
2128
3016
|
if (!member.has(obj))
|
|
@@ -2308,10 +3196,10 @@ _schemaTables = new WeakMap();
|
|
|
2308
3196
|
_search = new WeakSet();
|
|
2309
3197
|
search_fn = async function(query, options, getFetchProps) {
|
|
2310
3198
|
const fetchProps = await getFetchProps();
|
|
2311
|
-
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
|
3199
|
+
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
|
2312
3200
|
const { records } = await searchBranch({
|
|
2313
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
2314
|
-
body: { tables, query, fuzziness, prefix, highlight },
|
|
3201
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
3202
|
+
body: { tables, query, fuzziness, prefix, highlight, page },
|
|
2315
3203
|
...fetchProps
|
|
2316
3204
|
});
|
|
2317
3205
|
return records;
|
|
@@ -2322,25 +3210,37 @@ getSchemaTables_fn = async function(getFetchProps) {
|
|
|
2322
3210
|
return __privateGet$1(this, _schemaTables);
|
|
2323
3211
|
const fetchProps = await getFetchProps();
|
|
2324
3212
|
const { schema } = await getBranchDetails({
|
|
2325
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
3213
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
2326
3214
|
...fetchProps
|
|
2327
3215
|
});
|
|
2328
3216
|
__privateSet$1(this, _schemaTables, schema.tables);
|
|
2329
3217
|
return schema.tables;
|
|
2330
3218
|
};
|
|
2331
3219
|
|
|
3220
|
+
class TransactionPlugin extends XataPlugin {
|
|
3221
|
+
build({ getFetchProps }) {
|
|
3222
|
+
return {
|
|
3223
|
+
run: async (operations) => {
|
|
3224
|
+
const fetchProps = await getFetchProps();
|
|
3225
|
+
const response = await branchTransaction({
|
|
3226
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
3227
|
+
body: { operations },
|
|
3228
|
+
...fetchProps
|
|
3229
|
+
});
|
|
3230
|
+
return response;
|
|
3231
|
+
}
|
|
3232
|
+
};
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
|
|
2332
3236
|
const isBranchStrategyBuilder = (strategy) => {
|
|
2333
3237
|
return typeof strategy === "function";
|
|
2334
3238
|
};
|
|
2335
3239
|
|
|
2336
3240
|
async function getCurrentBranchName(options) {
|
|
2337
3241
|
const { branch, envBranch } = getEnvironment();
|
|
2338
|
-
if (branch)
|
|
2339
|
-
|
|
2340
|
-
if (details)
|
|
2341
|
-
return branch;
|
|
2342
|
-
console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
|
|
2343
|
-
}
|
|
3242
|
+
if (branch)
|
|
3243
|
+
return branch;
|
|
2344
3244
|
const gitBranch = envBranch || await getGitBranch();
|
|
2345
3245
|
return resolveXataBranch(gitBranch, options);
|
|
2346
3246
|
}
|
|
@@ -2360,16 +3260,20 @@ async function resolveXataBranch(gitBranch, options) {
|
|
|
2360
3260
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
|
2361
3261
|
);
|
|
2362
3262
|
const [protocol, , host, , dbName] = databaseURL.split("/");
|
|
2363
|
-
const
|
|
3263
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
|
3264
|
+
if (!urlParts)
|
|
3265
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
|
3266
|
+
const { workspace, region } = urlParts;
|
|
2364
3267
|
const { fallbackBranch } = getEnvironment();
|
|
2365
3268
|
const { branch } = await resolveBranch({
|
|
2366
3269
|
apiKey,
|
|
2367
3270
|
apiUrl: databaseURL,
|
|
2368
3271
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
|
2369
3272
|
workspacesApiUrl: `${protocol}//${host}`,
|
|
2370
|
-
pathParams: { dbName, workspace },
|
|
3273
|
+
pathParams: { dbName, workspace, region },
|
|
2371
3274
|
queryParams: { gitBranch, fallbackBranch },
|
|
2372
|
-
trace: defaultTrace
|
|
3275
|
+
trace: defaultTrace,
|
|
3276
|
+
clientName: options?.clientName
|
|
2373
3277
|
});
|
|
2374
3278
|
return branch;
|
|
2375
3279
|
}
|
|
@@ -2385,15 +3289,17 @@ async function getDatabaseBranch(branch, options) {
|
|
|
2385
3289
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
|
2386
3290
|
);
|
|
2387
3291
|
const [protocol, , host, , database] = databaseURL.split("/");
|
|
2388
|
-
const
|
|
2389
|
-
|
|
3292
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
|
3293
|
+
if (!urlParts)
|
|
3294
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
|
3295
|
+
const { workspace, region } = urlParts;
|
|
2390
3296
|
try {
|
|
2391
3297
|
return await getBranchDetails({
|
|
2392
3298
|
apiKey,
|
|
2393
3299
|
apiUrl: databaseURL,
|
|
2394
3300
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
|
2395
3301
|
workspacesApiUrl: `${protocol}//${host}`,
|
|
2396
|
-
pathParams: { dbBranchName
|
|
3302
|
+
pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
|
|
2397
3303
|
trace: defaultTrace
|
|
2398
3304
|
});
|
|
2399
3305
|
} catch (err) {
|
|
@@ -2451,8 +3357,10 @@ const buildClient = (plugins) => {
|
|
|
2451
3357
|
};
|
|
2452
3358
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
|
2453
3359
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
|
3360
|
+
const transactions = new TransactionPlugin().build(pluginOptions);
|
|
2454
3361
|
this.db = db;
|
|
2455
3362
|
this.search = search;
|
|
3363
|
+
this.transactions = transactions;
|
|
2456
3364
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
|
2457
3365
|
if (namespace === void 0)
|
|
2458
3366
|
continue;
|
|
@@ -2472,20 +3380,41 @@ const buildClient = (plugins) => {
|
|
|
2472
3380
|
return { databaseURL, branch };
|
|
2473
3381
|
}
|
|
2474
3382
|
}, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
|
3383
|
+
const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
|
|
3384
|
+
const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
|
|
3385
|
+
if (isBrowser && !enableBrowser) {
|
|
3386
|
+
throw new Error(
|
|
3387
|
+
"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."
|
|
3388
|
+
);
|
|
3389
|
+
}
|
|
2475
3390
|
const fetch = getFetchImplementation(options?.fetch);
|
|
2476
3391
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
2477
3392
|
const apiKey = options?.apiKey || getAPIKey();
|
|
2478
3393
|
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
|
2479
3394
|
const trace = options?.trace ?? defaultTrace;
|
|
2480
|
-
const
|
|
3395
|
+
const clientName = options?.clientName;
|
|
3396
|
+
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({
|
|
3397
|
+
apiKey,
|
|
3398
|
+
databaseURL,
|
|
3399
|
+
fetchImpl: options?.fetch,
|
|
3400
|
+
clientName: options?.clientName
|
|
3401
|
+
});
|
|
2481
3402
|
if (!apiKey) {
|
|
2482
3403
|
throw new Error("Option apiKey is required");
|
|
2483
3404
|
}
|
|
2484
3405
|
if (!databaseURL) {
|
|
2485
3406
|
throw new Error("Option databaseURL is required");
|
|
2486
3407
|
}
|
|
2487
|
-
return { fetch, databaseURL, apiKey, branch, cache, trace };
|
|
2488
|
-
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
|
|
3408
|
+
return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser, clientName };
|
|
3409
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
|
|
3410
|
+
fetch,
|
|
3411
|
+
apiKey,
|
|
3412
|
+
databaseURL,
|
|
3413
|
+
branch,
|
|
3414
|
+
trace,
|
|
3415
|
+
clientID,
|
|
3416
|
+
clientName
|
|
3417
|
+
}) {
|
|
2489
3418
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
|
2490
3419
|
if (!branchValue)
|
|
2491
3420
|
throw new Error("Unable to resolve branch value");
|
|
@@ -2498,7 +3427,9 @@ const buildClient = (plugins) => {
|
|
|
2498
3427
|
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
|
|
2499
3428
|
return databaseURL + newPath;
|
|
2500
3429
|
},
|
|
2501
|
-
trace
|
|
3430
|
+
trace,
|
|
3431
|
+
clientID,
|
|
3432
|
+
clientName
|
|
2502
3433
|
};
|
|
2503
3434
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
|
2504
3435
|
if (__privateGet(this, _branch))
|
|
@@ -2589,7 +3520,7 @@ const deserialize = (json) => {
|
|
|
2589
3520
|
};
|
|
2590
3521
|
|
|
2591
3522
|
function buildWorkerRunner(config) {
|
|
2592
|
-
return function xataWorker(name,
|
|
3523
|
+
return function xataWorker(name, worker) {
|
|
2593
3524
|
return async (...args) => {
|
|
2594
3525
|
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
|
2595
3526
|
const result = await fetch(url, {
|
|
@@ -2610,5 +3541,5 @@ class XataError extends Error {
|
|
|
2610
3541
|
}
|
|
2611
3542
|
}
|
|
2612
3543
|
|
|
2613
|
-
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, applyBranchSchemaEdit, buildClient, buildWorkerRunner, bulkInsertTableRecords,
|
|
3544
|
+
export { BaseClient, FetcherError, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, branchTransaction, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
|
|
2614
3545
|
//# sourceMappingURL=index.mjs.map
|