@xata.io/client 0.0.0-alpha.vf1f4abe → 0.0.0-alpha.vf20a10c
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 +146 -0
- package/README.md +16 -9
- package/Usage.md +5 -5
- package/dist/index.cjs +1520 -676
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3956 -2144
- package/dist/index.mjs +1516 -658
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -8
- package/rollup.config.mjs +44 -0
- 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
|
+
};
|
174
297
|
|
175
|
-
|
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
|
+
}
|
304
|
+
|
305
|
+
const VERSION = "0.21.6";
|
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,60 +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
394
|
trace,
|
259
|
-
signal
|
395
|
+
signal,
|
396
|
+
clientID,
|
397
|
+
sessionID,
|
398
|
+
clientName,
|
399
|
+
fetchOptions = {}
|
260
400
|
}) {
|
261
|
-
|
401
|
+
pool.setFetch(fetchImpl);
|
402
|
+
return await trace(
|
262
403
|
`${method.toUpperCase()} ${path}`,
|
263
404
|
async ({ setAttributes }) => {
|
264
|
-
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
405
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
265
406
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
266
407
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
267
408
|
setAttributes({
|
268
409
|
[TraceAttributes.HTTP_URL]: url,
|
269
410
|
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
270
411
|
});
|
271
|
-
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,
|
272
429
|
method: method.toUpperCase(),
|
273
430
|
body: body ? JSON.stringify(body) : void 0,
|
274
|
-
headers
|
275
|
-
"Content-Type": "application/json",
|
276
|
-
"User-Agent": `Xata client-ts/${VERSION}`,
|
277
|
-
...headers,
|
278
|
-
...hostHeader(fullUrl),
|
279
|
-
Authorization: `Bearer ${apiKey}`
|
280
|
-
},
|
431
|
+
headers,
|
281
432
|
signal
|
282
433
|
});
|
283
|
-
if (response.status === 204) {
|
284
|
-
return {};
|
285
|
-
}
|
286
434
|
const { host, protocol } = parseUrl(response.url);
|
287
435
|
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
288
436
|
setAttributes({
|
@@ -292,6 +440,12 @@ async function fetch$1({
|
|
292
440
|
[TraceAttributes.HTTP_HOST]: host,
|
293
441
|
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
294
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
|
+
}
|
295
449
|
try {
|
296
450
|
const jsonResponse = await response.json();
|
297
451
|
if (response.ok) {
|
@@ -314,384 +468,345 @@ function parseUrl(url) {
|
|
314
468
|
}
|
315
469
|
}
|
316
470
|
|
317
|
-
const
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
...variables,
|
322
|
-
signal
|
323
|
-
});
|
324
|
-
const deleteUser = (variables, signal) => fetch$1({ url: "/user", method: "delete", ...variables, signal });
|
325
|
-
const getUserAPIKeys = (variables, signal) => fetch$1({
|
326
|
-
url: "/user/keys",
|
471
|
+
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
472
|
+
|
473
|
+
const getBranchList = (variables, signal) => dataPlaneFetch({
|
474
|
+
url: "/dbs/{dbName}",
|
327
475
|
method: "get",
|
328
476
|
...variables,
|
329
477
|
signal
|
330
478
|
});
|
331
|
-
const
|
332
|
-
url: "/
|
333
|
-
method: "
|
479
|
+
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
480
|
+
url: "/db/{dbBranchName}",
|
481
|
+
method: "get",
|
334
482
|
...variables,
|
335
483
|
signal
|
336
484
|
});
|
337
|
-
const
|
338
|
-
|
485
|
+
const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
|
486
|
+
const deleteBranch = (variables, signal) => dataPlaneFetch({
|
487
|
+
url: "/db/{dbBranchName}",
|
339
488
|
method: "delete",
|
340
489
|
...variables,
|
341
490
|
signal
|
342
491
|
});
|
343
|
-
const
|
344
|
-
url: "/
|
345
|
-
method: "
|
492
|
+
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
493
|
+
url: "/db/{dbBranchName}/metadata",
|
494
|
+
method: "put",
|
346
495
|
...variables,
|
347
496
|
signal
|
348
497
|
});
|
349
|
-
const
|
350
|
-
url: "/
|
498
|
+
const getBranchMetadata = (variables, signal) => dataPlaneFetch({
|
499
|
+
url: "/db/{dbBranchName}/metadata",
|
351
500
|
method: "get",
|
352
501
|
...variables,
|
353
502
|
signal
|
354
503
|
});
|
355
|
-
const
|
356
|
-
url: "/
|
504
|
+
const getBranchStats = (variables, signal) => dataPlaneFetch({
|
505
|
+
url: "/db/{dbBranchName}/stats",
|
357
506
|
method: "get",
|
358
507
|
...variables,
|
359
508
|
signal
|
360
509
|
});
|
361
|
-
const
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
});
|
367
|
-
const
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
});
|
373
|
-
const getWorkspaceMembersList = (variables, signal) => fetch$1({
|
374
|
-
url: "/workspaces/{workspaceId}/members",
|
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}",
|
375
521
|
method: "get",
|
376
522
|
...variables,
|
377
523
|
signal
|
378
524
|
});
|
379
|
-
const
|
380
|
-
const
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
});
|
386
|
-
const inviteWorkspaceMember = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
|
387
|
-
const updateWorkspaceMemberInvite = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
|
388
|
-
const cancelWorkspaceMemberInvite = (variables, signal) => fetch$1({
|
389
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
390
|
-
method: "delete",
|
391
|
-
...variables,
|
392
|
-
signal
|
393
|
-
});
|
394
|
-
const resendWorkspaceMemberInvite = (variables, signal) => fetch$1({
|
395
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
|
396
|
-
method: "post",
|
397
|
-
...variables,
|
398
|
-
signal
|
399
|
-
});
|
400
|
-
const acceptWorkspaceMemberInvite = (variables, signal) => fetch$1({
|
401
|
-
url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
|
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",
|
402
531
|
method: "post",
|
403
532
|
...variables,
|
404
533
|
signal
|
405
534
|
});
|
406
|
-
const
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
});
|
412
|
-
const
|
413
|
-
url: "/
|
414
|
-
method: "get",
|
415
|
-
...variables,
|
416
|
-
signal
|
417
|
-
});
|
418
|
-
const createDatabase = (variables, signal) => fetch$1({
|
419
|
-
url: "/dbs/{dbName}",
|
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({
|
542
|
+
url: "/db/{dbBranchName}/tables/{tableName}",
|
420
543
|
method: "put",
|
421
544
|
...variables,
|
422
545
|
signal
|
423
546
|
});
|
424
|
-
const
|
425
|
-
url: "/
|
547
|
+
const deleteTable = (variables, signal) => dataPlaneFetch({
|
548
|
+
url: "/db/{dbBranchName}/tables/{tableName}",
|
426
549
|
method: "delete",
|
427
550
|
...variables,
|
428
551
|
signal
|
429
552
|
});
|
430
|
-
const
|
431
|
-
|
553
|
+
const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
|
554
|
+
const getTableSchema = (variables, signal) => dataPlaneFetch({
|
555
|
+
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
432
556
|
method: "get",
|
433
557
|
...variables,
|
434
558
|
signal
|
435
559
|
});
|
436
|
-
const
|
437
|
-
const
|
438
|
-
|
439
|
-
const removeGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
|
440
|
-
const resolveBranch = (variables, signal) => fetch$1({
|
441
|
-
url: "/dbs/{dbName}/resolveBranch",
|
560
|
+
const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
|
561
|
+
const getTableColumns = (variables, signal) => dataPlaneFetch({
|
562
|
+
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
442
563
|
method: "get",
|
443
564
|
...variables,
|
444
565
|
signal
|
445
566
|
});
|
446
|
-
const
|
447
|
-
|
448
|
-
|
449
|
-
|
567
|
+
const addTableColumn = (variables, signal) => dataPlaneFetch(
|
568
|
+
{ url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
|
569
|
+
);
|
570
|
+
const getColumn = (variables, signal) => dataPlaneFetch({
|
571
|
+
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
450
572
|
method: "get",
|
451
573
|
...variables,
|
452
574
|
signal
|
453
575
|
});
|
454
|
-
const
|
455
|
-
const
|
456
|
-
|
457
|
-
|
458
|
-
const mergeMigrationRequest = (variables, signal) => fetch$1({
|
459
|
-
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
460
|
-
method: "post",
|
576
|
+
const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
|
577
|
+
const deleteColumn = (variables, signal) => dataPlaneFetch({
|
578
|
+
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
579
|
+
method: "delete",
|
461
580
|
...variables,
|
462
581
|
signal
|
463
582
|
});
|
464
|
-
const
|
465
|
-
|
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({
|
586
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
466
587
|
method: "get",
|
467
588
|
...variables,
|
468
589
|
signal
|
469
590
|
});
|
470
|
-
const
|
471
|
-
const
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
}
|
477
|
-
|
478
|
-
url: "/db/{dbBranchName}/metadata",
|
479
|
-
method: "put",
|
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({
|
597
|
+
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
598
|
+
method: "post",
|
480
599
|
...variables,
|
481
600
|
signal
|
482
601
|
});
|
483
|
-
const
|
484
|
-
url: "/db/{dbBranchName}/
|
485
|
-
method: "
|
602
|
+
const searchBranch = (variables, signal) => dataPlaneFetch({
|
603
|
+
url: "/db/{dbBranchName}/search",
|
604
|
+
method: "post",
|
486
605
|
...variables,
|
487
606
|
signal
|
488
607
|
});
|
489
|
-
const
|
490
|
-
|
491
|
-
const getBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
492
|
-
const compareBranchWithUserSchema = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
|
493
|
-
const compareBranchSchemas = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
|
494
|
-
const updateBranchSchema = (variables, signal) => fetch$1({
|
495
|
-
url: "/db/{dbBranchName}/schema/update",
|
608
|
+
const searchTable = (variables, signal) => dataPlaneFetch({
|
609
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
496
610
|
method: "post",
|
497
611
|
...variables,
|
498
612
|
signal
|
499
613
|
});
|
500
|
-
const
|
501
|
-
const
|
502
|
-
const
|
503
|
-
|
504
|
-
|
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 = {
|
617
|
+
branch: {
|
618
|
+
getBranchList,
|
619
|
+
getBranchDetails,
|
620
|
+
createBranch,
|
621
|
+
deleteBranch,
|
622
|
+
updateBranchMetadata,
|
623
|
+
getBranchMetadata,
|
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
|
640
|
+
},
|
641
|
+
migrationRequests: {
|
642
|
+
queryMigrationRequests,
|
643
|
+
createMigrationRequest,
|
644
|
+
getMigrationRequest,
|
645
|
+
updateMigrationRequest,
|
646
|
+
listMigrationRequestsCommits,
|
647
|
+
compareMigrationRequest,
|
648
|
+
getMigrationRequestIsMerged,
|
649
|
+
mergeMigrationRequest
|
650
|
+
},
|
651
|
+
table: {
|
652
|
+
createTable,
|
653
|
+
deleteTable,
|
654
|
+
updateTable,
|
655
|
+
getTableSchema,
|
656
|
+
setTableSchema,
|
657
|
+
getTableColumns,
|
658
|
+
addTableColumn,
|
659
|
+
getColumn,
|
660
|
+
updateColumn,
|
661
|
+
deleteColumn
|
662
|
+
},
|
663
|
+
records: {
|
664
|
+
branchTransaction,
|
665
|
+
insertRecord,
|
666
|
+
getRecord,
|
667
|
+
insertRecordWithID,
|
668
|
+
updateRecordWithID,
|
669
|
+
upsertRecordWithID,
|
670
|
+
deleteRecord,
|
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",
|
505
680
|
method: "get",
|
506
681
|
...variables,
|
507
682
|
signal
|
508
683
|
});
|
509
|
-
const
|
510
|
-
url: "/
|
684
|
+
const updateUser = (variables, signal) => controlPlaneFetch({
|
685
|
+
url: "/user",
|
511
686
|
method: "put",
|
512
687
|
...variables,
|
513
688
|
signal
|
514
689
|
});
|
515
|
-
const
|
516
|
-
url: "/
|
690
|
+
const deleteUser = (variables, signal) => controlPlaneFetch({
|
691
|
+
url: "/user",
|
517
692
|
method: "delete",
|
518
693
|
...variables,
|
519
694
|
signal
|
520
695
|
});
|
521
|
-
const
|
522
|
-
url: "/
|
523
|
-
method: "
|
696
|
+
const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
|
697
|
+
url: "/user/keys",
|
698
|
+
method: "get",
|
524
699
|
...variables,
|
525
700
|
signal
|
526
701
|
});
|
527
|
-
const
|
528
|
-
url: "/
|
529
|
-
method: "
|
702
|
+
const createUserAPIKey = (variables, signal) => controlPlaneFetch({
|
703
|
+
url: "/user/keys/{keyName}",
|
704
|
+
method: "post",
|
530
705
|
...variables,
|
531
706
|
signal
|
532
707
|
});
|
533
|
-
const
|
534
|
-
url: "/
|
535
|
-
method: "
|
708
|
+
const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
709
|
+
url: "/user/keys/{keyName}",
|
710
|
+
method: "delete",
|
536
711
|
...variables,
|
537
712
|
signal
|
538
713
|
});
|
539
|
-
const
|
540
|
-
url: "/
|
714
|
+
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
715
|
+
url: "/workspaces",
|
541
716
|
method: "get",
|
542
717
|
...variables,
|
543
718
|
signal
|
544
719
|
});
|
545
|
-
const
|
546
|
-
url: "/
|
720
|
+
const createWorkspace = (variables, signal) => controlPlaneFetch({
|
721
|
+
url: "/workspaces",
|
547
722
|
method: "post",
|
548
723
|
...variables,
|
549
724
|
signal
|
550
725
|
});
|
551
|
-
const
|
552
|
-
url: "/
|
726
|
+
const getWorkspace = (variables, signal) => controlPlaneFetch({
|
727
|
+
url: "/workspaces/{workspaceId}",
|
553
728
|
method: "get",
|
554
729
|
...variables,
|
555
730
|
signal
|
556
731
|
});
|
557
|
-
const
|
558
|
-
url: "/
|
559
|
-
method: "
|
732
|
+
const updateWorkspace = (variables, signal) => controlPlaneFetch({
|
733
|
+
url: "/workspaces/{workspaceId}",
|
734
|
+
method: "put",
|
560
735
|
...variables,
|
561
736
|
signal
|
562
737
|
});
|
563
|
-
const
|
564
|
-
url: "/
|
565
|
-
method: "
|
738
|
+
const deleteWorkspace = (variables, signal) => controlPlaneFetch({
|
739
|
+
url: "/workspaces/{workspaceId}",
|
740
|
+
method: "delete",
|
566
741
|
...variables,
|
567
742
|
signal
|
568
743
|
});
|
569
|
-
const
|
570
|
-
const
|
571
|
-
const
|
572
|
-
|
573
|
-
const deleteRecord = (variables, signal) => fetch$1({
|
574
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
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}",
|
575
748
|
method: "delete",
|
576
749
|
...variables,
|
577
750
|
signal
|
578
751
|
});
|
579
|
-
const
|
580
|
-
|
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",
|
581
759
|
method: "get",
|
582
760
|
...variables,
|
583
761
|
signal
|
584
762
|
});
|
585
|
-
const
|
586
|
-
const
|
587
|
-
url: "/
|
588
|
-
method: "
|
589
|
-
...variables,
|
590
|
-
signal
|
591
|
-
});
|
592
|
-
const searchTable = (variables, signal) => fetch$1({
|
593
|
-
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
594
|
-
method: "post",
|
595
|
-
...variables,
|
596
|
-
signal
|
597
|
-
});
|
598
|
-
const searchBranch = (variables, signal) => fetch$1({
|
599
|
-
url: "/db/{dbBranchName}/search",
|
600
|
-
method: "post",
|
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",
|
601
767
|
...variables,
|
602
768
|
signal
|
603
769
|
});
|
604
|
-
const
|
605
|
-
|
606
|
-
|
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 listRegions = (variables, signal) => controlPlaneFetch({
|
773
|
+
url: "/workspaces/{workspaceId}/regions",
|
774
|
+
method: "get",
|
607
775
|
...variables,
|
608
776
|
signal
|
609
777
|
});
|
610
|
-
const operationsByTag = {
|
611
|
-
users: { getUser, updateUser, deleteUser
|
778
|
+
const operationsByTag$1 = {
|
779
|
+
users: { getUser, updateUser, deleteUser },
|
780
|
+
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
612
781
|
workspaces: {
|
613
|
-
createWorkspace,
|
614
782
|
getWorkspacesList,
|
783
|
+
createWorkspace,
|
615
784
|
getWorkspace,
|
616
785
|
updateWorkspace,
|
617
786
|
deleteWorkspace,
|
618
787
|
getWorkspaceMembersList,
|
619
788
|
updateWorkspaceMemberRole,
|
620
|
-
removeWorkspaceMember
|
789
|
+
removeWorkspaceMember
|
790
|
+
},
|
791
|
+
invites: {
|
621
792
|
inviteWorkspaceMember,
|
622
793
|
updateWorkspaceMemberInvite,
|
623
794
|
cancelWorkspaceMemberInvite,
|
624
|
-
|
625
|
-
|
795
|
+
acceptWorkspaceMemberInvite,
|
796
|
+
resendWorkspaceMemberInvite
|
626
797
|
},
|
627
|
-
|
798
|
+
databases: {
|
628
799
|
getDatabaseList,
|
629
800
|
createDatabase,
|
630
801
|
deleteDatabase,
|
631
802
|
getDatabaseMetadata,
|
632
803
|
updateDatabaseMetadata,
|
633
|
-
|
634
|
-
addGitBranchesEntry,
|
635
|
-
removeGitBranchesEntry,
|
636
|
-
resolveBranch
|
637
|
-
},
|
638
|
-
branch: {
|
639
|
-
getBranchList,
|
640
|
-
getBranchDetails,
|
641
|
-
createBranch,
|
642
|
-
deleteBranch,
|
643
|
-
updateBranchMetadata,
|
644
|
-
getBranchMetadata,
|
645
|
-
getBranchStats
|
646
|
-
},
|
647
|
-
migrationRequests: {
|
648
|
-
queryMigrationRequests,
|
649
|
-
createMigrationRequest,
|
650
|
-
getMigrationRequest,
|
651
|
-
updateMigrationRequest,
|
652
|
-
listMigrationRequestsCommits,
|
653
|
-
compareMigrationRequest,
|
654
|
-
getMigrationRequestIsMerged,
|
655
|
-
mergeMigrationRequest
|
656
|
-
},
|
657
|
-
branchSchema: {
|
658
|
-
getBranchMigrationHistory,
|
659
|
-
executeBranchMigrationPlan,
|
660
|
-
getBranchMigrationPlan,
|
661
|
-
compareBranchWithUserSchema,
|
662
|
-
compareBranchSchemas,
|
663
|
-
updateBranchSchema,
|
664
|
-
previewBranchSchemaEdit,
|
665
|
-
applyBranchSchemaEdit,
|
666
|
-
getBranchSchemaHistory
|
667
|
-
},
|
668
|
-
table: {
|
669
|
-
createTable,
|
670
|
-
deleteTable,
|
671
|
-
updateTable,
|
672
|
-
getTableSchema,
|
673
|
-
setTableSchema,
|
674
|
-
getTableColumns,
|
675
|
-
addTableColumn,
|
676
|
-
getColumn,
|
677
|
-
deleteColumn,
|
678
|
-
updateColumn
|
679
|
-
},
|
680
|
-
records: {
|
681
|
-
insertRecord,
|
682
|
-
insertRecordWithID,
|
683
|
-
updateRecordWithID,
|
684
|
-
upsertRecordWithID,
|
685
|
-
deleteRecord,
|
686
|
-
getRecord,
|
687
|
-
bulkInsertTableRecords,
|
688
|
-
queryTable,
|
689
|
-
searchTable,
|
690
|
-
searchBranch,
|
691
|
-
summarizeTable
|
804
|
+
listRegions
|
692
805
|
}
|
693
806
|
};
|
694
807
|
|
808
|
+
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
809
|
+
|
695
810
|
function getHostUrl(provider, type) {
|
696
811
|
if (isHostProviderAlias(provider)) {
|
697
812
|
return providers[provider][type];
|
@@ -703,11 +818,11 @@ function getHostUrl(provider, type) {
|
|
703
818
|
const providers = {
|
704
819
|
production: {
|
705
820
|
main: "https://api.xata.io",
|
706
|
-
workspaces: "https://{workspaceId}.xata.sh"
|
821
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
707
822
|
},
|
708
823
|
staging: {
|
709
824
|
main: "https://staging.xatabase.co",
|
710
|
-
workspaces: "https://{workspaceId}.staging.xatabase.co"
|
825
|
+
workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
|
711
826
|
}
|
712
827
|
};
|
713
828
|
function isHostProviderAlias(alias) {
|
@@ -725,6 +840,16 @@ function parseProviderString(provider = "production") {
|
|
725
840
|
return null;
|
726
841
|
return { main, workspaces };
|
727
842
|
}
|
843
|
+
function parseWorkspacesUrlParts(url) {
|
844
|
+
if (!isString(url))
|
845
|
+
return null;
|
846
|
+
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
847
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))\.xatabase\.co.*/;
|
848
|
+
const match = url.match(regex) || url.match(regexStaging);
|
849
|
+
if (!match)
|
850
|
+
return null;
|
851
|
+
return { workspace: match[1], region: match[2] };
|
852
|
+
}
|
728
853
|
|
729
854
|
var __accessCheck$7 = (obj, member, msg) => {
|
730
855
|
if (!member.has(obj))
|
@@ -752,6 +877,7 @@ class XataApiClient {
|
|
752
877
|
const provider = options.host ?? "production";
|
753
878
|
const apiKey = options.apiKey ?? getAPIKey();
|
754
879
|
const trace = options.trace ?? defaultTrace;
|
880
|
+
const clientID = generateUUID();
|
755
881
|
if (!apiKey) {
|
756
882
|
throw new Error("Could not resolve a valid apiKey");
|
757
883
|
}
|
@@ -760,7 +886,9 @@ class XataApiClient {
|
|
760
886
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
761
887
|
fetchImpl: getFetchImplementation(options.fetch),
|
762
888
|
apiKey,
|
763
|
-
trace
|
889
|
+
trace,
|
890
|
+
clientName: options.clientName,
|
891
|
+
clientID
|
764
892
|
});
|
765
893
|
}
|
766
894
|
get user() {
|
@@ -768,21 +896,41 @@ class XataApiClient {
|
|
768
896
|
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
769
897
|
return __privateGet$7(this, _namespaces).user;
|
770
898
|
}
|
899
|
+
get authentication() {
|
900
|
+
if (!__privateGet$7(this, _namespaces).authentication)
|
901
|
+
__privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
|
902
|
+
return __privateGet$7(this, _namespaces).authentication;
|
903
|
+
}
|
771
904
|
get workspaces() {
|
772
905
|
if (!__privateGet$7(this, _namespaces).workspaces)
|
773
906
|
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
774
907
|
return __privateGet$7(this, _namespaces).workspaces;
|
775
908
|
}
|
776
|
-
get
|
777
|
-
if (!__privateGet$7(this, _namespaces).
|
778
|
-
__privateGet$7(this, _namespaces).
|
779
|
-
return __privateGet$7(this, _namespaces).
|
909
|
+
get invites() {
|
910
|
+
if (!__privateGet$7(this, _namespaces).invites)
|
911
|
+
__privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
|
912
|
+
return __privateGet$7(this, _namespaces).invites;
|
913
|
+
}
|
914
|
+
get database() {
|
915
|
+
if (!__privateGet$7(this, _namespaces).database)
|
916
|
+
__privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
|
917
|
+
return __privateGet$7(this, _namespaces).database;
|
780
918
|
}
|
781
919
|
get branches() {
|
782
920
|
if (!__privateGet$7(this, _namespaces).branches)
|
783
921
|
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
784
922
|
return __privateGet$7(this, _namespaces).branches;
|
785
923
|
}
|
924
|
+
get migrations() {
|
925
|
+
if (!__privateGet$7(this, _namespaces).migrations)
|
926
|
+
__privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
|
927
|
+
return __privateGet$7(this, _namespaces).migrations;
|
928
|
+
}
|
929
|
+
get migrationRequests() {
|
930
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
931
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
932
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
933
|
+
}
|
786
934
|
get tables() {
|
787
935
|
if (!__privateGet$7(this, _namespaces).tables)
|
788
936
|
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
@@ -793,15 +941,10 @@ class XataApiClient {
|
|
793
941
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
794
942
|
return __privateGet$7(this, _namespaces).records;
|
795
943
|
}
|
796
|
-
get
|
797
|
-
if (!__privateGet$7(this, _namespaces).
|
798
|
-
__privateGet$7(this, _namespaces).
|
799
|
-
return __privateGet$7(this, _namespaces).
|
800
|
-
}
|
801
|
-
get branchSchema() {
|
802
|
-
if (!__privateGet$7(this, _namespaces).branchSchema)
|
803
|
-
__privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
|
804
|
-
return __privateGet$7(this, _namespaces).branchSchema;
|
944
|
+
get searchAndFilter() {
|
945
|
+
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
946
|
+
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
947
|
+
return __privateGet$7(this, _namespaces).searchAndFilter;
|
805
948
|
}
|
806
949
|
}
|
807
950
|
_extraProps = new WeakMap();
|
@@ -813,24 +956,29 @@ class UserApi {
|
|
813
956
|
getUser() {
|
814
957
|
return operationsByTag.users.getUser({ ...this.extraProps });
|
815
958
|
}
|
816
|
-
updateUser(user) {
|
959
|
+
updateUser({ user }) {
|
817
960
|
return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
|
818
961
|
}
|
819
962
|
deleteUser() {
|
820
963
|
return operationsByTag.users.deleteUser({ ...this.extraProps });
|
821
964
|
}
|
965
|
+
}
|
966
|
+
class AuthenticationApi {
|
967
|
+
constructor(extraProps) {
|
968
|
+
this.extraProps = extraProps;
|
969
|
+
}
|
822
970
|
getUserAPIKeys() {
|
823
|
-
return operationsByTag.
|
971
|
+
return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
|
824
972
|
}
|
825
|
-
createUserAPIKey(
|
826
|
-
return operationsByTag.
|
827
|
-
pathParams: { keyName },
|
973
|
+
createUserAPIKey({ name }) {
|
974
|
+
return operationsByTag.authentication.createUserAPIKey({
|
975
|
+
pathParams: { keyName: name },
|
828
976
|
...this.extraProps
|
829
977
|
});
|
830
978
|
}
|
831
|
-
deleteUserAPIKey(
|
832
|
-
return operationsByTag.
|
833
|
-
pathParams: { keyName },
|
979
|
+
deleteUserAPIKey({ name }) {
|
980
|
+
return operationsByTag.authentication.deleteUserAPIKey({
|
981
|
+
pathParams: { keyName: name },
|
834
982
|
...this.extraProps
|
835
983
|
});
|
836
984
|
}
|
@@ -839,196 +987,248 @@ class WorkspaceApi {
|
|
839
987
|
constructor(extraProps) {
|
840
988
|
this.extraProps = extraProps;
|
841
989
|
}
|
842
|
-
|
990
|
+
getWorkspacesList() {
|
991
|
+
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
992
|
+
}
|
993
|
+
createWorkspace({ data }) {
|
843
994
|
return operationsByTag.workspaces.createWorkspace({
|
844
|
-
body:
|
995
|
+
body: data,
|
845
996
|
...this.extraProps
|
846
997
|
});
|
847
998
|
}
|
848
|
-
|
849
|
-
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
850
|
-
}
|
851
|
-
getWorkspace(workspaceId) {
|
999
|
+
getWorkspace({ workspace }) {
|
852
1000
|
return operationsByTag.workspaces.getWorkspace({
|
853
|
-
pathParams: { workspaceId },
|
1001
|
+
pathParams: { workspaceId: workspace },
|
854
1002
|
...this.extraProps
|
855
1003
|
});
|
856
1004
|
}
|
857
|
-
updateWorkspace(
|
1005
|
+
updateWorkspace({
|
1006
|
+
workspace,
|
1007
|
+
update
|
1008
|
+
}) {
|
858
1009
|
return operationsByTag.workspaces.updateWorkspace({
|
859
|
-
pathParams: { workspaceId },
|
860
|
-
body:
|
1010
|
+
pathParams: { workspaceId: workspace },
|
1011
|
+
body: update,
|
861
1012
|
...this.extraProps
|
862
1013
|
});
|
863
1014
|
}
|
864
|
-
deleteWorkspace(
|
1015
|
+
deleteWorkspace({ workspace }) {
|
865
1016
|
return operationsByTag.workspaces.deleteWorkspace({
|
866
|
-
pathParams: { workspaceId },
|
1017
|
+
pathParams: { workspaceId: workspace },
|
867
1018
|
...this.extraProps
|
868
1019
|
});
|
869
1020
|
}
|
870
|
-
getWorkspaceMembersList(
|
1021
|
+
getWorkspaceMembersList({ workspace }) {
|
871
1022
|
return operationsByTag.workspaces.getWorkspaceMembersList({
|
872
|
-
pathParams: { workspaceId },
|
1023
|
+
pathParams: { workspaceId: workspace },
|
873
1024
|
...this.extraProps
|
874
1025
|
});
|
875
1026
|
}
|
876
|
-
updateWorkspaceMemberRole(
|
1027
|
+
updateWorkspaceMemberRole({
|
1028
|
+
workspace,
|
1029
|
+
user,
|
1030
|
+
role
|
1031
|
+
}) {
|
877
1032
|
return operationsByTag.workspaces.updateWorkspaceMemberRole({
|
878
|
-
pathParams: { workspaceId, userId },
|
1033
|
+
pathParams: { workspaceId: workspace, userId: user },
|
879
1034
|
body: { role },
|
880
1035
|
...this.extraProps
|
881
1036
|
});
|
882
1037
|
}
|
883
|
-
removeWorkspaceMember(
|
1038
|
+
removeWorkspaceMember({
|
1039
|
+
workspace,
|
1040
|
+
user
|
1041
|
+
}) {
|
884
1042
|
return operationsByTag.workspaces.removeWorkspaceMember({
|
885
|
-
pathParams: { workspaceId, userId },
|
1043
|
+
pathParams: { workspaceId: workspace, userId: user },
|
886
1044
|
...this.extraProps
|
887
1045
|
});
|
888
1046
|
}
|
889
|
-
|
890
|
-
|
891
|
-
|
1047
|
+
}
|
1048
|
+
class InvitesApi {
|
1049
|
+
constructor(extraProps) {
|
1050
|
+
this.extraProps = extraProps;
|
1051
|
+
}
|
1052
|
+
inviteWorkspaceMember({
|
1053
|
+
workspace,
|
1054
|
+
email,
|
1055
|
+
role
|
1056
|
+
}) {
|
1057
|
+
return operationsByTag.invites.inviteWorkspaceMember({
|
1058
|
+
pathParams: { workspaceId: workspace },
|
892
1059
|
body: { email, role },
|
893
1060
|
...this.extraProps
|
894
1061
|
});
|
895
1062
|
}
|
896
|
-
updateWorkspaceMemberInvite(
|
897
|
-
|
898
|
-
|
1063
|
+
updateWorkspaceMemberInvite({
|
1064
|
+
workspace,
|
1065
|
+
invite,
|
1066
|
+
role
|
1067
|
+
}) {
|
1068
|
+
return operationsByTag.invites.updateWorkspaceMemberInvite({
|
1069
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
899
1070
|
body: { role },
|
900
1071
|
...this.extraProps
|
901
1072
|
});
|
902
1073
|
}
|
903
|
-
cancelWorkspaceMemberInvite(
|
904
|
-
|
905
|
-
|
1074
|
+
cancelWorkspaceMemberInvite({
|
1075
|
+
workspace,
|
1076
|
+
invite
|
1077
|
+
}) {
|
1078
|
+
return operationsByTag.invites.cancelWorkspaceMemberInvite({
|
1079
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
906
1080
|
...this.extraProps
|
907
1081
|
});
|
908
1082
|
}
|
909
|
-
|
910
|
-
|
911
|
-
|
1083
|
+
acceptWorkspaceMemberInvite({
|
1084
|
+
workspace,
|
1085
|
+
key
|
1086
|
+
}) {
|
1087
|
+
return operationsByTag.invites.acceptWorkspaceMemberInvite({
|
1088
|
+
pathParams: { workspaceId: workspace, inviteKey: key },
|
912
1089
|
...this.extraProps
|
913
1090
|
});
|
914
1091
|
}
|
915
|
-
|
916
|
-
|
917
|
-
|
1092
|
+
resendWorkspaceMemberInvite({
|
1093
|
+
workspace,
|
1094
|
+
invite
|
1095
|
+
}) {
|
1096
|
+
return operationsByTag.invites.resendWorkspaceMemberInvite({
|
1097
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
918
1098
|
...this.extraProps
|
919
1099
|
});
|
920
1100
|
}
|
921
1101
|
}
|
922
|
-
class
|
1102
|
+
class BranchApi {
|
923
1103
|
constructor(extraProps) {
|
924
1104
|
this.extraProps = extraProps;
|
925
1105
|
}
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
return operationsByTag.database.createDatabase({
|
934
|
-
pathParams: { workspace, dbName },
|
935
|
-
body: options,
|
936
|
-
...this.extraProps
|
937
|
-
});
|
938
|
-
}
|
939
|
-
deleteDatabase(workspace, dbName) {
|
940
|
-
return operationsByTag.database.deleteDatabase({
|
941
|
-
pathParams: { workspace, dbName },
|
942
|
-
...this.extraProps
|
943
|
-
});
|
944
|
-
}
|
945
|
-
getDatabaseMetadata(workspace, dbName) {
|
946
|
-
return operationsByTag.database.getDatabaseMetadata({
|
947
|
-
pathParams: { workspace, dbName },
|
948
|
-
...this.extraProps
|
949
|
-
});
|
950
|
-
}
|
951
|
-
updateDatabaseMetadata(workspace, dbName, options = {}) {
|
952
|
-
return operationsByTag.database.updateDatabaseMetadata({
|
953
|
-
pathParams: { workspace, dbName },
|
954
|
-
body: options,
|
955
|
-
...this.extraProps
|
956
|
-
});
|
957
|
-
}
|
958
|
-
getGitBranchesMapping(workspace, dbName) {
|
959
|
-
return operationsByTag.database.getGitBranchesMapping({
|
960
|
-
pathParams: { workspace, dbName },
|
1106
|
+
getBranchList({
|
1107
|
+
workspace,
|
1108
|
+
region,
|
1109
|
+
database
|
1110
|
+
}) {
|
1111
|
+
return operationsByTag.branch.getBranchList({
|
1112
|
+
pathParams: { workspace, region, dbName: database },
|
961
1113
|
...this.extraProps
|
962
1114
|
});
|
963
1115
|
}
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
1116
|
+
getBranchDetails({
|
1117
|
+
workspace,
|
1118
|
+
region,
|
1119
|
+
database,
|
1120
|
+
branch
|
1121
|
+
}) {
|
1122
|
+
return operationsByTag.branch.getBranchDetails({
|
1123
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
968
1124
|
...this.extraProps
|
969
1125
|
});
|
970
1126
|
}
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
1127
|
+
createBranch({
|
1128
|
+
workspace,
|
1129
|
+
region,
|
1130
|
+
database,
|
1131
|
+
branch,
|
1132
|
+
from,
|
1133
|
+
metadata
|
1134
|
+
}) {
|
1135
|
+
return operationsByTag.branch.createBranch({
|
1136
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1137
|
+
body: { from, metadata },
|
975
1138
|
...this.extraProps
|
976
1139
|
});
|
977
1140
|
}
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
1141
|
+
deleteBranch({
|
1142
|
+
workspace,
|
1143
|
+
region,
|
1144
|
+
database,
|
1145
|
+
branch
|
1146
|
+
}) {
|
1147
|
+
return operationsByTag.branch.deleteBranch({
|
1148
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
982
1149
|
...this.extraProps
|
983
1150
|
});
|
984
1151
|
}
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
1152
|
+
updateBranchMetadata({
|
1153
|
+
workspace,
|
1154
|
+
region,
|
1155
|
+
database,
|
1156
|
+
branch,
|
1157
|
+
metadata
|
1158
|
+
}) {
|
1159
|
+
return operationsByTag.branch.updateBranchMetadata({
|
1160
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1161
|
+
body: metadata,
|
993
1162
|
...this.extraProps
|
994
1163
|
});
|
995
1164
|
}
|
996
|
-
|
997
|
-
|
998
|
-
|
1165
|
+
getBranchMetadata({
|
1166
|
+
workspace,
|
1167
|
+
region,
|
1168
|
+
database,
|
1169
|
+
branch
|
1170
|
+
}) {
|
1171
|
+
return operationsByTag.branch.getBranchMetadata({
|
1172
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
999
1173
|
...this.extraProps
|
1000
1174
|
});
|
1001
1175
|
}
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1176
|
+
getBranchStats({
|
1177
|
+
workspace,
|
1178
|
+
region,
|
1179
|
+
database,
|
1180
|
+
branch
|
1181
|
+
}) {
|
1182
|
+
return operationsByTag.branch.getBranchStats({
|
1183
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1007
1184
|
...this.extraProps
|
1008
1185
|
});
|
1009
1186
|
}
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1187
|
+
getGitBranchesMapping({
|
1188
|
+
workspace,
|
1189
|
+
region,
|
1190
|
+
database
|
1191
|
+
}) {
|
1192
|
+
return operationsByTag.branch.getGitBranchesMapping({
|
1193
|
+
pathParams: { workspace, region, dbName: database },
|
1013
1194
|
...this.extraProps
|
1014
1195
|
});
|
1015
1196
|
}
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1197
|
+
addGitBranchesEntry({
|
1198
|
+
workspace,
|
1199
|
+
region,
|
1200
|
+
database,
|
1201
|
+
gitBranch,
|
1202
|
+
xataBranch
|
1203
|
+
}) {
|
1204
|
+
return operationsByTag.branch.addGitBranchesEntry({
|
1205
|
+
pathParams: { workspace, region, dbName: database },
|
1206
|
+
body: { gitBranch, xataBranch },
|
1020
1207
|
...this.extraProps
|
1021
1208
|
});
|
1022
1209
|
}
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1210
|
+
removeGitBranchesEntry({
|
1211
|
+
workspace,
|
1212
|
+
region,
|
1213
|
+
database,
|
1214
|
+
gitBranch
|
1215
|
+
}) {
|
1216
|
+
return operationsByTag.branch.removeGitBranchesEntry({
|
1217
|
+
pathParams: { workspace, region, dbName: database },
|
1218
|
+
queryParams: { gitBranch },
|
1026
1219
|
...this.extraProps
|
1027
1220
|
});
|
1028
1221
|
}
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1222
|
+
resolveBranch({
|
1223
|
+
workspace,
|
1224
|
+
region,
|
1225
|
+
database,
|
1226
|
+
gitBranch,
|
1227
|
+
fallbackBranch
|
1228
|
+
}) {
|
1229
|
+
return operationsByTag.branch.resolveBranch({
|
1230
|
+
pathParams: { workspace, region, dbName: database },
|
1231
|
+
queryParams: { gitBranch, fallbackBranch },
|
1032
1232
|
...this.extraProps
|
1033
1233
|
});
|
1034
1234
|
}
|
@@ -1037,67 +1237,134 @@ class TableApi {
|
|
1037
1237
|
constructor(extraProps) {
|
1038
1238
|
this.extraProps = extraProps;
|
1039
1239
|
}
|
1040
|
-
createTable(
|
1240
|
+
createTable({
|
1241
|
+
workspace,
|
1242
|
+
region,
|
1243
|
+
database,
|
1244
|
+
branch,
|
1245
|
+
table
|
1246
|
+
}) {
|
1041
1247
|
return operationsByTag.table.createTable({
|
1042
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1248
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1043
1249
|
...this.extraProps
|
1044
1250
|
});
|
1045
1251
|
}
|
1046
|
-
deleteTable(
|
1252
|
+
deleteTable({
|
1253
|
+
workspace,
|
1254
|
+
region,
|
1255
|
+
database,
|
1256
|
+
branch,
|
1257
|
+
table
|
1258
|
+
}) {
|
1047
1259
|
return operationsByTag.table.deleteTable({
|
1048
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1260
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1049
1261
|
...this.extraProps
|
1050
1262
|
});
|
1051
1263
|
}
|
1052
|
-
updateTable(
|
1264
|
+
updateTable({
|
1265
|
+
workspace,
|
1266
|
+
region,
|
1267
|
+
database,
|
1268
|
+
branch,
|
1269
|
+
table,
|
1270
|
+
update
|
1271
|
+
}) {
|
1053
1272
|
return operationsByTag.table.updateTable({
|
1054
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1055
|
-
body:
|
1273
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1274
|
+
body: update,
|
1056
1275
|
...this.extraProps
|
1057
1276
|
});
|
1058
1277
|
}
|
1059
|
-
getTableSchema(
|
1278
|
+
getTableSchema({
|
1279
|
+
workspace,
|
1280
|
+
region,
|
1281
|
+
database,
|
1282
|
+
branch,
|
1283
|
+
table
|
1284
|
+
}) {
|
1060
1285
|
return operationsByTag.table.getTableSchema({
|
1061
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1286
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1062
1287
|
...this.extraProps
|
1063
1288
|
});
|
1064
1289
|
}
|
1065
|
-
setTableSchema(
|
1290
|
+
setTableSchema({
|
1291
|
+
workspace,
|
1292
|
+
region,
|
1293
|
+
database,
|
1294
|
+
branch,
|
1295
|
+
table,
|
1296
|
+
schema
|
1297
|
+
}) {
|
1066
1298
|
return operationsByTag.table.setTableSchema({
|
1067
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1068
|
-
body:
|
1299
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1300
|
+
body: schema,
|
1069
1301
|
...this.extraProps
|
1070
1302
|
});
|
1071
1303
|
}
|
1072
|
-
getTableColumns(
|
1304
|
+
getTableColumns({
|
1305
|
+
workspace,
|
1306
|
+
region,
|
1307
|
+
database,
|
1308
|
+
branch,
|
1309
|
+
table
|
1310
|
+
}) {
|
1073
1311
|
return operationsByTag.table.getTableColumns({
|
1074
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1312
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1075
1313
|
...this.extraProps
|
1076
1314
|
});
|
1077
1315
|
}
|
1078
|
-
addTableColumn(
|
1316
|
+
addTableColumn({
|
1317
|
+
workspace,
|
1318
|
+
region,
|
1319
|
+
database,
|
1320
|
+
branch,
|
1321
|
+
table,
|
1322
|
+
column
|
1323
|
+
}) {
|
1079
1324
|
return operationsByTag.table.addTableColumn({
|
1080
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1325
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1081
1326
|
body: column,
|
1082
1327
|
...this.extraProps
|
1083
1328
|
});
|
1084
1329
|
}
|
1085
|
-
getColumn(
|
1330
|
+
getColumn({
|
1331
|
+
workspace,
|
1332
|
+
region,
|
1333
|
+
database,
|
1334
|
+
branch,
|
1335
|
+
table,
|
1336
|
+
column
|
1337
|
+
}) {
|
1086
1338
|
return operationsByTag.table.getColumn({
|
1087
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
|
1339
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1088
1340
|
...this.extraProps
|
1089
1341
|
});
|
1090
1342
|
}
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1343
|
+
updateColumn({
|
1344
|
+
workspace,
|
1345
|
+
region,
|
1346
|
+
database,
|
1347
|
+
branch,
|
1348
|
+
table,
|
1349
|
+
column,
|
1350
|
+
update
|
1351
|
+
}) {
|
1352
|
+
return operationsByTag.table.updateColumn({
|
1353
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1354
|
+
body: update,
|
1094
1355
|
...this.extraProps
|
1095
1356
|
});
|
1096
1357
|
}
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1358
|
+
deleteColumn({
|
1359
|
+
workspace,
|
1360
|
+
region,
|
1361
|
+
database,
|
1362
|
+
branch,
|
1363
|
+
table,
|
1364
|
+
column
|
1365
|
+
}) {
|
1366
|
+
return operationsByTag.table.deleteColumn({
|
1367
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1101
1368
|
...this.extraProps
|
1102
1369
|
});
|
1103
1370
|
}
|
@@ -1106,85 +1373,228 @@ class RecordsApi {
|
|
1106
1373
|
constructor(extraProps) {
|
1107
1374
|
this.extraProps = extraProps;
|
1108
1375
|
}
|
1109
|
-
insertRecord(
|
1376
|
+
insertRecord({
|
1377
|
+
workspace,
|
1378
|
+
region,
|
1379
|
+
database,
|
1380
|
+
branch,
|
1381
|
+
table,
|
1382
|
+
record,
|
1383
|
+
columns
|
1384
|
+
}) {
|
1110
1385
|
return operationsByTag.records.insertRecord({
|
1111
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1112
|
-
queryParams:
|
1386
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1387
|
+
queryParams: { columns },
|
1113
1388
|
body: record,
|
1114
1389
|
...this.extraProps
|
1115
1390
|
});
|
1116
1391
|
}
|
1117
|
-
|
1392
|
+
getRecord({
|
1393
|
+
workspace,
|
1394
|
+
region,
|
1395
|
+
database,
|
1396
|
+
branch,
|
1397
|
+
table,
|
1398
|
+
id,
|
1399
|
+
columns
|
1400
|
+
}) {
|
1401
|
+
return operationsByTag.records.getRecord({
|
1402
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1403
|
+
queryParams: { columns },
|
1404
|
+
...this.extraProps
|
1405
|
+
});
|
1406
|
+
}
|
1407
|
+
insertRecordWithID({
|
1408
|
+
workspace,
|
1409
|
+
region,
|
1410
|
+
database,
|
1411
|
+
branch,
|
1412
|
+
table,
|
1413
|
+
id,
|
1414
|
+
record,
|
1415
|
+
columns,
|
1416
|
+
createOnly,
|
1417
|
+
ifVersion
|
1418
|
+
}) {
|
1118
1419
|
return operationsByTag.records.insertRecordWithID({
|
1119
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1120
|
-
queryParams:
|
1420
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1421
|
+
queryParams: { columns, createOnly, ifVersion },
|
1121
1422
|
body: record,
|
1122
1423
|
...this.extraProps
|
1123
1424
|
});
|
1124
1425
|
}
|
1125
|
-
updateRecordWithID(
|
1426
|
+
updateRecordWithID({
|
1427
|
+
workspace,
|
1428
|
+
region,
|
1429
|
+
database,
|
1430
|
+
branch,
|
1431
|
+
table,
|
1432
|
+
id,
|
1433
|
+
record,
|
1434
|
+
columns,
|
1435
|
+
ifVersion
|
1436
|
+
}) {
|
1126
1437
|
return operationsByTag.records.updateRecordWithID({
|
1127
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1128
|
-
queryParams:
|
1438
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1439
|
+
queryParams: { columns, ifVersion },
|
1129
1440
|
body: record,
|
1130
1441
|
...this.extraProps
|
1131
1442
|
});
|
1132
1443
|
}
|
1133
|
-
upsertRecordWithID(
|
1444
|
+
upsertRecordWithID({
|
1445
|
+
workspace,
|
1446
|
+
region,
|
1447
|
+
database,
|
1448
|
+
branch,
|
1449
|
+
table,
|
1450
|
+
id,
|
1451
|
+
record,
|
1452
|
+
columns,
|
1453
|
+
ifVersion
|
1454
|
+
}) {
|
1134
1455
|
return operationsByTag.records.upsertRecordWithID({
|
1135
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1136
|
-
queryParams:
|
1456
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1457
|
+
queryParams: { columns, ifVersion },
|
1137
1458
|
body: record,
|
1138
1459
|
...this.extraProps
|
1139
1460
|
});
|
1140
1461
|
}
|
1141
|
-
deleteRecord(
|
1462
|
+
deleteRecord({
|
1463
|
+
workspace,
|
1464
|
+
region,
|
1465
|
+
database,
|
1466
|
+
branch,
|
1467
|
+
table,
|
1468
|
+
id,
|
1469
|
+
columns
|
1470
|
+
}) {
|
1142
1471
|
return operationsByTag.records.deleteRecord({
|
1143
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1144
|
-
queryParams:
|
1145
|
-
...this.extraProps
|
1146
|
-
});
|
1147
|
-
}
|
1148
|
-
getRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
1149
|
-
return operationsByTag.records.getRecord({
|
1150
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1151
|
-
queryParams: options,
|
1472
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1473
|
+
queryParams: { columns },
|
1152
1474
|
...this.extraProps
|
1153
1475
|
});
|
1154
1476
|
}
|
1155
|
-
bulkInsertTableRecords(
|
1477
|
+
bulkInsertTableRecords({
|
1478
|
+
workspace,
|
1479
|
+
region,
|
1480
|
+
database,
|
1481
|
+
branch,
|
1482
|
+
table,
|
1483
|
+
records,
|
1484
|
+
columns
|
1485
|
+
}) {
|
1156
1486
|
return operationsByTag.records.bulkInsertTableRecords({
|
1157
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1158
|
-
queryParams:
|
1487
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1488
|
+
queryParams: { columns },
|
1159
1489
|
body: { records },
|
1160
1490
|
...this.extraProps
|
1161
1491
|
});
|
1162
1492
|
}
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
}
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
body: query,
|
1493
|
+
branchTransaction({
|
1494
|
+
workspace,
|
1495
|
+
region,
|
1496
|
+
database,
|
1497
|
+
branch,
|
1498
|
+
operations
|
1499
|
+
}) {
|
1500
|
+
return operationsByTag.records.branchTransaction({
|
1501
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1502
|
+
body: { operations },
|
1174
1503
|
...this.extraProps
|
1175
1504
|
});
|
1176
1505
|
}
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
...this.extraProps
|
1182
|
-
});
|
1506
|
+
}
|
1507
|
+
class SearchAndFilterApi {
|
1508
|
+
constructor(extraProps) {
|
1509
|
+
this.extraProps = extraProps;
|
1183
1510
|
}
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1511
|
+
queryTable({
|
1512
|
+
workspace,
|
1513
|
+
region,
|
1514
|
+
database,
|
1515
|
+
branch,
|
1516
|
+
table,
|
1517
|
+
filter,
|
1518
|
+
sort,
|
1519
|
+
page,
|
1520
|
+
columns,
|
1521
|
+
consistency
|
1522
|
+
}) {
|
1523
|
+
return operationsByTag.searchAndFilter.queryTable({
|
1524
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1525
|
+
body: { filter, sort, page, columns, consistency },
|
1526
|
+
...this.extraProps
|
1527
|
+
});
|
1528
|
+
}
|
1529
|
+
searchTable({
|
1530
|
+
workspace,
|
1531
|
+
region,
|
1532
|
+
database,
|
1533
|
+
branch,
|
1534
|
+
table,
|
1535
|
+
query,
|
1536
|
+
fuzziness,
|
1537
|
+
target,
|
1538
|
+
prefix,
|
1539
|
+
filter,
|
1540
|
+
highlight,
|
1541
|
+
boosters
|
1542
|
+
}) {
|
1543
|
+
return operationsByTag.searchAndFilter.searchTable({
|
1544
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1545
|
+
body: { query, fuzziness, target, prefix, filter, highlight, boosters },
|
1546
|
+
...this.extraProps
|
1547
|
+
});
|
1548
|
+
}
|
1549
|
+
searchBranch({
|
1550
|
+
workspace,
|
1551
|
+
region,
|
1552
|
+
database,
|
1553
|
+
branch,
|
1554
|
+
tables,
|
1555
|
+
query,
|
1556
|
+
fuzziness,
|
1557
|
+
prefix,
|
1558
|
+
highlight
|
1559
|
+
}) {
|
1560
|
+
return operationsByTag.searchAndFilter.searchBranch({
|
1561
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1562
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
1563
|
+
...this.extraProps
|
1564
|
+
});
|
1565
|
+
}
|
1566
|
+
summarizeTable({
|
1567
|
+
workspace,
|
1568
|
+
region,
|
1569
|
+
database,
|
1570
|
+
branch,
|
1571
|
+
table,
|
1572
|
+
filter,
|
1573
|
+
columns,
|
1574
|
+
summaries,
|
1575
|
+
sort,
|
1576
|
+
summariesFilter,
|
1577
|
+
page,
|
1578
|
+
consistency
|
1579
|
+
}) {
|
1580
|
+
return operationsByTag.searchAndFilter.summarizeTable({
|
1581
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1582
|
+
body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
|
1583
|
+
...this.extraProps
|
1584
|
+
});
|
1585
|
+
}
|
1586
|
+
aggregateTable({
|
1587
|
+
workspace,
|
1588
|
+
region,
|
1589
|
+
database,
|
1590
|
+
branch,
|
1591
|
+
table,
|
1592
|
+
filter,
|
1593
|
+
aggs
|
1594
|
+
}) {
|
1595
|
+
return operationsByTag.searchAndFilter.aggregateTable({
|
1596
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1597
|
+
body: { filter, aggs },
|
1188
1598
|
...this.extraProps
|
1189
1599
|
});
|
1190
1600
|
}
|
@@ -1193,123 +1603,281 @@ class MigrationRequestsApi {
|
|
1193
1603
|
constructor(extraProps) {
|
1194
1604
|
this.extraProps = extraProps;
|
1195
1605
|
}
|
1196
|
-
queryMigrationRequests(
|
1606
|
+
queryMigrationRequests({
|
1607
|
+
workspace,
|
1608
|
+
region,
|
1609
|
+
database,
|
1610
|
+
filter,
|
1611
|
+
sort,
|
1612
|
+
page,
|
1613
|
+
columns
|
1614
|
+
}) {
|
1197
1615
|
return operationsByTag.migrationRequests.queryMigrationRequests({
|
1198
|
-
pathParams: { workspace, dbName: database },
|
1199
|
-
body:
|
1616
|
+
pathParams: { workspace, region, dbName: database },
|
1617
|
+
body: { filter, sort, page, columns },
|
1200
1618
|
...this.extraProps
|
1201
1619
|
});
|
1202
1620
|
}
|
1203
|
-
createMigrationRequest(
|
1621
|
+
createMigrationRequest({
|
1622
|
+
workspace,
|
1623
|
+
region,
|
1624
|
+
database,
|
1625
|
+
migration
|
1626
|
+
}) {
|
1204
1627
|
return operationsByTag.migrationRequests.createMigrationRequest({
|
1205
|
-
pathParams: { workspace, dbName: database },
|
1206
|
-
body:
|
1628
|
+
pathParams: { workspace, region, dbName: database },
|
1629
|
+
body: migration,
|
1207
1630
|
...this.extraProps
|
1208
1631
|
});
|
1209
1632
|
}
|
1210
|
-
getMigrationRequest(
|
1633
|
+
getMigrationRequest({
|
1634
|
+
workspace,
|
1635
|
+
region,
|
1636
|
+
database,
|
1637
|
+
migrationRequest
|
1638
|
+
}) {
|
1211
1639
|
return operationsByTag.migrationRequests.getMigrationRequest({
|
1212
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1640
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1213
1641
|
...this.extraProps
|
1214
1642
|
});
|
1215
1643
|
}
|
1216
|
-
updateMigrationRequest(
|
1644
|
+
updateMigrationRequest({
|
1645
|
+
workspace,
|
1646
|
+
region,
|
1647
|
+
database,
|
1648
|
+
migrationRequest,
|
1649
|
+
update
|
1650
|
+
}) {
|
1217
1651
|
return operationsByTag.migrationRequests.updateMigrationRequest({
|
1218
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1219
|
-
body:
|
1652
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1653
|
+
body: update,
|
1220
1654
|
...this.extraProps
|
1221
1655
|
});
|
1222
1656
|
}
|
1223
|
-
listMigrationRequestsCommits(
|
1657
|
+
listMigrationRequestsCommits({
|
1658
|
+
workspace,
|
1659
|
+
region,
|
1660
|
+
database,
|
1661
|
+
migrationRequest,
|
1662
|
+
page
|
1663
|
+
}) {
|
1224
1664
|
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
1225
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1226
|
-
body:
|
1665
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1666
|
+
body: { page },
|
1227
1667
|
...this.extraProps
|
1228
1668
|
});
|
1229
1669
|
}
|
1230
|
-
compareMigrationRequest(
|
1670
|
+
compareMigrationRequest({
|
1671
|
+
workspace,
|
1672
|
+
region,
|
1673
|
+
database,
|
1674
|
+
migrationRequest
|
1675
|
+
}) {
|
1231
1676
|
return operationsByTag.migrationRequests.compareMigrationRequest({
|
1232
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1677
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1233
1678
|
...this.extraProps
|
1234
1679
|
});
|
1235
1680
|
}
|
1236
|
-
getMigrationRequestIsMerged(
|
1681
|
+
getMigrationRequestIsMerged({
|
1682
|
+
workspace,
|
1683
|
+
region,
|
1684
|
+
database,
|
1685
|
+
migrationRequest
|
1686
|
+
}) {
|
1237
1687
|
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
1238
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1688
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1239
1689
|
...this.extraProps
|
1240
1690
|
});
|
1241
1691
|
}
|
1242
|
-
mergeMigrationRequest(
|
1692
|
+
mergeMigrationRequest({
|
1693
|
+
workspace,
|
1694
|
+
region,
|
1695
|
+
database,
|
1696
|
+
migrationRequest
|
1697
|
+
}) {
|
1243
1698
|
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
1244
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1699
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1245
1700
|
...this.extraProps
|
1246
1701
|
});
|
1247
1702
|
}
|
1248
1703
|
}
|
1249
|
-
class
|
1704
|
+
class MigrationsApi {
|
1250
1705
|
constructor(extraProps) {
|
1251
1706
|
this.extraProps = extraProps;
|
1252
1707
|
}
|
1253
|
-
getBranchMigrationHistory(
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1708
|
+
getBranchMigrationHistory({
|
1709
|
+
workspace,
|
1710
|
+
region,
|
1711
|
+
database,
|
1712
|
+
branch,
|
1713
|
+
limit,
|
1714
|
+
startFrom
|
1715
|
+
}) {
|
1716
|
+
return operationsByTag.migrations.getBranchMigrationHistory({
|
1717
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1718
|
+
body: { limit, startFrom },
|
1719
|
+
...this.extraProps
|
1720
|
+
});
|
1721
|
+
}
|
1722
|
+
getBranchMigrationPlan({
|
1723
|
+
workspace,
|
1724
|
+
region,
|
1725
|
+
database,
|
1726
|
+
branch,
|
1727
|
+
schema
|
1728
|
+
}) {
|
1729
|
+
return operationsByTag.migrations.getBranchMigrationPlan({
|
1730
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1731
|
+
body: schema,
|
1257
1732
|
...this.extraProps
|
1258
1733
|
});
|
1259
1734
|
}
|
1260
|
-
executeBranchMigrationPlan(
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1735
|
+
executeBranchMigrationPlan({
|
1736
|
+
workspace,
|
1737
|
+
region,
|
1738
|
+
database,
|
1739
|
+
branch,
|
1740
|
+
plan
|
1741
|
+
}) {
|
1742
|
+
return operationsByTag.migrations.executeBranchMigrationPlan({
|
1743
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1744
|
+
body: plan,
|
1264
1745
|
...this.extraProps
|
1265
1746
|
});
|
1266
1747
|
}
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1748
|
+
getBranchSchemaHistory({
|
1749
|
+
workspace,
|
1750
|
+
region,
|
1751
|
+
database,
|
1752
|
+
branch,
|
1753
|
+
page
|
1754
|
+
}) {
|
1755
|
+
return operationsByTag.migrations.getBranchSchemaHistory({
|
1756
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1757
|
+
body: { page },
|
1271
1758
|
...this.extraProps
|
1272
1759
|
});
|
1273
1760
|
}
|
1274
|
-
compareBranchWithUserSchema(
|
1275
|
-
|
1276
|
-
|
1761
|
+
compareBranchWithUserSchema({
|
1762
|
+
workspace,
|
1763
|
+
region,
|
1764
|
+
database,
|
1765
|
+
branch,
|
1766
|
+
schema
|
1767
|
+
}) {
|
1768
|
+
return operationsByTag.migrations.compareBranchWithUserSchema({
|
1769
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1277
1770
|
body: { schema },
|
1278
1771
|
...this.extraProps
|
1279
1772
|
});
|
1280
1773
|
}
|
1281
|
-
compareBranchSchemas(
|
1282
|
-
|
1283
|
-
|
1774
|
+
compareBranchSchemas({
|
1775
|
+
workspace,
|
1776
|
+
region,
|
1777
|
+
database,
|
1778
|
+
branch,
|
1779
|
+
compare,
|
1780
|
+
schema
|
1781
|
+
}) {
|
1782
|
+
return operationsByTag.migrations.compareBranchSchemas({
|
1783
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
1284
1784
|
body: { schema },
|
1285
1785
|
...this.extraProps
|
1286
1786
|
});
|
1287
1787
|
}
|
1288
|
-
updateBranchSchema(
|
1289
|
-
|
1290
|
-
|
1788
|
+
updateBranchSchema({
|
1789
|
+
workspace,
|
1790
|
+
region,
|
1791
|
+
database,
|
1792
|
+
branch,
|
1793
|
+
migration
|
1794
|
+
}) {
|
1795
|
+
return operationsByTag.migrations.updateBranchSchema({
|
1796
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1291
1797
|
body: migration,
|
1292
1798
|
...this.extraProps
|
1293
1799
|
});
|
1294
1800
|
}
|
1295
|
-
previewBranchSchemaEdit(
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1801
|
+
previewBranchSchemaEdit({
|
1802
|
+
workspace,
|
1803
|
+
region,
|
1804
|
+
database,
|
1805
|
+
branch,
|
1806
|
+
data
|
1807
|
+
}) {
|
1808
|
+
return operationsByTag.migrations.previewBranchSchemaEdit({
|
1809
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1810
|
+
body: data,
|
1299
1811
|
...this.extraProps
|
1300
1812
|
});
|
1301
1813
|
}
|
1302
|
-
applyBranchSchemaEdit(
|
1303
|
-
|
1304
|
-
|
1814
|
+
applyBranchSchemaEdit({
|
1815
|
+
workspace,
|
1816
|
+
region,
|
1817
|
+
database,
|
1818
|
+
branch,
|
1819
|
+
edits
|
1820
|
+
}) {
|
1821
|
+
return operationsByTag.migrations.applyBranchSchemaEdit({
|
1822
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1305
1823
|
body: { edits },
|
1306
1824
|
...this.extraProps
|
1307
1825
|
});
|
1308
1826
|
}
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1827
|
+
}
|
1828
|
+
class DatabaseApi {
|
1829
|
+
constructor(extraProps) {
|
1830
|
+
this.extraProps = extraProps;
|
1831
|
+
}
|
1832
|
+
getDatabaseList({ workspace }) {
|
1833
|
+
return operationsByTag.databases.getDatabaseList({
|
1834
|
+
pathParams: { workspaceId: workspace },
|
1835
|
+
...this.extraProps
|
1836
|
+
});
|
1837
|
+
}
|
1838
|
+
createDatabase({
|
1839
|
+
workspace,
|
1840
|
+
database,
|
1841
|
+
data
|
1842
|
+
}) {
|
1843
|
+
return operationsByTag.databases.createDatabase({
|
1844
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1845
|
+
body: data,
|
1846
|
+
...this.extraProps
|
1847
|
+
});
|
1848
|
+
}
|
1849
|
+
deleteDatabase({
|
1850
|
+
workspace,
|
1851
|
+
database
|
1852
|
+
}) {
|
1853
|
+
return operationsByTag.databases.deleteDatabase({
|
1854
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1855
|
+
...this.extraProps
|
1856
|
+
});
|
1857
|
+
}
|
1858
|
+
getDatabaseMetadata({
|
1859
|
+
workspace,
|
1860
|
+
database
|
1861
|
+
}) {
|
1862
|
+
return operationsByTag.databases.getDatabaseMetadata({
|
1863
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1864
|
+
...this.extraProps
|
1865
|
+
});
|
1866
|
+
}
|
1867
|
+
updateDatabaseMetadata({
|
1868
|
+
workspace,
|
1869
|
+
database,
|
1870
|
+
metadata
|
1871
|
+
}) {
|
1872
|
+
return operationsByTag.databases.updateDatabaseMetadata({
|
1873
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1874
|
+
body: metadata,
|
1875
|
+
...this.extraProps
|
1876
|
+
});
|
1877
|
+
}
|
1878
|
+
listRegions({ workspace }) {
|
1879
|
+
return operationsByTag.databases.listRegions({
|
1880
|
+
pathParams: { workspaceId: workspace },
|
1313
1881
|
...this.extraProps
|
1314
1882
|
});
|
1315
1883
|
}
|
@@ -1325,6 +1893,13 @@ class XataApiPlugin {
|
|
1325
1893
|
class XataPlugin {
|
1326
1894
|
}
|
1327
1895
|
|
1896
|
+
function cleanFilter(filter) {
|
1897
|
+
if (!filter)
|
1898
|
+
return void 0;
|
1899
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
1900
|
+
return values.length > 0 ? filter : void 0;
|
1901
|
+
}
|
1902
|
+
|
1328
1903
|
var __accessCheck$6 = (obj, member, msg) => {
|
1329
1904
|
if (!member.has(obj))
|
1330
1905
|
throw TypeError("Cannot " + msg);
|
@@ -1357,11 +1932,11 @@ class Page {
|
|
1357
1932
|
async previousPage(size, offset) {
|
1358
1933
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
1359
1934
|
}
|
1360
|
-
async
|
1361
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
1935
|
+
async startPage(size, offset) {
|
1936
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
1362
1937
|
}
|
1363
|
-
async
|
1364
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
1938
|
+
async endPage(size, offset) {
|
1939
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
1365
1940
|
}
|
1366
1941
|
hasNextPage() {
|
1367
1942
|
return this.meta.page.more;
|
@@ -1373,7 +1948,7 @@ const PAGINATION_DEFAULT_SIZE = 20;
|
|
1373
1948
|
const PAGINATION_MAX_OFFSET = 800;
|
1374
1949
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
1375
1950
|
function isCursorPaginationOptions(options) {
|
1376
|
-
return isDefined(options) && (isDefined(options.
|
1951
|
+
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
1377
1952
|
}
|
1378
1953
|
const _RecordArray = class extends Array {
|
1379
1954
|
constructor(...args) {
|
@@ -1394,6 +1969,12 @@ const _RecordArray = class extends Array {
|
|
1394
1969
|
toArray() {
|
1395
1970
|
return new Array(...this);
|
1396
1971
|
}
|
1972
|
+
toSerializable() {
|
1973
|
+
return JSON.parse(this.toString());
|
1974
|
+
}
|
1975
|
+
toString() {
|
1976
|
+
return JSON.stringify(this.toArray());
|
1977
|
+
}
|
1397
1978
|
map(callbackfn, thisArg) {
|
1398
1979
|
return this.toArray().map(callbackfn, thisArg);
|
1399
1980
|
}
|
@@ -1405,12 +1986,12 @@ const _RecordArray = class extends Array {
|
|
1405
1986
|
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
1406
1987
|
return new _RecordArray(newPage);
|
1407
1988
|
}
|
1408
|
-
async
|
1409
|
-
const newPage = await __privateGet$6(this, _page).
|
1989
|
+
async startPage(size, offset) {
|
1990
|
+
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
1410
1991
|
return new _RecordArray(newPage);
|
1411
1992
|
}
|
1412
|
-
async
|
1413
|
-
const newPage = await __privateGet$6(this, _page).
|
1993
|
+
async endPage(size, offset) {
|
1994
|
+
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
1414
1995
|
return new _RecordArray(newPage);
|
1415
1996
|
}
|
1416
1997
|
hasNextPage() {
|
@@ -1464,9 +2045,11 @@ const _Query = class {
|
|
1464
2045
|
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
1465
2046
|
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
1466
2047
|
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
1467
|
-
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns
|
2048
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
|
2049
|
+
__privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
|
1468
2050
|
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
1469
2051
|
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
2052
|
+
__privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
|
1470
2053
|
this.any = this.any.bind(this);
|
1471
2054
|
this.all = this.all.bind(this);
|
1472
2055
|
this.not = this.not.bind(this);
|
@@ -1580,19 +2163,29 @@ const _Query = class {
|
|
1580
2163
|
throw new Error("No results found.");
|
1581
2164
|
return records[0];
|
1582
2165
|
}
|
2166
|
+
async summarize(params = {}) {
|
2167
|
+
const { summaries, summariesFilter, ...options } = params;
|
2168
|
+
const query = new _Query(
|
2169
|
+
__privateGet$5(this, _repository),
|
2170
|
+
__privateGet$5(this, _table$1),
|
2171
|
+
options,
|
2172
|
+
__privateGet$5(this, _data)
|
2173
|
+
);
|
2174
|
+
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
2175
|
+
}
|
1583
2176
|
cache(ttl) {
|
1584
2177
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1585
2178
|
}
|
1586
2179
|
nextPage(size, offset) {
|
1587
|
-
return this.
|
2180
|
+
return this.startPage(size, offset);
|
1588
2181
|
}
|
1589
2182
|
previousPage(size, offset) {
|
1590
|
-
return this.
|
2183
|
+
return this.startPage(size, offset);
|
1591
2184
|
}
|
1592
|
-
|
2185
|
+
startPage(size, offset) {
|
1593
2186
|
return this.getPaginated({ pagination: { size, offset } });
|
1594
2187
|
}
|
1595
|
-
|
2188
|
+
endPage(size, offset) {
|
1596
2189
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
1597
2190
|
}
|
1598
2191
|
hasNextPage() {
|
@@ -1616,7 +2209,7 @@ cleanFilterConstraint_fn = function(column, value) {
|
|
1616
2209
|
};
|
1617
2210
|
function cleanParent(data, parent) {
|
1618
2211
|
if (isCursorPaginationOptions(data.pagination)) {
|
1619
|
-
return { ...parent,
|
2212
|
+
return { ...parent, sort: void 0, filter: void 0 };
|
1620
2213
|
}
|
1621
2214
|
return parent;
|
1622
2215
|
}
|
@@ -1675,7 +2268,8 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
1675
2268
|
__accessCheck$4(obj, member, "access private method");
|
1676
2269
|
return method;
|
1677
2270
|
};
|
1678
|
-
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn,
|
2271
|
+
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;
|
2272
|
+
const BULK_OPERATION_MAX_SIZE = 1e3;
|
1679
2273
|
class Repository extends Query {
|
1680
2274
|
}
|
1681
2275
|
class RestRepository extends Query {
|
@@ -1687,10 +2281,12 @@ class RestRepository extends Query {
|
|
1687
2281
|
);
|
1688
2282
|
__privateAdd$4(this, _insertRecordWithoutId);
|
1689
2283
|
__privateAdd$4(this, _insertRecordWithId);
|
1690
|
-
__privateAdd$4(this,
|
2284
|
+
__privateAdd$4(this, _insertRecords);
|
1691
2285
|
__privateAdd$4(this, _updateRecordWithID);
|
2286
|
+
__privateAdd$4(this, _updateRecords);
|
1692
2287
|
__privateAdd$4(this, _upsertRecordWithID);
|
1693
2288
|
__privateAdd$4(this, _deleteRecord);
|
2289
|
+
__privateAdd$4(this, _deleteRecords);
|
1694
2290
|
__privateAdd$4(this, _setCacheQuery);
|
1695
2291
|
__privateAdd$4(this, _getCacheQuery);
|
1696
2292
|
__privateAdd$4(this, _getSchemaTables$1);
|
@@ -1701,10 +2297,13 @@ class RestRepository extends Query {
|
|
1701
2297
|
__privateAdd$4(this, _schemaTables$2, void 0);
|
1702
2298
|
__privateAdd$4(this, _trace, void 0);
|
1703
2299
|
__privateSet$4(this, _table, options.table);
|
1704
|
-
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1705
2300
|
__privateSet$4(this, _db, options.db);
|
1706
2301
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
1707
2302
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
2303
|
+
__privateSet$4(this, _getFetchProps, async () => {
|
2304
|
+
const props = await options.pluginOptions.getFetchProps();
|
2305
|
+
return { ...props, sessionID: generateUUID() };
|
2306
|
+
});
|
1708
2307
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
1709
2308
|
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
1710
2309
|
return trace(name, fn, {
|
@@ -1715,25 +2314,28 @@ class RestRepository extends Query {
|
|
1715
2314
|
});
|
1716
2315
|
});
|
1717
2316
|
}
|
1718
|
-
async create(a, b, c) {
|
2317
|
+
async create(a, b, c, d) {
|
1719
2318
|
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
2319
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1720
2320
|
if (Array.isArray(a)) {
|
1721
2321
|
if (a.length === 0)
|
1722
2322
|
return [];
|
1723
|
-
const
|
1724
|
-
|
2323
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
2324
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2325
|
+
const result = await this.read(ids, columns);
|
2326
|
+
return result;
|
1725
2327
|
}
|
1726
2328
|
if (isString(a) && isObject(b)) {
|
1727
2329
|
if (a === "")
|
1728
2330
|
throw new Error("The id can't be empty");
|
1729
2331
|
const columns = isStringArray(c) ? c : void 0;
|
1730
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
2332
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
1731
2333
|
}
|
1732
2334
|
if (isObject(a) && isString(a.id)) {
|
1733
2335
|
if (a.id === "")
|
1734
2336
|
throw new Error("The id can't be empty");
|
1735
2337
|
const columns = isStringArray(b) ? b : void 0;
|
1736
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
2338
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
1737
2339
|
}
|
1738
2340
|
if (isObject(a)) {
|
1739
2341
|
const columns = isStringArray(b) ? b : void 0;
|
@@ -1764,6 +2366,7 @@ class RestRepository extends Query {
|
|
1764
2366
|
pathParams: {
|
1765
2367
|
workspace: "{workspaceId}",
|
1766
2368
|
dbBranchName: "{dbBranch}",
|
2369
|
+
region: "{region}",
|
1767
2370
|
tableName: __privateGet$4(this, _table),
|
1768
2371
|
recordId: id
|
1769
2372
|
},
|
@@ -1801,31 +2404,42 @@ class RestRepository extends Query {
|
|
1801
2404
|
return result;
|
1802
2405
|
});
|
1803
2406
|
}
|
1804
|
-
async update(a, b, c) {
|
2407
|
+
async update(a, b, c, d) {
|
1805
2408
|
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
2409
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1806
2410
|
if (Array.isArray(a)) {
|
1807
2411
|
if (a.length === 0)
|
1808
2412
|
return [];
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
2413
|
+
const existing = await this.read(a, ["id"]);
|
2414
|
+
const updates = a.filter((_item, index) => existing[index] !== null);
|
2415
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
|
2416
|
+
ifVersion,
|
2417
|
+
upsert: false
|
2418
|
+
});
|
1812
2419
|
const columns = isStringArray(b) ? b : ["*"];
|
1813
|
-
|
1814
|
-
|
1815
|
-
if (isString(a) && isObject(b)) {
|
1816
|
-
const columns = isStringArray(c) ? c : void 0;
|
1817
|
-
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
|
2420
|
+
const result = await this.read(a, columns);
|
2421
|
+
return result;
|
1818
2422
|
}
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
2423
|
+
try {
|
2424
|
+
if (isString(a) && isObject(b)) {
|
2425
|
+
const columns = isStringArray(c) ? c : void 0;
|
2426
|
+
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
2427
|
+
}
|
2428
|
+
if (isObject(a) && isString(a.id)) {
|
2429
|
+
const columns = isStringArray(b) ? b : void 0;
|
2430
|
+
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
2431
|
+
}
|
2432
|
+
} catch (error) {
|
2433
|
+
if (error.status === 422)
|
2434
|
+
return null;
|
2435
|
+
throw error;
|
1822
2436
|
}
|
1823
2437
|
throw new Error("Invalid arguments for update method");
|
1824
2438
|
});
|
1825
2439
|
}
|
1826
|
-
async updateOrThrow(a, b, c) {
|
2440
|
+
async updateOrThrow(a, b, c, d) {
|
1827
2441
|
return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
|
1828
|
-
const result = await this.update(a, b, c);
|
2442
|
+
const result = await this.update(a, b, c, d);
|
1829
2443
|
if (Array.isArray(result)) {
|
1830
2444
|
const missingIds = compact(
|
1831
2445
|
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
@@ -1842,37 +2456,69 @@ class RestRepository extends Query {
|
|
1842
2456
|
return result;
|
1843
2457
|
});
|
1844
2458
|
}
|
1845
|
-
async createOrUpdate(a, b, c) {
|
2459
|
+
async createOrUpdate(a, b, c, d) {
|
1846
2460
|
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
2461
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1847
2462
|
if (Array.isArray(a)) {
|
1848
2463
|
if (a.length === 0)
|
1849
2464
|
return [];
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
2465
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
|
2466
|
+
ifVersion,
|
2467
|
+
upsert: true
|
2468
|
+
});
|
1853
2469
|
const columns = isStringArray(b) ? b : ["*"];
|
1854
|
-
|
2470
|
+
const result = await this.read(a, columns);
|
2471
|
+
return result;
|
1855
2472
|
}
|
1856
2473
|
if (isString(a) && isObject(b)) {
|
1857
2474
|
const columns = isStringArray(c) ? c : void 0;
|
1858
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
|
2475
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
1859
2476
|
}
|
1860
2477
|
if (isObject(a) && isString(a.id)) {
|
1861
2478
|
const columns = isStringArray(c) ? c : void 0;
|
1862
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
2479
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
1863
2480
|
}
|
1864
2481
|
throw new Error("Invalid arguments for createOrUpdate method");
|
1865
2482
|
});
|
1866
2483
|
}
|
2484
|
+
async createOrReplace(a, b, c, d) {
|
2485
|
+
return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
|
2486
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2487
|
+
if (Array.isArray(a)) {
|
2488
|
+
if (a.length === 0)
|
2489
|
+
return [];
|
2490
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
2491
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2492
|
+
const result = await this.read(ids, columns);
|
2493
|
+
return result;
|
2494
|
+
}
|
2495
|
+
if (isString(a) && isObject(b)) {
|
2496
|
+
const columns = isStringArray(c) ? c : void 0;
|
2497
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
2498
|
+
}
|
2499
|
+
if (isObject(a) && isString(a.id)) {
|
2500
|
+
const columns = isStringArray(c) ? c : void 0;
|
2501
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
2502
|
+
}
|
2503
|
+
throw new Error("Invalid arguments for createOrReplace method");
|
2504
|
+
});
|
2505
|
+
}
|
1867
2506
|
async delete(a, b) {
|
1868
2507
|
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
1869
2508
|
if (Array.isArray(a)) {
|
1870
2509
|
if (a.length === 0)
|
1871
2510
|
return [];
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
2511
|
+
const ids = a.map((o) => {
|
2512
|
+
if (isString(o))
|
2513
|
+
return o;
|
2514
|
+
if (isString(o.id))
|
2515
|
+
return o.id;
|
2516
|
+
throw new Error("Invalid arguments for delete method");
|
2517
|
+
});
|
2518
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2519
|
+
const result = await this.read(a, columns);
|
2520
|
+
await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
|
2521
|
+
return result;
|
1876
2522
|
}
|
1877
2523
|
if (isString(a)) {
|
1878
2524
|
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
|
@@ -1905,14 +2551,21 @@ class RestRepository extends Query {
|
|
1905
2551
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
1906
2552
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1907
2553
|
const { records } = await searchTable({
|
1908
|
-
pathParams: {
|
2554
|
+
pathParams: {
|
2555
|
+
workspace: "{workspaceId}",
|
2556
|
+
dbBranchName: "{dbBranch}",
|
2557
|
+
region: "{region}",
|
2558
|
+
tableName: __privateGet$4(this, _table)
|
2559
|
+
},
|
1909
2560
|
body: {
|
1910
2561
|
query,
|
1911
2562
|
fuzziness: options.fuzziness,
|
1912
2563
|
prefix: options.prefix,
|
1913
2564
|
highlight: options.highlight,
|
1914
2565
|
filter: options.filter,
|
1915
|
-
boosters: options.boosters
|
2566
|
+
boosters: options.boosters,
|
2567
|
+
page: options.page,
|
2568
|
+
target: options.target
|
1916
2569
|
},
|
1917
2570
|
...fetchProps
|
1918
2571
|
});
|
@@ -1920,22 +2573,44 @@ class RestRepository extends Query {
|
|
1920
2573
|
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
1921
2574
|
});
|
1922
2575
|
}
|
2576
|
+
async aggregate(aggs, filter) {
|
2577
|
+
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
2578
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2579
|
+
const result = await aggregateTable({
|
2580
|
+
pathParams: {
|
2581
|
+
workspace: "{workspaceId}",
|
2582
|
+
dbBranchName: "{dbBranch}",
|
2583
|
+
region: "{region}",
|
2584
|
+
tableName: __privateGet$4(this, _table)
|
2585
|
+
},
|
2586
|
+
body: { aggs, filter },
|
2587
|
+
...fetchProps
|
2588
|
+
});
|
2589
|
+
return result;
|
2590
|
+
});
|
2591
|
+
}
|
1923
2592
|
async query(query) {
|
1924
2593
|
return __privateGet$4(this, _trace).call(this, "query", async () => {
|
1925
2594
|
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
1926
2595
|
if (cacheQuery)
|
1927
2596
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
1928
2597
|
const data = query.getQueryOptions();
|
1929
|
-
const body = {
|
1930
|
-
filter: cleanFilter(data.filter),
|
1931
|
-
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1932
|
-
page: data.pagination,
|
1933
|
-
columns: data.columns
|
1934
|
-
};
|
1935
2598
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1936
2599
|
const { meta, records: objects } = await queryTable({
|
1937
|
-
pathParams: {
|
1938
|
-
|
2600
|
+
pathParams: {
|
2601
|
+
workspace: "{workspaceId}",
|
2602
|
+
dbBranchName: "{dbBranch}",
|
2603
|
+
region: "{region}",
|
2604
|
+
tableName: __privateGet$4(this, _table)
|
2605
|
+
},
|
2606
|
+
body: {
|
2607
|
+
filter: cleanFilter(data.filter),
|
2608
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2609
|
+
page: data.pagination,
|
2610
|
+
columns: data.columns ?? ["*"],
|
2611
|
+
consistency: data.consistency
|
2612
|
+
},
|
2613
|
+
fetchOptions: data.fetchOptions,
|
1939
2614
|
...fetchProps
|
1940
2615
|
});
|
1941
2616
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
@@ -1946,6 +2621,31 @@ class RestRepository extends Query {
|
|
1946
2621
|
return new Page(query, meta, records);
|
1947
2622
|
});
|
1948
2623
|
}
|
2624
|
+
async summarizeTable(query, summaries, summariesFilter) {
|
2625
|
+
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
2626
|
+
const data = query.getQueryOptions();
|
2627
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2628
|
+
const result = await summarizeTable({
|
2629
|
+
pathParams: {
|
2630
|
+
workspace: "{workspaceId}",
|
2631
|
+
dbBranchName: "{dbBranch}",
|
2632
|
+
region: "{region}",
|
2633
|
+
tableName: __privateGet$4(this, _table)
|
2634
|
+
},
|
2635
|
+
body: {
|
2636
|
+
filter: cleanFilter(data.filter),
|
2637
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2638
|
+
columns: data.columns,
|
2639
|
+
consistency: data.consistency,
|
2640
|
+
page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
|
2641
|
+
summaries,
|
2642
|
+
summariesFilter
|
2643
|
+
},
|
2644
|
+
...fetchProps
|
2645
|
+
});
|
2646
|
+
return result;
|
2647
|
+
});
|
2648
|
+
}
|
1949
2649
|
}
|
1950
2650
|
_table = new WeakMap();
|
1951
2651
|
_getFetchProps = new WeakMap();
|
@@ -1961,6 +2661,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1961
2661
|
pathParams: {
|
1962
2662
|
workspace: "{workspaceId}",
|
1963
2663
|
dbBranchName: "{dbBranch}",
|
2664
|
+
region: "{region}",
|
1964
2665
|
tableName: __privateGet$4(this, _table)
|
1965
2666
|
},
|
1966
2667
|
queryParams: { columns },
|
@@ -1971,47 +2672,68 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1971
2672
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1972
2673
|
};
|
1973
2674
|
_insertRecordWithId = new WeakSet();
|
1974
|
-
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
2675
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
1975
2676
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1976
2677
|
const record = transformObjectLinks(object);
|
1977
2678
|
const response = await insertRecordWithID({
|
1978
2679
|
pathParams: {
|
1979
2680
|
workspace: "{workspaceId}",
|
1980
2681
|
dbBranchName: "{dbBranch}",
|
2682
|
+
region: "{region}",
|
1981
2683
|
tableName: __privateGet$4(this, _table),
|
1982
2684
|
recordId
|
1983
2685
|
},
|
1984
2686
|
body: record,
|
1985
|
-
queryParams: { createOnly
|
2687
|
+
queryParams: { createOnly, columns, ifVersion },
|
1986
2688
|
...fetchProps
|
1987
2689
|
});
|
1988
2690
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1989
2691
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1990
2692
|
};
|
1991
|
-
|
1992
|
-
|
2693
|
+
_insertRecords = new WeakSet();
|
2694
|
+
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
1993
2695
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1994
|
-
const
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2696
|
+
const chunkedOperations = chunk(
|
2697
|
+
objects.map((object) => ({
|
2698
|
+
insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
|
2699
|
+
})),
|
2700
|
+
BULK_OPERATION_MAX_SIZE
|
2701
|
+
);
|
2702
|
+
const ids = [];
|
2703
|
+
for (const operations of chunkedOperations) {
|
2704
|
+
const { results } = await branchTransaction({
|
2705
|
+
pathParams: {
|
2706
|
+
workspace: "{workspaceId}",
|
2707
|
+
dbBranchName: "{dbBranch}",
|
2708
|
+
region: "{region}"
|
2709
|
+
},
|
2710
|
+
body: { operations },
|
2711
|
+
...fetchProps
|
2712
|
+
});
|
2713
|
+
for (const result of results) {
|
2714
|
+
if (result.operation === "insert") {
|
2715
|
+
ids.push(result.id);
|
2716
|
+
} else {
|
2717
|
+
ids.push(null);
|
2718
|
+
}
|
2719
|
+
}
|
2003
2720
|
}
|
2004
|
-
|
2005
|
-
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
|
2721
|
+
return ids;
|
2006
2722
|
};
|
2007
2723
|
_updateRecordWithID = new WeakSet();
|
2008
|
-
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2724
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
2009
2725
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2010
|
-
const record = transformObjectLinks(object);
|
2726
|
+
const { id: _id, ...record } = transformObjectLinks(object);
|
2011
2727
|
try {
|
2012
2728
|
const response = await updateRecordWithID({
|
2013
|
-
pathParams: {
|
2014
|
-
|
2729
|
+
pathParams: {
|
2730
|
+
workspace: "{workspaceId}",
|
2731
|
+
dbBranchName: "{dbBranch}",
|
2732
|
+
region: "{region}",
|
2733
|
+
tableName: __privateGet$4(this, _table),
|
2734
|
+
recordId
|
2735
|
+
},
|
2736
|
+
queryParams: { columns, ifVersion },
|
2015
2737
|
body: record,
|
2016
2738
|
...fetchProps
|
2017
2739
|
});
|
@@ -2024,12 +2746,48 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
2024
2746
|
throw e;
|
2025
2747
|
}
|
2026
2748
|
};
|
2749
|
+
_updateRecords = new WeakSet();
|
2750
|
+
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
2751
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2752
|
+
const chunkedOperations = chunk(
|
2753
|
+
objects.map(({ id, ...object }) => ({
|
2754
|
+
update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
|
2755
|
+
})),
|
2756
|
+
BULK_OPERATION_MAX_SIZE
|
2757
|
+
);
|
2758
|
+
const ids = [];
|
2759
|
+
for (const operations of chunkedOperations) {
|
2760
|
+
const { results } = await branchTransaction({
|
2761
|
+
pathParams: {
|
2762
|
+
workspace: "{workspaceId}",
|
2763
|
+
dbBranchName: "{dbBranch}",
|
2764
|
+
region: "{region}"
|
2765
|
+
},
|
2766
|
+
body: { operations },
|
2767
|
+
...fetchProps
|
2768
|
+
});
|
2769
|
+
for (const result of results) {
|
2770
|
+
if (result.operation === "update") {
|
2771
|
+
ids.push(result.id);
|
2772
|
+
} else {
|
2773
|
+
ids.push(null);
|
2774
|
+
}
|
2775
|
+
}
|
2776
|
+
}
|
2777
|
+
return ids;
|
2778
|
+
};
|
2027
2779
|
_upsertRecordWithID = new WeakSet();
|
2028
|
-
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2780
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
2029
2781
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2030
2782
|
const response = await upsertRecordWithID({
|
2031
|
-
pathParams: {
|
2032
|
-
|
2783
|
+
pathParams: {
|
2784
|
+
workspace: "{workspaceId}",
|
2785
|
+
dbBranchName: "{dbBranch}",
|
2786
|
+
region: "{region}",
|
2787
|
+
tableName: __privateGet$4(this, _table),
|
2788
|
+
recordId
|
2789
|
+
},
|
2790
|
+
queryParams: { columns, ifVersion },
|
2033
2791
|
body: object,
|
2034
2792
|
...fetchProps
|
2035
2793
|
});
|
@@ -2041,7 +2799,13 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
2041
2799
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2042
2800
|
try {
|
2043
2801
|
const response = await deleteRecord({
|
2044
|
-
pathParams: {
|
2802
|
+
pathParams: {
|
2803
|
+
workspace: "{workspaceId}",
|
2804
|
+
dbBranchName: "{dbBranch}",
|
2805
|
+
region: "{region}",
|
2806
|
+
tableName: __privateGet$4(this, _table),
|
2807
|
+
recordId
|
2808
|
+
},
|
2045
2809
|
queryParams: { columns },
|
2046
2810
|
...fetchProps
|
2047
2811
|
});
|
@@ -2054,6 +2818,25 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
2054
2818
|
throw e;
|
2055
2819
|
}
|
2056
2820
|
};
|
2821
|
+
_deleteRecords = new WeakSet();
|
2822
|
+
deleteRecords_fn = async function(recordIds) {
|
2823
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2824
|
+
const chunkedOperations = chunk(
|
2825
|
+
recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
2826
|
+
BULK_OPERATION_MAX_SIZE
|
2827
|
+
);
|
2828
|
+
for (const operations of chunkedOperations) {
|
2829
|
+
await branchTransaction({
|
2830
|
+
pathParams: {
|
2831
|
+
workspace: "{workspaceId}",
|
2832
|
+
dbBranchName: "{dbBranch}",
|
2833
|
+
region: "{region}"
|
2834
|
+
},
|
2835
|
+
body: { operations },
|
2836
|
+
...fetchProps
|
2837
|
+
});
|
2838
|
+
}
|
2839
|
+
};
|
2057
2840
|
_setCacheQuery = new WeakSet();
|
2058
2841
|
setCacheQuery_fn = async function(query, meta, records) {
|
2059
2842
|
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
@@ -2076,7 +2859,7 @@ getSchemaTables_fn$1 = async function() {
|
|
2076
2859
|
return __privateGet$4(this, _schemaTables$2);
|
2077
2860
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2078
2861
|
const { schema } = await getBranchDetails({
|
2079
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2862
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2080
2863
|
...fetchProps
|
2081
2864
|
});
|
2082
2865
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
@@ -2090,23 +2873,23 @@ const transformObjectLinks = (object) => {
|
|
2090
2873
|
}, {});
|
2091
2874
|
};
|
2092
2875
|
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
2093
|
-
const
|
2876
|
+
const data = {};
|
2094
2877
|
const { xata, ...rest } = object ?? {};
|
2095
|
-
Object.assign(
|
2878
|
+
Object.assign(data, rest);
|
2096
2879
|
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
2097
2880
|
if (!columns)
|
2098
2881
|
console.error(`Table ${table} not found in schema`);
|
2099
2882
|
for (const column of columns ?? []) {
|
2100
2883
|
if (!isValidColumn(selectedColumns, column))
|
2101
2884
|
continue;
|
2102
|
-
const value =
|
2885
|
+
const value = data[column.name];
|
2103
2886
|
switch (column.type) {
|
2104
2887
|
case "datetime": {
|
2105
|
-
const date = value !== void 0 ? new Date(value) :
|
2106
|
-
if (date && isNaN(date.getTime())) {
|
2888
|
+
const date = value !== void 0 ? new Date(value) : null;
|
2889
|
+
if (date !== null && isNaN(date.getTime())) {
|
2107
2890
|
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
2108
|
-
} else
|
2109
|
-
|
2891
|
+
} else {
|
2892
|
+
data[column.name] = date;
|
2110
2893
|
}
|
2111
2894
|
break;
|
2112
2895
|
}
|
@@ -2125,41 +2908,52 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2125
2908
|
}
|
2126
2909
|
return acc;
|
2127
2910
|
}, []);
|
2128
|
-
|
2911
|
+
data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
|
2129
2912
|
} else {
|
2130
|
-
|
2913
|
+
data[column.name] = null;
|
2131
2914
|
}
|
2132
2915
|
break;
|
2133
2916
|
}
|
2134
2917
|
default:
|
2135
|
-
|
2918
|
+
data[column.name] = value ?? null;
|
2136
2919
|
if (column.notNull === true && value === null) {
|
2137
2920
|
console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
|
2138
2921
|
}
|
2139
2922
|
break;
|
2140
2923
|
}
|
2141
2924
|
}
|
2142
|
-
|
2143
|
-
|
2925
|
+
const record = { ...data };
|
2926
|
+
record.read = function(columns2) {
|
2927
|
+
return db[table].read(record["id"], columns2);
|
2928
|
+
};
|
2929
|
+
record.update = function(data2, b, c) {
|
2930
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2931
|
+
const ifVersion = parseIfVersion(b, c);
|
2932
|
+
return db[table].update(record["id"], data2, columns2, { ifVersion });
|
2144
2933
|
};
|
2145
|
-
|
2146
|
-
|
2934
|
+
record.replace = function(data2, b, c) {
|
2935
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2936
|
+
const ifVersion = parseIfVersion(b, c);
|
2937
|
+
return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
|
2147
2938
|
};
|
2148
|
-
|
2149
|
-
return db[table].delete(
|
2939
|
+
record.delete = function() {
|
2940
|
+
return db[table].delete(record["id"]);
|
2150
2941
|
};
|
2151
|
-
|
2942
|
+
record.getMetadata = function() {
|
2152
2943
|
return xata;
|
2153
2944
|
};
|
2154
|
-
|
2155
|
-
|
2945
|
+
record.toSerializable = function() {
|
2946
|
+
return JSON.parse(JSON.stringify(transformObjectLinks(data)));
|
2947
|
+
};
|
2948
|
+
record.toString = function() {
|
2949
|
+
return JSON.stringify(transformObjectLinks(data));
|
2950
|
+
};
|
2951
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
2952
|
+
Object.defineProperty(record, prop, { enumerable: false });
|
2156
2953
|
}
|
2157
|
-
Object.freeze(
|
2158
|
-
return
|
2954
|
+
Object.freeze(record);
|
2955
|
+
return record;
|
2159
2956
|
};
|
2160
|
-
function isResponseWithRecords(value) {
|
2161
|
-
return isObject(value) && Array.isArray(value.records);
|
2162
|
-
}
|
2163
2957
|
function extractId(value) {
|
2164
2958
|
if (isString(value))
|
2165
2959
|
return value;
|
@@ -2167,12 +2961,6 @@ function extractId(value) {
|
|
2167
2961
|
return value.id;
|
2168
2962
|
return void 0;
|
2169
2963
|
}
|
2170
|
-
function cleanFilter(filter) {
|
2171
|
-
if (!filter)
|
2172
|
-
return void 0;
|
2173
|
-
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
2174
|
-
return values.length > 0 ? filter : void 0;
|
2175
|
-
}
|
2176
2964
|
function isValidColumn(columns, column) {
|
2177
2965
|
if (columns.includes("*"))
|
2178
2966
|
return true;
|
@@ -2182,6 +2970,14 @@ function isValidColumn(columns, column) {
|
|
2182
2970
|
}
|
2183
2971
|
return columns.includes(column.name);
|
2184
2972
|
}
|
2973
|
+
function parseIfVersion(...args) {
|
2974
|
+
for (const arg of args) {
|
2975
|
+
if (isObject(arg) && isNumber(arg.ifVersion)) {
|
2976
|
+
return arg.ifVersion;
|
2977
|
+
}
|
2978
|
+
}
|
2979
|
+
return void 0;
|
2980
|
+
}
|
2185
2981
|
|
2186
2982
|
var __accessCheck$3 = (obj, member, msg) => {
|
2187
2983
|
if (!member.has(obj))
|
@@ -2367,10 +3163,10 @@ _schemaTables = new WeakMap();
|
|
2367
3163
|
_search = new WeakSet();
|
2368
3164
|
search_fn = async function(query, options, getFetchProps) {
|
2369
3165
|
const fetchProps = await getFetchProps();
|
2370
|
-
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
3166
|
+
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
2371
3167
|
const { records } = await searchBranch({
|
2372
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2373
|
-
body: { tables, query, fuzziness, prefix, highlight },
|
3168
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3169
|
+
body: { tables, query, fuzziness, prefix, highlight, page },
|
2374
3170
|
...fetchProps
|
2375
3171
|
});
|
2376
3172
|
return records;
|
@@ -2381,25 +3177,37 @@ getSchemaTables_fn = async function(getFetchProps) {
|
|
2381
3177
|
return __privateGet$1(this, _schemaTables);
|
2382
3178
|
const fetchProps = await getFetchProps();
|
2383
3179
|
const { schema } = await getBranchDetails({
|
2384
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
3180
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2385
3181
|
...fetchProps
|
2386
3182
|
});
|
2387
3183
|
__privateSet$1(this, _schemaTables, schema.tables);
|
2388
3184
|
return schema.tables;
|
2389
3185
|
};
|
2390
3186
|
|
3187
|
+
class TransactionPlugin extends XataPlugin {
|
3188
|
+
build({ getFetchProps }) {
|
3189
|
+
return {
|
3190
|
+
run: async (operations) => {
|
3191
|
+
const fetchProps = await getFetchProps();
|
3192
|
+
const response = await branchTransaction({
|
3193
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3194
|
+
body: { operations },
|
3195
|
+
...fetchProps
|
3196
|
+
});
|
3197
|
+
return response;
|
3198
|
+
}
|
3199
|
+
};
|
3200
|
+
}
|
3201
|
+
}
|
3202
|
+
|
2391
3203
|
const isBranchStrategyBuilder = (strategy) => {
|
2392
3204
|
return typeof strategy === "function";
|
2393
3205
|
};
|
2394
3206
|
|
2395
3207
|
async function getCurrentBranchName(options) {
|
2396
3208
|
const { branch, envBranch } = getEnvironment();
|
2397
|
-
if (branch)
|
2398
|
-
|
2399
|
-
if (details)
|
2400
|
-
return branch;
|
2401
|
-
console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
|
2402
|
-
}
|
3209
|
+
if (branch)
|
3210
|
+
return branch;
|
2403
3211
|
const gitBranch = envBranch || await getGitBranch();
|
2404
3212
|
return resolveXataBranch(gitBranch, options);
|
2405
3213
|
}
|
@@ -2419,16 +3227,20 @@ async function resolveXataBranch(gitBranch, options) {
|
|
2419
3227
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2420
3228
|
);
|
2421
3229
|
const [protocol, , host, , dbName] = databaseURL.split("/");
|
2422
|
-
const
|
3230
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
3231
|
+
if (!urlParts)
|
3232
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3233
|
+
const { workspace, region } = urlParts;
|
2423
3234
|
const { fallbackBranch } = getEnvironment();
|
2424
3235
|
const { branch } = await resolveBranch({
|
2425
3236
|
apiKey,
|
2426
3237
|
apiUrl: databaseURL,
|
2427
3238
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2428
3239
|
workspacesApiUrl: `${protocol}//${host}`,
|
2429
|
-
pathParams: { dbName, workspace },
|
3240
|
+
pathParams: { dbName, workspace, region },
|
2430
3241
|
queryParams: { gitBranch, fallbackBranch },
|
2431
|
-
trace: defaultTrace
|
3242
|
+
trace: defaultTrace,
|
3243
|
+
clientName: options?.clientName
|
2432
3244
|
});
|
2433
3245
|
return branch;
|
2434
3246
|
}
|
@@ -2444,15 +3256,17 @@ async function getDatabaseBranch(branch, options) {
|
|
2444
3256
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2445
3257
|
);
|
2446
3258
|
const [protocol, , host, , database] = databaseURL.split("/");
|
2447
|
-
const
|
2448
|
-
|
3259
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
3260
|
+
if (!urlParts)
|
3261
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3262
|
+
const { workspace, region } = urlParts;
|
2449
3263
|
try {
|
2450
3264
|
return await getBranchDetails({
|
2451
3265
|
apiKey,
|
2452
3266
|
apiUrl: databaseURL,
|
2453
3267
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2454
3268
|
workspacesApiUrl: `${protocol}//${host}`,
|
2455
|
-
pathParams: { dbBranchName
|
3269
|
+
pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
|
2456
3270
|
trace: defaultTrace
|
2457
3271
|
});
|
2458
3272
|
} catch (err) {
|
@@ -2510,8 +3324,10 @@ const buildClient = (plugins) => {
|
|
2510
3324
|
};
|
2511
3325
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
2512
3326
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
3327
|
+
const transactions = new TransactionPlugin().build(pluginOptions);
|
2513
3328
|
this.db = db;
|
2514
3329
|
this.search = search;
|
3330
|
+
this.transactions = transactions;
|
2515
3331
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
2516
3332
|
if (namespace === void 0)
|
2517
3333
|
continue;
|
@@ -2531,20 +3347,41 @@ const buildClient = (plugins) => {
|
|
2531
3347
|
return { databaseURL, branch };
|
2532
3348
|
}
|
2533
3349
|
}, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
3350
|
+
const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
|
3351
|
+
const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
|
3352
|
+
if (isBrowser && !enableBrowser) {
|
3353
|
+
throw new Error(
|
3354
|
+
"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."
|
3355
|
+
);
|
3356
|
+
}
|
2534
3357
|
const fetch = getFetchImplementation(options?.fetch);
|
2535
3358
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
2536
3359
|
const apiKey = options?.apiKey || getAPIKey();
|
2537
3360
|
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
2538
3361
|
const trace = options?.trace ?? defaultTrace;
|
2539
|
-
const
|
3362
|
+
const clientName = options?.clientName;
|
3363
|
+
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({
|
3364
|
+
apiKey,
|
3365
|
+
databaseURL,
|
3366
|
+
fetchImpl: options?.fetch,
|
3367
|
+
clientName: options?.clientName
|
3368
|
+
});
|
2540
3369
|
if (!apiKey) {
|
2541
3370
|
throw new Error("Option apiKey is required");
|
2542
3371
|
}
|
2543
3372
|
if (!databaseURL) {
|
2544
3373
|
throw new Error("Option databaseURL is required");
|
2545
3374
|
}
|
2546
|
-
return { fetch, databaseURL, apiKey, branch, cache, trace };
|
2547
|
-
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
|
3375
|
+
return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser, clientName };
|
3376
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
|
3377
|
+
fetch,
|
3378
|
+
apiKey,
|
3379
|
+
databaseURL,
|
3380
|
+
branch,
|
3381
|
+
trace,
|
3382
|
+
clientID,
|
3383
|
+
clientName
|
3384
|
+
}) {
|
2548
3385
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
2549
3386
|
if (!branchValue)
|
2550
3387
|
throw new Error("Unable to resolve branch value");
|
@@ -2557,7 +3394,9 @@ const buildClient = (plugins) => {
|
|
2557
3394
|
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
|
2558
3395
|
return databaseURL + newPath;
|
2559
3396
|
},
|
2560
|
-
trace
|
3397
|
+
trace,
|
3398
|
+
clientID,
|
3399
|
+
clientName
|
2561
3400
|
};
|
2562
3401
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
2563
3402
|
if (__privateGet(this, _branch))
|
@@ -2648,7 +3487,7 @@ const deserialize = (json) => {
|
|
2648
3487
|
};
|
2649
3488
|
|
2650
3489
|
function buildWorkerRunner(config) {
|
2651
|
-
return function xataWorker(name,
|
3490
|
+
return function xataWorker(name, worker) {
|
2652
3491
|
return async (...args) => {
|
2653
3492
|
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
2654
3493
|
const result = await fetch(url, {
|
@@ -2670,6 +3509,7 @@ class XataError extends Error {
|
|
2670
3509
|
}
|
2671
3510
|
|
2672
3511
|
exports.BaseClient = BaseClient;
|
3512
|
+
exports.FetcherError = FetcherError;
|
2673
3513
|
exports.Operations = operationsByTag;
|
2674
3514
|
exports.PAGINATION_DEFAULT_OFFSET = PAGINATION_DEFAULT_OFFSET;
|
2675
3515
|
exports.PAGINATION_DEFAULT_SIZE = PAGINATION_DEFAULT_SIZE;
|
@@ -2691,7 +3531,9 @@ exports.XataPlugin = XataPlugin;
|
|
2691
3531
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
2692
3532
|
exports.addGitBranchesEntry = addGitBranchesEntry;
|
2693
3533
|
exports.addTableColumn = addTableColumn;
|
3534
|
+
exports.aggregateTable = aggregateTable;
|
2694
3535
|
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
3536
|
+
exports.branchTransaction = branchTransaction;
|
2695
3537
|
exports.buildClient = buildClient;
|
2696
3538
|
exports.buildWorkerRunner = buildWorkerRunner;
|
2697
3539
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
@@ -2770,12 +3612,14 @@ exports.lessEquals = lessEquals;
|
|
2770
3612
|
exports.lessThan = lessThan;
|
2771
3613
|
exports.lessThanEquals = lessThanEquals;
|
2772
3614
|
exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
|
3615
|
+
exports.listRegions = listRegions;
|
2773
3616
|
exports.lt = lt;
|
2774
3617
|
exports.lte = lte;
|
2775
3618
|
exports.mergeMigrationRequest = mergeMigrationRequest;
|
2776
3619
|
exports.notExists = notExists;
|
2777
3620
|
exports.operationsByTag = operationsByTag;
|
2778
3621
|
exports.parseProviderString = parseProviderString;
|
3622
|
+
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
2779
3623
|
exports.pattern = pattern;
|
2780
3624
|
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
2781
3625
|
exports.queryMigrationRequests = queryMigrationRequests;
|