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