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