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