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