@xata.io/client 0.0.0-alpha.vfe07d64 → 0.0.0-alpha.vfe1509c97472488e5d1b48df0fac2546209a2944
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 +257 -1
- package/dist/index.cjs +1663 -379
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4618 -2335
- package/dist/index.mjs +1619 -376
- 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,15 +714,16 @@ 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
|
-
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
726
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\.[^.]+\./, "http://") : fullUrl;
|
409
727
|
setAttributes({
|
410
728
|
[TraceAttributes.HTTP_URL]: url,
|
411
729
|
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
@@ -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,20 @@ 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
|
+
});
|
863
|
+
const pgRollMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/pgroll/migrations", method: "get", ...variables, signal });
|
475
864
|
const getBranchList = (variables, signal) => dataPlaneFetch({
|
476
865
|
url: "/dbs/{dbName}",
|
477
866
|
method: "get",
|
@@ -491,6 +880,18 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
|
|
491
880
|
...variables,
|
492
881
|
signal
|
493
882
|
});
|
883
|
+
const getSchema = (variables, signal) => dataPlaneFetch({
|
884
|
+
url: "/db/{dbBranchName}/schema",
|
885
|
+
method: "get",
|
886
|
+
...variables,
|
887
|
+
signal
|
888
|
+
});
|
889
|
+
const copyBranch = (variables, signal) => dataPlaneFetch({
|
890
|
+
url: "/db/{dbBranchName}/copy",
|
891
|
+
method: "post",
|
892
|
+
...variables,
|
893
|
+
signal
|
894
|
+
});
|
494
895
|
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
495
896
|
url: "/db/{dbBranchName}/metadata",
|
496
897
|
method: "put",
|
@@ -540,6 +941,7 @@ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{
|
|
540
941
|
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
541
942
|
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
542
943
|
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
944
|
+
const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
|
543
945
|
const createTable = (variables, signal) => dataPlaneFetch({
|
544
946
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
545
947
|
method: "put",
|
@@ -584,6 +986,42 @@ const deleteColumn = (variables, signal) => dataPlaneFetch({
|
|
584
986
|
});
|
585
987
|
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
586
988
|
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
989
|
+
const getFileItem = (variables, signal) => dataPlaneFetch({
|
990
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
991
|
+
method: "get",
|
992
|
+
...variables,
|
993
|
+
signal
|
994
|
+
});
|
995
|
+
const putFileItem = (variables, signal) => dataPlaneFetch({
|
996
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
997
|
+
method: "put",
|
998
|
+
...variables,
|
999
|
+
signal
|
1000
|
+
});
|
1001
|
+
const deleteFileItem = (variables, signal) => dataPlaneFetch({
|
1002
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
1003
|
+
method: "delete",
|
1004
|
+
...variables,
|
1005
|
+
signal
|
1006
|
+
});
|
1007
|
+
const getFile = (variables, signal) => dataPlaneFetch({
|
1008
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
1009
|
+
method: "get",
|
1010
|
+
...variables,
|
1011
|
+
signal
|
1012
|
+
});
|
1013
|
+
const putFile = (variables, signal) => dataPlaneFetch({
|
1014
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
1015
|
+
method: "put",
|
1016
|
+
...variables,
|
1017
|
+
signal
|
1018
|
+
});
|
1019
|
+
const deleteFile = (variables, signal) => dataPlaneFetch({
|
1020
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
1021
|
+
method: "delete",
|
1022
|
+
...variables,
|
1023
|
+
signal
|
1024
|
+
});
|
587
1025
|
const getRecord = (variables, signal) => dataPlaneFetch({
|
588
1026
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
589
1027
|
method: "get",
|
@@ -613,14 +1051,45 @@ const searchTable = (variables, signal) => dataPlaneFetch({
|
|
613
1051
|
...variables,
|
614
1052
|
signal
|
615
1053
|
});
|
1054
|
+
const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
|
1055
|
+
const askTable = (variables, signal) => dataPlaneFetch({
|
1056
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
1057
|
+
method: "post",
|
1058
|
+
...variables,
|
1059
|
+
signal
|
1060
|
+
});
|
1061
|
+
const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
|
616
1062
|
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
617
1063
|
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
1064
|
+
const fileAccess = (variables, signal) => dataPlaneFetch({
|
1065
|
+
url: "/file/{fileId}",
|
1066
|
+
method: "get",
|
1067
|
+
...variables,
|
1068
|
+
signal
|
1069
|
+
});
|
1070
|
+
const fileUpload = (variables, signal) => dataPlaneFetch({
|
1071
|
+
url: "/file/{fileId}",
|
1072
|
+
method: "put",
|
1073
|
+
...variables,
|
1074
|
+
signal
|
1075
|
+
});
|
1076
|
+
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
1077
|
+
url: "/db/{dbBranchName}/sql",
|
1078
|
+
method: "post",
|
1079
|
+
...variables,
|
1080
|
+
signal
|
1081
|
+
});
|
618
1082
|
const operationsByTag$2 = {
|
619
1083
|
branch: {
|
1084
|
+
applyMigration,
|
1085
|
+
pgRollStatus,
|
1086
|
+
pgRollJobStatus,
|
1087
|
+
pgRollMigrationHistory,
|
620
1088
|
getBranchList,
|
621
1089
|
getBranchDetails,
|
622
1090
|
createBranch,
|
623
1091
|
deleteBranch,
|
1092
|
+
copyBranch,
|
624
1093
|
updateBranchMetadata,
|
625
1094
|
getBranchMetadata,
|
626
1095
|
getBranchStats,
|
@@ -630,6 +1099,7 @@ const operationsByTag$2 = {
|
|
630
1099
|
resolveBranch
|
631
1100
|
},
|
632
1101
|
migrations: {
|
1102
|
+
getSchema,
|
633
1103
|
getBranchMigrationHistory,
|
634
1104
|
getBranchMigrationPlan,
|
635
1105
|
executeBranchMigrationPlan,
|
@@ -638,7 +1108,8 @@ const operationsByTag$2 = {
|
|
638
1108
|
compareBranchSchemas,
|
639
1109
|
updateBranchSchema,
|
640
1110
|
previewBranchSchemaEdit,
|
641
|
-
applyBranchSchemaEdit
|
1111
|
+
applyBranchSchemaEdit,
|
1112
|
+
pushBranchMigrations
|
642
1113
|
},
|
643
1114
|
migrationRequests: {
|
644
1115
|
queryMigrationRequests,
|
@@ -672,11 +1143,24 @@ const operationsByTag$2 = {
|
|
672
1143
|
deleteRecord,
|
673
1144
|
bulkInsertTableRecords
|
674
1145
|
},
|
675
|
-
|
1146
|
+
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess, fileUpload },
|
1147
|
+
searchAndFilter: {
|
1148
|
+
queryTable,
|
1149
|
+
searchBranch,
|
1150
|
+
searchTable,
|
1151
|
+
vectorSearchTable,
|
1152
|
+
askTable,
|
1153
|
+
askTableSession,
|
1154
|
+
summarizeTable,
|
1155
|
+
aggregateTable
|
1156
|
+
},
|
1157
|
+
sql: { sqlQuery }
|
676
1158
|
};
|
677
1159
|
|
678
1160
|
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
679
1161
|
|
1162
|
+
const getAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "get", ...variables, signal });
|
1163
|
+
const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
|
680
1164
|
const getUser = (variables, signal) => controlPlaneFetch({
|
681
1165
|
url: "/user",
|
682
1166
|
method: "get",
|
@@ -713,6 +1197,31 @@ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
|
713
1197
|
...variables,
|
714
1198
|
signal
|
715
1199
|
});
|
1200
|
+
const getUserOAuthClients = (variables, signal) => controlPlaneFetch({
|
1201
|
+
url: "/user/oauth/clients",
|
1202
|
+
method: "get",
|
1203
|
+
...variables,
|
1204
|
+
signal
|
1205
|
+
});
|
1206
|
+
const deleteUserOAuthClient = (variables, signal) => controlPlaneFetch({
|
1207
|
+
url: "/user/oauth/clients/{clientId}",
|
1208
|
+
method: "delete",
|
1209
|
+
...variables,
|
1210
|
+
signal
|
1211
|
+
});
|
1212
|
+
const getUserOAuthAccessTokens = (variables, signal) => controlPlaneFetch({
|
1213
|
+
url: "/user/oauth/tokens",
|
1214
|
+
method: "get",
|
1215
|
+
...variables,
|
1216
|
+
signal
|
1217
|
+
});
|
1218
|
+
const deleteOAuthAccessToken = (variables, signal) => controlPlaneFetch({
|
1219
|
+
url: "/user/oauth/tokens/{token}",
|
1220
|
+
method: "delete",
|
1221
|
+
...variables,
|
1222
|
+
signal
|
1223
|
+
});
|
1224
|
+
const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({ url: "/user/oauth/tokens/{token}", method: "patch", ...variables, signal });
|
716
1225
|
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
717
1226
|
url: "/workspaces",
|
718
1227
|
method: "get",
|
@@ -756,6 +1265,15 @@ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ u
|
|
756
1265
|
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
757
1266
|
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
758
1267
|
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
1268
|
+
const listClusters = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "get", ...variables, signal });
|
1269
|
+
const createCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "post", ...variables, signal });
|
1270
|
+
const getCluster = (variables, signal) => controlPlaneFetch({
|
1271
|
+
url: "/workspaces/{workspaceId}/clusters/{clusterId}",
|
1272
|
+
method: "get",
|
1273
|
+
...variables,
|
1274
|
+
signal
|
1275
|
+
});
|
1276
|
+
const updateCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters/{clusterId}", method: "patch", ...variables, signal });
|
759
1277
|
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
760
1278
|
url: "/workspaces/{workspaceId}/dbs",
|
761
1279
|
method: "get",
|
@@ -771,6 +1289,7 @@ const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
|
771
1289
|
});
|
772
1290
|
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
773
1291
|
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
1292
|
+
const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
|
774
1293
|
const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
|
775
1294
|
const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
|
776
1295
|
const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
|
@@ -781,6 +1300,15 @@ const listRegions = (variables, signal) => controlPlaneFetch({
|
|
781
1300
|
signal
|
782
1301
|
});
|
783
1302
|
const operationsByTag$1 = {
|
1303
|
+
oAuth: {
|
1304
|
+
getAuthorizationCode,
|
1305
|
+
grantAuthorizationCode,
|
1306
|
+
getUserOAuthClients,
|
1307
|
+
deleteUserOAuthClient,
|
1308
|
+
getUserOAuthAccessTokens,
|
1309
|
+
deleteOAuthAccessToken,
|
1310
|
+
updateOAuthAccessToken
|
1311
|
+
},
|
784
1312
|
users: { getUser, updateUser, deleteUser },
|
785
1313
|
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
786
1314
|
workspaces: {
|
@@ -800,12 +1328,14 @@ const operationsByTag$1 = {
|
|
800
1328
|
acceptWorkspaceMemberInvite,
|
801
1329
|
resendWorkspaceMemberInvite
|
802
1330
|
},
|
1331
|
+
xbcontrolOther: { listClusters, createCluster, getCluster, updateCluster },
|
803
1332
|
databases: {
|
804
1333
|
getDatabaseList,
|
805
1334
|
createDatabase,
|
806
1335
|
deleteDatabase,
|
807
1336
|
getDatabaseMetadata,
|
808
1337
|
updateDatabaseMetadata,
|
1338
|
+
renameDatabase,
|
809
1339
|
getDatabaseGithubSettings,
|
810
1340
|
updateDatabaseGithubSettings,
|
811
1341
|
deleteDatabaseGithubSettings,
|
@@ -815,51 +1345,6 @@ const operationsByTag$1 = {
|
|
815
1345
|
|
816
1346
|
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
817
1347
|
|
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
1348
|
var __accessCheck$7 = (obj, member, msg) => {
|
864
1349
|
if (!member.has(obj))
|
865
1350
|
throw TypeError("Cannot " + msg);
|
@@ -893,7 +1378,7 @@ class XataApiClient {
|
|
893
1378
|
__privateSet$7(this, _extraProps, {
|
894
1379
|
apiUrl: getHostUrl(provider, "main"),
|
895
1380
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
896
|
-
|
1381
|
+
fetch: getFetchImplementation(options.fetch),
|
897
1382
|
apiKey,
|
898
1383
|
trace,
|
899
1384
|
clientName: options.clientName,
|
@@ -951,6 +1436,11 @@ class XataApiClient {
|
|
951
1436
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
952
1437
|
return __privateGet$7(this, _namespaces).records;
|
953
1438
|
}
|
1439
|
+
get files() {
|
1440
|
+
if (!__privateGet$7(this, _namespaces).files)
|
1441
|
+
__privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
|
1442
|
+
return __privateGet$7(this, _namespaces).files;
|
1443
|
+
}
|
954
1444
|
get searchAndFilter() {
|
955
1445
|
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
956
1446
|
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
@@ -1159,6 +1649,20 @@ class BranchApi {
|
|
1159
1649
|
...this.extraProps
|
1160
1650
|
});
|
1161
1651
|
}
|
1652
|
+
copyBranch({
|
1653
|
+
workspace,
|
1654
|
+
region,
|
1655
|
+
database,
|
1656
|
+
branch,
|
1657
|
+
destinationBranch,
|
1658
|
+
limit
|
1659
|
+
}) {
|
1660
|
+
return operationsByTag.branch.copyBranch({
|
1661
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1662
|
+
body: { destinationBranch, limit },
|
1663
|
+
...this.extraProps
|
1664
|
+
});
|
1665
|
+
}
|
1162
1666
|
updateBranchMetadata({
|
1163
1667
|
workspace,
|
1164
1668
|
region,
|
@@ -1514,6 +2018,164 @@ class RecordsApi {
|
|
1514
2018
|
});
|
1515
2019
|
}
|
1516
2020
|
}
|
2021
|
+
class FilesApi {
|
2022
|
+
constructor(extraProps) {
|
2023
|
+
this.extraProps = extraProps;
|
2024
|
+
}
|
2025
|
+
getFileItem({
|
2026
|
+
workspace,
|
2027
|
+
region,
|
2028
|
+
database,
|
2029
|
+
branch,
|
2030
|
+
table,
|
2031
|
+
record,
|
2032
|
+
column,
|
2033
|
+
fileId
|
2034
|
+
}) {
|
2035
|
+
return operationsByTag.files.getFileItem({
|
2036
|
+
pathParams: {
|
2037
|
+
workspace,
|
2038
|
+
region,
|
2039
|
+
dbBranchName: `${database}:${branch}`,
|
2040
|
+
tableName: table,
|
2041
|
+
recordId: record,
|
2042
|
+
columnName: column,
|
2043
|
+
fileId
|
2044
|
+
},
|
2045
|
+
...this.extraProps
|
2046
|
+
});
|
2047
|
+
}
|
2048
|
+
putFileItem({
|
2049
|
+
workspace,
|
2050
|
+
region,
|
2051
|
+
database,
|
2052
|
+
branch,
|
2053
|
+
table,
|
2054
|
+
record,
|
2055
|
+
column,
|
2056
|
+
fileId,
|
2057
|
+
file
|
2058
|
+
}) {
|
2059
|
+
return operationsByTag.files.putFileItem({
|
2060
|
+
pathParams: {
|
2061
|
+
workspace,
|
2062
|
+
region,
|
2063
|
+
dbBranchName: `${database}:${branch}`,
|
2064
|
+
tableName: table,
|
2065
|
+
recordId: record,
|
2066
|
+
columnName: column,
|
2067
|
+
fileId
|
2068
|
+
},
|
2069
|
+
// @ts-ignore
|
2070
|
+
body: file,
|
2071
|
+
...this.extraProps
|
2072
|
+
});
|
2073
|
+
}
|
2074
|
+
deleteFileItem({
|
2075
|
+
workspace,
|
2076
|
+
region,
|
2077
|
+
database,
|
2078
|
+
branch,
|
2079
|
+
table,
|
2080
|
+
record,
|
2081
|
+
column,
|
2082
|
+
fileId
|
2083
|
+
}) {
|
2084
|
+
return operationsByTag.files.deleteFileItem({
|
2085
|
+
pathParams: {
|
2086
|
+
workspace,
|
2087
|
+
region,
|
2088
|
+
dbBranchName: `${database}:${branch}`,
|
2089
|
+
tableName: table,
|
2090
|
+
recordId: record,
|
2091
|
+
columnName: column,
|
2092
|
+
fileId
|
2093
|
+
},
|
2094
|
+
...this.extraProps
|
2095
|
+
});
|
2096
|
+
}
|
2097
|
+
getFile({
|
2098
|
+
workspace,
|
2099
|
+
region,
|
2100
|
+
database,
|
2101
|
+
branch,
|
2102
|
+
table,
|
2103
|
+
record,
|
2104
|
+
column
|
2105
|
+
}) {
|
2106
|
+
return operationsByTag.files.getFile({
|
2107
|
+
pathParams: {
|
2108
|
+
workspace,
|
2109
|
+
region,
|
2110
|
+
dbBranchName: `${database}:${branch}`,
|
2111
|
+
tableName: table,
|
2112
|
+
recordId: record,
|
2113
|
+
columnName: column
|
2114
|
+
},
|
2115
|
+
...this.extraProps
|
2116
|
+
});
|
2117
|
+
}
|
2118
|
+
putFile({
|
2119
|
+
workspace,
|
2120
|
+
region,
|
2121
|
+
database,
|
2122
|
+
branch,
|
2123
|
+
table,
|
2124
|
+
record,
|
2125
|
+
column,
|
2126
|
+
file
|
2127
|
+
}) {
|
2128
|
+
return operationsByTag.files.putFile({
|
2129
|
+
pathParams: {
|
2130
|
+
workspace,
|
2131
|
+
region,
|
2132
|
+
dbBranchName: `${database}:${branch}`,
|
2133
|
+
tableName: table,
|
2134
|
+
recordId: record,
|
2135
|
+
columnName: column
|
2136
|
+
},
|
2137
|
+
body: file,
|
2138
|
+
...this.extraProps
|
2139
|
+
});
|
2140
|
+
}
|
2141
|
+
deleteFile({
|
2142
|
+
workspace,
|
2143
|
+
region,
|
2144
|
+
database,
|
2145
|
+
branch,
|
2146
|
+
table,
|
2147
|
+
record,
|
2148
|
+
column
|
2149
|
+
}) {
|
2150
|
+
return operationsByTag.files.deleteFile({
|
2151
|
+
pathParams: {
|
2152
|
+
workspace,
|
2153
|
+
region,
|
2154
|
+
dbBranchName: `${database}:${branch}`,
|
2155
|
+
tableName: table,
|
2156
|
+
recordId: record,
|
2157
|
+
columnName: column
|
2158
|
+
},
|
2159
|
+
...this.extraProps
|
2160
|
+
});
|
2161
|
+
}
|
2162
|
+
fileAccess({
|
2163
|
+
workspace,
|
2164
|
+
region,
|
2165
|
+
fileId,
|
2166
|
+
verify
|
2167
|
+
}) {
|
2168
|
+
return operationsByTag.files.fileAccess({
|
2169
|
+
pathParams: {
|
2170
|
+
workspace,
|
2171
|
+
region,
|
2172
|
+
fileId
|
2173
|
+
},
|
2174
|
+
queryParams: { verify },
|
2175
|
+
...this.extraProps
|
2176
|
+
});
|
2177
|
+
}
|
2178
|
+
}
|
1517
2179
|
class SearchAndFilterApi {
|
1518
2180
|
constructor(extraProps) {
|
1519
2181
|
this.extraProps = extraProps;
|
@@ -1573,6 +2235,53 @@ class SearchAndFilterApi {
|
|
1573
2235
|
...this.extraProps
|
1574
2236
|
});
|
1575
2237
|
}
|
2238
|
+
vectorSearchTable({
|
2239
|
+
workspace,
|
2240
|
+
region,
|
2241
|
+
database,
|
2242
|
+
branch,
|
2243
|
+
table,
|
2244
|
+
queryVector,
|
2245
|
+
column,
|
2246
|
+
similarityFunction,
|
2247
|
+
size,
|
2248
|
+
filter
|
2249
|
+
}) {
|
2250
|
+
return operationsByTag.searchAndFilter.vectorSearchTable({
|
2251
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2252
|
+
body: { queryVector, column, similarityFunction, size, filter },
|
2253
|
+
...this.extraProps
|
2254
|
+
});
|
2255
|
+
}
|
2256
|
+
askTable({
|
2257
|
+
workspace,
|
2258
|
+
region,
|
2259
|
+
database,
|
2260
|
+
branch,
|
2261
|
+
table,
|
2262
|
+
options
|
2263
|
+
}) {
|
2264
|
+
return operationsByTag.searchAndFilter.askTable({
|
2265
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2266
|
+
body: { ...options },
|
2267
|
+
...this.extraProps
|
2268
|
+
});
|
2269
|
+
}
|
2270
|
+
askTableSession({
|
2271
|
+
workspace,
|
2272
|
+
region,
|
2273
|
+
database,
|
2274
|
+
branch,
|
2275
|
+
table,
|
2276
|
+
sessionId,
|
2277
|
+
message
|
2278
|
+
}) {
|
2279
|
+
return operationsByTag.searchAndFilter.askTableSession({
|
2280
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
|
2281
|
+
body: { message },
|
2282
|
+
...this.extraProps
|
2283
|
+
});
|
2284
|
+
}
|
1576
2285
|
summarizeTable({
|
1577
2286
|
workspace,
|
1578
2287
|
region,
|
@@ -1837,6 +2546,19 @@ class MigrationsApi {
|
|
1837
2546
|
...this.extraProps
|
1838
2547
|
});
|
1839
2548
|
}
|
2549
|
+
pushBranchMigrations({
|
2550
|
+
workspace,
|
2551
|
+
region,
|
2552
|
+
database,
|
2553
|
+
branch,
|
2554
|
+
migrations
|
2555
|
+
}) {
|
2556
|
+
return operationsByTag.migrations.pushBranchMigrations({
|
2557
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2558
|
+
body: { migrations },
|
2559
|
+
...this.extraProps
|
2560
|
+
});
|
2561
|
+
}
|
1840
2562
|
}
|
1841
2563
|
class DatabaseApi {
|
1842
2564
|
constructor(extraProps) {
|
@@ -1851,11 +2573,13 @@ class DatabaseApi {
|
|
1851
2573
|
createDatabase({
|
1852
2574
|
workspace,
|
1853
2575
|
database,
|
1854
|
-
data
|
2576
|
+
data,
|
2577
|
+
headers
|
1855
2578
|
}) {
|
1856
2579
|
return operationsByTag.databases.createDatabase({
|
1857
2580
|
pathParams: { workspaceId: workspace, dbName: database },
|
1858
2581
|
body: data,
|
2582
|
+
headers,
|
1859
2583
|
...this.extraProps
|
1860
2584
|
});
|
1861
2585
|
}
|
@@ -1877,14 +2601,25 @@ class DatabaseApi {
|
|
1877
2601
|
...this.extraProps
|
1878
2602
|
});
|
1879
2603
|
}
|
1880
|
-
updateDatabaseMetadata({
|
2604
|
+
updateDatabaseMetadata({
|
2605
|
+
workspace,
|
2606
|
+
database,
|
2607
|
+
metadata
|
2608
|
+
}) {
|
2609
|
+
return operationsByTag.databases.updateDatabaseMetadata({
|
2610
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2611
|
+
body: metadata,
|
2612
|
+
...this.extraProps
|
2613
|
+
});
|
2614
|
+
}
|
2615
|
+
renameDatabase({
|
1881
2616
|
workspace,
|
1882
2617
|
database,
|
1883
|
-
|
2618
|
+
newName
|
1884
2619
|
}) {
|
1885
|
-
return operationsByTag.databases.
|
2620
|
+
return operationsByTag.databases.renameDatabase({
|
1886
2621
|
pathParams: { workspaceId: workspace, dbName: database },
|
1887
|
-
body:
|
2622
|
+
body: { newName },
|
1888
2623
|
...this.extraProps
|
1889
2624
|
});
|
1890
2625
|
}
|
@@ -1926,20 +2661,203 @@ class DatabaseApi {
|
|
1926
2661
|
}
|
1927
2662
|
|
1928
2663
|
class XataApiPlugin {
|
1929
|
-
|
1930
|
-
|
1931
|
-
return new XataApiClient({ fetch: fetchImpl, apiKey });
|
2664
|
+
build(options) {
|
2665
|
+
return new XataApiClient(options);
|
1932
2666
|
}
|
1933
2667
|
}
|
1934
2668
|
|
1935
2669
|
class XataPlugin {
|
1936
2670
|
}
|
1937
2671
|
|
2672
|
+
function buildTransformString(transformations) {
|
2673
|
+
return transformations.flatMap(
|
2674
|
+
(t) => Object.entries(t).map(([key, value]) => {
|
2675
|
+
if (key === "trim") {
|
2676
|
+
const { left = 0, top = 0, right = 0, bottom = 0 } = value;
|
2677
|
+
return `${key}=${[top, right, bottom, left].join(";")}`;
|
2678
|
+
}
|
2679
|
+
if (key === "gravity" && typeof value === "object") {
|
2680
|
+
const { x = 0.5, y = 0.5 } = value;
|
2681
|
+
return `${key}=${[x, y].join("x")}`;
|
2682
|
+
}
|
2683
|
+
return `${key}=${value}`;
|
2684
|
+
})
|
2685
|
+
).join(",");
|
2686
|
+
}
|
2687
|
+
function transformImage(url, ...transformations) {
|
2688
|
+
if (!isDefined(url))
|
2689
|
+
return void 0;
|
2690
|
+
const newTransformations = buildTransformString(transformations);
|
2691
|
+
const { hostname, pathname, search } = new URL(url);
|
2692
|
+
const pathParts = pathname.split("/");
|
2693
|
+
const transformIndex = pathParts.findIndex((part) => part === "transform");
|
2694
|
+
const removedItems = transformIndex >= 0 ? pathParts.splice(transformIndex, 2) : [];
|
2695
|
+
const transform = `/transform/${[removedItems[1], newTransformations].filter(isDefined).join(",")}`;
|
2696
|
+
const path = pathParts.join("/");
|
2697
|
+
return `https://${hostname}${transform}${path}${search}`;
|
2698
|
+
}
|
2699
|
+
|
2700
|
+
class XataFile {
|
2701
|
+
constructor(file) {
|
2702
|
+
this.id = file.id;
|
2703
|
+
this.name = file.name;
|
2704
|
+
this.mediaType = file.mediaType;
|
2705
|
+
this.base64Content = file.base64Content;
|
2706
|
+
this.enablePublicUrl = file.enablePublicUrl;
|
2707
|
+
this.signedUrlTimeout = file.signedUrlTimeout;
|
2708
|
+
this.uploadUrlTimeout = file.uploadUrlTimeout;
|
2709
|
+
this.size = file.size;
|
2710
|
+
this.version = file.version;
|
2711
|
+
this.url = file.url;
|
2712
|
+
this.signedUrl = file.signedUrl;
|
2713
|
+
this.uploadUrl = file.uploadUrl;
|
2714
|
+
this.attributes = file.attributes;
|
2715
|
+
}
|
2716
|
+
static fromBuffer(buffer, options = {}) {
|
2717
|
+
const base64Content = buffer.toString("base64");
|
2718
|
+
return new XataFile({ ...options, base64Content });
|
2719
|
+
}
|
2720
|
+
toBuffer() {
|
2721
|
+
if (!this.base64Content) {
|
2722
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2723
|
+
}
|
2724
|
+
return Buffer.from(this.base64Content, "base64");
|
2725
|
+
}
|
2726
|
+
static fromArrayBuffer(arrayBuffer, options = {}) {
|
2727
|
+
const uint8Array = new Uint8Array(arrayBuffer);
|
2728
|
+
return this.fromUint8Array(uint8Array, options);
|
2729
|
+
}
|
2730
|
+
toArrayBuffer() {
|
2731
|
+
if (!this.base64Content) {
|
2732
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2733
|
+
}
|
2734
|
+
const binary = atob(this.base64Content);
|
2735
|
+
return new ArrayBuffer(binary.length);
|
2736
|
+
}
|
2737
|
+
static fromUint8Array(uint8Array, options = {}) {
|
2738
|
+
let binary = "";
|
2739
|
+
for (let i = 0; i < uint8Array.byteLength; i++) {
|
2740
|
+
binary += String.fromCharCode(uint8Array[i]);
|
2741
|
+
}
|
2742
|
+
const base64Content = btoa(binary);
|
2743
|
+
return new XataFile({ ...options, base64Content });
|
2744
|
+
}
|
2745
|
+
toUint8Array() {
|
2746
|
+
if (!this.base64Content) {
|
2747
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2748
|
+
}
|
2749
|
+
const binary = atob(this.base64Content);
|
2750
|
+
const uint8Array = new Uint8Array(binary.length);
|
2751
|
+
for (let i = 0; i < binary.length; i++) {
|
2752
|
+
uint8Array[i] = binary.charCodeAt(i);
|
2753
|
+
}
|
2754
|
+
return uint8Array;
|
2755
|
+
}
|
2756
|
+
static async fromBlob(file, options = {}) {
|
2757
|
+
const name = options.name ?? file.name;
|
2758
|
+
const mediaType = file.type;
|
2759
|
+
const arrayBuffer = await file.arrayBuffer();
|
2760
|
+
return this.fromArrayBuffer(arrayBuffer, { ...options, name, mediaType });
|
2761
|
+
}
|
2762
|
+
toBlob() {
|
2763
|
+
if (!this.base64Content) {
|
2764
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2765
|
+
}
|
2766
|
+
const binary = atob(this.base64Content);
|
2767
|
+
const uint8Array = new Uint8Array(binary.length);
|
2768
|
+
for (let i = 0; i < binary.length; i++) {
|
2769
|
+
uint8Array[i] = binary.charCodeAt(i);
|
2770
|
+
}
|
2771
|
+
return new Blob([uint8Array], { type: this.mediaType });
|
2772
|
+
}
|
2773
|
+
static fromString(string, options = {}) {
|
2774
|
+
const base64Content = btoa(string);
|
2775
|
+
return new XataFile({ ...options, base64Content });
|
2776
|
+
}
|
2777
|
+
toString() {
|
2778
|
+
if (!this.base64Content) {
|
2779
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2780
|
+
}
|
2781
|
+
return atob(this.base64Content);
|
2782
|
+
}
|
2783
|
+
static fromBase64(base64Content, options = {}) {
|
2784
|
+
return new XataFile({ ...options, base64Content });
|
2785
|
+
}
|
2786
|
+
toBase64() {
|
2787
|
+
if (!this.base64Content) {
|
2788
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2789
|
+
}
|
2790
|
+
return this.base64Content;
|
2791
|
+
}
|
2792
|
+
transform(...options) {
|
2793
|
+
return {
|
2794
|
+
url: transformImage(this.url, ...options),
|
2795
|
+
signedUrl: transformImage(this.signedUrl, ...options),
|
2796
|
+
metadataUrl: transformImage(this.url, ...options, { format: "json" }),
|
2797
|
+
metadataSignedUrl: transformImage(this.signedUrl, ...options, { format: "json" })
|
2798
|
+
};
|
2799
|
+
}
|
2800
|
+
}
|
2801
|
+
const parseInputFileEntry = async (entry) => {
|
2802
|
+
if (!isDefined(entry))
|
2803
|
+
return null;
|
2804
|
+
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout, uploadUrlTimeout } = await entry;
|
2805
|
+
return compactObject({
|
2806
|
+
id,
|
2807
|
+
// Name cannot be an empty string in our API
|
2808
|
+
name: name ? name : void 0,
|
2809
|
+
mediaType,
|
2810
|
+
base64Content,
|
2811
|
+
enablePublicUrl,
|
2812
|
+
signedUrlTimeout,
|
2813
|
+
uploadUrlTimeout
|
2814
|
+
});
|
2815
|
+
};
|
2816
|
+
|
1938
2817
|
function cleanFilter(filter) {
|
1939
|
-
if (!filter)
|
2818
|
+
if (!isDefined(filter))
|
1940
2819
|
return void 0;
|
1941
|
-
|
1942
|
-
|
2820
|
+
if (!isObject(filter))
|
2821
|
+
return filter;
|
2822
|
+
const values = Object.fromEntries(
|
2823
|
+
Object.entries(filter).reduce((acc, [key, value]) => {
|
2824
|
+
if (!isDefined(value))
|
2825
|
+
return acc;
|
2826
|
+
if (Array.isArray(value)) {
|
2827
|
+
const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
|
2828
|
+
if (clean.length === 0)
|
2829
|
+
return acc;
|
2830
|
+
return [...acc, [key, clean]];
|
2831
|
+
}
|
2832
|
+
if (isObject(value)) {
|
2833
|
+
const clean = cleanFilter(value);
|
2834
|
+
if (!isDefined(clean))
|
2835
|
+
return acc;
|
2836
|
+
return [...acc, [key, clean]];
|
2837
|
+
}
|
2838
|
+
return [...acc, [key, value]];
|
2839
|
+
}, [])
|
2840
|
+
);
|
2841
|
+
return Object.keys(values).length > 0 ? values : void 0;
|
2842
|
+
}
|
2843
|
+
|
2844
|
+
function stringifyJson(value) {
|
2845
|
+
if (!isDefined(value))
|
2846
|
+
return value;
|
2847
|
+
if (isString(value))
|
2848
|
+
return value;
|
2849
|
+
try {
|
2850
|
+
return JSON.stringify(value);
|
2851
|
+
} catch (e) {
|
2852
|
+
return value;
|
2853
|
+
}
|
2854
|
+
}
|
2855
|
+
function parseJson(value) {
|
2856
|
+
try {
|
2857
|
+
return JSON.parse(value);
|
2858
|
+
} catch (e) {
|
2859
|
+
return value;
|
2860
|
+
}
|
1943
2861
|
}
|
1944
2862
|
|
1945
2863
|
var __accessCheck$6 = (obj, member, msg) => {
|
@@ -1968,31 +2886,59 @@ class Page {
|
|
1968
2886
|
this.meta = meta;
|
1969
2887
|
this.records = new RecordArray(this, records);
|
1970
2888
|
}
|
2889
|
+
/**
|
2890
|
+
* Retrieves the next page of results.
|
2891
|
+
* @param size Maximum number of results to be retrieved.
|
2892
|
+
* @param offset Number of results to skip when retrieving the results.
|
2893
|
+
* @returns The next page or results.
|
2894
|
+
*/
|
1971
2895
|
async nextPage(size, offset) {
|
1972
2896
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
1973
2897
|
}
|
2898
|
+
/**
|
2899
|
+
* Retrieves the previous page of results.
|
2900
|
+
* @param size Maximum number of results to be retrieved.
|
2901
|
+
* @param offset Number of results to skip when retrieving the results.
|
2902
|
+
* @returns The previous page or results.
|
2903
|
+
*/
|
1974
2904
|
async previousPage(size, offset) {
|
1975
2905
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
1976
2906
|
}
|
2907
|
+
/**
|
2908
|
+
* Retrieves the start page of results.
|
2909
|
+
* @param size Maximum number of results to be retrieved.
|
2910
|
+
* @param offset Number of results to skip when retrieving the results.
|
2911
|
+
* @returns The start page or results.
|
2912
|
+
*/
|
1977
2913
|
async startPage(size, offset) {
|
1978
2914
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
1979
2915
|
}
|
2916
|
+
/**
|
2917
|
+
* Retrieves the end page of results.
|
2918
|
+
* @param size Maximum number of results to be retrieved.
|
2919
|
+
* @param offset Number of results to skip when retrieving the results.
|
2920
|
+
* @returns The end page or results.
|
2921
|
+
*/
|
1980
2922
|
async endPage(size, offset) {
|
1981
2923
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
1982
2924
|
}
|
2925
|
+
/**
|
2926
|
+
* Shortcut method to check if there will be additional results if the next page of results is retrieved.
|
2927
|
+
* @returns Whether or not there will be additional results in the next page of results.
|
2928
|
+
*/
|
1983
2929
|
hasNextPage() {
|
1984
2930
|
return this.meta.page.more;
|
1985
2931
|
}
|
1986
2932
|
}
|
1987
2933
|
_query = new WeakMap();
|
1988
|
-
const PAGINATION_MAX_SIZE =
|
2934
|
+
const PAGINATION_MAX_SIZE = 1e3;
|
1989
2935
|
const PAGINATION_DEFAULT_SIZE = 20;
|
1990
|
-
const PAGINATION_MAX_OFFSET =
|
2936
|
+
const PAGINATION_MAX_OFFSET = 49e3;
|
1991
2937
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
1992
2938
|
function isCursorPaginationOptions(options) {
|
1993
2939
|
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
1994
2940
|
}
|
1995
|
-
const _RecordArray = class extends Array {
|
2941
|
+
const _RecordArray = class _RecordArray extends Array {
|
1996
2942
|
constructor(...args) {
|
1997
2943
|
super(..._RecordArray.parseConstructorParams(...args));
|
1998
2944
|
__privateAdd$6(this, _page, void 0);
|
@@ -2020,28 +2966,51 @@ const _RecordArray = class extends Array {
|
|
2020
2966
|
map(callbackfn, thisArg) {
|
2021
2967
|
return this.toArray().map(callbackfn, thisArg);
|
2022
2968
|
}
|
2969
|
+
/**
|
2970
|
+
* Retrieve next page of records
|
2971
|
+
*
|
2972
|
+
* @returns A new array of objects
|
2973
|
+
*/
|
2023
2974
|
async nextPage(size, offset) {
|
2024
2975
|
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
2025
2976
|
return new _RecordArray(newPage);
|
2026
2977
|
}
|
2978
|
+
/**
|
2979
|
+
* Retrieve previous page of records
|
2980
|
+
*
|
2981
|
+
* @returns A new array of objects
|
2982
|
+
*/
|
2027
2983
|
async previousPage(size, offset) {
|
2028
2984
|
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
2029
2985
|
return new _RecordArray(newPage);
|
2030
2986
|
}
|
2987
|
+
/**
|
2988
|
+
* Retrieve start page of records
|
2989
|
+
*
|
2990
|
+
* @returns A new array of objects
|
2991
|
+
*/
|
2031
2992
|
async startPage(size, offset) {
|
2032
2993
|
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
2033
2994
|
return new _RecordArray(newPage);
|
2034
2995
|
}
|
2996
|
+
/**
|
2997
|
+
* Retrieve end page of records
|
2998
|
+
*
|
2999
|
+
* @returns A new array of objects
|
3000
|
+
*/
|
2035
3001
|
async endPage(size, offset) {
|
2036
3002
|
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
2037
3003
|
return new _RecordArray(newPage);
|
2038
3004
|
}
|
3005
|
+
/**
|
3006
|
+
* @returns Boolean indicating if there is a next page
|
3007
|
+
*/
|
2039
3008
|
hasNextPage() {
|
2040
3009
|
return __privateGet$6(this, _page).meta.page.more;
|
2041
3010
|
}
|
2042
3011
|
};
|
2043
|
-
let RecordArray = _RecordArray;
|
2044
3012
|
_page = new WeakMap();
|
3013
|
+
let RecordArray = _RecordArray;
|
2045
3014
|
|
2046
3015
|
var __accessCheck$5 = (obj, member, msg) => {
|
2047
3016
|
if (!member.has(obj))
|
@@ -2066,13 +3035,14 @@ var __privateMethod$3 = (obj, member, method) => {
|
|
2066
3035
|
return method;
|
2067
3036
|
};
|
2068
3037
|
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
2069
|
-
const _Query = class {
|
3038
|
+
const _Query = class _Query {
|
2070
3039
|
constructor(repository, table, data, rawParent) {
|
2071
3040
|
__privateAdd$5(this, _cleanFilterConstraint);
|
2072
3041
|
__privateAdd$5(this, _table$1, void 0);
|
2073
3042
|
__privateAdd$5(this, _repository, void 0);
|
2074
3043
|
__privateAdd$5(this, _data, { filter: {} });
|
2075
|
-
|
3044
|
+
// Implements pagination
|
3045
|
+
this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
|
2076
3046
|
this.records = new RecordArray(this, []);
|
2077
3047
|
__privateSet$5(this, _table$1, table);
|
2078
3048
|
if (repository) {
|
@@ -2109,18 +3079,38 @@ const _Query = class {
|
|
2109
3079
|
const key = JSON.stringify({ columns, filter, sort, pagination });
|
2110
3080
|
return toBase64(key);
|
2111
3081
|
}
|
3082
|
+
/**
|
3083
|
+
* Builds a new query object representing a logical OR between the given subqueries.
|
3084
|
+
* @param queries An array of subqueries.
|
3085
|
+
* @returns A new Query object.
|
3086
|
+
*/
|
2112
3087
|
any(...queries) {
|
2113
3088
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2114
3089
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
2115
3090
|
}
|
3091
|
+
/**
|
3092
|
+
* Builds a new query object representing a logical AND between the given subqueries.
|
3093
|
+
* @param queries An array of subqueries.
|
3094
|
+
* @returns A new Query object.
|
3095
|
+
*/
|
2116
3096
|
all(...queries) {
|
2117
3097
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2118
3098
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
2119
3099
|
}
|
3100
|
+
/**
|
3101
|
+
* Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
|
3102
|
+
* @param queries An array of subqueries.
|
3103
|
+
* @returns A new Query object.
|
3104
|
+
*/
|
2120
3105
|
not(...queries) {
|
2121
3106
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2122
3107
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
2123
3108
|
}
|
3109
|
+
/**
|
3110
|
+
* Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
|
3111
|
+
* @param queries An array of subqueries.
|
3112
|
+
* @returns A new Query object.
|
3113
|
+
*/
|
2124
3114
|
none(...queries) {
|
2125
3115
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2126
3116
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
@@ -2143,6 +3133,11 @@ const _Query = class {
|
|
2143
3133
|
const sort = [...originalSort, { column, direction }];
|
2144
3134
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
2145
3135
|
}
|
3136
|
+
/**
|
3137
|
+
* Builds a new query specifying the set of columns to be returned in the query response.
|
3138
|
+
* @param columns Array of column names to be returned by the query.
|
3139
|
+
* @returns A new Query object.
|
3140
|
+
*/
|
2146
3141
|
select(columns) {
|
2147
3142
|
return new _Query(
|
2148
3143
|
__privateGet$5(this, _repository),
|
@@ -2155,6 +3150,12 @@ const _Query = class {
|
|
2155
3150
|
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
2156
3151
|
return __privateGet$5(this, _repository).query(query);
|
2157
3152
|
}
|
3153
|
+
/**
|
3154
|
+
* Get results in an iterator
|
3155
|
+
*
|
3156
|
+
* @async
|
3157
|
+
* @returns Async interable of results
|
3158
|
+
*/
|
2158
3159
|
async *[Symbol.asyncIterator]() {
|
2159
3160
|
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
2160
3161
|
yield record;
|
@@ -2215,26 +3216,53 @@ const _Query = class {
|
|
2215
3216
|
);
|
2216
3217
|
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
2217
3218
|
}
|
3219
|
+
/**
|
3220
|
+
* Builds a new query object adding a cache TTL in milliseconds.
|
3221
|
+
* @param ttl The cache TTL in milliseconds.
|
3222
|
+
* @returns A new Query object.
|
3223
|
+
*/
|
2218
3224
|
cache(ttl) {
|
2219
3225
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
2220
3226
|
}
|
3227
|
+
/**
|
3228
|
+
* Retrieve next page of records
|
3229
|
+
*
|
3230
|
+
* @returns A new page object.
|
3231
|
+
*/
|
2221
3232
|
nextPage(size, offset) {
|
2222
3233
|
return this.startPage(size, offset);
|
2223
3234
|
}
|
3235
|
+
/**
|
3236
|
+
* Retrieve previous page of records
|
3237
|
+
*
|
3238
|
+
* @returns A new page object
|
3239
|
+
*/
|
2224
3240
|
previousPage(size, offset) {
|
2225
3241
|
return this.startPage(size, offset);
|
2226
3242
|
}
|
3243
|
+
/**
|
3244
|
+
* Retrieve start page of records
|
3245
|
+
*
|
3246
|
+
* @returns A new page object
|
3247
|
+
*/
|
2227
3248
|
startPage(size, offset) {
|
2228
3249
|
return this.getPaginated({ pagination: { size, offset } });
|
2229
3250
|
}
|
3251
|
+
/**
|
3252
|
+
* Retrieve last page of records
|
3253
|
+
*
|
3254
|
+
* @returns A new page object
|
3255
|
+
*/
|
2230
3256
|
endPage(size, offset) {
|
2231
3257
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
2232
3258
|
}
|
3259
|
+
/**
|
3260
|
+
* @returns Boolean indicating if there is a next page
|
3261
|
+
*/
|
2233
3262
|
hasNextPage() {
|
2234
3263
|
return this.meta.page.more;
|
2235
3264
|
}
|
2236
3265
|
};
|
2237
|
-
let Query = _Query;
|
2238
3266
|
_table$1 = new WeakMap();
|
2239
3267
|
_repository = new WeakMap();
|
2240
3268
|
_data = new WeakMap();
|
@@ -2249,6 +3277,7 @@ cleanFilterConstraint_fn = function(column, value) {
|
|
2249
3277
|
}
|
2250
3278
|
return value;
|
2251
3279
|
};
|
3280
|
+
let Query = _Query;
|
2252
3281
|
function cleanParent(data, parent) {
|
2253
3282
|
if (isCursorPaginationOptions(data.pagination)) {
|
2254
3283
|
return { ...parent, sort: void 0, filter: void 0 };
|
@@ -2256,6 +3285,22 @@ function cleanParent(data, parent) {
|
|
2256
3285
|
return parent;
|
2257
3286
|
}
|
2258
3287
|
|
3288
|
+
const RecordColumnTypes = [
|
3289
|
+
"bool",
|
3290
|
+
"int",
|
3291
|
+
"float",
|
3292
|
+
"string",
|
3293
|
+
"text",
|
3294
|
+
"email",
|
3295
|
+
"multiple",
|
3296
|
+
"link",
|
3297
|
+
"object",
|
3298
|
+
"datetime",
|
3299
|
+
"vector",
|
3300
|
+
"file[]",
|
3301
|
+
"file",
|
3302
|
+
"json"
|
3303
|
+
];
|
2259
3304
|
function isIdentifiable(x) {
|
2260
3305
|
return isObject(x) && isString(x?.id);
|
2261
3306
|
}
|
@@ -2265,11 +3310,33 @@ function isXataRecord(x) {
|
|
2265
3310
|
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
2266
3311
|
}
|
2267
3312
|
|
3313
|
+
function isValidExpandedColumn(column) {
|
3314
|
+
return isObject(column) && isString(column.name);
|
3315
|
+
}
|
3316
|
+
function isValidSelectableColumns(columns) {
|
3317
|
+
if (!Array.isArray(columns)) {
|
3318
|
+
return false;
|
3319
|
+
}
|
3320
|
+
return columns.every((column) => {
|
3321
|
+
if (typeof column === "string") {
|
3322
|
+
return true;
|
3323
|
+
}
|
3324
|
+
if (typeof column === "object") {
|
3325
|
+
return isValidExpandedColumn(column);
|
3326
|
+
}
|
3327
|
+
return false;
|
3328
|
+
});
|
3329
|
+
}
|
3330
|
+
|
2268
3331
|
function isSortFilterString(value) {
|
2269
3332
|
return isString(value);
|
2270
3333
|
}
|
2271
3334
|
function isSortFilterBase(filter) {
|
2272
|
-
return isObject(filter) && Object.
|
3335
|
+
return isObject(filter) && Object.entries(filter).every(([key, value]) => {
|
3336
|
+
if (key === "*")
|
3337
|
+
return value === "random";
|
3338
|
+
return value === "asc" || value === "desc";
|
3339
|
+
});
|
2273
3340
|
}
|
2274
3341
|
function isSortFilterObject(filter) {
|
2275
3342
|
return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
|
@@ -2310,7 +3377,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
2310
3377
|
__accessCheck$4(obj, member, "access private method");
|
2311
3378
|
return method;
|
2312
3379
|
};
|
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;
|
3380
|
+
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
3381
|
const BULK_OPERATION_MAX_SIZE = 1e3;
|
2315
3382
|
class Repository extends Query {
|
2316
3383
|
}
|
@@ -2332,6 +3399,7 @@ class RestRepository extends Query {
|
|
2332
3399
|
__privateAdd$4(this, _setCacheQuery);
|
2333
3400
|
__privateAdd$4(this, _getCacheQuery);
|
2334
3401
|
__privateAdd$4(this, _getSchemaTables$1);
|
3402
|
+
__privateAdd$4(this, _transformObjectToApi);
|
2335
3403
|
__privateAdd$4(this, _table, void 0);
|
2336
3404
|
__privateAdd$4(this, _getFetchProps, void 0);
|
2337
3405
|
__privateAdd$4(this, _db, void 0);
|
@@ -2342,10 +3410,7 @@ class RestRepository extends Query {
|
|
2342
3410
|
__privateSet$4(this, _db, options.db);
|
2343
3411
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
2344
3412
|
__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
|
-
});
|
3413
|
+
__privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
|
2349
3414
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
2350
3415
|
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
2351
3416
|
return trace(name, fn, {
|
@@ -2363,24 +3428,24 @@ class RestRepository extends Query {
|
|
2363
3428
|
if (a.length === 0)
|
2364
3429
|
return [];
|
2365
3430
|
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
2366
|
-
const columns =
|
3431
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2367
3432
|
const result = await this.read(ids, columns);
|
2368
3433
|
return result;
|
2369
3434
|
}
|
2370
3435
|
if (isString(a) && isObject(b)) {
|
2371
3436
|
if (a === "")
|
2372
3437
|
throw new Error("The id can't be empty");
|
2373
|
-
const columns =
|
3438
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
2374
3439
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
2375
3440
|
}
|
2376
3441
|
if (isObject(a) && isString(a.id)) {
|
2377
3442
|
if (a.id === "")
|
2378
3443
|
throw new Error("The id can't be empty");
|
2379
|
-
const columns =
|
3444
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
2380
3445
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
2381
3446
|
}
|
2382
3447
|
if (isObject(a)) {
|
2383
|
-
const columns =
|
3448
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
2384
3449
|
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
2385
3450
|
}
|
2386
3451
|
throw new Error("Invalid arguments for create method");
|
@@ -2388,7 +3453,7 @@ class RestRepository extends Query {
|
|
2388
3453
|
}
|
2389
3454
|
async read(a, b) {
|
2390
3455
|
return __privateGet$4(this, _trace).call(this, "read", async () => {
|
2391
|
-
const columns =
|
3456
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2392
3457
|
if (Array.isArray(a)) {
|
2393
3458
|
if (a.length === 0)
|
2394
3459
|
return [];
|
@@ -2402,7 +3467,6 @@ class RestRepository extends Query {
|
|
2402
3467
|
}
|
2403
3468
|
const id = extractId(a);
|
2404
3469
|
if (id) {
|
2405
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2406
3470
|
try {
|
2407
3471
|
const response = await getRecord({
|
2408
3472
|
pathParams: {
|
@@ -2413,10 +3477,16 @@ class RestRepository extends Query {
|
|
2413
3477
|
recordId: id
|
2414
3478
|
},
|
2415
3479
|
queryParams: { columns },
|
2416
|
-
...
|
3480
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2417
3481
|
});
|
2418
3482
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2419
|
-
return initObject(
|
3483
|
+
return initObject(
|
3484
|
+
__privateGet$4(this, _db),
|
3485
|
+
schemaTables,
|
3486
|
+
__privateGet$4(this, _table),
|
3487
|
+
response,
|
3488
|
+
columns
|
3489
|
+
);
|
2420
3490
|
} catch (e) {
|
2421
3491
|
if (isObject(e) && e.status === 404) {
|
2422
3492
|
return null;
|
@@ -2458,17 +3528,17 @@ class RestRepository extends Query {
|
|
2458
3528
|
ifVersion,
|
2459
3529
|
upsert: false
|
2460
3530
|
});
|
2461
|
-
const columns =
|
3531
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2462
3532
|
const result = await this.read(a, columns);
|
2463
3533
|
return result;
|
2464
3534
|
}
|
2465
3535
|
try {
|
2466
3536
|
if (isString(a) && isObject(b)) {
|
2467
|
-
const columns =
|
3537
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
2468
3538
|
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
2469
3539
|
}
|
2470
3540
|
if (isObject(a) && isString(a.id)) {
|
2471
|
-
const columns =
|
3541
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
2472
3542
|
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
2473
3543
|
}
|
2474
3544
|
} catch (error) {
|
@@ -2508,17 +3578,27 @@ class RestRepository extends Query {
|
|
2508
3578
|
ifVersion,
|
2509
3579
|
upsert: true
|
2510
3580
|
});
|
2511
|
-
const columns =
|
3581
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2512
3582
|
const result = await this.read(a, columns);
|
2513
3583
|
return result;
|
2514
3584
|
}
|
2515
3585
|
if (isString(a) && isObject(b)) {
|
2516
|
-
|
2517
|
-
|
3586
|
+
if (a === "")
|
3587
|
+
throw new Error("The id can't be empty");
|
3588
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3589
|
+
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
2518
3590
|
}
|
2519
3591
|
if (isObject(a) && isString(a.id)) {
|
2520
|
-
|
2521
|
-
|
3592
|
+
if (a.id === "")
|
3593
|
+
throw new Error("The id can't be empty");
|
3594
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3595
|
+
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3596
|
+
}
|
3597
|
+
if (!isDefined(a) && isObject(b)) {
|
3598
|
+
return await this.create(b, c);
|
3599
|
+
}
|
3600
|
+
if (isObject(a) && !isDefined(a.id)) {
|
3601
|
+
return await this.create(a, b);
|
2522
3602
|
}
|
2523
3603
|
throw new Error("Invalid arguments for createOrUpdate method");
|
2524
3604
|
});
|
@@ -2530,17 +3610,27 @@ class RestRepository extends Query {
|
|
2530
3610
|
if (a.length === 0)
|
2531
3611
|
return [];
|
2532
3612
|
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
2533
|
-
const columns =
|
3613
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2534
3614
|
const result = await this.read(ids, columns);
|
2535
3615
|
return result;
|
2536
3616
|
}
|
2537
3617
|
if (isString(a) && isObject(b)) {
|
2538
|
-
|
2539
|
-
|
3618
|
+
if (a === "")
|
3619
|
+
throw new Error("The id can't be empty");
|
3620
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3621
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
2540
3622
|
}
|
2541
3623
|
if (isObject(a) && isString(a.id)) {
|
2542
|
-
|
2543
|
-
|
3624
|
+
if (a.id === "")
|
3625
|
+
throw new Error("The id can't be empty");
|
3626
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3627
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
3628
|
+
}
|
3629
|
+
if (!isDefined(a) && isObject(b)) {
|
3630
|
+
return await this.create(b, c);
|
3631
|
+
}
|
3632
|
+
if (isObject(a) && !isDefined(a.id)) {
|
3633
|
+
return await this.create(a, b);
|
2544
3634
|
}
|
2545
3635
|
throw new Error("Invalid arguments for createOrReplace method");
|
2546
3636
|
});
|
@@ -2557,7 +3647,7 @@ class RestRepository extends Query {
|
|
2557
3647
|
return o.id;
|
2558
3648
|
throw new Error("Invalid arguments for delete method");
|
2559
3649
|
});
|
2560
|
-
const columns =
|
3650
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
2561
3651
|
const result = await this.read(a, columns);
|
2562
3652
|
await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
|
2563
3653
|
return result;
|
@@ -2591,8 +3681,7 @@ class RestRepository extends Query {
|
|
2591
3681
|
}
|
2592
3682
|
async search(query, options = {}) {
|
2593
3683
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
2594
|
-
const
|
2595
|
-
const { records } = await searchTable({
|
3684
|
+
const { records, totalCount } = await searchTable({
|
2596
3685
|
pathParams: {
|
2597
3686
|
workspace: "{workspaceId}",
|
2598
3687
|
dbBranchName: "{dbBranch}",
|
@@ -2609,15 +3698,42 @@ class RestRepository extends Query {
|
|
2609
3698
|
page: options.page,
|
2610
3699
|
target: options.target
|
2611
3700
|
},
|
2612
|
-
...
|
3701
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3702
|
+
});
|
3703
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3704
|
+
return {
|
3705
|
+
records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
|
3706
|
+
totalCount
|
3707
|
+
};
|
3708
|
+
});
|
3709
|
+
}
|
3710
|
+
async vectorSearch(column, query, options) {
|
3711
|
+
return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
|
3712
|
+
const { records, totalCount } = await vectorSearchTable({
|
3713
|
+
pathParams: {
|
3714
|
+
workspace: "{workspaceId}",
|
3715
|
+
dbBranchName: "{dbBranch}",
|
3716
|
+
region: "{region}",
|
3717
|
+
tableName: __privateGet$4(this, _table)
|
3718
|
+
},
|
3719
|
+
body: {
|
3720
|
+
column,
|
3721
|
+
queryVector: query,
|
3722
|
+
similarityFunction: options?.similarityFunction,
|
3723
|
+
size: options?.size,
|
3724
|
+
filter: options?.filter
|
3725
|
+
},
|
3726
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2613
3727
|
});
|
2614
3728
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2615
|
-
return
|
3729
|
+
return {
|
3730
|
+
records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
|
3731
|
+
totalCount
|
3732
|
+
};
|
2616
3733
|
});
|
2617
3734
|
}
|
2618
3735
|
async aggregate(aggs, filter) {
|
2619
3736
|
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
2620
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2621
3737
|
const result = await aggregateTable({
|
2622
3738
|
pathParams: {
|
2623
3739
|
workspace: "{workspaceId}",
|
@@ -2626,7 +3742,7 @@ class RestRepository extends Query {
|
|
2626
3742
|
tableName: __privateGet$4(this, _table)
|
2627
3743
|
},
|
2628
3744
|
body: { aggs, filter },
|
2629
|
-
...
|
3745
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2630
3746
|
});
|
2631
3747
|
return result;
|
2632
3748
|
});
|
@@ -2637,7 +3753,6 @@ class RestRepository extends Query {
|
|
2637
3753
|
if (cacheQuery)
|
2638
3754
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
2639
3755
|
const data = query.getQueryOptions();
|
2640
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2641
3756
|
const { meta, records: objects } = await queryTable({
|
2642
3757
|
pathParams: {
|
2643
3758
|
workspace: "{workspaceId}",
|
@@ -2653,11 +3768,17 @@ class RestRepository extends Query {
|
|
2653
3768
|
consistency: data.consistency
|
2654
3769
|
},
|
2655
3770
|
fetchOptions: data.fetchOptions,
|
2656
|
-
...
|
3771
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2657
3772
|
});
|
2658
3773
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2659
3774
|
const records = objects.map(
|
2660
|
-
(record) => initObject(
|
3775
|
+
(record) => initObject(
|
3776
|
+
__privateGet$4(this, _db),
|
3777
|
+
schemaTables,
|
3778
|
+
__privateGet$4(this, _table),
|
3779
|
+
record,
|
3780
|
+
data.columns ?? ["*"]
|
3781
|
+
)
|
2661
3782
|
);
|
2662
3783
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
2663
3784
|
return new Page(query, meta, records);
|
@@ -2666,7 +3787,6 @@ class RestRepository extends Query {
|
|
2666
3787
|
async summarizeTable(query, summaries, summariesFilter) {
|
2667
3788
|
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
2668
3789
|
const data = query.getQueryOptions();
|
2669
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2670
3790
|
const result = await summarizeTable({
|
2671
3791
|
pathParams: {
|
2672
3792
|
workspace: "{workspaceId}",
|
@@ -2683,11 +3803,50 @@ class RestRepository extends Query {
|
|
2683
3803
|
summaries,
|
2684
3804
|
summariesFilter
|
2685
3805
|
},
|
2686
|
-
...
|
3806
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2687
3807
|
});
|
2688
|
-
|
3808
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3809
|
+
return {
|
3810
|
+
...result,
|
3811
|
+
summaries: result.summaries.map(
|
3812
|
+
(summary) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), summary, data.columns ?? [])
|
3813
|
+
)
|
3814
|
+
};
|
2689
3815
|
});
|
2690
3816
|
}
|
3817
|
+
ask(question, options) {
|
3818
|
+
const questionParam = options?.sessionId ? { message: question } : { question };
|
3819
|
+
const params = {
|
3820
|
+
pathParams: {
|
3821
|
+
workspace: "{workspaceId}",
|
3822
|
+
dbBranchName: "{dbBranch}",
|
3823
|
+
region: "{region}",
|
3824
|
+
tableName: __privateGet$4(this, _table),
|
3825
|
+
sessionId: options?.sessionId
|
3826
|
+
},
|
3827
|
+
body: {
|
3828
|
+
...questionParam,
|
3829
|
+
rules: options?.rules,
|
3830
|
+
searchType: options?.searchType,
|
3831
|
+
search: options?.searchType === "keyword" ? options?.search : void 0,
|
3832
|
+
vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
|
3833
|
+
},
|
3834
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3835
|
+
};
|
3836
|
+
if (options?.onMessage) {
|
3837
|
+
fetchSSERequest({
|
3838
|
+
endpoint: "dataPlane",
|
3839
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
|
3840
|
+
method: "POST",
|
3841
|
+
onMessage: (message) => {
|
3842
|
+
options.onMessage?.({ answer: message.text, records: message.records });
|
3843
|
+
},
|
3844
|
+
...params
|
3845
|
+
});
|
3846
|
+
} else {
|
3847
|
+
return askTableSession(params);
|
3848
|
+
}
|
3849
|
+
}
|
2691
3850
|
}
|
2692
3851
|
_table = new WeakMap();
|
2693
3852
|
_getFetchProps = new WeakMap();
|
@@ -2697,8 +3856,7 @@ _schemaTables$2 = new WeakMap();
|
|
2697
3856
|
_trace = new WeakMap();
|
2698
3857
|
_insertRecordWithoutId = new WeakSet();
|
2699
3858
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
2700
|
-
const
|
2701
|
-
const record = transformObjectLinks(object);
|
3859
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
2702
3860
|
const response = await insertRecord({
|
2703
3861
|
pathParams: {
|
2704
3862
|
workspace: "{workspaceId}",
|
@@ -2708,15 +3866,16 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
2708
3866
|
},
|
2709
3867
|
queryParams: { columns },
|
2710
3868
|
body: record,
|
2711
|
-
...
|
3869
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2712
3870
|
});
|
2713
3871
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2714
3872
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2715
3873
|
};
|
2716
3874
|
_insertRecordWithId = new WeakSet();
|
2717
3875
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
2718
|
-
|
2719
|
-
|
3876
|
+
if (!recordId)
|
3877
|
+
return null;
|
3878
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
2720
3879
|
const response = await insertRecordWithID({
|
2721
3880
|
pathParams: {
|
2722
3881
|
workspace: "{workspaceId}",
|
@@ -2727,30 +3886,28 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
|
|
2727
3886
|
},
|
2728
3887
|
body: record,
|
2729
3888
|
queryParams: { createOnly, columns, ifVersion },
|
2730
|
-
...
|
3889
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2731
3890
|
});
|
2732
3891
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2733
3892
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2734
3893
|
};
|
2735
3894
|
_insertRecords = new WeakSet();
|
2736
3895
|
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
2737
|
-
const
|
2738
|
-
|
2739
|
-
|
2740
|
-
|
2741
|
-
|
2742
|
-
BULK_OPERATION_MAX_SIZE
|
2743
|
-
);
|
3896
|
+
const operations = await promiseMap(objects, async (object) => {
|
3897
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3898
|
+
return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
|
3899
|
+
});
|
3900
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
2744
3901
|
const ids = [];
|
2745
|
-
for (const
|
3902
|
+
for (const operations2 of chunkedOperations) {
|
2746
3903
|
const { results } = await branchTransaction({
|
2747
3904
|
pathParams: {
|
2748
3905
|
workspace: "{workspaceId}",
|
2749
3906
|
dbBranchName: "{dbBranch}",
|
2750
3907
|
region: "{region}"
|
2751
3908
|
},
|
2752
|
-
body: { operations },
|
2753
|
-
...
|
3909
|
+
body: { operations: operations2 },
|
3910
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2754
3911
|
});
|
2755
3912
|
for (const result of results) {
|
2756
3913
|
if (result.operation === "insert") {
|
@@ -2764,8 +3921,9 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
|
2764
3921
|
};
|
2765
3922
|
_updateRecordWithID = new WeakSet();
|
2766
3923
|
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
2767
|
-
|
2768
|
-
|
3924
|
+
if (!recordId)
|
3925
|
+
return null;
|
3926
|
+
const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
2769
3927
|
try {
|
2770
3928
|
const response = await updateRecordWithID({
|
2771
3929
|
pathParams: {
|
@@ -2777,7 +3935,7 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
2777
3935
|
},
|
2778
3936
|
queryParams: { columns, ifVersion },
|
2779
3937
|
body: record,
|
2780
|
-
...
|
3938
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2781
3939
|
});
|
2782
3940
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2783
3941
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
@@ -2790,23 +3948,21 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
2790
3948
|
};
|
2791
3949
|
_updateRecords = new WeakSet();
|
2792
3950
|
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
2793
|
-
const
|
2794
|
-
|
2795
|
-
|
2796
|
-
|
2797
|
-
|
2798
|
-
BULK_OPERATION_MAX_SIZE
|
2799
|
-
);
|
3951
|
+
const operations = await promiseMap(objects, async ({ id, ...object }) => {
|
3952
|
+
const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3953
|
+
return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
|
3954
|
+
});
|
3955
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
2800
3956
|
const ids = [];
|
2801
|
-
for (const
|
3957
|
+
for (const operations2 of chunkedOperations) {
|
2802
3958
|
const { results } = await branchTransaction({
|
2803
3959
|
pathParams: {
|
2804
3960
|
workspace: "{workspaceId}",
|
2805
3961
|
dbBranchName: "{dbBranch}",
|
2806
3962
|
region: "{region}"
|
2807
3963
|
},
|
2808
|
-
body: { operations },
|
2809
|
-
...
|
3964
|
+
body: { operations: operations2 },
|
3965
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2810
3966
|
});
|
2811
3967
|
for (const result of results) {
|
2812
3968
|
if (result.operation === "update") {
|
@@ -2820,7 +3976,8 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
|
2820
3976
|
};
|
2821
3977
|
_upsertRecordWithID = new WeakSet();
|
2822
3978
|
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
2823
|
-
|
3979
|
+
if (!recordId)
|
3980
|
+
return null;
|
2824
3981
|
const response = await upsertRecordWithID({
|
2825
3982
|
pathParams: {
|
2826
3983
|
workspace: "{workspaceId}",
|
@@ -2831,14 +3988,15 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
2831
3988
|
},
|
2832
3989
|
queryParams: { columns, ifVersion },
|
2833
3990
|
body: object,
|
2834
|
-
...
|
3991
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2835
3992
|
});
|
2836
3993
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2837
3994
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2838
3995
|
};
|
2839
3996
|
_deleteRecord = new WeakSet();
|
2840
3997
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
2841
|
-
|
3998
|
+
if (!recordId)
|
3999
|
+
return null;
|
2842
4000
|
try {
|
2843
4001
|
const response = await deleteRecord({
|
2844
4002
|
pathParams: {
|
@@ -2849,7 +4007,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
2849
4007
|
recordId
|
2850
4008
|
},
|
2851
4009
|
queryParams: { columns },
|
2852
|
-
...
|
4010
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2853
4011
|
});
|
2854
4012
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2855
4013
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
@@ -2862,9 +4020,8 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
2862
4020
|
};
|
2863
4021
|
_deleteRecords = new WeakSet();
|
2864
4022
|
deleteRecords_fn = async function(recordIds) {
|
2865
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2866
4023
|
const chunkedOperations = chunk(
|
2867
|
-
recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
4024
|
+
compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
2868
4025
|
BULK_OPERATION_MAX_SIZE
|
2869
4026
|
);
|
2870
4027
|
for (const operations of chunkedOperations) {
|
@@ -2875,21 +4032,22 @@ deleteRecords_fn = async function(recordIds) {
|
|
2875
4032
|
region: "{region}"
|
2876
4033
|
},
|
2877
4034
|
body: { operations },
|
2878
|
-
...
|
4035
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2879
4036
|
});
|
2880
4037
|
}
|
2881
4038
|
};
|
2882
4039
|
_setCacheQuery = new WeakSet();
|
2883
4040
|
setCacheQuery_fn = async function(query, meta, records) {
|
2884
|
-
await __privateGet$4(this, _cache)
|
4041
|
+
await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
|
2885
4042
|
};
|
2886
4043
|
_getCacheQuery = new WeakSet();
|
2887
4044
|
getCacheQuery_fn = async function(query) {
|
2888
4045
|
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
2889
|
-
const result = await __privateGet$4(this, _cache)
|
4046
|
+
const result = await __privateGet$4(this, _cache)?.get(key);
|
2890
4047
|
if (!result)
|
2891
4048
|
return null;
|
2892
|
-
const
|
4049
|
+
const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
|
4050
|
+
const { cache: ttl = defaultTTL } = query.getQueryOptions();
|
2893
4051
|
if (ttl < 0)
|
2894
4052
|
return null;
|
2895
4053
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
@@ -2899,20 +4057,47 @@ _getSchemaTables$1 = new WeakSet();
|
|
2899
4057
|
getSchemaTables_fn$1 = async function() {
|
2900
4058
|
if (__privateGet$4(this, _schemaTables$2))
|
2901
4059
|
return __privateGet$4(this, _schemaTables$2);
|
2902
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2903
4060
|
const { schema } = await getBranchDetails({
|
2904
4061
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2905
|
-
...
|
4062
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
2906
4063
|
});
|
2907
4064
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
2908
4065
|
return schema.tables;
|
2909
4066
|
};
|
2910
|
-
|
2911
|
-
|
4067
|
+
_transformObjectToApi = new WeakSet();
|
4068
|
+
transformObjectToApi_fn = async function(object) {
|
4069
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
4070
|
+
const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
|
4071
|
+
if (!schema)
|
4072
|
+
throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
|
4073
|
+
const result = {};
|
4074
|
+
for (const [key, value] of Object.entries(object)) {
|
2912
4075
|
if (key === "xata")
|
2913
|
-
|
2914
|
-
|
2915
|
-
|
4076
|
+
continue;
|
4077
|
+
const type = schema.columns.find((column) => column.name === key)?.type;
|
4078
|
+
switch (type) {
|
4079
|
+
case "link": {
|
4080
|
+
result[key] = isIdentifiable(value) ? value.id : value;
|
4081
|
+
break;
|
4082
|
+
}
|
4083
|
+
case "datetime": {
|
4084
|
+
result[key] = value instanceof Date ? value.toISOString() : value;
|
4085
|
+
break;
|
4086
|
+
}
|
4087
|
+
case `file`:
|
4088
|
+
result[key] = await parseInputFileEntry(value);
|
4089
|
+
break;
|
4090
|
+
case "file[]":
|
4091
|
+
result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
|
4092
|
+
break;
|
4093
|
+
case "json":
|
4094
|
+
result[key] = stringifyJson(value);
|
4095
|
+
break;
|
4096
|
+
default:
|
4097
|
+
result[key] = value;
|
4098
|
+
}
|
4099
|
+
}
|
4100
|
+
return result;
|
2916
4101
|
};
|
2917
4102
|
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
2918
4103
|
const data = {};
|
@@ -2944,18 +4129,33 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2944
4129
|
if (item === column.name) {
|
2945
4130
|
return [...acc, "*"];
|
2946
4131
|
}
|
2947
|
-
if (item.startsWith(`${column.name}.`)) {
|
4132
|
+
if (isString(item) && item.startsWith(`${column.name}.`)) {
|
2948
4133
|
const [, ...path] = item.split(".");
|
2949
4134
|
return [...acc, path.join(".")];
|
2950
4135
|
}
|
2951
4136
|
return acc;
|
2952
4137
|
}, []);
|
2953
|
-
data[column.name] = initObject(
|
4138
|
+
data[column.name] = initObject(
|
4139
|
+
db,
|
4140
|
+
schemaTables,
|
4141
|
+
linkTable,
|
4142
|
+
value,
|
4143
|
+
selectedLinkColumns
|
4144
|
+
);
|
2954
4145
|
} else {
|
2955
4146
|
data[column.name] = null;
|
2956
4147
|
}
|
2957
4148
|
break;
|
2958
4149
|
}
|
4150
|
+
case "file":
|
4151
|
+
data[column.name] = isDefined(value) ? new XataFile(value) : null;
|
4152
|
+
break;
|
4153
|
+
case "file[]":
|
4154
|
+
data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
|
4155
|
+
break;
|
4156
|
+
case "json":
|
4157
|
+
data[column.name] = parseJson(value);
|
4158
|
+
break;
|
2959
4159
|
default:
|
2960
4160
|
data[column.name] = value ?? null;
|
2961
4161
|
if (column.notNull === true && value === null) {
|
@@ -2965,30 +4165,34 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2965
4165
|
}
|
2966
4166
|
}
|
2967
4167
|
const record = { ...data };
|
4168
|
+
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
2968
4169
|
record.read = function(columns2) {
|
2969
4170
|
return db[table].read(record["id"], columns2);
|
2970
4171
|
};
|
2971
4172
|
record.update = function(data2, b, c) {
|
2972
|
-
const columns2 =
|
4173
|
+
const columns2 = isValidSelectableColumns(b) ? b : ["*"];
|
2973
4174
|
const ifVersion = parseIfVersion(b, c);
|
2974
4175
|
return db[table].update(record["id"], data2, columns2, { ifVersion });
|
2975
4176
|
};
|
2976
4177
|
record.replace = function(data2, b, c) {
|
2977
|
-
const columns2 =
|
4178
|
+
const columns2 = isValidSelectableColumns(b) ? b : ["*"];
|
2978
4179
|
const ifVersion = parseIfVersion(b, c);
|
2979
4180
|
return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
|
2980
4181
|
};
|
2981
4182
|
record.delete = function() {
|
2982
4183
|
return db[table].delete(record["id"]);
|
2983
4184
|
};
|
4185
|
+
if (metadata !== void 0) {
|
4186
|
+
record.xata = Object.freeze(metadata);
|
4187
|
+
}
|
2984
4188
|
record.getMetadata = function() {
|
2985
|
-
return xata;
|
4189
|
+
return record.xata;
|
2986
4190
|
};
|
2987
4191
|
record.toSerializable = function() {
|
2988
|
-
return JSON.parse(JSON.stringify(
|
4192
|
+
return JSON.parse(JSON.stringify(record));
|
2989
4193
|
};
|
2990
4194
|
record.toString = function() {
|
2991
|
-
return JSON.stringify(
|
4195
|
+
return JSON.stringify(record);
|
2992
4196
|
};
|
2993
4197
|
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
2994
4198
|
Object.defineProperty(record, prop, { enumerable: false });
|
@@ -3006,11 +4210,7 @@ function extractId(value) {
|
|
3006
4210
|
function isValidColumn(columns, column) {
|
3007
4211
|
if (columns.includes("*"))
|
3008
4212
|
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);
|
4213
|
+
return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
|
3014
4214
|
}
|
3015
4215
|
function parseIfVersion(...args) {
|
3016
4216
|
for (const arg of args) {
|
@@ -3087,10 +4287,12 @@ const notExists = (column) => ({ $notExists: column });
|
|
3087
4287
|
const startsWith = (value) => ({ $startsWith: value });
|
3088
4288
|
const endsWith = (value) => ({ $endsWith: value });
|
3089
4289
|
const pattern = (value) => ({ $pattern: value });
|
4290
|
+
const iPattern = (value) => ({ $iPattern: value });
|
3090
4291
|
const is = (value) => ({ $is: value });
|
3091
4292
|
const equals = is;
|
3092
4293
|
const isNot = (value) => ({ $isNot: value });
|
3093
4294
|
const contains = (value) => ({ $contains: value });
|
4295
|
+
const iContains = (value) => ({ $iContains: value });
|
3094
4296
|
const includes = (value) => ({ $includes: value });
|
3095
4297
|
const includesAll = (value) => ({ $includesAll: value });
|
3096
4298
|
const includesNone = (value) => ({ $includesNone: value });
|
@@ -3146,6 +4348,80 @@ class SchemaPlugin extends XataPlugin {
|
|
3146
4348
|
_tables = new WeakMap();
|
3147
4349
|
_schemaTables$1 = new WeakMap();
|
3148
4350
|
|
4351
|
+
class FilesPlugin extends XataPlugin {
|
4352
|
+
build(pluginOptions) {
|
4353
|
+
return {
|
4354
|
+
download: async (location) => {
|
4355
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
4356
|
+
return await getFileItem({
|
4357
|
+
pathParams: {
|
4358
|
+
workspace: "{workspaceId}",
|
4359
|
+
dbBranchName: "{dbBranch}",
|
4360
|
+
region: "{region}",
|
4361
|
+
tableName: table ?? "",
|
4362
|
+
recordId: record ?? "",
|
4363
|
+
columnName: column ?? "",
|
4364
|
+
fileId
|
4365
|
+
},
|
4366
|
+
...pluginOptions,
|
4367
|
+
rawResponse: true
|
4368
|
+
});
|
4369
|
+
},
|
4370
|
+
upload: async (location, file, options) => {
|
4371
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
4372
|
+
const resolvedFile = await file;
|
4373
|
+
const contentType = options?.mediaType || getContentType(resolvedFile);
|
4374
|
+
const body = resolvedFile instanceof XataFile ? resolvedFile.toBlob() : resolvedFile;
|
4375
|
+
return await putFileItem({
|
4376
|
+
...pluginOptions,
|
4377
|
+
pathParams: {
|
4378
|
+
workspace: "{workspaceId}",
|
4379
|
+
dbBranchName: "{dbBranch}",
|
4380
|
+
region: "{region}",
|
4381
|
+
tableName: table ?? "",
|
4382
|
+
recordId: record ?? "",
|
4383
|
+
columnName: column ?? "",
|
4384
|
+
fileId
|
4385
|
+
},
|
4386
|
+
body,
|
4387
|
+
headers: { "Content-Type": contentType }
|
4388
|
+
});
|
4389
|
+
},
|
4390
|
+
delete: async (location) => {
|
4391
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
4392
|
+
return await deleteFileItem({
|
4393
|
+
pathParams: {
|
4394
|
+
workspace: "{workspaceId}",
|
4395
|
+
dbBranchName: "{dbBranch}",
|
4396
|
+
region: "{region}",
|
4397
|
+
tableName: table ?? "",
|
4398
|
+
recordId: record ?? "",
|
4399
|
+
columnName: column ?? "",
|
4400
|
+
fileId
|
4401
|
+
},
|
4402
|
+
...pluginOptions
|
4403
|
+
});
|
4404
|
+
}
|
4405
|
+
};
|
4406
|
+
}
|
4407
|
+
}
|
4408
|
+
function getContentType(file) {
|
4409
|
+
if (typeof file === "string") {
|
4410
|
+
return "text/plain";
|
4411
|
+
}
|
4412
|
+
if ("mediaType" in file && file.mediaType !== void 0) {
|
4413
|
+
return file.mediaType;
|
4414
|
+
}
|
4415
|
+
if (isBlob(file)) {
|
4416
|
+
return file.type;
|
4417
|
+
}
|
4418
|
+
try {
|
4419
|
+
return file.type;
|
4420
|
+
} catch (e) {
|
4421
|
+
}
|
4422
|
+
return "application/octet-stream";
|
4423
|
+
}
|
4424
|
+
|
3149
4425
|
var __accessCheck$1 = (obj, member, msg) => {
|
3150
4426
|
if (!member.has(obj))
|
3151
4427
|
throw TypeError("Cannot " + msg);
|
@@ -3178,63 +4454,137 @@ class SearchPlugin extends XataPlugin {
|
|
3178
4454
|
__privateAdd$1(this, _schemaTables, void 0);
|
3179
4455
|
__privateSet$1(this, _schemaTables, schemaTables);
|
3180
4456
|
}
|
3181
|
-
build(
|
4457
|
+
build(pluginOptions) {
|
3182
4458
|
return {
|
3183
4459
|
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
|
-
|
4460
|
+
const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4461
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
4462
|
+
return {
|
4463
|
+
totalCount,
|
4464
|
+
records: records.map((record) => {
|
4465
|
+
const { table = "orphan" } = record.xata;
|
4466
|
+
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
4467
|
+
})
|
4468
|
+
};
|
3190
4469
|
},
|
3191
4470
|
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
|
-
|
4471
|
+
const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4472
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
4473
|
+
const records = rawRecords.reduce((acc, record) => {
|
3195
4474
|
const { table = "orphan" } = record.xata;
|
3196
4475
|
const items = acc[table] ?? [];
|
3197
4476
|
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
3198
4477
|
return { ...acc, [table]: [...items, item] };
|
3199
4478
|
}, {});
|
4479
|
+
return { totalCount, records };
|
3200
4480
|
}
|
3201
4481
|
};
|
3202
4482
|
}
|
3203
4483
|
}
|
3204
4484
|
_schemaTables = new WeakMap();
|
3205
4485
|
_search = new WeakSet();
|
3206
|
-
search_fn = async function(query, options,
|
3207
|
-
const fetchProps = await getFetchProps();
|
4486
|
+
search_fn = async function(query, options, pluginOptions) {
|
3208
4487
|
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
3209
|
-
const { records } = await searchBranch({
|
4488
|
+
const { records, totalCount } = await searchBranch({
|
3210
4489
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4490
|
+
// @ts-ignore https://github.com/xataio/client-ts/issues/313
|
3211
4491
|
body: { tables, query, fuzziness, prefix, highlight, page },
|
3212
|
-
...
|
4492
|
+
...pluginOptions
|
3213
4493
|
});
|
3214
|
-
return records;
|
4494
|
+
return { records, totalCount };
|
3215
4495
|
};
|
3216
4496
|
_getSchemaTables = new WeakSet();
|
3217
|
-
getSchemaTables_fn = async function(
|
4497
|
+
getSchemaTables_fn = async function(pluginOptions) {
|
3218
4498
|
if (__privateGet$1(this, _schemaTables))
|
3219
4499
|
return __privateGet$1(this, _schemaTables);
|
3220
|
-
const fetchProps = await getFetchProps();
|
3221
4500
|
const { schema } = await getBranchDetails({
|
3222
4501
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3223
|
-
...
|
4502
|
+
...pluginOptions
|
3224
4503
|
});
|
3225
4504
|
__privateSet$1(this, _schemaTables, schema.tables);
|
3226
4505
|
return schema.tables;
|
3227
4506
|
};
|
3228
4507
|
|
4508
|
+
function escapeElement(elementRepresentation) {
|
4509
|
+
const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
4510
|
+
return '"' + escaped + '"';
|
4511
|
+
}
|
4512
|
+
function arrayString(val) {
|
4513
|
+
let result = "{";
|
4514
|
+
for (let i = 0; i < val.length; i++) {
|
4515
|
+
if (i > 0) {
|
4516
|
+
result = result + ",";
|
4517
|
+
}
|
4518
|
+
if (val[i] === null || typeof val[i] === "undefined") {
|
4519
|
+
result = result + "NULL";
|
4520
|
+
} else if (Array.isArray(val[i])) {
|
4521
|
+
result = result + arrayString(val[i]);
|
4522
|
+
} else if (val[i] instanceof Buffer) {
|
4523
|
+
result += "\\\\x" + val[i].toString("hex");
|
4524
|
+
} else {
|
4525
|
+
result += escapeElement(prepareValue(val[i]));
|
4526
|
+
}
|
4527
|
+
}
|
4528
|
+
result = result + "}";
|
4529
|
+
return result;
|
4530
|
+
}
|
4531
|
+
function prepareValue(value) {
|
4532
|
+
if (!isDefined(value))
|
4533
|
+
return null;
|
4534
|
+
if (value instanceof Date) {
|
4535
|
+
return value.toISOString();
|
4536
|
+
}
|
4537
|
+
if (Array.isArray(value)) {
|
4538
|
+
return arrayString(value);
|
4539
|
+
}
|
4540
|
+
if (isObject(value)) {
|
4541
|
+
return JSON.stringify(value);
|
4542
|
+
}
|
4543
|
+
try {
|
4544
|
+
return value.toString();
|
4545
|
+
} catch (e) {
|
4546
|
+
return value;
|
4547
|
+
}
|
4548
|
+
}
|
4549
|
+
function prepareParams(param1, param2) {
|
4550
|
+
if (isString(param1)) {
|
4551
|
+
return { statement: param1, params: param2?.map((value) => prepareValue(value)) };
|
4552
|
+
}
|
4553
|
+
if (isStringArray(param1)) {
|
4554
|
+
const statement = param1.reduce((acc, curr, index) => {
|
4555
|
+
return acc + curr + (index < (param2?.length ?? 0) ? "$" + (index + 1) : "");
|
4556
|
+
}, "");
|
4557
|
+
return { statement, params: param2?.map((value) => prepareValue(value)) };
|
4558
|
+
}
|
4559
|
+
if (isObject(param1)) {
|
4560
|
+
const { statement, params, consistency } = param1;
|
4561
|
+
return { statement, params: params?.map((value) => prepareValue(value)), consistency };
|
4562
|
+
}
|
4563
|
+
throw new Error("Invalid query");
|
4564
|
+
}
|
4565
|
+
|
4566
|
+
class SQLPlugin extends XataPlugin {
|
4567
|
+
build(pluginOptions) {
|
4568
|
+
return async (param1, ...param2) => {
|
4569
|
+
const { statement, params, consistency } = prepareParams(param1, param2);
|
4570
|
+
const { records, warning } = await sqlQuery({
|
4571
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4572
|
+
body: { statement, params, consistency },
|
4573
|
+
...pluginOptions
|
4574
|
+
});
|
4575
|
+
return { records, warning };
|
4576
|
+
};
|
4577
|
+
}
|
4578
|
+
}
|
4579
|
+
|
3229
4580
|
class TransactionPlugin extends XataPlugin {
|
3230
|
-
build(
|
4581
|
+
build(pluginOptions) {
|
3231
4582
|
return {
|
3232
4583
|
run: async (operations) => {
|
3233
|
-
const fetchProps = await getFetchProps();
|
3234
4584
|
const response = await branchTransaction({
|
3235
4585
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3236
4586
|
body: { operations },
|
3237
|
-
...
|
4587
|
+
...pluginOptions
|
3238
4588
|
});
|
3239
4589
|
return response;
|
3240
4590
|
}
|
@@ -3242,91 +4592,6 @@ class TransactionPlugin extends XataPlugin {
|
|
3242
4592
|
}
|
3243
4593
|
}
|
3244
4594
|
|
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
4595
|
var __accessCheck = (obj, member, msg) => {
|
3331
4596
|
if (!member.has(obj))
|
3332
4597
|
throw TypeError("Cannot " + msg);
|
@@ -3350,46 +4615,41 @@ var __privateMethod = (obj, member, method) => {
|
|
3350
4615
|
return method;
|
3351
4616
|
};
|
3352
4617
|
const buildClient = (plugins) => {
|
3353
|
-
var
|
4618
|
+
var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
|
3354
4619
|
return _a = class {
|
3355
4620
|
constructor(options = {}, schemaTables) {
|
3356
4621
|
__privateAdd(this, _parseOptions);
|
3357
4622
|
__privateAdd(this, _getFetchProps);
|
3358
|
-
__privateAdd(this, _evaluateBranch);
|
3359
|
-
__privateAdd(this, _branch, void 0);
|
3360
4623
|
__privateAdd(this, _options, void 0);
|
3361
4624
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
3362
4625
|
__privateSet(this, _options, safeOptions);
|
3363
4626
|
const pluginOptions = {
|
3364
|
-
|
4627
|
+
...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
3365
4628
|
cache: safeOptions.cache,
|
3366
|
-
|
4629
|
+
host: safeOptions.host
|
3367
4630
|
};
|
3368
4631
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
3369
4632
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
3370
4633
|
const transactions = new TransactionPlugin().build(pluginOptions);
|
4634
|
+
const sql = new SQLPlugin().build(pluginOptions);
|
4635
|
+
const files = new FilesPlugin().build(pluginOptions);
|
3371
4636
|
this.db = db;
|
3372
4637
|
this.search = search;
|
3373
4638
|
this.transactions = transactions;
|
4639
|
+
this.sql = sql;
|
4640
|
+
this.files = files;
|
3374
4641
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
3375
4642
|
if (namespace === void 0)
|
3376
4643
|
continue;
|
3377
|
-
|
3378
|
-
if (result instanceof Promise) {
|
3379
|
-
void result.then((namespace2) => {
|
3380
|
-
this[key] = namespace2;
|
3381
|
-
});
|
3382
|
-
} else {
|
3383
|
-
this[key] = result;
|
3384
|
-
}
|
4644
|
+
this[key] = namespace.build(pluginOptions);
|
3385
4645
|
}
|
3386
4646
|
}
|
3387
4647
|
async getConfig() {
|
3388
4648
|
const databaseURL = __privateGet(this, _options).databaseURL;
|
3389
|
-
const branch =
|
4649
|
+
const branch = __privateGet(this, _options).branch;
|
3390
4650
|
return { databaseURL, branch };
|
3391
4651
|
}
|
3392
|
-
},
|
4652
|
+
}, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
3393
4653
|
const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
|
3394
4654
|
const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
|
3395
4655
|
if (isBrowser && !enableBrowser) {
|
@@ -3403,20 +4663,34 @@ const buildClient = (plugins) => {
|
|
3403
4663
|
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
3404
4664
|
const trace = options?.trace ?? defaultTrace;
|
3405
4665
|
const clientName = options?.clientName;
|
4666
|
+
const host = options?.host ?? "production";
|
3406
4667
|
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
4668
|
if (!apiKey) {
|
3415
4669
|
throw new Error("Option apiKey is required");
|
3416
4670
|
}
|
3417
4671
|
if (!databaseURL) {
|
3418
4672
|
throw new Error("Option databaseURL is required");
|
3419
4673
|
}
|
4674
|
+
const envBranch = getBranch();
|
4675
|
+
const previewBranch = getPreviewBranch();
|
4676
|
+
const branch = options?.branch || previewBranch || envBranch || "main";
|
4677
|
+
if (!!previewBranch && branch !== previewBranch) {
|
4678
|
+
console.warn(
|
4679
|
+
`Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
|
4680
|
+
);
|
4681
|
+
} else if (!!envBranch && branch !== envBranch) {
|
4682
|
+
console.warn(
|
4683
|
+
`Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
4684
|
+
);
|
4685
|
+
} else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
|
4686
|
+
console.warn(
|
4687
|
+
`Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
4688
|
+
);
|
4689
|
+
} else if (!previewBranch && !envBranch && options?.branch === void 0) {
|
4690
|
+
console.warn(
|
4691
|
+
`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.`
|
4692
|
+
);
|
4693
|
+
}
|
3420
4694
|
return {
|
3421
4695
|
fetch,
|
3422
4696
|
databaseURL,
|
@@ -3424,12 +4698,13 @@ const buildClient = (plugins) => {
|
|
3424
4698
|
branch,
|
3425
4699
|
cache,
|
3426
4700
|
trace,
|
4701
|
+
host,
|
3427
4702
|
clientID: generateUUID(),
|
3428
4703
|
enableBrowser,
|
3429
4704
|
clientName,
|
3430
4705
|
xataAgentExtra
|
3431
4706
|
};
|
3432
|
-
}, _getFetchProps = new WeakSet(), getFetchProps_fn =
|
4707
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
|
3433
4708
|
fetch,
|
3434
4709
|
apiKey,
|
3435
4710
|
databaseURL,
|
@@ -3439,16 +4714,14 @@ const buildClient = (plugins) => {
|
|
3439
4714
|
clientName,
|
3440
4715
|
xataAgentExtra
|
3441
4716
|
}) {
|
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
4717
|
return {
|
3446
|
-
|
4718
|
+
fetch,
|
3447
4719
|
apiKey,
|
3448
4720
|
apiUrl: "",
|
4721
|
+
// Instead of using workspace and dbBranch, we inject a probably CNAME'd URL
|
3449
4722
|
workspacesApiUrl: (path, params) => {
|
3450
4723
|
const hasBranch = params.dbBranchName ?? params.branch;
|
3451
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${
|
4724
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
|
3452
4725
|
return databaseURL + newPath;
|
3453
4726
|
},
|
3454
4727
|
trace,
|
@@ -3456,22 +4729,6 @@ const buildClient = (plugins) => {
|
|
3456
4729
|
clientName,
|
3457
4730
|
xataAgentExtra
|
3458
4731
|
};
|
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
4732
|
}, _a;
|
3476
4733
|
};
|
3477
4734
|
class BaseClient extends buildClient() {
|
@@ -3544,21 +4801,6 @@ const deserialize = (json) => {
|
|
3544
4801
|
return defaultSerializer.fromJSON(json);
|
3545
4802
|
};
|
3546
4803
|
|
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
4804
|
class XataError extends Error {
|
3563
4805
|
constructor(message, status) {
|
3564
4806
|
super(message);
|
@@ -3568,6 +4810,7 @@ class XataError extends Error {
|
|
3568
4810
|
|
3569
4811
|
exports.BaseClient = BaseClient;
|
3570
4812
|
exports.FetcherError = FetcherError;
|
4813
|
+
exports.FilesPlugin = FilesPlugin;
|
3571
4814
|
exports.Operations = operationsByTag;
|
3572
4815
|
exports.PAGINATION_DEFAULT_OFFSET = PAGINATION_DEFAULT_OFFSET;
|
3573
4816
|
exports.PAGINATION_DEFAULT_SIZE = PAGINATION_DEFAULT_SIZE;
|
@@ -3576,31 +4819,41 @@ exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
|
|
3576
4819
|
exports.Page = Page;
|
3577
4820
|
exports.Query = Query;
|
3578
4821
|
exports.RecordArray = RecordArray;
|
4822
|
+
exports.RecordColumnTypes = RecordColumnTypes;
|
3579
4823
|
exports.Repository = Repository;
|
3580
4824
|
exports.RestRepository = RestRepository;
|
4825
|
+
exports.SQLPlugin = SQLPlugin;
|
3581
4826
|
exports.SchemaPlugin = SchemaPlugin;
|
3582
4827
|
exports.SearchPlugin = SearchPlugin;
|
3583
4828
|
exports.Serializer = Serializer;
|
3584
4829
|
exports.SimpleCache = SimpleCache;
|
4830
|
+
exports.TransactionPlugin = TransactionPlugin;
|
3585
4831
|
exports.XataApiClient = XataApiClient;
|
3586
4832
|
exports.XataApiPlugin = XataApiPlugin;
|
3587
4833
|
exports.XataError = XataError;
|
4834
|
+
exports.XataFile = XataFile;
|
3588
4835
|
exports.XataPlugin = XataPlugin;
|
3589
4836
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
3590
4837
|
exports.addGitBranchesEntry = addGitBranchesEntry;
|
3591
4838
|
exports.addTableColumn = addTableColumn;
|
3592
4839
|
exports.aggregateTable = aggregateTable;
|
3593
4840
|
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
4841
|
+
exports.applyMigration = applyMigration;
|
4842
|
+
exports.askTable = askTable;
|
4843
|
+
exports.askTableSession = askTableSession;
|
3594
4844
|
exports.branchTransaction = branchTransaction;
|
3595
4845
|
exports.buildClient = buildClient;
|
3596
|
-
exports.
|
4846
|
+
exports.buildPreviewBranchName = buildPreviewBranchName;
|
4847
|
+
exports.buildProviderString = buildProviderString;
|
3597
4848
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
3598
4849
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
3599
4850
|
exports.compareBranchSchemas = compareBranchSchemas;
|
3600
4851
|
exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
|
3601
4852
|
exports.compareMigrationRequest = compareMigrationRequest;
|
3602
4853
|
exports.contains = contains;
|
4854
|
+
exports.copyBranch = copyBranch;
|
3603
4855
|
exports.createBranch = createBranch;
|
4856
|
+
exports.createCluster = createCluster;
|
3604
4857
|
exports.createDatabase = createDatabase;
|
3605
4858
|
exports.createMigrationRequest = createMigrationRequest;
|
3606
4859
|
exports.createTable = createTable;
|
@@ -3610,18 +4863,26 @@ exports.deleteBranch = deleteBranch;
|
|
3610
4863
|
exports.deleteColumn = deleteColumn;
|
3611
4864
|
exports.deleteDatabase = deleteDatabase;
|
3612
4865
|
exports.deleteDatabaseGithubSettings = deleteDatabaseGithubSettings;
|
4866
|
+
exports.deleteFile = deleteFile;
|
4867
|
+
exports.deleteFileItem = deleteFileItem;
|
4868
|
+
exports.deleteOAuthAccessToken = deleteOAuthAccessToken;
|
3613
4869
|
exports.deleteRecord = deleteRecord;
|
3614
4870
|
exports.deleteTable = deleteTable;
|
3615
4871
|
exports.deleteUser = deleteUser;
|
3616
4872
|
exports.deleteUserAPIKey = deleteUserAPIKey;
|
4873
|
+
exports.deleteUserOAuthClient = deleteUserOAuthClient;
|
3617
4874
|
exports.deleteWorkspace = deleteWorkspace;
|
3618
4875
|
exports.deserialize = deserialize;
|
3619
4876
|
exports.endsWith = endsWith;
|
3620
4877
|
exports.equals = equals;
|
3621
4878
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
3622
4879
|
exports.exists = exists;
|
4880
|
+
exports.fileAccess = fileAccess;
|
4881
|
+
exports.fileUpload = fileUpload;
|
3623
4882
|
exports.ge = ge;
|
3624
4883
|
exports.getAPIKey = getAPIKey;
|
4884
|
+
exports.getAuthorizationCode = getAuthorizationCode;
|
4885
|
+
exports.getBranch = getBranch;
|
3625
4886
|
exports.getBranchDetails = getBranchDetails;
|
3626
4887
|
exports.getBranchList = getBranchList;
|
3627
4888
|
exports.getBranchMetadata = getBranchMetadata;
|
@@ -3629,30 +4890,38 @@ exports.getBranchMigrationHistory = getBranchMigrationHistory;
|
|
3629
4890
|
exports.getBranchMigrationPlan = getBranchMigrationPlan;
|
3630
4891
|
exports.getBranchSchemaHistory = getBranchSchemaHistory;
|
3631
4892
|
exports.getBranchStats = getBranchStats;
|
4893
|
+
exports.getCluster = getCluster;
|
3632
4894
|
exports.getColumn = getColumn;
|
3633
|
-
exports.getCurrentBranchDetails = getCurrentBranchDetails;
|
3634
|
-
exports.getCurrentBranchName = getCurrentBranchName;
|
3635
4895
|
exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
|
3636
4896
|
exports.getDatabaseList = getDatabaseList;
|
3637
4897
|
exports.getDatabaseMetadata = getDatabaseMetadata;
|
3638
4898
|
exports.getDatabaseURL = getDatabaseURL;
|
4899
|
+
exports.getFile = getFile;
|
4900
|
+
exports.getFileItem = getFileItem;
|
3639
4901
|
exports.getGitBranchesMapping = getGitBranchesMapping;
|
3640
4902
|
exports.getHostUrl = getHostUrl;
|
3641
4903
|
exports.getMigrationRequest = getMigrationRequest;
|
3642
4904
|
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
4905
|
+
exports.getPreviewBranch = getPreviewBranch;
|
3643
4906
|
exports.getRecord = getRecord;
|
4907
|
+
exports.getSchema = getSchema;
|
3644
4908
|
exports.getTableColumns = getTableColumns;
|
3645
4909
|
exports.getTableSchema = getTableSchema;
|
3646
4910
|
exports.getUser = getUser;
|
3647
4911
|
exports.getUserAPIKeys = getUserAPIKeys;
|
4912
|
+
exports.getUserOAuthAccessTokens = getUserOAuthAccessTokens;
|
4913
|
+
exports.getUserOAuthClients = getUserOAuthClients;
|
3648
4914
|
exports.getWorkspace = getWorkspace;
|
3649
4915
|
exports.getWorkspaceMembersList = getWorkspaceMembersList;
|
3650
4916
|
exports.getWorkspacesList = getWorkspacesList;
|
4917
|
+
exports.grantAuthorizationCode = grantAuthorizationCode;
|
3651
4918
|
exports.greaterEquals = greaterEquals;
|
3652
4919
|
exports.greaterThan = greaterThan;
|
3653
4920
|
exports.greaterThanEquals = greaterThanEquals;
|
3654
4921
|
exports.gt = gt;
|
3655
4922
|
exports.gte = gte;
|
4923
|
+
exports.iContains = iContains;
|
4924
|
+
exports.iPattern = iPattern;
|
3656
4925
|
exports.includes = includes;
|
3657
4926
|
exports.includesAll = includesAll;
|
3658
4927
|
exports.includesAny = includesAny;
|
@@ -3666,11 +4935,14 @@ exports.isHostProviderAlias = isHostProviderAlias;
|
|
3666
4935
|
exports.isHostProviderBuilder = isHostProviderBuilder;
|
3667
4936
|
exports.isIdentifiable = isIdentifiable;
|
3668
4937
|
exports.isNot = isNot;
|
4938
|
+
exports.isValidExpandedColumn = isValidExpandedColumn;
|
4939
|
+
exports.isValidSelectableColumns = isValidSelectableColumns;
|
3669
4940
|
exports.isXataRecord = isXataRecord;
|
3670
4941
|
exports.le = le;
|
3671
4942
|
exports.lessEquals = lessEquals;
|
3672
4943
|
exports.lessThan = lessThan;
|
3673
4944
|
exports.lessThanEquals = lessThanEquals;
|
4945
|
+
exports.listClusters = listClusters;
|
3674
4946
|
exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
|
3675
4947
|
exports.listRegions = listRegions;
|
3676
4948
|
exports.lt = lt;
|
@@ -3681,25 +4953,36 @@ exports.operationsByTag = operationsByTag;
|
|
3681
4953
|
exports.parseProviderString = parseProviderString;
|
3682
4954
|
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
3683
4955
|
exports.pattern = pattern;
|
4956
|
+
exports.pgRollJobStatus = pgRollJobStatus;
|
4957
|
+
exports.pgRollMigrationHistory = pgRollMigrationHistory;
|
4958
|
+
exports.pgRollStatus = pgRollStatus;
|
3684
4959
|
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
4960
|
+
exports.pushBranchMigrations = pushBranchMigrations;
|
4961
|
+
exports.putFile = putFile;
|
4962
|
+
exports.putFileItem = putFileItem;
|
3685
4963
|
exports.queryMigrationRequests = queryMigrationRequests;
|
3686
4964
|
exports.queryTable = queryTable;
|
3687
4965
|
exports.removeGitBranchesEntry = removeGitBranchesEntry;
|
3688
4966
|
exports.removeWorkspaceMember = removeWorkspaceMember;
|
4967
|
+
exports.renameDatabase = renameDatabase;
|
3689
4968
|
exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
|
3690
4969
|
exports.resolveBranch = resolveBranch;
|
3691
4970
|
exports.searchBranch = searchBranch;
|
3692
4971
|
exports.searchTable = searchTable;
|
3693
4972
|
exports.serialize = serialize;
|
3694
4973
|
exports.setTableSchema = setTableSchema;
|
4974
|
+
exports.sqlQuery = sqlQuery;
|
3695
4975
|
exports.startsWith = startsWith;
|
3696
4976
|
exports.summarizeTable = summarizeTable;
|
4977
|
+
exports.transformImage = transformImage;
|
3697
4978
|
exports.updateBranchMetadata = updateBranchMetadata;
|
3698
4979
|
exports.updateBranchSchema = updateBranchSchema;
|
4980
|
+
exports.updateCluster = updateCluster;
|
3699
4981
|
exports.updateColumn = updateColumn;
|
3700
4982
|
exports.updateDatabaseGithubSettings = updateDatabaseGithubSettings;
|
3701
4983
|
exports.updateDatabaseMetadata = updateDatabaseMetadata;
|
3702
4984
|
exports.updateMigrationRequest = updateMigrationRequest;
|
4985
|
+
exports.updateOAuthAccessToken = updateOAuthAccessToken;
|
3703
4986
|
exports.updateRecordWithID = updateRecordWithID;
|
3704
4987
|
exports.updateTable = updateTable;
|
3705
4988
|
exports.updateUser = updateUser;
|
@@ -3707,4 +4990,5 @@ exports.updateWorkspace = updateWorkspace;
|
|
3707
4990
|
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
3708
4991
|
exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
|
3709
4992
|
exports.upsertRecordWithID = upsertRecordWithID;
|
4993
|
+
exports.vectorSearchTable = vectorSearchTable;
|
3710
4994
|
//# sourceMappingURL=index.cjs.map
|