@xata.io/client 0.0.0-alpha.vfafe7e2 → 0.0.0-alpha.vfb0d929
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/.turbo/turbo-add-version.log +4 -0
- package/.turbo/turbo-build.log +13 -0
- package/CHANGELOG.md +166 -0
- package/README.md +3 -269
- package/dist/index.cjs +1492 -308
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2887 -1144
- package/dist/index.mjs +1462 -307
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -10
- package/.eslintrc.cjs +0 -12
- package/Usage.md +0 -451
- package/rollup.config.mjs +0 -29
- package/tsconfig.json +0 -23
package/dist/index.mjs
CHANGED
@@ -27,8 +27,11 @@ function notEmpty(value) {
|
|
27
27
|
function compact(arr) {
|
28
28
|
return arr.filter(notEmpty);
|
29
29
|
}
|
30
|
+
function compactObject(obj) {
|
31
|
+
return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
|
32
|
+
}
|
30
33
|
function isObject(value) {
|
31
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
34
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date);
|
32
35
|
}
|
33
36
|
function isDefined(value) {
|
34
37
|
return value !== null && value !== void 0;
|
@@ -83,6 +86,27 @@ function chunk(array, chunkSize) {
|
|
83
86
|
async function timeout(ms) {
|
84
87
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
85
88
|
}
|
89
|
+
function timeoutWithCancel(ms) {
|
90
|
+
let timeoutId;
|
91
|
+
const promise = new Promise((resolve) => {
|
92
|
+
timeoutId = setTimeout(() => {
|
93
|
+
resolve();
|
94
|
+
}, ms);
|
95
|
+
});
|
96
|
+
return {
|
97
|
+
cancel: () => clearTimeout(timeoutId),
|
98
|
+
promise
|
99
|
+
};
|
100
|
+
}
|
101
|
+
function promiseMap(inputValues, mapper) {
|
102
|
+
const reducer = (acc$, inputValue) => acc$.then(
|
103
|
+
(acc) => mapper(inputValue).then((result) => {
|
104
|
+
acc.push(result);
|
105
|
+
return acc;
|
106
|
+
})
|
107
|
+
);
|
108
|
+
return inputValues.reduce(reducer, Promise.resolve([]));
|
109
|
+
}
|
86
110
|
|
87
111
|
function getEnvironment() {
|
88
112
|
try {
|
@@ -91,8 +115,10 @@ function getEnvironment() {
|
|
91
115
|
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
92
116
|
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
93
117
|
branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
|
94
|
-
|
95
|
-
|
118
|
+
deployPreview: process.env.XATA_PREVIEW,
|
119
|
+
deployPreviewBranch: process.env.XATA_PREVIEW_BRANCH,
|
120
|
+
vercelGitCommitRef: process.env.VERCEL_GIT_COMMIT_REF,
|
121
|
+
vercelGitRepoOwner: process.env.VERCEL_GIT_REPO_OWNER
|
96
122
|
};
|
97
123
|
}
|
98
124
|
} catch (err) {
|
@@ -103,8 +129,10 @@ function getEnvironment() {
|
|
103
129
|
apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
|
104
130
|
databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
|
105
131
|
branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
|
106
|
-
|
107
|
-
|
132
|
+
deployPreview: Deno.env.get("XATA_PREVIEW"),
|
133
|
+
deployPreviewBranch: Deno.env.get("XATA_PREVIEW_BRANCH"),
|
134
|
+
vercelGitCommitRef: Deno.env.get("VERCEL_GIT_COMMIT_REF"),
|
135
|
+
vercelGitRepoOwner: Deno.env.get("VERCEL_GIT_REPO_OWNER")
|
108
136
|
};
|
109
137
|
}
|
110
138
|
} catch (err) {
|
@@ -113,8 +141,10 @@ function getEnvironment() {
|
|
113
141
|
apiKey: getGlobalApiKey(),
|
114
142
|
databaseURL: getGlobalDatabaseURL(),
|
115
143
|
branch: getGlobalBranch(),
|
116
|
-
|
117
|
-
|
144
|
+
deployPreview: void 0,
|
145
|
+
deployPreviewBranch: void 0,
|
146
|
+
vercelGitCommitRef: void 0,
|
147
|
+
vercelGitRepoOwner: void 0
|
118
148
|
};
|
119
149
|
}
|
120
150
|
function getEnableBrowserVariable() {
|
@@ -157,45 +187,59 @@ function getGlobalBranch() {
|
|
157
187
|
return void 0;
|
158
188
|
}
|
159
189
|
}
|
160
|
-
function
|
190
|
+
function getDatabaseURL() {
|
161
191
|
try {
|
162
|
-
|
192
|
+
const { databaseURL } = getEnvironment();
|
193
|
+
return databaseURL;
|
163
194
|
} catch (err) {
|
164
195
|
return void 0;
|
165
196
|
}
|
166
197
|
}
|
167
|
-
|
168
|
-
const cmd = ["git", "branch", "--show-current"];
|
169
|
-
const fullCmd = cmd.join(" ");
|
170
|
-
const nodeModule = ["child", "process"].join("_");
|
171
|
-
const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
|
198
|
+
function getAPIKey() {
|
172
199
|
try {
|
173
|
-
const
|
174
|
-
|
175
|
-
return req(nodeModule).execSync(fullCmd, execOptions).trim();
|
176
|
-
}
|
177
|
-
const { execSync } = await import(nodeModule);
|
178
|
-
return execSync(fullCmd, execOptions).toString().trim();
|
200
|
+
const { apiKey } = getEnvironment();
|
201
|
+
return apiKey;
|
179
202
|
} catch (err) {
|
203
|
+
return void 0;
|
180
204
|
}
|
205
|
+
}
|
206
|
+
function getBranch() {
|
181
207
|
try {
|
182
|
-
|
183
|
-
|
184
|
-
return new TextDecoder().decode(await process2.output()).trim();
|
185
|
-
}
|
208
|
+
const { branch } = getEnvironment();
|
209
|
+
return branch;
|
186
210
|
} catch (err) {
|
211
|
+
return void 0;
|
187
212
|
}
|
188
213
|
}
|
189
|
-
|
190
|
-
|
214
|
+
function buildPreviewBranchName({ org, branch }) {
|
215
|
+
return `preview-${org}-${branch}`;
|
216
|
+
}
|
217
|
+
function getPreviewBranch() {
|
191
218
|
try {
|
192
|
-
const {
|
193
|
-
|
219
|
+
const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = getEnvironment();
|
220
|
+
if (deployPreviewBranch)
|
221
|
+
return deployPreviewBranch;
|
222
|
+
switch (deployPreview) {
|
223
|
+
case "vercel": {
|
224
|
+
if (!vercelGitCommitRef || !vercelGitRepoOwner) {
|
225
|
+
console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
|
226
|
+
return void 0;
|
227
|
+
}
|
228
|
+
return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
|
229
|
+
}
|
230
|
+
}
|
231
|
+
return void 0;
|
194
232
|
} catch (err) {
|
195
233
|
return void 0;
|
196
234
|
}
|
197
235
|
}
|
198
236
|
|
237
|
+
var __defProp$8 = Object.defineProperty;
|
238
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
239
|
+
var __publicField$8 = (obj, key, value) => {
|
240
|
+
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
241
|
+
return value;
|
242
|
+
};
|
199
243
|
var __accessCheck$8 = (obj, member, msg) => {
|
200
244
|
if (!member.has(obj))
|
201
245
|
throw TypeError("Cannot " + msg);
|
@@ -219,6 +263,7 @@ var __privateMethod$4 = (obj, member, method) => {
|
|
219
263
|
return method;
|
220
264
|
};
|
221
265
|
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
266
|
+
const REQUEST_TIMEOUT = 3e4;
|
222
267
|
function getFetchImplementation(userFetch) {
|
223
268
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
224
269
|
const fetchImpl = userFetch ?? globalFetch;
|
@@ -235,6 +280,8 @@ class ApiRequestPool {
|
|
235
280
|
__privateAdd$8(this, _fetch, void 0);
|
236
281
|
__privateAdd$8(this, _queue, void 0);
|
237
282
|
__privateAdd$8(this, _concurrency, void 0);
|
283
|
+
__publicField$8(this, "running");
|
284
|
+
__publicField$8(this, "started");
|
238
285
|
__privateSet$8(this, _queue, []);
|
239
286
|
__privateSet$8(this, _concurrency, concurrency);
|
240
287
|
this.running = 0;
|
@@ -250,18 +297,22 @@ class ApiRequestPool {
|
|
250
297
|
return __privateGet$8(this, _fetch);
|
251
298
|
}
|
252
299
|
request(url, options) {
|
253
|
-
const start = new Date();
|
254
|
-
const
|
300
|
+
const start = /* @__PURE__ */ new Date();
|
301
|
+
const fetchImpl = this.getFetch();
|
255
302
|
const runRequest = async (stalled = false) => {
|
256
|
-
const
|
303
|
+
const { promise, cancel } = timeoutWithCancel(REQUEST_TIMEOUT);
|
304
|
+
const response = await Promise.race([fetchImpl(url, options), promise.then(() => null)]).finally(cancel);
|
305
|
+
if (!response) {
|
306
|
+
throw new Error("Request timed out");
|
307
|
+
}
|
257
308
|
if (response.status === 429) {
|
258
309
|
const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
|
259
310
|
await timeout(rateLimitReset * 1e3);
|
260
311
|
return await runRequest(true);
|
261
312
|
}
|
262
313
|
if (stalled) {
|
263
|
-
const stalledTime = new Date().getTime() - start.getTime();
|
264
|
-
console.warn(`A request to Xata hit
|
314
|
+
const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
|
315
|
+
console.warn(`A request to Xata hit branch rate limits, was retried and stalled for ${stalledTime}ms`);
|
265
316
|
}
|
266
317
|
return response;
|
267
318
|
};
|
@@ -303,16 +354,199 @@ function generateUUID() {
|
|
303
354
|
});
|
304
355
|
}
|
305
356
|
|
306
|
-
|
357
|
+
async function getBytes(stream, onChunk) {
|
358
|
+
const reader = stream.getReader();
|
359
|
+
let result;
|
360
|
+
while (!(result = await reader.read()).done) {
|
361
|
+
onChunk(result.value);
|
362
|
+
}
|
363
|
+
}
|
364
|
+
function getLines(onLine) {
|
365
|
+
let buffer;
|
366
|
+
let position;
|
367
|
+
let fieldLength;
|
368
|
+
let discardTrailingNewline = false;
|
369
|
+
return function onChunk(arr) {
|
370
|
+
if (buffer === void 0) {
|
371
|
+
buffer = arr;
|
372
|
+
position = 0;
|
373
|
+
fieldLength = -1;
|
374
|
+
} else {
|
375
|
+
buffer = concat(buffer, arr);
|
376
|
+
}
|
377
|
+
const bufLength = buffer.length;
|
378
|
+
let lineStart = 0;
|
379
|
+
while (position < bufLength) {
|
380
|
+
if (discardTrailingNewline) {
|
381
|
+
if (buffer[position] === 10 /* NewLine */) {
|
382
|
+
lineStart = ++position;
|
383
|
+
}
|
384
|
+
discardTrailingNewline = false;
|
385
|
+
}
|
386
|
+
let lineEnd = -1;
|
387
|
+
for (; position < bufLength && lineEnd === -1; ++position) {
|
388
|
+
switch (buffer[position]) {
|
389
|
+
case 58 /* Colon */:
|
390
|
+
if (fieldLength === -1) {
|
391
|
+
fieldLength = position - lineStart;
|
392
|
+
}
|
393
|
+
break;
|
394
|
+
case 13 /* CarriageReturn */:
|
395
|
+
discardTrailingNewline = true;
|
396
|
+
case 10 /* NewLine */:
|
397
|
+
lineEnd = position;
|
398
|
+
break;
|
399
|
+
}
|
400
|
+
}
|
401
|
+
if (lineEnd === -1) {
|
402
|
+
break;
|
403
|
+
}
|
404
|
+
onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
|
405
|
+
lineStart = position;
|
406
|
+
fieldLength = -1;
|
407
|
+
}
|
408
|
+
if (lineStart === bufLength) {
|
409
|
+
buffer = void 0;
|
410
|
+
} else if (lineStart !== 0) {
|
411
|
+
buffer = buffer.subarray(lineStart);
|
412
|
+
position -= lineStart;
|
413
|
+
}
|
414
|
+
};
|
415
|
+
}
|
416
|
+
function getMessages(onId, onRetry, onMessage) {
|
417
|
+
let message = newMessage();
|
418
|
+
const decoder = new TextDecoder();
|
419
|
+
return function onLine(line, fieldLength) {
|
420
|
+
if (line.length === 0) {
|
421
|
+
onMessage?.(message);
|
422
|
+
message = newMessage();
|
423
|
+
} else if (fieldLength > 0) {
|
424
|
+
const field = decoder.decode(line.subarray(0, fieldLength));
|
425
|
+
const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
|
426
|
+
const value = decoder.decode(line.subarray(valueOffset));
|
427
|
+
switch (field) {
|
428
|
+
case "data":
|
429
|
+
message.data = message.data ? message.data + "\n" + value : value;
|
430
|
+
break;
|
431
|
+
case "event":
|
432
|
+
message.event = value;
|
433
|
+
break;
|
434
|
+
case "id":
|
435
|
+
onId(message.id = value);
|
436
|
+
break;
|
437
|
+
case "retry":
|
438
|
+
const retry = parseInt(value, 10);
|
439
|
+
if (!isNaN(retry)) {
|
440
|
+
onRetry(message.retry = retry);
|
441
|
+
}
|
442
|
+
break;
|
443
|
+
}
|
444
|
+
}
|
445
|
+
};
|
446
|
+
}
|
447
|
+
function concat(a, b) {
|
448
|
+
const res = new Uint8Array(a.length + b.length);
|
449
|
+
res.set(a);
|
450
|
+
res.set(b, a.length);
|
451
|
+
return res;
|
452
|
+
}
|
453
|
+
function newMessage() {
|
454
|
+
return {
|
455
|
+
data: "",
|
456
|
+
event: "",
|
457
|
+
id: "",
|
458
|
+
retry: void 0
|
459
|
+
};
|
460
|
+
}
|
461
|
+
const EventStreamContentType = "text/event-stream";
|
462
|
+
const LastEventId = "last-event-id";
|
463
|
+
function fetchEventSource(input, {
|
464
|
+
signal: inputSignal,
|
465
|
+
headers: inputHeaders,
|
466
|
+
onopen: inputOnOpen,
|
467
|
+
onmessage,
|
468
|
+
onclose,
|
469
|
+
onerror,
|
470
|
+
fetch: inputFetch,
|
471
|
+
...rest
|
472
|
+
}) {
|
473
|
+
return new Promise((resolve, reject) => {
|
474
|
+
const headers = { ...inputHeaders };
|
475
|
+
if (!headers.accept) {
|
476
|
+
headers.accept = EventStreamContentType;
|
477
|
+
}
|
478
|
+
let curRequestController;
|
479
|
+
function dispose() {
|
480
|
+
curRequestController.abort();
|
481
|
+
}
|
482
|
+
inputSignal?.addEventListener("abort", () => {
|
483
|
+
dispose();
|
484
|
+
resolve();
|
485
|
+
});
|
486
|
+
const fetchImpl = inputFetch ?? fetch;
|
487
|
+
const onopen = inputOnOpen ?? defaultOnOpen;
|
488
|
+
async function create() {
|
489
|
+
curRequestController = new AbortController();
|
490
|
+
try {
|
491
|
+
const response = await fetchImpl(input, {
|
492
|
+
...rest,
|
493
|
+
headers,
|
494
|
+
signal: curRequestController.signal
|
495
|
+
});
|
496
|
+
await onopen(response);
|
497
|
+
await getBytes(
|
498
|
+
response.body,
|
499
|
+
getLines(
|
500
|
+
getMessages(
|
501
|
+
(id) => {
|
502
|
+
if (id) {
|
503
|
+
headers[LastEventId] = id;
|
504
|
+
} else {
|
505
|
+
delete headers[LastEventId];
|
506
|
+
}
|
507
|
+
},
|
508
|
+
(_retry) => {
|
509
|
+
},
|
510
|
+
onmessage
|
511
|
+
)
|
512
|
+
)
|
513
|
+
);
|
514
|
+
onclose?.();
|
515
|
+
dispose();
|
516
|
+
resolve();
|
517
|
+
} catch (err) {
|
518
|
+
}
|
519
|
+
}
|
520
|
+
create();
|
521
|
+
});
|
522
|
+
}
|
523
|
+
function defaultOnOpen(response) {
|
524
|
+
const contentType = response.headers?.get("content-type");
|
525
|
+
if (!contentType?.startsWith(EventStreamContentType)) {
|
526
|
+
throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
|
527
|
+
}
|
528
|
+
}
|
307
529
|
|
530
|
+
const VERSION = "0.25.2";
|
531
|
+
|
532
|
+
var __defProp$7 = Object.defineProperty;
|
533
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
534
|
+
var __publicField$7 = (obj, key, value) => {
|
535
|
+
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
536
|
+
return value;
|
537
|
+
};
|
308
538
|
class ErrorWithCause extends Error {
|
309
539
|
constructor(message, options) {
|
310
540
|
super(message, options);
|
541
|
+
__publicField$7(this, "cause");
|
311
542
|
}
|
312
543
|
}
|
313
544
|
class FetcherError extends ErrorWithCause {
|
314
545
|
constructor(status, data, requestId) {
|
315
546
|
super(getMessage(data));
|
547
|
+
__publicField$7(this, "status");
|
548
|
+
__publicField$7(this, "requestId");
|
549
|
+
__publicField$7(this, "errors");
|
316
550
|
this.status = status;
|
317
551
|
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
318
552
|
this.requestId = requestId;
|
@@ -379,6 +613,15 @@ function hostHeader(url) {
|
|
379
613
|
const { groups } = pattern.exec(url) ?? {};
|
380
614
|
return groups?.host ? { Host: groups.host } : {};
|
381
615
|
}
|
616
|
+
function parseBody(body, headers) {
|
617
|
+
if (!isDefined(body))
|
618
|
+
return void 0;
|
619
|
+
const { "Content-Type": contentType } = headers ?? {};
|
620
|
+
if (String(contentType).toLowerCase() === "application/json") {
|
621
|
+
return JSON.stringify(body);
|
622
|
+
}
|
623
|
+
return body;
|
624
|
+
}
|
382
625
|
const defaultClientID = generateUUID();
|
383
626
|
async function fetch$1({
|
384
627
|
url: path,
|
@@ -387,7 +630,7 @@ async function fetch$1({
|
|
387
630
|
headers: customHeaders,
|
388
631
|
pathParams,
|
389
632
|
queryParams,
|
390
|
-
|
633
|
+
fetch: fetch2,
|
391
634
|
apiKey,
|
392
635
|
endpoint,
|
393
636
|
apiUrl,
|
@@ -397,12 +640,14 @@ async function fetch$1({
|
|
397
640
|
clientID,
|
398
641
|
sessionID,
|
399
642
|
clientName,
|
400
|
-
|
643
|
+
xataAgentExtra,
|
644
|
+
fetchOptions = {},
|
645
|
+
rawResponse = false
|
401
646
|
}) {
|
402
|
-
pool.setFetch(
|
647
|
+
pool.setFetch(fetch2);
|
403
648
|
return await trace(
|
404
649
|
`${method.toUpperCase()} ${path}`,
|
405
|
-
async ({
|
650
|
+
async ({ setAttributes }) => {
|
406
651
|
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
407
652
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
408
653
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
@@ -413,9 +658,10 @@ async function fetch$1({
|
|
413
658
|
const xataAgent = compact([
|
414
659
|
["client", "TS_SDK"],
|
415
660
|
["version", VERSION],
|
416
|
-
isDefined(clientName) ? ["service", clientName] : void 0
|
661
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
662
|
+
...Object.entries(xataAgentExtra ?? {})
|
417
663
|
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
418
|
-
const headers = {
|
664
|
+
const headers = compactObject({
|
419
665
|
"Accept-Encoding": "identity",
|
420
666
|
"Content-Type": "application/json",
|
421
667
|
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
@@ -424,11 +670,11 @@ async function fetch$1({
|
|
424
670
|
...customHeaders,
|
425
671
|
...hostHeader(fullUrl),
|
426
672
|
Authorization: `Bearer ${apiKey}`
|
427
|
-
};
|
673
|
+
});
|
428
674
|
const response = await pool.request(url, {
|
429
675
|
...fetchOptions,
|
430
676
|
method: method.toUpperCase(),
|
431
|
-
body: body
|
677
|
+
body: parseBody(body, headers),
|
432
678
|
headers,
|
433
679
|
signal
|
434
680
|
});
|
@@ -441,6 +687,9 @@ async function fetch$1({
|
|
441
687
|
[TraceAttributes.HTTP_HOST]: host,
|
442
688
|
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
443
689
|
});
|
690
|
+
const message = response.headers?.get("x-xata-message");
|
691
|
+
if (message)
|
692
|
+
console.warn(message);
|
444
693
|
if (response.status === 204) {
|
445
694
|
return {};
|
446
695
|
}
|
@@ -448,7 +697,7 @@ async function fetch$1({
|
|
448
697
|
throw new FetcherError(response.status, "Rate limit exceeded", requestId);
|
449
698
|
}
|
450
699
|
try {
|
451
|
-
const jsonResponse = await response.json();
|
700
|
+
const jsonResponse = rawResponse ? await response.blob() : await response.json();
|
452
701
|
if (response.ok) {
|
453
702
|
return jsonResponse;
|
454
703
|
}
|
@@ -460,6 +709,59 @@ async function fetch$1({
|
|
460
709
|
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
461
710
|
);
|
462
711
|
}
|
712
|
+
function fetchSSERequest({
|
713
|
+
url: path,
|
714
|
+
method,
|
715
|
+
body,
|
716
|
+
headers: customHeaders,
|
717
|
+
pathParams,
|
718
|
+
queryParams,
|
719
|
+
fetch: fetch2,
|
720
|
+
apiKey,
|
721
|
+
endpoint,
|
722
|
+
apiUrl,
|
723
|
+
workspacesApiUrl,
|
724
|
+
onMessage,
|
725
|
+
onError,
|
726
|
+
onClose,
|
727
|
+
signal,
|
728
|
+
clientID,
|
729
|
+
sessionID,
|
730
|
+
clientName,
|
731
|
+
xataAgentExtra
|
732
|
+
}) {
|
733
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
734
|
+
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
735
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
736
|
+
void fetchEventSource(url, {
|
737
|
+
method,
|
738
|
+
body: JSON.stringify(body),
|
739
|
+
fetch: fetch2,
|
740
|
+
signal,
|
741
|
+
headers: {
|
742
|
+
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
743
|
+
"X-Xata-Session-ID": sessionID ?? generateUUID(),
|
744
|
+
"X-Xata-Agent": compact([
|
745
|
+
["client", "TS_SDK"],
|
746
|
+
["version", VERSION],
|
747
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
748
|
+
...Object.entries(xataAgentExtra ?? {})
|
749
|
+
]).map(([key, value]) => `${key}=${value}`).join("; "),
|
750
|
+
...customHeaders,
|
751
|
+
Authorization: `Bearer ${apiKey}`,
|
752
|
+
"Content-Type": "application/json"
|
753
|
+
},
|
754
|
+
onmessage(ev) {
|
755
|
+
onMessage?.(JSON.parse(ev.data));
|
756
|
+
},
|
757
|
+
onerror(ev) {
|
758
|
+
onError?.(JSON.parse(ev.data));
|
759
|
+
},
|
760
|
+
onclose() {
|
761
|
+
onClose?.();
|
762
|
+
}
|
763
|
+
});
|
764
|
+
}
|
463
765
|
function parseUrl(url) {
|
464
766
|
try {
|
465
767
|
const { host, protocol } = new URL(url);
|
@@ -490,6 +792,12 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
|
|
490
792
|
...variables,
|
491
793
|
signal
|
492
794
|
});
|
795
|
+
const copyBranch = (variables, signal) => dataPlaneFetch({
|
796
|
+
url: "/db/{dbBranchName}/copy",
|
797
|
+
method: "post",
|
798
|
+
...variables,
|
799
|
+
signal
|
800
|
+
});
|
493
801
|
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
494
802
|
url: "/db/{dbBranchName}/metadata",
|
495
803
|
method: "put",
|
@@ -515,7 +823,6 @@ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName
|
|
515
823
|
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
516
824
|
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
517
825
|
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
518
|
-
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
519
826
|
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
520
827
|
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
521
828
|
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
@@ -540,6 +847,7 @@ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{
|
|
540
847
|
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
541
848
|
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
542
849
|
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
850
|
+
const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
|
543
851
|
const createTable = (variables, signal) => dataPlaneFetch({
|
544
852
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
545
853
|
method: "put",
|
@@ -582,7 +890,44 @@ const deleteColumn = (variables, signal) => dataPlaneFetch({
|
|
582
890
|
...variables,
|
583
891
|
signal
|
584
892
|
});
|
893
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
585
894
|
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
895
|
+
const getFileItem = (variables, signal) => dataPlaneFetch({
|
896
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
897
|
+
method: "get",
|
898
|
+
...variables,
|
899
|
+
signal
|
900
|
+
});
|
901
|
+
const putFileItem = (variables, signal) => dataPlaneFetch({
|
902
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
903
|
+
method: "put",
|
904
|
+
...variables,
|
905
|
+
signal
|
906
|
+
});
|
907
|
+
const deleteFileItem = (variables, signal) => dataPlaneFetch({
|
908
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
909
|
+
method: "delete",
|
910
|
+
...variables,
|
911
|
+
signal
|
912
|
+
});
|
913
|
+
const getFile = (variables, signal) => dataPlaneFetch({
|
914
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
915
|
+
method: "get",
|
916
|
+
...variables,
|
917
|
+
signal
|
918
|
+
});
|
919
|
+
const putFile = (variables, signal) => dataPlaneFetch({
|
920
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
921
|
+
method: "put",
|
922
|
+
...variables,
|
923
|
+
signal
|
924
|
+
});
|
925
|
+
const deleteFile = (variables, signal) => dataPlaneFetch({
|
926
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
927
|
+
method: "delete",
|
928
|
+
...variables,
|
929
|
+
signal
|
930
|
+
});
|
586
931
|
const getRecord = (variables, signal) => dataPlaneFetch({
|
587
932
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
588
933
|
method: "get",
|
@@ -612,14 +957,35 @@ const searchTable = (variables, signal) => dataPlaneFetch({
|
|
612
957
|
...variables,
|
613
958
|
signal
|
614
959
|
});
|
960
|
+
const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
|
961
|
+
const askTable = (variables, signal) => dataPlaneFetch({
|
962
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
963
|
+
method: "post",
|
964
|
+
...variables,
|
965
|
+
signal
|
966
|
+
});
|
967
|
+
const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
|
615
968
|
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
616
969
|
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
970
|
+
const fileAccess = (variables, signal) => dataPlaneFetch({
|
971
|
+
url: "/file/{fileId}",
|
972
|
+
method: "get",
|
973
|
+
...variables,
|
974
|
+
signal
|
975
|
+
});
|
976
|
+
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
977
|
+
url: "/db/{dbBranchName}/sql",
|
978
|
+
method: "post",
|
979
|
+
...variables,
|
980
|
+
signal
|
981
|
+
});
|
617
982
|
const operationsByTag$2 = {
|
618
983
|
branch: {
|
619
984
|
getBranchList,
|
620
985
|
getBranchDetails,
|
621
986
|
createBranch,
|
622
987
|
deleteBranch,
|
988
|
+
copyBranch,
|
623
989
|
updateBranchMetadata,
|
624
990
|
getBranchMetadata,
|
625
991
|
getBranchStats,
|
@@ -637,17 +1003,8 @@ const operationsByTag$2 = {
|
|
637
1003
|
compareBranchSchemas,
|
638
1004
|
updateBranchSchema,
|
639
1005
|
previewBranchSchemaEdit,
|
640
|
-
applyBranchSchemaEdit
|
641
|
-
|
642
|
-
records: {
|
643
|
-
branchTransaction,
|
644
|
-
insertRecord,
|
645
|
-
getRecord,
|
646
|
-
insertRecordWithID,
|
647
|
-
updateRecordWithID,
|
648
|
-
upsertRecordWithID,
|
649
|
-
deleteRecord,
|
650
|
-
bulkInsertTableRecords
|
1006
|
+
applyBranchSchemaEdit,
|
1007
|
+
pushBranchMigrations
|
651
1008
|
},
|
652
1009
|
migrationRequests: {
|
653
1010
|
queryMigrationRequests,
|
@@ -671,11 +1028,34 @@ const operationsByTag$2 = {
|
|
671
1028
|
updateColumn,
|
672
1029
|
deleteColumn
|
673
1030
|
},
|
674
|
-
|
1031
|
+
records: {
|
1032
|
+
branchTransaction,
|
1033
|
+
insertRecord,
|
1034
|
+
getRecord,
|
1035
|
+
insertRecordWithID,
|
1036
|
+
updateRecordWithID,
|
1037
|
+
upsertRecordWithID,
|
1038
|
+
deleteRecord,
|
1039
|
+
bulkInsertTableRecords
|
1040
|
+
},
|
1041
|
+
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
|
1042
|
+
searchAndFilter: {
|
1043
|
+
queryTable,
|
1044
|
+
searchBranch,
|
1045
|
+
searchTable,
|
1046
|
+
vectorSearchTable,
|
1047
|
+
askTable,
|
1048
|
+
askTableSession,
|
1049
|
+
summarizeTable,
|
1050
|
+
aggregateTable
|
1051
|
+
},
|
1052
|
+
sql: { sqlQuery }
|
675
1053
|
};
|
676
1054
|
|
677
1055
|
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
678
1056
|
|
1057
|
+
const getAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "get", ...variables, signal });
|
1058
|
+
const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
|
679
1059
|
const getUser = (variables, signal) => controlPlaneFetch({
|
680
1060
|
url: "/user",
|
681
1061
|
method: "get",
|
@@ -712,6 +1092,25 @@ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
|
712
1092
|
...variables,
|
713
1093
|
signal
|
714
1094
|
});
|
1095
|
+
const getUserOAuthClients = (variables, signal) => controlPlaneFetch({
|
1096
|
+
url: "/user/oauth/clients",
|
1097
|
+
method: "get",
|
1098
|
+
...variables,
|
1099
|
+
signal
|
1100
|
+
});
|
1101
|
+
const getUserOAuthAccessTokens = (variables, signal) => controlPlaneFetch({
|
1102
|
+
url: "/user/oauth/tokens",
|
1103
|
+
method: "get",
|
1104
|
+
...variables,
|
1105
|
+
signal
|
1106
|
+
});
|
1107
|
+
const deleteOAuthAccessToken = (variables, signal) => controlPlaneFetch({
|
1108
|
+
url: "/user/oauth/tokens/{token}",
|
1109
|
+
method: "delete",
|
1110
|
+
...variables,
|
1111
|
+
signal
|
1112
|
+
});
|
1113
|
+
const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({ url: "/user/oauth/tokens/{token}", method: "patch", ...variables, signal });
|
715
1114
|
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
716
1115
|
url: "/workspaces",
|
717
1116
|
method: "get",
|
@@ -770,6 +1169,10 @@ const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
|
770
1169
|
});
|
771
1170
|
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
772
1171
|
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
1172
|
+
const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
|
1173
|
+
const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
|
1174
|
+
const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
|
1175
|
+
const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
|
773
1176
|
const listRegions = (variables, signal) => controlPlaneFetch({
|
774
1177
|
url: "/workspaces/{workspaceId}/regions",
|
775
1178
|
method: "get",
|
@@ -777,8 +1180,9 @@ const listRegions = (variables, signal) => controlPlaneFetch({
|
|
777
1180
|
signal
|
778
1181
|
});
|
779
1182
|
const operationsByTag$1 = {
|
1183
|
+
authOther: { getAuthorizationCode, grantAuthorizationCode, deleteOAuthAccessToken, updateOAuthAccessToken },
|
780
1184
|
users: { getUser, updateUser, deleteUser },
|
781
|
-
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
1185
|
+
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey, getUserOAuthClients, getUserOAuthAccessTokens },
|
782
1186
|
workspaces: {
|
783
1187
|
getWorkspacesList,
|
784
1188
|
createWorkspace,
|
@@ -802,6 +1206,10 @@ const operationsByTag$1 = {
|
|
802
1206
|
deleteDatabase,
|
803
1207
|
getDatabaseMetadata,
|
804
1208
|
updateDatabaseMetadata,
|
1209
|
+
renameDatabase,
|
1210
|
+
getDatabaseGithubSettings,
|
1211
|
+
updateDatabaseGithubSettings,
|
1212
|
+
deleteDatabaseGithubSettings,
|
805
1213
|
listRegions
|
806
1214
|
}
|
807
1215
|
};
|
@@ -822,8 +1230,12 @@ const providers = {
|
|
822
1230
|
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
823
1231
|
},
|
824
1232
|
staging: {
|
825
|
-
main: "https://staging.
|
826
|
-
workspaces: "https://{workspaceId}.
|
1233
|
+
main: "https://api.staging-xata.dev",
|
1234
|
+
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
1235
|
+
},
|
1236
|
+
dev: {
|
1237
|
+
main: "https://api.dev-xata.dev",
|
1238
|
+
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
827
1239
|
}
|
828
1240
|
};
|
829
1241
|
function isHostProviderAlias(alias) {
|
@@ -841,12 +1253,19 @@ function parseProviderString(provider = "production") {
|
|
841
1253
|
return null;
|
842
1254
|
return { main, workspaces };
|
843
1255
|
}
|
1256
|
+
function buildProviderString(provider) {
|
1257
|
+
if (isHostProviderAlias(provider))
|
1258
|
+
return provider;
|
1259
|
+
return `${provider.main},${provider.workspaces}`;
|
1260
|
+
}
|
844
1261
|
function parseWorkspacesUrlParts(url) {
|
845
1262
|
if (!isString(url))
|
846
1263
|
return null;
|
847
1264
|
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
848
|
-
const
|
849
|
-
const
|
1265
|
+
const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
|
1266
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
|
1267
|
+
const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
|
1268
|
+
const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
|
850
1269
|
if (!match)
|
851
1270
|
return null;
|
852
1271
|
return { workspace: match[1], region: match[2] };
|
@@ -885,10 +1304,11 @@ class XataApiClient {
|
|
885
1304
|
__privateSet$7(this, _extraProps, {
|
886
1305
|
apiUrl: getHostUrl(provider, "main"),
|
887
1306
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
888
|
-
|
1307
|
+
fetch: getFetchImplementation(options.fetch),
|
889
1308
|
apiKey,
|
890
1309
|
trace,
|
891
1310
|
clientName: options.clientName,
|
1311
|
+
xataAgentExtra: options.xataAgentExtra,
|
892
1312
|
clientID
|
893
1313
|
});
|
894
1314
|
}
|
@@ -942,6 +1362,11 @@ class XataApiClient {
|
|
942
1362
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
943
1363
|
return __privateGet$7(this, _namespaces).records;
|
944
1364
|
}
|
1365
|
+
get files() {
|
1366
|
+
if (!__privateGet$7(this, _namespaces).files)
|
1367
|
+
__privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
|
1368
|
+
return __privateGet$7(this, _namespaces).files;
|
1369
|
+
}
|
945
1370
|
get searchAndFilter() {
|
946
1371
|
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
947
1372
|
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
@@ -1150,6 +1575,20 @@ class BranchApi {
|
|
1150
1575
|
...this.extraProps
|
1151
1576
|
});
|
1152
1577
|
}
|
1578
|
+
copyBranch({
|
1579
|
+
workspace,
|
1580
|
+
region,
|
1581
|
+
database,
|
1582
|
+
branch,
|
1583
|
+
destinationBranch,
|
1584
|
+
limit
|
1585
|
+
}) {
|
1586
|
+
return operationsByTag.branch.copyBranch({
|
1587
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1588
|
+
body: { destinationBranch, limit },
|
1589
|
+
...this.extraProps
|
1590
|
+
});
|
1591
|
+
}
|
1153
1592
|
updateBranchMetadata({
|
1154
1593
|
workspace,
|
1155
1594
|
region,
|
@@ -1505,6 +1944,164 @@ class RecordsApi {
|
|
1505
1944
|
});
|
1506
1945
|
}
|
1507
1946
|
}
|
1947
|
+
class FilesApi {
|
1948
|
+
constructor(extraProps) {
|
1949
|
+
this.extraProps = extraProps;
|
1950
|
+
}
|
1951
|
+
getFileItem({
|
1952
|
+
workspace,
|
1953
|
+
region,
|
1954
|
+
database,
|
1955
|
+
branch,
|
1956
|
+
table,
|
1957
|
+
record,
|
1958
|
+
column,
|
1959
|
+
fileId
|
1960
|
+
}) {
|
1961
|
+
return operationsByTag.files.getFileItem({
|
1962
|
+
pathParams: {
|
1963
|
+
workspace,
|
1964
|
+
region,
|
1965
|
+
dbBranchName: `${database}:${branch}`,
|
1966
|
+
tableName: table,
|
1967
|
+
recordId: record,
|
1968
|
+
columnName: column,
|
1969
|
+
fileId
|
1970
|
+
},
|
1971
|
+
...this.extraProps
|
1972
|
+
});
|
1973
|
+
}
|
1974
|
+
putFileItem({
|
1975
|
+
workspace,
|
1976
|
+
region,
|
1977
|
+
database,
|
1978
|
+
branch,
|
1979
|
+
table,
|
1980
|
+
record,
|
1981
|
+
column,
|
1982
|
+
fileId,
|
1983
|
+
file
|
1984
|
+
}) {
|
1985
|
+
return operationsByTag.files.putFileItem({
|
1986
|
+
pathParams: {
|
1987
|
+
workspace,
|
1988
|
+
region,
|
1989
|
+
dbBranchName: `${database}:${branch}`,
|
1990
|
+
tableName: table,
|
1991
|
+
recordId: record,
|
1992
|
+
columnName: column,
|
1993
|
+
fileId
|
1994
|
+
},
|
1995
|
+
// @ts-ignore
|
1996
|
+
body: file,
|
1997
|
+
...this.extraProps
|
1998
|
+
});
|
1999
|
+
}
|
2000
|
+
deleteFileItem({
|
2001
|
+
workspace,
|
2002
|
+
region,
|
2003
|
+
database,
|
2004
|
+
branch,
|
2005
|
+
table,
|
2006
|
+
record,
|
2007
|
+
column,
|
2008
|
+
fileId
|
2009
|
+
}) {
|
2010
|
+
return operationsByTag.files.deleteFileItem({
|
2011
|
+
pathParams: {
|
2012
|
+
workspace,
|
2013
|
+
region,
|
2014
|
+
dbBranchName: `${database}:${branch}`,
|
2015
|
+
tableName: table,
|
2016
|
+
recordId: record,
|
2017
|
+
columnName: column,
|
2018
|
+
fileId
|
2019
|
+
},
|
2020
|
+
...this.extraProps
|
2021
|
+
});
|
2022
|
+
}
|
2023
|
+
getFile({
|
2024
|
+
workspace,
|
2025
|
+
region,
|
2026
|
+
database,
|
2027
|
+
branch,
|
2028
|
+
table,
|
2029
|
+
record,
|
2030
|
+
column
|
2031
|
+
}) {
|
2032
|
+
return operationsByTag.files.getFile({
|
2033
|
+
pathParams: {
|
2034
|
+
workspace,
|
2035
|
+
region,
|
2036
|
+
dbBranchName: `${database}:${branch}`,
|
2037
|
+
tableName: table,
|
2038
|
+
recordId: record,
|
2039
|
+
columnName: column
|
2040
|
+
},
|
2041
|
+
...this.extraProps
|
2042
|
+
});
|
2043
|
+
}
|
2044
|
+
putFile({
|
2045
|
+
workspace,
|
2046
|
+
region,
|
2047
|
+
database,
|
2048
|
+
branch,
|
2049
|
+
table,
|
2050
|
+
record,
|
2051
|
+
column,
|
2052
|
+
file
|
2053
|
+
}) {
|
2054
|
+
return operationsByTag.files.putFile({
|
2055
|
+
pathParams: {
|
2056
|
+
workspace,
|
2057
|
+
region,
|
2058
|
+
dbBranchName: `${database}:${branch}`,
|
2059
|
+
tableName: table,
|
2060
|
+
recordId: record,
|
2061
|
+
columnName: column
|
2062
|
+
},
|
2063
|
+
body: file,
|
2064
|
+
...this.extraProps
|
2065
|
+
});
|
2066
|
+
}
|
2067
|
+
deleteFile({
|
2068
|
+
workspace,
|
2069
|
+
region,
|
2070
|
+
database,
|
2071
|
+
branch,
|
2072
|
+
table,
|
2073
|
+
record,
|
2074
|
+
column
|
2075
|
+
}) {
|
2076
|
+
return operationsByTag.files.deleteFile({
|
2077
|
+
pathParams: {
|
2078
|
+
workspace,
|
2079
|
+
region,
|
2080
|
+
dbBranchName: `${database}:${branch}`,
|
2081
|
+
tableName: table,
|
2082
|
+
recordId: record,
|
2083
|
+
columnName: column
|
2084
|
+
},
|
2085
|
+
...this.extraProps
|
2086
|
+
});
|
2087
|
+
}
|
2088
|
+
fileAccess({
|
2089
|
+
workspace,
|
2090
|
+
region,
|
2091
|
+
fileId,
|
2092
|
+
verify
|
2093
|
+
}) {
|
2094
|
+
return operationsByTag.files.fileAccess({
|
2095
|
+
pathParams: {
|
2096
|
+
workspace,
|
2097
|
+
region,
|
2098
|
+
fileId
|
2099
|
+
},
|
2100
|
+
queryParams: { verify },
|
2101
|
+
...this.extraProps
|
2102
|
+
});
|
2103
|
+
}
|
2104
|
+
}
|
1508
2105
|
class SearchAndFilterApi {
|
1509
2106
|
constructor(extraProps) {
|
1510
2107
|
this.extraProps = extraProps;
|
@@ -1541,26 +2138,73 @@ class SearchAndFilterApi {
|
|
1541
2138
|
highlight,
|
1542
2139
|
boosters
|
1543
2140
|
}) {
|
1544
|
-
return operationsByTag.searchAndFilter.searchTable({
|
2141
|
+
return operationsByTag.searchAndFilter.searchTable({
|
2142
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2143
|
+
body: { query, fuzziness, target, prefix, filter, highlight, boosters },
|
2144
|
+
...this.extraProps
|
2145
|
+
});
|
2146
|
+
}
|
2147
|
+
searchBranch({
|
2148
|
+
workspace,
|
2149
|
+
region,
|
2150
|
+
database,
|
2151
|
+
branch,
|
2152
|
+
tables,
|
2153
|
+
query,
|
2154
|
+
fuzziness,
|
2155
|
+
prefix,
|
2156
|
+
highlight
|
2157
|
+
}) {
|
2158
|
+
return operationsByTag.searchAndFilter.searchBranch({
|
2159
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2160
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
2161
|
+
...this.extraProps
|
2162
|
+
});
|
2163
|
+
}
|
2164
|
+
vectorSearchTable({
|
2165
|
+
workspace,
|
2166
|
+
region,
|
2167
|
+
database,
|
2168
|
+
branch,
|
2169
|
+
table,
|
2170
|
+
queryVector,
|
2171
|
+
column,
|
2172
|
+
similarityFunction,
|
2173
|
+
size,
|
2174
|
+
filter
|
2175
|
+
}) {
|
2176
|
+
return operationsByTag.searchAndFilter.vectorSearchTable({
|
2177
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2178
|
+
body: { queryVector, column, similarityFunction, size, filter },
|
2179
|
+
...this.extraProps
|
2180
|
+
});
|
2181
|
+
}
|
2182
|
+
askTable({
|
2183
|
+
workspace,
|
2184
|
+
region,
|
2185
|
+
database,
|
2186
|
+
branch,
|
2187
|
+
table,
|
2188
|
+
options
|
2189
|
+
}) {
|
2190
|
+
return operationsByTag.searchAndFilter.askTable({
|
1545
2191
|
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1546
|
-
body: {
|
2192
|
+
body: { ...options },
|
1547
2193
|
...this.extraProps
|
1548
2194
|
});
|
1549
2195
|
}
|
1550
|
-
|
2196
|
+
askTableSession({
|
1551
2197
|
workspace,
|
1552
2198
|
region,
|
1553
2199
|
database,
|
1554
2200
|
branch,
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
prefix,
|
1559
|
-
highlight
|
2201
|
+
table,
|
2202
|
+
sessionId,
|
2203
|
+
message
|
1560
2204
|
}) {
|
1561
|
-
return operationsByTag.searchAndFilter.
|
1562
|
-
pathParams: { workspace, region, dbBranchName: `${database}:${branch}
|
1563
|
-
body: {
|
2205
|
+
return operationsByTag.searchAndFilter.askTableSession({
|
2206
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
|
2207
|
+
body: { message },
|
1564
2208
|
...this.extraProps
|
1565
2209
|
});
|
1566
2210
|
}
|
@@ -1764,11 +2408,13 @@ class MigrationsApi {
|
|
1764
2408
|
region,
|
1765
2409
|
database,
|
1766
2410
|
branch,
|
1767
|
-
schema
|
2411
|
+
schema,
|
2412
|
+
schemaOperations,
|
2413
|
+
branchOperations
|
1768
2414
|
}) {
|
1769
2415
|
return operationsByTag.migrations.compareBranchWithUserSchema({
|
1770
2416
|
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1771
|
-
body: { schema },
|
2417
|
+
body: { schema, schemaOperations, branchOperations },
|
1772
2418
|
...this.extraProps
|
1773
2419
|
});
|
1774
2420
|
}
|
@@ -1778,11 +2424,12 @@ class MigrationsApi {
|
|
1778
2424
|
database,
|
1779
2425
|
branch,
|
1780
2426
|
compare,
|
1781
|
-
|
2427
|
+
sourceBranchOperations,
|
2428
|
+
targetBranchOperations
|
1782
2429
|
}) {
|
1783
2430
|
return operationsByTag.migrations.compareBranchSchemas({
|
1784
2431
|
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
1785
|
-
body: {
|
2432
|
+
body: { sourceBranchOperations, targetBranchOperations },
|
1786
2433
|
...this.extraProps
|
1787
2434
|
});
|
1788
2435
|
}
|
@@ -1825,6 +2472,19 @@ class MigrationsApi {
|
|
1825
2472
|
...this.extraProps
|
1826
2473
|
});
|
1827
2474
|
}
|
2475
|
+
pushBranchMigrations({
|
2476
|
+
workspace,
|
2477
|
+
region,
|
2478
|
+
database,
|
2479
|
+
branch,
|
2480
|
+
migrations
|
2481
|
+
}) {
|
2482
|
+
return operationsByTag.migrations.pushBranchMigrations({
|
2483
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2484
|
+
body: { migrations },
|
2485
|
+
...this.extraProps
|
2486
|
+
});
|
2487
|
+
}
|
1828
2488
|
}
|
1829
2489
|
class DatabaseApi {
|
1830
2490
|
constructor(extraProps) {
|
@@ -1839,11 +2499,13 @@ class DatabaseApi {
|
|
1839
2499
|
createDatabase({
|
1840
2500
|
workspace,
|
1841
2501
|
database,
|
1842
|
-
data
|
2502
|
+
data,
|
2503
|
+
headers
|
1843
2504
|
}) {
|
1844
2505
|
return operationsByTag.databases.createDatabase({
|
1845
2506
|
pathParams: { workspaceId: workspace, dbName: database },
|
1846
2507
|
body: data,
|
2508
|
+
headers,
|
1847
2509
|
...this.extraProps
|
1848
2510
|
});
|
1849
2511
|
}
|
@@ -1876,6 +2538,46 @@ class DatabaseApi {
|
|
1876
2538
|
...this.extraProps
|
1877
2539
|
});
|
1878
2540
|
}
|
2541
|
+
renameDatabase({
|
2542
|
+
workspace,
|
2543
|
+
database,
|
2544
|
+
newName
|
2545
|
+
}) {
|
2546
|
+
return operationsByTag.databases.renameDatabase({
|
2547
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2548
|
+
body: { newName },
|
2549
|
+
...this.extraProps
|
2550
|
+
});
|
2551
|
+
}
|
2552
|
+
getDatabaseGithubSettings({
|
2553
|
+
workspace,
|
2554
|
+
database
|
2555
|
+
}) {
|
2556
|
+
return operationsByTag.databases.getDatabaseGithubSettings({
|
2557
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2558
|
+
...this.extraProps
|
2559
|
+
});
|
2560
|
+
}
|
2561
|
+
updateDatabaseGithubSettings({
|
2562
|
+
workspace,
|
2563
|
+
database,
|
2564
|
+
settings
|
2565
|
+
}) {
|
2566
|
+
return operationsByTag.databases.updateDatabaseGithubSettings({
|
2567
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2568
|
+
body: settings,
|
2569
|
+
...this.extraProps
|
2570
|
+
});
|
2571
|
+
}
|
2572
|
+
deleteDatabaseGithubSettings({
|
2573
|
+
workspace,
|
2574
|
+
database
|
2575
|
+
}) {
|
2576
|
+
return operationsByTag.databases.deleteDatabaseGithubSettings({
|
2577
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2578
|
+
...this.extraProps
|
2579
|
+
});
|
2580
|
+
}
|
1879
2581
|
listRegions({ workspace }) {
|
1880
2582
|
return operationsByTag.databases.listRegions({
|
1881
2583
|
pathParams: { workspaceId: workspace },
|
@@ -1885,22 +2587,269 @@ class DatabaseApi {
|
|
1885
2587
|
}
|
1886
2588
|
|
1887
2589
|
class XataApiPlugin {
|
1888
|
-
|
1889
|
-
|
1890
|
-
return new XataApiClient({ fetch: fetchImpl, apiKey });
|
2590
|
+
build(options) {
|
2591
|
+
return new XataApiClient(options);
|
1891
2592
|
}
|
1892
2593
|
}
|
1893
2594
|
|
1894
2595
|
class XataPlugin {
|
1895
2596
|
}
|
1896
2597
|
|
2598
|
+
class FilesPlugin extends XataPlugin {
|
2599
|
+
build(pluginOptions) {
|
2600
|
+
return {
|
2601
|
+
download: async (location) => {
|
2602
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
2603
|
+
return await getFileItem({
|
2604
|
+
pathParams: {
|
2605
|
+
workspace: "{workspaceId}",
|
2606
|
+
dbBranchName: "{dbBranch}",
|
2607
|
+
region: "{region}",
|
2608
|
+
tableName: table ?? "",
|
2609
|
+
recordId: record ?? "",
|
2610
|
+
columnName: column ?? "",
|
2611
|
+
fileId
|
2612
|
+
},
|
2613
|
+
...pluginOptions,
|
2614
|
+
rawResponse: true
|
2615
|
+
});
|
2616
|
+
},
|
2617
|
+
upload: async (location, file) => {
|
2618
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
2619
|
+
return await putFileItem({
|
2620
|
+
pathParams: {
|
2621
|
+
workspace: "{workspaceId}",
|
2622
|
+
dbBranchName: "{dbBranch}",
|
2623
|
+
region: "{region}",
|
2624
|
+
tableName: table ?? "",
|
2625
|
+
recordId: record ?? "",
|
2626
|
+
columnName: column ?? "",
|
2627
|
+
fileId
|
2628
|
+
},
|
2629
|
+
body: file,
|
2630
|
+
...pluginOptions
|
2631
|
+
});
|
2632
|
+
},
|
2633
|
+
delete: async (location) => {
|
2634
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
2635
|
+
return await deleteFileItem({
|
2636
|
+
pathParams: {
|
2637
|
+
workspace: "{workspaceId}",
|
2638
|
+
dbBranchName: "{dbBranch}",
|
2639
|
+
region: "{region}",
|
2640
|
+
tableName: table ?? "",
|
2641
|
+
recordId: record ?? "",
|
2642
|
+
columnName: column ?? "",
|
2643
|
+
fileId
|
2644
|
+
},
|
2645
|
+
...pluginOptions
|
2646
|
+
});
|
2647
|
+
}
|
2648
|
+
};
|
2649
|
+
}
|
2650
|
+
}
|
2651
|
+
|
2652
|
+
function buildTransformString(transformations) {
|
2653
|
+
return transformations.flatMap(
|
2654
|
+
(t) => Object.entries(t).map(([key, value]) => {
|
2655
|
+
if (key === "trim") {
|
2656
|
+
const { left = 0, top = 0, right = 0, bottom = 0 } = value;
|
2657
|
+
return `${key}=${[top, right, bottom, left].join(";")}`;
|
2658
|
+
}
|
2659
|
+
if (key === "gravity" && typeof value === "object") {
|
2660
|
+
const { x = 0.5, y = 0.5 } = value;
|
2661
|
+
return `${key}=${[x, y].join("x")}`;
|
2662
|
+
}
|
2663
|
+
return `${key}=${value}`;
|
2664
|
+
})
|
2665
|
+
).join(",");
|
2666
|
+
}
|
2667
|
+
function transformImage(url, transformations) {
|
2668
|
+
if (!isDefined(url))
|
2669
|
+
return void 0;
|
2670
|
+
const transformationsString = buildTransformString(transformations);
|
2671
|
+
const { hostname, pathname, search } = new URL(url);
|
2672
|
+
return `https://${hostname}/transform/${transformationsString}${pathname}${search}`;
|
2673
|
+
}
|
2674
|
+
|
2675
|
+
var __defProp$6 = Object.defineProperty;
|
2676
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2677
|
+
var __publicField$6 = (obj, key, value) => {
|
2678
|
+
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2679
|
+
return value;
|
2680
|
+
};
|
2681
|
+
class XataFile {
|
2682
|
+
constructor(file) {
|
2683
|
+
/**
|
2684
|
+
* Name of this file.
|
2685
|
+
*/
|
2686
|
+
__publicField$6(this, "name");
|
2687
|
+
/**
|
2688
|
+
* Media type of this file.
|
2689
|
+
*/
|
2690
|
+
__publicField$6(this, "mediaType");
|
2691
|
+
/**
|
2692
|
+
* Base64 encoded content of this file.
|
2693
|
+
*/
|
2694
|
+
__publicField$6(this, "base64Content");
|
2695
|
+
/**
|
2696
|
+
* Whether to enable public url for this file.
|
2697
|
+
*/
|
2698
|
+
__publicField$6(this, "enablePublicUrl");
|
2699
|
+
/**
|
2700
|
+
* Timeout for the signed url.
|
2701
|
+
*/
|
2702
|
+
__publicField$6(this, "signedUrlTimeout");
|
2703
|
+
/**
|
2704
|
+
* Size of this file.
|
2705
|
+
*/
|
2706
|
+
__publicField$6(this, "size");
|
2707
|
+
/**
|
2708
|
+
* Version of this file.
|
2709
|
+
*/
|
2710
|
+
__publicField$6(this, "version");
|
2711
|
+
/**
|
2712
|
+
* Url of this file.
|
2713
|
+
*/
|
2714
|
+
__publicField$6(this, "url");
|
2715
|
+
/**
|
2716
|
+
* Signed url of this file.
|
2717
|
+
*/
|
2718
|
+
__publicField$6(this, "signedUrl");
|
2719
|
+
/**
|
2720
|
+
* Attributes of this file.
|
2721
|
+
*/
|
2722
|
+
__publicField$6(this, "attributes");
|
2723
|
+
this.name = file.name;
|
2724
|
+
this.mediaType = file.mediaType || "application/octet-stream";
|
2725
|
+
this.base64Content = file.base64Content;
|
2726
|
+
this.enablePublicUrl = file.enablePublicUrl;
|
2727
|
+
this.signedUrlTimeout = file.signedUrlTimeout;
|
2728
|
+
this.size = file.size;
|
2729
|
+
this.version = file.version;
|
2730
|
+
this.url = file.url;
|
2731
|
+
this.signedUrl = file.signedUrl;
|
2732
|
+
this.attributes = file.attributes;
|
2733
|
+
}
|
2734
|
+
static fromBuffer(buffer, options = {}) {
|
2735
|
+
const base64Content = buffer.toString("base64");
|
2736
|
+
return new XataFile({ ...options, base64Content });
|
2737
|
+
}
|
2738
|
+
toBuffer() {
|
2739
|
+
if (!this.base64Content) {
|
2740
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2741
|
+
}
|
2742
|
+
return Buffer.from(this.base64Content, "base64");
|
2743
|
+
}
|
2744
|
+
static fromArrayBuffer(arrayBuffer, options = {}) {
|
2745
|
+
const uint8Array = new Uint8Array(arrayBuffer);
|
2746
|
+
return this.fromUint8Array(uint8Array, options);
|
2747
|
+
}
|
2748
|
+
toArrayBuffer() {
|
2749
|
+
if (!this.base64Content) {
|
2750
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2751
|
+
}
|
2752
|
+
const binary = atob(this.base64Content);
|
2753
|
+
return new ArrayBuffer(binary.length);
|
2754
|
+
}
|
2755
|
+
static fromUint8Array(uint8Array, options = {}) {
|
2756
|
+
let binary = "";
|
2757
|
+
for (let i = 0; i < uint8Array.byteLength; i++) {
|
2758
|
+
binary += String.fromCharCode(uint8Array[i]);
|
2759
|
+
}
|
2760
|
+
const base64Content = btoa(binary);
|
2761
|
+
return new XataFile({ ...options, base64Content });
|
2762
|
+
}
|
2763
|
+
toUint8Array() {
|
2764
|
+
if (!this.base64Content) {
|
2765
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2766
|
+
}
|
2767
|
+
const binary = atob(this.base64Content);
|
2768
|
+
const uint8Array = new Uint8Array(binary.length);
|
2769
|
+
for (let i = 0; i < binary.length; i++) {
|
2770
|
+
uint8Array[i] = binary.charCodeAt(i);
|
2771
|
+
}
|
2772
|
+
return uint8Array;
|
2773
|
+
}
|
2774
|
+
static async fromBlob(file, options = {}) {
|
2775
|
+
const name = options.name ?? file.name;
|
2776
|
+
const mediaType = file.type;
|
2777
|
+
const arrayBuffer = await file.arrayBuffer();
|
2778
|
+
return this.fromArrayBuffer(arrayBuffer, { ...options, name, mediaType });
|
2779
|
+
}
|
2780
|
+
toBlob() {
|
2781
|
+
if (!this.base64Content) {
|
2782
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2783
|
+
}
|
2784
|
+
const arrayBuffer = this.toArrayBuffer();
|
2785
|
+
return new Blob([arrayBuffer], { type: this.mediaType });
|
2786
|
+
}
|
2787
|
+
static fromString(string, options = {}) {
|
2788
|
+
const base64Content = btoa(string);
|
2789
|
+
return new XataFile({ ...options, base64Content });
|
2790
|
+
}
|
2791
|
+
toString() {
|
2792
|
+
if (!this.base64Content) {
|
2793
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2794
|
+
}
|
2795
|
+
return atob(this.base64Content);
|
2796
|
+
}
|
2797
|
+
static fromBase64(base64Content, options = {}) {
|
2798
|
+
return new XataFile({ ...options, base64Content });
|
2799
|
+
}
|
2800
|
+
toBase64() {
|
2801
|
+
if (!this.base64Content) {
|
2802
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2803
|
+
}
|
2804
|
+
return this.base64Content;
|
2805
|
+
}
|
2806
|
+
transform(...options) {
|
2807
|
+
return {
|
2808
|
+
url: transformImage(this.url, options),
|
2809
|
+
signedUrl: transformImage(this.signedUrl, options)
|
2810
|
+
};
|
2811
|
+
}
|
2812
|
+
}
|
2813
|
+
const parseInputFileEntry = async (entry) => {
|
2814
|
+
if (!isDefined(entry))
|
2815
|
+
return null;
|
2816
|
+
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
|
2817
|
+
return compactObject({ id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout });
|
2818
|
+
};
|
2819
|
+
|
1897
2820
|
function cleanFilter(filter) {
|
1898
|
-
if (!filter)
|
2821
|
+
if (!isDefined(filter))
|
1899
2822
|
return void 0;
|
1900
|
-
|
1901
|
-
|
2823
|
+
if (!isObject(filter))
|
2824
|
+
return filter;
|
2825
|
+
const values = Object.fromEntries(
|
2826
|
+
Object.entries(filter).reduce((acc, [key, value]) => {
|
2827
|
+
if (!isDefined(value))
|
2828
|
+
return acc;
|
2829
|
+
if (Array.isArray(value)) {
|
2830
|
+
const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
|
2831
|
+
if (clean.length === 0)
|
2832
|
+
return acc;
|
2833
|
+
return [...acc, [key, clean]];
|
2834
|
+
}
|
2835
|
+
if (isObject(value)) {
|
2836
|
+
const clean = cleanFilter(value);
|
2837
|
+
if (!isDefined(clean))
|
2838
|
+
return acc;
|
2839
|
+
return [...acc, [key, clean]];
|
2840
|
+
}
|
2841
|
+
return [...acc, [key, value]];
|
2842
|
+
}, [])
|
2843
|
+
);
|
2844
|
+
return Object.keys(values).length > 0 ? values : void 0;
|
1902
2845
|
}
|
1903
2846
|
|
2847
|
+
var __defProp$5 = Object.defineProperty;
|
2848
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2849
|
+
var __publicField$5 = (obj, key, value) => {
|
2850
|
+
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2851
|
+
return value;
|
2852
|
+
};
|
1904
2853
|
var __accessCheck$6 = (obj, member, msg) => {
|
1905
2854
|
if (!member.has(obj))
|
1906
2855
|
throw TypeError("Cannot " + msg);
|
@@ -1923,22 +2872,58 @@ var _query, _page;
|
|
1923
2872
|
class Page {
|
1924
2873
|
constructor(query, meta, records = []) {
|
1925
2874
|
__privateAdd$6(this, _query, void 0);
|
2875
|
+
/**
|
2876
|
+
* Page metadata, required to retrieve additional records.
|
2877
|
+
*/
|
2878
|
+
__publicField$5(this, "meta");
|
2879
|
+
/**
|
2880
|
+
* The set of results for this page.
|
2881
|
+
*/
|
2882
|
+
__publicField$5(this, "records");
|
1926
2883
|
__privateSet$6(this, _query, query);
|
1927
2884
|
this.meta = meta;
|
1928
2885
|
this.records = new RecordArray(this, records);
|
1929
2886
|
}
|
2887
|
+
/**
|
2888
|
+
* Retrieves the next page of results.
|
2889
|
+
* @param size Maximum number of results to be retrieved.
|
2890
|
+
* @param offset Number of results to skip when retrieving the results.
|
2891
|
+
* @returns The next page or results.
|
2892
|
+
*/
|
1930
2893
|
async nextPage(size, offset) {
|
1931
2894
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
1932
2895
|
}
|
2896
|
+
/**
|
2897
|
+
* Retrieves the previous page of results.
|
2898
|
+
* @param size Maximum number of results to be retrieved.
|
2899
|
+
* @param offset Number of results to skip when retrieving the results.
|
2900
|
+
* @returns The previous page or results.
|
2901
|
+
*/
|
1933
2902
|
async previousPage(size, offset) {
|
1934
2903
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
1935
2904
|
}
|
2905
|
+
/**
|
2906
|
+
* Retrieves the start page of results.
|
2907
|
+
* @param size Maximum number of results to be retrieved.
|
2908
|
+
* @param offset Number of results to skip when retrieving the results.
|
2909
|
+
* @returns The start page or results.
|
2910
|
+
*/
|
1936
2911
|
async startPage(size, offset) {
|
1937
2912
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
1938
2913
|
}
|
2914
|
+
/**
|
2915
|
+
* Retrieves the end page of results.
|
2916
|
+
* @param size Maximum number of results to be retrieved.
|
2917
|
+
* @param offset Number of results to skip when retrieving the results.
|
2918
|
+
* @returns The end page or results.
|
2919
|
+
*/
|
1939
2920
|
async endPage(size, offset) {
|
1940
2921
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
1941
2922
|
}
|
2923
|
+
/**
|
2924
|
+
* Shortcut method to check if there will be additional results if the next page of results is retrieved.
|
2925
|
+
* @returns Whether or not there will be additional results in the next page of results.
|
2926
|
+
*/
|
1942
2927
|
hasNextPage() {
|
1943
2928
|
return this.meta.page.more;
|
1944
2929
|
}
|
@@ -1951,7 +2936,7 @@ const PAGINATION_DEFAULT_OFFSET = 0;
|
|
1951
2936
|
function isCursorPaginationOptions(options) {
|
1952
2937
|
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
1953
2938
|
}
|
1954
|
-
const _RecordArray = class extends Array {
|
2939
|
+
const _RecordArray = class _RecordArray extends Array {
|
1955
2940
|
constructor(...args) {
|
1956
2941
|
super(..._RecordArray.parseConstructorParams(...args));
|
1957
2942
|
__privateAdd$6(this, _page, void 0);
|
@@ -1970,32 +2955,67 @@ const _RecordArray = class extends Array {
|
|
1970
2955
|
toArray() {
|
1971
2956
|
return new Array(...this);
|
1972
2957
|
}
|
2958
|
+
toSerializable() {
|
2959
|
+
return JSON.parse(this.toString());
|
2960
|
+
}
|
2961
|
+
toString() {
|
2962
|
+
return JSON.stringify(this.toArray());
|
2963
|
+
}
|
1973
2964
|
map(callbackfn, thisArg) {
|
1974
2965
|
return this.toArray().map(callbackfn, thisArg);
|
1975
2966
|
}
|
2967
|
+
/**
|
2968
|
+
* Retrieve next page of records
|
2969
|
+
*
|
2970
|
+
* @returns A new array of objects
|
2971
|
+
*/
|
1976
2972
|
async nextPage(size, offset) {
|
1977
2973
|
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
1978
2974
|
return new _RecordArray(newPage);
|
1979
2975
|
}
|
2976
|
+
/**
|
2977
|
+
* Retrieve previous page of records
|
2978
|
+
*
|
2979
|
+
* @returns A new array of objects
|
2980
|
+
*/
|
1980
2981
|
async previousPage(size, offset) {
|
1981
2982
|
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
1982
2983
|
return new _RecordArray(newPage);
|
1983
2984
|
}
|
2985
|
+
/**
|
2986
|
+
* Retrieve start page of records
|
2987
|
+
*
|
2988
|
+
* @returns A new array of objects
|
2989
|
+
*/
|
1984
2990
|
async startPage(size, offset) {
|
1985
2991
|
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
1986
2992
|
return new _RecordArray(newPage);
|
1987
2993
|
}
|
2994
|
+
/**
|
2995
|
+
* Retrieve end page of records
|
2996
|
+
*
|
2997
|
+
* @returns A new array of objects
|
2998
|
+
*/
|
1988
2999
|
async endPage(size, offset) {
|
1989
3000
|
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
1990
3001
|
return new _RecordArray(newPage);
|
1991
3002
|
}
|
3003
|
+
/**
|
3004
|
+
* @returns Boolean indicating if there is a next page
|
3005
|
+
*/
|
1992
3006
|
hasNextPage() {
|
1993
3007
|
return __privateGet$6(this, _page).meta.page.more;
|
1994
3008
|
}
|
1995
3009
|
};
|
1996
|
-
let RecordArray = _RecordArray;
|
1997
3010
|
_page = new WeakMap();
|
3011
|
+
let RecordArray = _RecordArray;
|
1998
3012
|
|
3013
|
+
var __defProp$4 = Object.defineProperty;
|
3014
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3015
|
+
var __publicField$4 = (obj, key, value) => {
|
3016
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
3017
|
+
return value;
|
3018
|
+
};
|
1999
3019
|
var __accessCheck$5 = (obj, member, msg) => {
|
2000
3020
|
if (!member.has(obj))
|
2001
3021
|
throw TypeError("Cannot " + msg);
|
@@ -2019,14 +3039,15 @@ var __privateMethod$3 = (obj, member, method) => {
|
|
2019
3039
|
return method;
|
2020
3040
|
};
|
2021
3041
|
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
2022
|
-
const _Query = class {
|
3042
|
+
const _Query = class _Query {
|
2023
3043
|
constructor(repository, table, data, rawParent) {
|
2024
3044
|
__privateAdd$5(this, _cleanFilterConstraint);
|
2025
3045
|
__privateAdd$5(this, _table$1, void 0);
|
2026
3046
|
__privateAdd$5(this, _repository, void 0);
|
2027
3047
|
__privateAdd$5(this, _data, { filter: {} });
|
2028
|
-
|
2029
|
-
this
|
3048
|
+
// Implements pagination
|
3049
|
+
__publicField$4(this, "meta", { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } });
|
3050
|
+
__publicField$4(this, "records", new RecordArray(this, []));
|
2030
3051
|
__privateSet$5(this, _table$1, table);
|
2031
3052
|
if (repository) {
|
2032
3053
|
__privateSet$5(this, _repository, repository);
|
@@ -2062,18 +3083,38 @@ const _Query = class {
|
|
2062
3083
|
const key = JSON.stringify({ columns, filter, sort, pagination });
|
2063
3084
|
return toBase64(key);
|
2064
3085
|
}
|
3086
|
+
/**
|
3087
|
+
* Builds a new query object representing a logical OR between the given subqueries.
|
3088
|
+
* @param queries An array of subqueries.
|
3089
|
+
* @returns A new Query object.
|
3090
|
+
*/
|
2065
3091
|
any(...queries) {
|
2066
3092
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2067
3093
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
2068
3094
|
}
|
3095
|
+
/**
|
3096
|
+
* Builds a new query object representing a logical AND between the given subqueries.
|
3097
|
+
* @param queries An array of subqueries.
|
3098
|
+
* @returns A new Query object.
|
3099
|
+
*/
|
2069
3100
|
all(...queries) {
|
2070
3101
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2071
3102
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
2072
3103
|
}
|
3104
|
+
/**
|
3105
|
+
* Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
|
3106
|
+
* @param queries An array of subqueries.
|
3107
|
+
* @returns A new Query object.
|
3108
|
+
*/
|
2073
3109
|
not(...queries) {
|
2074
3110
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2075
3111
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
2076
3112
|
}
|
3113
|
+
/**
|
3114
|
+
* Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
|
3115
|
+
* @param queries An array of subqueries.
|
3116
|
+
* @returns A new Query object.
|
3117
|
+
*/
|
2077
3118
|
none(...queries) {
|
2078
3119
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2079
3120
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
@@ -2096,6 +3137,11 @@ const _Query = class {
|
|
2096
3137
|
const sort = [...originalSort, { column, direction }];
|
2097
3138
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
2098
3139
|
}
|
3140
|
+
/**
|
3141
|
+
* Builds a new query specifying the set of columns to be returned in the query response.
|
3142
|
+
* @param columns Array of column names to be returned by the query.
|
3143
|
+
* @returns A new Query object.
|
3144
|
+
*/
|
2099
3145
|
select(columns) {
|
2100
3146
|
return new _Query(
|
2101
3147
|
__privateGet$5(this, _repository),
|
@@ -2108,6 +3154,12 @@ const _Query = class {
|
|
2108
3154
|
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
2109
3155
|
return __privateGet$5(this, _repository).query(query);
|
2110
3156
|
}
|
3157
|
+
/**
|
3158
|
+
* Get results in an iterator
|
3159
|
+
*
|
3160
|
+
* @async
|
3161
|
+
* @returns Async interable of results
|
3162
|
+
*/
|
2111
3163
|
async *[Symbol.asyncIterator]() {
|
2112
3164
|
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
2113
3165
|
yield record;
|
@@ -2168,26 +3220,53 @@ const _Query = class {
|
|
2168
3220
|
);
|
2169
3221
|
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
2170
3222
|
}
|
3223
|
+
/**
|
3224
|
+
* Builds a new query object adding a cache TTL in milliseconds.
|
3225
|
+
* @param ttl The cache TTL in milliseconds.
|
3226
|
+
* @returns A new Query object.
|
3227
|
+
*/
|
2171
3228
|
cache(ttl) {
|
2172
3229
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
2173
3230
|
}
|
3231
|
+
/**
|
3232
|
+
* Retrieve next page of records
|
3233
|
+
*
|
3234
|
+
* @returns A new page object.
|
3235
|
+
*/
|
2174
3236
|
nextPage(size, offset) {
|
2175
3237
|
return this.startPage(size, offset);
|
2176
3238
|
}
|
3239
|
+
/**
|
3240
|
+
* Retrieve previous page of records
|
3241
|
+
*
|
3242
|
+
* @returns A new page object
|
3243
|
+
*/
|
2177
3244
|
previousPage(size, offset) {
|
2178
3245
|
return this.startPage(size, offset);
|
2179
3246
|
}
|
3247
|
+
/**
|
3248
|
+
* Retrieve start page of records
|
3249
|
+
*
|
3250
|
+
* @returns A new page object
|
3251
|
+
*/
|
2180
3252
|
startPage(size, offset) {
|
2181
3253
|
return this.getPaginated({ pagination: { size, offset } });
|
2182
3254
|
}
|
3255
|
+
/**
|
3256
|
+
* Retrieve last page of records
|
3257
|
+
*
|
3258
|
+
* @returns A new page object
|
3259
|
+
*/
|
2183
3260
|
endPage(size, offset) {
|
2184
3261
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
2185
3262
|
}
|
3263
|
+
/**
|
3264
|
+
* @returns Boolean indicating if there is a next page
|
3265
|
+
*/
|
2186
3266
|
hasNextPage() {
|
2187
3267
|
return this.meta.page.more;
|
2188
3268
|
}
|
2189
3269
|
};
|
2190
|
-
let Query = _Query;
|
2191
3270
|
_table$1 = new WeakMap();
|
2192
3271
|
_repository = new WeakMap();
|
2193
3272
|
_data = new WeakMap();
|
@@ -2202,6 +3281,7 @@ cleanFilterConstraint_fn = function(column, value) {
|
|
2202
3281
|
}
|
2203
3282
|
return value;
|
2204
3283
|
};
|
3284
|
+
let Query = _Query;
|
2205
3285
|
function cleanParent(data, parent) {
|
2206
3286
|
if (isCursorPaginationOptions(data.pagination)) {
|
2207
3287
|
return { ...parent, sort: void 0, filter: void 0 };
|
@@ -2209,6 +3289,21 @@ function cleanParent(data, parent) {
|
|
2209
3289
|
return parent;
|
2210
3290
|
}
|
2211
3291
|
|
3292
|
+
const RecordColumnTypes = [
|
3293
|
+
"bool",
|
3294
|
+
"int",
|
3295
|
+
"float",
|
3296
|
+
"string",
|
3297
|
+
"text",
|
3298
|
+
"email",
|
3299
|
+
"multiple",
|
3300
|
+
"link",
|
3301
|
+
"object",
|
3302
|
+
"datetime",
|
3303
|
+
"vector",
|
3304
|
+
"file[]",
|
3305
|
+
"file"
|
3306
|
+
];
|
2212
3307
|
function isIdentifiable(x) {
|
2213
3308
|
return isObject(x) && isString(x?.id);
|
2214
3309
|
}
|
@@ -2222,7 +3317,11 @@ function isSortFilterString(value) {
|
|
2222
3317
|
return isString(value);
|
2223
3318
|
}
|
2224
3319
|
function isSortFilterBase(filter) {
|
2225
|
-
return isObject(filter) && Object.
|
3320
|
+
return isObject(filter) && Object.entries(filter).every(([key, value]) => {
|
3321
|
+
if (key === "*")
|
3322
|
+
return value === "random";
|
3323
|
+
return value === "asc" || value === "desc";
|
3324
|
+
});
|
2226
3325
|
}
|
2227
3326
|
function isSortFilterObject(filter) {
|
2228
3327
|
return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
|
@@ -2263,7 +3362,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
2263
3362
|
__accessCheck$4(obj, member, "access private method");
|
2264
3363
|
return method;
|
2265
3364
|
};
|
2266
|
-
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;
|
3365
|
+
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, _transformObjectToApi, transformObjectToApi_fn;
|
2267
3366
|
const BULK_OPERATION_MAX_SIZE = 1e3;
|
2268
3367
|
class Repository extends Query {
|
2269
3368
|
}
|
@@ -2285,6 +3384,7 @@ class RestRepository extends Query {
|
|
2285
3384
|
__privateAdd$4(this, _setCacheQuery);
|
2286
3385
|
__privateAdd$4(this, _getCacheQuery);
|
2287
3386
|
__privateAdd$4(this, _getSchemaTables$1);
|
3387
|
+
__privateAdd$4(this, _transformObjectToApi);
|
2288
3388
|
__privateAdd$4(this, _table, void 0);
|
2289
3389
|
__privateAdd$4(this, _getFetchProps, void 0);
|
2290
3390
|
__privateAdd$4(this, _db, void 0);
|
@@ -2295,10 +3395,7 @@ class RestRepository extends Query {
|
|
2295
3395
|
__privateSet$4(this, _db, options.db);
|
2296
3396
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
2297
3397
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
2298
|
-
__privateSet$4(this, _getFetchProps,
|
2299
|
-
const props = await options.pluginOptions.getFetchProps();
|
2300
|
-
return { ...props, sessionID: generateUUID() };
|
2301
|
-
});
|
3398
|
+
__privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
|
2302
3399
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
2303
3400
|
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
2304
3401
|
return trace(name, fn, {
|
@@ -2355,7 +3452,6 @@ class RestRepository extends Query {
|
|
2355
3452
|
}
|
2356
3453
|
const id = extractId(a);
|
2357
3454
|
if (id) {
|
2358
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2359
3455
|
try {
|
2360
3456
|
const response = await getRecord({
|
2361
3457
|
pathParams: {
|
@@ -2366,7 +3462,7 @@ class RestRepository extends Query {
|
|
2366
3462
|
recordId: id
|
2367
3463
|
},
|
2368
3464
|
queryParams: { columns },
|
2369
|
-
...
|
3465
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2370
3466
|
});
|
2371
3467
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2372
3468
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
@@ -2466,12 +3562,22 @@ class RestRepository extends Query {
|
|
2466
3562
|
return result;
|
2467
3563
|
}
|
2468
3564
|
if (isString(a) && isObject(b)) {
|
3565
|
+
if (a === "")
|
3566
|
+
throw new Error("The id can't be empty");
|
2469
3567
|
const columns = isStringArray(c) ? c : void 0;
|
2470
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
3568
|
+
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
2471
3569
|
}
|
2472
3570
|
if (isObject(a) && isString(a.id)) {
|
3571
|
+
if (a.id === "")
|
3572
|
+
throw new Error("The id can't be empty");
|
2473
3573
|
const columns = isStringArray(c) ? c : void 0;
|
2474
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3574
|
+
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3575
|
+
}
|
3576
|
+
if (!isDefined(a) && isObject(b)) {
|
3577
|
+
return await this.create(b, c);
|
3578
|
+
}
|
3579
|
+
if (isObject(a) && !isDefined(a.id)) {
|
3580
|
+
return await this.create(a, b);
|
2475
3581
|
}
|
2476
3582
|
throw new Error("Invalid arguments for createOrUpdate method");
|
2477
3583
|
});
|
@@ -2488,12 +3594,22 @@ class RestRepository extends Query {
|
|
2488
3594
|
return result;
|
2489
3595
|
}
|
2490
3596
|
if (isString(a) && isObject(b)) {
|
3597
|
+
if (a === "")
|
3598
|
+
throw new Error("The id can't be empty");
|
2491
3599
|
const columns = isStringArray(c) ? c : void 0;
|
2492
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
3600
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
2493
3601
|
}
|
2494
3602
|
if (isObject(a) && isString(a.id)) {
|
3603
|
+
if (a.id === "")
|
3604
|
+
throw new Error("The id can't be empty");
|
2495
3605
|
const columns = isStringArray(c) ? c : void 0;
|
2496
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
3606
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
3607
|
+
}
|
3608
|
+
if (!isDefined(a) && isObject(b)) {
|
3609
|
+
return await this.create(b, c);
|
3610
|
+
}
|
3611
|
+
if (isObject(a) && !isDefined(a.id)) {
|
3612
|
+
return await this.create(a, b);
|
2497
3613
|
}
|
2498
3614
|
throw new Error("Invalid arguments for createOrReplace method");
|
2499
3615
|
});
|
@@ -2544,7 +3660,6 @@ class RestRepository extends Query {
|
|
2544
3660
|
}
|
2545
3661
|
async search(query, options = {}) {
|
2546
3662
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
2547
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2548
3663
|
const { records } = await searchTable({
|
2549
3664
|
pathParams: {
|
2550
3665
|
workspace: "{workspaceId}",
|
@@ -2562,7 +3677,29 @@ class RestRepository extends Query {
|
|
2562
3677
|
page: options.page,
|
2563
3678
|
target: options.target
|
2564
3679
|
},
|
2565
|
-
...
|
3680
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3681
|
+
});
|
3682
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3683
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
3684
|
+
});
|
3685
|
+
}
|
3686
|
+
async vectorSearch(column, query, options) {
|
3687
|
+
return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
|
3688
|
+
const { records } = await vectorSearchTable({
|
3689
|
+
pathParams: {
|
3690
|
+
workspace: "{workspaceId}",
|
3691
|
+
dbBranchName: "{dbBranch}",
|
3692
|
+
region: "{region}",
|
3693
|
+
tableName: __privateGet$4(this, _table)
|
3694
|
+
},
|
3695
|
+
body: {
|
3696
|
+
column,
|
3697
|
+
queryVector: query,
|
3698
|
+
similarityFunction: options?.similarityFunction,
|
3699
|
+
size: options?.size,
|
3700
|
+
filter: options?.filter
|
3701
|
+
},
|
3702
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2566
3703
|
});
|
2567
3704
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2568
3705
|
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
@@ -2570,7 +3707,6 @@ class RestRepository extends Query {
|
|
2570
3707
|
}
|
2571
3708
|
async aggregate(aggs, filter) {
|
2572
3709
|
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
2573
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2574
3710
|
const result = await aggregateTable({
|
2575
3711
|
pathParams: {
|
2576
3712
|
workspace: "{workspaceId}",
|
@@ -2579,7 +3715,7 @@ class RestRepository extends Query {
|
|
2579
3715
|
tableName: __privateGet$4(this, _table)
|
2580
3716
|
},
|
2581
3717
|
body: { aggs, filter },
|
2582
|
-
...
|
3718
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2583
3719
|
});
|
2584
3720
|
return result;
|
2585
3721
|
});
|
@@ -2590,7 +3726,6 @@ class RestRepository extends Query {
|
|
2590
3726
|
if (cacheQuery)
|
2591
3727
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
2592
3728
|
const data = query.getQueryOptions();
|
2593
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2594
3729
|
const { meta, records: objects } = await queryTable({
|
2595
3730
|
pathParams: {
|
2596
3731
|
workspace: "{workspaceId}",
|
@@ -2606,7 +3741,7 @@ class RestRepository extends Query {
|
|
2606
3741
|
consistency: data.consistency
|
2607
3742
|
},
|
2608
3743
|
fetchOptions: data.fetchOptions,
|
2609
|
-
...
|
3744
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2610
3745
|
});
|
2611
3746
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2612
3747
|
const records = objects.map(
|
@@ -2619,7 +3754,6 @@ class RestRepository extends Query {
|
|
2619
3754
|
async summarizeTable(query, summaries, summariesFilter) {
|
2620
3755
|
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
2621
3756
|
const data = query.getQueryOptions();
|
2622
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2623
3757
|
const result = await summarizeTable({
|
2624
3758
|
pathParams: {
|
2625
3759
|
workspace: "{workspaceId}",
|
@@ -2636,11 +3770,44 @@ class RestRepository extends Query {
|
|
2636
3770
|
summaries,
|
2637
3771
|
summariesFilter
|
2638
3772
|
},
|
2639
|
-
...
|
3773
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2640
3774
|
});
|
2641
3775
|
return result;
|
2642
3776
|
});
|
2643
3777
|
}
|
3778
|
+
ask(question, options) {
|
3779
|
+
const questionParam = options?.sessionId ? { message: question } : { question };
|
3780
|
+
const params = {
|
3781
|
+
pathParams: {
|
3782
|
+
workspace: "{workspaceId}",
|
3783
|
+
dbBranchName: "{dbBranch}",
|
3784
|
+
region: "{region}",
|
3785
|
+
tableName: __privateGet$4(this, _table),
|
3786
|
+
sessionId: options?.sessionId
|
3787
|
+
},
|
3788
|
+
body: {
|
3789
|
+
...questionParam,
|
3790
|
+
rules: options?.rules,
|
3791
|
+
searchType: options?.searchType,
|
3792
|
+
search: options?.searchType === "keyword" ? options?.search : void 0,
|
3793
|
+
vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
|
3794
|
+
},
|
3795
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3796
|
+
};
|
3797
|
+
if (options?.onMessage) {
|
3798
|
+
fetchSSERequest({
|
3799
|
+
endpoint: "dataPlane",
|
3800
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
|
3801
|
+
method: "POST",
|
3802
|
+
onMessage: (message) => {
|
3803
|
+
options.onMessage?.({ answer: message.text, records: message.records });
|
3804
|
+
},
|
3805
|
+
...params
|
3806
|
+
});
|
3807
|
+
} else {
|
3808
|
+
return askTableSession(params);
|
3809
|
+
}
|
3810
|
+
}
|
2644
3811
|
}
|
2645
3812
|
_table = new WeakMap();
|
2646
3813
|
_getFetchProps = new WeakMap();
|
@@ -2650,8 +3817,7 @@ _schemaTables$2 = new WeakMap();
|
|
2650
3817
|
_trace = new WeakMap();
|
2651
3818
|
_insertRecordWithoutId = new WeakSet();
|
2652
3819
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
2653
|
-
const
|
2654
|
-
const record = transformObjectLinks(object);
|
3820
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
2655
3821
|
const response = await insertRecord({
|
2656
3822
|
pathParams: {
|
2657
3823
|
workspace: "{workspaceId}",
|
@@ -2661,15 +3827,16 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
2661
3827
|
},
|
2662
3828
|
queryParams: { columns },
|
2663
3829
|
body: record,
|
2664
|
-
...
|
3830
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2665
3831
|
});
|
2666
3832
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2667
3833
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2668
3834
|
};
|
2669
3835
|
_insertRecordWithId = new WeakSet();
|
2670
3836
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
2671
|
-
|
2672
|
-
|
3837
|
+
if (!recordId)
|
3838
|
+
return null;
|
3839
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
2673
3840
|
const response = await insertRecordWithID({
|
2674
3841
|
pathParams: {
|
2675
3842
|
workspace: "{workspaceId}",
|
@@ -2680,30 +3847,28 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
|
|
2680
3847
|
},
|
2681
3848
|
body: record,
|
2682
3849
|
queryParams: { createOnly, columns, ifVersion },
|
2683
|
-
...
|
3850
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2684
3851
|
});
|
2685
3852
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2686
3853
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2687
3854
|
};
|
2688
3855
|
_insertRecords = new WeakSet();
|
2689
3856
|
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
2690
|
-
const
|
2691
|
-
|
2692
|
-
|
2693
|
-
|
2694
|
-
|
2695
|
-
BULK_OPERATION_MAX_SIZE
|
2696
|
-
);
|
3857
|
+
const operations = await promiseMap(objects, async (object) => {
|
3858
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3859
|
+
return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
|
3860
|
+
});
|
3861
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
2697
3862
|
const ids = [];
|
2698
|
-
for (const
|
3863
|
+
for (const operations2 of chunkedOperations) {
|
2699
3864
|
const { results } = await branchTransaction({
|
2700
3865
|
pathParams: {
|
2701
3866
|
workspace: "{workspaceId}",
|
2702
3867
|
dbBranchName: "{dbBranch}",
|
2703
3868
|
region: "{region}"
|
2704
3869
|
},
|
2705
|
-
body: { operations },
|
2706
|
-
...
|
3870
|
+
body: { operations: operations2 },
|
3871
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2707
3872
|
});
|
2708
3873
|
for (const result of results) {
|
2709
3874
|
if (result.operation === "insert") {
|
@@ -2717,8 +3882,9 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
|
2717
3882
|
};
|
2718
3883
|
_updateRecordWithID = new WeakSet();
|
2719
3884
|
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
2720
|
-
|
2721
|
-
|
3885
|
+
if (!recordId)
|
3886
|
+
return null;
|
3887
|
+
const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
2722
3888
|
try {
|
2723
3889
|
const response = await updateRecordWithID({
|
2724
3890
|
pathParams: {
|
@@ -2730,7 +3896,7 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
2730
3896
|
},
|
2731
3897
|
queryParams: { columns, ifVersion },
|
2732
3898
|
body: record,
|
2733
|
-
...
|
3899
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2734
3900
|
});
|
2735
3901
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2736
3902
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
@@ -2743,23 +3909,21 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
2743
3909
|
};
|
2744
3910
|
_updateRecords = new WeakSet();
|
2745
3911
|
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
2746
|
-
const
|
2747
|
-
|
2748
|
-
|
2749
|
-
|
2750
|
-
|
2751
|
-
BULK_OPERATION_MAX_SIZE
|
2752
|
-
);
|
3912
|
+
const operations = await promiseMap(objects, async ({ id, ...object }) => {
|
3913
|
+
const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3914
|
+
return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
|
3915
|
+
});
|
3916
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
2753
3917
|
const ids = [];
|
2754
|
-
for (const
|
3918
|
+
for (const operations2 of chunkedOperations) {
|
2755
3919
|
const { results } = await branchTransaction({
|
2756
3920
|
pathParams: {
|
2757
3921
|
workspace: "{workspaceId}",
|
2758
3922
|
dbBranchName: "{dbBranch}",
|
2759
3923
|
region: "{region}"
|
2760
3924
|
},
|
2761
|
-
body: { operations },
|
2762
|
-
...
|
3925
|
+
body: { operations: operations2 },
|
3926
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2763
3927
|
});
|
2764
3928
|
for (const result of results) {
|
2765
3929
|
if (result.operation === "update") {
|
@@ -2773,7 +3937,8 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
|
2773
3937
|
};
|
2774
3938
|
_upsertRecordWithID = new WeakSet();
|
2775
3939
|
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
2776
|
-
|
3940
|
+
if (!recordId)
|
3941
|
+
return null;
|
2777
3942
|
const response = await upsertRecordWithID({
|
2778
3943
|
pathParams: {
|
2779
3944
|
workspace: "{workspaceId}",
|
@@ -2784,14 +3949,15 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
2784
3949
|
},
|
2785
3950
|
queryParams: { columns, ifVersion },
|
2786
3951
|
body: object,
|
2787
|
-
...
|
3952
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2788
3953
|
});
|
2789
3954
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2790
3955
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2791
3956
|
};
|
2792
3957
|
_deleteRecord = new WeakSet();
|
2793
3958
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
2794
|
-
|
3959
|
+
if (!recordId)
|
3960
|
+
return null;
|
2795
3961
|
try {
|
2796
3962
|
const response = await deleteRecord({
|
2797
3963
|
pathParams: {
|
@@ -2802,7 +3968,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
2802
3968
|
recordId
|
2803
3969
|
},
|
2804
3970
|
queryParams: { columns },
|
2805
|
-
...
|
3971
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2806
3972
|
});
|
2807
3973
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2808
3974
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
@@ -2815,9 +3981,8 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
2815
3981
|
};
|
2816
3982
|
_deleteRecords = new WeakSet();
|
2817
3983
|
deleteRecords_fn = async function(recordIds) {
|
2818
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2819
3984
|
const chunkedOperations = chunk(
|
2820
|
-
recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
3985
|
+
compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
2821
3986
|
BULK_OPERATION_MAX_SIZE
|
2822
3987
|
);
|
2823
3988
|
for (const operations of chunkedOperations) {
|
@@ -2828,21 +3993,22 @@ deleteRecords_fn = async function(recordIds) {
|
|
2828
3993
|
region: "{region}"
|
2829
3994
|
},
|
2830
3995
|
body: { operations },
|
2831
|
-
...
|
3996
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2832
3997
|
});
|
2833
3998
|
}
|
2834
3999
|
};
|
2835
4000
|
_setCacheQuery = new WeakSet();
|
2836
4001
|
setCacheQuery_fn = async function(query, meta, records) {
|
2837
|
-
await __privateGet$4(this, _cache)
|
4002
|
+
await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
|
2838
4003
|
};
|
2839
4004
|
_getCacheQuery = new WeakSet();
|
2840
4005
|
getCacheQuery_fn = async function(query) {
|
2841
4006
|
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
2842
|
-
const result = await __privateGet$4(this, _cache)
|
4007
|
+
const result = await __privateGet$4(this, _cache)?.get(key);
|
2843
4008
|
if (!result)
|
2844
4009
|
return null;
|
2845
|
-
const
|
4010
|
+
const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
|
4011
|
+
const { cache: ttl = defaultTTL } = query.getQueryOptions();
|
2846
4012
|
if (ttl < 0)
|
2847
4013
|
return null;
|
2848
4014
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
@@ -2852,15 +4018,46 @@ _getSchemaTables$1 = new WeakSet();
|
|
2852
4018
|
getSchemaTables_fn$1 = async function() {
|
2853
4019
|
if (__privateGet$4(this, _schemaTables$2))
|
2854
4020
|
return __privateGet$4(this, _schemaTables$2);
|
2855
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2856
4021
|
const { schema } = await getBranchDetails({
|
2857
4022
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2858
|
-
...
|
4023
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2859
4024
|
});
|
2860
4025
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
2861
4026
|
return schema.tables;
|
2862
4027
|
};
|
2863
|
-
|
4028
|
+
_transformObjectToApi = new WeakSet();
|
4029
|
+
transformObjectToApi_fn = async function(object) {
|
4030
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
4031
|
+
const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
|
4032
|
+
if (!schema)
|
4033
|
+
throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
|
4034
|
+
const result = {};
|
4035
|
+
for (const [key, value] of Object.entries(object)) {
|
4036
|
+
if (key === "xata")
|
4037
|
+
continue;
|
4038
|
+
const type = schema.columns.find((column) => column.name === key)?.type;
|
4039
|
+
switch (type) {
|
4040
|
+
case "link": {
|
4041
|
+
result[key] = isIdentifiable(value) ? value.id : value;
|
4042
|
+
break;
|
4043
|
+
}
|
4044
|
+
case "datetime": {
|
4045
|
+
result[key] = value instanceof Date ? value.toISOString() : value;
|
4046
|
+
break;
|
4047
|
+
}
|
4048
|
+
case `file`:
|
4049
|
+
result[key] = await parseInputFileEntry(value);
|
4050
|
+
break;
|
4051
|
+
case "file[]":
|
4052
|
+
result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
|
4053
|
+
break;
|
4054
|
+
default:
|
4055
|
+
result[key] = value;
|
4056
|
+
}
|
4057
|
+
}
|
4058
|
+
return result;
|
4059
|
+
};
|
4060
|
+
const removeLinksFromObject = (object) => {
|
2864
4061
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
2865
4062
|
if (key === "xata")
|
2866
4063
|
return acc;
|
@@ -2909,6 +4106,12 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2909
4106
|
}
|
2910
4107
|
break;
|
2911
4108
|
}
|
4109
|
+
case "file":
|
4110
|
+
data[column.name] = isDefined(value) ? new XataFile(value) : null;
|
4111
|
+
break;
|
4112
|
+
case "file[]":
|
4113
|
+
data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
|
4114
|
+
break;
|
2912
4115
|
default:
|
2913
4116
|
data[column.name] = value ?? null;
|
2914
4117
|
if (column.notNull === true && value === null) {
|
@@ -2918,6 +4121,8 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2918
4121
|
}
|
2919
4122
|
}
|
2920
4123
|
const record = { ...data };
|
4124
|
+
const serializable = { xata, ...removeLinksFromObject(data) };
|
4125
|
+
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
2921
4126
|
record.read = function(columns2) {
|
2922
4127
|
return db[table].read(record["id"], columns2);
|
2923
4128
|
};
|
@@ -2934,13 +4139,17 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2934
4139
|
record.delete = function() {
|
2935
4140
|
return db[table].delete(record["id"]);
|
2936
4141
|
};
|
4142
|
+
record.xata = Object.freeze(metadata);
|
2937
4143
|
record.getMetadata = function() {
|
2938
|
-
return xata;
|
4144
|
+
return record.xata;
|
4145
|
+
};
|
4146
|
+
record.toSerializable = function() {
|
4147
|
+
return JSON.parse(JSON.stringify(serializable));
|
2939
4148
|
};
|
2940
|
-
record.
|
2941
|
-
return JSON.
|
4149
|
+
record.toString = function() {
|
4150
|
+
return JSON.stringify(serializable);
|
2942
4151
|
};
|
2943
|
-
for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
|
4152
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
2944
4153
|
Object.defineProperty(record, prop, { enumerable: false });
|
2945
4154
|
}
|
2946
4155
|
Object.freeze(record);
|
@@ -2956,11 +4165,7 @@ function extractId(value) {
|
|
2956
4165
|
function isValidColumn(columns, column) {
|
2957
4166
|
if (columns.includes("*"))
|
2958
4167
|
return true;
|
2959
|
-
|
2960
|
-
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
2961
|
-
return linkColumns.length > 0;
|
2962
|
-
}
|
2963
|
-
return columns.includes(column.name);
|
4168
|
+
return columns.filter((item) => item.startsWith(column.name)).length > 0;
|
2964
4169
|
}
|
2965
4170
|
function parseIfVersion(...args) {
|
2966
4171
|
for (const arg of args) {
|
@@ -2971,6 +4176,12 @@ function parseIfVersion(...args) {
|
|
2971
4176
|
return void 0;
|
2972
4177
|
}
|
2973
4178
|
|
4179
|
+
var __defProp$3 = Object.defineProperty;
|
4180
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4181
|
+
var __publicField$3 = (obj, key, value) => {
|
4182
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4183
|
+
return value;
|
4184
|
+
};
|
2974
4185
|
var __accessCheck$3 = (obj, member, msg) => {
|
2975
4186
|
if (!member.has(obj))
|
2976
4187
|
throw TypeError("Cannot " + msg);
|
@@ -2993,6 +4204,8 @@ var _map;
|
|
2993
4204
|
class SimpleCache {
|
2994
4205
|
constructor(options = {}) {
|
2995
4206
|
__privateAdd$3(this, _map, void 0);
|
4207
|
+
__publicField$3(this, "capacity");
|
4208
|
+
__publicField$3(this, "defaultQueryTTL");
|
2996
4209
|
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
2997
4210
|
this.capacity = options.max ?? 500;
|
2998
4211
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
@@ -3128,19 +4341,19 @@ class SearchPlugin extends XataPlugin {
|
|
3128
4341
|
__privateAdd$1(this, _schemaTables, void 0);
|
3129
4342
|
__privateSet$1(this, _schemaTables, schemaTables);
|
3130
4343
|
}
|
3131
|
-
build(
|
4344
|
+
build(pluginOptions) {
|
3132
4345
|
return {
|
3133
4346
|
all: async (query, options = {}) => {
|
3134
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
3135
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
4347
|
+
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4348
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
3136
4349
|
return records.map((record) => {
|
3137
4350
|
const { table = "orphan" } = record.xata;
|
3138
4351
|
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
3139
4352
|
});
|
3140
4353
|
},
|
3141
4354
|
byTable: async (query, options = {}) => {
|
3142
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
3143
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
4355
|
+
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4356
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
3144
4357
|
return records.reduce((acc, record) => {
|
3145
4358
|
const { table = "orphan" } = record.xata;
|
3146
4359
|
const items = acc[table] ?? [];
|
@@ -3153,38 +4366,36 @@ class SearchPlugin extends XataPlugin {
|
|
3153
4366
|
}
|
3154
4367
|
_schemaTables = new WeakMap();
|
3155
4368
|
_search = new WeakSet();
|
3156
|
-
search_fn = async function(query, options,
|
3157
|
-
const fetchProps = await getFetchProps();
|
4369
|
+
search_fn = async function(query, options, pluginOptions) {
|
3158
4370
|
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
3159
4371
|
const { records } = await searchBranch({
|
3160
4372
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4373
|
+
// @ts-ignore https://github.com/xataio/client-ts/issues/313
|
3161
4374
|
body: { tables, query, fuzziness, prefix, highlight, page },
|
3162
|
-
...
|
4375
|
+
...pluginOptions
|
3163
4376
|
});
|
3164
4377
|
return records;
|
3165
4378
|
};
|
3166
4379
|
_getSchemaTables = new WeakSet();
|
3167
|
-
getSchemaTables_fn = async function(
|
4380
|
+
getSchemaTables_fn = async function(pluginOptions) {
|
3168
4381
|
if (__privateGet$1(this, _schemaTables))
|
3169
4382
|
return __privateGet$1(this, _schemaTables);
|
3170
|
-
const fetchProps = await getFetchProps();
|
3171
4383
|
const { schema } = await getBranchDetails({
|
3172
4384
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3173
|
-
...
|
4385
|
+
...pluginOptions
|
3174
4386
|
});
|
3175
4387
|
__privateSet$1(this, _schemaTables, schema.tables);
|
3176
4388
|
return schema.tables;
|
3177
4389
|
};
|
3178
4390
|
|
3179
4391
|
class TransactionPlugin extends XataPlugin {
|
3180
|
-
build(
|
4392
|
+
build(pluginOptions) {
|
3181
4393
|
return {
|
3182
4394
|
run: async (operations) => {
|
3183
|
-
const fetchProps = await getFetchProps();
|
3184
4395
|
const response = await branchTransaction({
|
3185
4396
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3186
4397
|
body: { operations },
|
3187
|
-
...
|
4398
|
+
...pluginOptions
|
3188
4399
|
});
|
3189
4400
|
return response;
|
3190
4401
|
}
|
@@ -3192,90 +4403,12 @@ class TransactionPlugin extends XataPlugin {
|
|
3192
4403
|
}
|
3193
4404
|
}
|
3194
4405
|
|
3195
|
-
|
3196
|
-
|
4406
|
+
var __defProp$2 = Object.defineProperty;
|
4407
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4408
|
+
var __publicField$2 = (obj, key, value) => {
|
4409
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4410
|
+
return value;
|
3197
4411
|
};
|
3198
|
-
|
3199
|
-
async function getCurrentBranchName(options) {
|
3200
|
-
const { branch, envBranch } = getEnvironment();
|
3201
|
-
if (branch)
|
3202
|
-
return branch;
|
3203
|
-
const gitBranch = envBranch || await getGitBranch();
|
3204
|
-
return resolveXataBranch(gitBranch, options);
|
3205
|
-
}
|
3206
|
-
async function getCurrentBranchDetails(options) {
|
3207
|
-
const branch = await getCurrentBranchName(options);
|
3208
|
-
return getDatabaseBranch(branch, options);
|
3209
|
-
}
|
3210
|
-
async function resolveXataBranch(gitBranch, options) {
|
3211
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
3212
|
-
const apiKey = options?.apiKey || getAPIKey();
|
3213
|
-
if (!databaseURL)
|
3214
|
-
throw new Error(
|
3215
|
-
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
3216
|
-
);
|
3217
|
-
if (!apiKey)
|
3218
|
-
throw new Error(
|
3219
|
-
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
3220
|
-
);
|
3221
|
-
const [protocol, , host, , dbName] = databaseURL.split("/");
|
3222
|
-
const urlParts = parseWorkspacesUrlParts(host);
|
3223
|
-
if (!urlParts)
|
3224
|
-
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3225
|
-
const { workspace, region } = urlParts;
|
3226
|
-
const { fallbackBranch } = getEnvironment();
|
3227
|
-
const { branch } = await resolveBranch({
|
3228
|
-
apiKey,
|
3229
|
-
apiUrl: databaseURL,
|
3230
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
3231
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
3232
|
-
pathParams: { dbName, workspace, region },
|
3233
|
-
queryParams: { gitBranch, fallbackBranch },
|
3234
|
-
trace: defaultTrace,
|
3235
|
-
clientName: options?.clientName
|
3236
|
-
});
|
3237
|
-
return branch;
|
3238
|
-
}
|
3239
|
-
async function getDatabaseBranch(branch, options) {
|
3240
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
3241
|
-
const apiKey = options?.apiKey || getAPIKey();
|
3242
|
-
if (!databaseURL)
|
3243
|
-
throw new Error(
|
3244
|
-
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
3245
|
-
);
|
3246
|
-
if (!apiKey)
|
3247
|
-
throw new Error(
|
3248
|
-
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
3249
|
-
);
|
3250
|
-
const [protocol, , host, , database] = databaseURL.split("/");
|
3251
|
-
const urlParts = parseWorkspacesUrlParts(host);
|
3252
|
-
if (!urlParts)
|
3253
|
-
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3254
|
-
const { workspace, region } = urlParts;
|
3255
|
-
try {
|
3256
|
-
return await getBranchDetails({
|
3257
|
-
apiKey,
|
3258
|
-
apiUrl: databaseURL,
|
3259
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
3260
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
3261
|
-
pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
|
3262
|
-
trace: defaultTrace
|
3263
|
-
});
|
3264
|
-
} catch (err) {
|
3265
|
-
if (isObject(err) && err.status === 404)
|
3266
|
-
return null;
|
3267
|
-
throw err;
|
3268
|
-
}
|
3269
|
-
}
|
3270
|
-
function getDatabaseURL() {
|
3271
|
-
try {
|
3272
|
-
const { databaseURL } = getEnvironment();
|
3273
|
-
return databaseURL;
|
3274
|
-
} catch (err) {
|
3275
|
-
return void 0;
|
3276
|
-
}
|
3277
|
-
}
|
3278
|
-
|
3279
4412
|
var __accessCheck = (obj, member, msg) => {
|
3280
4413
|
if (!member.has(obj))
|
3281
4414
|
throw TypeError("Cannot " + msg);
|
@@ -3299,48 +4432,45 @@ var __privateMethod = (obj, member, method) => {
|
|
3299
4432
|
return method;
|
3300
4433
|
};
|
3301
4434
|
const buildClient = (plugins) => {
|
3302
|
-
var
|
4435
|
+
var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
|
3303
4436
|
return _a = class {
|
3304
4437
|
constructor(options = {}, schemaTables) {
|
3305
4438
|
__privateAdd(this, _parseOptions);
|
3306
4439
|
__privateAdd(this, _getFetchProps);
|
3307
|
-
__privateAdd(this, _evaluateBranch);
|
3308
|
-
__privateAdd(this, _branch, void 0);
|
3309
4440
|
__privateAdd(this, _options, void 0);
|
4441
|
+
__publicField$2(this, "db");
|
4442
|
+
__publicField$2(this, "search");
|
4443
|
+
__publicField$2(this, "transactions");
|
4444
|
+
__publicField$2(this, "files");
|
3310
4445
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
3311
4446
|
__privateSet(this, _options, safeOptions);
|
3312
4447
|
const pluginOptions = {
|
3313
|
-
|
4448
|
+
...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
3314
4449
|
cache: safeOptions.cache,
|
3315
|
-
|
4450
|
+
host: safeOptions.host
|
3316
4451
|
};
|
3317
4452
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
3318
4453
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
3319
4454
|
const transactions = new TransactionPlugin().build(pluginOptions);
|
4455
|
+
const files = new FilesPlugin().build(pluginOptions);
|
3320
4456
|
this.db = db;
|
3321
4457
|
this.search = search;
|
3322
4458
|
this.transactions = transactions;
|
4459
|
+
this.files = files;
|
3323
4460
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
3324
4461
|
if (namespace === void 0)
|
3325
4462
|
continue;
|
3326
|
-
|
3327
|
-
if (result instanceof Promise) {
|
3328
|
-
void result.then((namespace2) => {
|
3329
|
-
this[key] = namespace2;
|
3330
|
-
});
|
3331
|
-
} else {
|
3332
|
-
this[key] = result;
|
3333
|
-
}
|
4463
|
+
this[key] = namespace.build(pluginOptions);
|
3334
4464
|
}
|
3335
4465
|
}
|
3336
4466
|
async getConfig() {
|
3337
4467
|
const databaseURL = __privateGet(this, _options).databaseURL;
|
3338
|
-
const branch =
|
4468
|
+
const branch = __privateGet(this, _options).branch;
|
3339
4469
|
return { databaseURL, branch };
|
3340
4470
|
}
|
3341
|
-
},
|
4471
|
+
}, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
3342
4472
|
const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
|
3343
|
-
const isBrowser = typeof window !== "undefined";
|
4473
|
+
const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
|
3344
4474
|
if (isBrowser && !enableBrowser) {
|
3345
4475
|
throw new Error(
|
3346
4476
|
"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."
|
@@ -3352,70 +4482,88 @@ const buildClient = (plugins) => {
|
|
3352
4482
|
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
3353
4483
|
const trace = options?.trace ?? defaultTrace;
|
3354
4484
|
const clientName = options?.clientName;
|
3355
|
-
const
|
3356
|
-
|
3357
|
-
databaseURL,
|
3358
|
-
fetchImpl: options?.fetch,
|
3359
|
-
clientName: options?.clientName
|
3360
|
-
});
|
4485
|
+
const host = options?.host ?? "production";
|
4486
|
+
const xataAgentExtra = options?.xataAgentExtra;
|
3361
4487
|
if (!apiKey) {
|
3362
4488
|
throw new Error("Option apiKey is required");
|
3363
4489
|
}
|
3364
4490
|
if (!databaseURL) {
|
3365
4491
|
throw new Error("Option databaseURL is required");
|
3366
4492
|
}
|
3367
|
-
|
3368
|
-
|
4493
|
+
const envBranch = getBranch();
|
4494
|
+
const previewBranch = getPreviewBranch();
|
4495
|
+
const branch = options?.branch || previewBranch || envBranch || "main";
|
4496
|
+
if (!!previewBranch && branch !== previewBranch) {
|
4497
|
+
console.warn(
|
4498
|
+
`Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
|
4499
|
+
);
|
4500
|
+
} else if (!!envBranch && branch !== envBranch) {
|
4501
|
+
console.warn(
|
4502
|
+
`Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
4503
|
+
);
|
4504
|
+
} else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
|
4505
|
+
console.warn(
|
4506
|
+
`Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
4507
|
+
);
|
4508
|
+
} else if (!previewBranch && !envBranch && options?.branch === void 0) {
|
4509
|
+
console.warn(
|
4510
|
+
`No branch was passed to the client constructor. Using default branch ${branch}. You can set the branch with the environment variable XATA_BRANCH or by passing the branch option to the client constructor.`
|
4511
|
+
);
|
4512
|
+
}
|
4513
|
+
return {
|
4514
|
+
fetch,
|
4515
|
+
databaseURL,
|
4516
|
+
apiKey,
|
4517
|
+
branch,
|
4518
|
+
cache,
|
4519
|
+
trace,
|
4520
|
+
host,
|
4521
|
+
clientID: generateUUID(),
|
4522
|
+
enableBrowser,
|
4523
|
+
clientName,
|
4524
|
+
xataAgentExtra
|
4525
|
+
};
|
4526
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
|
3369
4527
|
fetch,
|
3370
4528
|
apiKey,
|
3371
4529
|
databaseURL,
|
3372
4530
|
branch,
|
3373
4531
|
trace,
|
3374
4532
|
clientID,
|
3375
|
-
clientName
|
4533
|
+
clientName,
|
4534
|
+
xataAgentExtra
|
3376
4535
|
}) {
|
3377
|
-
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
3378
|
-
if (!branchValue)
|
3379
|
-
throw new Error("Unable to resolve branch value");
|
3380
4536
|
return {
|
3381
|
-
|
4537
|
+
fetch,
|
3382
4538
|
apiKey,
|
3383
4539
|
apiUrl: "",
|
4540
|
+
// Instead of using workspace and dbBranch, we inject a probably CNAME'd URL
|
3384
4541
|
workspacesApiUrl: (path, params) => {
|
3385
4542
|
const hasBranch = params.dbBranchName ?? params.branch;
|
3386
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${
|
4543
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
|
3387
4544
|
return databaseURL + newPath;
|
3388
4545
|
},
|
3389
4546
|
trace,
|
3390
4547
|
clientID,
|
3391
|
-
clientName
|
3392
|
-
|
3393
|
-
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
3394
|
-
if (__privateGet(this, _branch))
|
3395
|
-
return __privateGet(this, _branch);
|
3396
|
-
if (param === void 0)
|
3397
|
-
return void 0;
|
3398
|
-
const strategies = Array.isArray(param) ? [...param] : [param];
|
3399
|
-
const evaluateBranch = async (strategy) => {
|
3400
|
-
return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
|
4548
|
+
clientName,
|
4549
|
+
xataAgentExtra
|
3401
4550
|
};
|
3402
|
-
for await (const strategy of strategies) {
|
3403
|
-
const branch = await evaluateBranch(strategy);
|
3404
|
-
if (branch) {
|
3405
|
-
__privateSet(this, _branch, branch);
|
3406
|
-
return branch;
|
3407
|
-
}
|
3408
|
-
}
|
3409
4551
|
}, _a;
|
3410
4552
|
};
|
3411
4553
|
class BaseClient extends buildClient() {
|
3412
4554
|
}
|
3413
4555
|
|
4556
|
+
var __defProp$1 = Object.defineProperty;
|
4557
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4558
|
+
var __publicField$1 = (obj, key, value) => {
|
4559
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4560
|
+
return value;
|
4561
|
+
};
|
3414
4562
|
const META = "__";
|
3415
4563
|
const VALUE = "___";
|
3416
4564
|
class Serializer {
|
3417
4565
|
constructor() {
|
3418
|
-
this
|
4566
|
+
__publicField$1(this, "classes", {});
|
3419
4567
|
}
|
3420
4568
|
add(clazz) {
|
3421
4569
|
this.classes[clazz.name] = clazz;
|
@@ -3493,12 +4641,19 @@ function buildWorkerRunner(config) {
|
|
3493
4641
|
};
|
3494
4642
|
}
|
3495
4643
|
|
4644
|
+
var __defProp = Object.defineProperty;
|
4645
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4646
|
+
var __publicField = (obj, key, value) => {
|
4647
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4648
|
+
return value;
|
4649
|
+
};
|
3496
4650
|
class XataError extends Error {
|
3497
4651
|
constructor(message, status) {
|
3498
4652
|
super(message);
|
4653
|
+
__publicField(this, "status");
|
3499
4654
|
this.status = status;
|
3500
4655
|
}
|
3501
4656
|
}
|
3502
4657
|
|
3503
|
-
export { BaseClient, FetcherError, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, branchTransaction, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn,
|
4658
|
+
export { BaseClient, FetcherError, FilesPlugin, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteOAuthAccessToken, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, ge, getAPIKey, getAuthorizationCode, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getUserOAuthAccessTokens, getUserOAuthClients, getWorkspace, getWorkspaceMembersList, getWorkspacesList, grantAuthorizationCode, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, transformImage, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateOAuthAccessToken, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
|
3504
4659
|
//# sourceMappingURL=index.mjs.map
|