@xata.io/client 0.0.0-alpha.vfafe7e2 → 0.0.0-alpha.vfb070a9
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 +218 -0
- package/README.md +3 -269
- package/dist/index.cjs +1753 -364
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2969 -1139
- package/dist/index.mjs +1719 -363
- 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.cjs
CHANGED
@@ -20,7 +20,8 @@ const TraceAttributes = {
|
|
20
20
|
HTTP_METHOD: "http.method",
|
21
21
|
HTTP_URL: "http.url",
|
22
22
|
HTTP_ROUTE: "http.route",
|
23
|
-
HTTP_TARGET: "http.target"
|
23
|
+
HTTP_TARGET: "http.target",
|
24
|
+
CLOUDFLARE_RAY_ID: "cf.ray"
|
24
25
|
};
|
25
26
|
|
26
27
|
function notEmpty(value) {
|
@@ -29,8 +30,18 @@ function notEmpty(value) {
|
|
29
30
|
function compact(arr) {
|
30
31
|
return arr.filter(notEmpty);
|
31
32
|
}
|
33
|
+
function compactObject(obj) {
|
34
|
+
return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
|
35
|
+
}
|
36
|
+
function isBlob(value) {
|
37
|
+
try {
|
38
|
+
return value instanceof Blob;
|
39
|
+
} catch (error) {
|
40
|
+
return false;
|
41
|
+
}
|
42
|
+
}
|
32
43
|
function isObject(value) {
|
33
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
44
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !isBlob(value);
|
34
45
|
}
|
35
46
|
function isDefined(value) {
|
36
47
|
return value !== null && value !== void 0;
|
@@ -85,6 +96,27 @@ function chunk(array, chunkSize) {
|
|
85
96
|
async function timeout(ms) {
|
86
97
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
87
98
|
}
|
99
|
+
function timeoutWithCancel(ms) {
|
100
|
+
let timeoutId;
|
101
|
+
const promise = new Promise((resolve) => {
|
102
|
+
timeoutId = setTimeout(() => {
|
103
|
+
resolve();
|
104
|
+
}, ms);
|
105
|
+
});
|
106
|
+
return {
|
107
|
+
cancel: () => clearTimeout(timeoutId),
|
108
|
+
promise
|
109
|
+
};
|
110
|
+
}
|
111
|
+
function promiseMap(inputValues, mapper) {
|
112
|
+
const reducer = (acc$, inputValue) => acc$.then(
|
113
|
+
(acc) => mapper(inputValue).then((result) => {
|
114
|
+
acc.push(result);
|
115
|
+
return acc;
|
116
|
+
})
|
117
|
+
);
|
118
|
+
return inputValues.reduce(reducer, Promise.resolve([]));
|
119
|
+
}
|
88
120
|
|
89
121
|
function getEnvironment() {
|
90
122
|
try {
|
@@ -93,8 +125,10 @@ function getEnvironment() {
|
|
93
125
|
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
94
126
|
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
95
127
|
branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
|
96
|
-
|
97
|
-
|
128
|
+
deployPreview: process.env.XATA_PREVIEW,
|
129
|
+
deployPreviewBranch: process.env.XATA_PREVIEW_BRANCH,
|
130
|
+
vercelGitCommitRef: process.env.VERCEL_GIT_COMMIT_REF,
|
131
|
+
vercelGitRepoOwner: process.env.VERCEL_GIT_REPO_OWNER
|
98
132
|
};
|
99
133
|
}
|
100
134
|
} catch (err) {
|
@@ -105,8 +139,10 @@ function getEnvironment() {
|
|
105
139
|
apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
|
106
140
|
databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
|
107
141
|
branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
|
108
|
-
|
109
|
-
|
142
|
+
deployPreview: Deno.env.get("XATA_PREVIEW"),
|
143
|
+
deployPreviewBranch: Deno.env.get("XATA_PREVIEW_BRANCH"),
|
144
|
+
vercelGitCommitRef: Deno.env.get("VERCEL_GIT_COMMIT_REF"),
|
145
|
+
vercelGitRepoOwner: Deno.env.get("VERCEL_GIT_REPO_OWNER")
|
110
146
|
};
|
111
147
|
}
|
112
148
|
} catch (err) {
|
@@ -115,8 +151,10 @@ function getEnvironment() {
|
|
115
151
|
apiKey: getGlobalApiKey(),
|
116
152
|
databaseURL: getGlobalDatabaseURL(),
|
117
153
|
branch: getGlobalBranch(),
|
118
|
-
|
119
|
-
|
154
|
+
deployPreview: void 0,
|
155
|
+
deployPreviewBranch: void 0,
|
156
|
+
vercelGitCommitRef: void 0,
|
157
|
+
vercelGitRepoOwner: void 0
|
120
158
|
};
|
121
159
|
}
|
122
160
|
function getEnableBrowserVariable() {
|
@@ -159,45 +197,59 @@ function getGlobalBranch() {
|
|
159
197
|
return void 0;
|
160
198
|
}
|
161
199
|
}
|
162
|
-
function
|
200
|
+
function getDatabaseURL() {
|
163
201
|
try {
|
164
|
-
|
202
|
+
const { databaseURL } = getEnvironment();
|
203
|
+
return databaseURL;
|
165
204
|
} catch (err) {
|
166
205
|
return void 0;
|
167
206
|
}
|
168
207
|
}
|
169
|
-
|
170
|
-
const cmd = ["git", "branch", "--show-current"];
|
171
|
-
const fullCmd = cmd.join(" ");
|
172
|
-
const nodeModule = ["child", "process"].join("_");
|
173
|
-
const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
|
208
|
+
function getAPIKey() {
|
174
209
|
try {
|
175
|
-
const
|
176
|
-
|
177
|
-
return req(nodeModule).execSync(fullCmd, execOptions).trim();
|
178
|
-
}
|
179
|
-
const { execSync } = await import(nodeModule);
|
180
|
-
return execSync(fullCmd, execOptions).toString().trim();
|
210
|
+
const { apiKey } = getEnvironment();
|
211
|
+
return apiKey;
|
181
212
|
} catch (err) {
|
213
|
+
return void 0;
|
182
214
|
}
|
215
|
+
}
|
216
|
+
function getBranch() {
|
183
217
|
try {
|
184
|
-
|
185
|
-
|
186
|
-
return new TextDecoder().decode(await process2.output()).trim();
|
187
|
-
}
|
218
|
+
const { branch } = getEnvironment();
|
219
|
+
return branch;
|
188
220
|
} catch (err) {
|
221
|
+
return void 0;
|
189
222
|
}
|
190
223
|
}
|
191
|
-
|
192
|
-
|
224
|
+
function buildPreviewBranchName({ org, branch }) {
|
225
|
+
return `preview-${org}-${branch}`;
|
226
|
+
}
|
227
|
+
function getPreviewBranch() {
|
193
228
|
try {
|
194
|
-
const {
|
195
|
-
|
229
|
+
const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = getEnvironment();
|
230
|
+
if (deployPreviewBranch)
|
231
|
+
return deployPreviewBranch;
|
232
|
+
switch (deployPreview) {
|
233
|
+
case "vercel": {
|
234
|
+
if (!vercelGitCommitRef || !vercelGitRepoOwner) {
|
235
|
+
console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
|
236
|
+
return void 0;
|
237
|
+
}
|
238
|
+
return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
|
239
|
+
}
|
240
|
+
}
|
241
|
+
return void 0;
|
196
242
|
} catch (err) {
|
197
243
|
return void 0;
|
198
244
|
}
|
199
245
|
}
|
200
246
|
|
247
|
+
var __defProp$8 = Object.defineProperty;
|
248
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
249
|
+
var __publicField$8 = (obj, key, value) => {
|
250
|
+
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
251
|
+
return value;
|
252
|
+
};
|
201
253
|
var __accessCheck$8 = (obj, member, msg) => {
|
202
254
|
if (!member.has(obj))
|
203
255
|
throw TypeError("Cannot " + msg);
|
@@ -221,13 +273,13 @@ var __privateMethod$4 = (obj, member, method) => {
|
|
221
273
|
return method;
|
222
274
|
};
|
223
275
|
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
276
|
+
const REQUEST_TIMEOUT = 5 * 60 * 1e3;
|
224
277
|
function getFetchImplementation(userFetch) {
|
225
278
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
226
|
-
const
|
279
|
+
const globalThisFetch = typeof globalThis !== "undefined" ? globalThis.fetch : void 0;
|
280
|
+
const fetchImpl = userFetch ?? globalFetch ?? globalThisFetch;
|
227
281
|
if (!fetchImpl) {
|
228
|
-
throw new Error(
|
229
|
-
`Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
|
230
|
-
);
|
282
|
+
throw new Error(`Couldn't find a global \`fetch\`. Pass a fetch implementation explicitly.`);
|
231
283
|
}
|
232
284
|
return fetchImpl;
|
233
285
|
}
|
@@ -237,6 +289,8 @@ class ApiRequestPool {
|
|
237
289
|
__privateAdd$8(this, _fetch, void 0);
|
238
290
|
__privateAdd$8(this, _queue, void 0);
|
239
291
|
__privateAdd$8(this, _concurrency, void 0);
|
292
|
+
__publicField$8(this, "running");
|
293
|
+
__publicField$8(this, "started");
|
240
294
|
__privateSet$8(this, _queue, []);
|
241
295
|
__privateSet$8(this, _concurrency, concurrency);
|
242
296
|
this.running = 0;
|
@@ -252,18 +306,22 @@ class ApiRequestPool {
|
|
252
306
|
return __privateGet$8(this, _fetch);
|
253
307
|
}
|
254
308
|
request(url, options) {
|
255
|
-
const start = new Date();
|
256
|
-
const
|
309
|
+
const start = /* @__PURE__ */ new Date();
|
310
|
+
const fetchImpl = this.getFetch();
|
257
311
|
const runRequest = async (stalled = false) => {
|
258
|
-
const
|
312
|
+
const { promise, cancel } = timeoutWithCancel(REQUEST_TIMEOUT);
|
313
|
+
const response = await Promise.race([fetchImpl(url, options), promise.then(() => null)]).finally(cancel);
|
314
|
+
if (!response) {
|
315
|
+
throw new Error("Request timed out");
|
316
|
+
}
|
259
317
|
if (response.status === 429) {
|
260
318
|
const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
|
261
319
|
await timeout(rateLimitReset * 1e3);
|
262
320
|
return await runRequest(true);
|
263
321
|
}
|
264
322
|
if (stalled) {
|
265
|
-
const stalledTime = new Date().getTime() - start.getTime();
|
266
|
-
console.warn(`A request to Xata hit
|
323
|
+
const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
|
324
|
+
console.warn(`A request to Xata hit branch rate limits, was retried and stalled for ${stalledTime}ms`);
|
267
325
|
}
|
268
326
|
return response;
|
269
327
|
};
|
@@ -305,16 +363,199 @@ function generateUUID() {
|
|
305
363
|
});
|
306
364
|
}
|
307
365
|
|
308
|
-
|
366
|
+
async function getBytes(stream, onChunk) {
|
367
|
+
const reader = stream.getReader();
|
368
|
+
let result;
|
369
|
+
while (!(result = await reader.read()).done) {
|
370
|
+
onChunk(result.value);
|
371
|
+
}
|
372
|
+
}
|
373
|
+
function getLines(onLine) {
|
374
|
+
let buffer;
|
375
|
+
let position;
|
376
|
+
let fieldLength;
|
377
|
+
let discardTrailingNewline = false;
|
378
|
+
return function onChunk(arr) {
|
379
|
+
if (buffer === void 0) {
|
380
|
+
buffer = arr;
|
381
|
+
position = 0;
|
382
|
+
fieldLength = -1;
|
383
|
+
} else {
|
384
|
+
buffer = concat(buffer, arr);
|
385
|
+
}
|
386
|
+
const bufLength = buffer.length;
|
387
|
+
let lineStart = 0;
|
388
|
+
while (position < bufLength) {
|
389
|
+
if (discardTrailingNewline) {
|
390
|
+
if (buffer[position] === 10 /* NewLine */) {
|
391
|
+
lineStart = ++position;
|
392
|
+
}
|
393
|
+
discardTrailingNewline = false;
|
394
|
+
}
|
395
|
+
let lineEnd = -1;
|
396
|
+
for (; position < bufLength && lineEnd === -1; ++position) {
|
397
|
+
switch (buffer[position]) {
|
398
|
+
case 58 /* Colon */:
|
399
|
+
if (fieldLength === -1) {
|
400
|
+
fieldLength = position - lineStart;
|
401
|
+
}
|
402
|
+
break;
|
403
|
+
case 13 /* CarriageReturn */:
|
404
|
+
discardTrailingNewline = true;
|
405
|
+
case 10 /* NewLine */:
|
406
|
+
lineEnd = position;
|
407
|
+
break;
|
408
|
+
}
|
409
|
+
}
|
410
|
+
if (lineEnd === -1) {
|
411
|
+
break;
|
412
|
+
}
|
413
|
+
onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
|
414
|
+
lineStart = position;
|
415
|
+
fieldLength = -1;
|
416
|
+
}
|
417
|
+
if (lineStart === bufLength) {
|
418
|
+
buffer = void 0;
|
419
|
+
} else if (lineStart !== 0) {
|
420
|
+
buffer = buffer.subarray(lineStart);
|
421
|
+
position -= lineStart;
|
422
|
+
}
|
423
|
+
};
|
424
|
+
}
|
425
|
+
function getMessages(onId, onRetry, onMessage) {
|
426
|
+
let message = newMessage();
|
427
|
+
const decoder = new TextDecoder();
|
428
|
+
return function onLine(line, fieldLength) {
|
429
|
+
if (line.length === 0) {
|
430
|
+
onMessage?.(message);
|
431
|
+
message = newMessage();
|
432
|
+
} else if (fieldLength > 0) {
|
433
|
+
const field = decoder.decode(line.subarray(0, fieldLength));
|
434
|
+
const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
|
435
|
+
const value = decoder.decode(line.subarray(valueOffset));
|
436
|
+
switch (field) {
|
437
|
+
case "data":
|
438
|
+
message.data = message.data ? message.data + "\n" + value : value;
|
439
|
+
break;
|
440
|
+
case "event":
|
441
|
+
message.event = value;
|
442
|
+
break;
|
443
|
+
case "id":
|
444
|
+
onId(message.id = value);
|
445
|
+
break;
|
446
|
+
case "retry":
|
447
|
+
const retry = parseInt(value, 10);
|
448
|
+
if (!isNaN(retry)) {
|
449
|
+
onRetry(message.retry = retry);
|
450
|
+
}
|
451
|
+
break;
|
452
|
+
}
|
453
|
+
}
|
454
|
+
};
|
455
|
+
}
|
456
|
+
function concat(a, b) {
|
457
|
+
const res = new Uint8Array(a.length + b.length);
|
458
|
+
res.set(a);
|
459
|
+
res.set(b, a.length);
|
460
|
+
return res;
|
461
|
+
}
|
462
|
+
function newMessage() {
|
463
|
+
return {
|
464
|
+
data: "",
|
465
|
+
event: "",
|
466
|
+
id: "",
|
467
|
+
retry: void 0
|
468
|
+
};
|
469
|
+
}
|
470
|
+
const EventStreamContentType = "text/event-stream";
|
471
|
+
const LastEventId = "last-event-id";
|
472
|
+
function fetchEventSource(input, {
|
473
|
+
signal: inputSignal,
|
474
|
+
headers: inputHeaders,
|
475
|
+
onopen: inputOnOpen,
|
476
|
+
onmessage,
|
477
|
+
onclose,
|
478
|
+
onerror,
|
479
|
+
fetch: inputFetch,
|
480
|
+
...rest
|
481
|
+
}) {
|
482
|
+
return new Promise((resolve, reject) => {
|
483
|
+
const headers = { ...inputHeaders };
|
484
|
+
if (!headers.accept) {
|
485
|
+
headers.accept = EventStreamContentType;
|
486
|
+
}
|
487
|
+
let curRequestController;
|
488
|
+
function dispose() {
|
489
|
+
curRequestController.abort();
|
490
|
+
}
|
491
|
+
inputSignal?.addEventListener("abort", () => {
|
492
|
+
dispose();
|
493
|
+
resolve();
|
494
|
+
});
|
495
|
+
const fetchImpl = inputFetch ?? fetch;
|
496
|
+
const onopen = inputOnOpen ?? defaultOnOpen;
|
497
|
+
async function create() {
|
498
|
+
curRequestController = new AbortController();
|
499
|
+
try {
|
500
|
+
const response = await fetchImpl(input, {
|
501
|
+
...rest,
|
502
|
+
headers,
|
503
|
+
signal: curRequestController.signal
|
504
|
+
});
|
505
|
+
await onopen(response);
|
506
|
+
await getBytes(
|
507
|
+
response.body,
|
508
|
+
getLines(
|
509
|
+
getMessages(
|
510
|
+
(id) => {
|
511
|
+
if (id) {
|
512
|
+
headers[LastEventId] = id;
|
513
|
+
} else {
|
514
|
+
delete headers[LastEventId];
|
515
|
+
}
|
516
|
+
},
|
517
|
+
(_retry) => {
|
518
|
+
},
|
519
|
+
onmessage
|
520
|
+
)
|
521
|
+
)
|
522
|
+
);
|
523
|
+
onclose?.();
|
524
|
+
dispose();
|
525
|
+
resolve();
|
526
|
+
} catch (err) {
|
527
|
+
}
|
528
|
+
}
|
529
|
+
create();
|
530
|
+
});
|
531
|
+
}
|
532
|
+
function defaultOnOpen(response) {
|
533
|
+
const contentType = response.headers?.get("content-type");
|
534
|
+
if (!contentType?.startsWith(EventStreamContentType)) {
|
535
|
+
throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
|
536
|
+
}
|
537
|
+
}
|
538
|
+
|
539
|
+
const VERSION = "0.26.5";
|
309
540
|
|
541
|
+
var __defProp$7 = Object.defineProperty;
|
542
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
543
|
+
var __publicField$7 = (obj, key, value) => {
|
544
|
+
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
545
|
+
return value;
|
546
|
+
};
|
310
547
|
class ErrorWithCause extends Error {
|
311
548
|
constructor(message, options) {
|
312
549
|
super(message, options);
|
550
|
+
__publicField$7(this, "cause");
|
313
551
|
}
|
314
552
|
}
|
315
553
|
class FetcherError extends ErrorWithCause {
|
316
554
|
constructor(status, data, requestId) {
|
317
555
|
super(getMessage(data));
|
556
|
+
__publicField$7(this, "status");
|
557
|
+
__publicField$7(this, "requestId");
|
558
|
+
__publicField$7(this, "errors");
|
318
559
|
this.status = status;
|
319
560
|
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
320
561
|
this.requestId = requestId;
|
@@ -381,6 +622,18 @@ function hostHeader(url) {
|
|
381
622
|
const { groups } = pattern.exec(url) ?? {};
|
382
623
|
return groups?.host ? { Host: groups.host } : {};
|
383
624
|
}
|
625
|
+
async function parseBody(body, headers) {
|
626
|
+
if (!isDefined(body))
|
627
|
+
return void 0;
|
628
|
+
if (isBlob(body) || typeof body.text === "function") {
|
629
|
+
return body;
|
630
|
+
}
|
631
|
+
const { "Content-Type": contentType } = headers ?? {};
|
632
|
+
if (String(contentType).toLowerCase() === "application/json" && isObject(body)) {
|
633
|
+
return JSON.stringify(body);
|
634
|
+
}
|
635
|
+
return body;
|
636
|
+
}
|
384
637
|
const defaultClientID = generateUUID();
|
385
638
|
async function fetch$1({
|
386
639
|
url: path,
|
@@ -389,7 +642,7 @@ async function fetch$1({
|
|
389
642
|
headers: customHeaders,
|
390
643
|
pathParams,
|
391
644
|
queryParams,
|
392
|
-
|
645
|
+
fetch: fetch2,
|
393
646
|
apiKey,
|
394
647
|
endpoint,
|
395
648
|
apiUrl,
|
@@ -399,12 +652,14 @@ async function fetch$1({
|
|
399
652
|
clientID,
|
400
653
|
sessionID,
|
401
654
|
clientName,
|
402
|
-
|
655
|
+
xataAgentExtra,
|
656
|
+
fetchOptions = {},
|
657
|
+
rawResponse = false
|
403
658
|
}) {
|
404
|
-
pool.setFetch(
|
659
|
+
pool.setFetch(fetch2);
|
405
660
|
return await trace(
|
406
661
|
`${method.toUpperCase()} ${path}`,
|
407
|
-
async ({
|
662
|
+
async ({ setAttributes }) => {
|
408
663
|
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
409
664
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
410
665
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
@@ -415,9 +670,10 @@ async function fetch$1({
|
|
415
670
|
const xataAgent = compact([
|
416
671
|
["client", "TS_SDK"],
|
417
672
|
["version", VERSION],
|
418
|
-
isDefined(clientName) ? ["service", clientName] : void 0
|
673
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
674
|
+
...Object.entries(xataAgentExtra ?? {})
|
419
675
|
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
420
|
-
const headers = {
|
676
|
+
const headers = compactObject({
|
421
677
|
"Accept-Encoding": "identity",
|
422
678
|
"Content-Type": "application/json",
|
423
679
|
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
@@ -426,11 +682,11 @@ async function fetch$1({
|
|
426
682
|
...customHeaders,
|
427
683
|
...hostHeader(fullUrl),
|
428
684
|
Authorization: `Bearer ${apiKey}`
|
429
|
-
};
|
685
|
+
});
|
430
686
|
const response = await pool.request(url, {
|
431
687
|
...fetchOptions,
|
432
688
|
method: method.toUpperCase(),
|
433
|
-
body:
|
689
|
+
body: await parseBody(body, headers),
|
434
690
|
headers,
|
435
691
|
signal
|
436
692
|
});
|
@@ -441,8 +697,12 @@ async function fetch$1({
|
|
441
697
|
[TraceAttributes.HTTP_REQUEST_ID]: requestId,
|
442
698
|
[TraceAttributes.HTTP_STATUS_CODE]: response.status,
|
443
699
|
[TraceAttributes.HTTP_HOST]: host,
|
444
|
-
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
700
|
+
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", ""),
|
701
|
+
[TraceAttributes.CLOUDFLARE_RAY_ID]: response.headers?.get("cf-ray") ?? void 0
|
445
702
|
});
|
703
|
+
const message = response.headers?.get("x-xata-message");
|
704
|
+
if (message)
|
705
|
+
console.warn(message);
|
446
706
|
if (response.status === 204) {
|
447
707
|
return {};
|
448
708
|
}
|
@@ -450,7 +710,7 @@ async function fetch$1({
|
|
450
710
|
throw new FetcherError(response.status, "Rate limit exceeded", requestId);
|
451
711
|
}
|
452
712
|
try {
|
453
|
-
const jsonResponse = await response.json();
|
713
|
+
const jsonResponse = rawResponse ? await response.blob() : await response.json();
|
454
714
|
if (response.ok) {
|
455
715
|
return jsonResponse;
|
456
716
|
}
|
@@ -462,6 +722,59 @@ async function fetch$1({
|
|
462
722
|
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
463
723
|
);
|
464
724
|
}
|
725
|
+
function fetchSSERequest({
|
726
|
+
url: path,
|
727
|
+
method,
|
728
|
+
body,
|
729
|
+
headers: customHeaders,
|
730
|
+
pathParams,
|
731
|
+
queryParams,
|
732
|
+
fetch: fetch2,
|
733
|
+
apiKey,
|
734
|
+
endpoint,
|
735
|
+
apiUrl,
|
736
|
+
workspacesApiUrl,
|
737
|
+
onMessage,
|
738
|
+
onError,
|
739
|
+
onClose,
|
740
|
+
signal,
|
741
|
+
clientID,
|
742
|
+
sessionID,
|
743
|
+
clientName,
|
744
|
+
xataAgentExtra
|
745
|
+
}) {
|
746
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
747
|
+
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
748
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
749
|
+
void fetchEventSource(url, {
|
750
|
+
method,
|
751
|
+
body: JSON.stringify(body),
|
752
|
+
fetch: fetch2,
|
753
|
+
signal,
|
754
|
+
headers: {
|
755
|
+
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
756
|
+
"X-Xata-Session-ID": sessionID ?? generateUUID(),
|
757
|
+
"X-Xata-Agent": compact([
|
758
|
+
["client", "TS_SDK"],
|
759
|
+
["version", VERSION],
|
760
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
761
|
+
...Object.entries(xataAgentExtra ?? {})
|
762
|
+
]).map(([key, value]) => `${key}=${value}`).join("; "),
|
763
|
+
...customHeaders,
|
764
|
+
Authorization: `Bearer ${apiKey}`,
|
765
|
+
"Content-Type": "application/json"
|
766
|
+
},
|
767
|
+
onmessage(ev) {
|
768
|
+
onMessage?.(JSON.parse(ev.data));
|
769
|
+
},
|
770
|
+
onerror(ev) {
|
771
|
+
onError?.(JSON.parse(ev.data));
|
772
|
+
},
|
773
|
+
onclose() {
|
774
|
+
onClose?.();
|
775
|
+
}
|
776
|
+
});
|
777
|
+
}
|
465
778
|
function parseUrl(url) {
|
466
779
|
try {
|
467
780
|
const { host, protocol } = new URL(url);
|
@@ -492,6 +805,12 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
|
|
492
805
|
...variables,
|
493
806
|
signal
|
494
807
|
});
|
808
|
+
const copyBranch = (variables, signal) => dataPlaneFetch({
|
809
|
+
url: "/db/{dbBranchName}/copy",
|
810
|
+
method: "post",
|
811
|
+
...variables,
|
812
|
+
signal
|
813
|
+
});
|
495
814
|
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
496
815
|
url: "/db/{dbBranchName}/metadata",
|
497
816
|
method: "put",
|
@@ -517,7 +836,6 @@ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName
|
|
517
836
|
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
518
837
|
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
519
838
|
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
520
|
-
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
521
839
|
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
522
840
|
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
523
841
|
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
@@ -542,6 +860,7 @@ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{
|
|
542
860
|
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
543
861
|
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
544
862
|
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
863
|
+
const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
|
545
864
|
const createTable = (variables, signal) => dataPlaneFetch({
|
546
865
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
547
866
|
method: "put",
|
@@ -584,7 +903,44 @@ const deleteColumn = (variables, signal) => dataPlaneFetch({
|
|
584
903
|
...variables,
|
585
904
|
signal
|
586
905
|
});
|
906
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
587
907
|
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
908
|
+
const getFileItem = (variables, signal) => dataPlaneFetch({
|
909
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
910
|
+
method: "get",
|
911
|
+
...variables,
|
912
|
+
signal
|
913
|
+
});
|
914
|
+
const putFileItem = (variables, signal) => dataPlaneFetch({
|
915
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
916
|
+
method: "put",
|
917
|
+
...variables,
|
918
|
+
signal
|
919
|
+
});
|
920
|
+
const deleteFileItem = (variables, signal) => dataPlaneFetch({
|
921
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
922
|
+
method: "delete",
|
923
|
+
...variables,
|
924
|
+
signal
|
925
|
+
});
|
926
|
+
const getFile = (variables, signal) => dataPlaneFetch({
|
927
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
928
|
+
method: "get",
|
929
|
+
...variables,
|
930
|
+
signal
|
931
|
+
});
|
932
|
+
const putFile = (variables, signal) => dataPlaneFetch({
|
933
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
934
|
+
method: "put",
|
935
|
+
...variables,
|
936
|
+
signal
|
937
|
+
});
|
938
|
+
const deleteFile = (variables, signal) => dataPlaneFetch({
|
939
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
940
|
+
method: "delete",
|
941
|
+
...variables,
|
942
|
+
signal
|
943
|
+
});
|
588
944
|
const getRecord = (variables, signal) => dataPlaneFetch({
|
589
945
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
590
946
|
method: "get",
|
@@ -614,14 +970,35 @@ const searchTable = (variables, signal) => dataPlaneFetch({
|
|
614
970
|
...variables,
|
615
971
|
signal
|
616
972
|
});
|
973
|
+
const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
|
974
|
+
const askTable = (variables, signal) => dataPlaneFetch({
|
975
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
976
|
+
method: "post",
|
977
|
+
...variables,
|
978
|
+
signal
|
979
|
+
});
|
980
|
+
const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
|
617
981
|
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
618
982
|
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
983
|
+
const fileAccess = (variables, signal) => dataPlaneFetch({
|
984
|
+
url: "/file/{fileId}",
|
985
|
+
method: "get",
|
986
|
+
...variables,
|
987
|
+
signal
|
988
|
+
});
|
989
|
+
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
990
|
+
url: "/db/{dbBranchName}/sql",
|
991
|
+
method: "post",
|
992
|
+
...variables,
|
993
|
+
signal
|
994
|
+
});
|
619
995
|
const operationsByTag$2 = {
|
620
996
|
branch: {
|
621
997
|
getBranchList,
|
622
998
|
getBranchDetails,
|
623
999
|
createBranch,
|
624
1000
|
deleteBranch,
|
1001
|
+
copyBranch,
|
625
1002
|
updateBranchMetadata,
|
626
1003
|
getBranchMetadata,
|
627
1004
|
getBranchStats,
|
@@ -639,17 +1016,8 @@ const operationsByTag$2 = {
|
|
639
1016
|
compareBranchSchemas,
|
640
1017
|
updateBranchSchema,
|
641
1018
|
previewBranchSchemaEdit,
|
642
|
-
applyBranchSchemaEdit
|
643
|
-
|
644
|
-
records: {
|
645
|
-
branchTransaction,
|
646
|
-
insertRecord,
|
647
|
-
getRecord,
|
648
|
-
insertRecordWithID,
|
649
|
-
updateRecordWithID,
|
650
|
-
upsertRecordWithID,
|
651
|
-
deleteRecord,
|
652
|
-
bulkInsertTableRecords
|
1019
|
+
applyBranchSchemaEdit,
|
1020
|
+
pushBranchMigrations
|
653
1021
|
},
|
654
1022
|
migrationRequests: {
|
655
1023
|
queryMigrationRequests,
|
@@ -673,11 +1041,34 @@ const operationsByTag$2 = {
|
|
673
1041
|
updateColumn,
|
674
1042
|
deleteColumn
|
675
1043
|
},
|
676
|
-
|
1044
|
+
records: {
|
1045
|
+
branchTransaction,
|
1046
|
+
insertRecord,
|
1047
|
+
getRecord,
|
1048
|
+
insertRecordWithID,
|
1049
|
+
updateRecordWithID,
|
1050
|
+
upsertRecordWithID,
|
1051
|
+
deleteRecord,
|
1052
|
+
bulkInsertTableRecords
|
1053
|
+
},
|
1054
|
+
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
|
1055
|
+
searchAndFilter: {
|
1056
|
+
queryTable,
|
1057
|
+
searchBranch,
|
1058
|
+
searchTable,
|
1059
|
+
vectorSearchTable,
|
1060
|
+
askTable,
|
1061
|
+
askTableSession,
|
1062
|
+
summarizeTable,
|
1063
|
+
aggregateTable
|
1064
|
+
},
|
1065
|
+
sql: { sqlQuery }
|
677
1066
|
};
|
678
1067
|
|
679
1068
|
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
680
1069
|
|
1070
|
+
const getAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "get", ...variables, signal });
|
1071
|
+
const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
|
681
1072
|
const getUser = (variables, signal) => controlPlaneFetch({
|
682
1073
|
url: "/user",
|
683
1074
|
method: "get",
|
@@ -714,6 +1105,31 @@ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
|
714
1105
|
...variables,
|
715
1106
|
signal
|
716
1107
|
});
|
1108
|
+
const getUserOAuthClients = (variables, signal) => controlPlaneFetch({
|
1109
|
+
url: "/user/oauth/clients",
|
1110
|
+
method: "get",
|
1111
|
+
...variables,
|
1112
|
+
signal
|
1113
|
+
});
|
1114
|
+
const deleteUserOAuthClient = (variables, signal) => controlPlaneFetch({
|
1115
|
+
url: "/user/oauth/clients/{clientId}",
|
1116
|
+
method: "delete",
|
1117
|
+
...variables,
|
1118
|
+
signal
|
1119
|
+
});
|
1120
|
+
const getUserOAuthAccessTokens = (variables, signal) => controlPlaneFetch({
|
1121
|
+
url: "/user/oauth/tokens",
|
1122
|
+
method: "get",
|
1123
|
+
...variables,
|
1124
|
+
signal
|
1125
|
+
});
|
1126
|
+
const deleteOAuthAccessToken = (variables, signal) => controlPlaneFetch({
|
1127
|
+
url: "/user/oauth/tokens/{token}",
|
1128
|
+
method: "delete",
|
1129
|
+
...variables,
|
1130
|
+
signal
|
1131
|
+
});
|
1132
|
+
const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({ url: "/user/oauth/tokens/{token}", method: "patch", ...variables, signal });
|
717
1133
|
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
718
1134
|
url: "/workspaces",
|
719
1135
|
method: "get",
|
@@ -772,6 +1188,10 @@ const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
|
772
1188
|
});
|
773
1189
|
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
774
1190
|
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
1191
|
+
const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
|
1192
|
+
const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
|
1193
|
+
const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
|
1194
|
+
const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
|
775
1195
|
const listRegions = (variables, signal) => controlPlaneFetch({
|
776
1196
|
url: "/workspaces/{workspaceId}/regions",
|
777
1197
|
method: "get",
|
@@ -779,6 +1199,15 @@ const listRegions = (variables, signal) => controlPlaneFetch({
|
|
779
1199
|
signal
|
780
1200
|
});
|
781
1201
|
const operationsByTag$1 = {
|
1202
|
+
oAuth: {
|
1203
|
+
getAuthorizationCode,
|
1204
|
+
grantAuthorizationCode,
|
1205
|
+
getUserOAuthClients,
|
1206
|
+
deleteUserOAuthClient,
|
1207
|
+
getUserOAuthAccessTokens,
|
1208
|
+
deleteOAuthAccessToken,
|
1209
|
+
updateOAuthAccessToken
|
1210
|
+
},
|
782
1211
|
users: { getUser, updateUser, deleteUser },
|
783
1212
|
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
784
1213
|
workspaces: {
|
@@ -804,6 +1233,10 @@ const operationsByTag$1 = {
|
|
804
1233
|
deleteDatabase,
|
805
1234
|
getDatabaseMetadata,
|
806
1235
|
updateDatabaseMetadata,
|
1236
|
+
renameDatabase,
|
1237
|
+
getDatabaseGithubSettings,
|
1238
|
+
updateDatabaseGithubSettings,
|
1239
|
+
deleteDatabaseGithubSettings,
|
807
1240
|
listRegions
|
808
1241
|
}
|
809
1242
|
};
|
@@ -824,8 +1257,12 @@ const providers = {
|
|
824
1257
|
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
825
1258
|
},
|
826
1259
|
staging: {
|
827
|
-
main: "https://staging.
|
828
|
-
workspaces: "https://{workspaceId}.
|
1260
|
+
main: "https://api.staging-xata.dev",
|
1261
|
+
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
1262
|
+
},
|
1263
|
+
dev: {
|
1264
|
+
main: "https://api.dev-xata.dev",
|
1265
|
+
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
829
1266
|
}
|
830
1267
|
};
|
831
1268
|
function isHostProviderAlias(alias) {
|
@@ -843,12 +1280,19 @@ function parseProviderString(provider = "production") {
|
|
843
1280
|
return null;
|
844
1281
|
return { main, workspaces };
|
845
1282
|
}
|
1283
|
+
function buildProviderString(provider) {
|
1284
|
+
if (isHostProviderAlias(provider))
|
1285
|
+
return provider;
|
1286
|
+
return `${provider.main},${provider.workspaces}`;
|
1287
|
+
}
|
846
1288
|
function parseWorkspacesUrlParts(url) {
|
847
1289
|
if (!isString(url))
|
848
1290
|
return null;
|
849
1291
|
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
850
|
-
const
|
851
|
-
const
|
1292
|
+
const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
|
1293
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
|
1294
|
+
const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
|
1295
|
+
const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
|
852
1296
|
if (!match)
|
853
1297
|
return null;
|
854
1298
|
return { workspace: match[1], region: match[2] };
|
@@ -887,10 +1331,11 @@ class XataApiClient {
|
|
887
1331
|
__privateSet$7(this, _extraProps, {
|
888
1332
|
apiUrl: getHostUrl(provider, "main"),
|
889
1333
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
890
|
-
|
1334
|
+
fetch: getFetchImplementation(options.fetch),
|
891
1335
|
apiKey,
|
892
1336
|
trace,
|
893
1337
|
clientName: options.clientName,
|
1338
|
+
xataAgentExtra: options.xataAgentExtra,
|
894
1339
|
clientID
|
895
1340
|
});
|
896
1341
|
}
|
@@ -944,6 +1389,11 @@ class XataApiClient {
|
|
944
1389
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
945
1390
|
return __privateGet$7(this, _namespaces).records;
|
946
1391
|
}
|
1392
|
+
get files() {
|
1393
|
+
if (!__privateGet$7(this, _namespaces).files)
|
1394
|
+
__privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
|
1395
|
+
return __privateGet$7(this, _namespaces).files;
|
1396
|
+
}
|
947
1397
|
get searchAndFilter() {
|
948
1398
|
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
949
1399
|
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
@@ -1152,6 +1602,20 @@ class BranchApi {
|
|
1152
1602
|
...this.extraProps
|
1153
1603
|
});
|
1154
1604
|
}
|
1605
|
+
copyBranch({
|
1606
|
+
workspace,
|
1607
|
+
region,
|
1608
|
+
database,
|
1609
|
+
branch,
|
1610
|
+
destinationBranch,
|
1611
|
+
limit
|
1612
|
+
}) {
|
1613
|
+
return operationsByTag.branch.copyBranch({
|
1614
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1615
|
+
body: { destinationBranch, limit },
|
1616
|
+
...this.extraProps
|
1617
|
+
});
|
1618
|
+
}
|
1155
1619
|
updateBranchMetadata({
|
1156
1620
|
workspace,
|
1157
1621
|
region,
|
@@ -1507,82 +1971,287 @@ class RecordsApi {
|
|
1507
1971
|
});
|
1508
1972
|
}
|
1509
1973
|
}
|
1510
|
-
class
|
1974
|
+
class FilesApi {
|
1511
1975
|
constructor(extraProps) {
|
1512
1976
|
this.extraProps = extraProps;
|
1513
1977
|
}
|
1514
|
-
|
1978
|
+
getFileItem({
|
1515
1979
|
workspace,
|
1516
1980
|
region,
|
1517
1981
|
database,
|
1518
1982
|
branch,
|
1519
1983
|
table,
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
columns,
|
1524
|
-
consistency
|
1984
|
+
record,
|
1985
|
+
column,
|
1986
|
+
fileId
|
1525
1987
|
}) {
|
1526
|
-
return operationsByTag.
|
1527
|
-
pathParams: {
|
1528
|
-
|
1988
|
+
return operationsByTag.files.getFileItem({
|
1989
|
+
pathParams: {
|
1990
|
+
workspace,
|
1991
|
+
region,
|
1992
|
+
dbBranchName: `${database}:${branch}`,
|
1993
|
+
tableName: table,
|
1994
|
+
recordId: record,
|
1995
|
+
columnName: column,
|
1996
|
+
fileId
|
1997
|
+
},
|
1529
1998
|
...this.extraProps
|
1530
1999
|
});
|
1531
2000
|
}
|
1532
|
-
|
2001
|
+
putFileItem({
|
1533
2002
|
workspace,
|
1534
2003
|
region,
|
1535
2004
|
database,
|
1536
2005
|
branch,
|
1537
2006
|
table,
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
filter,
|
1543
|
-
highlight,
|
1544
|
-
boosters
|
2007
|
+
record,
|
2008
|
+
column,
|
2009
|
+
fileId,
|
2010
|
+
file
|
1545
2011
|
}) {
|
1546
|
-
return operationsByTag.
|
1547
|
-
pathParams: {
|
1548
|
-
|
2012
|
+
return operationsByTag.files.putFileItem({
|
2013
|
+
pathParams: {
|
2014
|
+
workspace,
|
2015
|
+
region,
|
2016
|
+
dbBranchName: `${database}:${branch}`,
|
2017
|
+
tableName: table,
|
2018
|
+
recordId: record,
|
2019
|
+
columnName: column,
|
2020
|
+
fileId
|
2021
|
+
},
|
2022
|
+
// @ts-ignore
|
2023
|
+
body: file,
|
1549
2024
|
...this.extraProps
|
1550
2025
|
});
|
1551
2026
|
}
|
1552
|
-
|
2027
|
+
deleteFileItem({
|
1553
2028
|
workspace,
|
1554
2029
|
region,
|
1555
2030
|
database,
|
1556
2031
|
branch,
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
highlight
|
2032
|
+
table,
|
2033
|
+
record,
|
2034
|
+
column,
|
2035
|
+
fileId
|
1562
2036
|
}) {
|
1563
|
-
return operationsByTag.
|
1564
|
-
pathParams: {
|
1565
|
-
|
2037
|
+
return operationsByTag.files.deleteFileItem({
|
2038
|
+
pathParams: {
|
2039
|
+
workspace,
|
2040
|
+
region,
|
2041
|
+
dbBranchName: `${database}:${branch}`,
|
2042
|
+
tableName: table,
|
2043
|
+
recordId: record,
|
2044
|
+
columnName: column,
|
2045
|
+
fileId
|
2046
|
+
},
|
1566
2047
|
...this.extraProps
|
1567
2048
|
});
|
1568
2049
|
}
|
1569
|
-
|
2050
|
+
getFile({
|
1570
2051
|
workspace,
|
1571
2052
|
region,
|
1572
2053
|
database,
|
1573
2054
|
branch,
|
1574
2055
|
table,
|
1575
|
-
|
1576
|
-
|
1577
|
-
summaries,
|
1578
|
-
sort,
|
1579
|
-
summariesFilter,
|
1580
|
-
page,
|
1581
|
-
consistency
|
2056
|
+
record,
|
2057
|
+
column
|
1582
2058
|
}) {
|
1583
|
-
return operationsByTag.
|
1584
|
-
pathParams: {
|
1585
|
-
|
2059
|
+
return operationsByTag.files.getFile({
|
2060
|
+
pathParams: {
|
2061
|
+
workspace,
|
2062
|
+
region,
|
2063
|
+
dbBranchName: `${database}:${branch}`,
|
2064
|
+
tableName: table,
|
2065
|
+
recordId: record,
|
2066
|
+
columnName: column
|
2067
|
+
},
|
2068
|
+
...this.extraProps
|
2069
|
+
});
|
2070
|
+
}
|
2071
|
+
putFile({
|
2072
|
+
workspace,
|
2073
|
+
region,
|
2074
|
+
database,
|
2075
|
+
branch,
|
2076
|
+
table,
|
2077
|
+
record,
|
2078
|
+
column,
|
2079
|
+
file
|
2080
|
+
}) {
|
2081
|
+
return operationsByTag.files.putFile({
|
2082
|
+
pathParams: {
|
2083
|
+
workspace,
|
2084
|
+
region,
|
2085
|
+
dbBranchName: `${database}:${branch}`,
|
2086
|
+
tableName: table,
|
2087
|
+
recordId: record,
|
2088
|
+
columnName: column
|
2089
|
+
},
|
2090
|
+
body: file,
|
2091
|
+
...this.extraProps
|
2092
|
+
});
|
2093
|
+
}
|
2094
|
+
deleteFile({
|
2095
|
+
workspace,
|
2096
|
+
region,
|
2097
|
+
database,
|
2098
|
+
branch,
|
2099
|
+
table,
|
2100
|
+
record,
|
2101
|
+
column
|
2102
|
+
}) {
|
2103
|
+
return operationsByTag.files.deleteFile({
|
2104
|
+
pathParams: {
|
2105
|
+
workspace,
|
2106
|
+
region,
|
2107
|
+
dbBranchName: `${database}:${branch}`,
|
2108
|
+
tableName: table,
|
2109
|
+
recordId: record,
|
2110
|
+
columnName: column
|
2111
|
+
},
|
2112
|
+
...this.extraProps
|
2113
|
+
});
|
2114
|
+
}
|
2115
|
+
fileAccess({
|
2116
|
+
workspace,
|
2117
|
+
region,
|
2118
|
+
fileId,
|
2119
|
+
verify
|
2120
|
+
}) {
|
2121
|
+
return operationsByTag.files.fileAccess({
|
2122
|
+
pathParams: {
|
2123
|
+
workspace,
|
2124
|
+
region,
|
2125
|
+
fileId
|
2126
|
+
},
|
2127
|
+
queryParams: { verify },
|
2128
|
+
...this.extraProps
|
2129
|
+
});
|
2130
|
+
}
|
2131
|
+
}
|
2132
|
+
class SearchAndFilterApi {
|
2133
|
+
constructor(extraProps) {
|
2134
|
+
this.extraProps = extraProps;
|
2135
|
+
}
|
2136
|
+
queryTable({
|
2137
|
+
workspace,
|
2138
|
+
region,
|
2139
|
+
database,
|
2140
|
+
branch,
|
2141
|
+
table,
|
2142
|
+
filter,
|
2143
|
+
sort,
|
2144
|
+
page,
|
2145
|
+
columns,
|
2146
|
+
consistency
|
2147
|
+
}) {
|
2148
|
+
return operationsByTag.searchAndFilter.queryTable({
|
2149
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2150
|
+
body: { filter, sort, page, columns, consistency },
|
2151
|
+
...this.extraProps
|
2152
|
+
});
|
2153
|
+
}
|
2154
|
+
searchTable({
|
2155
|
+
workspace,
|
2156
|
+
region,
|
2157
|
+
database,
|
2158
|
+
branch,
|
2159
|
+
table,
|
2160
|
+
query,
|
2161
|
+
fuzziness,
|
2162
|
+
target,
|
2163
|
+
prefix,
|
2164
|
+
filter,
|
2165
|
+
highlight,
|
2166
|
+
boosters
|
2167
|
+
}) {
|
2168
|
+
return operationsByTag.searchAndFilter.searchTable({
|
2169
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2170
|
+
body: { query, fuzziness, target, prefix, filter, highlight, boosters },
|
2171
|
+
...this.extraProps
|
2172
|
+
});
|
2173
|
+
}
|
2174
|
+
searchBranch({
|
2175
|
+
workspace,
|
2176
|
+
region,
|
2177
|
+
database,
|
2178
|
+
branch,
|
2179
|
+
tables,
|
2180
|
+
query,
|
2181
|
+
fuzziness,
|
2182
|
+
prefix,
|
2183
|
+
highlight
|
2184
|
+
}) {
|
2185
|
+
return operationsByTag.searchAndFilter.searchBranch({
|
2186
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2187
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
2188
|
+
...this.extraProps
|
2189
|
+
});
|
2190
|
+
}
|
2191
|
+
vectorSearchTable({
|
2192
|
+
workspace,
|
2193
|
+
region,
|
2194
|
+
database,
|
2195
|
+
branch,
|
2196
|
+
table,
|
2197
|
+
queryVector,
|
2198
|
+
column,
|
2199
|
+
similarityFunction,
|
2200
|
+
size,
|
2201
|
+
filter
|
2202
|
+
}) {
|
2203
|
+
return operationsByTag.searchAndFilter.vectorSearchTable({
|
2204
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2205
|
+
body: { queryVector, column, similarityFunction, size, filter },
|
2206
|
+
...this.extraProps
|
2207
|
+
});
|
2208
|
+
}
|
2209
|
+
askTable({
|
2210
|
+
workspace,
|
2211
|
+
region,
|
2212
|
+
database,
|
2213
|
+
branch,
|
2214
|
+
table,
|
2215
|
+
options
|
2216
|
+
}) {
|
2217
|
+
return operationsByTag.searchAndFilter.askTable({
|
2218
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2219
|
+
body: { ...options },
|
2220
|
+
...this.extraProps
|
2221
|
+
});
|
2222
|
+
}
|
2223
|
+
askTableSession({
|
2224
|
+
workspace,
|
2225
|
+
region,
|
2226
|
+
database,
|
2227
|
+
branch,
|
2228
|
+
table,
|
2229
|
+
sessionId,
|
2230
|
+
message
|
2231
|
+
}) {
|
2232
|
+
return operationsByTag.searchAndFilter.askTableSession({
|
2233
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
|
2234
|
+
body: { message },
|
2235
|
+
...this.extraProps
|
2236
|
+
});
|
2237
|
+
}
|
2238
|
+
summarizeTable({
|
2239
|
+
workspace,
|
2240
|
+
region,
|
2241
|
+
database,
|
2242
|
+
branch,
|
2243
|
+
table,
|
2244
|
+
filter,
|
2245
|
+
columns,
|
2246
|
+
summaries,
|
2247
|
+
sort,
|
2248
|
+
summariesFilter,
|
2249
|
+
page,
|
2250
|
+
consistency
|
2251
|
+
}) {
|
2252
|
+
return operationsByTag.searchAndFilter.summarizeTable({
|
2253
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2254
|
+
body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
|
1586
2255
|
...this.extraProps
|
1587
2256
|
});
|
1588
2257
|
}
|
@@ -1766,11 +2435,13 @@ class MigrationsApi {
|
|
1766
2435
|
region,
|
1767
2436
|
database,
|
1768
2437
|
branch,
|
1769
|
-
schema
|
2438
|
+
schema,
|
2439
|
+
schemaOperations,
|
2440
|
+
branchOperations
|
1770
2441
|
}) {
|
1771
2442
|
return operationsByTag.migrations.compareBranchWithUserSchema({
|
1772
2443
|
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1773
|
-
body: { schema },
|
2444
|
+
body: { schema, schemaOperations, branchOperations },
|
1774
2445
|
...this.extraProps
|
1775
2446
|
});
|
1776
2447
|
}
|
@@ -1780,11 +2451,12 @@ class MigrationsApi {
|
|
1780
2451
|
database,
|
1781
2452
|
branch,
|
1782
2453
|
compare,
|
1783
|
-
|
2454
|
+
sourceBranchOperations,
|
2455
|
+
targetBranchOperations
|
1784
2456
|
}) {
|
1785
2457
|
return operationsByTag.migrations.compareBranchSchemas({
|
1786
2458
|
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
1787
|
-
body: {
|
2459
|
+
body: { sourceBranchOperations, targetBranchOperations },
|
1788
2460
|
...this.extraProps
|
1789
2461
|
});
|
1790
2462
|
}
|
@@ -1827,6 +2499,19 @@ class MigrationsApi {
|
|
1827
2499
|
...this.extraProps
|
1828
2500
|
});
|
1829
2501
|
}
|
2502
|
+
pushBranchMigrations({
|
2503
|
+
workspace,
|
2504
|
+
region,
|
2505
|
+
database,
|
2506
|
+
branch,
|
2507
|
+
migrations
|
2508
|
+
}) {
|
2509
|
+
return operationsByTag.migrations.pushBranchMigrations({
|
2510
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2511
|
+
body: { migrations },
|
2512
|
+
...this.extraProps
|
2513
|
+
});
|
2514
|
+
}
|
1830
2515
|
}
|
1831
2516
|
class DatabaseApi {
|
1832
2517
|
constructor(extraProps) {
|
@@ -1841,11 +2526,13 @@ class DatabaseApi {
|
|
1841
2526
|
createDatabase({
|
1842
2527
|
workspace,
|
1843
2528
|
database,
|
1844
|
-
data
|
2529
|
+
data,
|
2530
|
+
headers
|
1845
2531
|
}) {
|
1846
2532
|
return operationsByTag.databases.createDatabase({
|
1847
2533
|
pathParams: { workspaceId: workspace, dbName: database },
|
1848
2534
|
body: data,
|
2535
|
+
headers,
|
1849
2536
|
...this.extraProps
|
1850
2537
|
});
|
1851
2538
|
}
|
@@ -1878,6 +2565,46 @@ class DatabaseApi {
|
|
1878
2565
|
...this.extraProps
|
1879
2566
|
});
|
1880
2567
|
}
|
2568
|
+
renameDatabase({
|
2569
|
+
workspace,
|
2570
|
+
database,
|
2571
|
+
newName
|
2572
|
+
}) {
|
2573
|
+
return operationsByTag.databases.renameDatabase({
|
2574
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2575
|
+
body: { newName },
|
2576
|
+
...this.extraProps
|
2577
|
+
});
|
2578
|
+
}
|
2579
|
+
getDatabaseGithubSettings({
|
2580
|
+
workspace,
|
2581
|
+
database
|
2582
|
+
}) {
|
2583
|
+
return operationsByTag.databases.getDatabaseGithubSettings({
|
2584
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2585
|
+
...this.extraProps
|
2586
|
+
});
|
2587
|
+
}
|
2588
|
+
updateDatabaseGithubSettings({
|
2589
|
+
workspace,
|
2590
|
+
database,
|
2591
|
+
settings
|
2592
|
+
}) {
|
2593
|
+
return operationsByTag.databases.updateDatabaseGithubSettings({
|
2594
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2595
|
+
body: settings,
|
2596
|
+
...this.extraProps
|
2597
|
+
});
|
2598
|
+
}
|
2599
|
+
deleteDatabaseGithubSettings({
|
2600
|
+
workspace,
|
2601
|
+
database
|
2602
|
+
}) {
|
2603
|
+
return operationsByTag.databases.deleteDatabaseGithubSettings({
|
2604
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2605
|
+
...this.extraProps
|
2606
|
+
});
|
2607
|
+
}
|
1881
2608
|
listRegions({ workspace }) {
|
1882
2609
|
return operationsByTag.databases.listRegions({
|
1883
2610
|
pathParams: { workspaceId: workspace },
|
@@ -1887,22 +2614,327 @@ class DatabaseApi {
|
|
1887
2614
|
}
|
1888
2615
|
|
1889
2616
|
class XataApiPlugin {
|
1890
|
-
|
1891
|
-
|
1892
|
-
return new XataApiClient({ fetch: fetchImpl, apiKey });
|
2617
|
+
build(options) {
|
2618
|
+
return new XataApiClient(options);
|
1893
2619
|
}
|
1894
2620
|
}
|
1895
2621
|
|
1896
2622
|
class XataPlugin {
|
1897
2623
|
}
|
1898
2624
|
|
2625
|
+
class FilesPlugin extends XataPlugin {
|
2626
|
+
build(pluginOptions) {
|
2627
|
+
return {
|
2628
|
+
download: async (location) => {
|
2629
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
2630
|
+
return await getFileItem({
|
2631
|
+
pathParams: {
|
2632
|
+
workspace: "{workspaceId}",
|
2633
|
+
dbBranchName: "{dbBranch}",
|
2634
|
+
region: "{region}",
|
2635
|
+
tableName: table ?? "",
|
2636
|
+
recordId: record ?? "",
|
2637
|
+
columnName: column ?? "",
|
2638
|
+
fileId
|
2639
|
+
},
|
2640
|
+
...pluginOptions,
|
2641
|
+
rawResponse: true
|
2642
|
+
});
|
2643
|
+
},
|
2644
|
+
upload: async (location, file) => {
|
2645
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
2646
|
+
const contentType = getContentType(file);
|
2647
|
+
return await putFileItem({
|
2648
|
+
...pluginOptions,
|
2649
|
+
pathParams: {
|
2650
|
+
workspace: "{workspaceId}",
|
2651
|
+
dbBranchName: "{dbBranch}",
|
2652
|
+
region: "{region}",
|
2653
|
+
tableName: table ?? "",
|
2654
|
+
recordId: record ?? "",
|
2655
|
+
columnName: column ?? "",
|
2656
|
+
fileId
|
2657
|
+
},
|
2658
|
+
body: file,
|
2659
|
+
headers: { "Content-Type": contentType }
|
2660
|
+
});
|
2661
|
+
},
|
2662
|
+
delete: async (location) => {
|
2663
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
2664
|
+
return await deleteFileItem({
|
2665
|
+
pathParams: {
|
2666
|
+
workspace: "{workspaceId}",
|
2667
|
+
dbBranchName: "{dbBranch}",
|
2668
|
+
region: "{region}",
|
2669
|
+
tableName: table ?? "",
|
2670
|
+
recordId: record ?? "",
|
2671
|
+
columnName: column ?? "",
|
2672
|
+
fileId
|
2673
|
+
},
|
2674
|
+
...pluginOptions
|
2675
|
+
});
|
2676
|
+
}
|
2677
|
+
};
|
2678
|
+
}
|
2679
|
+
}
|
2680
|
+
function getContentType(file) {
|
2681
|
+
if (typeof file === "string") {
|
2682
|
+
return "text/plain";
|
2683
|
+
}
|
2684
|
+
if (isBlob(file)) {
|
2685
|
+
return file.type;
|
2686
|
+
}
|
2687
|
+
try {
|
2688
|
+
return file.type;
|
2689
|
+
} catch (e) {
|
2690
|
+
}
|
2691
|
+
return "application/octet-stream";
|
2692
|
+
}
|
2693
|
+
|
2694
|
+
function buildTransformString(transformations) {
|
2695
|
+
return transformations.flatMap(
|
2696
|
+
(t) => Object.entries(t).map(([key, value]) => {
|
2697
|
+
if (key === "trim") {
|
2698
|
+
const { left = 0, top = 0, right = 0, bottom = 0 } = value;
|
2699
|
+
return `${key}=${[top, right, bottom, left].join(";")}`;
|
2700
|
+
}
|
2701
|
+
if (key === "gravity" && typeof value === "object") {
|
2702
|
+
const { x = 0.5, y = 0.5 } = value;
|
2703
|
+
return `${key}=${[x, y].join("x")}`;
|
2704
|
+
}
|
2705
|
+
return `${key}=${value}`;
|
2706
|
+
})
|
2707
|
+
).join(",");
|
2708
|
+
}
|
2709
|
+
function transformImage(url, ...transformations) {
|
2710
|
+
if (!isDefined(url))
|
2711
|
+
return void 0;
|
2712
|
+
const newTransformations = buildTransformString(transformations);
|
2713
|
+
const { hostname, pathname, search } = new URL(url);
|
2714
|
+
const pathParts = pathname.split("/");
|
2715
|
+
const transformIndex = pathParts.findIndex((part) => part === "transform");
|
2716
|
+
const removedItems = transformIndex >= 0 ? pathParts.splice(transformIndex, 2) : [];
|
2717
|
+
const transform = `/transform/${[removedItems[1], newTransformations].filter(isDefined).join(",")}`;
|
2718
|
+
const path = pathParts.join("/");
|
2719
|
+
return `https://${hostname}${transform}${path}${search}`;
|
2720
|
+
}
|
2721
|
+
|
2722
|
+
var __defProp$6 = Object.defineProperty;
|
2723
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2724
|
+
var __publicField$6 = (obj, key, value) => {
|
2725
|
+
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2726
|
+
return value;
|
2727
|
+
};
|
2728
|
+
class XataFile {
|
2729
|
+
constructor(file) {
|
2730
|
+
/**
|
2731
|
+
* Identifier of the file.
|
2732
|
+
*/
|
2733
|
+
__publicField$6(this, "id");
|
2734
|
+
/**
|
2735
|
+
* Name of the file.
|
2736
|
+
*/
|
2737
|
+
__publicField$6(this, "name");
|
2738
|
+
/**
|
2739
|
+
* Media type of the file.
|
2740
|
+
*/
|
2741
|
+
__publicField$6(this, "mediaType");
|
2742
|
+
/**
|
2743
|
+
* Base64 encoded content of the file.
|
2744
|
+
*/
|
2745
|
+
__publicField$6(this, "base64Content");
|
2746
|
+
/**
|
2747
|
+
* Whether to enable public url for the file.
|
2748
|
+
*/
|
2749
|
+
__publicField$6(this, "enablePublicUrl");
|
2750
|
+
/**
|
2751
|
+
* Timeout for the signed url.
|
2752
|
+
*/
|
2753
|
+
__publicField$6(this, "signedUrlTimeout");
|
2754
|
+
/**
|
2755
|
+
* Size of the file.
|
2756
|
+
*/
|
2757
|
+
__publicField$6(this, "size");
|
2758
|
+
/**
|
2759
|
+
* Version of the file.
|
2760
|
+
*/
|
2761
|
+
__publicField$6(this, "version");
|
2762
|
+
/**
|
2763
|
+
* Url of the file.
|
2764
|
+
*/
|
2765
|
+
__publicField$6(this, "url");
|
2766
|
+
/**
|
2767
|
+
* Signed url of the file.
|
2768
|
+
*/
|
2769
|
+
__publicField$6(this, "signedUrl");
|
2770
|
+
/**
|
2771
|
+
* Attributes of the file.
|
2772
|
+
*/
|
2773
|
+
__publicField$6(this, "attributes");
|
2774
|
+
this.id = file.id;
|
2775
|
+
this.name = file.name || "";
|
2776
|
+
this.mediaType = file.mediaType || "application/octet-stream";
|
2777
|
+
this.base64Content = file.base64Content;
|
2778
|
+
this.enablePublicUrl = file.enablePublicUrl ?? false;
|
2779
|
+
this.signedUrlTimeout = file.signedUrlTimeout ?? 300;
|
2780
|
+
this.size = file.size ?? 0;
|
2781
|
+
this.version = file.version ?? 1;
|
2782
|
+
this.url = file.url || "";
|
2783
|
+
this.signedUrl = file.signedUrl;
|
2784
|
+
this.attributes = file.attributes || {};
|
2785
|
+
}
|
2786
|
+
static fromBuffer(buffer, options = {}) {
|
2787
|
+
const base64Content = buffer.toString("base64");
|
2788
|
+
return new XataFile({ ...options, base64Content });
|
2789
|
+
}
|
2790
|
+
toBuffer() {
|
2791
|
+
if (!this.base64Content) {
|
2792
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2793
|
+
}
|
2794
|
+
return Buffer.from(this.base64Content, "base64");
|
2795
|
+
}
|
2796
|
+
static fromArrayBuffer(arrayBuffer, options = {}) {
|
2797
|
+
const uint8Array = new Uint8Array(arrayBuffer);
|
2798
|
+
return this.fromUint8Array(uint8Array, options);
|
2799
|
+
}
|
2800
|
+
toArrayBuffer() {
|
2801
|
+
if (!this.base64Content) {
|
2802
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2803
|
+
}
|
2804
|
+
const binary = atob(this.base64Content);
|
2805
|
+
return new ArrayBuffer(binary.length);
|
2806
|
+
}
|
2807
|
+
static fromUint8Array(uint8Array, options = {}) {
|
2808
|
+
let binary = "";
|
2809
|
+
for (let i = 0; i < uint8Array.byteLength; i++) {
|
2810
|
+
binary += String.fromCharCode(uint8Array[i]);
|
2811
|
+
}
|
2812
|
+
const base64Content = btoa(binary);
|
2813
|
+
return new XataFile({ ...options, base64Content });
|
2814
|
+
}
|
2815
|
+
toUint8Array() {
|
2816
|
+
if (!this.base64Content) {
|
2817
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2818
|
+
}
|
2819
|
+
const binary = atob(this.base64Content);
|
2820
|
+
const uint8Array = new Uint8Array(binary.length);
|
2821
|
+
for (let i = 0; i < binary.length; i++) {
|
2822
|
+
uint8Array[i] = binary.charCodeAt(i);
|
2823
|
+
}
|
2824
|
+
return uint8Array;
|
2825
|
+
}
|
2826
|
+
static async fromBlob(file, options = {}) {
|
2827
|
+
const name = options.name ?? file.name;
|
2828
|
+
const mediaType = file.type;
|
2829
|
+
const arrayBuffer = await file.arrayBuffer();
|
2830
|
+
return this.fromArrayBuffer(arrayBuffer, { ...options, name, mediaType });
|
2831
|
+
}
|
2832
|
+
toBlob() {
|
2833
|
+
if (!this.base64Content) {
|
2834
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2835
|
+
}
|
2836
|
+
const binary = atob(this.base64Content);
|
2837
|
+
const uint8Array = new Uint8Array(binary.length);
|
2838
|
+
for (let i = 0; i < binary.length; i++) {
|
2839
|
+
uint8Array[i] = binary.charCodeAt(i);
|
2840
|
+
}
|
2841
|
+
return new Blob([uint8Array], { type: this.mediaType });
|
2842
|
+
}
|
2843
|
+
static fromString(string, options = {}) {
|
2844
|
+
const base64Content = btoa(string);
|
2845
|
+
return new XataFile({ ...options, base64Content });
|
2846
|
+
}
|
2847
|
+
toString() {
|
2848
|
+
if (!this.base64Content) {
|
2849
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2850
|
+
}
|
2851
|
+
return atob(this.base64Content);
|
2852
|
+
}
|
2853
|
+
static fromBase64(base64Content, options = {}) {
|
2854
|
+
return new XataFile({ ...options, base64Content });
|
2855
|
+
}
|
2856
|
+
toBase64() {
|
2857
|
+
if (!this.base64Content) {
|
2858
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2859
|
+
}
|
2860
|
+
return this.base64Content;
|
2861
|
+
}
|
2862
|
+
transform(...options) {
|
2863
|
+
return {
|
2864
|
+
url: transformImage(this.url, ...options),
|
2865
|
+
signedUrl: transformImage(this.signedUrl, ...options),
|
2866
|
+
metadataUrl: transformImage(this.url, ...options, { format: "json" }),
|
2867
|
+
metadataSignedUrl: transformImage(this.signedUrl, ...options, { format: "json" })
|
2868
|
+
};
|
2869
|
+
}
|
2870
|
+
}
|
2871
|
+
const parseInputFileEntry = async (entry) => {
|
2872
|
+
if (!isDefined(entry))
|
2873
|
+
return null;
|
2874
|
+
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
|
2875
|
+
return compactObject({
|
2876
|
+
id,
|
2877
|
+
// Name cannot be an empty string in our API
|
2878
|
+
name: name ? name : void 0,
|
2879
|
+
mediaType,
|
2880
|
+
base64Content,
|
2881
|
+
enablePublicUrl,
|
2882
|
+
signedUrlTimeout
|
2883
|
+
});
|
2884
|
+
};
|
2885
|
+
|
1899
2886
|
function cleanFilter(filter) {
|
1900
|
-
if (!filter)
|
2887
|
+
if (!isDefined(filter))
|
1901
2888
|
return void 0;
|
1902
|
-
|
1903
|
-
|
2889
|
+
if (!isObject(filter))
|
2890
|
+
return filter;
|
2891
|
+
const values = Object.fromEntries(
|
2892
|
+
Object.entries(filter).reduce((acc, [key, value]) => {
|
2893
|
+
if (!isDefined(value))
|
2894
|
+
return acc;
|
2895
|
+
if (Array.isArray(value)) {
|
2896
|
+
const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
|
2897
|
+
if (clean.length === 0)
|
2898
|
+
return acc;
|
2899
|
+
return [...acc, [key, clean]];
|
2900
|
+
}
|
2901
|
+
if (isObject(value)) {
|
2902
|
+
const clean = cleanFilter(value);
|
2903
|
+
if (!isDefined(clean))
|
2904
|
+
return acc;
|
2905
|
+
return [...acc, [key, clean]];
|
2906
|
+
}
|
2907
|
+
return [...acc, [key, value]];
|
2908
|
+
}, [])
|
2909
|
+
);
|
2910
|
+
return Object.keys(values).length > 0 ? values : void 0;
|
1904
2911
|
}
|
1905
2912
|
|
2913
|
+
function stringifyJson(value) {
|
2914
|
+
if (!isDefined(value))
|
2915
|
+
return value;
|
2916
|
+
if (isString(value))
|
2917
|
+
return value;
|
2918
|
+
try {
|
2919
|
+
return JSON.stringify(value);
|
2920
|
+
} catch (e) {
|
2921
|
+
return value;
|
2922
|
+
}
|
2923
|
+
}
|
2924
|
+
function parseJson(value) {
|
2925
|
+
try {
|
2926
|
+
return JSON.parse(value);
|
2927
|
+
} catch (e) {
|
2928
|
+
return value;
|
2929
|
+
}
|
2930
|
+
}
|
2931
|
+
|
2932
|
+
var __defProp$5 = Object.defineProperty;
|
2933
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2934
|
+
var __publicField$5 = (obj, key, value) => {
|
2935
|
+
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2936
|
+
return value;
|
2937
|
+
};
|
1906
2938
|
var __accessCheck$6 = (obj, member, msg) => {
|
1907
2939
|
if (!member.has(obj))
|
1908
2940
|
throw TypeError("Cannot " + msg);
|
@@ -1925,22 +2957,58 @@ var _query, _page;
|
|
1925
2957
|
class Page {
|
1926
2958
|
constructor(query, meta, records = []) {
|
1927
2959
|
__privateAdd$6(this, _query, void 0);
|
2960
|
+
/**
|
2961
|
+
* Page metadata, required to retrieve additional records.
|
2962
|
+
*/
|
2963
|
+
__publicField$5(this, "meta");
|
2964
|
+
/**
|
2965
|
+
* The set of results for this page.
|
2966
|
+
*/
|
2967
|
+
__publicField$5(this, "records");
|
1928
2968
|
__privateSet$6(this, _query, query);
|
1929
2969
|
this.meta = meta;
|
1930
2970
|
this.records = new RecordArray(this, records);
|
1931
2971
|
}
|
2972
|
+
/**
|
2973
|
+
* Retrieves the next page of results.
|
2974
|
+
* @param size Maximum number of results to be retrieved.
|
2975
|
+
* @param offset Number of results to skip when retrieving the results.
|
2976
|
+
* @returns The next page or results.
|
2977
|
+
*/
|
1932
2978
|
async nextPage(size, offset) {
|
1933
2979
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
1934
2980
|
}
|
2981
|
+
/**
|
2982
|
+
* Retrieves the previous page of results.
|
2983
|
+
* @param size Maximum number of results to be retrieved.
|
2984
|
+
* @param offset Number of results to skip when retrieving the results.
|
2985
|
+
* @returns The previous page or results.
|
2986
|
+
*/
|
1935
2987
|
async previousPage(size, offset) {
|
1936
2988
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
1937
2989
|
}
|
2990
|
+
/**
|
2991
|
+
* Retrieves the start page of results.
|
2992
|
+
* @param size Maximum number of results to be retrieved.
|
2993
|
+
* @param offset Number of results to skip when retrieving the results.
|
2994
|
+
* @returns The start page or results.
|
2995
|
+
*/
|
1938
2996
|
async startPage(size, offset) {
|
1939
2997
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
1940
2998
|
}
|
2999
|
+
/**
|
3000
|
+
* Retrieves the end page of results.
|
3001
|
+
* @param size Maximum number of results to be retrieved.
|
3002
|
+
* @param offset Number of results to skip when retrieving the results.
|
3003
|
+
* @returns The end page or results.
|
3004
|
+
*/
|
1941
3005
|
async endPage(size, offset) {
|
1942
3006
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
1943
3007
|
}
|
3008
|
+
/**
|
3009
|
+
* Shortcut method to check if there will be additional results if the next page of results is retrieved.
|
3010
|
+
* @returns Whether or not there will be additional results in the next page of results.
|
3011
|
+
*/
|
1944
3012
|
hasNextPage() {
|
1945
3013
|
return this.meta.page.more;
|
1946
3014
|
}
|
@@ -1953,7 +3021,7 @@ const PAGINATION_DEFAULT_OFFSET = 0;
|
|
1953
3021
|
function isCursorPaginationOptions(options) {
|
1954
3022
|
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
1955
3023
|
}
|
1956
|
-
const _RecordArray = class extends Array {
|
3024
|
+
const _RecordArray = class _RecordArray extends Array {
|
1957
3025
|
constructor(...args) {
|
1958
3026
|
super(..._RecordArray.parseConstructorParams(...args));
|
1959
3027
|
__privateAdd$6(this, _page, void 0);
|
@@ -1972,32 +3040,67 @@ const _RecordArray = class extends Array {
|
|
1972
3040
|
toArray() {
|
1973
3041
|
return new Array(...this);
|
1974
3042
|
}
|
3043
|
+
toSerializable() {
|
3044
|
+
return JSON.parse(this.toString());
|
3045
|
+
}
|
3046
|
+
toString() {
|
3047
|
+
return JSON.stringify(this.toArray());
|
3048
|
+
}
|
1975
3049
|
map(callbackfn, thisArg) {
|
1976
3050
|
return this.toArray().map(callbackfn, thisArg);
|
1977
3051
|
}
|
3052
|
+
/**
|
3053
|
+
* Retrieve next page of records
|
3054
|
+
*
|
3055
|
+
* @returns A new array of objects
|
3056
|
+
*/
|
1978
3057
|
async nextPage(size, offset) {
|
1979
3058
|
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
1980
3059
|
return new _RecordArray(newPage);
|
1981
3060
|
}
|
3061
|
+
/**
|
3062
|
+
* Retrieve previous page of records
|
3063
|
+
*
|
3064
|
+
* @returns A new array of objects
|
3065
|
+
*/
|
1982
3066
|
async previousPage(size, offset) {
|
1983
3067
|
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
1984
3068
|
return new _RecordArray(newPage);
|
1985
3069
|
}
|
3070
|
+
/**
|
3071
|
+
* Retrieve start page of records
|
3072
|
+
*
|
3073
|
+
* @returns A new array of objects
|
3074
|
+
*/
|
1986
3075
|
async startPage(size, offset) {
|
1987
3076
|
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
1988
3077
|
return new _RecordArray(newPage);
|
1989
3078
|
}
|
3079
|
+
/**
|
3080
|
+
* Retrieve end page of records
|
3081
|
+
*
|
3082
|
+
* @returns A new array of objects
|
3083
|
+
*/
|
1990
3084
|
async endPage(size, offset) {
|
1991
3085
|
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
1992
3086
|
return new _RecordArray(newPage);
|
1993
3087
|
}
|
3088
|
+
/**
|
3089
|
+
* @returns Boolean indicating if there is a next page
|
3090
|
+
*/
|
1994
3091
|
hasNextPage() {
|
1995
3092
|
return __privateGet$6(this, _page).meta.page.more;
|
1996
3093
|
}
|
1997
3094
|
};
|
1998
|
-
let RecordArray = _RecordArray;
|
1999
3095
|
_page = new WeakMap();
|
3096
|
+
let RecordArray = _RecordArray;
|
2000
3097
|
|
3098
|
+
var __defProp$4 = Object.defineProperty;
|
3099
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3100
|
+
var __publicField$4 = (obj, key, value) => {
|
3101
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
3102
|
+
return value;
|
3103
|
+
};
|
2001
3104
|
var __accessCheck$5 = (obj, member, msg) => {
|
2002
3105
|
if (!member.has(obj))
|
2003
3106
|
throw TypeError("Cannot " + msg);
|
@@ -2021,14 +3124,15 @@ var __privateMethod$3 = (obj, member, method) => {
|
|
2021
3124
|
return method;
|
2022
3125
|
};
|
2023
3126
|
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
2024
|
-
const _Query = class {
|
3127
|
+
const _Query = class _Query {
|
2025
3128
|
constructor(repository, table, data, rawParent) {
|
2026
3129
|
__privateAdd$5(this, _cleanFilterConstraint);
|
2027
3130
|
__privateAdd$5(this, _table$1, void 0);
|
2028
3131
|
__privateAdd$5(this, _repository, void 0);
|
2029
3132
|
__privateAdd$5(this, _data, { filter: {} });
|
2030
|
-
|
2031
|
-
this
|
3133
|
+
// Implements pagination
|
3134
|
+
__publicField$4(this, "meta", { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } });
|
3135
|
+
__publicField$4(this, "records", new RecordArray(this, []));
|
2032
3136
|
__privateSet$5(this, _table$1, table);
|
2033
3137
|
if (repository) {
|
2034
3138
|
__privateSet$5(this, _repository, repository);
|
@@ -2064,18 +3168,38 @@ const _Query = class {
|
|
2064
3168
|
const key = JSON.stringify({ columns, filter, sort, pagination });
|
2065
3169
|
return toBase64(key);
|
2066
3170
|
}
|
3171
|
+
/**
|
3172
|
+
* Builds a new query object representing a logical OR between the given subqueries.
|
3173
|
+
* @param queries An array of subqueries.
|
3174
|
+
* @returns A new Query object.
|
3175
|
+
*/
|
2067
3176
|
any(...queries) {
|
2068
3177
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2069
3178
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
2070
3179
|
}
|
3180
|
+
/**
|
3181
|
+
* Builds a new query object representing a logical AND between the given subqueries.
|
3182
|
+
* @param queries An array of subqueries.
|
3183
|
+
* @returns A new Query object.
|
3184
|
+
*/
|
2071
3185
|
all(...queries) {
|
2072
3186
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2073
3187
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
2074
3188
|
}
|
3189
|
+
/**
|
3190
|
+
* Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
|
3191
|
+
* @param queries An array of subqueries.
|
3192
|
+
* @returns A new Query object.
|
3193
|
+
*/
|
2075
3194
|
not(...queries) {
|
2076
3195
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2077
3196
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
2078
3197
|
}
|
3198
|
+
/**
|
3199
|
+
* Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
|
3200
|
+
* @param queries An array of subqueries.
|
3201
|
+
* @returns A new Query object.
|
3202
|
+
*/
|
2079
3203
|
none(...queries) {
|
2080
3204
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2081
3205
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
@@ -2098,6 +3222,11 @@ const _Query = class {
|
|
2098
3222
|
const sort = [...originalSort, { column, direction }];
|
2099
3223
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
2100
3224
|
}
|
3225
|
+
/**
|
3226
|
+
* Builds a new query specifying the set of columns to be returned in the query response.
|
3227
|
+
* @param columns Array of column names to be returned by the query.
|
3228
|
+
* @returns A new Query object.
|
3229
|
+
*/
|
2101
3230
|
select(columns) {
|
2102
3231
|
return new _Query(
|
2103
3232
|
__privateGet$5(this, _repository),
|
@@ -2110,6 +3239,12 @@ const _Query = class {
|
|
2110
3239
|
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
2111
3240
|
return __privateGet$5(this, _repository).query(query);
|
2112
3241
|
}
|
3242
|
+
/**
|
3243
|
+
* Get results in an iterator
|
3244
|
+
*
|
3245
|
+
* @async
|
3246
|
+
* @returns Async interable of results
|
3247
|
+
*/
|
2113
3248
|
async *[Symbol.asyncIterator]() {
|
2114
3249
|
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
2115
3250
|
yield record;
|
@@ -2170,26 +3305,53 @@ const _Query = class {
|
|
2170
3305
|
);
|
2171
3306
|
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
2172
3307
|
}
|
3308
|
+
/**
|
3309
|
+
* Builds a new query object adding a cache TTL in milliseconds.
|
3310
|
+
* @param ttl The cache TTL in milliseconds.
|
3311
|
+
* @returns A new Query object.
|
3312
|
+
*/
|
2173
3313
|
cache(ttl) {
|
2174
3314
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
2175
3315
|
}
|
3316
|
+
/**
|
3317
|
+
* Retrieve next page of records
|
3318
|
+
*
|
3319
|
+
* @returns A new page object.
|
3320
|
+
*/
|
2176
3321
|
nextPage(size, offset) {
|
2177
3322
|
return this.startPage(size, offset);
|
2178
3323
|
}
|
3324
|
+
/**
|
3325
|
+
* Retrieve previous page of records
|
3326
|
+
*
|
3327
|
+
* @returns A new page object
|
3328
|
+
*/
|
2179
3329
|
previousPage(size, offset) {
|
2180
3330
|
return this.startPage(size, offset);
|
2181
3331
|
}
|
3332
|
+
/**
|
3333
|
+
* Retrieve start page of records
|
3334
|
+
*
|
3335
|
+
* @returns A new page object
|
3336
|
+
*/
|
2182
3337
|
startPage(size, offset) {
|
2183
3338
|
return this.getPaginated({ pagination: { size, offset } });
|
2184
3339
|
}
|
3340
|
+
/**
|
3341
|
+
* Retrieve last page of records
|
3342
|
+
*
|
3343
|
+
* @returns A new page object
|
3344
|
+
*/
|
2185
3345
|
endPage(size, offset) {
|
2186
3346
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
2187
3347
|
}
|
3348
|
+
/**
|
3349
|
+
* @returns Boolean indicating if there is a next page
|
3350
|
+
*/
|
2188
3351
|
hasNextPage() {
|
2189
3352
|
return this.meta.page.more;
|
2190
3353
|
}
|
2191
3354
|
};
|
2192
|
-
let Query = _Query;
|
2193
3355
|
_table$1 = new WeakMap();
|
2194
3356
|
_repository = new WeakMap();
|
2195
3357
|
_data = new WeakMap();
|
@@ -2204,6 +3366,7 @@ cleanFilterConstraint_fn = function(column, value) {
|
|
2204
3366
|
}
|
2205
3367
|
return value;
|
2206
3368
|
};
|
3369
|
+
let Query = _Query;
|
2207
3370
|
function cleanParent(data, parent) {
|
2208
3371
|
if (isCursorPaginationOptions(data.pagination)) {
|
2209
3372
|
return { ...parent, sort: void 0, filter: void 0 };
|
@@ -2211,6 +3374,22 @@ function cleanParent(data, parent) {
|
|
2211
3374
|
return parent;
|
2212
3375
|
}
|
2213
3376
|
|
3377
|
+
const RecordColumnTypes = [
|
3378
|
+
"bool",
|
3379
|
+
"int",
|
3380
|
+
"float",
|
3381
|
+
"string",
|
3382
|
+
"text",
|
3383
|
+
"email",
|
3384
|
+
"multiple",
|
3385
|
+
"link",
|
3386
|
+
"object",
|
3387
|
+
"datetime",
|
3388
|
+
"vector",
|
3389
|
+
"file[]",
|
3390
|
+
"file",
|
3391
|
+
"json"
|
3392
|
+
];
|
2214
3393
|
function isIdentifiable(x) {
|
2215
3394
|
return isObject(x) && isString(x?.id);
|
2216
3395
|
}
|
@@ -2220,11 +3399,33 @@ function isXataRecord(x) {
|
|
2220
3399
|
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
2221
3400
|
}
|
2222
3401
|
|
3402
|
+
function isValidExpandedColumn(column) {
|
3403
|
+
return isObject(column) && isString(column.name);
|
3404
|
+
}
|
3405
|
+
function isValidSelectableColumns(columns) {
|
3406
|
+
if (!Array.isArray(columns)) {
|
3407
|
+
return false;
|
3408
|
+
}
|
3409
|
+
return columns.every((column) => {
|
3410
|
+
if (typeof column === "string") {
|
3411
|
+
return true;
|
3412
|
+
}
|
3413
|
+
if (typeof column === "object") {
|
3414
|
+
return isValidExpandedColumn(column);
|
3415
|
+
}
|
3416
|
+
return false;
|
3417
|
+
});
|
3418
|
+
}
|
3419
|
+
|
2223
3420
|
function isSortFilterString(value) {
|
2224
3421
|
return isString(value);
|
2225
3422
|
}
|
2226
3423
|
function isSortFilterBase(filter) {
|
2227
|
-
return isObject(filter) && Object.
|
3424
|
+
return isObject(filter) && Object.entries(filter).every(([key, value]) => {
|
3425
|
+
if (key === "*")
|
3426
|
+
return value === "random";
|
3427
|
+
return value === "asc" || value === "desc";
|
3428
|
+
});
|
2228
3429
|
}
|
2229
3430
|
function isSortFilterObject(filter) {
|
2230
3431
|
return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
|
@@ -2265,7 +3466,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
2265
3466
|
__accessCheck$4(obj, member, "access private method");
|
2266
3467
|
return method;
|
2267
3468
|
};
|
2268
|
-
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;
|
3469
|
+
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;
|
2269
3470
|
const BULK_OPERATION_MAX_SIZE = 1e3;
|
2270
3471
|
class Repository extends Query {
|
2271
3472
|
}
|
@@ -2287,6 +3488,7 @@ class RestRepository extends Query {
|
|
2287
3488
|
__privateAdd$4(this, _setCacheQuery);
|
2288
3489
|
__privateAdd$4(this, _getCacheQuery);
|
2289
3490
|
__privateAdd$4(this, _getSchemaTables$1);
|
3491
|
+
__privateAdd$4(this, _transformObjectToApi);
|
2290
3492
|
__privateAdd$4(this, _table, void 0);
|
2291
3493
|
__privateAdd$4(this, _getFetchProps, void 0);
|
2292
3494
|
__privateAdd$4(this, _db, void 0);
|
@@ -2297,10 +3499,7 @@ class RestRepository extends Query {
|
|
2297
3499
|
__privateSet$4(this, _db, options.db);
|
2298
3500
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
2299
3501
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
2300
|
-
__privateSet$4(this, _getFetchProps,
|
2301
|
-
const props = await options.pluginOptions.getFetchProps();
|
2302
|
-
return { ...props, sessionID: generateUUID() };
|
2303
|
-
});
|
3502
|
+
__privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
|
2304
3503
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
2305
3504
|
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
2306
3505
|
return trace(name, fn, {
|
@@ -2318,24 +3517,24 @@ class RestRepository extends Query {
|
|
2318
3517
|
if (a.length === 0)
|
2319
3518
|
return [];
|
2320
3519
|
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
2321
|
-
const columns =
|
3520
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2322
3521
|
const result = await this.read(ids, columns);
|
2323
3522
|
return result;
|
2324
3523
|
}
|
2325
3524
|
if (isString(a) && isObject(b)) {
|
2326
3525
|
if (a === "")
|
2327
3526
|
throw new Error("The id can't be empty");
|
2328
|
-
const columns =
|
3527
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
2329
3528
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
2330
3529
|
}
|
2331
3530
|
if (isObject(a) && isString(a.id)) {
|
2332
3531
|
if (a.id === "")
|
2333
3532
|
throw new Error("The id can't be empty");
|
2334
|
-
const columns =
|
3533
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
2335
3534
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
2336
3535
|
}
|
2337
3536
|
if (isObject(a)) {
|
2338
|
-
const columns =
|
3537
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
2339
3538
|
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
2340
3539
|
}
|
2341
3540
|
throw new Error("Invalid arguments for create method");
|
@@ -2343,7 +3542,7 @@ class RestRepository extends Query {
|
|
2343
3542
|
}
|
2344
3543
|
async read(a, b) {
|
2345
3544
|
return __privateGet$4(this, _trace).call(this, "read", async () => {
|
2346
|
-
const columns =
|
3545
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2347
3546
|
if (Array.isArray(a)) {
|
2348
3547
|
if (a.length === 0)
|
2349
3548
|
return [];
|
@@ -2357,7 +3556,6 @@ class RestRepository extends Query {
|
|
2357
3556
|
}
|
2358
3557
|
const id = extractId(a);
|
2359
3558
|
if (id) {
|
2360
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2361
3559
|
try {
|
2362
3560
|
const response = await getRecord({
|
2363
3561
|
pathParams: {
|
@@ -2368,10 +3566,16 @@ class RestRepository extends Query {
|
|
2368
3566
|
recordId: id
|
2369
3567
|
},
|
2370
3568
|
queryParams: { columns },
|
2371
|
-
...
|
3569
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2372
3570
|
});
|
2373
3571
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2374
|
-
return initObject(
|
3572
|
+
return initObject(
|
3573
|
+
__privateGet$4(this, _db),
|
3574
|
+
schemaTables,
|
3575
|
+
__privateGet$4(this, _table),
|
3576
|
+
response,
|
3577
|
+
columns
|
3578
|
+
);
|
2375
3579
|
} catch (e) {
|
2376
3580
|
if (isObject(e) && e.status === 404) {
|
2377
3581
|
return null;
|
@@ -2413,17 +3617,17 @@ class RestRepository extends Query {
|
|
2413
3617
|
ifVersion,
|
2414
3618
|
upsert: false
|
2415
3619
|
});
|
2416
|
-
const columns =
|
3620
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2417
3621
|
const result = await this.read(a, columns);
|
2418
3622
|
return result;
|
2419
3623
|
}
|
2420
3624
|
try {
|
2421
3625
|
if (isString(a) && isObject(b)) {
|
2422
|
-
const columns =
|
3626
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
2423
3627
|
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
2424
3628
|
}
|
2425
3629
|
if (isObject(a) && isString(a.id)) {
|
2426
|
-
const columns =
|
3630
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
2427
3631
|
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
2428
3632
|
}
|
2429
3633
|
} catch (error) {
|
@@ -2463,17 +3667,27 @@ class RestRepository extends Query {
|
|
2463
3667
|
ifVersion,
|
2464
3668
|
upsert: true
|
2465
3669
|
});
|
2466
|
-
const columns =
|
3670
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2467
3671
|
const result = await this.read(a, columns);
|
2468
3672
|
return result;
|
2469
3673
|
}
|
2470
3674
|
if (isString(a) && isObject(b)) {
|
2471
|
-
|
2472
|
-
|
3675
|
+
if (a === "")
|
3676
|
+
throw new Error("The id can't be empty");
|
3677
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3678
|
+
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
2473
3679
|
}
|
2474
3680
|
if (isObject(a) && isString(a.id)) {
|
2475
|
-
|
2476
|
-
|
3681
|
+
if (a.id === "")
|
3682
|
+
throw new Error("The id can't be empty");
|
3683
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3684
|
+
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3685
|
+
}
|
3686
|
+
if (!isDefined(a) && isObject(b)) {
|
3687
|
+
return await this.create(b, c);
|
3688
|
+
}
|
3689
|
+
if (isObject(a) && !isDefined(a.id)) {
|
3690
|
+
return await this.create(a, b);
|
2477
3691
|
}
|
2478
3692
|
throw new Error("Invalid arguments for createOrUpdate method");
|
2479
3693
|
});
|
@@ -2485,17 +3699,27 @@ class RestRepository extends Query {
|
|
2485
3699
|
if (a.length === 0)
|
2486
3700
|
return [];
|
2487
3701
|
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
2488
|
-
const columns =
|
3702
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2489
3703
|
const result = await this.read(ids, columns);
|
2490
3704
|
return result;
|
2491
3705
|
}
|
2492
3706
|
if (isString(a) && isObject(b)) {
|
2493
|
-
|
2494
|
-
|
3707
|
+
if (a === "")
|
3708
|
+
throw new Error("The id can't be empty");
|
3709
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3710
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
2495
3711
|
}
|
2496
3712
|
if (isObject(a) && isString(a.id)) {
|
2497
|
-
|
2498
|
-
|
3713
|
+
if (a.id === "")
|
3714
|
+
throw new Error("The id can't be empty");
|
3715
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3716
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
3717
|
+
}
|
3718
|
+
if (!isDefined(a) && isObject(b)) {
|
3719
|
+
return await this.create(b, c);
|
3720
|
+
}
|
3721
|
+
if (isObject(a) && !isDefined(a.id)) {
|
3722
|
+
return await this.create(a, b);
|
2499
3723
|
}
|
2500
3724
|
throw new Error("Invalid arguments for createOrReplace method");
|
2501
3725
|
});
|
@@ -2512,7 +3736,7 @@ class RestRepository extends Query {
|
|
2512
3736
|
return o.id;
|
2513
3737
|
throw new Error("Invalid arguments for delete method");
|
2514
3738
|
});
|
2515
|
-
const columns =
|
3739
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2516
3740
|
const result = await this.read(a, columns);
|
2517
3741
|
await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
|
2518
3742
|
return result;
|
@@ -2546,7 +3770,6 @@ class RestRepository extends Query {
|
|
2546
3770
|
}
|
2547
3771
|
async search(query, options = {}) {
|
2548
3772
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
2549
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2550
3773
|
const { records } = await searchTable({
|
2551
3774
|
pathParams: {
|
2552
3775
|
workspace: "{workspaceId}",
|
@@ -2564,7 +3787,29 @@ class RestRepository extends Query {
|
|
2564
3787
|
page: options.page,
|
2565
3788
|
target: options.target
|
2566
3789
|
},
|
2567
|
-
...
|
3790
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3791
|
+
});
|
3792
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3793
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
3794
|
+
});
|
3795
|
+
}
|
3796
|
+
async vectorSearch(column, query, options) {
|
3797
|
+
return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
|
3798
|
+
const { records } = await vectorSearchTable({
|
3799
|
+
pathParams: {
|
3800
|
+
workspace: "{workspaceId}",
|
3801
|
+
dbBranchName: "{dbBranch}",
|
3802
|
+
region: "{region}",
|
3803
|
+
tableName: __privateGet$4(this, _table)
|
3804
|
+
},
|
3805
|
+
body: {
|
3806
|
+
column,
|
3807
|
+
queryVector: query,
|
3808
|
+
similarityFunction: options?.similarityFunction,
|
3809
|
+
size: options?.size,
|
3810
|
+
filter: options?.filter
|
3811
|
+
},
|
3812
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2568
3813
|
});
|
2569
3814
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2570
3815
|
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
@@ -2572,7 +3817,6 @@ class RestRepository extends Query {
|
|
2572
3817
|
}
|
2573
3818
|
async aggregate(aggs, filter) {
|
2574
3819
|
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
2575
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2576
3820
|
const result = await aggregateTable({
|
2577
3821
|
pathParams: {
|
2578
3822
|
workspace: "{workspaceId}",
|
@@ -2581,7 +3825,7 @@ class RestRepository extends Query {
|
|
2581
3825
|
tableName: __privateGet$4(this, _table)
|
2582
3826
|
},
|
2583
3827
|
body: { aggs, filter },
|
2584
|
-
...
|
3828
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2585
3829
|
});
|
2586
3830
|
return result;
|
2587
3831
|
});
|
@@ -2592,7 +3836,6 @@ class RestRepository extends Query {
|
|
2592
3836
|
if (cacheQuery)
|
2593
3837
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
2594
3838
|
const data = query.getQueryOptions();
|
2595
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2596
3839
|
const { meta, records: objects } = await queryTable({
|
2597
3840
|
pathParams: {
|
2598
3841
|
workspace: "{workspaceId}",
|
@@ -2608,11 +3851,17 @@ class RestRepository extends Query {
|
|
2608
3851
|
consistency: data.consistency
|
2609
3852
|
},
|
2610
3853
|
fetchOptions: data.fetchOptions,
|
2611
|
-
...
|
3854
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2612
3855
|
});
|
2613
3856
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2614
3857
|
const records = objects.map(
|
2615
|
-
(record) => initObject(
|
3858
|
+
(record) => initObject(
|
3859
|
+
__privateGet$4(this, _db),
|
3860
|
+
schemaTables,
|
3861
|
+
__privateGet$4(this, _table),
|
3862
|
+
record,
|
3863
|
+
data.columns ?? ["*"]
|
3864
|
+
)
|
2616
3865
|
);
|
2617
3866
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
2618
3867
|
return new Page(query, meta, records);
|
@@ -2621,7 +3870,6 @@ class RestRepository extends Query {
|
|
2621
3870
|
async summarizeTable(query, summaries, summariesFilter) {
|
2622
3871
|
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
2623
3872
|
const data = query.getQueryOptions();
|
2624
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2625
3873
|
const result = await summarizeTable({
|
2626
3874
|
pathParams: {
|
2627
3875
|
workspace: "{workspaceId}",
|
@@ -2638,11 +3886,44 @@ class RestRepository extends Query {
|
|
2638
3886
|
summaries,
|
2639
3887
|
summariesFilter
|
2640
3888
|
},
|
2641
|
-
...
|
3889
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2642
3890
|
});
|
2643
3891
|
return result;
|
2644
3892
|
});
|
2645
3893
|
}
|
3894
|
+
ask(question, options) {
|
3895
|
+
const questionParam = options?.sessionId ? { message: question } : { question };
|
3896
|
+
const params = {
|
3897
|
+
pathParams: {
|
3898
|
+
workspace: "{workspaceId}",
|
3899
|
+
dbBranchName: "{dbBranch}",
|
3900
|
+
region: "{region}",
|
3901
|
+
tableName: __privateGet$4(this, _table),
|
3902
|
+
sessionId: options?.sessionId
|
3903
|
+
},
|
3904
|
+
body: {
|
3905
|
+
...questionParam,
|
3906
|
+
rules: options?.rules,
|
3907
|
+
searchType: options?.searchType,
|
3908
|
+
search: options?.searchType === "keyword" ? options?.search : void 0,
|
3909
|
+
vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
|
3910
|
+
},
|
3911
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3912
|
+
};
|
3913
|
+
if (options?.onMessage) {
|
3914
|
+
fetchSSERequest({
|
3915
|
+
endpoint: "dataPlane",
|
3916
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
|
3917
|
+
method: "POST",
|
3918
|
+
onMessage: (message) => {
|
3919
|
+
options.onMessage?.({ answer: message.text, records: message.records });
|
3920
|
+
},
|
3921
|
+
...params
|
3922
|
+
});
|
3923
|
+
} else {
|
3924
|
+
return askTableSession(params);
|
3925
|
+
}
|
3926
|
+
}
|
2646
3927
|
}
|
2647
3928
|
_table = new WeakMap();
|
2648
3929
|
_getFetchProps = new WeakMap();
|
@@ -2652,8 +3933,7 @@ _schemaTables$2 = new WeakMap();
|
|
2652
3933
|
_trace = new WeakMap();
|
2653
3934
|
_insertRecordWithoutId = new WeakSet();
|
2654
3935
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
2655
|
-
const
|
2656
|
-
const record = transformObjectLinks(object);
|
3936
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
2657
3937
|
const response = await insertRecord({
|
2658
3938
|
pathParams: {
|
2659
3939
|
workspace: "{workspaceId}",
|
@@ -2663,15 +3943,16 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
2663
3943
|
},
|
2664
3944
|
queryParams: { columns },
|
2665
3945
|
body: record,
|
2666
|
-
...
|
3946
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2667
3947
|
});
|
2668
3948
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2669
3949
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2670
3950
|
};
|
2671
3951
|
_insertRecordWithId = new WeakSet();
|
2672
3952
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
2673
|
-
|
2674
|
-
|
3953
|
+
if (!recordId)
|
3954
|
+
return null;
|
3955
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
2675
3956
|
const response = await insertRecordWithID({
|
2676
3957
|
pathParams: {
|
2677
3958
|
workspace: "{workspaceId}",
|
@@ -2682,30 +3963,28 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
|
|
2682
3963
|
},
|
2683
3964
|
body: record,
|
2684
3965
|
queryParams: { createOnly, columns, ifVersion },
|
2685
|
-
...
|
3966
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2686
3967
|
});
|
2687
3968
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2688
3969
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2689
3970
|
};
|
2690
3971
|
_insertRecords = new WeakSet();
|
2691
3972
|
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
2692
|
-
const
|
2693
|
-
|
2694
|
-
|
2695
|
-
|
2696
|
-
|
2697
|
-
BULK_OPERATION_MAX_SIZE
|
2698
|
-
);
|
3973
|
+
const operations = await promiseMap(objects, async (object) => {
|
3974
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3975
|
+
return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
|
3976
|
+
});
|
3977
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
2699
3978
|
const ids = [];
|
2700
|
-
for (const
|
3979
|
+
for (const operations2 of chunkedOperations) {
|
2701
3980
|
const { results } = await branchTransaction({
|
2702
3981
|
pathParams: {
|
2703
3982
|
workspace: "{workspaceId}",
|
2704
3983
|
dbBranchName: "{dbBranch}",
|
2705
3984
|
region: "{region}"
|
2706
3985
|
},
|
2707
|
-
body: { operations },
|
2708
|
-
...
|
3986
|
+
body: { operations: operations2 },
|
3987
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2709
3988
|
});
|
2710
3989
|
for (const result of results) {
|
2711
3990
|
if (result.operation === "insert") {
|
@@ -2719,8 +3998,9 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
|
2719
3998
|
};
|
2720
3999
|
_updateRecordWithID = new WeakSet();
|
2721
4000
|
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
2722
|
-
|
2723
|
-
|
4001
|
+
if (!recordId)
|
4002
|
+
return null;
|
4003
|
+
const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
2724
4004
|
try {
|
2725
4005
|
const response = await updateRecordWithID({
|
2726
4006
|
pathParams: {
|
@@ -2732,7 +4012,7 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
2732
4012
|
},
|
2733
4013
|
queryParams: { columns, ifVersion },
|
2734
4014
|
body: record,
|
2735
|
-
...
|
4015
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2736
4016
|
});
|
2737
4017
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2738
4018
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
@@ -2745,23 +4025,21 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
2745
4025
|
};
|
2746
4026
|
_updateRecords = new WeakSet();
|
2747
4027
|
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
2748
|
-
const
|
2749
|
-
|
2750
|
-
|
2751
|
-
|
2752
|
-
|
2753
|
-
BULK_OPERATION_MAX_SIZE
|
2754
|
-
);
|
4028
|
+
const operations = await promiseMap(objects, async ({ id, ...object }) => {
|
4029
|
+
const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
4030
|
+
return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
|
4031
|
+
});
|
4032
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
2755
4033
|
const ids = [];
|
2756
|
-
for (const
|
4034
|
+
for (const operations2 of chunkedOperations) {
|
2757
4035
|
const { results } = await branchTransaction({
|
2758
4036
|
pathParams: {
|
2759
4037
|
workspace: "{workspaceId}",
|
2760
4038
|
dbBranchName: "{dbBranch}",
|
2761
4039
|
region: "{region}"
|
2762
4040
|
},
|
2763
|
-
body: { operations },
|
2764
|
-
...
|
4041
|
+
body: { operations: operations2 },
|
4042
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2765
4043
|
});
|
2766
4044
|
for (const result of results) {
|
2767
4045
|
if (result.operation === "update") {
|
@@ -2775,7 +4053,8 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
|
2775
4053
|
};
|
2776
4054
|
_upsertRecordWithID = new WeakSet();
|
2777
4055
|
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
2778
|
-
|
4056
|
+
if (!recordId)
|
4057
|
+
return null;
|
2779
4058
|
const response = await upsertRecordWithID({
|
2780
4059
|
pathParams: {
|
2781
4060
|
workspace: "{workspaceId}",
|
@@ -2786,14 +4065,15 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
2786
4065
|
},
|
2787
4066
|
queryParams: { columns, ifVersion },
|
2788
4067
|
body: object,
|
2789
|
-
...
|
4068
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2790
4069
|
});
|
2791
4070
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2792
4071
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2793
4072
|
};
|
2794
4073
|
_deleteRecord = new WeakSet();
|
2795
4074
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
2796
|
-
|
4075
|
+
if (!recordId)
|
4076
|
+
return null;
|
2797
4077
|
try {
|
2798
4078
|
const response = await deleteRecord({
|
2799
4079
|
pathParams: {
|
@@ -2804,7 +4084,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
2804
4084
|
recordId
|
2805
4085
|
},
|
2806
4086
|
queryParams: { columns },
|
2807
|
-
...
|
4087
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2808
4088
|
});
|
2809
4089
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2810
4090
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
@@ -2817,9 +4097,8 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
2817
4097
|
};
|
2818
4098
|
_deleteRecords = new WeakSet();
|
2819
4099
|
deleteRecords_fn = async function(recordIds) {
|
2820
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2821
4100
|
const chunkedOperations = chunk(
|
2822
|
-
recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
4101
|
+
compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
2823
4102
|
BULK_OPERATION_MAX_SIZE
|
2824
4103
|
);
|
2825
4104
|
for (const operations of chunkedOperations) {
|
@@ -2830,21 +4109,22 @@ deleteRecords_fn = async function(recordIds) {
|
|
2830
4109
|
region: "{region}"
|
2831
4110
|
},
|
2832
4111
|
body: { operations },
|
2833
|
-
...
|
4112
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2834
4113
|
});
|
2835
4114
|
}
|
2836
4115
|
};
|
2837
4116
|
_setCacheQuery = new WeakSet();
|
2838
4117
|
setCacheQuery_fn = async function(query, meta, records) {
|
2839
|
-
await __privateGet$4(this, _cache)
|
4118
|
+
await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
|
2840
4119
|
};
|
2841
4120
|
_getCacheQuery = new WeakSet();
|
2842
4121
|
getCacheQuery_fn = async function(query) {
|
2843
4122
|
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
2844
|
-
const result = await __privateGet$4(this, _cache)
|
4123
|
+
const result = await __privateGet$4(this, _cache)?.get(key);
|
2845
4124
|
if (!result)
|
2846
4125
|
return null;
|
2847
|
-
const
|
4126
|
+
const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
|
4127
|
+
const { cache: ttl = defaultTTL } = query.getQueryOptions();
|
2848
4128
|
if (ttl < 0)
|
2849
4129
|
return null;
|
2850
4130
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
@@ -2854,15 +4134,49 @@ _getSchemaTables$1 = new WeakSet();
|
|
2854
4134
|
getSchemaTables_fn$1 = async function() {
|
2855
4135
|
if (__privateGet$4(this, _schemaTables$2))
|
2856
4136
|
return __privateGet$4(this, _schemaTables$2);
|
2857
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2858
4137
|
const { schema } = await getBranchDetails({
|
2859
4138
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2860
|
-
...
|
4139
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2861
4140
|
});
|
2862
4141
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
2863
4142
|
return schema.tables;
|
2864
4143
|
};
|
2865
|
-
|
4144
|
+
_transformObjectToApi = new WeakSet();
|
4145
|
+
transformObjectToApi_fn = async function(object) {
|
4146
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
4147
|
+
const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
|
4148
|
+
if (!schema)
|
4149
|
+
throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
|
4150
|
+
const result = {};
|
4151
|
+
for (const [key, value] of Object.entries(object)) {
|
4152
|
+
if (key === "xata")
|
4153
|
+
continue;
|
4154
|
+
const type = schema.columns.find((column) => column.name === key)?.type;
|
4155
|
+
switch (type) {
|
4156
|
+
case "link": {
|
4157
|
+
result[key] = isIdentifiable(value) ? value.id : value;
|
4158
|
+
break;
|
4159
|
+
}
|
4160
|
+
case "datetime": {
|
4161
|
+
result[key] = value instanceof Date ? value.toISOString() : value;
|
4162
|
+
break;
|
4163
|
+
}
|
4164
|
+
case `file`:
|
4165
|
+
result[key] = await parseInputFileEntry(value);
|
4166
|
+
break;
|
4167
|
+
case "file[]":
|
4168
|
+
result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
|
4169
|
+
break;
|
4170
|
+
case "json":
|
4171
|
+
result[key] = stringifyJson(value);
|
4172
|
+
break;
|
4173
|
+
default:
|
4174
|
+
result[key] = value;
|
4175
|
+
}
|
4176
|
+
}
|
4177
|
+
return result;
|
4178
|
+
};
|
4179
|
+
const removeLinksFromObject = (object) => {
|
2866
4180
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
2867
4181
|
if (key === "xata")
|
2868
4182
|
return acc;
|
@@ -2899,18 +4213,33 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2899
4213
|
if (item === column.name) {
|
2900
4214
|
return [...acc, "*"];
|
2901
4215
|
}
|
2902
|
-
if (item.startsWith(`${column.name}.`)) {
|
4216
|
+
if (isString(item) && item.startsWith(`${column.name}.`)) {
|
2903
4217
|
const [, ...path] = item.split(".");
|
2904
4218
|
return [...acc, path.join(".")];
|
2905
4219
|
}
|
2906
4220
|
return acc;
|
2907
4221
|
}, []);
|
2908
|
-
data[column.name] = initObject(
|
4222
|
+
data[column.name] = initObject(
|
4223
|
+
db,
|
4224
|
+
schemaTables,
|
4225
|
+
linkTable,
|
4226
|
+
value,
|
4227
|
+
selectedLinkColumns
|
4228
|
+
);
|
2909
4229
|
} else {
|
2910
4230
|
data[column.name] = null;
|
2911
4231
|
}
|
2912
4232
|
break;
|
2913
4233
|
}
|
4234
|
+
case "file":
|
4235
|
+
data[column.name] = isDefined(value) ? new XataFile(value) : null;
|
4236
|
+
break;
|
4237
|
+
case "file[]":
|
4238
|
+
data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
|
4239
|
+
break;
|
4240
|
+
case "json":
|
4241
|
+
data[column.name] = parseJson(value);
|
4242
|
+
break;
|
2914
4243
|
default:
|
2915
4244
|
data[column.name] = value ?? null;
|
2916
4245
|
if (column.notNull === true && value === null) {
|
@@ -2920,29 +4249,35 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2920
4249
|
}
|
2921
4250
|
}
|
2922
4251
|
const record = { ...data };
|
4252
|
+
const serializable = { xata, ...removeLinksFromObject(data) };
|
4253
|
+
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
2923
4254
|
record.read = function(columns2) {
|
2924
4255
|
return db[table].read(record["id"], columns2);
|
2925
4256
|
};
|
2926
4257
|
record.update = function(data2, b, c) {
|
2927
|
-
const columns2 =
|
4258
|
+
const columns2 = isValidSelectableColumns(b) ? b : ["*"];
|
2928
4259
|
const ifVersion = parseIfVersion(b, c);
|
2929
4260
|
return db[table].update(record["id"], data2, columns2, { ifVersion });
|
2930
4261
|
};
|
2931
4262
|
record.replace = function(data2, b, c) {
|
2932
|
-
const columns2 =
|
4263
|
+
const columns2 = isValidSelectableColumns(b) ? b : ["*"];
|
2933
4264
|
const ifVersion = parseIfVersion(b, c);
|
2934
4265
|
return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
|
2935
4266
|
};
|
2936
4267
|
record.delete = function() {
|
2937
4268
|
return db[table].delete(record["id"]);
|
2938
4269
|
};
|
4270
|
+
record.xata = Object.freeze(metadata);
|
2939
4271
|
record.getMetadata = function() {
|
2940
|
-
return xata;
|
4272
|
+
return record.xata;
|
2941
4273
|
};
|
2942
|
-
record.
|
2943
|
-
return JSON.parse(JSON.stringify(
|
4274
|
+
record.toSerializable = function() {
|
4275
|
+
return JSON.parse(JSON.stringify(serializable));
|
2944
4276
|
};
|
2945
|
-
|
4277
|
+
record.toString = function() {
|
4278
|
+
return JSON.stringify(serializable);
|
4279
|
+
};
|
4280
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
2946
4281
|
Object.defineProperty(record, prop, { enumerable: false });
|
2947
4282
|
}
|
2948
4283
|
Object.freeze(record);
|
@@ -2958,11 +4293,7 @@ function extractId(value) {
|
|
2958
4293
|
function isValidColumn(columns, column) {
|
2959
4294
|
if (columns.includes("*"))
|
2960
4295
|
return true;
|
2961
|
-
|
2962
|
-
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
2963
|
-
return linkColumns.length > 0;
|
2964
|
-
}
|
2965
|
-
return columns.includes(column.name);
|
4296
|
+
return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
|
2966
4297
|
}
|
2967
4298
|
function parseIfVersion(...args) {
|
2968
4299
|
for (const arg of args) {
|
@@ -2973,6 +4304,12 @@ function parseIfVersion(...args) {
|
|
2973
4304
|
return void 0;
|
2974
4305
|
}
|
2975
4306
|
|
4307
|
+
var __defProp$3 = Object.defineProperty;
|
4308
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4309
|
+
var __publicField$3 = (obj, key, value) => {
|
4310
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4311
|
+
return value;
|
4312
|
+
};
|
2976
4313
|
var __accessCheck$3 = (obj, member, msg) => {
|
2977
4314
|
if (!member.has(obj))
|
2978
4315
|
throw TypeError("Cannot " + msg);
|
@@ -2995,6 +4332,8 @@ var _map;
|
|
2995
4332
|
class SimpleCache {
|
2996
4333
|
constructor(options = {}) {
|
2997
4334
|
__privateAdd$3(this, _map, void 0);
|
4335
|
+
__publicField$3(this, "capacity");
|
4336
|
+
__publicField$3(this, "defaultQueryTTL");
|
2998
4337
|
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
2999
4338
|
this.capacity = options.max ?? 500;
|
3000
4339
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
@@ -3130,19 +4469,19 @@ class SearchPlugin extends XataPlugin {
|
|
3130
4469
|
__privateAdd$1(this, _schemaTables, void 0);
|
3131
4470
|
__privateSet$1(this, _schemaTables, schemaTables);
|
3132
4471
|
}
|
3133
|
-
build(
|
4472
|
+
build(pluginOptions) {
|
3134
4473
|
return {
|
3135
4474
|
all: async (query, options = {}) => {
|
3136
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
3137
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
4475
|
+
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4476
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
3138
4477
|
return records.map((record) => {
|
3139
4478
|
const { table = "orphan" } = record.xata;
|
3140
4479
|
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
3141
4480
|
});
|
3142
4481
|
},
|
3143
4482
|
byTable: async (query, options = {}) => {
|
3144
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
3145
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
4483
|
+
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4484
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
3146
4485
|
return records.reduce((acc, record) => {
|
3147
4486
|
const { table = "orphan" } = record.xata;
|
3148
4487
|
const items = acc[table] ?? [];
|
@@ -3155,38 +4494,108 @@ class SearchPlugin extends XataPlugin {
|
|
3155
4494
|
}
|
3156
4495
|
_schemaTables = new WeakMap();
|
3157
4496
|
_search = new WeakSet();
|
3158
|
-
search_fn = async function(query, options,
|
3159
|
-
const fetchProps = await getFetchProps();
|
4497
|
+
search_fn = async function(query, options, pluginOptions) {
|
3160
4498
|
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
3161
4499
|
const { records } = await searchBranch({
|
3162
4500
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4501
|
+
// @ts-ignore https://github.com/xataio/client-ts/issues/313
|
3163
4502
|
body: { tables, query, fuzziness, prefix, highlight, page },
|
3164
|
-
...
|
4503
|
+
...pluginOptions
|
3165
4504
|
});
|
3166
4505
|
return records;
|
3167
4506
|
};
|
3168
4507
|
_getSchemaTables = new WeakSet();
|
3169
|
-
getSchemaTables_fn = async function(
|
4508
|
+
getSchemaTables_fn = async function(pluginOptions) {
|
3170
4509
|
if (__privateGet$1(this, _schemaTables))
|
3171
4510
|
return __privateGet$1(this, _schemaTables);
|
3172
|
-
const fetchProps = await getFetchProps();
|
3173
4511
|
const { schema } = await getBranchDetails({
|
3174
4512
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3175
|
-
...
|
4513
|
+
...pluginOptions
|
3176
4514
|
});
|
3177
4515
|
__privateSet$1(this, _schemaTables, schema.tables);
|
3178
4516
|
return schema.tables;
|
3179
4517
|
};
|
3180
4518
|
|
4519
|
+
function escapeElement(elementRepresentation) {
|
4520
|
+
const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
4521
|
+
return '"' + escaped + '"';
|
4522
|
+
}
|
4523
|
+
function arrayString(val) {
|
4524
|
+
let result = "{";
|
4525
|
+
for (let i = 0; i < val.length; i++) {
|
4526
|
+
if (i > 0) {
|
4527
|
+
result = result + ",";
|
4528
|
+
}
|
4529
|
+
if (val[i] === null || typeof val[i] === "undefined") {
|
4530
|
+
result = result + "NULL";
|
4531
|
+
} else if (Array.isArray(val[i])) {
|
4532
|
+
result = result + arrayString(val[i]);
|
4533
|
+
} else if (val[i] instanceof Buffer) {
|
4534
|
+
result += "\\\\x" + val[i].toString("hex");
|
4535
|
+
} else {
|
4536
|
+
result += escapeElement(prepareValue(val[i]));
|
4537
|
+
}
|
4538
|
+
}
|
4539
|
+
result = result + "}";
|
4540
|
+
return result;
|
4541
|
+
}
|
4542
|
+
function prepareValue(value) {
|
4543
|
+
if (!isDefined(value))
|
4544
|
+
return null;
|
4545
|
+
if (value instanceof Date) {
|
4546
|
+
return value.toISOString();
|
4547
|
+
}
|
4548
|
+
if (Array.isArray(value)) {
|
4549
|
+
return arrayString(value);
|
4550
|
+
}
|
4551
|
+
if (isObject(value)) {
|
4552
|
+
return JSON.stringify(value);
|
4553
|
+
}
|
4554
|
+
try {
|
4555
|
+
return value.toString();
|
4556
|
+
} catch (e) {
|
4557
|
+
return value;
|
4558
|
+
}
|
4559
|
+
}
|
4560
|
+
function prepareParams(param1, param2) {
|
4561
|
+
if (isString(param1)) {
|
4562
|
+
return { statement: param1, params: param2?.map((value) => prepareValue(value)) };
|
4563
|
+
}
|
4564
|
+
if (isStringArray(param1)) {
|
4565
|
+
const statement = param1.reduce((acc, curr, index) => {
|
4566
|
+
return acc + curr + (index < (param2?.length ?? 0) ? "$" + (index + 1) : "");
|
4567
|
+
}, "");
|
4568
|
+
return { statement, params: param2?.map((value) => prepareValue(value)) };
|
4569
|
+
}
|
4570
|
+
if (isObject(param1)) {
|
4571
|
+
const { statement, params, consistency } = param1;
|
4572
|
+
return { statement, params: params?.map((value) => prepareValue(value)), consistency };
|
4573
|
+
}
|
4574
|
+
throw new Error("Invalid query");
|
4575
|
+
}
|
4576
|
+
|
4577
|
+
class SQLPlugin extends XataPlugin {
|
4578
|
+
build(pluginOptions) {
|
4579
|
+
return async (param1, ...param2) => {
|
4580
|
+
const { statement, params, consistency } = prepareParams(param1, param2);
|
4581
|
+
const { records, warning } = await sqlQuery({
|
4582
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4583
|
+
body: { statement, params, consistency },
|
4584
|
+
...pluginOptions
|
4585
|
+
});
|
4586
|
+
return { records, warning };
|
4587
|
+
};
|
4588
|
+
}
|
4589
|
+
}
|
4590
|
+
|
3181
4591
|
class TransactionPlugin extends XataPlugin {
|
3182
|
-
build(
|
4592
|
+
build(pluginOptions) {
|
3183
4593
|
return {
|
3184
4594
|
run: async (operations) => {
|
3185
|
-
const fetchProps = await getFetchProps();
|
3186
4595
|
const response = await branchTransaction({
|
3187
4596
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3188
4597
|
body: { operations },
|
3189
|
-
...
|
4598
|
+
...pluginOptions
|
3190
4599
|
});
|
3191
4600
|
return response;
|
3192
4601
|
}
|
@@ -3194,90 +4603,12 @@ class TransactionPlugin extends XataPlugin {
|
|
3194
4603
|
}
|
3195
4604
|
}
|
3196
4605
|
|
3197
|
-
|
3198
|
-
|
4606
|
+
var __defProp$2 = Object.defineProperty;
|
4607
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4608
|
+
var __publicField$2 = (obj, key, value) => {
|
4609
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4610
|
+
return value;
|
3199
4611
|
};
|
3200
|
-
|
3201
|
-
async function getCurrentBranchName(options) {
|
3202
|
-
const { branch, envBranch } = getEnvironment();
|
3203
|
-
if (branch)
|
3204
|
-
return branch;
|
3205
|
-
const gitBranch = envBranch || await getGitBranch();
|
3206
|
-
return resolveXataBranch(gitBranch, options);
|
3207
|
-
}
|
3208
|
-
async function getCurrentBranchDetails(options) {
|
3209
|
-
const branch = await getCurrentBranchName(options);
|
3210
|
-
return getDatabaseBranch(branch, options);
|
3211
|
-
}
|
3212
|
-
async function resolveXataBranch(gitBranch, options) {
|
3213
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
3214
|
-
const apiKey = options?.apiKey || getAPIKey();
|
3215
|
-
if (!databaseURL)
|
3216
|
-
throw new Error(
|
3217
|
-
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
3218
|
-
);
|
3219
|
-
if (!apiKey)
|
3220
|
-
throw new Error(
|
3221
|
-
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
3222
|
-
);
|
3223
|
-
const [protocol, , host, , dbName] = databaseURL.split("/");
|
3224
|
-
const urlParts = parseWorkspacesUrlParts(host);
|
3225
|
-
if (!urlParts)
|
3226
|
-
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3227
|
-
const { workspace, region } = urlParts;
|
3228
|
-
const { fallbackBranch } = getEnvironment();
|
3229
|
-
const { branch } = await resolveBranch({
|
3230
|
-
apiKey,
|
3231
|
-
apiUrl: databaseURL,
|
3232
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
3233
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
3234
|
-
pathParams: { dbName, workspace, region },
|
3235
|
-
queryParams: { gitBranch, fallbackBranch },
|
3236
|
-
trace: defaultTrace,
|
3237
|
-
clientName: options?.clientName
|
3238
|
-
});
|
3239
|
-
return branch;
|
3240
|
-
}
|
3241
|
-
async function getDatabaseBranch(branch, options) {
|
3242
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
3243
|
-
const apiKey = options?.apiKey || getAPIKey();
|
3244
|
-
if (!databaseURL)
|
3245
|
-
throw new Error(
|
3246
|
-
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
3247
|
-
);
|
3248
|
-
if (!apiKey)
|
3249
|
-
throw new Error(
|
3250
|
-
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
3251
|
-
);
|
3252
|
-
const [protocol, , host, , database] = databaseURL.split("/");
|
3253
|
-
const urlParts = parseWorkspacesUrlParts(host);
|
3254
|
-
if (!urlParts)
|
3255
|
-
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3256
|
-
const { workspace, region } = urlParts;
|
3257
|
-
try {
|
3258
|
-
return await getBranchDetails({
|
3259
|
-
apiKey,
|
3260
|
-
apiUrl: databaseURL,
|
3261
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
3262
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
3263
|
-
pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
|
3264
|
-
trace: defaultTrace
|
3265
|
-
});
|
3266
|
-
} catch (err) {
|
3267
|
-
if (isObject(err) && err.status === 404)
|
3268
|
-
return null;
|
3269
|
-
throw err;
|
3270
|
-
}
|
3271
|
-
}
|
3272
|
-
function getDatabaseURL() {
|
3273
|
-
try {
|
3274
|
-
const { databaseURL } = getEnvironment();
|
3275
|
-
return databaseURL;
|
3276
|
-
} catch (err) {
|
3277
|
-
return void 0;
|
3278
|
-
}
|
3279
|
-
}
|
3280
|
-
|
3281
4612
|
var __accessCheck = (obj, member, msg) => {
|
3282
4613
|
if (!member.has(obj))
|
3283
4614
|
throw TypeError("Cannot " + msg);
|
@@ -3301,48 +4632,48 @@ var __privateMethod = (obj, member, method) => {
|
|
3301
4632
|
return method;
|
3302
4633
|
};
|
3303
4634
|
const buildClient = (plugins) => {
|
3304
|
-
var
|
4635
|
+
var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
|
3305
4636
|
return _a = class {
|
3306
4637
|
constructor(options = {}, schemaTables) {
|
3307
4638
|
__privateAdd(this, _parseOptions);
|
3308
4639
|
__privateAdd(this, _getFetchProps);
|
3309
|
-
__privateAdd(this, _evaluateBranch);
|
3310
|
-
__privateAdd(this, _branch, void 0);
|
3311
4640
|
__privateAdd(this, _options, void 0);
|
4641
|
+
__publicField$2(this, "db");
|
4642
|
+
__publicField$2(this, "search");
|
4643
|
+
__publicField$2(this, "transactions");
|
4644
|
+
__publicField$2(this, "sql");
|
4645
|
+
__publicField$2(this, "files");
|
3312
4646
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
3313
4647
|
__privateSet(this, _options, safeOptions);
|
3314
4648
|
const pluginOptions = {
|
3315
|
-
|
4649
|
+
...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
3316
4650
|
cache: safeOptions.cache,
|
3317
|
-
|
4651
|
+
host: safeOptions.host
|
3318
4652
|
};
|
3319
4653
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
3320
4654
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
3321
4655
|
const transactions = new TransactionPlugin().build(pluginOptions);
|
4656
|
+
const sql = new SQLPlugin().build(pluginOptions);
|
4657
|
+
const files = new FilesPlugin().build(pluginOptions);
|
3322
4658
|
this.db = db;
|
3323
4659
|
this.search = search;
|
3324
4660
|
this.transactions = transactions;
|
4661
|
+
this.sql = sql;
|
4662
|
+
this.files = files;
|
3325
4663
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
3326
4664
|
if (namespace === void 0)
|
3327
4665
|
continue;
|
3328
|
-
|
3329
|
-
if (result instanceof Promise) {
|
3330
|
-
void result.then((namespace2) => {
|
3331
|
-
this[key] = namespace2;
|
3332
|
-
});
|
3333
|
-
} else {
|
3334
|
-
this[key] = result;
|
3335
|
-
}
|
4666
|
+
this[key] = namespace.build(pluginOptions);
|
3336
4667
|
}
|
3337
4668
|
}
|
3338
4669
|
async getConfig() {
|
3339
4670
|
const databaseURL = __privateGet(this, _options).databaseURL;
|
3340
|
-
const branch =
|
4671
|
+
const branch = __privateGet(this, _options).branch;
|
3341
4672
|
return { databaseURL, branch };
|
3342
4673
|
}
|
3343
|
-
},
|
4674
|
+
}, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
3344
4675
|
const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
|
3345
|
-
const isBrowser = typeof window !== "undefined";
|
4676
|
+
const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
|
3346
4677
|
if (isBrowser && !enableBrowser) {
|
3347
4678
|
throw new Error(
|
3348
4679
|
"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."
|
@@ -3354,70 +4685,88 @@ const buildClient = (plugins) => {
|
|
3354
4685
|
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
3355
4686
|
const trace = options?.trace ?? defaultTrace;
|
3356
4687
|
const clientName = options?.clientName;
|
3357
|
-
const
|
3358
|
-
|
3359
|
-
databaseURL,
|
3360
|
-
fetchImpl: options?.fetch,
|
3361
|
-
clientName: options?.clientName
|
3362
|
-
});
|
4688
|
+
const host = options?.host ?? "production";
|
4689
|
+
const xataAgentExtra = options?.xataAgentExtra;
|
3363
4690
|
if (!apiKey) {
|
3364
4691
|
throw new Error("Option apiKey is required");
|
3365
4692
|
}
|
3366
4693
|
if (!databaseURL) {
|
3367
4694
|
throw new Error("Option databaseURL is required");
|
3368
4695
|
}
|
3369
|
-
|
3370
|
-
|
4696
|
+
const envBranch = getBranch();
|
4697
|
+
const previewBranch = getPreviewBranch();
|
4698
|
+
const branch = options?.branch || previewBranch || envBranch || "main";
|
4699
|
+
if (!!previewBranch && branch !== previewBranch) {
|
4700
|
+
console.warn(
|
4701
|
+
`Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
|
4702
|
+
);
|
4703
|
+
} else if (!!envBranch && branch !== envBranch) {
|
4704
|
+
console.warn(
|
4705
|
+
`Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
4706
|
+
);
|
4707
|
+
} else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
|
4708
|
+
console.warn(
|
4709
|
+
`Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
4710
|
+
);
|
4711
|
+
} else if (!previewBranch && !envBranch && options?.branch === void 0) {
|
4712
|
+
console.warn(
|
4713
|
+
`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.`
|
4714
|
+
);
|
4715
|
+
}
|
4716
|
+
return {
|
4717
|
+
fetch,
|
4718
|
+
databaseURL,
|
4719
|
+
apiKey,
|
4720
|
+
branch,
|
4721
|
+
cache,
|
4722
|
+
trace,
|
4723
|
+
host,
|
4724
|
+
clientID: generateUUID(),
|
4725
|
+
enableBrowser,
|
4726
|
+
clientName,
|
4727
|
+
xataAgentExtra
|
4728
|
+
};
|
4729
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
|
3371
4730
|
fetch,
|
3372
4731
|
apiKey,
|
3373
4732
|
databaseURL,
|
3374
4733
|
branch,
|
3375
4734
|
trace,
|
3376
4735
|
clientID,
|
3377
|
-
clientName
|
4736
|
+
clientName,
|
4737
|
+
xataAgentExtra
|
3378
4738
|
}) {
|
3379
|
-
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
3380
|
-
if (!branchValue)
|
3381
|
-
throw new Error("Unable to resolve branch value");
|
3382
4739
|
return {
|
3383
|
-
|
4740
|
+
fetch,
|
3384
4741
|
apiKey,
|
3385
4742
|
apiUrl: "",
|
4743
|
+
// Instead of using workspace and dbBranch, we inject a probably CNAME'd URL
|
3386
4744
|
workspacesApiUrl: (path, params) => {
|
3387
4745
|
const hasBranch = params.dbBranchName ?? params.branch;
|
3388
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${
|
4746
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
|
3389
4747
|
return databaseURL + newPath;
|
3390
4748
|
},
|
3391
4749
|
trace,
|
3392
4750
|
clientID,
|
3393
|
-
clientName
|
3394
|
-
|
3395
|
-
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
3396
|
-
if (__privateGet(this, _branch))
|
3397
|
-
return __privateGet(this, _branch);
|
3398
|
-
if (param === void 0)
|
3399
|
-
return void 0;
|
3400
|
-
const strategies = Array.isArray(param) ? [...param] : [param];
|
3401
|
-
const evaluateBranch = async (strategy) => {
|
3402
|
-
return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
|
4751
|
+
clientName,
|
4752
|
+
xataAgentExtra
|
3403
4753
|
};
|
3404
|
-
for await (const strategy of strategies) {
|
3405
|
-
const branch = await evaluateBranch(strategy);
|
3406
|
-
if (branch) {
|
3407
|
-
__privateSet(this, _branch, branch);
|
3408
|
-
return branch;
|
3409
|
-
}
|
3410
|
-
}
|
3411
4754
|
}, _a;
|
3412
4755
|
};
|
3413
4756
|
class BaseClient extends buildClient() {
|
3414
4757
|
}
|
3415
4758
|
|
4759
|
+
var __defProp$1 = Object.defineProperty;
|
4760
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4761
|
+
var __publicField$1 = (obj, key, value) => {
|
4762
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4763
|
+
return value;
|
4764
|
+
};
|
3416
4765
|
const META = "__";
|
3417
4766
|
const VALUE = "___";
|
3418
4767
|
class Serializer {
|
3419
4768
|
constructor() {
|
3420
|
-
this
|
4769
|
+
__publicField$1(this, "classes", {});
|
3421
4770
|
}
|
3422
4771
|
add(clazz) {
|
3423
4772
|
this.classes[clazz.name] = clazz;
|
@@ -3495,15 +4844,23 @@ function buildWorkerRunner(config) {
|
|
3495
4844
|
};
|
3496
4845
|
}
|
3497
4846
|
|
4847
|
+
var __defProp = Object.defineProperty;
|
4848
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4849
|
+
var __publicField = (obj, key, value) => {
|
4850
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4851
|
+
return value;
|
4852
|
+
};
|
3498
4853
|
class XataError extends Error {
|
3499
4854
|
constructor(message, status) {
|
3500
4855
|
super(message);
|
4856
|
+
__publicField(this, "status");
|
3501
4857
|
this.status = status;
|
3502
4858
|
}
|
3503
4859
|
}
|
3504
4860
|
|
3505
4861
|
exports.BaseClient = BaseClient;
|
3506
4862
|
exports.FetcherError = FetcherError;
|
4863
|
+
exports.FilesPlugin = FilesPlugin;
|
3507
4864
|
exports.Operations = operationsByTag;
|
3508
4865
|
exports.PAGINATION_DEFAULT_OFFSET = PAGINATION_DEFAULT_OFFSET;
|
3509
4866
|
exports.PAGINATION_DEFAULT_SIZE = PAGINATION_DEFAULT_SIZE;
|
@@ -3512,8 +4869,10 @@ exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
|
|
3512
4869
|
exports.Page = Page;
|
3513
4870
|
exports.Query = Query;
|
3514
4871
|
exports.RecordArray = RecordArray;
|
4872
|
+
exports.RecordColumnTypes = RecordColumnTypes;
|
3515
4873
|
exports.Repository = Repository;
|
3516
4874
|
exports.RestRepository = RestRepository;
|
4875
|
+
exports.SQLPlugin = SQLPlugin;
|
3517
4876
|
exports.SchemaPlugin = SchemaPlugin;
|
3518
4877
|
exports.SearchPlugin = SearchPlugin;
|
3519
4878
|
exports.Serializer = Serializer;
|
@@ -3521,14 +4880,19 @@ exports.SimpleCache = SimpleCache;
|
|
3521
4880
|
exports.XataApiClient = XataApiClient;
|
3522
4881
|
exports.XataApiPlugin = XataApiPlugin;
|
3523
4882
|
exports.XataError = XataError;
|
4883
|
+
exports.XataFile = XataFile;
|
3524
4884
|
exports.XataPlugin = XataPlugin;
|
3525
4885
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
3526
4886
|
exports.addGitBranchesEntry = addGitBranchesEntry;
|
3527
4887
|
exports.addTableColumn = addTableColumn;
|
3528
4888
|
exports.aggregateTable = aggregateTable;
|
3529
4889
|
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
4890
|
+
exports.askTable = askTable;
|
4891
|
+
exports.askTableSession = askTableSession;
|
3530
4892
|
exports.branchTransaction = branchTransaction;
|
3531
4893
|
exports.buildClient = buildClient;
|
4894
|
+
exports.buildPreviewBranchName = buildPreviewBranchName;
|
4895
|
+
exports.buildProviderString = buildProviderString;
|
3532
4896
|
exports.buildWorkerRunner = buildWorkerRunner;
|
3533
4897
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
3534
4898
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
@@ -3536,6 +4900,7 @@ exports.compareBranchSchemas = compareBranchSchemas;
|
|
3536
4900
|
exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
|
3537
4901
|
exports.compareMigrationRequest = compareMigrationRequest;
|
3538
4902
|
exports.contains = contains;
|
4903
|
+
exports.copyBranch = copyBranch;
|
3539
4904
|
exports.createBranch = createBranch;
|
3540
4905
|
exports.createDatabase = createDatabase;
|
3541
4906
|
exports.createMigrationRequest = createMigrationRequest;
|
@@ -3545,18 +4910,26 @@ exports.createWorkspace = createWorkspace;
|
|
3545
4910
|
exports.deleteBranch = deleteBranch;
|
3546
4911
|
exports.deleteColumn = deleteColumn;
|
3547
4912
|
exports.deleteDatabase = deleteDatabase;
|
4913
|
+
exports.deleteDatabaseGithubSettings = deleteDatabaseGithubSettings;
|
4914
|
+
exports.deleteFile = deleteFile;
|
4915
|
+
exports.deleteFileItem = deleteFileItem;
|
4916
|
+
exports.deleteOAuthAccessToken = deleteOAuthAccessToken;
|
3548
4917
|
exports.deleteRecord = deleteRecord;
|
3549
4918
|
exports.deleteTable = deleteTable;
|
3550
4919
|
exports.deleteUser = deleteUser;
|
3551
4920
|
exports.deleteUserAPIKey = deleteUserAPIKey;
|
4921
|
+
exports.deleteUserOAuthClient = deleteUserOAuthClient;
|
3552
4922
|
exports.deleteWorkspace = deleteWorkspace;
|
3553
4923
|
exports.deserialize = deserialize;
|
3554
4924
|
exports.endsWith = endsWith;
|
3555
4925
|
exports.equals = equals;
|
3556
4926
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
3557
4927
|
exports.exists = exists;
|
4928
|
+
exports.fileAccess = fileAccess;
|
3558
4929
|
exports.ge = ge;
|
3559
4930
|
exports.getAPIKey = getAPIKey;
|
4931
|
+
exports.getAuthorizationCode = getAuthorizationCode;
|
4932
|
+
exports.getBranch = getBranch;
|
3560
4933
|
exports.getBranchDetails = getBranchDetails;
|
3561
4934
|
exports.getBranchList = getBranchList;
|
3562
4935
|
exports.getBranchMetadata = getBranchMetadata;
|
@@ -3565,23 +4938,28 @@ exports.getBranchMigrationPlan = getBranchMigrationPlan;
|
|
3565
4938
|
exports.getBranchSchemaHistory = getBranchSchemaHistory;
|
3566
4939
|
exports.getBranchStats = getBranchStats;
|
3567
4940
|
exports.getColumn = getColumn;
|
3568
|
-
exports.
|
3569
|
-
exports.getCurrentBranchName = getCurrentBranchName;
|
4941
|
+
exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
|
3570
4942
|
exports.getDatabaseList = getDatabaseList;
|
3571
4943
|
exports.getDatabaseMetadata = getDatabaseMetadata;
|
3572
4944
|
exports.getDatabaseURL = getDatabaseURL;
|
4945
|
+
exports.getFile = getFile;
|
4946
|
+
exports.getFileItem = getFileItem;
|
3573
4947
|
exports.getGitBranchesMapping = getGitBranchesMapping;
|
3574
4948
|
exports.getHostUrl = getHostUrl;
|
3575
4949
|
exports.getMigrationRequest = getMigrationRequest;
|
3576
4950
|
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
4951
|
+
exports.getPreviewBranch = getPreviewBranch;
|
3577
4952
|
exports.getRecord = getRecord;
|
3578
4953
|
exports.getTableColumns = getTableColumns;
|
3579
4954
|
exports.getTableSchema = getTableSchema;
|
3580
4955
|
exports.getUser = getUser;
|
3581
4956
|
exports.getUserAPIKeys = getUserAPIKeys;
|
4957
|
+
exports.getUserOAuthAccessTokens = getUserOAuthAccessTokens;
|
4958
|
+
exports.getUserOAuthClients = getUserOAuthClients;
|
3582
4959
|
exports.getWorkspace = getWorkspace;
|
3583
4960
|
exports.getWorkspaceMembersList = getWorkspaceMembersList;
|
3584
4961
|
exports.getWorkspacesList = getWorkspacesList;
|
4962
|
+
exports.grantAuthorizationCode = grantAuthorizationCode;
|
3585
4963
|
exports.greaterEquals = greaterEquals;
|
3586
4964
|
exports.greaterThan = greaterThan;
|
3587
4965
|
exports.greaterThanEquals = greaterThanEquals;
|
@@ -3600,6 +4978,8 @@ exports.isHostProviderAlias = isHostProviderAlias;
|
|
3600
4978
|
exports.isHostProviderBuilder = isHostProviderBuilder;
|
3601
4979
|
exports.isIdentifiable = isIdentifiable;
|
3602
4980
|
exports.isNot = isNot;
|
4981
|
+
exports.isValidExpandedColumn = isValidExpandedColumn;
|
4982
|
+
exports.isValidSelectableColumns = isValidSelectableColumns;
|
3603
4983
|
exports.isXataRecord = isXataRecord;
|
3604
4984
|
exports.le = le;
|
3605
4985
|
exports.lessEquals = lessEquals;
|
@@ -3616,23 +4996,31 @@ exports.parseProviderString = parseProviderString;
|
|
3616
4996
|
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
3617
4997
|
exports.pattern = pattern;
|
3618
4998
|
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
4999
|
+
exports.pushBranchMigrations = pushBranchMigrations;
|
5000
|
+
exports.putFile = putFile;
|
5001
|
+
exports.putFileItem = putFileItem;
|
3619
5002
|
exports.queryMigrationRequests = queryMigrationRequests;
|
3620
5003
|
exports.queryTable = queryTable;
|
3621
5004
|
exports.removeGitBranchesEntry = removeGitBranchesEntry;
|
3622
5005
|
exports.removeWorkspaceMember = removeWorkspaceMember;
|
5006
|
+
exports.renameDatabase = renameDatabase;
|
3623
5007
|
exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
|
3624
5008
|
exports.resolveBranch = resolveBranch;
|
3625
5009
|
exports.searchBranch = searchBranch;
|
3626
5010
|
exports.searchTable = searchTable;
|
3627
5011
|
exports.serialize = serialize;
|
3628
5012
|
exports.setTableSchema = setTableSchema;
|
5013
|
+
exports.sqlQuery = sqlQuery;
|
3629
5014
|
exports.startsWith = startsWith;
|
3630
5015
|
exports.summarizeTable = summarizeTable;
|
5016
|
+
exports.transformImage = transformImage;
|
3631
5017
|
exports.updateBranchMetadata = updateBranchMetadata;
|
3632
5018
|
exports.updateBranchSchema = updateBranchSchema;
|
3633
5019
|
exports.updateColumn = updateColumn;
|
5020
|
+
exports.updateDatabaseGithubSettings = updateDatabaseGithubSettings;
|
3634
5021
|
exports.updateDatabaseMetadata = updateDatabaseMetadata;
|
3635
5022
|
exports.updateMigrationRequest = updateMigrationRequest;
|
5023
|
+
exports.updateOAuthAccessToken = updateOAuthAccessToken;
|
3636
5024
|
exports.updateRecordWithID = updateRecordWithID;
|
3637
5025
|
exports.updateTable = updateTable;
|
3638
5026
|
exports.updateUser = updateUser;
|
@@ -3640,4 +5028,5 @@ exports.updateWorkspace = updateWorkspace;
|
|
3640
5028
|
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
3641
5029
|
exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
|
3642
5030
|
exports.upsertRecordWithID = upsertRecordWithID;
|
5031
|
+
exports.vectorSearchTable = vectorSearchTable;
|
3643
5032
|
//# sourceMappingURL=index.cjs.map
|