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