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