@xata.io/client 0.0.0-alpha.vfe4ae98 → 0.0.0-alpha.vfe896b3
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 +348 -0
- package/README.md +3 -267
- package/dist/index.cjs +2745 -902
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6006 -1481
- package/dist/index.mjs +2697 -900
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -10
- package/rollup.config.mjs +44 -0
- package/Usage.md +0 -395
- package/rollup.config.js +0 -29
package/dist/index.cjs
CHANGED
@@ -1,6 +1,27 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
3
|
+
const defaultTrace = async (name, fn, _options) => {
|
4
|
+
return await fn({
|
5
|
+
name,
|
6
|
+
setAttributes: () => {
|
7
|
+
return;
|
8
|
+
}
|
9
|
+
});
|
10
|
+
};
|
11
|
+
const TraceAttributes = {
|
12
|
+
KIND: "xata.trace.kind",
|
13
|
+
VERSION: "xata.sdk.version",
|
14
|
+
TABLE: "xata.table",
|
15
|
+
HTTP_REQUEST_ID: "http.request_id",
|
16
|
+
HTTP_STATUS_CODE: "http.status_code",
|
17
|
+
HTTP_HOST: "http.host",
|
18
|
+
HTTP_SCHEME: "http.scheme",
|
19
|
+
HTTP_USER_AGENT: "http.user_agent",
|
20
|
+
HTTP_METHOD: "http.method",
|
21
|
+
HTTP_URL: "http.url",
|
22
|
+
HTTP_ROUTE: "http.route",
|
23
|
+
HTTP_TARGET: "http.target"
|
24
|
+
};
|
4
25
|
|
5
26
|
function notEmpty(value) {
|
6
27
|
return value !== null && value !== void 0;
|
@@ -17,6 +38,24 @@ function isDefined(value) {
|
|
17
38
|
function isString(value) {
|
18
39
|
return isDefined(value) && typeof value === "string";
|
19
40
|
}
|
41
|
+
function isStringArray(value) {
|
42
|
+
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
43
|
+
}
|
44
|
+
function isNumber(value) {
|
45
|
+
return isDefined(value) && typeof value === "number";
|
46
|
+
}
|
47
|
+
function parseNumber(value) {
|
48
|
+
if (isNumber(value)) {
|
49
|
+
return value;
|
50
|
+
}
|
51
|
+
if (isString(value)) {
|
52
|
+
const parsed = Number(value);
|
53
|
+
if (!Number.isNaN(parsed)) {
|
54
|
+
return parsed;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
return void 0;
|
58
|
+
}
|
20
59
|
function toBase64(value) {
|
21
60
|
try {
|
22
61
|
return btoa(value);
|
@@ -25,60 +64,435 @@ function toBase64(value) {
|
|
25
64
|
return buf.from(value).toString("base64");
|
26
65
|
}
|
27
66
|
}
|
67
|
+
function deepMerge(a, b) {
|
68
|
+
const result = { ...a };
|
69
|
+
for (const [key, value] of Object.entries(b)) {
|
70
|
+
if (isObject(value) && isObject(result[key])) {
|
71
|
+
result[key] = deepMerge(result[key], value);
|
72
|
+
} else {
|
73
|
+
result[key] = value;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
return result;
|
77
|
+
}
|
78
|
+
function chunk(array, chunkSize) {
|
79
|
+
const result = [];
|
80
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
81
|
+
result.push(array.slice(i, i + chunkSize));
|
82
|
+
}
|
83
|
+
return result;
|
84
|
+
}
|
85
|
+
async function timeout(ms) {
|
86
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
87
|
+
}
|
28
88
|
|
29
|
-
function
|
89
|
+
function getEnvironment() {
|
30
90
|
try {
|
31
|
-
if (
|
32
|
-
return
|
91
|
+
if (isDefined(process) && isDefined(process.env)) {
|
92
|
+
return {
|
93
|
+
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
94
|
+
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
95
|
+
branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
|
96
|
+
deployPreview: process.env.XATA_PREVIEW,
|
97
|
+
deployPreviewBranch: process.env.XATA_PREVIEW_BRANCH,
|
98
|
+
vercelGitCommitRef: process.env.VERCEL_GIT_COMMIT_REF,
|
99
|
+
vercelGitRepoOwner: process.env.VERCEL_GIT_REPO_OWNER
|
100
|
+
};
|
33
101
|
}
|
34
102
|
} catch (err) {
|
35
103
|
}
|
36
104
|
try {
|
37
|
-
if (isObject(Deno) &&
|
38
|
-
return
|
105
|
+
if (isObject(Deno) && isObject(Deno.env)) {
|
106
|
+
return {
|
107
|
+
apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
|
108
|
+
databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
|
109
|
+
branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
|
110
|
+
deployPreview: Deno.env.get("XATA_PREVIEW"),
|
111
|
+
deployPreviewBranch: Deno.env.get("XATA_PREVIEW_BRANCH"),
|
112
|
+
vercelGitCommitRef: Deno.env.get("VERCEL_GIT_COMMIT_REF"),
|
113
|
+
vercelGitRepoOwner: Deno.env.get("VERCEL_GIT_REPO_OWNER")
|
114
|
+
};
|
39
115
|
}
|
40
116
|
} catch (err) {
|
41
117
|
}
|
118
|
+
return {
|
119
|
+
apiKey: getGlobalApiKey(),
|
120
|
+
databaseURL: getGlobalDatabaseURL(),
|
121
|
+
branch: getGlobalBranch(),
|
122
|
+
deployPreview: void 0,
|
123
|
+
deployPreviewBranch: void 0,
|
124
|
+
vercelGitCommitRef: void 0,
|
125
|
+
vercelGitRepoOwner: void 0
|
126
|
+
};
|
42
127
|
}
|
43
|
-
|
128
|
+
function getEnableBrowserVariable() {
|
44
129
|
try {
|
45
|
-
if (
|
46
|
-
|
47
|
-
return req("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
|
130
|
+
if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
|
131
|
+
return process.env.XATA_ENABLE_BROWSER === "true";
|
48
132
|
}
|
49
133
|
} catch (err) {
|
50
134
|
}
|
51
135
|
try {
|
52
|
-
if (isObject(Deno)) {
|
53
|
-
|
54
|
-
cmd: ["git", "branch", "--show-current"],
|
55
|
-
stdout: "piped",
|
56
|
-
stderr: "piped"
|
57
|
-
});
|
58
|
-
return new TextDecoder().decode(await process2.output()).trim();
|
136
|
+
if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
|
137
|
+
return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
|
59
138
|
}
|
60
139
|
} catch (err) {
|
61
140
|
}
|
141
|
+
try {
|
142
|
+
return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
|
143
|
+
} catch (err) {
|
144
|
+
return void 0;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
function getGlobalApiKey() {
|
148
|
+
try {
|
149
|
+
return XATA_API_KEY;
|
150
|
+
} catch (err) {
|
151
|
+
return void 0;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
function getGlobalDatabaseURL() {
|
155
|
+
try {
|
156
|
+
return XATA_DATABASE_URL;
|
157
|
+
} catch (err) {
|
158
|
+
return void 0;
|
159
|
+
}
|
160
|
+
}
|
161
|
+
function getGlobalBranch() {
|
162
|
+
try {
|
163
|
+
return XATA_BRANCH;
|
164
|
+
} catch (err) {
|
165
|
+
return void 0;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
function getDatabaseURL() {
|
169
|
+
try {
|
170
|
+
const { databaseURL } = getEnvironment();
|
171
|
+
return databaseURL;
|
172
|
+
} catch (err) {
|
173
|
+
return void 0;
|
174
|
+
}
|
62
175
|
}
|
63
|
-
|
64
176
|
function getAPIKey() {
|
65
177
|
try {
|
66
|
-
|
178
|
+
const { apiKey } = getEnvironment();
|
179
|
+
return apiKey;
|
180
|
+
} catch (err) {
|
181
|
+
return void 0;
|
182
|
+
}
|
183
|
+
}
|
184
|
+
function getBranch() {
|
185
|
+
try {
|
186
|
+
const { branch } = getEnvironment();
|
187
|
+
return branch ?? "main";
|
188
|
+
} catch (err) {
|
189
|
+
return void 0;
|
190
|
+
}
|
191
|
+
}
|
192
|
+
function buildPreviewBranchName({ org, branch }) {
|
193
|
+
return `preview-${org}-${branch}`;
|
194
|
+
}
|
195
|
+
function getPreviewBranch() {
|
196
|
+
try {
|
197
|
+
const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = getEnvironment();
|
198
|
+
if (deployPreviewBranch)
|
199
|
+
return deployPreviewBranch;
|
200
|
+
switch (deployPreview) {
|
201
|
+
case "vercel": {
|
202
|
+
if (!vercelGitCommitRef || !vercelGitRepoOwner) {
|
203
|
+
console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
|
204
|
+
return void 0;
|
205
|
+
}
|
206
|
+
return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
|
207
|
+
}
|
208
|
+
}
|
209
|
+
return void 0;
|
67
210
|
} catch (err) {
|
68
211
|
return void 0;
|
69
212
|
}
|
70
213
|
}
|
71
214
|
|
215
|
+
var __accessCheck$8 = (obj, member, msg) => {
|
216
|
+
if (!member.has(obj))
|
217
|
+
throw TypeError("Cannot " + msg);
|
218
|
+
};
|
219
|
+
var __privateGet$8 = (obj, member, getter) => {
|
220
|
+
__accessCheck$8(obj, member, "read from private field");
|
221
|
+
return getter ? getter.call(obj) : member.get(obj);
|
222
|
+
};
|
223
|
+
var __privateAdd$8 = (obj, member, value) => {
|
224
|
+
if (member.has(obj))
|
225
|
+
throw TypeError("Cannot add the same private member more than once");
|
226
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
227
|
+
};
|
228
|
+
var __privateSet$8 = (obj, member, value, setter) => {
|
229
|
+
__accessCheck$8(obj, member, "write to private field");
|
230
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
231
|
+
return value;
|
232
|
+
};
|
233
|
+
var __privateMethod$4 = (obj, member, method) => {
|
234
|
+
__accessCheck$8(obj, member, "access private method");
|
235
|
+
return method;
|
236
|
+
};
|
237
|
+
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
72
238
|
function getFetchImplementation(userFetch) {
|
73
239
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
74
240
|
const fetchImpl = userFetch ?? globalFetch;
|
75
241
|
if (!fetchImpl) {
|
76
|
-
throw new Error(
|
242
|
+
throw new Error(
|
243
|
+
`Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
|
244
|
+
);
|
77
245
|
}
|
78
246
|
return fetchImpl;
|
79
247
|
}
|
248
|
+
class ApiRequestPool {
|
249
|
+
constructor(concurrency = 10) {
|
250
|
+
__privateAdd$8(this, _enqueue);
|
251
|
+
__privateAdd$8(this, _fetch, void 0);
|
252
|
+
__privateAdd$8(this, _queue, void 0);
|
253
|
+
__privateAdd$8(this, _concurrency, void 0);
|
254
|
+
__privateSet$8(this, _queue, []);
|
255
|
+
__privateSet$8(this, _concurrency, concurrency);
|
256
|
+
this.running = 0;
|
257
|
+
this.started = 0;
|
258
|
+
}
|
259
|
+
setFetch(fetch2) {
|
260
|
+
__privateSet$8(this, _fetch, fetch2);
|
261
|
+
}
|
262
|
+
getFetch() {
|
263
|
+
if (!__privateGet$8(this, _fetch)) {
|
264
|
+
throw new Error("Fetch not set");
|
265
|
+
}
|
266
|
+
return __privateGet$8(this, _fetch);
|
267
|
+
}
|
268
|
+
request(url, options) {
|
269
|
+
const start = new Date();
|
270
|
+
const fetch2 = this.getFetch();
|
271
|
+
const runRequest = async (stalled = false) => {
|
272
|
+
const response = await fetch2(url, options);
|
273
|
+
if (response.status === 429) {
|
274
|
+
const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
|
275
|
+
await timeout(rateLimitReset * 1e3);
|
276
|
+
return await runRequest(true);
|
277
|
+
}
|
278
|
+
if (stalled) {
|
279
|
+
const stalledTime = new Date().getTime() - start.getTime();
|
280
|
+
console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
|
281
|
+
}
|
282
|
+
return response;
|
283
|
+
};
|
284
|
+
return __privateMethod$4(this, _enqueue, enqueue_fn).call(this, async () => {
|
285
|
+
return await runRequest();
|
286
|
+
});
|
287
|
+
}
|
288
|
+
}
|
289
|
+
_fetch = new WeakMap();
|
290
|
+
_queue = new WeakMap();
|
291
|
+
_concurrency = new WeakMap();
|
292
|
+
_enqueue = new WeakSet();
|
293
|
+
enqueue_fn = function(task) {
|
294
|
+
const promise = new Promise((resolve) => __privateGet$8(this, _queue).push(resolve)).finally(() => {
|
295
|
+
this.started--;
|
296
|
+
this.running++;
|
297
|
+
}).then(() => task()).finally(() => {
|
298
|
+
this.running--;
|
299
|
+
const next = __privateGet$8(this, _queue).shift();
|
300
|
+
if (next !== void 0) {
|
301
|
+
this.started++;
|
302
|
+
next();
|
303
|
+
}
|
304
|
+
});
|
305
|
+
if (this.running + this.started < __privateGet$8(this, _concurrency)) {
|
306
|
+
const next = __privateGet$8(this, _queue).shift();
|
307
|
+
if (next !== void 0) {
|
308
|
+
this.started++;
|
309
|
+
next();
|
310
|
+
}
|
311
|
+
}
|
312
|
+
return promise;
|
313
|
+
};
|
80
314
|
|
81
|
-
|
315
|
+
function generateUUID() {
|
316
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
317
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
318
|
+
return v.toString(16);
|
319
|
+
});
|
320
|
+
}
|
321
|
+
|
322
|
+
async function getBytes(stream, onChunk) {
|
323
|
+
const reader = stream.getReader();
|
324
|
+
let result;
|
325
|
+
while (!(result = await reader.read()).done) {
|
326
|
+
onChunk(result.value);
|
327
|
+
}
|
328
|
+
}
|
329
|
+
function getLines(onLine) {
|
330
|
+
let buffer;
|
331
|
+
let position;
|
332
|
+
let fieldLength;
|
333
|
+
let discardTrailingNewline = false;
|
334
|
+
return function onChunk(arr) {
|
335
|
+
if (buffer === void 0) {
|
336
|
+
buffer = arr;
|
337
|
+
position = 0;
|
338
|
+
fieldLength = -1;
|
339
|
+
} else {
|
340
|
+
buffer = concat(buffer, arr);
|
341
|
+
}
|
342
|
+
const bufLength = buffer.length;
|
343
|
+
let lineStart = 0;
|
344
|
+
while (position < bufLength) {
|
345
|
+
if (discardTrailingNewline) {
|
346
|
+
if (buffer[position] === 10 /* NewLine */) {
|
347
|
+
lineStart = ++position;
|
348
|
+
}
|
349
|
+
discardTrailingNewline = false;
|
350
|
+
}
|
351
|
+
let lineEnd = -1;
|
352
|
+
for (; position < bufLength && lineEnd === -1; ++position) {
|
353
|
+
switch (buffer[position]) {
|
354
|
+
case 58 /* Colon */:
|
355
|
+
if (fieldLength === -1) {
|
356
|
+
fieldLength = position - lineStart;
|
357
|
+
}
|
358
|
+
break;
|
359
|
+
case 13 /* CarriageReturn */:
|
360
|
+
discardTrailingNewline = true;
|
361
|
+
case 10 /* NewLine */:
|
362
|
+
lineEnd = position;
|
363
|
+
break;
|
364
|
+
}
|
365
|
+
}
|
366
|
+
if (lineEnd === -1) {
|
367
|
+
break;
|
368
|
+
}
|
369
|
+
onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
|
370
|
+
lineStart = position;
|
371
|
+
fieldLength = -1;
|
372
|
+
}
|
373
|
+
if (lineStart === bufLength) {
|
374
|
+
buffer = void 0;
|
375
|
+
} else if (lineStart !== 0) {
|
376
|
+
buffer = buffer.subarray(lineStart);
|
377
|
+
position -= lineStart;
|
378
|
+
}
|
379
|
+
};
|
380
|
+
}
|
381
|
+
function getMessages(onId, onRetry, onMessage) {
|
382
|
+
let message = newMessage();
|
383
|
+
const decoder = new TextDecoder();
|
384
|
+
return function onLine(line, fieldLength) {
|
385
|
+
if (line.length === 0) {
|
386
|
+
onMessage?.(message);
|
387
|
+
message = newMessage();
|
388
|
+
} else if (fieldLength > 0) {
|
389
|
+
const field = decoder.decode(line.subarray(0, fieldLength));
|
390
|
+
const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
|
391
|
+
const value = decoder.decode(line.subarray(valueOffset));
|
392
|
+
switch (field) {
|
393
|
+
case "data":
|
394
|
+
message.data = message.data ? message.data + "\n" + value : value;
|
395
|
+
break;
|
396
|
+
case "event":
|
397
|
+
message.event = value;
|
398
|
+
break;
|
399
|
+
case "id":
|
400
|
+
onId(message.id = value);
|
401
|
+
break;
|
402
|
+
case "retry":
|
403
|
+
const retry = parseInt(value, 10);
|
404
|
+
if (!isNaN(retry)) {
|
405
|
+
onRetry(message.retry = retry);
|
406
|
+
}
|
407
|
+
break;
|
408
|
+
}
|
409
|
+
}
|
410
|
+
};
|
411
|
+
}
|
412
|
+
function concat(a, b) {
|
413
|
+
const res = new Uint8Array(a.length + b.length);
|
414
|
+
res.set(a);
|
415
|
+
res.set(b, a.length);
|
416
|
+
return res;
|
417
|
+
}
|
418
|
+
function newMessage() {
|
419
|
+
return {
|
420
|
+
data: "",
|
421
|
+
event: "",
|
422
|
+
id: "",
|
423
|
+
retry: void 0
|
424
|
+
};
|
425
|
+
}
|
426
|
+
const EventStreamContentType = "text/event-stream";
|
427
|
+
const LastEventId = "last-event-id";
|
428
|
+
function fetchEventSource(input, {
|
429
|
+
signal: inputSignal,
|
430
|
+
headers: inputHeaders,
|
431
|
+
onopen: inputOnOpen,
|
432
|
+
onmessage,
|
433
|
+
onclose,
|
434
|
+
onerror,
|
435
|
+
fetch: inputFetch,
|
436
|
+
...rest
|
437
|
+
}) {
|
438
|
+
return new Promise((resolve, reject) => {
|
439
|
+
const headers = { ...inputHeaders };
|
440
|
+
if (!headers.accept) {
|
441
|
+
headers.accept = EventStreamContentType;
|
442
|
+
}
|
443
|
+
let curRequestController;
|
444
|
+
function dispose() {
|
445
|
+
curRequestController.abort();
|
446
|
+
}
|
447
|
+
inputSignal?.addEventListener("abort", () => {
|
448
|
+
dispose();
|
449
|
+
resolve();
|
450
|
+
});
|
451
|
+
const fetchImpl = inputFetch ?? fetch;
|
452
|
+
const onopen = inputOnOpen ?? defaultOnOpen;
|
453
|
+
async function create() {
|
454
|
+
curRequestController = new AbortController();
|
455
|
+
try {
|
456
|
+
const response = await fetchImpl(input, {
|
457
|
+
...rest,
|
458
|
+
headers,
|
459
|
+
signal: curRequestController.signal
|
460
|
+
});
|
461
|
+
await onopen(response);
|
462
|
+
await getBytes(
|
463
|
+
response.body,
|
464
|
+
getLines(
|
465
|
+
getMessages(
|
466
|
+
(id) => {
|
467
|
+
if (id) {
|
468
|
+
headers[LastEventId] = id;
|
469
|
+
} else {
|
470
|
+
delete headers[LastEventId];
|
471
|
+
}
|
472
|
+
},
|
473
|
+
(_retry) => {
|
474
|
+
},
|
475
|
+
onmessage
|
476
|
+
)
|
477
|
+
)
|
478
|
+
);
|
479
|
+
onclose?.();
|
480
|
+
dispose();
|
481
|
+
resolve();
|
482
|
+
} catch (err) {
|
483
|
+
}
|
484
|
+
}
|
485
|
+
create();
|
486
|
+
});
|
487
|
+
}
|
488
|
+
function defaultOnOpen(response) {
|
489
|
+
const contentType = response.headers?.get("content-type");
|
490
|
+
if (!contentType?.startsWith(EventStreamContentType)) {
|
491
|
+
throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
|
492
|
+
}
|
493
|
+
}
|
494
|
+
|
495
|
+
const VERSION = "0.23.3";
|
82
496
|
|
83
497
|
class ErrorWithCause extends Error {
|
84
498
|
constructor(message, options) {
|
@@ -89,7 +503,7 @@ class FetcherError extends ErrorWithCause {
|
|
89
503
|
constructor(status, data, requestId) {
|
90
504
|
super(getMessage(data));
|
91
505
|
this.status = status;
|
92
|
-
this.errors = isBulkError(data) ? data.errors :
|
506
|
+
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
93
507
|
this.requestId = requestId;
|
94
508
|
if (data instanceof Error) {
|
95
509
|
this.stack = data.stack;
|
@@ -121,6 +535,7 @@ function getMessage(data) {
|
|
121
535
|
}
|
122
536
|
}
|
123
537
|
|
538
|
+
const pool = new ApiRequestPool();
|
124
539
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
125
540
|
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
126
541
|
if (value === void 0 || value === null)
|
@@ -129,316 +544,376 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
129
544
|
}, {});
|
130
545
|
const query = new URLSearchParams(cleanQueryParams).toString();
|
131
546
|
const queryString = query.length > 0 ? `?${query}` : "";
|
132
|
-
|
547
|
+
const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
|
548
|
+
return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
|
549
|
+
}, {});
|
550
|
+
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
133
551
|
};
|
134
552
|
function buildBaseUrl({
|
553
|
+
endpoint,
|
135
554
|
path,
|
136
555
|
workspacesApiUrl,
|
137
556
|
apiUrl,
|
138
|
-
pathParams
|
557
|
+
pathParams = {}
|
139
558
|
}) {
|
140
|
-
if (
|
141
|
-
|
142
|
-
|
143
|
-
|
559
|
+
if (endpoint === "dataPlane") {
|
560
|
+
const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
561
|
+
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
562
|
+
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
563
|
+
}
|
564
|
+
return `${apiUrl}${path}`;
|
144
565
|
}
|
145
566
|
function hostHeader(url) {
|
146
567
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
147
568
|
const { groups } = pattern.exec(url) ?? {};
|
148
569
|
return groups?.host ? { Host: groups.host } : {};
|
149
570
|
}
|
571
|
+
const defaultClientID = generateUUID();
|
150
572
|
async function fetch$1({
|
151
573
|
url: path,
|
152
574
|
method,
|
153
575
|
body,
|
154
|
-
headers,
|
576
|
+
headers: customHeaders,
|
155
577
|
pathParams,
|
156
578
|
queryParams,
|
157
|
-
|
579
|
+
fetch: fetch2,
|
158
580
|
apiKey,
|
581
|
+
endpoint,
|
159
582
|
apiUrl,
|
160
|
-
workspacesApiUrl
|
583
|
+
workspacesApiUrl,
|
584
|
+
trace,
|
585
|
+
signal,
|
586
|
+
clientID,
|
587
|
+
sessionID,
|
588
|
+
clientName,
|
589
|
+
xataAgentExtra,
|
590
|
+
fetchOptions = {}
|
161
591
|
}) {
|
162
|
-
|
592
|
+
pool.setFetch(fetch2);
|
593
|
+
return await trace(
|
594
|
+
`${method.toUpperCase()} ${path}`,
|
595
|
+
async ({ setAttributes }) => {
|
596
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
597
|
+
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
598
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
599
|
+
setAttributes({
|
600
|
+
[TraceAttributes.HTTP_URL]: url,
|
601
|
+
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
602
|
+
});
|
603
|
+
const xataAgent = compact([
|
604
|
+
["client", "TS_SDK"],
|
605
|
+
["version", VERSION],
|
606
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
607
|
+
...Object.entries(xataAgentExtra ?? {})
|
608
|
+
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
609
|
+
const headers = {
|
610
|
+
"Accept-Encoding": "identity",
|
611
|
+
"Content-Type": "application/json",
|
612
|
+
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
613
|
+
"X-Xata-Session-ID": sessionID ?? generateUUID(),
|
614
|
+
"X-Xata-Agent": xataAgent,
|
615
|
+
...customHeaders,
|
616
|
+
...hostHeader(fullUrl),
|
617
|
+
Authorization: `Bearer ${apiKey}`
|
618
|
+
};
|
619
|
+
const response = await pool.request(url, {
|
620
|
+
...fetchOptions,
|
621
|
+
method: method.toUpperCase(),
|
622
|
+
body: body ? JSON.stringify(body) : void 0,
|
623
|
+
headers,
|
624
|
+
signal
|
625
|
+
});
|
626
|
+
const { host, protocol } = parseUrl(response.url);
|
627
|
+
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
628
|
+
setAttributes({
|
629
|
+
[TraceAttributes.KIND]: "http",
|
630
|
+
[TraceAttributes.HTTP_REQUEST_ID]: requestId,
|
631
|
+
[TraceAttributes.HTTP_STATUS_CODE]: response.status,
|
632
|
+
[TraceAttributes.HTTP_HOST]: host,
|
633
|
+
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
634
|
+
});
|
635
|
+
if (response.status === 204) {
|
636
|
+
return {};
|
637
|
+
}
|
638
|
+
if (response.status === 429) {
|
639
|
+
throw new FetcherError(response.status, "Rate limit exceeded", requestId);
|
640
|
+
}
|
641
|
+
try {
|
642
|
+
const jsonResponse = await response.json();
|
643
|
+
if (response.ok) {
|
644
|
+
return jsonResponse;
|
645
|
+
}
|
646
|
+
throw new FetcherError(response.status, jsonResponse, requestId);
|
647
|
+
} catch (error) {
|
648
|
+
throw new FetcherError(response.status, error, requestId);
|
649
|
+
}
|
650
|
+
},
|
651
|
+
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
652
|
+
);
|
653
|
+
}
|
654
|
+
function fetchSSERequest({
|
655
|
+
url: path,
|
656
|
+
method,
|
657
|
+
body,
|
658
|
+
headers: customHeaders,
|
659
|
+
pathParams,
|
660
|
+
queryParams,
|
661
|
+
fetch: fetch2,
|
662
|
+
apiKey,
|
663
|
+
endpoint,
|
664
|
+
apiUrl,
|
665
|
+
workspacesApiUrl,
|
666
|
+
onMessage,
|
667
|
+
onError,
|
668
|
+
onClose,
|
669
|
+
signal,
|
670
|
+
clientID,
|
671
|
+
sessionID,
|
672
|
+
clientName,
|
673
|
+
xataAgentExtra
|
674
|
+
}) {
|
675
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
163
676
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
164
677
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
165
|
-
|
166
|
-
method
|
167
|
-
body:
|
678
|
+
void fetchEventSource(url, {
|
679
|
+
method,
|
680
|
+
body: JSON.stringify(body),
|
681
|
+
fetch: fetch2,
|
682
|
+
signal,
|
168
683
|
headers: {
|
169
|
-
"
|
170
|
-
"
|
171
|
-
|
172
|
-
|
173
|
-
|
684
|
+
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
685
|
+
"X-Xata-Session-ID": sessionID ?? generateUUID(),
|
686
|
+
"X-Xata-Agent": compact([
|
687
|
+
["client", "TS_SDK"],
|
688
|
+
["version", VERSION],
|
689
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
690
|
+
...Object.entries(xataAgentExtra ?? {})
|
691
|
+
]).map(([key, value]) => `${key}=${value}`).join("; "),
|
692
|
+
...customHeaders,
|
693
|
+
Authorization: `Bearer ${apiKey}`,
|
694
|
+
"Content-Type": "application/json"
|
695
|
+
},
|
696
|
+
onmessage(ev) {
|
697
|
+
onMessage?.(JSON.parse(ev.data));
|
698
|
+
},
|
699
|
+
onerror(ev) {
|
700
|
+
onError?.(JSON.parse(ev.data));
|
701
|
+
},
|
702
|
+
onclose() {
|
703
|
+
onClose?.();
|
174
704
|
}
|
175
705
|
});
|
176
|
-
|
177
|
-
|
178
|
-
}
|
179
|
-
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
706
|
+
}
|
707
|
+
function parseUrl(url) {
|
180
708
|
try {
|
181
|
-
const
|
182
|
-
|
183
|
-
return jsonResponse;
|
184
|
-
}
|
185
|
-
throw new FetcherError(response.status, jsonResponse, requestId);
|
709
|
+
const { host, protocol } = new URL(url);
|
710
|
+
return { host, protocol };
|
186
711
|
} catch (error) {
|
187
|
-
|
712
|
+
return {};
|
188
713
|
}
|
189
714
|
}
|
190
715
|
|
191
|
-
const
|
192
|
-
|
193
|
-
const
|
194
|
-
const getUserAPIKeys = (variables) => fetch$1({
|
195
|
-
url: "/user/keys",
|
196
|
-
method: "get",
|
197
|
-
...variables
|
198
|
-
});
|
199
|
-
const createUserAPIKey = (variables) => fetch$1({
|
200
|
-
url: "/user/keys/{keyName}",
|
201
|
-
method: "post",
|
202
|
-
...variables
|
203
|
-
});
|
204
|
-
const deleteUserAPIKey = (variables) => fetch$1({
|
205
|
-
url: "/user/keys/{keyName}",
|
206
|
-
method: "delete",
|
207
|
-
...variables
|
208
|
-
});
|
209
|
-
const createWorkspace = (variables) => fetch$1({
|
210
|
-
url: "/workspaces",
|
211
|
-
method: "post",
|
212
|
-
...variables
|
213
|
-
});
|
214
|
-
const getWorkspacesList = (variables) => fetch$1({
|
215
|
-
url: "/workspaces",
|
216
|
-
method: "get",
|
217
|
-
...variables
|
218
|
-
});
|
219
|
-
const getWorkspace = (variables) => fetch$1({
|
220
|
-
url: "/workspaces/{workspaceId}",
|
221
|
-
method: "get",
|
222
|
-
...variables
|
223
|
-
});
|
224
|
-
const updateWorkspace = (variables) => fetch$1({
|
225
|
-
url: "/workspaces/{workspaceId}",
|
226
|
-
method: "put",
|
227
|
-
...variables
|
228
|
-
});
|
229
|
-
const deleteWorkspace = (variables) => fetch$1({
|
230
|
-
url: "/workspaces/{workspaceId}",
|
231
|
-
method: "delete",
|
232
|
-
...variables
|
233
|
-
});
|
234
|
-
const getWorkspaceMembersList = (variables) => fetch$1({
|
235
|
-
url: "/workspaces/{workspaceId}/members",
|
236
|
-
method: "get",
|
237
|
-
...variables
|
238
|
-
});
|
239
|
-
const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
|
240
|
-
const removeWorkspaceMember = (variables) => fetch$1({
|
241
|
-
url: "/workspaces/{workspaceId}/members/{userId}",
|
242
|
-
method: "delete",
|
243
|
-
...variables
|
244
|
-
});
|
245
|
-
const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
|
246
|
-
const cancelWorkspaceMemberInvite = (variables) => fetch$1({
|
247
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
248
|
-
method: "delete",
|
249
|
-
...variables
|
250
|
-
});
|
251
|
-
const resendWorkspaceMemberInvite = (variables) => fetch$1({
|
252
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
|
253
|
-
method: "post",
|
254
|
-
...variables
|
255
|
-
});
|
256
|
-
const acceptWorkspaceMemberInvite = (variables) => fetch$1({
|
257
|
-
url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
|
258
|
-
method: "post",
|
259
|
-
...variables
|
260
|
-
});
|
261
|
-
const getDatabaseList = (variables) => fetch$1({
|
262
|
-
url: "/dbs",
|
263
|
-
method: "get",
|
264
|
-
...variables
|
265
|
-
});
|
266
|
-
const getBranchList = (variables) => fetch$1({
|
267
|
-
url: "/dbs/{dbName}",
|
268
|
-
method: "get",
|
269
|
-
...variables
|
270
|
-
});
|
271
|
-
const createDatabase = (variables) => fetch$1({
|
272
|
-
url: "/dbs/{dbName}",
|
273
|
-
method: "put",
|
274
|
-
...variables
|
275
|
-
});
|
276
|
-
const deleteDatabase = (variables) => fetch$1({
|
716
|
+
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
717
|
+
|
718
|
+
const getBranchList = (variables, signal) => dataPlaneFetch({
|
277
719
|
url: "/dbs/{dbName}",
|
278
|
-
method: "delete",
|
279
|
-
...variables
|
280
|
-
});
|
281
|
-
const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
|
282
|
-
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
283
|
-
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
284
|
-
const resolveBranch = (variables) => fetch$1({
|
285
|
-
url: "/dbs/{dbName}/resolveBranch",
|
286
720
|
method: "get",
|
287
|
-
...variables
|
721
|
+
...variables,
|
722
|
+
signal
|
288
723
|
});
|
289
|
-
const getBranchDetails = (variables) =>
|
724
|
+
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
290
725
|
url: "/db/{dbBranchName}",
|
291
726
|
method: "get",
|
292
|
-
...variables
|
727
|
+
...variables,
|
728
|
+
signal
|
293
729
|
});
|
294
|
-
const createBranch = (variables) =>
|
295
|
-
|
296
|
-
method: "put",
|
297
|
-
...variables
|
298
|
-
});
|
299
|
-
const deleteBranch = (variables) => fetch$1({
|
730
|
+
const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
|
731
|
+
const deleteBranch = (variables, signal) => dataPlaneFetch({
|
300
732
|
url: "/db/{dbBranchName}",
|
301
733
|
method: "delete",
|
302
|
-
...variables
|
734
|
+
...variables,
|
735
|
+
signal
|
736
|
+
});
|
737
|
+
const copyBranch = (variables, signal) => dataPlaneFetch({
|
738
|
+
url: "/db/{dbBranchName}/copy",
|
739
|
+
method: "post",
|
740
|
+
...variables,
|
741
|
+
signal
|
303
742
|
});
|
304
|
-
const updateBranchMetadata = (variables) =>
|
743
|
+
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
305
744
|
url: "/db/{dbBranchName}/metadata",
|
306
745
|
method: "put",
|
307
|
-
...variables
|
746
|
+
...variables,
|
747
|
+
signal
|
308
748
|
});
|
309
|
-
const getBranchMetadata = (variables) =>
|
749
|
+
const getBranchMetadata = (variables, signal) => dataPlaneFetch({
|
310
750
|
url: "/db/{dbBranchName}/metadata",
|
311
751
|
method: "get",
|
312
|
-
...variables
|
752
|
+
...variables,
|
753
|
+
signal
|
313
754
|
});
|
314
|
-
const
|
315
|
-
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
316
|
-
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
317
|
-
const getBranchStats = (variables) => fetch$1({
|
755
|
+
const getBranchStats = (variables, signal) => dataPlaneFetch({
|
318
756
|
url: "/db/{dbBranchName}/stats",
|
319
757
|
method: "get",
|
320
|
-
...variables
|
758
|
+
...variables,
|
759
|
+
signal
|
760
|
+
});
|
761
|
+
const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
|
762
|
+
const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
|
763
|
+
const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
|
764
|
+
const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
|
765
|
+
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
766
|
+
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
767
|
+
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
768
|
+
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
769
|
+
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
770
|
+
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
771
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
772
|
+
method: "get",
|
773
|
+
...variables,
|
774
|
+
signal
|
775
|
+
});
|
776
|
+
const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
|
777
|
+
const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
|
778
|
+
const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
|
779
|
+
const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
|
780
|
+
const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
|
781
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
782
|
+
method: "post",
|
783
|
+
...variables,
|
784
|
+
signal
|
321
785
|
});
|
322
|
-
const
|
786
|
+
const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
|
787
|
+
const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
|
788
|
+
const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
|
789
|
+
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
790
|
+
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
791
|
+
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
792
|
+
const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
|
793
|
+
const createTable = (variables, signal) => dataPlaneFetch({
|
323
794
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
324
795
|
method: "put",
|
325
|
-
...variables
|
796
|
+
...variables,
|
797
|
+
signal
|
326
798
|
});
|
327
|
-
const deleteTable = (variables) =>
|
799
|
+
const deleteTable = (variables, signal) => dataPlaneFetch({
|
328
800
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
329
801
|
method: "delete",
|
330
|
-
...variables
|
802
|
+
...variables,
|
803
|
+
signal
|
331
804
|
});
|
332
|
-
const updateTable = (variables) =>
|
333
|
-
|
334
|
-
method: "patch",
|
335
|
-
...variables
|
336
|
-
});
|
337
|
-
const getTableSchema = (variables) => fetch$1({
|
805
|
+
const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
|
806
|
+
const getTableSchema = (variables, signal) => dataPlaneFetch({
|
338
807
|
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
339
808
|
method: "get",
|
340
|
-
...variables
|
341
|
-
|
342
|
-
const setTableSchema = (variables) => fetch$1({
|
343
|
-
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
344
|
-
method: "put",
|
345
|
-
...variables
|
809
|
+
...variables,
|
810
|
+
signal
|
346
811
|
});
|
347
|
-
const
|
812
|
+
const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
|
813
|
+
const getTableColumns = (variables, signal) => dataPlaneFetch({
|
348
814
|
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
349
815
|
method: "get",
|
350
|
-
...variables
|
816
|
+
...variables,
|
817
|
+
signal
|
351
818
|
});
|
352
|
-
const addTableColumn = (variables) =>
|
353
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
354
|
-
|
355
|
-
|
356
|
-
});
|
357
|
-
const getColumn = (variables) => fetch$1({
|
819
|
+
const addTableColumn = (variables, signal) => dataPlaneFetch(
|
820
|
+
{ url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
|
821
|
+
);
|
822
|
+
const getColumn = (variables, signal) => dataPlaneFetch({
|
358
823
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
359
824
|
method: "get",
|
360
|
-
...variables
|
361
|
-
|
362
|
-
const deleteColumn = (variables) => fetch$1({
|
363
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
364
|
-
method: "delete",
|
365
|
-
...variables
|
825
|
+
...variables,
|
826
|
+
signal
|
366
827
|
});
|
367
|
-
const updateColumn = (variables) =>
|
828
|
+
const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
|
829
|
+
const deleteColumn = (variables, signal) => dataPlaneFetch({
|
368
830
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
369
|
-
method: "patch",
|
370
|
-
...variables
|
371
|
-
});
|
372
|
-
const insertRecord = (variables) => fetch$1({
|
373
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data",
|
374
|
-
method: "post",
|
375
|
-
...variables
|
376
|
-
});
|
377
|
-
const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
|
378
|
-
const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
|
379
|
-
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
380
|
-
const deleteRecord = (variables) => fetch$1({
|
381
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
382
831
|
method: "delete",
|
383
|
-
...variables
|
832
|
+
...variables,
|
833
|
+
signal
|
384
834
|
});
|
385
|
-
const
|
835
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
836
|
+
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
837
|
+
const getRecord = (variables, signal) => dataPlaneFetch({
|
386
838
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
387
839
|
method: "get",
|
388
|
-
...variables
|
840
|
+
...variables,
|
841
|
+
signal
|
389
842
|
});
|
390
|
-
const
|
391
|
-
const
|
843
|
+
const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
|
844
|
+
const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
|
845
|
+
const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
|
846
|
+
const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
|
847
|
+
const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
|
848
|
+
const queryTable = (variables, signal) => dataPlaneFetch({
|
392
849
|
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
393
850
|
method: "post",
|
394
|
-
...variables
|
851
|
+
...variables,
|
852
|
+
signal
|
395
853
|
});
|
396
|
-
const
|
854
|
+
const searchBranch = (variables, signal) => dataPlaneFetch({
|
855
|
+
url: "/db/{dbBranchName}/search",
|
856
|
+
method: "post",
|
857
|
+
...variables,
|
858
|
+
signal
|
859
|
+
});
|
860
|
+
const searchTable = (variables, signal) => dataPlaneFetch({
|
397
861
|
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
398
862
|
method: "post",
|
399
|
-
...variables
|
863
|
+
...variables,
|
864
|
+
signal
|
400
865
|
});
|
401
|
-
const
|
402
|
-
url: "/db/{dbBranchName}/
|
866
|
+
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
867
|
+
url: "/db/{dbBranchName}/sql",
|
403
868
|
method: "post",
|
404
|
-
...variables
|
869
|
+
...variables,
|
870
|
+
signal
|
405
871
|
});
|
406
|
-
const
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
removeWorkspaceMember,
|
417
|
-
inviteWorkspaceMember,
|
418
|
-
cancelWorkspaceMemberInvite,
|
419
|
-
resendWorkspaceMemberInvite,
|
420
|
-
acceptWorkspaceMemberInvite
|
421
|
-
},
|
422
|
-
database: {
|
423
|
-
getDatabaseList,
|
424
|
-
createDatabase,
|
425
|
-
deleteDatabase,
|
426
|
-
getGitBranchesMapping,
|
427
|
-
addGitBranchesEntry,
|
428
|
-
removeGitBranchesEntry,
|
429
|
-
resolveBranch
|
430
|
-
},
|
872
|
+
const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
|
873
|
+
const askTable = (variables, signal) => dataPlaneFetch({
|
874
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
875
|
+
method: "post",
|
876
|
+
...variables,
|
877
|
+
signal
|
878
|
+
});
|
879
|
+
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
880
|
+
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
881
|
+
const operationsByTag$2 = {
|
431
882
|
branch: {
|
432
883
|
getBranchList,
|
433
884
|
getBranchDetails,
|
434
885
|
createBranch,
|
435
886
|
deleteBranch,
|
887
|
+
copyBranch,
|
436
888
|
updateBranchMetadata,
|
437
889
|
getBranchMetadata,
|
890
|
+
getBranchStats,
|
891
|
+
getGitBranchesMapping,
|
892
|
+
addGitBranchesEntry,
|
893
|
+
removeGitBranchesEntry,
|
894
|
+
resolveBranch
|
895
|
+
},
|
896
|
+
migrations: {
|
438
897
|
getBranchMigrationHistory,
|
439
|
-
executeBranchMigrationPlan,
|
440
898
|
getBranchMigrationPlan,
|
441
|
-
|
899
|
+
executeBranchMigrationPlan,
|
900
|
+
getBranchSchemaHistory,
|
901
|
+
compareBranchWithUserSchema,
|
902
|
+
compareBranchSchemas,
|
903
|
+
updateBranchSchema,
|
904
|
+
previewBranchSchemaEdit,
|
905
|
+
applyBranchSchemaEdit,
|
906
|
+
pushBranchMigrations
|
907
|
+
},
|
908
|
+
migrationRequests: {
|
909
|
+
queryMigrationRequests,
|
910
|
+
createMigrationRequest,
|
911
|
+
getMigrationRequest,
|
912
|
+
updateMigrationRequest,
|
913
|
+
listMigrationRequestsCommits,
|
914
|
+
compareMigrationRequest,
|
915
|
+
getMigrationRequestIsMerged,
|
916
|
+
mergeMigrationRequest
|
442
917
|
},
|
443
918
|
table: {
|
444
919
|
createTable,
|
@@ -449,27 +924,175 @@ const operationsByTag = {
|
|
449
924
|
getTableColumns,
|
450
925
|
addTableColumn,
|
451
926
|
getColumn,
|
452
|
-
|
453
|
-
|
927
|
+
updateColumn,
|
928
|
+
deleteColumn
|
454
929
|
},
|
455
930
|
records: {
|
931
|
+
branchTransaction,
|
456
932
|
insertRecord,
|
933
|
+
getRecord,
|
457
934
|
insertRecordWithID,
|
458
935
|
updateRecordWithID,
|
459
936
|
upsertRecordWithID,
|
460
937
|
deleteRecord,
|
461
|
-
|
462
|
-
|
938
|
+
bulkInsertTableRecords
|
939
|
+
},
|
940
|
+
searchAndFilter: {
|
463
941
|
queryTable,
|
942
|
+
searchBranch,
|
464
943
|
searchTable,
|
465
|
-
|
944
|
+
sqlQuery,
|
945
|
+
vectorSearchTable,
|
946
|
+
askTable,
|
947
|
+
summarizeTable,
|
948
|
+
aggregateTable
|
949
|
+
}
|
950
|
+
};
|
951
|
+
|
952
|
+
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
953
|
+
|
954
|
+
const getUser = (variables, signal) => controlPlaneFetch({
|
955
|
+
url: "/user",
|
956
|
+
method: "get",
|
957
|
+
...variables,
|
958
|
+
signal
|
959
|
+
});
|
960
|
+
const updateUser = (variables, signal) => controlPlaneFetch({
|
961
|
+
url: "/user",
|
962
|
+
method: "put",
|
963
|
+
...variables,
|
964
|
+
signal
|
965
|
+
});
|
966
|
+
const deleteUser = (variables, signal) => controlPlaneFetch({
|
967
|
+
url: "/user",
|
968
|
+
method: "delete",
|
969
|
+
...variables,
|
970
|
+
signal
|
971
|
+
});
|
972
|
+
const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
|
973
|
+
url: "/user/keys",
|
974
|
+
method: "get",
|
975
|
+
...variables,
|
976
|
+
signal
|
977
|
+
});
|
978
|
+
const createUserAPIKey = (variables, signal) => controlPlaneFetch({
|
979
|
+
url: "/user/keys/{keyName}",
|
980
|
+
method: "post",
|
981
|
+
...variables,
|
982
|
+
signal
|
983
|
+
});
|
984
|
+
const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
985
|
+
url: "/user/keys/{keyName}",
|
986
|
+
method: "delete",
|
987
|
+
...variables,
|
988
|
+
signal
|
989
|
+
});
|
990
|
+
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
991
|
+
url: "/workspaces",
|
992
|
+
method: "get",
|
993
|
+
...variables,
|
994
|
+
signal
|
995
|
+
});
|
996
|
+
const createWorkspace = (variables, signal) => controlPlaneFetch({
|
997
|
+
url: "/workspaces",
|
998
|
+
method: "post",
|
999
|
+
...variables,
|
1000
|
+
signal
|
1001
|
+
});
|
1002
|
+
const getWorkspace = (variables, signal) => controlPlaneFetch({
|
1003
|
+
url: "/workspaces/{workspaceId}",
|
1004
|
+
method: "get",
|
1005
|
+
...variables,
|
1006
|
+
signal
|
1007
|
+
});
|
1008
|
+
const updateWorkspace = (variables, signal) => controlPlaneFetch({
|
1009
|
+
url: "/workspaces/{workspaceId}",
|
1010
|
+
method: "put",
|
1011
|
+
...variables,
|
1012
|
+
signal
|
1013
|
+
});
|
1014
|
+
const deleteWorkspace = (variables, signal) => controlPlaneFetch({
|
1015
|
+
url: "/workspaces/{workspaceId}",
|
1016
|
+
method: "delete",
|
1017
|
+
...variables,
|
1018
|
+
signal
|
1019
|
+
});
|
1020
|
+
const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
|
1021
|
+
const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
|
1022
|
+
const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
1023
|
+
url: "/workspaces/{workspaceId}/members/{userId}",
|
1024
|
+
method: "delete",
|
1025
|
+
...variables,
|
1026
|
+
signal
|
1027
|
+
});
|
1028
|
+
const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
|
1029
|
+
const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
|
1030
|
+
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
1031
|
+
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
1032
|
+
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
1033
|
+
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
1034
|
+
url: "/workspaces/{workspaceId}/dbs",
|
1035
|
+
method: "get",
|
1036
|
+
...variables,
|
1037
|
+
signal
|
1038
|
+
});
|
1039
|
+
const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
|
1040
|
+
const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
1041
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
1042
|
+
method: "delete",
|
1043
|
+
...variables,
|
1044
|
+
signal
|
1045
|
+
});
|
1046
|
+
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
1047
|
+
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
1048
|
+
const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
|
1049
|
+
const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
|
1050
|
+
const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
|
1051
|
+
const listRegions = (variables, signal) => controlPlaneFetch({
|
1052
|
+
url: "/workspaces/{workspaceId}/regions",
|
1053
|
+
method: "get",
|
1054
|
+
...variables,
|
1055
|
+
signal
|
1056
|
+
});
|
1057
|
+
const operationsByTag$1 = {
|
1058
|
+
users: { getUser, updateUser, deleteUser },
|
1059
|
+
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
1060
|
+
workspaces: {
|
1061
|
+
getWorkspacesList,
|
1062
|
+
createWorkspace,
|
1063
|
+
getWorkspace,
|
1064
|
+
updateWorkspace,
|
1065
|
+
deleteWorkspace,
|
1066
|
+
getWorkspaceMembersList,
|
1067
|
+
updateWorkspaceMemberRole,
|
1068
|
+
removeWorkspaceMember
|
1069
|
+
},
|
1070
|
+
invites: {
|
1071
|
+
inviteWorkspaceMember,
|
1072
|
+
updateWorkspaceMemberInvite,
|
1073
|
+
cancelWorkspaceMemberInvite,
|
1074
|
+
acceptWorkspaceMemberInvite,
|
1075
|
+
resendWorkspaceMemberInvite
|
1076
|
+
},
|
1077
|
+
databases: {
|
1078
|
+
getDatabaseList,
|
1079
|
+
createDatabase,
|
1080
|
+
deleteDatabase,
|
1081
|
+
getDatabaseMetadata,
|
1082
|
+
updateDatabaseMetadata,
|
1083
|
+
getDatabaseGithubSettings,
|
1084
|
+
updateDatabaseGithubSettings,
|
1085
|
+
deleteDatabaseGithubSettings,
|
1086
|
+
listRegions
|
466
1087
|
}
|
467
1088
|
};
|
468
1089
|
|
1090
|
+
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
1091
|
+
|
469
1092
|
function getHostUrl(provider, type) {
|
470
|
-
if (
|
1093
|
+
if (isHostProviderAlias(provider)) {
|
471
1094
|
return providers[provider][type];
|
472
|
-
} else if (
|
1095
|
+
} else if (isHostProviderBuilder(provider)) {
|
473
1096
|
return provider[type];
|
474
1097
|
}
|
475
1098
|
throw new Error("Invalid API provider");
|
@@ -477,19 +1100,49 @@ function getHostUrl(provider, type) {
|
|
477
1100
|
const providers = {
|
478
1101
|
production: {
|
479
1102
|
main: "https://api.xata.io",
|
480
|
-
workspaces: "https://{workspaceId}.xata.sh"
|
1103
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
481
1104
|
},
|
482
1105
|
staging: {
|
483
|
-
main: "https://staging.
|
484
|
-
workspaces: "https://{workspaceId}.staging.
|
1106
|
+
main: "https://api.staging-xata.dev",
|
1107
|
+
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
1108
|
+
},
|
1109
|
+
dev: {
|
1110
|
+
main: "https://api.dev-xata.dev",
|
1111
|
+
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
485
1112
|
}
|
486
1113
|
};
|
487
|
-
function
|
1114
|
+
function isHostProviderAlias(alias) {
|
488
1115
|
return isString(alias) && Object.keys(providers).includes(alias);
|
489
1116
|
}
|
490
|
-
function
|
1117
|
+
function isHostProviderBuilder(builder) {
|
491
1118
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
492
1119
|
}
|
1120
|
+
function parseProviderString(provider = "production") {
|
1121
|
+
if (isHostProviderAlias(provider)) {
|
1122
|
+
return provider;
|
1123
|
+
}
|
1124
|
+
const [main, workspaces] = provider.split(",");
|
1125
|
+
if (!main || !workspaces)
|
1126
|
+
return null;
|
1127
|
+
return { main, workspaces };
|
1128
|
+
}
|
1129
|
+
function buildProviderString(provider) {
|
1130
|
+
if (isHostProviderAlias(provider))
|
1131
|
+
return provider;
|
1132
|
+
return `${provider.main},${provider.workspaces}`;
|
1133
|
+
}
|
1134
|
+
function parseWorkspacesUrlParts(url) {
|
1135
|
+
if (!isString(url))
|
1136
|
+
return null;
|
1137
|
+
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
1138
|
+
const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
|
1139
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
|
1140
|
+
const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
|
1141
|
+
const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
|
1142
|
+
if (!match)
|
1143
|
+
return null;
|
1144
|
+
return { workspace: match[1], region: match[2] };
|
1145
|
+
}
|
493
1146
|
|
494
1147
|
var __accessCheck$7 = (obj, member, msg) => {
|
495
1148
|
if (!member.has(obj))
|
@@ -515,15 +1168,21 @@ class XataApiClient {
|
|
515
1168
|
__privateAdd$7(this, _extraProps, void 0);
|
516
1169
|
__privateAdd$7(this, _namespaces, {});
|
517
1170
|
const provider = options.host ?? "production";
|
518
|
-
const apiKey = options
|
1171
|
+
const apiKey = options.apiKey ?? getAPIKey();
|
1172
|
+
const trace = options.trace ?? defaultTrace;
|
1173
|
+
const clientID = generateUUID();
|
519
1174
|
if (!apiKey) {
|
520
1175
|
throw new Error("Could not resolve a valid apiKey");
|
521
1176
|
}
|
522
1177
|
__privateSet$7(this, _extraProps, {
|
523
1178
|
apiUrl: getHostUrl(provider, "main"),
|
524
1179
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
525
|
-
|
526
|
-
apiKey
|
1180
|
+
fetch: getFetchImplementation(options.fetch),
|
1181
|
+
apiKey,
|
1182
|
+
trace,
|
1183
|
+
clientName: options.clientName,
|
1184
|
+
xataAgentExtra: options.xataAgentExtra,
|
1185
|
+
clientID
|
527
1186
|
});
|
528
1187
|
}
|
529
1188
|
get user() {
|
@@ -531,21 +1190,41 @@ class XataApiClient {
|
|
531
1190
|
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
532
1191
|
return __privateGet$7(this, _namespaces).user;
|
533
1192
|
}
|
1193
|
+
get authentication() {
|
1194
|
+
if (!__privateGet$7(this, _namespaces).authentication)
|
1195
|
+
__privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
|
1196
|
+
return __privateGet$7(this, _namespaces).authentication;
|
1197
|
+
}
|
534
1198
|
get workspaces() {
|
535
1199
|
if (!__privateGet$7(this, _namespaces).workspaces)
|
536
1200
|
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
537
1201
|
return __privateGet$7(this, _namespaces).workspaces;
|
538
1202
|
}
|
539
|
-
get
|
540
|
-
if (!__privateGet$7(this, _namespaces).
|
541
|
-
__privateGet$7(this, _namespaces).
|
542
|
-
return __privateGet$7(this, _namespaces).
|
1203
|
+
get invites() {
|
1204
|
+
if (!__privateGet$7(this, _namespaces).invites)
|
1205
|
+
__privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
|
1206
|
+
return __privateGet$7(this, _namespaces).invites;
|
1207
|
+
}
|
1208
|
+
get database() {
|
1209
|
+
if (!__privateGet$7(this, _namespaces).database)
|
1210
|
+
__privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
|
1211
|
+
return __privateGet$7(this, _namespaces).database;
|
543
1212
|
}
|
544
1213
|
get branches() {
|
545
1214
|
if (!__privateGet$7(this, _namespaces).branches)
|
546
1215
|
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
547
1216
|
return __privateGet$7(this, _namespaces).branches;
|
548
1217
|
}
|
1218
|
+
get migrations() {
|
1219
|
+
if (!__privateGet$7(this, _namespaces).migrations)
|
1220
|
+
__privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
|
1221
|
+
return __privateGet$7(this, _namespaces).migrations;
|
1222
|
+
}
|
1223
|
+
get migrationRequests() {
|
1224
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
1225
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
1226
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
1227
|
+
}
|
549
1228
|
get tables() {
|
550
1229
|
if (!__privateGet$7(this, _namespaces).tables)
|
551
1230
|
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
@@ -556,6 +1235,11 @@ class XataApiClient {
|
|
556
1235
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
557
1236
|
return __privateGet$7(this, _namespaces).records;
|
558
1237
|
}
|
1238
|
+
get searchAndFilter() {
|
1239
|
+
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
1240
|
+
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
1241
|
+
return __privateGet$7(this, _namespaces).searchAndFilter;
|
1242
|
+
}
|
559
1243
|
}
|
560
1244
|
_extraProps = new WeakMap();
|
561
1245
|
_namespaces = new WeakMap();
|
@@ -566,24 +1250,29 @@ class UserApi {
|
|
566
1250
|
getUser() {
|
567
1251
|
return operationsByTag.users.getUser({ ...this.extraProps });
|
568
1252
|
}
|
569
|
-
updateUser(user) {
|
1253
|
+
updateUser({ user }) {
|
570
1254
|
return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
|
571
1255
|
}
|
572
1256
|
deleteUser() {
|
573
1257
|
return operationsByTag.users.deleteUser({ ...this.extraProps });
|
574
1258
|
}
|
1259
|
+
}
|
1260
|
+
class AuthenticationApi {
|
1261
|
+
constructor(extraProps) {
|
1262
|
+
this.extraProps = extraProps;
|
1263
|
+
}
|
575
1264
|
getUserAPIKeys() {
|
576
|
-
return operationsByTag.
|
1265
|
+
return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
|
577
1266
|
}
|
578
|
-
createUserAPIKey(
|
579
|
-
return operationsByTag.
|
580
|
-
pathParams: { keyName },
|
1267
|
+
createUserAPIKey({ name }) {
|
1268
|
+
return operationsByTag.authentication.createUserAPIKey({
|
1269
|
+
pathParams: { keyName: name },
|
581
1270
|
...this.extraProps
|
582
1271
|
});
|
583
1272
|
}
|
584
|
-
deleteUserAPIKey(
|
585
|
-
return operationsByTag.
|
586
|
-
pathParams: { keyName },
|
1273
|
+
deleteUserAPIKey({ name }) {
|
1274
|
+
return operationsByTag.authentication.deleteUserAPIKey({
|
1275
|
+
pathParams: { keyName: name },
|
587
1276
|
...this.extraProps
|
588
1277
|
});
|
589
1278
|
}
|
@@ -592,357 +1281,1009 @@ class WorkspaceApi {
|
|
592
1281
|
constructor(extraProps) {
|
593
1282
|
this.extraProps = extraProps;
|
594
1283
|
}
|
595
|
-
|
1284
|
+
getWorkspacesList() {
|
1285
|
+
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
1286
|
+
}
|
1287
|
+
createWorkspace({ data }) {
|
596
1288
|
return operationsByTag.workspaces.createWorkspace({
|
597
|
-
body:
|
1289
|
+
body: data,
|
598
1290
|
...this.extraProps
|
599
1291
|
});
|
600
1292
|
}
|
601
|
-
|
602
|
-
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
603
|
-
}
|
604
|
-
getWorkspace(workspaceId) {
|
1293
|
+
getWorkspace({ workspace }) {
|
605
1294
|
return operationsByTag.workspaces.getWorkspace({
|
606
|
-
pathParams: { workspaceId },
|
1295
|
+
pathParams: { workspaceId: workspace },
|
607
1296
|
...this.extraProps
|
608
1297
|
});
|
609
1298
|
}
|
610
|
-
updateWorkspace(
|
1299
|
+
updateWorkspace({
|
1300
|
+
workspace,
|
1301
|
+
update
|
1302
|
+
}) {
|
611
1303
|
return operationsByTag.workspaces.updateWorkspace({
|
612
|
-
pathParams: { workspaceId },
|
613
|
-
body:
|
1304
|
+
pathParams: { workspaceId: workspace },
|
1305
|
+
body: update,
|
614
1306
|
...this.extraProps
|
615
1307
|
});
|
616
1308
|
}
|
617
|
-
deleteWorkspace(
|
1309
|
+
deleteWorkspace({ workspace }) {
|
618
1310
|
return operationsByTag.workspaces.deleteWorkspace({
|
619
|
-
pathParams: { workspaceId },
|
1311
|
+
pathParams: { workspaceId: workspace },
|
620
1312
|
...this.extraProps
|
621
1313
|
});
|
622
1314
|
}
|
623
|
-
getWorkspaceMembersList(
|
1315
|
+
getWorkspaceMembersList({ workspace }) {
|
624
1316
|
return operationsByTag.workspaces.getWorkspaceMembersList({
|
625
|
-
pathParams: { workspaceId },
|
1317
|
+
pathParams: { workspaceId: workspace },
|
626
1318
|
...this.extraProps
|
627
1319
|
});
|
628
1320
|
}
|
629
|
-
updateWorkspaceMemberRole(
|
1321
|
+
updateWorkspaceMemberRole({
|
1322
|
+
workspace,
|
1323
|
+
user,
|
1324
|
+
role
|
1325
|
+
}) {
|
630
1326
|
return operationsByTag.workspaces.updateWorkspaceMemberRole({
|
631
|
-
pathParams: { workspaceId, userId },
|
1327
|
+
pathParams: { workspaceId: workspace, userId: user },
|
632
1328
|
body: { role },
|
633
1329
|
...this.extraProps
|
634
1330
|
});
|
635
1331
|
}
|
636
|
-
removeWorkspaceMember(
|
1332
|
+
removeWorkspaceMember({
|
1333
|
+
workspace,
|
1334
|
+
user
|
1335
|
+
}) {
|
637
1336
|
return operationsByTag.workspaces.removeWorkspaceMember({
|
638
|
-
pathParams: { workspaceId, userId },
|
1337
|
+
pathParams: { workspaceId: workspace, userId: user },
|
639
1338
|
...this.extraProps
|
640
1339
|
});
|
641
1340
|
}
|
642
|
-
|
643
|
-
|
644
|
-
|
1341
|
+
}
|
1342
|
+
class InvitesApi {
|
1343
|
+
constructor(extraProps) {
|
1344
|
+
this.extraProps = extraProps;
|
1345
|
+
}
|
1346
|
+
inviteWorkspaceMember({
|
1347
|
+
workspace,
|
1348
|
+
email,
|
1349
|
+
role
|
1350
|
+
}) {
|
1351
|
+
return operationsByTag.invites.inviteWorkspaceMember({
|
1352
|
+
pathParams: { workspaceId: workspace },
|
645
1353
|
body: { email, role },
|
646
1354
|
...this.extraProps
|
647
1355
|
});
|
648
1356
|
}
|
649
|
-
|
650
|
-
|
651
|
-
|
1357
|
+
updateWorkspaceMemberInvite({
|
1358
|
+
workspace,
|
1359
|
+
invite,
|
1360
|
+
role
|
1361
|
+
}) {
|
1362
|
+
return operationsByTag.invites.updateWorkspaceMemberInvite({
|
1363
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
1364
|
+
body: { role },
|
1365
|
+
...this.extraProps
|
1366
|
+
});
|
1367
|
+
}
|
1368
|
+
cancelWorkspaceMemberInvite({
|
1369
|
+
workspace,
|
1370
|
+
invite
|
1371
|
+
}) {
|
1372
|
+
return operationsByTag.invites.cancelWorkspaceMemberInvite({
|
1373
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
652
1374
|
...this.extraProps
|
653
1375
|
});
|
654
1376
|
}
|
655
|
-
|
656
|
-
|
657
|
-
|
1377
|
+
acceptWorkspaceMemberInvite({
|
1378
|
+
workspace,
|
1379
|
+
key
|
1380
|
+
}) {
|
1381
|
+
return operationsByTag.invites.acceptWorkspaceMemberInvite({
|
1382
|
+
pathParams: { workspaceId: workspace, inviteKey: key },
|
658
1383
|
...this.extraProps
|
659
1384
|
});
|
660
1385
|
}
|
661
|
-
|
662
|
-
|
663
|
-
|
1386
|
+
resendWorkspaceMemberInvite({
|
1387
|
+
workspace,
|
1388
|
+
invite
|
1389
|
+
}) {
|
1390
|
+
return operationsByTag.invites.resendWorkspaceMemberInvite({
|
1391
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
664
1392
|
...this.extraProps
|
665
1393
|
});
|
666
1394
|
}
|
667
1395
|
}
|
668
|
-
class
|
1396
|
+
class BranchApi {
|
669
1397
|
constructor(extraProps) {
|
670
1398
|
this.extraProps = extraProps;
|
671
1399
|
}
|
672
|
-
|
673
|
-
|
674
|
-
|
1400
|
+
getBranchList({
|
1401
|
+
workspace,
|
1402
|
+
region,
|
1403
|
+
database
|
1404
|
+
}) {
|
1405
|
+
return operationsByTag.branch.getBranchList({
|
1406
|
+
pathParams: { workspace, region, dbName: database },
|
1407
|
+
...this.extraProps
|
1408
|
+
});
|
1409
|
+
}
|
1410
|
+
getBranchDetails({
|
1411
|
+
workspace,
|
1412
|
+
region,
|
1413
|
+
database,
|
1414
|
+
branch
|
1415
|
+
}) {
|
1416
|
+
return operationsByTag.branch.getBranchDetails({
|
1417
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1418
|
+
...this.extraProps
|
1419
|
+
});
|
1420
|
+
}
|
1421
|
+
createBranch({
|
1422
|
+
workspace,
|
1423
|
+
region,
|
1424
|
+
database,
|
1425
|
+
branch,
|
1426
|
+
from,
|
1427
|
+
metadata
|
1428
|
+
}) {
|
1429
|
+
return operationsByTag.branch.createBranch({
|
1430
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1431
|
+
body: { from, metadata },
|
1432
|
+
...this.extraProps
|
1433
|
+
});
|
1434
|
+
}
|
1435
|
+
deleteBranch({
|
1436
|
+
workspace,
|
1437
|
+
region,
|
1438
|
+
database,
|
1439
|
+
branch
|
1440
|
+
}) {
|
1441
|
+
return operationsByTag.branch.deleteBranch({
|
1442
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1443
|
+
...this.extraProps
|
1444
|
+
});
|
1445
|
+
}
|
1446
|
+
copyBranch({
|
1447
|
+
workspace,
|
1448
|
+
region,
|
1449
|
+
database,
|
1450
|
+
branch,
|
1451
|
+
destinationBranch,
|
1452
|
+
limit
|
1453
|
+
}) {
|
1454
|
+
return operationsByTag.branch.copyBranch({
|
1455
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1456
|
+
body: { destinationBranch, limit },
|
1457
|
+
...this.extraProps
|
1458
|
+
});
|
1459
|
+
}
|
1460
|
+
updateBranchMetadata({
|
1461
|
+
workspace,
|
1462
|
+
region,
|
1463
|
+
database,
|
1464
|
+
branch,
|
1465
|
+
metadata
|
1466
|
+
}) {
|
1467
|
+
return operationsByTag.branch.updateBranchMetadata({
|
1468
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1469
|
+
body: metadata,
|
675
1470
|
...this.extraProps
|
676
1471
|
});
|
677
1472
|
}
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
1473
|
+
getBranchMetadata({
|
1474
|
+
workspace,
|
1475
|
+
region,
|
1476
|
+
database,
|
1477
|
+
branch
|
1478
|
+
}) {
|
1479
|
+
return operationsByTag.branch.getBranchMetadata({
|
1480
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
682
1481
|
...this.extraProps
|
683
1482
|
});
|
684
1483
|
}
|
685
|
-
|
686
|
-
|
687
|
-
|
1484
|
+
getBranchStats({
|
1485
|
+
workspace,
|
1486
|
+
region,
|
1487
|
+
database,
|
1488
|
+
branch
|
1489
|
+
}) {
|
1490
|
+
return operationsByTag.branch.getBranchStats({
|
1491
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
688
1492
|
...this.extraProps
|
689
1493
|
});
|
690
1494
|
}
|
691
|
-
getGitBranchesMapping(
|
692
|
-
|
693
|
-
|
1495
|
+
getGitBranchesMapping({
|
1496
|
+
workspace,
|
1497
|
+
region,
|
1498
|
+
database
|
1499
|
+
}) {
|
1500
|
+
return operationsByTag.branch.getGitBranchesMapping({
|
1501
|
+
pathParams: { workspace, region, dbName: database },
|
694
1502
|
...this.extraProps
|
695
1503
|
});
|
696
1504
|
}
|
697
|
-
addGitBranchesEntry(
|
698
|
-
|
699
|
-
|
700
|
-
|
1505
|
+
addGitBranchesEntry({
|
1506
|
+
workspace,
|
1507
|
+
region,
|
1508
|
+
database,
|
1509
|
+
gitBranch,
|
1510
|
+
xataBranch
|
1511
|
+
}) {
|
1512
|
+
return operationsByTag.branch.addGitBranchesEntry({
|
1513
|
+
pathParams: { workspace, region, dbName: database },
|
1514
|
+
body: { gitBranch, xataBranch },
|
701
1515
|
...this.extraProps
|
702
1516
|
});
|
703
1517
|
}
|
704
|
-
removeGitBranchesEntry(
|
705
|
-
|
706
|
-
|
1518
|
+
removeGitBranchesEntry({
|
1519
|
+
workspace,
|
1520
|
+
region,
|
1521
|
+
database,
|
1522
|
+
gitBranch
|
1523
|
+
}) {
|
1524
|
+
return operationsByTag.branch.removeGitBranchesEntry({
|
1525
|
+
pathParams: { workspace, region, dbName: database },
|
707
1526
|
queryParams: { gitBranch },
|
708
1527
|
...this.extraProps
|
709
1528
|
});
|
710
1529
|
}
|
711
|
-
resolveBranch(
|
712
|
-
|
713
|
-
|
1530
|
+
resolveBranch({
|
1531
|
+
workspace,
|
1532
|
+
region,
|
1533
|
+
database,
|
1534
|
+
gitBranch,
|
1535
|
+
fallbackBranch
|
1536
|
+
}) {
|
1537
|
+
return operationsByTag.branch.resolveBranch({
|
1538
|
+
pathParams: { workspace, region, dbName: database },
|
714
1539
|
queryParams: { gitBranch, fallbackBranch },
|
715
1540
|
...this.extraProps
|
716
1541
|
});
|
717
1542
|
}
|
718
1543
|
}
|
719
|
-
class
|
1544
|
+
class TableApi {
|
720
1545
|
constructor(extraProps) {
|
721
1546
|
this.extraProps = extraProps;
|
722
1547
|
}
|
723
|
-
|
724
|
-
|
725
|
-
|
1548
|
+
createTable({
|
1549
|
+
workspace,
|
1550
|
+
region,
|
1551
|
+
database,
|
1552
|
+
branch,
|
1553
|
+
table
|
1554
|
+
}) {
|
1555
|
+
return operationsByTag.table.createTable({
|
1556
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
726
1557
|
...this.extraProps
|
727
1558
|
});
|
728
1559
|
}
|
729
|
-
|
730
|
-
|
731
|
-
|
1560
|
+
deleteTable({
|
1561
|
+
workspace,
|
1562
|
+
region,
|
1563
|
+
database,
|
1564
|
+
branch,
|
1565
|
+
table
|
1566
|
+
}) {
|
1567
|
+
return operationsByTag.table.deleteTable({
|
1568
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
732
1569
|
...this.extraProps
|
733
1570
|
});
|
734
1571
|
}
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
1572
|
+
updateTable({
|
1573
|
+
workspace,
|
1574
|
+
region,
|
1575
|
+
database,
|
1576
|
+
branch,
|
1577
|
+
table,
|
1578
|
+
update
|
1579
|
+
}) {
|
1580
|
+
return operationsByTag.table.updateTable({
|
1581
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1582
|
+
body: update,
|
740
1583
|
...this.extraProps
|
741
1584
|
});
|
742
1585
|
}
|
743
|
-
|
744
|
-
|
745
|
-
|
1586
|
+
getTableSchema({
|
1587
|
+
workspace,
|
1588
|
+
region,
|
1589
|
+
database,
|
1590
|
+
branch,
|
1591
|
+
table
|
1592
|
+
}) {
|
1593
|
+
return operationsByTag.table.getTableSchema({
|
1594
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
746
1595
|
...this.extraProps
|
747
1596
|
});
|
748
1597
|
}
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
1598
|
+
setTableSchema({
|
1599
|
+
workspace,
|
1600
|
+
region,
|
1601
|
+
database,
|
1602
|
+
branch,
|
1603
|
+
table,
|
1604
|
+
schema
|
1605
|
+
}) {
|
1606
|
+
return operationsByTag.table.setTableSchema({
|
1607
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1608
|
+
body: schema,
|
753
1609
|
...this.extraProps
|
754
1610
|
});
|
755
1611
|
}
|
756
|
-
|
757
|
-
|
758
|
-
|
1612
|
+
getTableColumns({
|
1613
|
+
workspace,
|
1614
|
+
region,
|
1615
|
+
database,
|
1616
|
+
branch,
|
1617
|
+
table
|
1618
|
+
}) {
|
1619
|
+
return operationsByTag.table.getTableColumns({
|
1620
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
759
1621
|
...this.extraProps
|
760
1622
|
});
|
761
1623
|
}
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
1624
|
+
addTableColumn({
|
1625
|
+
workspace,
|
1626
|
+
region,
|
1627
|
+
database,
|
1628
|
+
branch,
|
1629
|
+
table,
|
1630
|
+
column
|
1631
|
+
}) {
|
1632
|
+
return operationsByTag.table.addTableColumn({
|
1633
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1634
|
+
body: column,
|
766
1635
|
...this.extraProps
|
767
1636
|
});
|
768
1637
|
}
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
1638
|
+
getColumn({
|
1639
|
+
workspace,
|
1640
|
+
region,
|
1641
|
+
database,
|
1642
|
+
branch,
|
1643
|
+
table,
|
1644
|
+
column
|
1645
|
+
}) {
|
1646
|
+
return operationsByTag.table.getColumn({
|
1647
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
773
1648
|
...this.extraProps
|
774
1649
|
});
|
775
1650
|
}
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
1651
|
+
updateColumn({
|
1652
|
+
workspace,
|
1653
|
+
region,
|
1654
|
+
database,
|
1655
|
+
branch,
|
1656
|
+
table,
|
1657
|
+
column,
|
1658
|
+
update
|
1659
|
+
}) {
|
1660
|
+
return operationsByTag.table.updateColumn({
|
1661
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1662
|
+
body: update,
|
780
1663
|
...this.extraProps
|
781
1664
|
});
|
782
1665
|
}
|
783
|
-
|
784
|
-
|
785
|
-
|
1666
|
+
deleteColumn({
|
1667
|
+
workspace,
|
1668
|
+
region,
|
1669
|
+
database,
|
1670
|
+
branch,
|
1671
|
+
table,
|
1672
|
+
column
|
1673
|
+
}) {
|
1674
|
+
return operationsByTag.table.deleteColumn({
|
1675
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
786
1676
|
...this.extraProps
|
787
1677
|
});
|
788
1678
|
}
|
789
1679
|
}
|
790
|
-
class
|
1680
|
+
class RecordsApi {
|
791
1681
|
constructor(extraProps) {
|
792
1682
|
this.extraProps = extraProps;
|
793
1683
|
}
|
794
|
-
|
795
|
-
|
796
|
-
|
1684
|
+
insertRecord({
|
1685
|
+
workspace,
|
1686
|
+
region,
|
1687
|
+
database,
|
1688
|
+
branch,
|
1689
|
+
table,
|
1690
|
+
record,
|
1691
|
+
columns
|
1692
|
+
}) {
|
1693
|
+
return operationsByTag.records.insertRecord({
|
1694
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1695
|
+
queryParams: { columns },
|
1696
|
+
body: record,
|
797
1697
|
...this.extraProps
|
798
1698
|
});
|
799
1699
|
}
|
800
|
-
|
801
|
-
|
802
|
-
|
1700
|
+
getRecord({
|
1701
|
+
workspace,
|
1702
|
+
region,
|
1703
|
+
database,
|
1704
|
+
branch,
|
1705
|
+
table,
|
1706
|
+
id,
|
1707
|
+
columns
|
1708
|
+
}) {
|
1709
|
+
return operationsByTag.records.getRecord({
|
1710
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1711
|
+
queryParams: { columns },
|
803
1712
|
...this.extraProps
|
804
1713
|
});
|
805
1714
|
}
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
1715
|
+
insertRecordWithID({
|
1716
|
+
workspace,
|
1717
|
+
region,
|
1718
|
+
database,
|
1719
|
+
branch,
|
1720
|
+
table,
|
1721
|
+
id,
|
1722
|
+
record,
|
1723
|
+
columns,
|
1724
|
+
createOnly,
|
1725
|
+
ifVersion
|
1726
|
+
}) {
|
1727
|
+
return operationsByTag.records.insertRecordWithID({
|
1728
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1729
|
+
queryParams: { columns, createOnly, ifVersion },
|
1730
|
+
body: record,
|
810
1731
|
...this.extraProps
|
811
1732
|
});
|
812
1733
|
}
|
813
|
-
|
814
|
-
|
815
|
-
|
1734
|
+
updateRecordWithID({
|
1735
|
+
workspace,
|
1736
|
+
region,
|
1737
|
+
database,
|
1738
|
+
branch,
|
1739
|
+
table,
|
1740
|
+
id,
|
1741
|
+
record,
|
1742
|
+
columns,
|
1743
|
+
ifVersion
|
1744
|
+
}) {
|
1745
|
+
return operationsByTag.records.updateRecordWithID({
|
1746
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1747
|
+
queryParams: { columns, ifVersion },
|
1748
|
+
body: record,
|
816
1749
|
...this.extraProps
|
817
1750
|
});
|
818
1751
|
}
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
1752
|
+
upsertRecordWithID({
|
1753
|
+
workspace,
|
1754
|
+
region,
|
1755
|
+
database,
|
1756
|
+
branch,
|
1757
|
+
table,
|
1758
|
+
id,
|
1759
|
+
record,
|
1760
|
+
columns,
|
1761
|
+
ifVersion
|
1762
|
+
}) {
|
1763
|
+
return operationsByTag.records.upsertRecordWithID({
|
1764
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1765
|
+
queryParams: { columns, ifVersion },
|
1766
|
+
body: record,
|
823
1767
|
...this.extraProps
|
824
1768
|
});
|
825
1769
|
}
|
826
|
-
|
827
|
-
|
828
|
-
|
1770
|
+
deleteRecord({
|
1771
|
+
workspace,
|
1772
|
+
region,
|
1773
|
+
database,
|
1774
|
+
branch,
|
1775
|
+
table,
|
1776
|
+
id,
|
1777
|
+
columns
|
1778
|
+
}) {
|
1779
|
+
return operationsByTag.records.deleteRecord({
|
1780
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1781
|
+
queryParams: { columns },
|
829
1782
|
...this.extraProps
|
830
1783
|
});
|
831
1784
|
}
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
1785
|
+
bulkInsertTableRecords({
|
1786
|
+
workspace,
|
1787
|
+
region,
|
1788
|
+
database,
|
1789
|
+
branch,
|
1790
|
+
table,
|
1791
|
+
records,
|
1792
|
+
columns
|
1793
|
+
}) {
|
1794
|
+
return operationsByTag.records.bulkInsertTableRecords({
|
1795
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1796
|
+
queryParams: { columns },
|
1797
|
+
body: { records },
|
836
1798
|
...this.extraProps
|
837
1799
|
});
|
838
1800
|
}
|
839
|
-
|
840
|
-
|
841
|
-
|
1801
|
+
branchTransaction({
|
1802
|
+
workspace,
|
1803
|
+
region,
|
1804
|
+
database,
|
1805
|
+
branch,
|
1806
|
+
operations
|
1807
|
+
}) {
|
1808
|
+
return operationsByTag.records.branchTransaction({
|
1809
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1810
|
+
body: { operations },
|
1811
|
+
...this.extraProps
|
1812
|
+
});
|
1813
|
+
}
|
1814
|
+
}
|
1815
|
+
class SearchAndFilterApi {
|
1816
|
+
constructor(extraProps) {
|
1817
|
+
this.extraProps = extraProps;
|
1818
|
+
}
|
1819
|
+
queryTable({
|
1820
|
+
workspace,
|
1821
|
+
region,
|
1822
|
+
database,
|
1823
|
+
branch,
|
1824
|
+
table,
|
1825
|
+
filter,
|
1826
|
+
sort,
|
1827
|
+
page,
|
1828
|
+
columns,
|
1829
|
+
consistency
|
1830
|
+
}) {
|
1831
|
+
return operationsByTag.searchAndFilter.queryTable({
|
1832
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1833
|
+
body: { filter, sort, page, columns, consistency },
|
1834
|
+
...this.extraProps
|
1835
|
+
});
|
1836
|
+
}
|
1837
|
+
searchTable({
|
1838
|
+
workspace,
|
1839
|
+
region,
|
1840
|
+
database,
|
1841
|
+
branch,
|
1842
|
+
table,
|
1843
|
+
query,
|
1844
|
+
fuzziness,
|
1845
|
+
target,
|
1846
|
+
prefix,
|
1847
|
+
filter,
|
1848
|
+
highlight,
|
1849
|
+
boosters
|
1850
|
+
}) {
|
1851
|
+
return operationsByTag.searchAndFilter.searchTable({
|
1852
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1853
|
+
body: { query, fuzziness, target, prefix, filter, highlight, boosters },
|
1854
|
+
...this.extraProps
|
1855
|
+
});
|
1856
|
+
}
|
1857
|
+
searchBranch({
|
1858
|
+
workspace,
|
1859
|
+
region,
|
1860
|
+
database,
|
1861
|
+
branch,
|
1862
|
+
tables,
|
1863
|
+
query,
|
1864
|
+
fuzziness,
|
1865
|
+
prefix,
|
1866
|
+
highlight
|
1867
|
+
}) {
|
1868
|
+
return operationsByTag.searchAndFilter.searchBranch({
|
1869
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1870
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
1871
|
+
...this.extraProps
|
1872
|
+
});
|
1873
|
+
}
|
1874
|
+
vectorSearchTable({
|
1875
|
+
workspace,
|
1876
|
+
region,
|
1877
|
+
database,
|
1878
|
+
branch,
|
1879
|
+
table,
|
1880
|
+
queryVector,
|
1881
|
+
column,
|
1882
|
+
similarityFunction,
|
1883
|
+
size,
|
1884
|
+
filter
|
1885
|
+
}) {
|
1886
|
+
return operationsByTag.searchAndFilter.vectorSearchTable({
|
1887
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1888
|
+
body: { queryVector, column, similarityFunction, size, filter },
|
1889
|
+
...this.extraProps
|
1890
|
+
});
|
1891
|
+
}
|
1892
|
+
askTable({
|
1893
|
+
workspace,
|
1894
|
+
region,
|
1895
|
+
database,
|
1896
|
+
branch,
|
1897
|
+
table,
|
1898
|
+
options
|
1899
|
+
}) {
|
1900
|
+
return operationsByTag.searchAndFilter.askTable({
|
1901
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1902
|
+
body: { ...options },
|
1903
|
+
...this.extraProps
|
1904
|
+
});
|
1905
|
+
}
|
1906
|
+
summarizeTable({
|
1907
|
+
workspace,
|
1908
|
+
region,
|
1909
|
+
database,
|
1910
|
+
branch,
|
1911
|
+
table,
|
1912
|
+
filter,
|
1913
|
+
columns,
|
1914
|
+
summaries,
|
1915
|
+
sort,
|
1916
|
+
summariesFilter,
|
1917
|
+
page,
|
1918
|
+
consistency
|
1919
|
+
}) {
|
1920
|
+
return operationsByTag.searchAndFilter.summarizeTable({
|
1921
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1922
|
+
body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
|
1923
|
+
...this.extraProps
|
1924
|
+
});
|
1925
|
+
}
|
1926
|
+
aggregateTable({
|
1927
|
+
workspace,
|
1928
|
+
region,
|
1929
|
+
database,
|
1930
|
+
branch,
|
1931
|
+
table,
|
1932
|
+
filter,
|
1933
|
+
aggs
|
1934
|
+
}) {
|
1935
|
+
return operationsByTag.searchAndFilter.aggregateTable({
|
1936
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1937
|
+
body: { filter, aggs },
|
1938
|
+
...this.extraProps
|
1939
|
+
});
|
1940
|
+
}
|
1941
|
+
}
|
1942
|
+
class MigrationRequestsApi {
|
1943
|
+
constructor(extraProps) {
|
1944
|
+
this.extraProps = extraProps;
|
1945
|
+
}
|
1946
|
+
queryMigrationRequests({
|
1947
|
+
workspace,
|
1948
|
+
region,
|
1949
|
+
database,
|
1950
|
+
filter,
|
1951
|
+
sort,
|
1952
|
+
page,
|
1953
|
+
columns
|
1954
|
+
}) {
|
1955
|
+
return operationsByTag.migrationRequests.queryMigrationRequests({
|
1956
|
+
pathParams: { workspace, region, dbName: database },
|
1957
|
+
body: { filter, sort, page, columns },
|
1958
|
+
...this.extraProps
|
1959
|
+
});
|
1960
|
+
}
|
1961
|
+
createMigrationRequest({
|
1962
|
+
workspace,
|
1963
|
+
region,
|
1964
|
+
database,
|
1965
|
+
migration
|
1966
|
+
}) {
|
1967
|
+
return operationsByTag.migrationRequests.createMigrationRequest({
|
1968
|
+
pathParams: { workspace, region, dbName: database },
|
1969
|
+
body: migration,
|
1970
|
+
...this.extraProps
|
1971
|
+
});
|
1972
|
+
}
|
1973
|
+
getMigrationRequest({
|
1974
|
+
workspace,
|
1975
|
+
region,
|
1976
|
+
database,
|
1977
|
+
migrationRequest
|
1978
|
+
}) {
|
1979
|
+
return operationsByTag.migrationRequests.getMigrationRequest({
|
1980
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1981
|
+
...this.extraProps
|
1982
|
+
});
|
1983
|
+
}
|
1984
|
+
updateMigrationRequest({
|
1985
|
+
workspace,
|
1986
|
+
region,
|
1987
|
+
database,
|
1988
|
+
migrationRequest,
|
1989
|
+
update
|
1990
|
+
}) {
|
1991
|
+
return operationsByTag.migrationRequests.updateMigrationRequest({
|
1992
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1993
|
+
body: update,
|
1994
|
+
...this.extraProps
|
1995
|
+
});
|
1996
|
+
}
|
1997
|
+
listMigrationRequestsCommits({
|
1998
|
+
workspace,
|
1999
|
+
region,
|
2000
|
+
database,
|
2001
|
+
migrationRequest,
|
2002
|
+
page
|
2003
|
+
}) {
|
2004
|
+
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
2005
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
2006
|
+
body: { page },
|
2007
|
+
...this.extraProps
|
2008
|
+
});
|
2009
|
+
}
|
2010
|
+
compareMigrationRequest({
|
2011
|
+
workspace,
|
2012
|
+
region,
|
2013
|
+
database,
|
2014
|
+
migrationRequest
|
2015
|
+
}) {
|
2016
|
+
return operationsByTag.migrationRequests.compareMigrationRequest({
|
2017
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
2018
|
+
...this.extraProps
|
2019
|
+
});
|
2020
|
+
}
|
2021
|
+
getMigrationRequestIsMerged({
|
2022
|
+
workspace,
|
2023
|
+
region,
|
2024
|
+
database,
|
2025
|
+
migrationRequest
|
2026
|
+
}) {
|
2027
|
+
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
2028
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
2029
|
+
...this.extraProps
|
2030
|
+
});
|
2031
|
+
}
|
2032
|
+
mergeMigrationRequest({
|
2033
|
+
workspace,
|
2034
|
+
region,
|
2035
|
+
database,
|
2036
|
+
migrationRequest
|
2037
|
+
}) {
|
2038
|
+
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
2039
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
2040
|
+
...this.extraProps
|
2041
|
+
});
|
2042
|
+
}
|
2043
|
+
}
|
2044
|
+
class MigrationsApi {
|
2045
|
+
constructor(extraProps) {
|
2046
|
+
this.extraProps = extraProps;
|
2047
|
+
}
|
2048
|
+
getBranchMigrationHistory({
|
2049
|
+
workspace,
|
2050
|
+
region,
|
2051
|
+
database,
|
2052
|
+
branch,
|
2053
|
+
limit,
|
2054
|
+
startFrom
|
2055
|
+
}) {
|
2056
|
+
return operationsByTag.migrations.getBranchMigrationHistory({
|
2057
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2058
|
+
body: { limit, startFrom },
|
2059
|
+
...this.extraProps
|
2060
|
+
});
|
2061
|
+
}
|
2062
|
+
getBranchMigrationPlan({
|
2063
|
+
workspace,
|
2064
|
+
region,
|
2065
|
+
database,
|
2066
|
+
branch,
|
2067
|
+
schema
|
2068
|
+
}) {
|
2069
|
+
return operationsByTag.migrations.getBranchMigrationPlan({
|
2070
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2071
|
+
body: schema,
|
2072
|
+
...this.extraProps
|
2073
|
+
});
|
2074
|
+
}
|
2075
|
+
executeBranchMigrationPlan({
|
2076
|
+
workspace,
|
2077
|
+
region,
|
2078
|
+
database,
|
2079
|
+
branch,
|
2080
|
+
plan
|
2081
|
+
}) {
|
2082
|
+
return operationsByTag.migrations.executeBranchMigrationPlan({
|
2083
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2084
|
+
body: plan,
|
2085
|
+
...this.extraProps
|
2086
|
+
});
|
2087
|
+
}
|
2088
|
+
getBranchSchemaHistory({
|
2089
|
+
workspace,
|
2090
|
+
region,
|
2091
|
+
database,
|
2092
|
+
branch,
|
2093
|
+
page
|
2094
|
+
}) {
|
2095
|
+
return operationsByTag.migrations.getBranchSchemaHistory({
|
2096
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2097
|
+
body: { page },
|
2098
|
+
...this.extraProps
|
2099
|
+
});
|
2100
|
+
}
|
2101
|
+
compareBranchWithUserSchema({
|
2102
|
+
workspace,
|
2103
|
+
region,
|
2104
|
+
database,
|
2105
|
+
branch,
|
2106
|
+
schema,
|
2107
|
+
schemaOperations,
|
2108
|
+
branchOperations
|
2109
|
+
}) {
|
2110
|
+
return operationsByTag.migrations.compareBranchWithUserSchema({
|
2111
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2112
|
+
body: { schema, schemaOperations, branchOperations },
|
2113
|
+
...this.extraProps
|
2114
|
+
});
|
2115
|
+
}
|
2116
|
+
compareBranchSchemas({
|
2117
|
+
workspace,
|
2118
|
+
region,
|
2119
|
+
database,
|
2120
|
+
branch,
|
2121
|
+
compare,
|
2122
|
+
sourceBranchOperations,
|
2123
|
+
targetBranchOperations
|
2124
|
+
}) {
|
2125
|
+
return operationsByTag.migrations.compareBranchSchemas({
|
2126
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
2127
|
+
body: { sourceBranchOperations, targetBranchOperations },
|
2128
|
+
...this.extraProps
|
2129
|
+
});
|
2130
|
+
}
|
2131
|
+
updateBranchSchema({
|
2132
|
+
workspace,
|
2133
|
+
region,
|
2134
|
+
database,
|
2135
|
+
branch,
|
2136
|
+
migration
|
2137
|
+
}) {
|
2138
|
+
return operationsByTag.migrations.updateBranchSchema({
|
2139
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2140
|
+
body: migration,
|
2141
|
+
...this.extraProps
|
2142
|
+
});
|
2143
|
+
}
|
2144
|
+
previewBranchSchemaEdit({
|
2145
|
+
workspace,
|
2146
|
+
region,
|
2147
|
+
database,
|
2148
|
+
branch,
|
2149
|
+
data
|
2150
|
+
}) {
|
2151
|
+
return operationsByTag.migrations.previewBranchSchemaEdit({
|
2152
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2153
|
+
body: data,
|
842
2154
|
...this.extraProps
|
843
2155
|
});
|
844
2156
|
}
|
845
|
-
|
846
|
-
|
847
|
-
|
2157
|
+
applyBranchSchemaEdit({
|
2158
|
+
workspace,
|
2159
|
+
region,
|
2160
|
+
database,
|
2161
|
+
branch,
|
2162
|
+
edits
|
2163
|
+
}) {
|
2164
|
+
return operationsByTag.migrations.applyBranchSchemaEdit({
|
2165
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2166
|
+
body: { edits },
|
848
2167
|
...this.extraProps
|
849
2168
|
});
|
850
2169
|
}
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
2170
|
+
pushBranchMigrations({
|
2171
|
+
workspace,
|
2172
|
+
region,
|
2173
|
+
database,
|
2174
|
+
branch,
|
2175
|
+
migrations
|
2176
|
+
}) {
|
2177
|
+
return operationsByTag.migrations.pushBranchMigrations({
|
2178
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2179
|
+
body: { migrations },
|
855
2180
|
...this.extraProps
|
856
2181
|
});
|
857
2182
|
}
|
858
2183
|
}
|
859
|
-
class
|
2184
|
+
class DatabaseApi {
|
860
2185
|
constructor(extraProps) {
|
861
2186
|
this.extraProps = extraProps;
|
862
2187
|
}
|
863
|
-
|
864
|
-
return operationsByTag.
|
865
|
-
pathParams: {
|
866
|
-
body: record,
|
867
|
-
...this.extraProps
|
868
|
-
});
|
869
|
-
}
|
870
|
-
insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
|
871
|
-
return operationsByTag.records.insertRecordWithID({
|
872
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
873
|
-
queryParams: options,
|
874
|
-
body: record,
|
2188
|
+
getDatabaseList({ workspace }) {
|
2189
|
+
return operationsByTag.databases.getDatabaseList({
|
2190
|
+
pathParams: { workspaceId: workspace },
|
875
2191
|
...this.extraProps
|
876
2192
|
});
|
877
2193
|
}
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
2194
|
+
createDatabase({
|
2195
|
+
workspace,
|
2196
|
+
database,
|
2197
|
+
data
|
2198
|
+
}) {
|
2199
|
+
return operationsByTag.databases.createDatabase({
|
2200
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2201
|
+
body: data,
|
883
2202
|
...this.extraProps
|
884
2203
|
});
|
885
2204
|
}
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
2205
|
+
deleteDatabase({
|
2206
|
+
workspace,
|
2207
|
+
database
|
2208
|
+
}) {
|
2209
|
+
return operationsByTag.databases.deleteDatabase({
|
2210
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
891
2211
|
...this.extraProps
|
892
2212
|
});
|
893
2213
|
}
|
894
|
-
|
895
|
-
|
896
|
-
|
2214
|
+
getDatabaseMetadata({
|
2215
|
+
workspace,
|
2216
|
+
database
|
2217
|
+
}) {
|
2218
|
+
return operationsByTag.databases.getDatabaseMetadata({
|
2219
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
897
2220
|
...this.extraProps
|
898
2221
|
});
|
899
2222
|
}
|
900
|
-
|
901
|
-
|
902
|
-
|
2223
|
+
updateDatabaseMetadata({
|
2224
|
+
workspace,
|
2225
|
+
database,
|
2226
|
+
metadata
|
2227
|
+
}) {
|
2228
|
+
return operationsByTag.databases.updateDatabaseMetadata({
|
2229
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2230
|
+
body: metadata,
|
903
2231
|
...this.extraProps
|
904
2232
|
});
|
905
2233
|
}
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
2234
|
+
getDatabaseGithubSettings({
|
2235
|
+
workspace,
|
2236
|
+
database
|
2237
|
+
}) {
|
2238
|
+
return operationsByTag.databases.getDatabaseGithubSettings({
|
2239
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
910
2240
|
...this.extraProps
|
911
2241
|
});
|
912
2242
|
}
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
2243
|
+
updateDatabaseGithubSettings({
|
2244
|
+
workspace,
|
2245
|
+
database,
|
2246
|
+
settings
|
2247
|
+
}) {
|
2248
|
+
return operationsByTag.databases.updateDatabaseGithubSettings({
|
2249
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2250
|
+
body: settings,
|
917
2251
|
...this.extraProps
|
918
2252
|
});
|
919
2253
|
}
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
2254
|
+
deleteDatabaseGithubSettings({
|
2255
|
+
workspace,
|
2256
|
+
database
|
2257
|
+
}) {
|
2258
|
+
return operationsByTag.databases.deleteDatabaseGithubSettings({
|
2259
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
924
2260
|
...this.extraProps
|
925
2261
|
});
|
926
2262
|
}
|
927
|
-
|
928
|
-
return operationsByTag.
|
929
|
-
pathParams: {
|
930
|
-
body: query,
|
2263
|
+
listRegions({ workspace }) {
|
2264
|
+
return operationsByTag.databases.listRegions({
|
2265
|
+
pathParams: { workspaceId: workspace },
|
931
2266
|
...this.extraProps
|
932
2267
|
});
|
933
2268
|
}
|
934
2269
|
}
|
935
2270
|
|
936
2271
|
class XataApiPlugin {
|
937
|
-
|
938
|
-
|
939
|
-
return new XataApiClient({ fetch: fetchImpl, apiKey });
|
2272
|
+
build(options) {
|
2273
|
+
return new XataApiClient(options);
|
940
2274
|
}
|
941
2275
|
}
|
942
2276
|
|
943
2277
|
class XataPlugin {
|
944
2278
|
}
|
945
2279
|
|
2280
|
+
function cleanFilter(filter) {
|
2281
|
+
if (!filter)
|
2282
|
+
return void 0;
|
2283
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
2284
|
+
return values.length > 0 ? filter : void 0;
|
2285
|
+
}
|
2286
|
+
|
946
2287
|
var __accessCheck$6 = (obj, member, msg) => {
|
947
2288
|
if (!member.has(obj))
|
948
2289
|
throw TypeError("Cannot " + msg);
|
@@ -975,11 +2316,11 @@ class Page {
|
|
975
2316
|
async previousPage(size, offset) {
|
976
2317
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
977
2318
|
}
|
978
|
-
async
|
979
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
2319
|
+
async startPage(size, offset) {
|
2320
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
980
2321
|
}
|
981
|
-
async
|
982
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
2322
|
+
async endPage(size, offset) {
|
2323
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
983
2324
|
}
|
984
2325
|
hasNextPage() {
|
985
2326
|
return this.meta.page.more;
|
@@ -991,13 +2332,13 @@ const PAGINATION_DEFAULT_SIZE = 20;
|
|
991
2332
|
const PAGINATION_MAX_OFFSET = 800;
|
992
2333
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
993
2334
|
function isCursorPaginationOptions(options) {
|
994
|
-
return isDefined(options) && (isDefined(options.
|
2335
|
+
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
995
2336
|
}
|
996
2337
|
const _RecordArray = class extends Array {
|
997
2338
|
constructor(...args) {
|
998
2339
|
super(..._RecordArray.parseConstructorParams(...args));
|
999
2340
|
__privateAdd$6(this, _page, void 0);
|
1000
|
-
__privateSet$6(this, _page, args[0]);
|
2341
|
+
__privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
|
1001
2342
|
}
|
1002
2343
|
static parseConstructorParams(...args) {
|
1003
2344
|
if (args.length === 1 && typeof args[0] === "number") {
|
@@ -1009,6 +2350,18 @@ const _RecordArray = class extends Array {
|
|
1009
2350
|
}
|
1010
2351
|
return new Array(...args);
|
1011
2352
|
}
|
2353
|
+
toArray() {
|
2354
|
+
return new Array(...this);
|
2355
|
+
}
|
2356
|
+
toSerializable() {
|
2357
|
+
return JSON.parse(this.toString());
|
2358
|
+
}
|
2359
|
+
toString() {
|
2360
|
+
return JSON.stringify(this.toArray());
|
2361
|
+
}
|
2362
|
+
map(callbackfn, thisArg) {
|
2363
|
+
return this.toArray().map(callbackfn, thisArg);
|
2364
|
+
}
|
1012
2365
|
async nextPage(size, offset) {
|
1013
2366
|
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
1014
2367
|
return new _RecordArray(newPage);
|
@@ -1017,12 +2370,12 @@ const _RecordArray = class extends Array {
|
|
1017
2370
|
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
1018
2371
|
return new _RecordArray(newPage);
|
1019
2372
|
}
|
1020
|
-
async
|
1021
|
-
const newPage = await __privateGet$6(this, _page).
|
2373
|
+
async startPage(size, offset) {
|
2374
|
+
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
1022
2375
|
return new _RecordArray(newPage);
|
1023
2376
|
}
|
1024
|
-
async
|
1025
|
-
const newPage = await __privateGet$6(this, _page).
|
2377
|
+
async endPage(size, offset) {
|
2378
|
+
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
1026
2379
|
return new _RecordArray(newPage);
|
1027
2380
|
}
|
1028
2381
|
hasNextPage() {
|
@@ -1050,9 +2403,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
|
|
1050
2403
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1051
2404
|
return value;
|
1052
2405
|
};
|
1053
|
-
var
|
2406
|
+
var __privateMethod$3 = (obj, member, method) => {
|
2407
|
+
__accessCheck$5(obj, member, "access private method");
|
2408
|
+
return method;
|
2409
|
+
};
|
2410
|
+
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
1054
2411
|
const _Query = class {
|
1055
2412
|
constructor(repository, table, data, rawParent) {
|
2413
|
+
__privateAdd$5(this, _cleanFilterConstraint);
|
1056
2414
|
__privateAdd$5(this, _table$1, void 0);
|
1057
2415
|
__privateAdd$5(this, _repository, void 0);
|
1058
2416
|
__privateAdd$5(this, _data, { filter: {} });
|
@@ -1071,9 +2429,11 @@ const _Query = class {
|
|
1071
2429
|
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
1072
2430
|
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
1073
2431
|
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
1074
|
-
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns
|
2432
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
|
2433
|
+
__privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
|
1075
2434
|
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
1076
2435
|
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
2436
|
+
__privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
|
1077
2437
|
this.any = this.any.bind(this);
|
1078
2438
|
this.all = this.all.bind(this);
|
1079
2439
|
this.not = this.not.bind(this);
|
@@ -1109,21 +2469,29 @@ const _Query = class {
|
|
1109
2469
|
}
|
1110
2470
|
filter(a, b) {
|
1111
2471
|
if (arguments.length === 1) {
|
1112
|
-
const constraints = Object.entries(a).map(([column, constraint]) => ({
|
2472
|
+
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
2473
|
+
[column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
|
2474
|
+
}));
|
1113
2475
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1114
2476
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1115
2477
|
} else {
|
1116
|
-
const
|
2478
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
|
2479
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1117
2480
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1118
2481
|
}
|
1119
2482
|
}
|
1120
|
-
sort(column, direction) {
|
2483
|
+
sort(column, direction = "asc") {
|
1121
2484
|
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
1122
2485
|
const sort = [...originalSort, { column, direction }];
|
1123
2486
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
1124
2487
|
}
|
1125
2488
|
select(columns) {
|
1126
|
-
return new _Query(
|
2489
|
+
return new _Query(
|
2490
|
+
__privateGet$5(this, _repository),
|
2491
|
+
__privateGet$5(this, _table$1),
|
2492
|
+
{ columns },
|
2493
|
+
__privateGet$5(this, _data)
|
2494
|
+
);
|
1127
2495
|
}
|
1128
2496
|
getPaginated(options = {}) {
|
1129
2497
|
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
@@ -1146,11 +2514,20 @@ const _Query = class {
|
|
1146
2514
|
}
|
1147
2515
|
}
|
1148
2516
|
async getMany(options = {}) {
|
1149
|
-
const
|
2517
|
+
const { pagination = {}, ...rest } = options;
|
2518
|
+
const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
|
2519
|
+
const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
|
2520
|
+
let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
|
2521
|
+
const results = [...page.records];
|
2522
|
+
while (page.hasNextPage() && results.length < size) {
|
2523
|
+
page = await page.nextPage();
|
2524
|
+
results.push(...page.records);
|
2525
|
+
}
|
1150
2526
|
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
1151
2527
|
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
1152
2528
|
}
|
1153
|
-
|
2529
|
+
const array = new RecordArray(page, results.slice(0, size));
|
2530
|
+
return array;
|
1154
2531
|
}
|
1155
2532
|
async getAll(options = {}) {
|
1156
2533
|
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
@@ -1164,19 +2541,35 @@ const _Query = class {
|
|
1164
2541
|
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1165
2542
|
return records[0] ?? null;
|
1166
2543
|
}
|
2544
|
+
async getFirstOrThrow(options = {}) {
|
2545
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
2546
|
+
if (records[0] === void 0)
|
2547
|
+
throw new Error("No results found.");
|
2548
|
+
return records[0];
|
2549
|
+
}
|
2550
|
+
async summarize(params = {}) {
|
2551
|
+
const { summaries, summariesFilter, ...options } = params;
|
2552
|
+
const query = new _Query(
|
2553
|
+
__privateGet$5(this, _repository),
|
2554
|
+
__privateGet$5(this, _table$1),
|
2555
|
+
options,
|
2556
|
+
__privateGet$5(this, _data)
|
2557
|
+
);
|
2558
|
+
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
2559
|
+
}
|
1167
2560
|
cache(ttl) {
|
1168
2561
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1169
2562
|
}
|
1170
2563
|
nextPage(size, offset) {
|
1171
|
-
return this.
|
2564
|
+
return this.startPage(size, offset);
|
1172
2565
|
}
|
1173
2566
|
previousPage(size, offset) {
|
1174
|
-
return this.
|
2567
|
+
return this.startPage(size, offset);
|
1175
2568
|
}
|
1176
|
-
|
2569
|
+
startPage(size, offset) {
|
1177
2570
|
return this.getPaginated({ pagination: { size, offset } });
|
1178
2571
|
}
|
1179
|
-
|
2572
|
+
endPage(size, offset) {
|
1180
2573
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
1181
2574
|
}
|
1182
2575
|
hasNextPage() {
|
@@ -1187,9 +2580,20 @@ let Query = _Query;
|
|
1187
2580
|
_table$1 = new WeakMap();
|
1188
2581
|
_repository = new WeakMap();
|
1189
2582
|
_data = new WeakMap();
|
2583
|
+
_cleanFilterConstraint = new WeakSet();
|
2584
|
+
cleanFilterConstraint_fn = function(column, value) {
|
2585
|
+
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
2586
|
+
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
2587
|
+
return { $includes: value };
|
2588
|
+
}
|
2589
|
+
if (columnType === "link" && isObject(value) && isString(value.id)) {
|
2590
|
+
return value.id;
|
2591
|
+
}
|
2592
|
+
return value;
|
2593
|
+
};
|
1190
2594
|
function cleanParent(data, parent) {
|
1191
2595
|
if (isCursorPaginationOptions(data.pagination)) {
|
1192
|
-
return { ...parent,
|
2596
|
+
return { ...parent, sort: void 0, filter: void 0 };
|
1193
2597
|
}
|
1194
2598
|
return parent;
|
1195
2599
|
}
|
@@ -1248,329 +2652,621 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
1248
2652
|
__accessCheck$4(obj, member, "access private method");
|
1249
2653
|
return method;
|
1250
2654
|
};
|
1251
|
-
var _table, _getFetchProps, _cache, _schemaTables$2, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn,
|
2655
|
+
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;
|
2656
|
+
const BULK_OPERATION_MAX_SIZE = 1e3;
|
1252
2657
|
class Repository extends Query {
|
1253
2658
|
}
|
1254
2659
|
class RestRepository extends Query {
|
1255
2660
|
constructor(options) {
|
1256
|
-
super(
|
2661
|
+
super(
|
2662
|
+
null,
|
2663
|
+
{ name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
|
2664
|
+
{}
|
2665
|
+
);
|
1257
2666
|
__privateAdd$4(this, _insertRecordWithoutId);
|
1258
2667
|
__privateAdd$4(this, _insertRecordWithId);
|
1259
|
-
__privateAdd$4(this,
|
2668
|
+
__privateAdd$4(this, _insertRecords);
|
1260
2669
|
__privateAdd$4(this, _updateRecordWithID);
|
2670
|
+
__privateAdd$4(this, _updateRecords);
|
1261
2671
|
__privateAdd$4(this, _upsertRecordWithID);
|
1262
2672
|
__privateAdd$4(this, _deleteRecord);
|
1263
|
-
__privateAdd$4(this,
|
1264
|
-
__privateAdd$4(this, _setCacheRecord);
|
1265
|
-
__privateAdd$4(this, _getCacheRecord);
|
2673
|
+
__privateAdd$4(this, _deleteRecords);
|
1266
2674
|
__privateAdd$4(this, _setCacheQuery);
|
1267
2675
|
__privateAdd$4(this, _getCacheQuery);
|
1268
2676
|
__privateAdd$4(this, _getSchemaTables$1);
|
1269
2677
|
__privateAdd$4(this, _table, void 0);
|
1270
2678
|
__privateAdd$4(this, _getFetchProps, void 0);
|
2679
|
+
__privateAdd$4(this, _db, void 0);
|
1271
2680
|
__privateAdd$4(this, _cache, void 0);
|
1272
2681
|
__privateAdd$4(this, _schemaTables$2, void 0);
|
2682
|
+
__privateAdd$4(this, _trace, void 0);
|
1273
2683
|
__privateSet$4(this, _table, options.table);
|
1274
|
-
__privateSet$4(this,
|
1275
|
-
this.db = options.db;
|
2684
|
+
__privateSet$4(this, _db, options.db);
|
1276
2685
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
1277
2686
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
2687
|
+
__privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
|
2688
|
+
const trace = options.pluginOptions.trace ?? defaultTrace;
|
2689
|
+
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
2690
|
+
return trace(name, fn, {
|
2691
|
+
...options2,
|
2692
|
+
[TraceAttributes.TABLE]: __privateGet$4(this, _table),
|
2693
|
+
[TraceAttributes.KIND]: "sdk-operation",
|
2694
|
+
[TraceAttributes.VERSION]: VERSION
|
2695
|
+
});
|
2696
|
+
});
|
1278
2697
|
}
|
1279
|
-
async create(a, b) {
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
2698
|
+
async create(a, b, c, d) {
|
2699
|
+
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
2700
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2701
|
+
if (Array.isArray(a)) {
|
2702
|
+
if (a.length === 0)
|
2703
|
+
return [];
|
2704
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
2705
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2706
|
+
const result = await this.read(ids, columns);
|
2707
|
+
return result;
|
2708
|
+
}
|
2709
|
+
if (isString(a) && isObject(b)) {
|
2710
|
+
if (a === "")
|
2711
|
+
throw new Error("The id can't be empty");
|
2712
|
+
const columns = isStringArray(c) ? c : void 0;
|
2713
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
2714
|
+
}
|
2715
|
+
if (isObject(a) && isString(a.id)) {
|
2716
|
+
if (a.id === "")
|
2717
|
+
throw new Error("The id can't be empty");
|
2718
|
+
const columns = isStringArray(b) ? b : void 0;
|
2719
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
2720
|
+
}
|
2721
|
+
if (isObject(a)) {
|
2722
|
+
const columns = isStringArray(b) ? b : void 0;
|
2723
|
+
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
2724
|
+
}
|
2725
|
+
throw new Error("Invalid arguments for create method");
|
2726
|
+
});
|
2727
|
+
}
|
2728
|
+
async read(a, b) {
|
2729
|
+
return __privateGet$4(this, _trace).call(this, "read", async () => {
|
2730
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2731
|
+
if (Array.isArray(a)) {
|
2732
|
+
if (a.length === 0)
|
2733
|
+
return [];
|
2734
|
+
const ids = a.map((item) => extractId(item));
|
2735
|
+
const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
|
2736
|
+
const dictionary = finalObjects.reduce((acc, object) => {
|
2737
|
+
acc[object.id] = object;
|
2738
|
+
return acc;
|
2739
|
+
}, {});
|
2740
|
+
return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
|
2741
|
+
}
|
2742
|
+
const id = extractId(a);
|
2743
|
+
if (id) {
|
2744
|
+
try {
|
2745
|
+
const response = await getRecord({
|
2746
|
+
pathParams: {
|
2747
|
+
workspace: "{workspaceId}",
|
2748
|
+
dbBranchName: "{dbBranch}",
|
2749
|
+
region: "{region}",
|
2750
|
+
tableName: __privateGet$4(this, _table),
|
2751
|
+
recordId: id
|
2752
|
+
},
|
2753
|
+
queryParams: { columns },
|
2754
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2755
|
+
});
|
2756
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2757
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2758
|
+
} catch (e) {
|
2759
|
+
if (isObject(e) && e.status === 404) {
|
2760
|
+
return null;
|
2761
|
+
}
|
2762
|
+
throw e;
|
2763
|
+
}
|
2764
|
+
}
|
2765
|
+
return null;
|
2766
|
+
});
|
2767
|
+
}
|
2768
|
+
async readOrThrow(a, b) {
|
2769
|
+
return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
|
2770
|
+
const result = await this.read(a, b);
|
2771
|
+
if (Array.isArray(result)) {
|
2772
|
+
const missingIds = compact(
|
2773
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2774
|
+
);
|
2775
|
+
if (missingIds.length > 0) {
|
2776
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
2777
|
+
}
|
2778
|
+
return result;
|
2779
|
+
}
|
2780
|
+
if (result === null) {
|
2781
|
+
const id = extractId(a) ?? "unknown";
|
2782
|
+
throw new Error(`Record with id ${id} not found`);
|
2783
|
+
}
|
2784
|
+
return result;
|
2785
|
+
});
|
2786
|
+
}
|
2787
|
+
async update(a, b, c, d) {
|
2788
|
+
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
2789
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2790
|
+
if (Array.isArray(a)) {
|
2791
|
+
if (a.length === 0)
|
2792
|
+
return [];
|
2793
|
+
const existing = await this.read(a, ["id"]);
|
2794
|
+
const updates = a.filter((_item, index) => existing[index] !== null);
|
2795
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
|
2796
|
+
ifVersion,
|
2797
|
+
upsert: false
|
1325
2798
|
});
|
1326
|
-
const
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
2799
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2800
|
+
const result = await this.read(a, columns);
|
2801
|
+
return result;
|
2802
|
+
}
|
2803
|
+
try {
|
2804
|
+
if (isString(a) && isObject(b)) {
|
2805
|
+
const columns = isStringArray(c) ? c : void 0;
|
2806
|
+
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
2807
|
+
}
|
2808
|
+
if (isObject(a) && isString(a.id)) {
|
2809
|
+
const columns = isStringArray(b) ? b : void 0;
|
2810
|
+
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
2811
|
+
}
|
2812
|
+
} catch (error) {
|
2813
|
+
if (error.status === 422)
|
1330
2814
|
return null;
|
2815
|
+
throw error;
|
2816
|
+
}
|
2817
|
+
throw new Error("Invalid arguments for update method");
|
2818
|
+
});
|
2819
|
+
}
|
2820
|
+
async updateOrThrow(a, b, c, d) {
|
2821
|
+
return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
|
2822
|
+
const result = await this.update(a, b, c, d);
|
2823
|
+
if (Array.isArray(result)) {
|
2824
|
+
const missingIds = compact(
|
2825
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2826
|
+
);
|
2827
|
+
if (missingIds.length > 0) {
|
2828
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
1331
2829
|
}
|
1332
|
-
|
2830
|
+
return result;
|
1333
2831
|
}
|
1334
|
-
|
2832
|
+
if (result === null) {
|
2833
|
+
const id = extractId(a) ?? "unknown";
|
2834
|
+
throw new Error(`Record with id ${id} not found`);
|
2835
|
+
}
|
2836
|
+
return result;
|
2837
|
+
});
|
1335
2838
|
}
|
1336
|
-
async
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
2839
|
+
async createOrUpdate(a, b, c, d) {
|
2840
|
+
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
2841
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2842
|
+
if (Array.isArray(a)) {
|
2843
|
+
if (a.length === 0)
|
2844
|
+
return [];
|
2845
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
|
2846
|
+
ifVersion,
|
2847
|
+
upsert: true
|
2848
|
+
});
|
2849
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2850
|
+
const result = await this.read(a, columns);
|
2851
|
+
return result;
|
1342
2852
|
}
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
|
1347
|
-
const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b);
|
1348
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1349
|
-
return record;
|
1350
|
-
}
|
1351
|
-
if (isObject(a) && isString(a.id)) {
|
1352
|
-
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
|
1353
|
-
const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
|
1354
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1355
|
-
return record;
|
1356
|
-
}
|
1357
|
-
throw new Error("Invalid arguments for update method");
|
1358
|
-
}
|
1359
|
-
async createOrUpdate(a, b) {
|
1360
|
-
if (Array.isArray(a)) {
|
1361
|
-
if (a.length === 0)
|
1362
|
-
return [];
|
1363
|
-
if (a.length > 100) {
|
1364
|
-
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
2853
|
+
if (isString(a) && isObject(b)) {
|
2854
|
+
const columns = isStringArray(c) ? c : void 0;
|
2855
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
1365
2856
|
}
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
|
1370
|
-
const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b);
|
1371
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1372
|
-
return record;
|
1373
|
-
}
|
1374
|
-
if (isObject(a) && isString(a.id)) {
|
1375
|
-
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
|
1376
|
-
const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
|
1377
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1378
|
-
return record;
|
1379
|
-
}
|
1380
|
-
throw new Error("Invalid arguments for createOrUpdate method");
|
1381
|
-
}
|
1382
|
-
async delete(a) {
|
1383
|
-
if (Array.isArray(a)) {
|
1384
|
-
if (a.length === 0)
|
1385
|
-
return;
|
1386
|
-
if (a.length > 100) {
|
1387
|
-
console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
|
2857
|
+
if (isObject(a) && isString(a.id)) {
|
2858
|
+
const columns = isStringArray(c) ? c : void 0;
|
2859
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
1388
2860
|
}
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
2861
|
+
throw new Error("Invalid arguments for createOrUpdate method");
|
2862
|
+
});
|
2863
|
+
}
|
2864
|
+
async createOrReplace(a, b, c, d) {
|
2865
|
+
return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
|
2866
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2867
|
+
if (Array.isArray(a)) {
|
2868
|
+
if (a.length === 0)
|
2869
|
+
return [];
|
2870
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
2871
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2872
|
+
const result = await this.read(ids, columns);
|
2873
|
+
return result;
|
2874
|
+
}
|
2875
|
+
if (isString(a) && isObject(b)) {
|
2876
|
+
const columns = isStringArray(c) ? c : void 0;
|
2877
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
2878
|
+
}
|
2879
|
+
if (isObject(a) && isString(a.id)) {
|
2880
|
+
const columns = isStringArray(c) ? c : void 0;
|
2881
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
2882
|
+
}
|
2883
|
+
throw new Error("Invalid arguments for createOrReplace method");
|
2884
|
+
});
|
2885
|
+
}
|
2886
|
+
async delete(a, b) {
|
2887
|
+
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
2888
|
+
if (Array.isArray(a)) {
|
2889
|
+
if (a.length === 0)
|
2890
|
+
return [];
|
2891
|
+
const ids = a.map((o) => {
|
2892
|
+
if (isString(o))
|
2893
|
+
return o;
|
2894
|
+
if (isString(o.id))
|
2895
|
+
return o.id;
|
2896
|
+
throw new Error("Invalid arguments for delete method");
|
2897
|
+
});
|
2898
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2899
|
+
const result = await this.read(a, columns);
|
2900
|
+
await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
|
2901
|
+
return result;
|
2902
|
+
}
|
2903
|
+
if (isString(a)) {
|
2904
|
+
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
|
2905
|
+
}
|
2906
|
+
if (isObject(a) && isString(a.id)) {
|
2907
|
+
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
|
2908
|
+
}
|
2909
|
+
throw new Error("Invalid arguments for delete method");
|
2910
|
+
});
|
2911
|
+
}
|
2912
|
+
async deleteOrThrow(a, b) {
|
2913
|
+
return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
|
2914
|
+
const result = await this.delete(a, b);
|
2915
|
+
if (Array.isArray(result)) {
|
2916
|
+
const missingIds = compact(
|
2917
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2918
|
+
);
|
2919
|
+
if (missingIds.length > 0) {
|
2920
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
2921
|
+
}
|
2922
|
+
return result;
|
2923
|
+
} else if (result === null) {
|
2924
|
+
const id = extractId(a) ?? "unknown";
|
2925
|
+
throw new Error(`Record with id ${id} not found`);
|
2926
|
+
}
|
2927
|
+
return result;
|
2928
|
+
});
|
1403
2929
|
}
|
1404
2930
|
async search(query, options = {}) {
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
2931
|
+
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
2932
|
+
const { records } = await searchTable({
|
2933
|
+
pathParams: {
|
2934
|
+
workspace: "{workspaceId}",
|
2935
|
+
dbBranchName: "{dbBranch}",
|
2936
|
+
region: "{region}",
|
2937
|
+
tableName: __privateGet$4(this, _table)
|
2938
|
+
},
|
2939
|
+
body: {
|
2940
|
+
query,
|
2941
|
+
fuzziness: options.fuzziness,
|
2942
|
+
prefix: options.prefix,
|
2943
|
+
highlight: options.highlight,
|
2944
|
+
filter: options.filter,
|
2945
|
+
boosters: options.boosters,
|
2946
|
+
page: options.page,
|
2947
|
+
target: options.target
|
2948
|
+
},
|
2949
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2950
|
+
});
|
2951
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2952
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
2953
|
+
});
|
2954
|
+
}
|
2955
|
+
async vectorSearch(column, query, options) {
|
2956
|
+
return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
|
2957
|
+
const { records } = await vectorSearchTable({
|
2958
|
+
pathParams: {
|
2959
|
+
workspace: "{workspaceId}",
|
2960
|
+
dbBranchName: "{dbBranch}",
|
2961
|
+
region: "{region}",
|
2962
|
+
tableName: __privateGet$4(this, _table)
|
2963
|
+
},
|
2964
|
+
body: {
|
2965
|
+
column,
|
2966
|
+
queryVector: query,
|
2967
|
+
similarityFunction: options?.similarityFunction,
|
2968
|
+
size: options?.size,
|
2969
|
+
filter: options?.filter
|
2970
|
+
},
|
2971
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2972
|
+
});
|
2973
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2974
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
2975
|
+
});
|
2976
|
+
}
|
2977
|
+
async aggregate(aggs, filter) {
|
2978
|
+
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
2979
|
+
const result = await aggregateTable({
|
2980
|
+
pathParams: {
|
2981
|
+
workspace: "{workspaceId}",
|
2982
|
+
dbBranchName: "{dbBranch}",
|
2983
|
+
region: "{region}",
|
2984
|
+
tableName: __privateGet$4(this, _table)
|
2985
|
+
},
|
2986
|
+
body: { aggs, filter },
|
2987
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2988
|
+
});
|
2989
|
+
return result;
|
1415
2990
|
});
|
1416
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1417
|
-
return records.map((item) => initObject(this.db, schemaTables, __privateGet$4(this, _table), item));
|
1418
2991
|
}
|
1419
2992
|
async query(query) {
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
2993
|
+
return __privateGet$4(this, _trace).call(this, "query", async () => {
|
2994
|
+
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
2995
|
+
if (cacheQuery)
|
2996
|
+
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
2997
|
+
const data = query.getQueryOptions();
|
2998
|
+
const { meta, records: objects } = await queryTable({
|
2999
|
+
pathParams: {
|
3000
|
+
workspace: "{workspaceId}",
|
3001
|
+
dbBranchName: "{dbBranch}",
|
3002
|
+
region: "{region}",
|
3003
|
+
tableName: __privateGet$4(this, _table)
|
3004
|
+
},
|
3005
|
+
body: {
|
3006
|
+
filter: cleanFilter(data.filter),
|
3007
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
3008
|
+
page: data.pagination,
|
3009
|
+
columns: data.columns ?? ["*"],
|
3010
|
+
consistency: data.consistency
|
3011
|
+
},
|
3012
|
+
fetchOptions: data.fetchOptions,
|
3013
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3014
|
+
});
|
3015
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3016
|
+
const records = objects.map(
|
3017
|
+
(record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
|
3018
|
+
);
|
3019
|
+
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
3020
|
+
return new Page(query, meta, records);
|
1435
3021
|
});
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
3022
|
+
}
|
3023
|
+
async summarizeTable(query, summaries, summariesFilter) {
|
3024
|
+
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
3025
|
+
const data = query.getQueryOptions();
|
3026
|
+
const result = await summarizeTable({
|
3027
|
+
pathParams: {
|
3028
|
+
workspace: "{workspaceId}",
|
3029
|
+
dbBranchName: "{dbBranch}",
|
3030
|
+
region: "{region}",
|
3031
|
+
tableName: __privateGet$4(this, _table)
|
3032
|
+
},
|
3033
|
+
body: {
|
3034
|
+
filter: cleanFilter(data.filter),
|
3035
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
3036
|
+
columns: data.columns,
|
3037
|
+
consistency: data.consistency,
|
3038
|
+
page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
|
3039
|
+
summaries,
|
3040
|
+
summariesFilter
|
3041
|
+
},
|
3042
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3043
|
+
});
|
3044
|
+
return result;
|
3045
|
+
});
|
3046
|
+
}
|
3047
|
+
ask(question, options) {
|
3048
|
+
const params = {
|
3049
|
+
pathParams: {
|
3050
|
+
workspace: "{workspaceId}",
|
3051
|
+
dbBranchName: "{dbBranch}",
|
3052
|
+
region: "{region}",
|
3053
|
+
tableName: __privateGet$4(this, _table)
|
3054
|
+
},
|
3055
|
+
body: {
|
3056
|
+
question,
|
3057
|
+
...options
|
3058
|
+
},
|
3059
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3060
|
+
};
|
3061
|
+
if (options?.onMessage) {
|
3062
|
+
fetchSSERequest({
|
3063
|
+
endpoint: "dataPlane",
|
3064
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
3065
|
+
method: "POST",
|
3066
|
+
onMessage: (message) => {
|
3067
|
+
options.onMessage?.({ answer: message.text, records: message.records });
|
3068
|
+
},
|
3069
|
+
...params
|
3070
|
+
});
|
3071
|
+
} else {
|
3072
|
+
return askTable(params);
|
3073
|
+
}
|
1440
3074
|
}
|
1441
3075
|
}
|
1442
3076
|
_table = new WeakMap();
|
1443
3077
|
_getFetchProps = new WeakMap();
|
3078
|
+
_db = new WeakMap();
|
1444
3079
|
_cache = new WeakMap();
|
1445
3080
|
_schemaTables$2 = new WeakMap();
|
3081
|
+
_trace = new WeakMap();
|
1446
3082
|
_insertRecordWithoutId = new WeakSet();
|
1447
|
-
insertRecordWithoutId_fn = async function(object) {
|
1448
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
3083
|
+
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
1449
3084
|
const record = transformObjectLinks(object);
|
1450
3085
|
const response = await insertRecord({
|
1451
3086
|
pathParams: {
|
1452
3087
|
workspace: "{workspaceId}",
|
1453
3088
|
dbBranchName: "{dbBranch}",
|
3089
|
+
region: "{region}",
|
1454
3090
|
tableName: __privateGet$4(this, _table)
|
1455
3091
|
},
|
3092
|
+
queryParams: { columns },
|
1456
3093
|
body: record,
|
1457
|
-
...
|
3094
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
1458
3095
|
});
|
1459
|
-
const
|
1460
|
-
|
1461
|
-
throw new Error("The server failed to save the record");
|
1462
|
-
}
|
1463
|
-
return finalObject;
|
3096
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3097
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1464
3098
|
};
|
1465
3099
|
_insertRecordWithId = new WeakSet();
|
1466
|
-
insertRecordWithId_fn = async function(recordId, object) {
|
1467
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
3100
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
1468
3101
|
const record = transformObjectLinks(object);
|
1469
3102
|
const response = await insertRecordWithID({
|
1470
3103
|
pathParams: {
|
1471
3104
|
workspace: "{workspaceId}",
|
1472
3105
|
dbBranchName: "{dbBranch}",
|
3106
|
+
region: "{region}",
|
1473
3107
|
tableName: __privateGet$4(this, _table),
|
1474
3108
|
recordId
|
1475
3109
|
},
|
1476
3110
|
body: record,
|
1477
|
-
queryParams: { createOnly
|
1478
|
-
...
|
3111
|
+
queryParams: { createOnly, columns, ifVersion },
|
3112
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
1479
3113
|
});
|
1480
|
-
const
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
3114
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3115
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
3116
|
+
};
|
3117
|
+
_insertRecords = new WeakSet();
|
3118
|
+
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
3119
|
+
const chunkedOperations = chunk(
|
3120
|
+
objects.map((object) => ({
|
3121
|
+
insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
|
3122
|
+
})),
|
3123
|
+
BULK_OPERATION_MAX_SIZE
|
3124
|
+
);
|
3125
|
+
const ids = [];
|
3126
|
+
for (const operations of chunkedOperations) {
|
3127
|
+
const { results } = await branchTransaction({
|
3128
|
+
pathParams: {
|
3129
|
+
workspace: "{workspaceId}",
|
3130
|
+
dbBranchName: "{dbBranch}",
|
3131
|
+
region: "{region}"
|
3132
|
+
},
|
3133
|
+
body: { operations },
|
3134
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3135
|
+
});
|
3136
|
+
for (const result of results) {
|
3137
|
+
if (result.operation === "insert") {
|
3138
|
+
ids.push(result.id);
|
3139
|
+
} else {
|
3140
|
+
ids.push(null);
|
3141
|
+
}
|
3142
|
+
}
|
1498
3143
|
}
|
1499
|
-
|
1500
|
-
acc[object.id] = object;
|
1501
|
-
return acc;
|
1502
|
-
}, {});
|
1503
|
-
return recordIDs.map((id) => dictionary[id]);
|
3144
|
+
return ids;
|
1504
3145
|
};
|
1505
3146
|
_updateRecordWithID = new WeakSet();
|
1506
|
-
updateRecordWithID_fn = async function(recordId, object) {
|
1507
|
-
const
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
3147
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
3148
|
+
const { id: _id, ...record } = transformObjectLinks(object);
|
3149
|
+
try {
|
3150
|
+
const response = await updateRecordWithID({
|
3151
|
+
pathParams: {
|
3152
|
+
workspace: "{workspaceId}",
|
3153
|
+
dbBranchName: "{dbBranch}",
|
3154
|
+
region: "{region}",
|
3155
|
+
tableName: __privateGet$4(this, _table),
|
3156
|
+
recordId
|
3157
|
+
},
|
3158
|
+
queryParams: { columns, ifVersion },
|
3159
|
+
body: record,
|
3160
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3161
|
+
});
|
3162
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3163
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
3164
|
+
} catch (e) {
|
3165
|
+
if (isObject(e) && e.status === 404) {
|
3166
|
+
return null;
|
3167
|
+
}
|
3168
|
+
throw e;
|
3169
|
+
}
|
3170
|
+
};
|
3171
|
+
_updateRecords = new WeakSet();
|
3172
|
+
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
3173
|
+
const chunkedOperations = chunk(
|
3174
|
+
objects.map(({ id, ...object }) => ({
|
3175
|
+
update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
|
3176
|
+
})),
|
3177
|
+
BULK_OPERATION_MAX_SIZE
|
3178
|
+
);
|
3179
|
+
const ids = [];
|
3180
|
+
for (const operations of chunkedOperations) {
|
3181
|
+
const { results } = await branchTransaction({
|
3182
|
+
pathParams: {
|
3183
|
+
workspace: "{workspaceId}",
|
3184
|
+
dbBranchName: "{dbBranch}",
|
3185
|
+
region: "{region}"
|
3186
|
+
},
|
3187
|
+
body: { operations },
|
3188
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3189
|
+
});
|
3190
|
+
for (const result of results) {
|
3191
|
+
if (result.operation === "update") {
|
3192
|
+
ids.push(result.id);
|
3193
|
+
} else {
|
3194
|
+
ids.push(null);
|
3195
|
+
}
|
3196
|
+
}
|
3197
|
+
}
|
3198
|
+
return ids;
|
1518
3199
|
};
|
1519
3200
|
_upsertRecordWithID = new WeakSet();
|
1520
|
-
upsertRecordWithID_fn = async function(recordId, object) {
|
1521
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
3201
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
1522
3202
|
const response = await upsertRecordWithID({
|
1523
|
-
pathParams: {
|
3203
|
+
pathParams: {
|
3204
|
+
workspace: "{workspaceId}",
|
3205
|
+
dbBranchName: "{dbBranch}",
|
3206
|
+
region: "{region}",
|
3207
|
+
tableName: __privateGet$4(this, _table),
|
3208
|
+
recordId
|
3209
|
+
},
|
3210
|
+
queryParams: { columns, ifVersion },
|
1524
3211
|
body: object,
|
1525
|
-
...
|
3212
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
1526
3213
|
});
|
1527
|
-
const
|
1528
|
-
|
1529
|
-
throw new Error("The server failed to save the record");
|
1530
|
-
return item;
|
3214
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3215
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1531
3216
|
};
|
1532
3217
|
_deleteRecord = new WeakSet();
|
1533
|
-
deleteRecord_fn = async function(recordId) {
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
3218
|
+
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
3219
|
+
try {
|
3220
|
+
const response = await deleteRecord({
|
3221
|
+
pathParams: {
|
3222
|
+
workspace: "{workspaceId}",
|
3223
|
+
dbBranchName: "{dbBranch}",
|
3224
|
+
region: "{region}",
|
3225
|
+
tableName: __privateGet$4(this, _table),
|
3226
|
+
recordId
|
3227
|
+
},
|
3228
|
+
queryParams: { columns },
|
3229
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3230
|
+
});
|
3231
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3232
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
3233
|
+
} catch (e) {
|
3234
|
+
if (isObject(e) && e.status === 404) {
|
3235
|
+
return null;
|
3236
|
+
}
|
3237
|
+
throw e;
|
3238
|
+
}
|
1539
3239
|
};
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
}
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
}
|
1557
|
-
_getCacheRecord = new WeakSet();
|
1558
|
-
getCacheRecord_fn = async function(recordId) {
|
1559
|
-
if (!__privateGet$4(this, _cache).cacheRecords)
|
1560
|
-
return null;
|
1561
|
-
return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
3240
|
+
_deleteRecords = new WeakSet();
|
3241
|
+
deleteRecords_fn = async function(recordIds) {
|
3242
|
+
const chunkedOperations = chunk(
|
3243
|
+
recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
3244
|
+
BULK_OPERATION_MAX_SIZE
|
3245
|
+
);
|
3246
|
+
for (const operations of chunkedOperations) {
|
3247
|
+
await branchTransaction({
|
3248
|
+
pathParams: {
|
3249
|
+
workspace: "{workspaceId}",
|
3250
|
+
dbBranchName: "{dbBranch}",
|
3251
|
+
region: "{region}"
|
3252
|
+
},
|
3253
|
+
body: { operations },
|
3254
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3255
|
+
});
|
3256
|
+
}
|
1562
3257
|
};
|
1563
3258
|
_setCacheQuery = new WeakSet();
|
1564
3259
|
setCacheQuery_fn = async function(query, meta, records) {
|
1565
|
-
await __privateGet$4(this, _cache)
|
3260
|
+
await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
1566
3261
|
};
|
1567
3262
|
_getCacheQuery = new WeakSet();
|
1568
3263
|
getCacheQuery_fn = async function(query) {
|
1569
3264
|
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
1570
|
-
const result = await __privateGet$4(this, _cache)
|
3265
|
+
const result = await __privateGet$4(this, _cache)?.get(key);
|
1571
3266
|
if (!result)
|
1572
3267
|
return null;
|
1573
|
-
const
|
3268
|
+
const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
|
3269
|
+
const { cache: ttl = defaultTTL } = query.getQueryOptions();
|
1574
3270
|
if (ttl < 0)
|
1575
3271
|
return null;
|
1576
3272
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
@@ -1580,10 +3276,9 @@ _getSchemaTables$1 = new WeakSet();
|
|
1580
3276
|
getSchemaTables_fn$1 = async function() {
|
1581
3277
|
if (__privateGet$4(this, _schemaTables$2))
|
1582
3278
|
return __privateGet$4(this, _schemaTables$2);
|
1583
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1584
3279
|
const { schema } = await getBranchDetails({
|
1585
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1586
|
-
...
|
3280
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3281
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
1587
3282
|
});
|
1588
3283
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
1589
3284
|
return schema.tables;
|
@@ -1595,22 +3290,24 @@ const transformObjectLinks = (object) => {
|
|
1595
3290
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1596
3291
|
}, {});
|
1597
3292
|
};
|
1598
|
-
const initObject = (db, schemaTables, table, object) => {
|
1599
|
-
const
|
3293
|
+
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
3294
|
+
const data = {};
|
1600
3295
|
const { xata, ...rest } = object ?? {};
|
1601
|
-
Object.assign(
|
3296
|
+
Object.assign(data, rest);
|
1602
3297
|
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
1603
3298
|
if (!columns)
|
1604
3299
|
console.error(`Table ${table} not found in schema`);
|
1605
3300
|
for (const column of columns ?? []) {
|
1606
|
-
|
3301
|
+
if (!isValidColumn(selectedColumns, column))
|
3302
|
+
continue;
|
3303
|
+
const value = data[column.name];
|
1607
3304
|
switch (column.type) {
|
1608
3305
|
case "datetime": {
|
1609
|
-
const date = value !== void 0 ? new Date(value) :
|
1610
|
-
if (date && isNaN(date.getTime())) {
|
3306
|
+
const date = value !== void 0 ? new Date(value) : null;
|
3307
|
+
if (date !== null && isNaN(date.getTime())) {
|
1611
3308
|
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
1612
|
-
} else
|
1613
|
-
|
3309
|
+
} else {
|
3310
|
+
data[column.name] = date;
|
1614
3311
|
}
|
1615
3312
|
break;
|
1616
3313
|
}
|
@@ -1619,38 +3316,85 @@ const initObject = (db, schemaTables, table, object) => {
|
|
1619
3316
|
if (!linkTable) {
|
1620
3317
|
console.error(`Failed to parse link for field ${column.name}`);
|
1621
3318
|
} else if (isObject(value)) {
|
1622
|
-
|
3319
|
+
const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
|
3320
|
+
if (item === column.name) {
|
3321
|
+
return [...acc, "*"];
|
3322
|
+
}
|
3323
|
+
if (item.startsWith(`${column.name}.`)) {
|
3324
|
+
const [, ...path] = item.split(".");
|
3325
|
+
return [...acc, path.join(".")];
|
3326
|
+
}
|
3327
|
+
return acc;
|
3328
|
+
}, []);
|
3329
|
+
data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
|
3330
|
+
} else {
|
3331
|
+
data[column.name] = null;
|
1623
3332
|
}
|
1624
3333
|
break;
|
1625
3334
|
}
|
3335
|
+
default:
|
3336
|
+
data[column.name] = value ?? null;
|
3337
|
+
if (column.notNull === true && value === null) {
|
3338
|
+
console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
|
3339
|
+
}
|
3340
|
+
break;
|
1626
3341
|
}
|
1627
3342
|
}
|
1628
|
-
|
1629
|
-
|
3343
|
+
const record = { ...data };
|
3344
|
+
record.read = function(columns2) {
|
3345
|
+
return db[table].read(record["id"], columns2);
|
1630
3346
|
};
|
1631
|
-
|
1632
|
-
|
3347
|
+
record.update = function(data2, b, c) {
|
3348
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
3349
|
+
const ifVersion = parseIfVersion(b, c);
|
3350
|
+
return db[table].update(record["id"], data2, columns2, { ifVersion });
|
1633
3351
|
};
|
1634
|
-
|
1635
|
-
|
3352
|
+
record.replace = function(data2, b, c) {
|
3353
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
3354
|
+
const ifVersion = parseIfVersion(b, c);
|
3355
|
+
return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
|
1636
3356
|
};
|
1637
|
-
|
3357
|
+
record.delete = function() {
|
3358
|
+
return db[table].delete(record["id"]);
|
3359
|
+
};
|
3360
|
+
record.getMetadata = function() {
|
1638
3361
|
return xata;
|
1639
3362
|
};
|
1640
|
-
|
1641
|
-
|
3363
|
+
record.toSerializable = function() {
|
3364
|
+
return JSON.parse(JSON.stringify(transformObjectLinks(data)));
|
3365
|
+
};
|
3366
|
+
record.toString = function() {
|
3367
|
+
return JSON.stringify(transformObjectLinks(data));
|
3368
|
+
};
|
3369
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
3370
|
+
Object.defineProperty(record, prop, { enumerable: false });
|
1642
3371
|
}
|
1643
|
-
Object.freeze(
|
1644
|
-
return
|
3372
|
+
Object.freeze(record);
|
3373
|
+
return record;
|
1645
3374
|
};
|
1646
|
-
function
|
1647
|
-
if (
|
1648
|
-
return value
|
3375
|
+
function extractId(value) {
|
3376
|
+
if (isString(value))
|
3377
|
+
return value;
|
3378
|
+
if (isObject(value) && isString(value.id))
|
3379
|
+
return value.id;
|
3380
|
+
return void 0;
|
3381
|
+
}
|
3382
|
+
function isValidColumn(columns, column) {
|
3383
|
+
if (columns.includes("*"))
|
3384
|
+
return true;
|
3385
|
+
if (column.type === "link") {
|
3386
|
+
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
3387
|
+
return linkColumns.length > 0;
|
3388
|
+
}
|
3389
|
+
return columns.includes(column.name);
|
3390
|
+
}
|
3391
|
+
function parseIfVersion(...args) {
|
3392
|
+
for (const arg of args) {
|
3393
|
+
if (isObject(arg) && isNumber(arg.ifVersion)) {
|
3394
|
+
return arg.ifVersion;
|
3395
|
+
}
|
1649
3396
|
}
|
1650
|
-
|
1651
|
-
return [];
|
1652
|
-
const nestedIds = Object.values(value).map((item) => getIds(item)).flat();
|
1653
|
-
return isString(value.id) ? [value.id, ...nestedIds] : nestedIds;
|
3397
|
+
return void 0;
|
1654
3398
|
}
|
1655
3399
|
|
1656
3400
|
var __accessCheck$3 = (obj, member, msg) => {
|
@@ -1677,7 +3421,6 @@ class SimpleCache {
|
|
1677
3421
|
__privateAdd$3(this, _map, void 0);
|
1678
3422
|
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
1679
3423
|
this.capacity = options.max ?? 500;
|
1680
|
-
this.cacheRecords = options.cacheRecords ?? true;
|
1681
3424
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
1682
3425
|
}
|
1683
3426
|
async getAll() {
|
@@ -1703,18 +3446,25 @@ class SimpleCache {
|
|
1703
3446
|
}
|
1704
3447
|
_map = new WeakMap();
|
1705
3448
|
|
1706
|
-
const
|
1707
|
-
const
|
1708
|
-
const
|
1709
|
-
const
|
1710
|
-
const
|
1711
|
-
const
|
3449
|
+
const greaterThan = (value) => ({ $gt: value });
|
3450
|
+
const gt = greaterThan;
|
3451
|
+
const greaterThanEquals = (value) => ({ $ge: value });
|
3452
|
+
const greaterEquals = greaterThanEquals;
|
3453
|
+
const gte = greaterThanEquals;
|
3454
|
+
const ge = greaterThanEquals;
|
3455
|
+
const lessThan = (value) => ({ $lt: value });
|
3456
|
+
const lt = lessThan;
|
3457
|
+
const lessThanEquals = (value) => ({ $le: value });
|
3458
|
+
const lessEquals = lessThanEquals;
|
3459
|
+
const lte = lessThanEquals;
|
3460
|
+
const le = lessThanEquals;
|
1712
3461
|
const exists = (column) => ({ $exists: column });
|
1713
3462
|
const notExists = (column) => ({ $notExists: column });
|
1714
3463
|
const startsWith = (value) => ({ $startsWith: value });
|
1715
3464
|
const endsWith = (value) => ({ $endsWith: value });
|
1716
3465
|
const pattern = (value) => ({ $pattern: value });
|
1717
3466
|
const is = (value) => ({ $is: value });
|
3467
|
+
const equals = is;
|
1718
3468
|
const isNot = (value) => ({ $isNot: value });
|
1719
3469
|
const contains = (value) => ({ $contains: value });
|
1720
3470
|
const includes = (value) => ({ $includes: value });
|
@@ -1749,16 +3499,19 @@ class SchemaPlugin extends XataPlugin {
|
|
1749
3499
|
__privateSet$2(this, _schemaTables$1, schemaTables);
|
1750
3500
|
}
|
1751
3501
|
build(pluginOptions) {
|
1752
|
-
const db = new Proxy(
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
3502
|
+
const db = new Proxy(
|
3503
|
+
{},
|
3504
|
+
{
|
3505
|
+
get: (_target, table) => {
|
3506
|
+
if (!isString(table))
|
3507
|
+
throw new Error("Invalid table name");
|
3508
|
+
if (__privateGet$2(this, _tables)[table] === void 0) {
|
3509
|
+
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
3510
|
+
}
|
3511
|
+
return __privateGet$2(this, _tables)[table];
|
1758
3512
|
}
|
1759
|
-
return __privateGet$2(this, _tables)[table];
|
1760
3513
|
}
|
1761
|
-
|
3514
|
+
);
|
1762
3515
|
const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
|
1763
3516
|
for (const table of tableNames) {
|
1764
3517
|
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
@@ -1801,23 +3554,23 @@ class SearchPlugin extends XataPlugin {
|
|
1801
3554
|
__privateAdd$1(this, _schemaTables, void 0);
|
1802
3555
|
__privateSet$1(this, _schemaTables, schemaTables);
|
1803
3556
|
}
|
1804
|
-
build(
|
3557
|
+
build(pluginOptions) {
|
1805
3558
|
return {
|
1806
3559
|
all: async (query, options = {}) => {
|
1807
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
1808
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
3560
|
+
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
3561
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
1809
3562
|
return records.map((record) => {
|
1810
3563
|
const { table = "orphan" } = record.xata;
|
1811
|
-
return { table, record: initObject(this.db, schemaTables, table, record) };
|
3564
|
+
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
1812
3565
|
});
|
1813
3566
|
},
|
1814
3567
|
byTable: async (query, options = {}) => {
|
1815
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
1816
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
3568
|
+
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
3569
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
1817
3570
|
return records.reduce((acc, record) => {
|
1818
3571
|
const { table = "orphan" } = record.xata;
|
1819
3572
|
const items = acc[table] ?? [];
|
1820
|
-
const item = initObject(this.db, schemaTables, table, record);
|
3573
|
+
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
1821
3574
|
return { ...acc, [table]: [...items, item] };
|
1822
3575
|
}, {});
|
1823
3576
|
}
|
@@ -1826,114 +3579,39 @@ class SearchPlugin extends XataPlugin {
|
|
1826
3579
|
}
|
1827
3580
|
_schemaTables = new WeakMap();
|
1828
3581
|
_search = new WeakSet();
|
1829
|
-
search_fn = async function(query, options,
|
1830
|
-
const
|
1831
|
-
const { tables, fuzziness, highlight } = options ?? {};
|
3582
|
+
search_fn = async function(query, options, pluginOptions) {
|
3583
|
+
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
1832
3584
|
const { records } = await searchBranch({
|
1833
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1834
|
-
body: { tables, query, fuzziness, highlight },
|
1835
|
-
...
|
3585
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3586
|
+
body: { tables, query, fuzziness, prefix, highlight, page },
|
3587
|
+
...pluginOptions
|
1836
3588
|
});
|
1837
3589
|
return records;
|
1838
3590
|
};
|
1839
3591
|
_getSchemaTables = new WeakSet();
|
1840
|
-
getSchemaTables_fn = async function(
|
3592
|
+
getSchemaTables_fn = async function(pluginOptions) {
|
1841
3593
|
if (__privateGet$1(this, _schemaTables))
|
1842
3594
|
return __privateGet$1(this, _schemaTables);
|
1843
|
-
const fetchProps = await getFetchProps();
|
1844
3595
|
const { schema } = await getBranchDetails({
|
1845
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1846
|
-
...
|
3596
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3597
|
+
...pluginOptions
|
1847
3598
|
});
|
1848
3599
|
__privateSet$1(this, _schemaTables, schema.tables);
|
1849
3600
|
return schema.tables;
|
1850
3601
|
};
|
1851
3602
|
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
const
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
if (env) {
|
1865
|
-
const details = await getDatabaseBranch(env, options);
|
1866
|
-
if (details)
|
1867
|
-
return env;
|
1868
|
-
console.warn(`Branch ${env} not found in Xata. Ignoring...`);
|
1869
|
-
}
|
1870
|
-
const gitBranch = await getGitBranch();
|
1871
|
-
return resolveXataBranch(gitBranch, options);
|
1872
|
-
}
|
1873
|
-
async function getCurrentBranchDetails(options) {
|
1874
|
-
const branch = await getCurrentBranchName(options);
|
1875
|
-
return getDatabaseBranch(branch, options);
|
1876
|
-
}
|
1877
|
-
async function resolveXataBranch(gitBranch, options) {
|
1878
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1879
|
-
const apiKey = options?.apiKey || getAPIKey();
|
1880
|
-
if (!databaseURL)
|
1881
|
-
throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
|
1882
|
-
if (!apiKey)
|
1883
|
-
throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
|
1884
|
-
const [protocol, , host, , dbName] = databaseURL.split("/");
|
1885
|
-
const [workspace] = host.split(".");
|
1886
|
-
const { branch } = await resolveBranch({
|
1887
|
-
apiKey,
|
1888
|
-
apiUrl: databaseURL,
|
1889
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1890
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
1891
|
-
pathParams: { dbName, workspace },
|
1892
|
-
queryParams: { gitBranch, fallbackBranch: getEnvVariable("XATA_FALLBACK_BRANCH") }
|
1893
|
-
});
|
1894
|
-
return branch;
|
1895
|
-
}
|
1896
|
-
async function getDatabaseBranch(branch, options) {
|
1897
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1898
|
-
const apiKey = options?.apiKey || getAPIKey();
|
1899
|
-
if (!databaseURL)
|
1900
|
-
throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
|
1901
|
-
if (!apiKey)
|
1902
|
-
throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
|
1903
|
-
const [protocol, , host, , database] = databaseURL.split("/");
|
1904
|
-
const [workspace] = host.split(".");
|
1905
|
-
const dbBranchName = `${database}:${branch}`;
|
1906
|
-
try {
|
1907
|
-
return await getBranchDetails({
|
1908
|
-
apiKey,
|
1909
|
-
apiUrl: databaseURL,
|
1910
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1911
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
1912
|
-
pathParams: { dbBranchName, workspace }
|
1913
|
-
});
|
1914
|
-
} catch (err) {
|
1915
|
-
if (isObject(err) && err.status === 404)
|
1916
|
-
return null;
|
1917
|
-
throw err;
|
1918
|
-
}
|
1919
|
-
}
|
1920
|
-
function getBranchByEnvVariable() {
|
1921
|
-
for (const name of envBranchNames) {
|
1922
|
-
const value = getEnvVariable(name);
|
1923
|
-
if (value) {
|
1924
|
-
return value;
|
1925
|
-
}
|
1926
|
-
}
|
1927
|
-
try {
|
1928
|
-
return XATA_BRANCH;
|
1929
|
-
} catch (err) {
|
1930
|
-
}
|
1931
|
-
}
|
1932
|
-
function getDatabaseURL() {
|
1933
|
-
try {
|
1934
|
-
return getEnvVariable("XATA_DATABASE_URL") ?? XATA_DATABASE_URL;
|
1935
|
-
} catch (err) {
|
1936
|
-
return void 0;
|
3603
|
+
class TransactionPlugin extends XataPlugin {
|
3604
|
+
build(pluginOptions) {
|
3605
|
+
return {
|
3606
|
+
run: async (operations) => {
|
3607
|
+
const response = await branchTransaction({
|
3608
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3609
|
+
body: { operations },
|
3610
|
+
...pluginOptions
|
3611
|
+
});
|
3612
|
+
return response;
|
3613
|
+
}
|
3614
|
+
};
|
1937
3615
|
}
|
1938
3616
|
}
|
1939
3617
|
|
@@ -1960,85 +3638,202 @@ var __privateMethod = (obj, member, method) => {
|
|
1960
3638
|
return method;
|
1961
3639
|
};
|
1962
3640
|
const buildClient = (plugins) => {
|
1963
|
-
var
|
3641
|
+
var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
|
1964
3642
|
return _a = class {
|
1965
3643
|
constructor(options = {}, schemaTables) {
|
1966
3644
|
__privateAdd(this, _parseOptions);
|
1967
3645
|
__privateAdd(this, _getFetchProps);
|
1968
|
-
__privateAdd(this,
|
1969
|
-
__privateAdd(this, _branch, void 0);
|
3646
|
+
__privateAdd(this, _options, void 0);
|
1970
3647
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
3648
|
+
__privateSet(this, _options, safeOptions);
|
1971
3649
|
const pluginOptions = {
|
1972
|
-
|
1973
|
-
cache: safeOptions.cache
|
3650
|
+
...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
3651
|
+
cache: safeOptions.cache,
|
3652
|
+
host: safeOptions.host
|
1974
3653
|
};
|
1975
3654
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
1976
3655
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
3656
|
+
const transactions = new TransactionPlugin().build(pluginOptions);
|
1977
3657
|
this.db = db;
|
1978
3658
|
this.search = search;
|
3659
|
+
this.transactions = transactions;
|
1979
3660
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
1980
3661
|
if (namespace === void 0)
|
1981
3662
|
continue;
|
1982
|
-
|
1983
|
-
if (result instanceof Promise) {
|
1984
|
-
void result.then((namespace2) => {
|
1985
|
-
this[key] = namespace2;
|
1986
|
-
});
|
1987
|
-
} else {
|
1988
|
-
this[key] = result;
|
1989
|
-
}
|
3663
|
+
this[key] = namespace.build(pluginOptions);
|
1990
3664
|
}
|
1991
3665
|
}
|
1992
|
-
|
3666
|
+
async getConfig() {
|
3667
|
+
const databaseURL = __privateGet(this, _options).databaseURL;
|
3668
|
+
const branch = __privateGet(this, _options).branch;
|
3669
|
+
return { databaseURL, branch };
|
3670
|
+
}
|
3671
|
+
}, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
3672
|
+
const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
|
3673
|
+
const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
|
3674
|
+
if (isBrowser && !enableBrowser) {
|
3675
|
+
throw new Error(
|
3676
|
+
"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."
|
3677
|
+
);
|
3678
|
+
}
|
1993
3679
|
const fetch = getFetchImplementation(options?.fetch);
|
1994
3680
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1995
3681
|
const apiKey = options?.apiKey || getAPIKey();
|
1996
|
-
const cache = options?.cache ?? new SimpleCache({
|
1997
|
-
const
|
1998
|
-
|
1999
|
-
|
3682
|
+
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
3683
|
+
const trace = options?.trace ?? defaultTrace;
|
3684
|
+
const clientName = options?.clientName;
|
3685
|
+
const host = options?.host ?? "production";
|
3686
|
+
const xataAgentExtra = options?.xataAgentExtra;
|
3687
|
+
if (!apiKey) {
|
3688
|
+
throw new Error("Option apiKey is required");
|
3689
|
+
}
|
3690
|
+
if (!databaseURL) {
|
3691
|
+
throw new Error("Option databaseURL is required");
|
2000
3692
|
}
|
2001
|
-
|
2002
|
-
|
3693
|
+
const envBranch = getBranch();
|
3694
|
+
const previewBranch = getPreviewBranch();
|
3695
|
+
const branch = options?.branch || previewBranch || envBranch || "main";
|
3696
|
+
if (!!previewBranch && branch !== previewBranch) {
|
3697
|
+
console.warn(
|
3698
|
+
`Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
|
3699
|
+
);
|
3700
|
+
} else if (!!envBranch && branch !== envBranch) {
|
3701
|
+
console.warn(
|
3702
|
+
`Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
3703
|
+
);
|
3704
|
+
} else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
|
3705
|
+
console.warn(
|
3706
|
+
`Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
3707
|
+
);
|
3708
|
+
} else if (!previewBranch && !envBranch && options?.branch === void 0) {
|
3709
|
+
console.warn(
|
3710
|
+
`No branch was passed to the client constructor. Using default branch ${branch}. You can set the branch with the environment variable XATA_BRANCH or by passing the branch option to the client constructor.`
|
3711
|
+
);
|
3712
|
+
}
|
3713
|
+
return {
|
3714
|
+
fetch,
|
3715
|
+
databaseURL,
|
3716
|
+
apiKey,
|
3717
|
+
branch,
|
3718
|
+
cache,
|
3719
|
+
trace,
|
3720
|
+
host,
|
3721
|
+
clientID: generateUUID(),
|
3722
|
+
enableBrowser,
|
3723
|
+
clientName,
|
3724
|
+
xataAgentExtra
|
3725
|
+
};
|
3726
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
|
2003
3727
|
fetch,
|
2004
3728
|
apiKey,
|
2005
3729
|
databaseURL,
|
2006
|
-
branch
|
3730
|
+
branch,
|
3731
|
+
trace,
|
3732
|
+
clientID,
|
3733
|
+
clientName,
|
3734
|
+
xataAgentExtra
|
2007
3735
|
}) {
|
2008
|
-
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
2009
|
-
if (!branchValue)
|
2010
|
-
throw new Error("Unable to resolve branch value");
|
2011
3736
|
return {
|
2012
|
-
|
3737
|
+
fetch,
|
2013
3738
|
apiKey,
|
2014
3739
|
apiUrl: "",
|
2015
3740
|
workspacesApiUrl: (path, params) => {
|
2016
3741
|
const hasBranch = params.dbBranchName ?? params.branch;
|
2017
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${
|
3742
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
|
2018
3743
|
return databaseURL + newPath;
|
2019
|
-
}
|
2020
|
-
|
2021
|
-
|
2022
|
-
|
2023
|
-
|
2024
|
-
if (param === void 0)
|
2025
|
-
return void 0;
|
2026
|
-
const strategies = Array.isArray(param) ? [...param] : [param];
|
2027
|
-
const evaluateBranch = async (strategy) => {
|
2028
|
-
return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
|
3744
|
+
},
|
3745
|
+
trace,
|
3746
|
+
clientID,
|
3747
|
+
clientName,
|
3748
|
+
xataAgentExtra
|
2029
3749
|
};
|
2030
|
-
for await (const strategy of strategies) {
|
2031
|
-
const branch = await evaluateBranch(strategy);
|
2032
|
-
if (branch) {
|
2033
|
-
__privateSet(this, _branch, branch);
|
2034
|
-
return branch;
|
2035
|
-
}
|
2036
|
-
}
|
2037
3750
|
}, _a;
|
2038
3751
|
};
|
2039
3752
|
class BaseClient extends buildClient() {
|
2040
3753
|
}
|
2041
3754
|
|
3755
|
+
const META = "__";
|
3756
|
+
const VALUE = "___";
|
3757
|
+
class Serializer {
|
3758
|
+
constructor() {
|
3759
|
+
this.classes = {};
|
3760
|
+
}
|
3761
|
+
add(clazz) {
|
3762
|
+
this.classes[clazz.name] = clazz;
|
3763
|
+
}
|
3764
|
+
toJSON(data) {
|
3765
|
+
function visit(obj) {
|
3766
|
+
if (Array.isArray(obj))
|
3767
|
+
return obj.map(visit);
|
3768
|
+
const type = typeof obj;
|
3769
|
+
if (type === "undefined")
|
3770
|
+
return { [META]: "undefined" };
|
3771
|
+
if (type === "bigint")
|
3772
|
+
return { [META]: "bigint", [VALUE]: obj.toString() };
|
3773
|
+
if (obj === null || type !== "object")
|
3774
|
+
return obj;
|
3775
|
+
const constructor = obj.constructor;
|
3776
|
+
const o = { [META]: constructor.name };
|
3777
|
+
for (const [key, value] of Object.entries(obj)) {
|
3778
|
+
o[key] = visit(value);
|
3779
|
+
}
|
3780
|
+
if (constructor === Date)
|
3781
|
+
o[VALUE] = obj.toISOString();
|
3782
|
+
if (constructor === Map)
|
3783
|
+
o[VALUE] = Object.fromEntries(obj);
|
3784
|
+
if (constructor === Set)
|
3785
|
+
o[VALUE] = [...obj];
|
3786
|
+
return o;
|
3787
|
+
}
|
3788
|
+
return JSON.stringify(visit(data));
|
3789
|
+
}
|
3790
|
+
fromJSON(json) {
|
3791
|
+
return JSON.parse(json, (key, value) => {
|
3792
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
3793
|
+
const { [META]: clazz, [VALUE]: val, ...rest } = value;
|
3794
|
+
const constructor = this.classes[clazz];
|
3795
|
+
if (constructor) {
|
3796
|
+
return Object.assign(Object.create(constructor.prototype), rest);
|
3797
|
+
}
|
3798
|
+
if (clazz === "Date")
|
3799
|
+
return new Date(val);
|
3800
|
+
if (clazz === "Set")
|
3801
|
+
return new Set(val);
|
3802
|
+
if (clazz === "Map")
|
3803
|
+
return new Map(Object.entries(val));
|
3804
|
+
if (clazz === "bigint")
|
3805
|
+
return BigInt(val);
|
3806
|
+
if (clazz === "undefined")
|
3807
|
+
return void 0;
|
3808
|
+
return rest;
|
3809
|
+
}
|
3810
|
+
return value;
|
3811
|
+
});
|
3812
|
+
}
|
3813
|
+
}
|
3814
|
+
const defaultSerializer = new Serializer();
|
3815
|
+
const serialize = (data) => {
|
3816
|
+
return defaultSerializer.toJSON(data);
|
3817
|
+
};
|
3818
|
+
const deserialize = (json) => {
|
3819
|
+
return defaultSerializer.fromJSON(json);
|
3820
|
+
};
|
3821
|
+
|
3822
|
+
function buildWorkerRunner(config) {
|
3823
|
+
return function xataWorker(name, worker) {
|
3824
|
+
return async (...args) => {
|
3825
|
+
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
3826
|
+
const result = await fetch(url, {
|
3827
|
+
method: "POST",
|
3828
|
+
headers: { "Content-Type": "application/json" },
|
3829
|
+
body: serialize({ args })
|
3830
|
+
});
|
3831
|
+
const text = await result.text();
|
3832
|
+
return deserialize(text);
|
3833
|
+
};
|
3834
|
+
};
|
3835
|
+
}
|
3836
|
+
|
2042
3837
|
class XataError extends Error {
|
2043
3838
|
constructor(message, status) {
|
2044
3839
|
super(message);
|
@@ -2047,6 +3842,7 @@ class XataError extends Error {
|
|
2047
3842
|
}
|
2048
3843
|
|
2049
3844
|
exports.BaseClient = BaseClient;
|
3845
|
+
exports.FetcherError = FetcherError;
|
2050
3846
|
exports.Operations = operationsByTag;
|
2051
3847
|
exports.PAGINATION_DEFAULT_OFFSET = PAGINATION_DEFAULT_OFFSET;
|
2052
3848
|
exports.PAGINATION_DEFAULT_SIZE = PAGINATION_DEFAULT_SIZE;
|
@@ -2059,6 +3855,7 @@ exports.Repository = Repository;
|
|
2059
3855
|
exports.RestRepository = RestRepository;
|
2060
3856
|
exports.SchemaPlugin = SchemaPlugin;
|
2061
3857
|
exports.SearchPlugin = SearchPlugin;
|
3858
|
+
exports.Serializer = Serializer;
|
2062
3859
|
exports.SimpleCache = SimpleCache;
|
2063
3860
|
exports.XataApiClient = XataApiClient;
|
2064
3861
|
exports.XataApiPlugin = XataApiPlugin;
|
@@ -2067,40 +3864,61 @@ exports.XataPlugin = XataPlugin;
|
|
2067
3864
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
2068
3865
|
exports.addGitBranchesEntry = addGitBranchesEntry;
|
2069
3866
|
exports.addTableColumn = addTableColumn;
|
3867
|
+
exports.aggregateTable = aggregateTable;
|
3868
|
+
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
3869
|
+
exports.askTable = askTable;
|
3870
|
+
exports.branchTransaction = branchTransaction;
|
2070
3871
|
exports.buildClient = buildClient;
|
3872
|
+
exports.buildPreviewBranchName = buildPreviewBranchName;
|
3873
|
+
exports.buildProviderString = buildProviderString;
|
3874
|
+
exports.buildWorkerRunner = buildWorkerRunner;
|
2071
3875
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
2072
3876
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
3877
|
+
exports.compareBranchSchemas = compareBranchSchemas;
|
3878
|
+
exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
|
3879
|
+
exports.compareMigrationRequest = compareMigrationRequest;
|
2073
3880
|
exports.contains = contains;
|
3881
|
+
exports.copyBranch = copyBranch;
|
2074
3882
|
exports.createBranch = createBranch;
|
2075
3883
|
exports.createDatabase = createDatabase;
|
3884
|
+
exports.createMigrationRequest = createMigrationRequest;
|
2076
3885
|
exports.createTable = createTable;
|
2077
3886
|
exports.createUserAPIKey = createUserAPIKey;
|
2078
3887
|
exports.createWorkspace = createWorkspace;
|
2079
3888
|
exports.deleteBranch = deleteBranch;
|
2080
3889
|
exports.deleteColumn = deleteColumn;
|
2081
3890
|
exports.deleteDatabase = deleteDatabase;
|
3891
|
+
exports.deleteDatabaseGithubSettings = deleteDatabaseGithubSettings;
|
2082
3892
|
exports.deleteRecord = deleteRecord;
|
2083
3893
|
exports.deleteTable = deleteTable;
|
2084
3894
|
exports.deleteUser = deleteUser;
|
2085
3895
|
exports.deleteUserAPIKey = deleteUserAPIKey;
|
2086
3896
|
exports.deleteWorkspace = deleteWorkspace;
|
3897
|
+
exports.deserialize = deserialize;
|
2087
3898
|
exports.endsWith = endsWith;
|
3899
|
+
exports.equals = equals;
|
2088
3900
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
2089
3901
|
exports.exists = exists;
|
2090
3902
|
exports.ge = ge;
|
2091
3903
|
exports.getAPIKey = getAPIKey;
|
3904
|
+
exports.getBranch = getBranch;
|
2092
3905
|
exports.getBranchDetails = getBranchDetails;
|
2093
3906
|
exports.getBranchList = getBranchList;
|
2094
3907
|
exports.getBranchMetadata = getBranchMetadata;
|
2095
3908
|
exports.getBranchMigrationHistory = getBranchMigrationHistory;
|
2096
3909
|
exports.getBranchMigrationPlan = getBranchMigrationPlan;
|
3910
|
+
exports.getBranchSchemaHistory = getBranchSchemaHistory;
|
2097
3911
|
exports.getBranchStats = getBranchStats;
|
2098
3912
|
exports.getColumn = getColumn;
|
2099
|
-
exports.
|
2100
|
-
exports.getCurrentBranchName = getCurrentBranchName;
|
3913
|
+
exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
|
2101
3914
|
exports.getDatabaseList = getDatabaseList;
|
3915
|
+
exports.getDatabaseMetadata = getDatabaseMetadata;
|
2102
3916
|
exports.getDatabaseURL = getDatabaseURL;
|
2103
3917
|
exports.getGitBranchesMapping = getGitBranchesMapping;
|
3918
|
+
exports.getHostUrl = getHostUrl;
|
3919
|
+
exports.getMigrationRequest = getMigrationRequest;
|
3920
|
+
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
3921
|
+
exports.getPreviewBranch = getPreviewBranch;
|
2104
3922
|
exports.getRecord = getRecord;
|
2105
3923
|
exports.getTableColumns = getTableColumns;
|
2106
3924
|
exports.getTableSchema = getTableSchema;
|
@@ -2109,6 +3927,9 @@ exports.getUserAPIKeys = getUserAPIKeys;
|
|
2109
3927
|
exports.getWorkspace = getWorkspace;
|
2110
3928
|
exports.getWorkspaceMembersList = getWorkspaceMembersList;
|
2111
3929
|
exports.getWorkspacesList = getWorkspacesList;
|
3930
|
+
exports.greaterEquals = greaterEquals;
|
3931
|
+
exports.greaterThan = greaterThan;
|
3932
|
+
exports.greaterThanEquals = greaterThanEquals;
|
2112
3933
|
exports.gt = gt;
|
2113
3934
|
exports.gte = gte;
|
2114
3935
|
exports.includes = includes;
|
@@ -2120,15 +3941,28 @@ exports.insertRecordWithID = insertRecordWithID;
|
|
2120
3941
|
exports.inviteWorkspaceMember = inviteWorkspaceMember;
|
2121
3942
|
exports.is = is;
|
2122
3943
|
exports.isCursorPaginationOptions = isCursorPaginationOptions;
|
3944
|
+
exports.isHostProviderAlias = isHostProviderAlias;
|
3945
|
+
exports.isHostProviderBuilder = isHostProviderBuilder;
|
2123
3946
|
exports.isIdentifiable = isIdentifiable;
|
2124
3947
|
exports.isNot = isNot;
|
2125
3948
|
exports.isXataRecord = isXataRecord;
|
2126
3949
|
exports.le = le;
|
3950
|
+
exports.lessEquals = lessEquals;
|
3951
|
+
exports.lessThan = lessThan;
|
3952
|
+
exports.lessThanEquals = lessThanEquals;
|
3953
|
+
exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
|
3954
|
+
exports.listRegions = listRegions;
|
2127
3955
|
exports.lt = lt;
|
2128
3956
|
exports.lte = lte;
|
3957
|
+
exports.mergeMigrationRequest = mergeMigrationRequest;
|
2129
3958
|
exports.notExists = notExists;
|
2130
3959
|
exports.operationsByTag = operationsByTag;
|
3960
|
+
exports.parseProviderString = parseProviderString;
|
3961
|
+
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
2131
3962
|
exports.pattern = pattern;
|
3963
|
+
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
3964
|
+
exports.pushBranchMigrations = pushBranchMigrations;
|
3965
|
+
exports.queryMigrationRequests = queryMigrationRequests;
|
2132
3966
|
exports.queryTable = queryTable;
|
2133
3967
|
exports.removeGitBranchesEntry = removeGitBranchesEntry;
|
2134
3968
|
exports.removeWorkspaceMember = removeWorkspaceMember;
|
@@ -2136,14 +3970,23 @@ exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
|
|
2136
3970
|
exports.resolveBranch = resolveBranch;
|
2137
3971
|
exports.searchBranch = searchBranch;
|
2138
3972
|
exports.searchTable = searchTable;
|
3973
|
+
exports.serialize = serialize;
|
2139
3974
|
exports.setTableSchema = setTableSchema;
|
3975
|
+
exports.sqlQuery = sqlQuery;
|
2140
3976
|
exports.startsWith = startsWith;
|
3977
|
+
exports.summarizeTable = summarizeTable;
|
2141
3978
|
exports.updateBranchMetadata = updateBranchMetadata;
|
3979
|
+
exports.updateBranchSchema = updateBranchSchema;
|
2142
3980
|
exports.updateColumn = updateColumn;
|
3981
|
+
exports.updateDatabaseGithubSettings = updateDatabaseGithubSettings;
|
3982
|
+
exports.updateDatabaseMetadata = updateDatabaseMetadata;
|
3983
|
+
exports.updateMigrationRequest = updateMigrationRequest;
|
2143
3984
|
exports.updateRecordWithID = updateRecordWithID;
|
2144
3985
|
exports.updateTable = updateTable;
|
2145
3986
|
exports.updateUser = updateUser;
|
2146
3987
|
exports.updateWorkspace = updateWorkspace;
|
3988
|
+
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
2147
3989
|
exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
|
2148
3990
|
exports.upsertRecordWithID = upsertRecordWithID;
|
3991
|
+
exports.vectorSearchTable = vectorSearchTable;
|
2149
3992
|
//# sourceMappingURL=index.cjs.map
|