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