@xata.io/client 0.0.0-alpha.vfe07d64 → 0.0.0-alpha.vfe2d35daeb67fe5687ae597dfaeff7494139827f
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 +1 -1
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +253 -1
- package/dist/index.cjs +1664 -378
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4526 -2360
- package/dist/index.mjs +1621 -375
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -3
- package/.eslintrc.cjs +0 -13
- package/rollup.config.mjs +0 -44
- 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,37 +197,48 @@ 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
|
-
|
176
|
-
|
177
|
-
}
|
210
|
+
const { apiKey } = getEnvironment();
|
211
|
+
return apiKey;
|
178
212
|
} catch (err) {
|
213
|
+
return void 0;
|
179
214
|
}
|
215
|
+
}
|
216
|
+
function getBranch() {
|
180
217
|
try {
|
181
|
-
|
182
|
-
|
183
|
-
return new TextDecoder().decode(await process2.output()).trim();
|
184
|
-
}
|
218
|
+
const { branch } = getEnvironment();
|
219
|
+
return branch;
|
185
220
|
} catch (err) {
|
221
|
+
return void 0;
|
186
222
|
}
|
187
223
|
}
|
188
|
-
|
189
|
-
|
224
|
+
function buildPreviewBranchName({ org, branch }) {
|
225
|
+
return `preview-${org}-${branch}`;
|
226
|
+
}
|
227
|
+
function getPreviewBranch() {
|
190
228
|
try {
|
191
|
-
const {
|
192
|
-
|
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;
|
193
242
|
} catch (err) {
|
194
243
|
return void 0;
|
195
244
|
}
|
@@ -218,13 +267,13 @@ var __privateMethod$4 = (obj, member, method) => {
|
|
218
267
|
return method;
|
219
268
|
};
|
220
269
|
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
270
|
+
const REQUEST_TIMEOUT = 5 * 60 * 1e3;
|
221
271
|
function getFetchImplementation(userFetch) {
|
222
272
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
223
|
-
const
|
273
|
+
const globalThisFetch = typeof globalThis !== "undefined" ? globalThis.fetch : void 0;
|
274
|
+
const fetchImpl = userFetch ?? globalFetch ?? globalThisFetch;
|
224
275
|
if (!fetchImpl) {
|
225
|
-
throw new Error(
|
226
|
-
`Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
|
227
|
-
);
|
276
|
+
throw new Error(`Couldn't find a global \`fetch\`. Pass a fetch implementation explicitly.`);
|
228
277
|
}
|
229
278
|
return fetchImpl;
|
230
279
|
}
|
@@ -249,18 +298,22 @@ class ApiRequestPool {
|
|
249
298
|
return __privateGet$8(this, _fetch);
|
250
299
|
}
|
251
300
|
request(url, options) {
|
252
|
-
const start = new Date();
|
253
|
-
const
|
301
|
+
const start = /* @__PURE__ */ new Date();
|
302
|
+
const fetchImpl = this.getFetch();
|
254
303
|
const runRequest = async (stalled = false) => {
|
255
|
-
const
|
304
|
+
const { promise, cancel } = timeoutWithCancel(REQUEST_TIMEOUT);
|
305
|
+
const response = await Promise.race([fetchImpl(url, options), promise.then(() => null)]).finally(cancel);
|
306
|
+
if (!response) {
|
307
|
+
throw new Error("Request timed out");
|
308
|
+
}
|
256
309
|
if (response.status === 429) {
|
257
310
|
const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
|
258
311
|
await timeout(rateLimitReset * 1e3);
|
259
312
|
return await runRequest(true);
|
260
313
|
}
|
261
314
|
if (stalled) {
|
262
|
-
const stalledTime = new Date().getTime() - start.getTime();
|
263
|
-
console.warn(`A request to Xata hit
|
315
|
+
const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
|
316
|
+
console.warn(`A request to Xata hit branch rate limits, was retried and stalled for ${stalledTime}ms`);
|
264
317
|
}
|
265
318
|
return response;
|
266
319
|
};
|
@@ -302,7 +355,180 @@ function generateUUID() {
|
|
302
355
|
});
|
303
356
|
}
|
304
357
|
|
305
|
-
|
358
|
+
async function getBytes(stream, onChunk) {
|
359
|
+
const reader = stream.getReader();
|
360
|
+
let result;
|
361
|
+
while (!(result = await reader.read()).done) {
|
362
|
+
onChunk(result.value);
|
363
|
+
}
|
364
|
+
}
|
365
|
+
function getLines(onLine) {
|
366
|
+
let buffer;
|
367
|
+
let position;
|
368
|
+
let fieldLength;
|
369
|
+
let discardTrailingNewline = false;
|
370
|
+
return function onChunk(arr) {
|
371
|
+
if (buffer === void 0) {
|
372
|
+
buffer = arr;
|
373
|
+
position = 0;
|
374
|
+
fieldLength = -1;
|
375
|
+
} else {
|
376
|
+
buffer = concat(buffer, arr);
|
377
|
+
}
|
378
|
+
const bufLength = buffer.length;
|
379
|
+
let lineStart = 0;
|
380
|
+
while (position < bufLength) {
|
381
|
+
if (discardTrailingNewline) {
|
382
|
+
if (buffer[position] === 10 /* NewLine */) {
|
383
|
+
lineStart = ++position;
|
384
|
+
}
|
385
|
+
discardTrailingNewline = false;
|
386
|
+
}
|
387
|
+
let lineEnd = -1;
|
388
|
+
for (; position < bufLength && lineEnd === -1; ++position) {
|
389
|
+
switch (buffer[position]) {
|
390
|
+
case 58 /* Colon */:
|
391
|
+
if (fieldLength === -1) {
|
392
|
+
fieldLength = position - lineStart;
|
393
|
+
}
|
394
|
+
break;
|
395
|
+
case 13 /* CarriageReturn */:
|
396
|
+
discardTrailingNewline = true;
|
397
|
+
case 10 /* NewLine */:
|
398
|
+
lineEnd = position;
|
399
|
+
break;
|
400
|
+
}
|
401
|
+
}
|
402
|
+
if (lineEnd === -1) {
|
403
|
+
break;
|
404
|
+
}
|
405
|
+
onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
|
406
|
+
lineStart = position;
|
407
|
+
fieldLength = -1;
|
408
|
+
}
|
409
|
+
if (lineStart === bufLength) {
|
410
|
+
buffer = void 0;
|
411
|
+
} else if (lineStart !== 0) {
|
412
|
+
buffer = buffer.subarray(lineStart);
|
413
|
+
position -= lineStart;
|
414
|
+
}
|
415
|
+
};
|
416
|
+
}
|
417
|
+
function getMessages(onId, onRetry, onMessage) {
|
418
|
+
let message = newMessage();
|
419
|
+
const decoder = new TextDecoder();
|
420
|
+
return function onLine(line, fieldLength) {
|
421
|
+
if (line.length === 0) {
|
422
|
+
onMessage?.(message);
|
423
|
+
message = newMessage();
|
424
|
+
} else if (fieldLength > 0) {
|
425
|
+
const field = decoder.decode(line.subarray(0, fieldLength));
|
426
|
+
const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
|
427
|
+
const value = decoder.decode(line.subarray(valueOffset));
|
428
|
+
switch (field) {
|
429
|
+
case "data":
|
430
|
+
message.data = message.data ? message.data + "\n" + value : value;
|
431
|
+
break;
|
432
|
+
case "event":
|
433
|
+
message.event = value;
|
434
|
+
break;
|
435
|
+
case "id":
|
436
|
+
onId(message.id = value);
|
437
|
+
break;
|
438
|
+
case "retry":
|
439
|
+
const retry = parseInt(value, 10);
|
440
|
+
if (!isNaN(retry)) {
|
441
|
+
onRetry(message.retry = retry);
|
442
|
+
}
|
443
|
+
break;
|
444
|
+
}
|
445
|
+
}
|
446
|
+
};
|
447
|
+
}
|
448
|
+
function concat(a, b) {
|
449
|
+
const res = new Uint8Array(a.length + b.length);
|
450
|
+
res.set(a);
|
451
|
+
res.set(b, a.length);
|
452
|
+
return res;
|
453
|
+
}
|
454
|
+
function newMessage() {
|
455
|
+
return {
|
456
|
+
data: "",
|
457
|
+
event: "",
|
458
|
+
id: "",
|
459
|
+
retry: void 0
|
460
|
+
};
|
461
|
+
}
|
462
|
+
const EventStreamContentType = "text/event-stream";
|
463
|
+
const LastEventId = "last-event-id";
|
464
|
+
function fetchEventSource(input, {
|
465
|
+
signal: inputSignal,
|
466
|
+
headers: inputHeaders,
|
467
|
+
onopen: inputOnOpen,
|
468
|
+
onmessage,
|
469
|
+
onclose,
|
470
|
+
onerror,
|
471
|
+
fetch: inputFetch,
|
472
|
+
...rest
|
473
|
+
}) {
|
474
|
+
return new Promise((resolve, reject) => {
|
475
|
+
const headers = { ...inputHeaders };
|
476
|
+
if (!headers.accept) {
|
477
|
+
headers.accept = EventStreamContentType;
|
478
|
+
}
|
479
|
+
let curRequestController;
|
480
|
+
function dispose() {
|
481
|
+
curRequestController.abort();
|
482
|
+
}
|
483
|
+
inputSignal?.addEventListener("abort", () => {
|
484
|
+
dispose();
|
485
|
+
resolve();
|
486
|
+
});
|
487
|
+
const fetchImpl = inputFetch ?? fetch;
|
488
|
+
const onopen = inputOnOpen ?? defaultOnOpen;
|
489
|
+
async function create() {
|
490
|
+
curRequestController = new AbortController();
|
491
|
+
try {
|
492
|
+
const response = await fetchImpl(input, {
|
493
|
+
...rest,
|
494
|
+
headers,
|
495
|
+
signal: curRequestController.signal
|
496
|
+
});
|
497
|
+
await onopen(response);
|
498
|
+
await getBytes(
|
499
|
+
response.body,
|
500
|
+
getLines(
|
501
|
+
getMessages(
|
502
|
+
(id) => {
|
503
|
+
if (id) {
|
504
|
+
headers[LastEventId] = id;
|
505
|
+
} else {
|
506
|
+
delete headers[LastEventId];
|
507
|
+
}
|
508
|
+
},
|
509
|
+
(_retry) => {
|
510
|
+
},
|
511
|
+
onmessage
|
512
|
+
)
|
513
|
+
)
|
514
|
+
);
|
515
|
+
onclose?.();
|
516
|
+
dispose();
|
517
|
+
resolve();
|
518
|
+
} catch (err) {
|
519
|
+
}
|
520
|
+
}
|
521
|
+
create();
|
522
|
+
});
|
523
|
+
}
|
524
|
+
function defaultOnOpen(response) {
|
525
|
+
const contentType = response.headers?.get("content-type");
|
526
|
+
if (!contentType?.startsWith(EventStreamContentType)) {
|
527
|
+
throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
|
528
|
+
}
|
529
|
+
}
|
530
|
+
|
531
|
+
const VERSION = "0.28.3";
|
306
532
|
|
307
533
|
class ErrorWithCause extends Error {
|
308
534
|
constructor(message, options) {
|
@@ -345,6 +571,67 @@ function getMessage(data) {
|
|
345
571
|
}
|
346
572
|
}
|
347
573
|
|
574
|
+
function getHostUrl(provider, type) {
|
575
|
+
if (isHostProviderAlias(provider)) {
|
576
|
+
return providers[provider][type];
|
577
|
+
} else if (isHostProviderBuilder(provider)) {
|
578
|
+
return provider[type];
|
579
|
+
}
|
580
|
+
throw new Error("Invalid API provider");
|
581
|
+
}
|
582
|
+
const providers = {
|
583
|
+
production: {
|
584
|
+
main: "https://api.xata.io",
|
585
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
586
|
+
},
|
587
|
+
staging: {
|
588
|
+
main: "https://api.staging-xata.dev",
|
589
|
+
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
590
|
+
},
|
591
|
+
dev: {
|
592
|
+
main: "https://api.dev-xata.dev",
|
593
|
+
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
594
|
+
},
|
595
|
+
local: {
|
596
|
+
main: "http://localhost:6001",
|
597
|
+
workspaces: "http://{workspaceId}.{region}.localhost:6001"
|
598
|
+
}
|
599
|
+
};
|
600
|
+
function isHostProviderAlias(alias) {
|
601
|
+
return isString(alias) && Object.keys(providers).includes(alias);
|
602
|
+
}
|
603
|
+
function isHostProviderBuilder(builder) {
|
604
|
+
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
605
|
+
}
|
606
|
+
function parseProviderString(provider = "production") {
|
607
|
+
if (isHostProviderAlias(provider)) {
|
608
|
+
return provider;
|
609
|
+
}
|
610
|
+
const [main, workspaces] = provider.split(",");
|
611
|
+
if (!main || !workspaces)
|
612
|
+
return null;
|
613
|
+
return { main, workspaces };
|
614
|
+
}
|
615
|
+
function buildProviderString(provider) {
|
616
|
+
if (isHostProviderAlias(provider))
|
617
|
+
return provider;
|
618
|
+
return `${provider.main},${provider.workspaces}`;
|
619
|
+
}
|
620
|
+
function parseWorkspacesUrlParts(url) {
|
621
|
+
if (!isString(url))
|
622
|
+
return null;
|
623
|
+
const matches = {
|
624
|
+
production: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/),
|
625
|
+
staging: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/),
|
626
|
+
dev: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/),
|
627
|
+
local: url.match(/(?:https?:\/\/)?([^.]+)\.localhost:(\d+)/)
|
628
|
+
};
|
629
|
+
const [host, match] = Object.entries(matches).find(([, match2]) => match2 !== null) ?? [];
|
630
|
+
if (!isHostProviderAlias(host) || !match)
|
631
|
+
return null;
|
632
|
+
return { workspace: match[1], region: match[2], host };
|
633
|
+
}
|
634
|
+
|
348
635
|
const pool = new ApiRequestPool();
|
349
636
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
350
637
|
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
@@ -360,6 +647,7 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
360
647
|
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
361
648
|
};
|
362
649
|
function buildBaseUrl({
|
650
|
+
method,
|
363
651
|
endpoint,
|
364
652
|
path,
|
365
653
|
workspacesApiUrl,
|
@@ -367,7 +655,24 @@ function buildBaseUrl({
|
|
367
655
|
pathParams = {}
|
368
656
|
}) {
|
369
657
|
if (endpoint === "dataPlane") {
|
370
|
-
|
658
|
+
let url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
659
|
+
if (method.toUpperCase() === "PUT" && [
|
660
|
+
"/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
661
|
+
"/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}"
|
662
|
+
].includes(path)) {
|
663
|
+
const { host } = parseWorkspacesUrlParts(url) ?? {};
|
664
|
+
switch (host) {
|
665
|
+
case "production":
|
666
|
+
url = url.replace("xata.sh", "upload.xata.sh");
|
667
|
+
break;
|
668
|
+
case "staging":
|
669
|
+
url = url.replace("staging-xata.dev", "upload.staging-xata.dev");
|
670
|
+
break;
|
671
|
+
case "dev":
|
672
|
+
url = url.replace("dev-xata.dev", "upload.dev-xata.dev");
|
673
|
+
break;
|
674
|
+
}
|
675
|
+
}
|
371
676
|
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
372
677
|
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
373
678
|
}
|
@@ -378,6 +683,18 @@ function hostHeader(url) {
|
|
378
683
|
const { groups } = pattern.exec(url) ?? {};
|
379
684
|
return groups?.host ? { Host: groups.host } : {};
|
380
685
|
}
|
686
|
+
async function parseBody(body, headers) {
|
687
|
+
if (!isDefined(body))
|
688
|
+
return void 0;
|
689
|
+
if (isBlob(body) || typeof body.text === "function") {
|
690
|
+
return body;
|
691
|
+
}
|
692
|
+
const { "Content-Type": contentType } = headers ?? {};
|
693
|
+
if (String(contentType).toLowerCase() === "application/json" && isObject(body)) {
|
694
|
+
return JSON.stringify(body);
|
695
|
+
}
|
696
|
+
return body;
|
697
|
+
}
|
381
698
|
const defaultClientID = generateUUID();
|
382
699
|
async function fetch$1({
|
383
700
|
url: path,
|
@@ -386,7 +703,7 @@ async function fetch$1({
|
|
386
703
|
headers: customHeaders,
|
387
704
|
pathParams,
|
388
705
|
queryParams,
|
389
|
-
|
706
|
+
fetch: fetch2,
|
390
707
|
apiKey,
|
391
708
|
endpoint,
|
392
709
|
apiUrl,
|
@@ -397,13 +714,14 @@ async function fetch$1({
|
|
397
714
|
sessionID,
|
398
715
|
clientName,
|
399
716
|
xataAgentExtra,
|
400
|
-
fetchOptions = {}
|
717
|
+
fetchOptions = {},
|
718
|
+
rawResponse = false
|
401
719
|
}) {
|
402
|
-
pool.setFetch(
|
720
|
+
pool.setFetch(fetch2);
|
403
721
|
return await trace(
|
404
722
|
`${method.toUpperCase()} ${path}`,
|
405
723
|
async ({ setAttributes }) => {
|
406
|
-
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
724
|
+
const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
407
725
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
408
726
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
409
727
|
setAttributes({
|
@@ -416,7 +734,7 @@ async function fetch$1({
|
|
416
734
|
isDefined(clientName) ? ["service", clientName] : void 0,
|
417
735
|
...Object.entries(xataAgentExtra ?? {})
|
418
736
|
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
419
|
-
const headers = {
|
737
|
+
const headers = compactObject({
|
420
738
|
"Accept-Encoding": "identity",
|
421
739
|
"Content-Type": "application/json",
|
422
740
|
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
@@ -425,11 +743,11 @@ async function fetch$1({
|
|
425
743
|
...customHeaders,
|
426
744
|
...hostHeader(fullUrl),
|
427
745
|
Authorization: `Bearer ${apiKey}`
|
428
|
-
};
|
746
|
+
});
|
429
747
|
const response = await pool.request(url, {
|
430
748
|
...fetchOptions,
|
431
749
|
method: method.toUpperCase(),
|
432
|
-
body:
|
750
|
+
body: await parseBody(body, headers),
|
433
751
|
headers,
|
434
752
|
signal
|
435
753
|
});
|
@@ -440,8 +758,12 @@ async function fetch$1({
|
|
440
758
|
[TraceAttributes.HTTP_REQUEST_ID]: requestId,
|
441
759
|
[TraceAttributes.HTTP_STATUS_CODE]: response.status,
|
442
760
|
[TraceAttributes.HTTP_HOST]: host,
|
443
|
-
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
761
|
+
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", ""),
|
762
|
+
[TraceAttributes.CLOUDFLARE_RAY_ID]: response.headers?.get("cf-ray") ?? void 0
|
444
763
|
});
|
764
|
+
const message = response.headers?.get("x-xata-message");
|
765
|
+
if (message)
|
766
|
+
console.warn(message);
|
445
767
|
if (response.status === 204) {
|
446
768
|
return {};
|
447
769
|
}
|
@@ -449,7 +771,7 @@ async function fetch$1({
|
|
449
771
|
throw new FetcherError(response.status, "Rate limit exceeded", requestId);
|
450
772
|
}
|
451
773
|
try {
|
452
|
-
const jsonResponse = await response.json();
|
774
|
+
const jsonResponse = rawResponse ? await response.blob() : await response.json();
|
453
775
|
if (response.ok) {
|
454
776
|
return jsonResponse;
|
455
777
|
}
|
@@ -461,6 +783,59 @@ async function fetch$1({
|
|
461
783
|
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
462
784
|
);
|
463
785
|
}
|
786
|
+
function fetchSSERequest({
|
787
|
+
url: path,
|
788
|
+
method,
|
789
|
+
body,
|
790
|
+
headers: customHeaders,
|
791
|
+
pathParams,
|
792
|
+
queryParams,
|
793
|
+
fetch: fetch2,
|
794
|
+
apiKey,
|
795
|
+
endpoint,
|
796
|
+
apiUrl,
|
797
|
+
workspacesApiUrl,
|
798
|
+
onMessage,
|
799
|
+
onError,
|
800
|
+
onClose,
|
801
|
+
signal,
|
802
|
+
clientID,
|
803
|
+
sessionID,
|
804
|
+
clientName,
|
805
|
+
xataAgentExtra
|
806
|
+
}) {
|
807
|
+
const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
808
|
+
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
809
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
810
|
+
void fetchEventSource(url, {
|
811
|
+
method,
|
812
|
+
body: JSON.stringify(body),
|
813
|
+
fetch: fetch2,
|
814
|
+
signal,
|
815
|
+
headers: {
|
816
|
+
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
817
|
+
"X-Xata-Session-ID": sessionID ?? generateUUID(),
|
818
|
+
"X-Xata-Agent": compact([
|
819
|
+
["client", "TS_SDK"],
|
820
|
+
["version", VERSION],
|
821
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
822
|
+
...Object.entries(xataAgentExtra ?? {})
|
823
|
+
]).map(([key, value]) => `${key}=${value}`).join("; "),
|
824
|
+
...customHeaders,
|
825
|
+
Authorization: `Bearer ${apiKey}`,
|
826
|
+
"Content-Type": "application/json"
|
827
|
+
},
|
828
|
+
onmessage(ev) {
|
829
|
+
onMessage?.(JSON.parse(ev.data));
|
830
|
+
},
|
831
|
+
onerror(ev) {
|
832
|
+
onError?.(JSON.parse(ev.data));
|
833
|
+
},
|
834
|
+
onclose() {
|
835
|
+
onClose?.();
|
836
|
+
}
|
837
|
+
});
|
838
|
+
}
|
464
839
|
function parseUrl(url) {
|
465
840
|
try {
|
466
841
|
const { host, protocol } = new URL(url);
|
@@ -472,6 +847,19 @@ function parseUrl(url) {
|
|
472
847
|
|
473
848
|
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
474
849
|
|
850
|
+
const applyMigration = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/pgroll/apply", method: "post", ...variables, signal });
|
851
|
+
const pgRollStatus = (variables, signal) => dataPlaneFetch({
|
852
|
+
url: "/db/{dbBranchName}/pgroll/status",
|
853
|
+
method: "get",
|
854
|
+
...variables,
|
855
|
+
signal
|
856
|
+
});
|
857
|
+
const pgRollJobStatus = (variables, signal) => dataPlaneFetch({
|
858
|
+
url: "/db/{dbBranchName}/pgroll/jobs/{jobId}",
|
859
|
+
method: "get",
|
860
|
+
...variables,
|
861
|
+
signal
|
862
|
+
});
|
475
863
|
const getBranchList = (variables, signal) => dataPlaneFetch({
|
476
864
|
url: "/dbs/{dbName}",
|
477
865
|
method: "get",
|
@@ -491,6 +879,18 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
|
|
491
879
|
...variables,
|
492
880
|
signal
|
493
881
|
});
|
882
|
+
const getSchema = (variables, signal) => dataPlaneFetch({
|
883
|
+
url: "/db/{dbBranchName}/schema",
|
884
|
+
method: "get",
|
885
|
+
...variables,
|
886
|
+
signal
|
887
|
+
});
|
888
|
+
const copyBranch = (variables, signal) => dataPlaneFetch({
|
889
|
+
url: "/db/{dbBranchName}/copy",
|
890
|
+
method: "post",
|
891
|
+
...variables,
|
892
|
+
signal
|
893
|
+
});
|
494
894
|
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
495
895
|
url: "/db/{dbBranchName}/metadata",
|
496
896
|
method: "put",
|
@@ -540,6 +940,7 @@ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{
|
|
540
940
|
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
541
941
|
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
542
942
|
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
943
|
+
const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
|
543
944
|
const createTable = (variables, signal) => dataPlaneFetch({
|
544
945
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
545
946
|
method: "put",
|
@@ -584,6 +985,42 @@ const deleteColumn = (variables, signal) => dataPlaneFetch({
|
|
584
985
|
});
|
585
986
|
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
586
987
|
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
988
|
+
const getFileItem = (variables, signal) => dataPlaneFetch({
|
989
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
990
|
+
method: "get",
|
991
|
+
...variables,
|
992
|
+
signal
|
993
|
+
});
|
994
|
+
const putFileItem = (variables, signal) => dataPlaneFetch({
|
995
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
996
|
+
method: "put",
|
997
|
+
...variables,
|
998
|
+
signal
|
999
|
+
});
|
1000
|
+
const deleteFileItem = (variables, signal) => dataPlaneFetch({
|
1001
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
1002
|
+
method: "delete",
|
1003
|
+
...variables,
|
1004
|
+
signal
|
1005
|
+
});
|
1006
|
+
const getFile = (variables, signal) => dataPlaneFetch({
|
1007
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
1008
|
+
method: "get",
|
1009
|
+
...variables,
|
1010
|
+
signal
|
1011
|
+
});
|
1012
|
+
const putFile = (variables, signal) => dataPlaneFetch({
|
1013
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
1014
|
+
method: "put",
|
1015
|
+
...variables,
|
1016
|
+
signal
|
1017
|
+
});
|
1018
|
+
const deleteFile = (variables, signal) => dataPlaneFetch({
|
1019
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
1020
|
+
method: "delete",
|
1021
|
+
...variables,
|
1022
|
+
signal
|
1023
|
+
});
|
587
1024
|
const getRecord = (variables, signal) => dataPlaneFetch({
|
588
1025
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
589
1026
|
method: "get",
|
@@ -613,14 +1050,44 @@ const searchTable = (variables, signal) => dataPlaneFetch({
|
|
613
1050
|
...variables,
|
614
1051
|
signal
|
615
1052
|
});
|
1053
|
+
const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
|
1054
|
+
const askTable = (variables, signal) => dataPlaneFetch({
|
1055
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
1056
|
+
method: "post",
|
1057
|
+
...variables,
|
1058
|
+
signal
|
1059
|
+
});
|
1060
|
+
const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
|
616
1061
|
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
617
1062
|
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
1063
|
+
const fileAccess = (variables, signal) => dataPlaneFetch({
|
1064
|
+
url: "/file/{fileId}",
|
1065
|
+
method: "get",
|
1066
|
+
...variables,
|
1067
|
+
signal
|
1068
|
+
});
|
1069
|
+
const fileUpload = (variables, signal) => dataPlaneFetch({
|
1070
|
+
url: "/file/{fileId}",
|
1071
|
+
method: "put",
|
1072
|
+
...variables,
|
1073
|
+
signal
|
1074
|
+
});
|
1075
|
+
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
1076
|
+
url: "/db/{dbBranchName}/sql",
|
1077
|
+
method: "post",
|
1078
|
+
...variables,
|
1079
|
+
signal
|
1080
|
+
});
|
618
1081
|
const operationsByTag$2 = {
|
619
1082
|
branch: {
|
1083
|
+
applyMigration,
|
1084
|
+
pgRollStatus,
|
1085
|
+
pgRollJobStatus,
|
620
1086
|
getBranchList,
|
621
1087
|
getBranchDetails,
|
622
1088
|
createBranch,
|
623
1089
|
deleteBranch,
|
1090
|
+
copyBranch,
|
624
1091
|
updateBranchMetadata,
|
625
1092
|
getBranchMetadata,
|
626
1093
|
getBranchStats,
|
@@ -630,6 +1097,7 @@ const operationsByTag$2 = {
|
|
630
1097
|
resolveBranch
|
631
1098
|
},
|
632
1099
|
migrations: {
|
1100
|
+
getSchema,
|
633
1101
|
getBranchMigrationHistory,
|
634
1102
|
getBranchMigrationPlan,
|
635
1103
|
executeBranchMigrationPlan,
|
@@ -638,7 +1106,8 @@ const operationsByTag$2 = {
|
|
638
1106
|
compareBranchSchemas,
|
639
1107
|
updateBranchSchema,
|
640
1108
|
previewBranchSchemaEdit,
|
641
|
-
applyBranchSchemaEdit
|
1109
|
+
applyBranchSchemaEdit,
|
1110
|
+
pushBranchMigrations
|
642
1111
|
},
|
643
1112
|
migrationRequests: {
|
644
1113
|
queryMigrationRequests,
|
@@ -672,11 +1141,24 @@ const operationsByTag$2 = {
|
|
672
1141
|
deleteRecord,
|
673
1142
|
bulkInsertTableRecords
|
674
1143
|
},
|
675
|
-
|
1144
|
+
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess, fileUpload },
|
1145
|
+
searchAndFilter: {
|
1146
|
+
queryTable,
|
1147
|
+
searchBranch,
|
1148
|
+
searchTable,
|
1149
|
+
vectorSearchTable,
|
1150
|
+
askTable,
|
1151
|
+
askTableSession,
|
1152
|
+
summarizeTable,
|
1153
|
+
aggregateTable
|
1154
|
+
},
|
1155
|
+
sql: { sqlQuery }
|
676
1156
|
};
|
677
1157
|
|
678
1158
|
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
679
1159
|
|
1160
|
+
const getAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "get", ...variables, signal });
|
1161
|
+
const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
|
680
1162
|
const getUser = (variables, signal) => controlPlaneFetch({
|
681
1163
|
url: "/user",
|
682
1164
|
method: "get",
|
@@ -713,6 +1195,31 @@ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
|
713
1195
|
...variables,
|
714
1196
|
signal
|
715
1197
|
});
|
1198
|
+
const getUserOAuthClients = (variables, signal) => controlPlaneFetch({
|
1199
|
+
url: "/user/oauth/clients",
|
1200
|
+
method: "get",
|
1201
|
+
...variables,
|
1202
|
+
signal
|
1203
|
+
});
|
1204
|
+
const deleteUserOAuthClient = (variables, signal) => controlPlaneFetch({
|
1205
|
+
url: "/user/oauth/clients/{clientId}",
|
1206
|
+
method: "delete",
|
1207
|
+
...variables,
|
1208
|
+
signal
|
1209
|
+
});
|
1210
|
+
const getUserOAuthAccessTokens = (variables, signal) => controlPlaneFetch({
|
1211
|
+
url: "/user/oauth/tokens",
|
1212
|
+
method: "get",
|
1213
|
+
...variables,
|
1214
|
+
signal
|
1215
|
+
});
|
1216
|
+
const deleteOAuthAccessToken = (variables, signal) => controlPlaneFetch({
|
1217
|
+
url: "/user/oauth/tokens/{token}",
|
1218
|
+
method: "delete",
|
1219
|
+
...variables,
|
1220
|
+
signal
|
1221
|
+
});
|
1222
|
+
const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({ url: "/user/oauth/tokens/{token}", method: "patch", ...variables, signal });
|
716
1223
|
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
717
1224
|
url: "/workspaces",
|
718
1225
|
method: "get",
|
@@ -756,6 +1263,20 @@ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ u
|
|
756
1263
|
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
757
1264
|
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
758
1265
|
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
1266
|
+
const listClusters = (variables, signal) => controlPlaneFetch({
|
1267
|
+
url: "/workspaces/{workspaceId}/clusters",
|
1268
|
+
method: "get",
|
1269
|
+
...variables,
|
1270
|
+
signal
|
1271
|
+
});
|
1272
|
+
const createCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "post", ...variables, signal });
|
1273
|
+
const getCluster = (variables, signal) => controlPlaneFetch({
|
1274
|
+
url: "/workspaces/{workspaceId}/clusters/{clusterId}",
|
1275
|
+
method: "get",
|
1276
|
+
...variables,
|
1277
|
+
signal
|
1278
|
+
});
|
1279
|
+
const updateCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters/{clusterId}", method: "patch", ...variables, signal });
|
759
1280
|
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
760
1281
|
url: "/workspaces/{workspaceId}/dbs",
|
761
1282
|
method: "get",
|
@@ -771,6 +1292,7 @@ const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
|
771
1292
|
});
|
772
1293
|
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
773
1294
|
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
1295
|
+
const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
|
774
1296
|
const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
|
775
1297
|
const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
|
776
1298
|
const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
|
@@ -781,6 +1303,15 @@ const listRegions = (variables, signal) => controlPlaneFetch({
|
|
781
1303
|
signal
|
782
1304
|
});
|
783
1305
|
const operationsByTag$1 = {
|
1306
|
+
oAuth: {
|
1307
|
+
getAuthorizationCode,
|
1308
|
+
grantAuthorizationCode,
|
1309
|
+
getUserOAuthClients,
|
1310
|
+
deleteUserOAuthClient,
|
1311
|
+
getUserOAuthAccessTokens,
|
1312
|
+
deleteOAuthAccessToken,
|
1313
|
+
updateOAuthAccessToken
|
1314
|
+
},
|
784
1315
|
users: { getUser, updateUser, deleteUser },
|
785
1316
|
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
786
1317
|
workspaces: {
|
@@ -800,12 +1331,14 @@ const operationsByTag$1 = {
|
|
800
1331
|
acceptWorkspaceMemberInvite,
|
801
1332
|
resendWorkspaceMemberInvite
|
802
1333
|
},
|
1334
|
+
xbcontrolOther: { listClusters, createCluster, getCluster, updateCluster },
|
803
1335
|
databases: {
|
804
1336
|
getDatabaseList,
|
805
1337
|
createDatabase,
|
806
1338
|
deleteDatabase,
|
807
1339
|
getDatabaseMetadata,
|
808
1340
|
updateDatabaseMetadata,
|
1341
|
+
renameDatabase,
|
809
1342
|
getDatabaseGithubSettings,
|
810
1343
|
updateDatabaseGithubSettings,
|
811
1344
|
deleteDatabaseGithubSettings,
|
@@ -815,51 +1348,6 @@ const operationsByTag$1 = {
|
|
815
1348
|
|
816
1349
|
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
817
1350
|
|
818
|
-
function getHostUrl(provider, type) {
|
819
|
-
if (isHostProviderAlias(provider)) {
|
820
|
-
return providers[provider][type];
|
821
|
-
} else if (isHostProviderBuilder(provider)) {
|
822
|
-
return provider[type];
|
823
|
-
}
|
824
|
-
throw new Error("Invalid API provider");
|
825
|
-
}
|
826
|
-
const providers = {
|
827
|
-
production: {
|
828
|
-
main: "https://api.xata.io",
|
829
|
-
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
830
|
-
},
|
831
|
-
staging: {
|
832
|
-
main: "https://staging.xatabase.co",
|
833
|
-
workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
|
834
|
-
}
|
835
|
-
};
|
836
|
-
function isHostProviderAlias(alias) {
|
837
|
-
return isString(alias) && Object.keys(providers).includes(alias);
|
838
|
-
}
|
839
|
-
function isHostProviderBuilder(builder) {
|
840
|
-
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
841
|
-
}
|
842
|
-
function parseProviderString(provider = "production") {
|
843
|
-
if (isHostProviderAlias(provider)) {
|
844
|
-
return provider;
|
845
|
-
}
|
846
|
-
const [main, workspaces] = provider.split(",");
|
847
|
-
if (!main || !workspaces)
|
848
|
-
return null;
|
849
|
-
return { main, workspaces };
|
850
|
-
}
|
851
|
-
function parseWorkspacesUrlParts(url) {
|
852
|
-
if (!isString(url))
|
853
|
-
return null;
|
854
|
-
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
855
|
-
const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))\.xatabase\.co.*/;
|
856
|
-
const regexDev = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))\.xata\.tech.*/;
|
857
|
-
const match = url.match(regex) || url.match(regexStaging) || url.match(regexDev);
|
858
|
-
if (!match)
|
859
|
-
return null;
|
860
|
-
return { workspace: match[1], region: match[2] };
|
861
|
-
}
|
862
|
-
|
863
1351
|
var __accessCheck$7 = (obj, member, msg) => {
|
864
1352
|
if (!member.has(obj))
|
865
1353
|
throw TypeError("Cannot " + msg);
|
@@ -893,7 +1381,7 @@ class XataApiClient {
|
|
893
1381
|
__privateSet$7(this, _extraProps, {
|
894
1382
|
apiUrl: getHostUrl(provider, "main"),
|
895
1383
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
896
|
-
|
1384
|
+
fetch: getFetchImplementation(options.fetch),
|
897
1385
|
apiKey,
|
898
1386
|
trace,
|
899
1387
|
clientName: options.clientName,
|
@@ -951,6 +1439,11 @@ class XataApiClient {
|
|
951
1439
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
952
1440
|
return __privateGet$7(this, _namespaces).records;
|
953
1441
|
}
|
1442
|
+
get files() {
|
1443
|
+
if (!__privateGet$7(this, _namespaces).files)
|
1444
|
+
__privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
|
1445
|
+
return __privateGet$7(this, _namespaces).files;
|
1446
|
+
}
|
954
1447
|
get searchAndFilter() {
|
955
1448
|
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
956
1449
|
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
@@ -1159,6 +1652,20 @@ class BranchApi {
|
|
1159
1652
|
...this.extraProps
|
1160
1653
|
});
|
1161
1654
|
}
|
1655
|
+
copyBranch({
|
1656
|
+
workspace,
|
1657
|
+
region,
|
1658
|
+
database,
|
1659
|
+
branch,
|
1660
|
+
destinationBranch,
|
1661
|
+
limit
|
1662
|
+
}) {
|
1663
|
+
return operationsByTag.branch.copyBranch({
|
1664
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1665
|
+
body: { destinationBranch, limit },
|
1666
|
+
...this.extraProps
|
1667
|
+
});
|
1668
|
+
}
|
1162
1669
|
updateBranchMetadata({
|
1163
1670
|
workspace,
|
1164
1671
|
region,
|
@@ -1514,6 +2021,164 @@ class RecordsApi {
|
|
1514
2021
|
});
|
1515
2022
|
}
|
1516
2023
|
}
|
2024
|
+
class FilesApi {
|
2025
|
+
constructor(extraProps) {
|
2026
|
+
this.extraProps = extraProps;
|
2027
|
+
}
|
2028
|
+
getFileItem({
|
2029
|
+
workspace,
|
2030
|
+
region,
|
2031
|
+
database,
|
2032
|
+
branch,
|
2033
|
+
table,
|
2034
|
+
record,
|
2035
|
+
column,
|
2036
|
+
fileId
|
2037
|
+
}) {
|
2038
|
+
return operationsByTag.files.getFileItem({
|
2039
|
+
pathParams: {
|
2040
|
+
workspace,
|
2041
|
+
region,
|
2042
|
+
dbBranchName: `${database}:${branch}`,
|
2043
|
+
tableName: table,
|
2044
|
+
recordId: record,
|
2045
|
+
columnName: column,
|
2046
|
+
fileId
|
2047
|
+
},
|
2048
|
+
...this.extraProps
|
2049
|
+
});
|
2050
|
+
}
|
2051
|
+
putFileItem({
|
2052
|
+
workspace,
|
2053
|
+
region,
|
2054
|
+
database,
|
2055
|
+
branch,
|
2056
|
+
table,
|
2057
|
+
record,
|
2058
|
+
column,
|
2059
|
+
fileId,
|
2060
|
+
file
|
2061
|
+
}) {
|
2062
|
+
return operationsByTag.files.putFileItem({
|
2063
|
+
pathParams: {
|
2064
|
+
workspace,
|
2065
|
+
region,
|
2066
|
+
dbBranchName: `${database}:${branch}`,
|
2067
|
+
tableName: table,
|
2068
|
+
recordId: record,
|
2069
|
+
columnName: column,
|
2070
|
+
fileId
|
2071
|
+
},
|
2072
|
+
// @ts-ignore
|
2073
|
+
body: file,
|
2074
|
+
...this.extraProps
|
2075
|
+
});
|
2076
|
+
}
|
2077
|
+
deleteFileItem({
|
2078
|
+
workspace,
|
2079
|
+
region,
|
2080
|
+
database,
|
2081
|
+
branch,
|
2082
|
+
table,
|
2083
|
+
record,
|
2084
|
+
column,
|
2085
|
+
fileId
|
2086
|
+
}) {
|
2087
|
+
return operationsByTag.files.deleteFileItem({
|
2088
|
+
pathParams: {
|
2089
|
+
workspace,
|
2090
|
+
region,
|
2091
|
+
dbBranchName: `${database}:${branch}`,
|
2092
|
+
tableName: table,
|
2093
|
+
recordId: record,
|
2094
|
+
columnName: column,
|
2095
|
+
fileId
|
2096
|
+
},
|
2097
|
+
...this.extraProps
|
2098
|
+
});
|
2099
|
+
}
|
2100
|
+
getFile({
|
2101
|
+
workspace,
|
2102
|
+
region,
|
2103
|
+
database,
|
2104
|
+
branch,
|
2105
|
+
table,
|
2106
|
+
record,
|
2107
|
+
column
|
2108
|
+
}) {
|
2109
|
+
return operationsByTag.files.getFile({
|
2110
|
+
pathParams: {
|
2111
|
+
workspace,
|
2112
|
+
region,
|
2113
|
+
dbBranchName: `${database}:${branch}`,
|
2114
|
+
tableName: table,
|
2115
|
+
recordId: record,
|
2116
|
+
columnName: column
|
2117
|
+
},
|
2118
|
+
...this.extraProps
|
2119
|
+
});
|
2120
|
+
}
|
2121
|
+
putFile({
|
2122
|
+
workspace,
|
2123
|
+
region,
|
2124
|
+
database,
|
2125
|
+
branch,
|
2126
|
+
table,
|
2127
|
+
record,
|
2128
|
+
column,
|
2129
|
+
file
|
2130
|
+
}) {
|
2131
|
+
return operationsByTag.files.putFile({
|
2132
|
+
pathParams: {
|
2133
|
+
workspace,
|
2134
|
+
region,
|
2135
|
+
dbBranchName: `${database}:${branch}`,
|
2136
|
+
tableName: table,
|
2137
|
+
recordId: record,
|
2138
|
+
columnName: column
|
2139
|
+
},
|
2140
|
+
body: file,
|
2141
|
+
...this.extraProps
|
2142
|
+
});
|
2143
|
+
}
|
2144
|
+
deleteFile({
|
2145
|
+
workspace,
|
2146
|
+
region,
|
2147
|
+
database,
|
2148
|
+
branch,
|
2149
|
+
table,
|
2150
|
+
record,
|
2151
|
+
column
|
2152
|
+
}) {
|
2153
|
+
return operationsByTag.files.deleteFile({
|
2154
|
+
pathParams: {
|
2155
|
+
workspace,
|
2156
|
+
region,
|
2157
|
+
dbBranchName: `${database}:${branch}`,
|
2158
|
+
tableName: table,
|
2159
|
+
recordId: record,
|
2160
|
+
columnName: column
|
2161
|
+
},
|
2162
|
+
...this.extraProps
|
2163
|
+
});
|
2164
|
+
}
|
2165
|
+
fileAccess({
|
2166
|
+
workspace,
|
2167
|
+
region,
|
2168
|
+
fileId,
|
2169
|
+
verify
|
2170
|
+
}) {
|
2171
|
+
return operationsByTag.files.fileAccess({
|
2172
|
+
pathParams: {
|
2173
|
+
workspace,
|
2174
|
+
region,
|
2175
|
+
fileId
|
2176
|
+
},
|
2177
|
+
queryParams: { verify },
|
2178
|
+
...this.extraProps
|
2179
|
+
});
|
2180
|
+
}
|
2181
|
+
}
|
1517
2182
|
class SearchAndFilterApi {
|
1518
2183
|
constructor(extraProps) {
|
1519
2184
|
this.extraProps = extraProps;
|
@@ -1573,6 +2238,53 @@ class SearchAndFilterApi {
|
|
1573
2238
|
...this.extraProps
|
1574
2239
|
});
|
1575
2240
|
}
|
2241
|
+
vectorSearchTable({
|
2242
|
+
workspace,
|
2243
|
+
region,
|
2244
|
+
database,
|
2245
|
+
branch,
|
2246
|
+
table,
|
2247
|
+
queryVector,
|
2248
|
+
column,
|
2249
|
+
similarityFunction,
|
2250
|
+
size,
|
2251
|
+
filter
|
2252
|
+
}) {
|
2253
|
+
return operationsByTag.searchAndFilter.vectorSearchTable({
|
2254
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2255
|
+
body: { queryVector, column, similarityFunction, size, filter },
|
2256
|
+
...this.extraProps
|
2257
|
+
});
|
2258
|
+
}
|
2259
|
+
askTable({
|
2260
|
+
workspace,
|
2261
|
+
region,
|
2262
|
+
database,
|
2263
|
+
branch,
|
2264
|
+
table,
|
2265
|
+
options
|
2266
|
+
}) {
|
2267
|
+
return operationsByTag.searchAndFilter.askTable({
|
2268
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2269
|
+
body: { ...options },
|
2270
|
+
...this.extraProps
|
2271
|
+
});
|
2272
|
+
}
|
2273
|
+
askTableSession({
|
2274
|
+
workspace,
|
2275
|
+
region,
|
2276
|
+
database,
|
2277
|
+
branch,
|
2278
|
+
table,
|
2279
|
+
sessionId,
|
2280
|
+
message
|
2281
|
+
}) {
|
2282
|
+
return operationsByTag.searchAndFilter.askTableSession({
|
2283
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
|
2284
|
+
body: { message },
|
2285
|
+
...this.extraProps
|
2286
|
+
});
|
2287
|
+
}
|
1576
2288
|
summarizeTable({
|
1577
2289
|
workspace,
|
1578
2290
|
region,
|
@@ -1837,6 +2549,19 @@ class MigrationsApi {
|
|
1837
2549
|
...this.extraProps
|
1838
2550
|
});
|
1839
2551
|
}
|
2552
|
+
pushBranchMigrations({
|
2553
|
+
workspace,
|
2554
|
+
region,
|
2555
|
+
database,
|
2556
|
+
branch,
|
2557
|
+
migrations
|
2558
|
+
}) {
|
2559
|
+
return operationsByTag.migrations.pushBranchMigrations({
|
2560
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2561
|
+
body: { migrations },
|
2562
|
+
...this.extraProps
|
2563
|
+
});
|
2564
|
+
}
|
1840
2565
|
}
|
1841
2566
|
class DatabaseApi {
|
1842
2567
|
constructor(extraProps) {
|
@@ -1851,11 +2576,13 @@ class DatabaseApi {
|
|
1851
2576
|
createDatabase({
|
1852
2577
|
workspace,
|
1853
2578
|
database,
|
1854
|
-
data
|
2579
|
+
data,
|
2580
|
+
headers
|
1855
2581
|
}) {
|
1856
2582
|
return operationsByTag.databases.createDatabase({
|
1857
2583
|
pathParams: { workspaceId: workspace, dbName: database },
|
1858
2584
|
body: data,
|
2585
|
+
headers,
|
1859
2586
|
...this.extraProps
|
1860
2587
|
});
|
1861
2588
|
}
|
@@ -1877,14 +2604,25 @@ class DatabaseApi {
|
|
1877
2604
|
...this.extraProps
|
1878
2605
|
});
|
1879
2606
|
}
|
1880
|
-
updateDatabaseMetadata({
|
2607
|
+
updateDatabaseMetadata({
|
2608
|
+
workspace,
|
2609
|
+
database,
|
2610
|
+
metadata
|
2611
|
+
}) {
|
2612
|
+
return operationsByTag.databases.updateDatabaseMetadata({
|
2613
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2614
|
+
body: metadata,
|
2615
|
+
...this.extraProps
|
2616
|
+
});
|
2617
|
+
}
|
2618
|
+
renameDatabase({
|
1881
2619
|
workspace,
|
1882
2620
|
database,
|
1883
|
-
|
2621
|
+
newName
|
1884
2622
|
}) {
|
1885
|
-
return operationsByTag.databases.
|
2623
|
+
return operationsByTag.databases.renameDatabase({
|
1886
2624
|
pathParams: { workspaceId: workspace, dbName: database },
|
1887
|
-
body:
|
2625
|
+
body: { newName },
|
1888
2626
|
...this.extraProps
|
1889
2627
|
});
|
1890
2628
|
}
|
@@ -1926,20 +2664,203 @@ class DatabaseApi {
|
|
1926
2664
|
}
|
1927
2665
|
|
1928
2666
|
class XataApiPlugin {
|
1929
|
-
|
1930
|
-
|
1931
|
-
return new XataApiClient({ fetch: fetchImpl, apiKey });
|
2667
|
+
build(options) {
|
2668
|
+
return new XataApiClient(options);
|
1932
2669
|
}
|
1933
2670
|
}
|
1934
2671
|
|
1935
2672
|
class XataPlugin {
|
1936
2673
|
}
|
1937
2674
|
|
2675
|
+
function buildTransformString(transformations) {
|
2676
|
+
return transformations.flatMap(
|
2677
|
+
(t) => Object.entries(t).map(([key, value]) => {
|
2678
|
+
if (key === "trim") {
|
2679
|
+
const { left = 0, top = 0, right = 0, bottom = 0 } = value;
|
2680
|
+
return `${key}=${[top, right, bottom, left].join(";")}`;
|
2681
|
+
}
|
2682
|
+
if (key === "gravity" && typeof value === "object") {
|
2683
|
+
const { x = 0.5, y = 0.5 } = value;
|
2684
|
+
return `${key}=${[x, y].join("x")}`;
|
2685
|
+
}
|
2686
|
+
return `${key}=${value}`;
|
2687
|
+
})
|
2688
|
+
).join(",");
|
2689
|
+
}
|
2690
|
+
function transformImage(url, ...transformations) {
|
2691
|
+
if (!isDefined(url))
|
2692
|
+
return void 0;
|
2693
|
+
const newTransformations = buildTransformString(transformations);
|
2694
|
+
const { hostname, pathname, search } = new URL(url);
|
2695
|
+
const pathParts = pathname.split("/");
|
2696
|
+
const transformIndex = pathParts.findIndex((part) => part === "transform");
|
2697
|
+
const removedItems = transformIndex >= 0 ? pathParts.splice(transformIndex, 2) : [];
|
2698
|
+
const transform = `/transform/${[removedItems[1], newTransformations].filter(isDefined).join(",")}`;
|
2699
|
+
const path = pathParts.join("/");
|
2700
|
+
return `https://${hostname}${transform}${path}${search}`;
|
2701
|
+
}
|
2702
|
+
|
2703
|
+
class XataFile {
|
2704
|
+
constructor(file) {
|
2705
|
+
this.id = file.id;
|
2706
|
+
this.name = file.name;
|
2707
|
+
this.mediaType = file.mediaType;
|
2708
|
+
this.base64Content = file.base64Content;
|
2709
|
+
this.enablePublicUrl = file.enablePublicUrl;
|
2710
|
+
this.signedUrlTimeout = file.signedUrlTimeout;
|
2711
|
+
this.uploadUrlTimeout = file.uploadUrlTimeout;
|
2712
|
+
this.size = file.size;
|
2713
|
+
this.version = file.version;
|
2714
|
+
this.url = file.url;
|
2715
|
+
this.signedUrl = file.signedUrl;
|
2716
|
+
this.uploadUrl = file.uploadUrl;
|
2717
|
+
this.attributes = file.attributes;
|
2718
|
+
}
|
2719
|
+
static fromBuffer(buffer, options = {}) {
|
2720
|
+
const base64Content = buffer.toString("base64");
|
2721
|
+
return new XataFile({ ...options, base64Content });
|
2722
|
+
}
|
2723
|
+
toBuffer() {
|
2724
|
+
if (!this.base64Content) {
|
2725
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2726
|
+
}
|
2727
|
+
return Buffer.from(this.base64Content, "base64");
|
2728
|
+
}
|
2729
|
+
static fromArrayBuffer(arrayBuffer, options = {}) {
|
2730
|
+
const uint8Array = new Uint8Array(arrayBuffer);
|
2731
|
+
return this.fromUint8Array(uint8Array, options);
|
2732
|
+
}
|
2733
|
+
toArrayBuffer() {
|
2734
|
+
if (!this.base64Content) {
|
2735
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2736
|
+
}
|
2737
|
+
const binary = atob(this.base64Content);
|
2738
|
+
return new ArrayBuffer(binary.length);
|
2739
|
+
}
|
2740
|
+
static fromUint8Array(uint8Array, options = {}) {
|
2741
|
+
let binary = "";
|
2742
|
+
for (let i = 0; i < uint8Array.byteLength; i++) {
|
2743
|
+
binary += String.fromCharCode(uint8Array[i]);
|
2744
|
+
}
|
2745
|
+
const base64Content = btoa(binary);
|
2746
|
+
return new XataFile({ ...options, base64Content });
|
2747
|
+
}
|
2748
|
+
toUint8Array() {
|
2749
|
+
if (!this.base64Content) {
|
2750
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2751
|
+
}
|
2752
|
+
const binary = atob(this.base64Content);
|
2753
|
+
const uint8Array = new Uint8Array(binary.length);
|
2754
|
+
for (let i = 0; i < binary.length; i++) {
|
2755
|
+
uint8Array[i] = binary.charCodeAt(i);
|
2756
|
+
}
|
2757
|
+
return uint8Array;
|
2758
|
+
}
|
2759
|
+
static async fromBlob(file, options = {}) {
|
2760
|
+
const name = options.name ?? file.name;
|
2761
|
+
const mediaType = file.type;
|
2762
|
+
const arrayBuffer = await file.arrayBuffer();
|
2763
|
+
return this.fromArrayBuffer(arrayBuffer, { ...options, name, mediaType });
|
2764
|
+
}
|
2765
|
+
toBlob() {
|
2766
|
+
if (!this.base64Content) {
|
2767
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2768
|
+
}
|
2769
|
+
const binary = atob(this.base64Content);
|
2770
|
+
const uint8Array = new Uint8Array(binary.length);
|
2771
|
+
for (let i = 0; i < binary.length; i++) {
|
2772
|
+
uint8Array[i] = binary.charCodeAt(i);
|
2773
|
+
}
|
2774
|
+
return new Blob([uint8Array], { type: this.mediaType });
|
2775
|
+
}
|
2776
|
+
static fromString(string, options = {}) {
|
2777
|
+
const base64Content = btoa(string);
|
2778
|
+
return new XataFile({ ...options, base64Content });
|
2779
|
+
}
|
2780
|
+
toString() {
|
2781
|
+
if (!this.base64Content) {
|
2782
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2783
|
+
}
|
2784
|
+
return atob(this.base64Content);
|
2785
|
+
}
|
2786
|
+
static fromBase64(base64Content, options = {}) {
|
2787
|
+
return new XataFile({ ...options, base64Content });
|
2788
|
+
}
|
2789
|
+
toBase64() {
|
2790
|
+
if (!this.base64Content) {
|
2791
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2792
|
+
}
|
2793
|
+
return this.base64Content;
|
2794
|
+
}
|
2795
|
+
transform(...options) {
|
2796
|
+
return {
|
2797
|
+
url: transformImage(this.url, ...options),
|
2798
|
+
signedUrl: transformImage(this.signedUrl, ...options),
|
2799
|
+
metadataUrl: transformImage(this.url, ...options, { format: "json" }),
|
2800
|
+
metadataSignedUrl: transformImage(this.signedUrl, ...options, { format: "json" })
|
2801
|
+
};
|
2802
|
+
}
|
2803
|
+
}
|
2804
|
+
const parseInputFileEntry = async (entry) => {
|
2805
|
+
if (!isDefined(entry))
|
2806
|
+
return null;
|
2807
|
+
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout, uploadUrlTimeout } = await entry;
|
2808
|
+
return compactObject({
|
2809
|
+
id,
|
2810
|
+
// Name cannot be an empty string in our API
|
2811
|
+
name: name ? name : void 0,
|
2812
|
+
mediaType,
|
2813
|
+
base64Content,
|
2814
|
+
enablePublicUrl,
|
2815
|
+
signedUrlTimeout,
|
2816
|
+
uploadUrlTimeout
|
2817
|
+
});
|
2818
|
+
};
|
2819
|
+
|
1938
2820
|
function cleanFilter(filter) {
|
1939
|
-
if (!filter)
|
2821
|
+
if (!isDefined(filter))
|
1940
2822
|
return void 0;
|
1941
|
-
|
1942
|
-
|
2823
|
+
if (!isObject(filter))
|
2824
|
+
return filter;
|
2825
|
+
const values = Object.fromEntries(
|
2826
|
+
Object.entries(filter).reduce((acc, [key, value]) => {
|
2827
|
+
if (!isDefined(value))
|
2828
|
+
return acc;
|
2829
|
+
if (Array.isArray(value)) {
|
2830
|
+
const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
|
2831
|
+
if (clean.length === 0)
|
2832
|
+
return acc;
|
2833
|
+
return [...acc, [key, clean]];
|
2834
|
+
}
|
2835
|
+
if (isObject(value)) {
|
2836
|
+
const clean = cleanFilter(value);
|
2837
|
+
if (!isDefined(clean))
|
2838
|
+
return acc;
|
2839
|
+
return [...acc, [key, clean]];
|
2840
|
+
}
|
2841
|
+
return [...acc, [key, value]];
|
2842
|
+
}, [])
|
2843
|
+
);
|
2844
|
+
return Object.keys(values).length > 0 ? values : void 0;
|
2845
|
+
}
|
2846
|
+
|
2847
|
+
function stringifyJson(value) {
|
2848
|
+
if (!isDefined(value))
|
2849
|
+
return value;
|
2850
|
+
if (isString(value))
|
2851
|
+
return value;
|
2852
|
+
try {
|
2853
|
+
return JSON.stringify(value);
|
2854
|
+
} catch (e) {
|
2855
|
+
return value;
|
2856
|
+
}
|
2857
|
+
}
|
2858
|
+
function parseJson(value) {
|
2859
|
+
try {
|
2860
|
+
return JSON.parse(value);
|
2861
|
+
} catch (e) {
|
2862
|
+
return value;
|
2863
|
+
}
|
1943
2864
|
}
|
1944
2865
|
|
1945
2866
|
var __accessCheck$6 = (obj, member, msg) => {
|
@@ -1968,31 +2889,59 @@ class Page {
|
|
1968
2889
|
this.meta = meta;
|
1969
2890
|
this.records = new RecordArray(this, records);
|
1970
2891
|
}
|
2892
|
+
/**
|
2893
|
+
* Retrieves the next page of results.
|
2894
|
+
* @param size Maximum number of results to be retrieved.
|
2895
|
+
* @param offset Number of results to skip when retrieving the results.
|
2896
|
+
* @returns The next page or results.
|
2897
|
+
*/
|
1971
2898
|
async nextPage(size, offset) {
|
1972
2899
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
1973
2900
|
}
|
2901
|
+
/**
|
2902
|
+
* Retrieves the previous page of results.
|
2903
|
+
* @param size Maximum number of results to be retrieved.
|
2904
|
+
* @param offset Number of results to skip when retrieving the results.
|
2905
|
+
* @returns The previous page or results.
|
2906
|
+
*/
|
1974
2907
|
async previousPage(size, offset) {
|
1975
2908
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
1976
2909
|
}
|
2910
|
+
/**
|
2911
|
+
* Retrieves the start page of results.
|
2912
|
+
* @param size Maximum number of results to be retrieved.
|
2913
|
+
* @param offset Number of results to skip when retrieving the results.
|
2914
|
+
* @returns The start page or results.
|
2915
|
+
*/
|
1977
2916
|
async startPage(size, offset) {
|
1978
2917
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
1979
2918
|
}
|
2919
|
+
/**
|
2920
|
+
* Retrieves the end page of results.
|
2921
|
+
* @param size Maximum number of results to be retrieved.
|
2922
|
+
* @param offset Number of results to skip when retrieving the results.
|
2923
|
+
* @returns The end page or results.
|
2924
|
+
*/
|
1980
2925
|
async endPage(size, offset) {
|
1981
2926
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
1982
2927
|
}
|
2928
|
+
/**
|
2929
|
+
* Shortcut method to check if there will be additional results if the next page of results is retrieved.
|
2930
|
+
* @returns Whether or not there will be additional results in the next page of results.
|
2931
|
+
*/
|
1983
2932
|
hasNextPage() {
|
1984
2933
|
return this.meta.page.more;
|
1985
2934
|
}
|
1986
2935
|
}
|
1987
2936
|
_query = new WeakMap();
|
1988
|
-
const PAGINATION_MAX_SIZE =
|
2937
|
+
const PAGINATION_MAX_SIZE = 1e3;
|
1989
2938
|
const PAGINATION_DEFAULT_SIZE = 20;
|
1990
|
-
const PAGINATION_MAX_OFFSET =
|
2939
|
+
const PAGINATION_MAX_OFFSET = 49e3;
|
1991
2940
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
1992
2941
|
function isCursorPaginationOptions(options) {
|
1993
2942
|
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
1994
2943
|
}
|
1995
|
-
const _RecordArray = class extends Array {
|
2944
|
+
const _RecordArray = class _RecordArray extends Array {
|
1996
2945
|
constructor(...args) {
|
1997
2946
|
super(..._RecordArray.parseConstructorParams(...args));
|
1998
2947
|
__privateAdd$6(this, _page, void 0);
|
@@ -2020,28 +2969,51 @@ const _RecordArray = class extends Array {
|
|
2020
2969
|
map(callbackfn, thisArg) {
|
2021
2970
|
return this.toArray().map(callbackfn, thisArg);
|
2022
2971
|
}
|
2972
|
+
/**
|
2973
|
+
* Retrieve next page of records
|
2974
|
+
*
|
2975
|
+
* @returns A new array of objects
|
2976
|
+
*/
|
2023
2977
|
async nextPage(size, offset) {
|
2024
2978
|
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
2025
2979
|
return new _RecordArray(newPage);
|
2026
2980
|
}
|
2981
|
+
/**
|
2982
|
+
* Retrieve previous page of records
|
2983
|
+
*
|
2984
|
+
* @returns A new array of objects
|
2985
|
+
*/
|
2027
2986
|
async previousPage(size, offset) {
|
2028
2987
|
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
2029
2988
|
return new _RecordArray(newPage);
|
2030
2989
|
}
|
2990
|
+
/**
|
2991
|
+
* Retrieve start page of records
|
2992
|
+
*
|
2993
|
+
* @returns A new array of objects
|
2994
|
+
*/
|
2031
2995
|
async startPage(size, offset) {
|
2032
2996
|
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
2033
2997
|
return new _RecordArray(newPage);
|
2034
2998
|
}
|
2999
|
+
/**
|
3000
|
+
* Retrieve end page of records
|
3001
|
+
*
|
3002
|
+
* @returns A new array of objects
|
3003
|
+
*/
|
2035
3004
|
async endPage(size, offset) {
|
2036
3005
|
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
2037
3006
|
return new _RecordArray(newPage);
|
2038
3007
|
}
|
3008
|
+
/**
|
3009
|
+
* @returns Boolean indicating if there is a next page
|
3010
|
+
*/
|
2039
3011
|
hasNextPage() {
|
2040
3012
|
return __privateGet$6(this, _page).meta.page.more;
|
2041
3013
|
}
|
2042
3014
|
};
|
2043
|
-
let RecordArray = _RecordArray;
|
2044
3015
|
_page = new WeakMap();
|
3016
|
+
let RecordArray = _RecordArray;
|
2045
3017
|
|
2046
3018
|
var __accessCheck$5 = (obj, member, msg) => {
|
2047
3019
|
if (!member.has(obj))
|
@@ -2066,13 +3038,14 @@ var __privateMethod$3 = (obj, member, method) => {
|
|
2066
3038
|
return method;
|
2067
3039
|
};
|
2068
3040
|
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
2069
|
-
const _Query = class {
|
3041
|
+
const _Query = class _Query {
|
2070
3042
|
constructor(repository, table, data, rawParent) {
|
2071
3043
|
__privateAdd$5(this, _cleanFilterConstraint);
|
2072
3044
|
__privateAdd$5(this, _table$1, void 0);
|
2073
3045
|
__privateAdd$5(this, _repository, void 0);
|
2074
3046
|
__privateAdd$5(this, _data, { filter: {} });
|
2075
|
-
|
3047
|
+
// Implements pagination
|
3048
|
+
this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
|
2076
3049
|
this.records = new RecordArray(this, []);
|
2077
3050
|
__privateSet$5(this, _table$1, table);
|
2078
3051
|
if (repository) {
|
@@ -2109,18 +3082,38 @@ const _Query = class {
|
|
2109
3082
|
const key = JSON.stringify({ columns, filter, sort, pagination });
|
2110
3083
|
return toBase64(key);
|
2111
3084
|
}
|
3085
|
+
/**
|
3086
|
+
* Builds a new query object representing a logical OR between the given subqueries.
|
3087
|
+
* @param queries An array of subqueries.
|
3088
|
+
* @returns A new Query object.
|
3089
|
+
*/
|
2112
3090
|
any(...queries) {
|
2113
3091
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2114
3092
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
2115
3093
|
}
|
3094
|
+
/**
|
3095
|
+
* Builds a new query object representing a logical AND between the given subqueries.
|
3096
|
+
* @param queries An array of subqueries.
|
3097
|
+
* @returns A new Query object.
|
3098
|
+
*/
|
2116
3099
|
all(...queries) {
|
2117
3100
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2118
3101
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
2119
3102
|
}
|
3103
|
+
/**
|
3104
|
+
* Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
|
3105
|
+
* @param queries An array of subqueries.
|
3106
|
+
* @returns A new Query object.
|
3107
|
+
*/
|
2120
3108
|
not(...queries) {
|
2121
3109
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2122
3110
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
2123
3111
|
}
|
3112
|
+
/**
|
3113
|
+
* Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
|
3114
|
+
* @param queries An array of subqueries.
|
3115
|
+
* @returns A new Query object.
|
3116
|
+
*/
|
2124
3117
|
none(...queries) {
|
2125
3118
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2126
3119
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
@@ -2143,6 +3136,11 @@ const _Query = class {
|
|
2143
3136
|
const sort = [...originalSort, { column, direction }];
|
2144
3137
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
2145
3138
|
}
|
3139
|
+
/**
|
3140
|
+
* Builds a new query specifying the set of columns to be returned in the query response.
|
3141
|
+
* @param columns Array of column names to be returned by the query.
|
3142
|
+
* @returns A new Query object.
|
3143
|
+
*/
|
2146
3144
|
select(columns) {
|
2147
3145
|
return new _Query(
|
2148
3146
|
__privateGet$5(this, _repository),
|
@@ -2155,6 +3153,12 @@ const _Query = class {
|
|
2155
3153
|
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
2156
3154
|
return __privateGet$5(this, _repository).query(query);
|
2157
3155
|
}
|
3156
|
+
/**
|
3157
|
+
* Get results in an iterator
|
3158
|
+
*
|
3159
|
+
* @async
|
3160
|
+
* @returns Async interable of results
|
3161
|
+
*/
|
2158
3162
|
async *[Symbol.asyncIterator]() {
|
2159
3163
|
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
2160
3164
|
yield record;
|
@@ -2215,26 +3219,53 @@ const _Query = class {
|
|
2215
3219
|
);
|
2216
3220
|
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
2217
3221
|
}
|
3222
|
+
/**
|
3223
|
+
* Builds a new query object adding a cache TTL in milliseconds.
|
3224
|
+
* @param ttl The cache TTL in milliseconds.
|
3225
|
+
* @returns A new Query object.
|
3226
|
+
*/
|
2218
3227
|
cache(ttl) {
|
2219
3228
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
2220
3229
|
}
|
3230
|
+
/**
|
3231
|
+
* Retrieve next page of records
|
3232
|
+
*
|
3233
|
+
* @returns A new page object.
|
3234
|
+
*/
|
2221
3235
|
nextPage(size, offset) {
|
2222
3236
|
return this.startPage(size, offset);
|
2223
3237
|
}
|
3238
|
+
/**
|
3239
|
+
* Retrieve previous page of records
|
3240
|
+
*
|
3241
|
+
* @returns A new page object
|
3242
|
+
*/
|
2224
3243
|
previousPage(size, offset) {
|
2225
3244
|
return this.startPage(size, offset);
|
2226
3245
|
}
|
3246
|
+
/**
|
3247
|
+
* Retrieve start page of records
|
3248
|
+
*
|
3249
|
+
* @returns A new page object
|
3250
|
+
*/
|
2227
3251
|
startPage(size, offset) {
|
2228
3252
|
return this.getPaginated({ pagination: { size, offset } });
|
2229
3253
|
}
|
3254
|
+
/**
|
3255
|
+
* Retrieve last page of records
|
3256
|
+
*
|
3257
|
+
* @returns A new page object
|
3258
|
+
*/
|
2230
3259
|
endPage(size, offset) {
|
2231
3260
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
2232
3261
|
}
|
3262
|
+
/**
|
3263
|
+
* @returns Boolean indicating if there is a next page
|
3264
|
+
*/
|
2233
3265
|
hasNextPage() {
|
2234
3266
|
return this.meta.page.more;
|
2235
3267
|
}
|
2236
3268
|
};
|
2237
|
-
let Query = _Query;
|
2238
3269
|
_table$1 = new WeakMap();
|
2239
3270
|
_repository = new WeakMap();
|
2240
3271
|
_data = new WeakMap();
|
@@ -2249,6 +3280,7 @@ cleanFilterConstraint_fn = function(column, value) {
|
|
2249
3280
|
}
|
2250
3281
|
return value;
|
2251
3282
|
};
|
3283
|
+
let Query = _Query;
|
2252
3284
|
function cleanParent(data, parent) {
|
2253
3285
|
if (isCursorPaginationOptions(data.pagination)) {
|
2254
3286
|
return { ...parent, sort: void 0, filter: void 0 };
|
@@ -2256,6 +3288,22 @@ function cleanParent(data, parent) {
|
|
2256
3288
|
return parent;
|
2257
3289
|
}
|
2258
3290
|
|
3291
|
+
const RecordColumnTypes = [
|
3292
|
+
"bool",
|
3293
|
+
"int",
|
3294
|
+
"float",
|
3295
|
+
"string",
|
3296
|
+
"text",
|
3297
|
+
"email",
|
3298
|
+
"multiple",
|
3299
|
+
"link",
|
3300
|
+
"object",
|
3301
|
+
"datetime",
|
3302
|
+
"vector",
|
3303
|
+
"file[]",
|
3304
|
+
"file",
|
3305
|
+
"json"
|
3306
|
+
];
|
2259
3307
|
function isIdentifiable(x) {
|
2260
3308
|
return isObject(x) && isString(x?.id);
|
2261
3309
|
}
|
@@ -2265,11 +3313,33 @@ function isXataRecord(x) {
|
|
2265
3313
|
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
2266
3314
|
}
|
2267
3315
|
|
3316
|
+
function isValidExpandedColumn(column) {
|
3317
|
+
return isObject(column) && isString(column.name);
|
3318
|
+
}
|
3319
|
+
function isValidSelectableColumns(columns) {
|
3320
|
+
if (!Array.isArray(columns)) {
|
3321
|
+
return false;
|
3322
|
+
}
|
3323
|
+
return columns.every((column) => {
|
3324
|
+
if (typeof column === "string") {
|
3325
|
+
return true;
|
3326
|
+
}
|
3327
|
+
if (typeof column === "object") {
|
3328
|
+
return isValidExpandedColumn(column);
|
3329
|
+
}
|
3330
|
+
return false;
|
3331
|
+
});
|
3332
|
+
}
|
3333
|
+
|
2268
3334
|
function isSortFilterString(value) {
|
2269
3335
|
return isString(value);
|
2270
3336
|
}
|
2271
3337
|
function isSortFilterBase(filter) {
|
2272
|
-
return isObject(filter) && Object.
|
3338
|
+
return isObject(filter) && Object.entries(filter).every(([key, value]) => {
|
3339
|
+
if (key === "*")
|
3340
|
+
return value === "random";
|
3341
|
+
return value === "asc" || value === "desc";
|
3342
|
+
});
|
2273
3343
|
}
|
2274
3344
|
function isSortFilterObject(filter) {
|
2275
3345
|
return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
|
@@ -2310,7 +3380,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
2310
3380
|
__accessCheck$4(obj, member, "access private method");
|
2311
3381
|
return method;
|
2312
3382
|
};
|
2313
|
-
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;
|
3383
|
+
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;
|
2314
3384
|
const BULK_OPERATION_MAX_SIZE = 1e3;
|
2315
3385
|
class Repository extends Query {
|
2316
3386
|
}
|
@@ -2332,6 +3402,7 @@ class RestRepository extends Query {
|
|
2332
3402
|
__privateAdd$4(this, _setCacheQuery);
|
2333
3403
|
__privateAdd$4(this, _getCacheQuery);
|
2334
3404
|
__privateAdd$4(this, _getSchemaTables$1);
|
3405
|
+
__privateAdd$4(this, _transformObjectToApi);
|
2335
3406
|
__privateAdd$4(this, _table, void 0);
|
2336
3407
|
__privateAdd$4(this, _getFetchProps, void 0);
|
2337
3408
|
__privateAdd$4(this, _db, void 0);
|
@@ -2342,10 +3413,7 @@ class RestRepository extends Query {
|
|
2342
3413
|
__privateSet$4(this, _db, options.db);
|
2343
3414
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
2344
3415
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
2345
|
-
__privateSet$4(this, _getFetchProps,
|
2346
|
-
const props = await options.pluginOptions.getFetchProps();
|
2347
|
-
return { ...props, sessionID: generateUUID() };
|
2348
|
-
});
|
3416
|
+
__privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
|
2349
3417
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
2350
3418
|
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
2351
3419
|
return trace(name, fn, {
|
@@ -2363,24 +3431,24 @@ class RestRepository extends Query {
|
|
2363
3431
|
if (a.length === 0)
|
2364
3432
|
return [];
|
2365
3433
|
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
2366
|
-
const columns =
|
3434
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2367
3435
|
const result = await this.read(ids, columns);
|
2368
3436
|
return result;
|
2369
3437
|
}
|
2370
3438
|
if (isString(a) && isObject(b)) {
|
2371
3439
|
if (a === "")
|
2372
3440
|
throw new Error("The id can't be empty");
|
2373
|
-
const columns =
|
3441
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
2374
3442
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
2375
3443
|
}
|
2376
3444
|
if (isObject(a) && isString(a.id)) {
|
2377
3445
|
if (a.id === "")
|
2378
3446
|
throw new Error("The id can't be empty");
|
2379
|
-
const columns =
|
3447
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
2380
3448
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
2381
3449
|
}
|
2382
3450
|
if (isObject(a)) {
|
2383
|
-
const columns =
|
3451
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
2384
3452
|
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
2385
3453
|
}
|
2386
3454
|
throw new Error("Invalid arguments for create method");
|
@@ -2388,7 +3456,7 @@ class RestRepository extends Query {
|
|
2388
3456
|
}
|
2389
3457
|
async read(a, b) {
|
2390
3458
|
return __privateGet$4(this, _trace).call(this, "read", async () => {
|
2391
|
-
const columns =
|
3459
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2392
3460
|
if (Array.isArray(a)) {
|
2393
3461
|
if (a.length === 0)
|
2394
3462
|
return [];
|
@@ -2402,7 +3470,6 @@ class RestRepository extends Query {
|
|
2402
3470
|
}
|
2403
3471
|
const id = extractId(a);
|
2404
3472
|
if (id) {
|
2405
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2406
3473
|
try {
|
2407
3474
|
const response = await getRecord({
|
2408
3475
|
pathParams: {
|
@@ -2413,10 +3480,16 @@ class RestRepository extends Query {
|
|
2413
3480
|
recordId: id
|
2414
3481
|
},
|
2415
3482
|
queryParams: { columns },
|
2416
|
-
...
|
3483
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2417
3484
|
});
|
2418
3485
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2419
|
-
return initObject(
|
3486
|
+
return initObject(
|
3487
|
+
__privateGet$4(this, _db),
|
3488
|
+
schemaTables,
|
3489
|
+
__privateGet$4(this, _table),
|
3490
|
+
response,
|
3491
|
+
columns
|
3492
|
+
);
|
2420
3493
|
} catch (e) {
|
2421
3494
|
if (isObject(e) && e.status === 404) {
|
2422
3495
|
return null;
|
@@ -2458,17 +3531,17 @@ class RestRepository extends Query {
|
|
2458
3531
|
ifVersion,
|
2459
3532
|
upsert: false
|
2460
3533
|
});
|
2461
|
-
const columns =
|
3534
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2462
3535
|
const result = await this.read(a, columns);
|
2463
3536
|
return result;
|
2464
3537
|
}
|
2465
3538
|
try {
|
2466
3539
|
if (isString(a) && isObject(b)) {
|
2467
|
-
const columns =
|
3540
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
2468
3541
|
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
2469
3542
|
}
|
2470
3543
|
if (isObject(a) && isString(a.id)) {
|
2471
|
-
const columns =
|
3544
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
2472
3545
|
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
2473
3546
|
}
|
2474
3547
|
} catch (error) {
|
@@ -2508,17 +3581,27 @@ class RestRepository extends Query {
|
|
2508
3581
|
ifVersion,
|
2509
3582
|
upsert: true
|
2510
3583
|
});
|
2511
|
-
const columns =
|
3584
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2512
3585
|
const result = await this.read(a, columns);
|
2513
3586
|
return result;
|
2514
3587
|
}
|
2515
3588
|
if (isString(a) && isObject(b)) {
|
2516
|
-
|
2517
|
-
|
3589
|
+
if (a === "")
|
3590
|
+
throw new Error("The id can't be empty");
|
3591
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3592
|
+
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
2518
3593
|
}
|
2519
3594
|
if (isObject(a) && isString(a.id)) {
|
2520
|
-
|
2521
|
-
|
3595
|
+
if (a.id === "")
|
3596
|
+
throw new Error("The id can't be empty");
|
3597
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3598
|
+
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3599
|
+
}
|
3600
|
+
if (!isDefined(a) && isObject(b)) {
|
3601
|
+
return await this.create(b, c);
|
3602
|
+
}
|
3603
|
+
if (isObject(a) && !isDefined(a.id)) {
|
3604
|
+
return await this.create(a, b);
|
2522
3605
|
}
|
2523
3606
|
throw new Error("Invalid arguments for createOrUpdate method");
|
2524
3607
|
});
|
@@ -2530,17 +3613,27 @@ class RestRepository extends Query {
|
|
2530
3613
|
if (a.length === 0)
|
2531
3614
|
return [];
|
2532
3615
|
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
2533
|
-
const columns =
|
3616
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2534
3617
|
const result = await this.read(ids, columns);
|
2535
3618
|
return result;
|
2536
3619
|
}
|
2537
3620
|
if (isString(a) && isObject(b)) {
|
2538
|
-
|
2539
|
-
|
3621
|
+
if (a === "")
|
3622
|
+
throw new Error("The id can't be empty");
|
3623
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3624
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
2540
3625
|
}
|
2541
3626
|
if (isObject(a) && isString(a.id)) {
|
2542
|
-
|
2543
|
-
|
3627
|
+
if (a.id === "")
|
3628
|
+
throw new Error("The id can't be empty");
|
3629
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3630
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
3631
|
+
}
|
3632
|
+
if (!isDefined(a) && isObject(b)) {
|
3633
|
+
return await this.create(b, c);
|
3634
|
+
}
|
3635
|
+
if (isObject(a) && !isDefined(a.id)) {
|
3636
|
+
return await this.create(a, b);
|
2544
3637
|
}
|
2545
3638
|
throw new Error("Invalid arguments for createOrReplace method");
|
2546
3639
|
});
|
@@ -2557,7 +3650,7 @@ class RestRepository extends Query {
|
|
2557
3650
|
return o.id;
|
2558
3651
|
throw new Error("Invalid arguments for delete method");
|
2559
3652
|
});
|
2560
|
-
const columns =
|
3653
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2561
3654
|
const result = await this.read(a, columns);
|
2562
3655
|
await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
|
2563
3656
|
return result;
|
@@ -2591,8 +3684,7 @@ class RestRepository extends Query {
|
|
2591
3684
|
}
|
2592
3685
|
async search(query, options = {}) {
|
2593
3686
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
2594
|
-
const
|
2595
|
-
const { records } = await searchTable({
|
3687
|
+
const { records, totalCount } = await searchTable({
|
2596
3688
|
pathParams: {
|
2597
3689
|
workspace: "{workspaceId}",
|
2598
3690
|
dbBranchName: "{dbBranch}",
|
@@ -2609,15 +3701,42 @@ class RestRepository extends Query {
|
|
2609
3701
|
page: options.page,
|
2610
3702
|
target: options.target
|
2611
3703
|
},
|
2612
|
-
...
|
3704
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3705
|
+
});
|
3706
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3707
|
+
return {
|
3708
|
+
records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
|
3709
|
+
totalCount
|
3710
|
+
};
|
3711
|
+
});
|
3712
|
+
}
|
3713
|
+
async vectorSearch(column, query, options) {
|
3714
|
+
return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
|
3715
|
+
const { records, totalCount } = await vectorSearchTable({
|
3716
|
+
pathParams: {
|
3717
|
+
workspace: "{workspaceId}",
|
3718
|
+
dbBranchName: "{dbBranch}",
|
3719
|
+
region: "{region}",
|
3720
|
+
tableName: __privateGet$4(this, _table)
|
3721
|
+
},
|
3722
|
+
body: {
|
3723
|
+
column,
|
3724
|
+
queryVector: query,
|
3725
|
+
similarityFunction: options?.similarityFunction,
|
3726
|
+
size: options?.size,
|
3727
|
+
filter: options?.filter
|
3728
|
+
},
|
3729
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2613
3730
|
});
|
2614
3731
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2615
|
-
return
|
3732
|
+
return {
|
3733
|
+
records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
|
3734
|
+
totalCount
|
3735
|
+
};
|
2616
3736
|
});
|
2617
3737
|
}
|
2618
3738
|
async aggregate(aggs, filter) {
|
2619
3739
|
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
2620
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2621
3740
|
const result = await aggregateTable({
|
2622
3741
|
pathParams: {
|
2623
3742
|
workspace: "{workspaceId}",
|
@@ -2626,7 +3745,7 @@ class RestRepository extends Query {
|
|
2626
3745
|
tableName: __privateGet$4(this, _table)
|
2627
3746
|
},
|
2628
3747
|
body: { aggs, filter },
|
2629
|
-
...
|
3748
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2630
3749
|
});
|
2631
3750
|
return result;
|
2632
3751
|
});
|
@@ -2637,7 +3756,6 @@ class RestRepository extends Query {
|
|
2637
3756
|
if (cacheQuery)
|
2638
3757
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
2639
3758
|
const data = query.getQueryOptions();
|
2640
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2641
3759
|
const { meta, records: objects } = await queryTable({
|
2642
3760
|
pathParams: {
|
2643
3761
|
workspace: "{workspaceId}",
|
@@ -2653,11 +3771,17 @@ class RestRepository extends Query {
|
|
2653
3771
|
consistency: data.consistency
|
2654
3772
|
},
|
2655
3773
|
fetchOptions: data.fetchOptions,
|
2656
|
-
...
|
3774
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2657
3775
|
});
|
2658
3776
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2659
3777
|
const records = objects.map(
|
2660
|
-
(record) => initObject(
|
3778
|
+
(record) => initObject(
|
3779
|
+
__privateGet$4(this, _db),
|
3780
|
+
schemaTables,
|
3781
|
+
__privateGet$4(this, _table),
|
3782
|
+
record,
|
3783
|
+
data.columns ?? ["*"]
|
3784
|
+
)
|
2661
3785
|
);
|
2662
3786
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
2663
3787
|
return new Page(query, meta, records);
|
@@ -2666,7 +3790,6 @@ class RestRepository extends Query {
|
|
2666
3790
|
async summarizeTable(query, summaries, summariesFilter) {
|
2667
3791
|
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
2668
3792
|
const data = query.getQueryOptions();
|
2669
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2670
3793
|
const result = await summarizeTable({
|
2671
3794
|
pathParams: {
|
2672
3795
|
workspace: "{workspaceId}",
|
@@ -2683,11 +3806,50 @@ class RestRepository extends Query {
|
|
2683
3806
|
summaries,
|
2684
3807
|
summariesFilter
|
2685
3808
|
},
|
2686
|
-
...
|
3809
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2687
3810
|
});
|
2688
|
-
|
3811
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3812
|
+
return {
|
3813
|
+
...result,
|
3814
|
+
summaries: result.summaries.map(
|
3815
|
+
(summary) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), summary, data.columns ?? [])
|
3816
|
+
)
|
3817
|
+
};
|
2689
3818
|
});
|
2690
3819
|
}
|
3820
|
+
ask(question, options) {
|
3821
|
+
const questionParam = options?.sessionId ? { message: question } : { question };
|
3822
|
+
const params = {
|
3823
|
+
pathParams: {
|
3824
|
+
workspace: "{workspaceId}",
|
3825
|
+
dbBranchName: "{dbBranch}",
|
3826
|
+
region: "{region}",
|
3827
|
+
tableName: __privateGet$4(this, _table),
|
3828
|
+
sessionId: options?.sessionId
|
3829
|
+
},
|
3830
|
+
body: {
|
3831
|
+
...questionParam,
|
3832
|
+
rules: options?.rules,
|
3833
|
+
searchType: options?.searchType,
|
3834
|
+
search: options?.searchType === "keyword" ? options?.search : void 0,
|
3835
|
+
vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
|
3836
|
+
},
|
3837
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3838
|
+
};
|
3839
|
+
if (options?.onMessage) {
|
3840
|
+
fetchSSERequest({
|
3841
|
+
endpoint: "dataPlane",
|
3842
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
|
3843
|
+
method: "POST",
|
3844
|
+
onMessage: (message) => {
|
3845
|
+
options.onMessage?.({ answer: message.text, records: message.records });
|
3846
|
+
},
|
3847
|
+
...params
|
3848
|
+
});
|
3849
|
+
} else {
|
3850
|
+
return askTableSession(params);
|
3851
|
+
}
|
3852
|
+
}
|
2691
3853
|
}
|
2692
3854
|
_table = new WeakMap();
|
2693
3855
|
_getFetchProps = new WeakMap();
|
@@ -2697,8 +3859,7 @@ _schemaTables$2 = new WeakMap();
|
|
2697
3859
|
_trace = new WeakMap();
|
2698
3860
|
_insertRecordWithoutId = new WeakSet();
|
2699
3861
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
2700
|
-
const
|
2701
|
-
const record = transformObjectLinks(object);
|
3862
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
2702
3863
|
const response = await insertRecord({
|
2703
3864
|
pathParams: {
|
2704
3865
|
workspace: "{workspaceId}",
|
@@ -2708,15 +3869,16 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
2708
3869
|
},
|
2709
3870
|
queryParams: { columns },
|
2710
3871
|
body: record,
|
2711
|
-
...
|
3872
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2712
3873
|
});
|
2713
3874
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2714
3875
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2715
3876
|
};
|
2716
3877
|
_insertRecordWithId = new WeakSet();
|
2717
3878
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
2718
|
-
|
2719
|
-
|
3879
|
+
if (!recordId)
|
3880
|
+
return null;
|
3881
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
2720
3882
|
const response = await insertRecordWithID({
|
2721
3883
|
pathParams: {
|
2722
3884
|
workspace: "{workspaceId}",
|
@@ -2727,30 +3889,28 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
|
|
2727
3889
|
},
|
2728
3890
|
body: record,
|
2729
3891
|
queryParams: { createOnly, columns, ifVersion },
|
2730
|
-
...
|
3892
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2731
3893
|
});
|
2732
3894
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2733
3895
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2734
3896
|
};
|
2735
3897
|
_insertRecords = new WeakSet();
|
2736
3898
|
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
2737
|
-
const
|
2738
|
-
|
2739
|
-
|
2740
|
-
|
2741
|
-
|
2742
|
-
BULK_OPERATION_MAX_SIZE
|
2743
|
-
);
|
3899
|
+
const operations = await promiseMap(objects, async (object) => {
|
3900
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3901
|
+
return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
|
3902
|
+
});
|
3903
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
2744
3904
|
const ids = [];
|
2745
|
-
for (const
|
3905
|
+
for (const operations2 of chunkedOperations) {
|
2746
3906
|
const { results } = await branchTransaction({
|
2747
3907
|
pathParams: {
|
2748
3908
|
workspace: "{workspaceId}",
|
2749
3909
|
dbBranchName: "{dbBranch}",
|
2750
3910
|
region: "{region}"
|
2751
3911
|
},
|
2752
|
-
body: { operations },
|
2753
|
-
...
|
3912
|
+
body: { operations: operations2 },
|
3913
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2754
3914
|
});
|
2755
3915
|
for (const result of results) {
|
2756
3916
|
if (result.operation === "insert") {
|
@@ -2764,8 +3924,9 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
|
2764
3924
|
};
|
2765
3925
|
_updateRecordWithID = new WeakSet();
|
2766
3926
|
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
2767
|
-
|
2768
|
-
|
3927
|
+
if (!recordId)
|
3928
|
+
return null;
|
3929
|
+
const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
2769
3930
|
try {
|
2770
3931
|
const response = await updateRecordWithID({
|
2771
3932
|
pathParams: {
|
@@ -2777,7 +3938,7 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
2777
3938
|
},
|
2778
3939
|
queryParams: { columns, ifVersion },
|
2779
3940
|
body: record,
|
2780
|
-
...
|
3941
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2781
3942
|
});
|
2782
3943
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2783
3944
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
@@ -2790,23 +3951,21 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
2790
3951
|
};
|
2791
3952
|
_updateRecords = new WeakSet();
|
2792
3953
|
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
2793
|
-
const
|
2794
|
-
|
2795
|
-
|
2796
|
-
|
2797
|
-
|
2798
|
-
BULK_OPERATION_MAX_SIZE
|
2799
|
-
);
|
3954
|
+
const operations = await promiseMap(objects, async ({ id, ...object }) => {
|
3955
|
+
const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3956
|
+
return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
|
3957
|
+
});
|
3958
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
2800
3959
|
const ids = [];
|
2801
|
-
for (const
|
3960
|
+
for (const operations2 of chunkedOperations) {
|
2802
3961
|
const { results } = await branchTransaction({
|
2803
3962
|
pathParams: {
|
2804
3963
|
workspace: "{workspaceId}",
|
2805
3964
|
dbBranchName: "{dbBranch}",
|
2806
3965
|
region: "{region}"
|
2807
3966
|
},
|
2808
|
-
body: { operations },
|
2809
|
-
...
|
3967
|
+
body: { operations: operations2 },
|
3968
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2810
3969
|
});
|
2811
3970
|
for (const result of results) {
|
2812
3971
|
if (result.operation === "update") {
|
@@ -2820,7 +3979,8 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
|
2820
3979
|
};
|
2821
3980
|
_upsertRecordWithID = new WeakSet();
|
2822
3981
|
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
2823
|
-
|
3982
|
+
if (!recordId)
|
3983
|
+
return null;
|
2824
3984
|
const response = await upsertRecordWithID({
|
2825
3985
|
pathParams: {
|
2826
3986
|
workspace: "{workspaceId}",
|
@@ -2831,14 +3991,15 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
2831
3991
|
},
|
2832
3992
|
queryParams: { columns, ifVersion },
|
2833
3993
|
body: object,
|
2834
|
-
...
|
3994
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2835
3995
|
});
|
2836
3996
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2837
3997
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2838
3998
|
};
|
2839
3999
|
_deleteRecord = new WeakSet();
|
2840
4000
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
2841
|
-
|
4001
|
+
if (!recordId)
|
4002
|
+
return null;
|
2842
4003
|
try {
|
2843
4004
|
const response = await deleteRecord({
|
2844
4005
|
pathParams: {
|
@@ -2849,7 +4010,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
2849
4010
|
recordId
|
2850
4011
|
},
|
2851
4012
|
queryParams: { columns },
|
2852
|
-
...
|
4013
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2853
4014
|
});
|
2854
4015
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2855
4016
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
@@ -2862,9 +4023,8 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
2862
4023
|
};
|
2863
4024
|
_deleteRecords = new WeakSet();
|
2864
4025
|
deleteRecords_fn = async function(recordIds) {
|
2865
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2866
4026
|
const chunkedOperations = chunk(
|
2867
|
-
recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
4027
|
+
compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
2868
4028
|
BULK_OPERATION_MAX_SIZE
|
2869
4029
|
);
|
2870
4030
|
for (const operations of chunkedOperations) {
|
@@ -2875,21 +4035,22 @@ deleteRecords_fn = async function(recordIds) {
|
|
2875
4035
|
region: "{region}"
|
2876
4036
|
},
|
2877
4037
|
body: { operations },
|
2878
|
-
...
|
4038
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2879
4039
|
});
|
2880
4040
|
}
|
2881
4041
|
};
|
2882
4042
|
_setCacheQuery = new WeakSet();
|
2883
4043
|
setCacheQuery_fn = async function(query, meta, records) {
|
2884
|
-
await __privateGet$4(this, _cache)
|
4044
|
+
await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
|
2885
4045
|
};
|
2886
4046
|
_getCacheQuery = new WeakSet();
|
2887
4047
|
getCacheQuery_fn = async function(query) {
|
2888
4048
|
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
2889
|
-
const result = await __privateGet$4(this, _cache)
|
4049
|
+
const result = await __privateGet$4(this, _cache)?.get(key);
|
2890
4050
|
if (!result)
|
2891
4051
|
return null;
|
2892
|
-
const
|
4052
|
+
const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
|
4053
|
+
const { cache: ttl = defaultTTL } = query.getQueryOptions();
|
2893
4054
|
if (ttl < 0)
|
2894
4055
|
return null;
|
2895
4056
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
@@ -2899,20 +4060,47 @@ _getSchemaTables$1 = new WeakSet();
|
|
2899
4060
|
getSchemaTables_fn$1 = async function() {
|
2900
4061
|
if (__privateGet$4(this, _schemaTables$2))
|
2901
4062
|
return __privateGet$4(this, _schemaTables$2);
|
2902
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2903
4063
|
const { schema } = await getBranchDetails({
|
2904
4064
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2905
|
-
...
|
4065
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2906
4066
|
});
|
2907
4067
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
2908
4068
|
return schema.tables;
|
2909
4069
|
};
|
2910
|
-
|
2911
|
-
|
4070
|
+
_transformObjectToApi = new WeakSet();
|
4071
|
+
transformObjectToApi_fn = async function(object) {
|
4072
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
4073
|
+
const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
|
4074
|
+
if (!schema)
|
4075
|
+
throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
|
4076
|
+
const result = {};
|
4077
|
+
for (const [key, value] of Object.entries(object)) {
|
2912
4078
|
if (key === "xata")
|
2913
|
-
|
2914
|
-
|
2915
|
-
|
4079
|
+
continue;
|
4080
|
+
const type = schema.columns.find((column) => column.name === key)?.type;
|
4081
|
+
switch (type) {
|
4082
|
+
case "link": {
|
4083
|
+
result[key] = isIdentifiable(value) ? value.id : value;
|
4084
|
+
break;
|
4085
|
+
}
|
4086
|
+
case "datetime": {
|
4087
|
+
result[key] = value instanceof Date ? value.toISOString() : value;
|
4088
|
+
break;
|
4089
|
+
}
|
4090
|
+
case `file`:
|
4091
|
+
result[key] = await parseInputFileEntry(value);
|
4092
|
+
break;
|
4093
|
+
case "file[]":
|
4094
|
+
result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
|
4095
|
+
break;
|
4096
|
+
case "json":
|
4097
|
+
result[key] = stringifyJson(value);
|
4098
|
+
break;
|
4099
|
+
default:
|
4100
|
+
result[key] = value;
|
4101
|
+
}
|
4102
|
+
}
|
4103
|
+
return result;
|
2916
4104
|
};
|
2917
4105
|
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
2918
4106
|
const data = {};
|
@@ -2944,18 +4132,33 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2944
4132
|
if (item === column.name) {
|
2945
4133
|
return [...acc, "*"];
|
2946
4134
|
}
|
2947
|
-
if (item.startsWith(`${column.name}.`)) {
|
4135
|
+
if (isString(item) && item.startsWith(`${column.name}.`)) {
|
2948
4136
|
const [, ...path] = item.split(".");
|
2949
4137
|
return [...acc, path.join(".")];
|
2950
4138
|
}
|
2951
4139
|
return acc;
|
2952
4140
|
}, []);
|
2953
|
-
data[column.name] = initObject(
|
4141
|
+
data[column.name] = initObject(
|
4142
|
+
db,
|
4143
|
+
schemaTables,
|
4144
|
+
linkTable,
|
4145
|
+
value,
|
4146
|
+
selectedLinkColumns
|
4147
|
+
);
|
2954
4148
|
} else {
|
2955
4149
|
data[column.name] = null;
|
2956
4150
|
}
|
2957
4151
|
break;
|
2958
4152
|
}
|
4153
|
+
case "file":
|
4154
|
+
data[column.name] = isDefined(value) ? new XataFile(value) : null;
|
4155
|
+
break;
|
4156
|
+
case "file[]":
|
4157
|
+
data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
|
4158
|
+
break;
|
4159
|
+
case "json":
|
4160
|
+
data[column.name] = parseJson(value);
|
4161
|
+
break;
|
2959
4162
|
default:
|
2960
4163
|
data[column.name] = value ?? null;
|
2961
4164
|
if (column.notNull === true && value === null) {
|
@@ -2965,30 +4168,34 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2965
4168
|
}
|
2966
4169
|
}
|
2967
4170
|
const record = { ...data };
|
4171
|
+
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
2968
4172
|
record.read = function(columns2) {
|
2969
4173
|
return db[table].read(record["id"], columns2);
|
2970
4174
|
};
|
2971
4175
|
record.update = function(data2, b, c) {
|
2972
|
-
const columns2 =
|
4176
|
+
const columns2 = isValidSelectableColumns(b) ? b : ["*"];
|
2973
4177
|
const ifVersion = parseIfVersion(b, c);
|
2974
4178
|
return db[table].update(record["id"], data2, columns2, { ifVersion });
|
2975
4179
|
};
|
2976
4180
|
record.replace = function(data2, b, c) {
|
2977
|
-
const columns2 =
|
4181
|
+
const columns2 = isValidSelectableColumns(b) ? b : ["*"];
|
2978
4182
|
const ifVersion = parseIfVersion(b, c);
|
2979
4183
|
return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
|
2980
4184
|
};
|
2981
4185
|
record.delete = function() {
|
2982
4186
|
return db[table].delete(record["id"]);
|
2983
4187
|
};
|
4188
|
+
if (metadata !== void 0) {
|
4189
|
+
record.xata = Object.freeze(metadata);
|
4190
|
+
}
|
2984
4191
|
record.getMetadata = function() {
|
2985
|
-
return xata;
|
4192
|
+
return record.xata;
|
2986
4193
|
};
|
2987
4194
|
record.toSerializable = function() {
|
2988
|
-
return JSON.parse(JSON.stringify(
|
4195
|
+
return JSON.parse(JSON.stringify(record));
|
2989
4196
|
};
|
2990
4197
|
record.toString = function() {
|
2991
|
-
return JSON.stringify(
|
4198
|
+
return JSON.stringify(record);
|
2992
4199
|
};
|
2993
4200
|
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
2994
4201
|
Object.defineProperty(record, prop, { enumerable: false });
|
@@ -3006,11 +4213,7 @@ function extractId(value) {
|
|
3006
4213
|
function isValidColumn(columns, column) {
|
3007
4214
|
if (columns.includes("*"))
|
3008
4215
|
return true;
|
3009
|
-
|
3010
|
-
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
3011
|
-
return linkColumns.length > 0;
|
3012
|
-
}
|
3013
|
-
return columns.includes(column.name);
|
4216
|
+
return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
|
3014
4217
|
}
|
3015
4218
|
function parseIfVersion(...args) {
|
3016
4219
|
for (const arg of args) {
|
@@ -3087,10 +4290,12 @@ const notExists = (column) => ({ $notExists: column });
|
|
3087
4290
|
const startsWith = (value) => ({ $startsWith: value });
|
3088
4291
|
const endsWith = (value) => ({ $endsWith: value });
|
3089
4292
|
const pattern = (value) => ({ $pattern: value });
|
4293
|
+
const iPattern = (value) => ({ $iPattern: value });
|
3090
4294
|
const is = (value) => ({ $is: value });
|
3091
4295
|
const equals = is;
|
3092
4296
|
const isNot = (value) => ({ $isNot: value });
|
3093
4297
|
const contains = (value) => ({ $contains: value });
|
4298
|
+
const iContains = (value) => ({ $iContains: value });
|
3094
4299
|
const includes = (value) => ({ $includes: value });
|
3095
4300
|
const includesAll = (value) => ({ $includesAll: value });
|
3096
4301
|
const includesNone = (value) => ({ $includesNone: value });
|
@@ -3146,6 +4351,80 @@ class SchemaPlugin extends XataPlugin {
|
|
3146
4351
|
_tables = new WeakMap();
|
3147
4352
|
_schemaTables$1 = new WeakMap();
|
3148
4353
|
|
4354
|
+
class FilesPlugin extends XataPlugin {
|
4355
|
+
build(pluginOptions) {
|
4356
|
+
return {
|
4357
|
+
download: async (location) => {
|
4358
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
4359
|
+
return await getFileItem({
|
4360
|
+
pathParams: {
|
4361
|
+
workspace: "{workspaceId}",
|
4362
|
+
dbBranchName: "{dbBranch}",
|
4363
|
+
region: "{region}",
|
4364
|
+
tableName: table ?? "",
|
4365
|
+
recordId: record ?? "",
|
4366
|
+
columnName: column ?? "",
|
4367
|
+
fileId
|
4368
|
+
},
|
4369
|
+
...pluginOptions,
|
4370
|
+
rawResponse: true
|
4371
|
+
});
|
4372
|
+
},
|
4373
|
+
upload: async (location, file, options) => {
|
4374
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
4375
|
+
const resolvedFile = await file;
|
4376
|
+
const contentType = options?.mediaType || getContentType(resolvedFile);
|
4377
|
+
const body = resolvedFile instanceof XataFile ? resolvedFile.toBlob() : resolvedFile;
|
4378
|
+
return await putFileItem({
|
4379
|
+
...pluginOptions,
|
4380
|
+
pathParams: {
|
4381
|
+
workspace: "{workspaceId}",
|
4382
|
+
dbBranchName: "{dbBranch}",
|
4383
|
+
region: "{region}",
|
4384
|
+
tableName: table ?? "",
|
4385
|
+
recordId: record ?? "",
|
4386
|
+
columnName: column ?? "",
|
4387
|
+
fileId
|
4388
|
+
},
|
4389
|
+
body,
|
4390
|
+
headers: { "Content-Type": contentType }
|
4391
|
+
});
|
4392
|
+
},
|
4393
|
+
delete: async (location) => {
|
4394
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
4395
|
+
return await deleteFileItem({
|
4396
|
+
pathParams: {
|
4397
|
+
workspace: "{workspaceId}",
|
4398
|
+
dbBranchName: "{dbBranch}",
|
4399
|
+
region: "{region}",
|
4400
|
+
tableName: table ?? "",
|
4401
|
+
recordId: record ?? "",
|
4402
|
+
columnName: column ?? "",
|
4403
|
+
fileId
|
4404
|
+
},
|
4405
|
+
...pluginOptions
|
4406
|
+
});
|
4407
|
+
}
|
4408
|
+
};
|
4409
|
+
}
|
4410
|
+
}
|
4411
|
+
function getContentType(file) {
|
4412
|
+
if (typeof file === "string") {
|
4413
|
+
return "text/plain";
|
4414
|
+
}
|
4415
|
+
if ("mediaType" in file && file.mediaType !== void 0) {
|
4416
|
+
return file.mediaType;
|
4417
|
+
}
|
4418
|
+
if (isBlob(file)) {
|
4419
|
+
return file.type;
|
4420
|
+
}
|
4421
|
+
try {
|
4422
|
+
return file.type;
|
4423
|
+
} catch (e) {
|
4424
|
+
}
|
4425
|
+
return "application/octet-stream";
|
4426
|
+
}
|
4427
|
+
|
3149
4428
|
var __accessCheck$1 = (obj, member, msg) => {
|
3150
4429
|
if (!member.has(obj))
|
3151
4430
|
throw TypeError("Cannot " + msg);
|
@@ -3178,63 +4457,137 @@ class SearchPlugin extends XataPlugin {
|
|
3178
4457
|
__privateAdd$1(this, _schemaTables, void 0);
|
3179
4458
|
__privateSet$1(this, _schemaTables, schemaTables);
|
3180
4459
|
}
|
3181
|
-
build(
|
4460
|
+
build(pluginOptions) {
|
3182
4461
|
return {
|
3183
4462
|
all: async (query, options = {}) => {
|
3184
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
3185
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
3186
|
-
return
|
3187
|
-
|
3188
|
-
|
3189
|
-
|
4463
|
+
const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4464
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
4465
|
+
return {
|
4466
|
+
totalCount,
|
4467
|
+
records: records.map((record) => {
|
4468
|
+
const { table = "orphan" } = record.xata;
|
4469
|
+
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
4470
|
+
})
|
4471
|
+
};
|
3190
4472
|
},
|
3191
4473
|
byTable: async (query, options = {}) => {
|
3192
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
3193
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
3194
|
-
|
4474
|
+
const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4475
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
4476
|
+
const records = rawRecords.reduce((acc, record) => {
|
3195
4477
|
const { table = "orphan" } = record.xata;
|
3196
4478
|
const items = acc[table] ?? [];
|
3197
4479
|
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
3198
4480
|
return { ...acc, [table]: [...items, item] };
|
3199
4481
|
}, {});
|
4482
|
+
return { totalCount, records };
|
3200
4483
|
}
|
3201
4484
|
};
|
3202
4485
|
}
|
3203
4486
|
}
|
3204
4487
|
_schemaTables = new WeakMap();
|
3205
4488
|
_search = new WeakSet();
|
3206
|
-
search_fn = async function(query, options,
|
3207
|
-
const fetchProps = await getFetchProps();
|
4489
|
+
search_fn = async function(query, options, pluginOptions) {
|
3208
4490
|
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
3209
|
-
const { records } = await searchBranch({
|
4491
|
+
const { records, totalCount } = await searchBranch({
|
3210
4492
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4493
|
+
// @ts-ignore https://github.com/xataio/client-ts/issues/313
|
3211
4494
|
body: { tables, query, fuzziness, prefix, highlight, page },
|
3212
|
-
...
|
4495
|
+
...pluginOptions
|
3213
4496
|
});
|
3214
|
-
return records;
|
4497
|
+
return { records, totalCount };
|
3215
4498
|
};
|
3216
4499
|
_getSchemaTables = new WeakSet();
|
3217
|
-
getSchemaTables_fn = async function(
|
4500
|
+
getSchemaTables_fn = async function(pluginOptions) {
|
3218
4501
|
if (__privateGet$1(this, _schemaTables))
|
3219
4502
|
return __privateGet$1(this, _schemaTables);
|
3220
|
-
const fetchProps = await getFetchProps();
|
3221
4503
|
const { schema } = await getBranchDetails({
|
3222
4504
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3223
|
-
...
|
4505
|
+
...pluginOptions
|
3224
4506
|
});
|
3225
4507
|
__privateSet$1(this, _schemaTables, schema.tables);
|
3226
4508
|
return schema.tables;
|
3227
4509
|
};
|
3228
4510
|
|
4511
|
+
function escapeElement(elementRepresentation) {
|
4512
|
+
const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
4513
|
+
return '"' + escaped + '"';
|
4514
|
+
}
|
4515
|
+
function arrayString(val) {
|
4516
|
+
let result = "{";
|
4517
|
+
for (let i = 0; i < val.length; i++) {
|
4518
|
+
if (i > 0) {
|
4519
|
+
result = result + ",";
|
4520
|
+
}
|
4521
|
+
if (val[i] === null || typeof val[i] === "undefined") {
|
4522
|
+
result = result + "NULL";
|
4523
|
+
} else if (Array.isArray(val[i])) {
|
4524
|
+
result = result + arrayString(val[i]);
|
4525
|
+
} else if (val[i] instanceof Buffer) {
|
4526
|
+
result += "\\\\x" + val[i].toString("hex");
|
4527
|
+
} else {
|
4528
|
+
result += escapeElement(prepareValue(val[i]));
|
4529
|
+
}
|
4530
|
+
}
|
4531
|
+
result = result + "}";
|
4532
|
+
return result;
|
4533
|
+
}
|
4534
|
+
function prepareValue(value) {
|
4535
|
+
if (!isDefined(value))
|
4536
|
+
return null;
|
4537
|
+
if (value instanceof Date) {
|
4538
|
+
return value.toISOString();
|
4539
|
+
}
|
4540
|
+
if (Array.isArray(value)) {
|
4541
|
+
return arrayString(value);
|
4542
|
+
}
|
4543
|
+
if (isObject(value)) {
|
4544
|
+
return JSON.stringify(value);
|
4545
|
+
}
|
4546
|
+
try {
|
4547
|
+
return value.toString();
|
4548
|
+
} catch (e) {
|
4549
|
+
return value;
|
4550
|
+
}
|
4551
|
+
}
|
4552
|
+
function prepareParams(param1, param2) {
|
4553
|
+
if (isString(param1)) {
|
4554
|
+
return { statement: param1, params: param2?.map((value) => prepareValue(value)) };
|
4555
|
+
}
|
4556
|
+
if (isStringArray(param1)) {
|
4557
|
+
const statement = param1.reduce((acc, curr, index) => {
|
4558
|
+
return acc + curr + (index < (param2?.length ?? 0) ? "$" + (index + 1) : "");
|
4559
|
+
}, "");
|
4560
|
+
return { statement, params: param2?.map((value) => prepareValue(value)) };
|
4561
|
+
}
|
4562
|
+
if (isObject(param1)) {
|
4563
|
+
const { statement, params, consistency } = param1;
|
4564
|
+
return { statement, params: params?.map((value) => prepareValue(value)), consistency };
|
4565
|
+
}
|
4566
|
+
throw new Error("Invalid query");
|
4567
|
+
}
|
4568
|
+
|
4569
|
+
class SQLPlugin extends XataPlugin {
|
4570
|
+
build(pluginOptions) {
|
4571
|
+
return async (param1, ...param2) => {
|
4572
|
+
const { statement, params, consistency } = prepareParams(param1, param2);
|
4573
|
+
const { records, warning } = await sqlQuery({
|
4574
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4575
|
+
body: { statement, params, consistency },
|
4576
|
+
...pluginOptions
|
4577
|
+
});
|
4578
|
+
return { records, warning };
|
4579
|
+
};
|
4580
|
+
}
|
4581
|
+
}
|
4582
|
+
|
3229
4583
|
class TransactionPlugin extends XataPlugin {
|
3230
|
-
build(
|
4584
|
+
build(pluginOptions) {
|
3231
4585
|
return {
|
3232
4586
|
run: async (operations) => {
|
3233
|
-
const fetchProps = await getFetchProps();
|
3234
4587
|
const response = await branchTransaction({
|
3235
4588
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3236
4589
|
body: { operations },
|
3237
|
-
...
|
4590
|
+
...pluginOptions
|
3238
4591
|
});
|
3239
4592
|
return response;
|
3240
4593
|
}
|
@@ -3242,91 +4595,6 @@ class TransactionPlugin extends XataPlugin {
|
|
3242
4595
|
}
|
3243
4596
|
}
|
3244
4597
|
|
3245
|
-
const isBranchStrategyBuilder = (strategy) => {
|
3246
|
-
return typeof strategy === "function";
|
3247
|
-
};
|
3248
|
-
|
3249
|
-
async function getCurrentBranchName(options) {
|
3250
|
-
const { branch, envBranch } = getEnvironment();
|
3251
|
-
if (branch)
|
3252
|
-
return branch;
|
3253
|
-
const gitBranch = envBranch || await getGitBranch();
|
3254
|
-
return resolveXataBranch(gitBranch, options);
|
3255
|
-
}
|
3256
|
-
async function getCurrentBranchDetails(options) {
|
3257
|
-
const branch = await getCurrentBranchName(options);
|
3258
|
-
return getDatabaseBranch(branch, options);
|
3259
|
-
}
|
3260
|
-
async function resolveXataBranch(gitBranch, options) {
|
3261
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
3262
|
-
const apiKey = options?.apiKey || getAPIKey();
|
3263
|
-
if (!databaseURL)
|
3264
|
-
throw new Error(
|
3265
|
-
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
3266
|
-
);
|
3267
|
-
if (!apiKey)
|
3268
|
-
throw new Error(
|
3269
|
-
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
3270
|
-
);
|
3271
|
-
const [protocol, , host, , dbName] = databaseURL.split("/");
|
3272
|
-
const urlParts = parseWorkspacesUrlParts(host);
|
3273
|
-
if (!urlParts)
|
3274
|
-
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3275
|
-
const { workspace, region } = urlParts;
|
3276
|
-
const { fallbackBranch } = getEnvironment();
|
3277
|
-
const { branch } = await resolveBranch({
|
3278
|
-
apiKey,
|
3279
|
-
apiUrl: databaseURL,
|
3280
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
3281
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
3282
|
-
pathParams: { dbName, workspace, region },
|
3283
|
-
queryParams: { gitBranch, fallbackBranch },
|
3284
|
-
trace: defaultTrace,
|
3285
|
-
clientName: options?.clientName,
|
3286
|
-
xataAgentExtra: options?.xataAgentExtra
|
3287
|
-
});
|
3288
|
-
return branch;
|
3289
|
-
}
|
3290
|
-
async function getDatabaseBranch(branch, options) {
|
3291
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
3292
|
-
const apiKey = options?.apiKey || getAPIKey();
|
3293
|
-
if (!databaseURL)
|
3294
|
-
throw new Error(
|
3295
|
-
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
3296
|
-
);
|
3297
|
-
if (!apiKey)
|
3298
|
-
throw new Error(
|
3299
|
-
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
3300
|
-
);
|
3301
|
-
const [protocol, , host, , database] = databaseURL.split("/");
|
3302
|
-
const urlParts = parseWorkspacesUrlParts(host);
|
3303
|
-
if (!urlParts)
|
3304
|
-
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3305
|
-
const { workspace, region } = urlParts;
|
3306
|
-
try {
|
3307
|
-
return await getBranchDetails({
|
3308
|
-
apiKey,
|
3309
|
-
apiUrl: databaseURL,
|
3310
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
3311
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
3312
|
-
pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
|
3313
|
-
trace: defaultTrace
|
3314
|
-
});
|
3315
|
-
} catch (err) {
|
3316
|
-
if (isObject(err) && err.status === 404)
|
3317
|
-
return null;
|
3318
|
-
throw err;
|
3319
|
-
}
|
3320
|
-
}
|
3321
|
-
function getDatabaseURL() {
|
3322
|
-
try {
|
3323
|
-
const { databaseURL } = getEnvironment();
|
3324
|
-
return databaseURL;
|
3325
|
-
} catch (err) {
|
3326
|
-
return void 0;
|
3327
|
-
}
|
3328
|
-
}
|
3329
|
-
|
3330
4598
|
var __accessCheck = (obj, member, msg) => {
|
3331
4599
|
if (!member.has(obj))
|
3332
4600
|
throw TypeError("Cannot " + msg);
|
@@ -3350,46 +4618,41 @@ var __privateMethod = (obj, member, method) => {
|
|
3350
4618
|
return method;
|
3351
4619
|
};
|
3352
4620
|
const buildClient = (plugins) => {
|
3353
|
-
var
|
4621
|
+
var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
|
3354
4622
|
return _a = class {
|
3355
4623
|
constructor(options = {}, schemaTables) {
|
3356
4624
|
__privateAdd(this, _parseOptions);
|
3357
4625
|
__privateAdd(this, _getFetchProps);
|
3358
|
-
__privateAdd(this, _evaluateBranch);
|
3359
|
-
__privateAdd(this, _branch, void 0);
|
3360
4626
|
__privateAdd(this, _options, void 0);
|
3361
4627
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
3362
4628
|
__privateSet(this, _options, safeOptions);
|
3363
4629
|
const pluginOptions = {
|
3364
|
-
|
4630
|
+
...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
3365
4631
|
cache: safeOptions.cache,
|
3366
|
-
|
4632
|
+
host: safeOptions.host
|
3367
4633
|
};
|
3368
4634
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
3369
4635
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
3370
4636
|
const transactions = new TransactionPlugin().build(pluginOptions);
|
4637
|
+
const sql = new SQLPlugin().build(pluginOptions);
|
4638
|
+
const files = new FilesPlugin().build(pluginOptions);
|
3371
4639
|
this.db = db;
|
3372
4640
|
this.search = search;
|
3373
4641
|
this.transactions = transactions;
|
4642
|
+
this.sql = sql;
|
4643
|
+
this.files = files;
|
3374
4644
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
3375
4645
|
if (namespace === void 0)
|
3376
4646
|
continue;
|
3377
|
-
|
3378
|
-
if (result instanceof Promise) {
|
3379
|
-
void result.then((namespace2) => {
|
3380
|
-
this[key] = namespace2;
|
3381
|
-
});
|
3382
|
-
} else {
|
3383
|
-
this[key] = result;
|
3384
|
-
}
|
4647
|
+
this[key] = namespace.build(pluginOptions);
|
3385
4648
|
}
|
3386
4649
|
}
|
3387
4650
|
async getConfig() {
|
3388
4651
|
const databaseURL = __privateGet(this, _options).databaseURL;
|
3389
|
-
const branch =
|
4652
|
+
const branch = __privateGet(this, _options).branch;
|
3390
4653
|
return { databaseURL, branch };
|
3391
4654
|
}
|
3392
|
-
},
|
4655
|
+
}, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
3393
4656
|
const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
|
3394
4657
|
const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
|
3395
4658
|
if (isBrowser && !enableBrowser) {
|
@@ -3403,20 +4666,34 @@ const buildClient = (plugins) => {
|
|
3403
4666
|
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
3404
4667
|
const trace = options?.trace ?? defaultTrace;
|
3405
4668
|
const clientName = options?.clientName;
|
4669
|
+
const host = options?.host ?? "production";
|
3406
4670
|
const xataAgentExtra = options?.xataAgentExtra;
|
3407
|
-
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({
|
3408
|
-
apiKey,
|
3409
|
-
databaseURL,
|
3410
|
-
fetchImpl: options?.fetch,
|
3411
|
-
clientName,
|
3412
|
-
xataAgentExtra
|
3413
|
-
});
|
3414
4671
|
if (!apiKey) {
|
3415
4672
|
throw new Error("Option apiKey is required");
|
3416
4673
|
}
|
3417
4674
|
if (!databaseURL) {
|
3418
4675
|
throw new Error("Option databaseURL is required");
|
3419
4676
|
}
|
4677
|
+
const envBranch = getBranch();
|
4678
|
+
const previewBranch = getPreviewBranch();
|
4679
|
+
const branch = options?.branch || previewBranch || envBranch || "main";
|
4680
|
+
if (!!previewBranch && branch !== previewBranch) {
|
4681
|
+
console.warn(
|
4682
|
+
`Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
|
4683
|
+
);
|
4684
|
+
} else if (!!envBranch && branch !== envBranch) {
|
4685
|
+
console.warn(
|
4686
|
+
`Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
4687
|
+
);
|
4688
|
+
} else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
|
4689
|
+
console.warn(
|
4690
|
+
`Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
4691
|
+
);
|
4692
|
+
} else if (!previewBranch && !envBranch && options?.branch === void 0) {
|
4693
|
+
console.warn(
|
4694
|
+
`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.`
|
4695
|
+
);
|
4696
|
+
}
|
3420
4697
|
return {
|
3421
4698
|
fetch,
|
3422
4699
|
databaseURL,
|
@@ -3424,12 +4701,13 @@ const buildClient = (plugins) => {
|
|
3424
4701
|
branch,
|
3425
4702
|
cache,
|
3426
4703
|
trace,
|
4704
|
+
host,
|
3427
4705
|
clientID: generateUUID(),
|
3428
4706
|
enableBrowser,
|
3429
4707
|
clientName,
|
3430
4708
|
xataAgentExtra
|
3431
4709
|
};
|
3432
|
-
}, _getFetchProps = new WeakSet(), getFetchProps_fn =
|
4710
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
|
3433
4711
|
fetch,
|
3434
4712
|
apiKey,
|
3435
4713
|
databaseURL,
|
@@ -3439,16 +4717,14 @@ const buildClient = (plugins) => {
|
|
3439
4717
|
clientName,
|
3440
4718
|
xataAgentExtra
|
3441
4719
|
}) {
|
3442
|
-
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
3443
|
-
if (!branchValue)
|
3444
|
-
throw new Error("Unable to resolve branch value");
|
3445
4720
|
return {
|
3446
|
-
|
4721
|
+
fetch,
|
3447
4722
|
apiKey,
|
3448
4723
|
apiUrl: "",
|
4724
|
+
// Instead of using workspace and dbBranch, we inject a probably CNAME'd URL
|
3449
4725
|
workspacesApiUrl: (path, params) => {
|
3450
4726
|
const hasBranch = params.dbBranchName ?? params.branch;
|
3451
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${
|
4727
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
|
3452
4728
|
return databaseURL + newPath;
|
3453
4729
|
},
|
3454
4730
|
trace,
|
@@ -3456,22 +4732,6 @@ const buildClient = (plugins) => {
|
|
3456
4732
|
clientName,
|
3457
4733
|
xataAgentExtra
|
3458
4734
|
};
|
3459
|
-
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
3460
|
-
if (__privateGet(this, _branch))
|
3461
|
-
return __privateGet(this, _branch);
|
3462
|
-
if (param === void 0)
|
3463
|
-
return void 0;
|
3464
|
-
const strategies = Array.isArray(param) ? [...param] : [param];
|
3465
|
-
const evaluateBranch = async (strategy) => {
|
3466
|
-
return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
|
3467
|
-
};
|
3468
|
-
for await (const strategy of strategies) {
|
3469
|
-
const branch = await evaluateBranch(strategy);
|
3470
|
-
if (branch) {
|
3471
|
-
__privateSet(this, _branch, branch);
|
3472
|
-
return branch;
|
3473
|
-
}
|
3474
|
-
}
|
3475
4735
|
}, _a;
|
3476
4736
|
};
|
3477
4737
|
class BaseClient extends buildClient() {
|
@@ -3544,21 +4804,6 @@ const deserialize = (json) => {
|
|
3544
4804
|
return defaultSerializer.fromJSON(json);
|
3545
4805
|
};
|
3546
4806
|
|
3547
|
-
function buildWorkerRunner(config) {
|
3548
|
-
return function xataWorker(name, worker) {
|
3549
|
-
return async (...args) => {
|
3550
|
-
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
3551
|
-
const result = await fetch(url, {
|
3552
|
-
method: "POST",
|
3553
|
-
headers: { "Content-Type": "application/json" },
|
3554
|
-
body: serialize({ args })
|
3555
|
-
});
|
3556
|
-
const text = await result.text();
|
3557
|
-
return deserialize(text);
|
3558
|
-
};
|
3559
|
-
};
|
3560
|
-
}
|
3561
|
-
|
3562
4807
|
class XataError extends Error {
|
3563
4808
|
constructor(message, status) {
|
3564
4809
|
super(message);
|
@@ -3568,6 +4813,7 @@ class XataError extends Error {
|
|
3568
4813
|
|
3569
4814
|
exports.BaseClient = BaseClient;
|
3570
4815
|
exports.FetcherError = FetcherError;
|
4816
|
+
exports.FilesPlugin = FilesPlugin;
|
3571
4817
|
exports.Operations = operationsByTag;
|
3572
4818
|
exports.PAGINATION_DEFAULT_OFFSET = PAGINATION_DEFAULT_OFFSET;
|
3573
4819
|
exports.PAGINATION_DEFAULT_SIZE = PAGINATION_DEFAULT_SIZE;
|
@@ -3576,31 +4822,41 @@ exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
|
|
3576
4822
|
exports.Page = Page;
|
3577
4823
|
exports.Query = Query;
|
3578
4824
|
exports.RecordArray = RecordArray;
|
4825
|
+
exports.RecordColumnTypes = RecordColumnTypes;
|
3579
4826
|
exports.Repository = Repository;
|
3580
4827
|
exports.RestRepository = RestRepository;
|
4828
|
+
exports.SQLPlugin = SQLPlugin;
|
3581
4829
|
exports.SchemaPlugin = SchemaPlugin;
|
3582
4830
|
exports.SearchPlugin = SearchPlugin;
|
3583
4831
|
exports.Serializer = Serializer;
|
3584
4832
|
exports.SimpleCache = SimpleCache;
|
4833
|
+
exports.TransactionPlugin = TransactionPlugin;
|
3585
4834
|
exports.XataApiClient = XataApiClient;
|
3586
4835
|
exports.XataApiPlugin = XataApiPlugin;
|
3587
4836
|
exports.XataError = XataError;
|
4837
|
+
exports.XataFile = XataFile;
|
3588
4838
|
exports.XataPlugin = XataPlugin;
|
3589
4839
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
3590
4840
|
exports.addGitBranchesEntry = addGitBranchesEntry;
|
3591
4841
|
exports.addTableColumn = addTableColumn;
|
3592
4842
|
exports.aggregateTable = aggregateTable;
|
3593
4843
|
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
4844
|
+
exports.applyMigration = applyMigration;
|
4845
|
+
exports.askTable = askTable;
|
4846
|
+
exports.askTableSession = askTableSession;
|
3594
4847
|
exports.branchTransaction = branchTransaction;
|
3595
4848
|
exports.buildClient = buildClient;
|
3596
|
-
exports.
|
4849
|
+
exports.buildPreviewBranchName = buildPreviewBranchName;
|
4850
|
+
exports.buildProviderString = buildProviderString;
|
3597
4851
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
3598
4852
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
3599
4853
|
exports.compareBranchSchemas = compareBranchSchemas;
|
3600
4854
|
exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
|
3601
4855
|
exports.compareMigrationRequest = compareMigrationRequest;
|
3602
4856
|
exports.contains = contains;
|
4857
|
+
exports.copyBranch = copyBranch;
|
3603
4858
|
exports.createBranch = createBranch;
|
4859
|
+
exports.createCluster = createCluster;
|
3604
4860
|
exports.createDatabase = createDatabase;
|
3605
4861
|
exports.createMigrationRequest = createMigrationRequest;
|
3606
4862
|
exports.createTable = createTable;
|
@@ -3610,18 +4866,26 @@ exports.deleteBranch = deleteBranch;
|
|
3610
4866
|
exports.deleteColumn = deleteColumn;
|
3611
4867
|
exports.deleteDatabase = deleteDatabase;
|
3612
4868
|
exports.deleteDatabaseGithubSettings = deleteDatabaseGithubSettings;
|
4869
|
+
exports.deleteFile = deleteFile;
|
4870
|
+
exports.deleteFileItem = deleteFileItem;
|
4871
|
+
exports.deleteOAuthAccessToken = deleteOAuthAccessToken;
|
3613
4872
|
exports.deleteRecord = deleteRecord;
|
3614
4873
|
exports.deleteTable = deleteTable;
|
3615
4874
|
exports.deleteUser = deleteUser;
|
3616
4875
|
exports.deleteUserAPIKey = deleteUserAPIKey;
|
4876
|
+
exports.deleteUserOAuthClient = deleteUserOAuthClient;
|
3617
4877
|
exports.deleteWorkspace = deleteWorkspace;
|
3618
4878
|
exports.deserialize = deserialize;
|
3619
4879
|
exports.endsWith = endsWith;
|
3620
4880
|
exports.equals = equals;
|
3621
4881
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
3622
4882
|
exports.exists = exists;
|
4883
|
+
exports.fileAccess = fileAccess;
|
4884
|
+
exports.fileUpload = fileUpload;
|
3623
4885
|
exports.ge = ge;
|
3624
4886
|
exports.getAPIKey = getAPIKey;
|
4887
|
+
exports.getAuthorizationCode = getAuthorizationCode;
|
4888
|
+
exports.getBranch = getBranch;
|
3625
4889
|
exports.getBranchDetails = getBranchDetails;
|
3626
4890
|
exports.getBranchList = getBranchList;
|
3627
4891
|
exports.getBranchMetadata = getBranchMetadata;
|
@@ -3629,30 +4893,38 @@ exports.getBranchMigrationHistory = getBranchMigrationHistory;
|
|
3629
4893
|
exports.getBranchMigrationPlan = getBranchMigrationPlan;
|
3630
4894
|
exports.getBranchSchemaHistory = getBranchSchemaHistory;
|
3631
4895
|
exports.getBranchStats = getBranchStats;
|
4896
|
+
exports.getCluster = getCluster;
|
3632
4897
|
exports.getColumn = getColumn;
|
3633
|
-
exports.getCurrentBranchDetails = getCurrentBranchDetails;
|
3634
|
-
exports.getCurrentBranchName = getCurrentBranchName;
|
3635
4898
|
exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
|
3636
4899
|
exports.getDatabaseList = getDatabaseList;
|
3637
4900
|
exports.getDatabaseMetadata = getDatabaseMetadata;
|
3638
4901
|
exports.getDatabaseURL = getDatabaseURL;
|
4902
|
+
exports.getFile = getFile;
|
4903
|
+
exports.getFileItem = getFileItem;
|
3639
4904
|
exports.getGitBranchesMapping = getGitBranchesMapping;
|
3640
4905
|
exports.getHostUrl = getHostUrl;
|
3641
4906
|
exports.getMigrationRequest = getMigrationRequest;
|
3642
4907
|
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
4908
|
+
exports.getPreviewBranch = getPreviewBranch;
|
3643
4909
|
exports.getRecord = getRecord;
|
4910
|
+
exports.getSchema = getSchema;
|
3644
4911
|
exports.getTableColumns = getTableColumns;
|
3645
4912
|
exports.getTableSchema = getTableSchema;
|
3646
4913
|
exports.getUser = getUser;
|
3647
4914
|
exports.getUserAPIKeys = getUserAPIKeys;
|
4915
|
+
exports.getUserOAuthAccessTokens = getUserOAuthAccessTokens;
|
4916
|
+
exports.getUserOAuthClients = getUserOAuthClients;
|
3648
4917
|
exports.getWorkspace = getWorkspace;
|
3649
4918
|
exports.getWorkspaceMembersList = getWorkspaceMembersList;
|
3650
4919
|
exports.getWorkspacesList = getWorkspacesList;
|
4920
|
+
exports.grantAuthorizationCode = grantAuthorizationCode;
|
3651
4921
|
exports.greaterEquals = greaterEquals;
|
3652
4922
|
exports.greaterThan = greaterThan;
|
3653
4923
|
exports.greaterThanEquals = greaterThanEquals;
|
3654
4924
|
exports.gt = gt;
|
3655
4925
|
exports.gte = gte;
|
4926
|
+
exports.iContains = iContains;
|
4927
|
+
exports.iPattern = iPattern;
|
3656
4928
|
exports.includes = includes;
|
3657
4929
|
exports.includesAll = includesAll;
|
3658
4930
|
exports.includesAny = includesAny;
|
@@ -3666,11 +4938,14 @@ exports.isHostProviderAlias = isHostProviderAlias;
|
|
3666
4938
|
exports.isHostProviderBuilder = isHostProviderBuilder;
|
3667
4939
|
exports.isIdentifiable = isIdentifiable;
|
3668
4940
|
exports.isNot = isNot;
|
4941
|
+
exports.isValidExpandedColumn = isValidExpandedColumn;
|
4942
|
+
exports.isValidSelectableColumns = isValidSelectableColumns;
|
3669
4943
|
exports.isXataRecord = isXataRecord;
|
3670
4944
|
exports.le = le;
|
3671
4945
|
exports.lessEquals = lessEquals;
|
3672
4946
|
exports.lessThan = lessThan;
|
3673
4947
|
exports.lessThanEquals = lessThanEquals;
|
4948
|
+
exports.listClusters = listClusters;
|
3674
4949
|
exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
|
3675
4950
|
exports.listRegions = listRegions;
|
3676
4951
|
exports.lt = lt;
|
@@ -3681,25 +4956,35 @@ exports.operationsByTag = operationsByTag;
|
|
3681
4956
|
exports.parseProviderString = parseProviderString;
|
3682
4957
|
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
3683
4958
|
exports.pattern = pattern;
|
4959
|
+
exports.pgRollJobStatus = pgRollJobStatus;
|
4960
|
+
exports.pgRollStatus = pgRollStatus;
|
3684
4961
|
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
4962
|
+
exports.pushBranchMigrations = pushBranchMigrations;
|
4963
|
+
exports.putFile = putFile;
|
4964
|
+
exports.putFileItem = putFileItem;
|
3685
4965
|
exports.queryMigrationRequests = queryMigrationRequests;
|
3686
4966
|
exports.queryTable = queryTable;
|
3687
4967
|
exports.removeGitBranchesEntry = removeGitBranchesEntry;
|
3688
4968
|
exports.removeWorkspaceMember = removeWorkspaceMember;
|
4969
|
+
exports.renameDatabase = renameDatabase;
|
3689
4970
|
exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
|
3690
4971
|
exports.resolveBranch = resolveBranch;
|
3691
4972
|
exports.searchBranch = searchBranch;
|
3692
4973
|
exports.searchTable = searchTable;
|
3693
4974
|
exports.serialize = serialize;
|
3694
4975
|
exports.setTableSchema = setTableSchema;
|
4976
|
+
exports.sqlQuery = sqlQuery;
|
3695
4977
|
exports.startsWith = startsWith;
|
3696
4978
|
exports.summarizeTable = summarizeTable;
|
4979
|
+
exports.transformImage = transformImage;
|
3697
4980
|
exports.updateBranchMetadata = updateBranchMetadata;
|
3698
4981
|
exports.updateBranchSchema = updateBranchSchema;
|
4982
|
+
exports.updateCluster = updateCluster;
|
3699
4983
|
exports.updateColumn = updateColumn;
|
3700
4984
|
exports.updateDatabaseGithubSettings = updateDatabaseGithubSettings;
|
3701
4985
|
exports.updateDatabaseMetadata = updateDatabaseMetadata;
|
3702
4986
|
exports.updateMigrationRequest = updateMigrationRequest;
|
4987
|
+
exports.updateOAuthAccessToken = updateOAuthAccessToken;
|
3703
4988
|
exports.updateRecordWithID = updateRecordWithID;
|
3704
4989
|
exports.updateTable = updateTable;
|
3705
4990
|
exports.updateUser = updateUser;
|
@@ -3707,4 +4992,5 @@ exports.updateWorkspace = updateWorkspace;
|
|
3707
4992
|
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
3708
4993
|
exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
|
3709
4994
|
exports.upsertRecordWithID = upsertRecordWithID;
|
4995
|
+
exports.vectorSearchTable = vectorSearchTable;
|
3710
4996
|
//# sourceMappingURL=index.cjs.map
|