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