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