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