@xata.io/client 0.0.0-alpha.vf2ed8b7 → 0.0.0-alpha.vf2f26ae
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-add-version.log +4 -0
- package/.turbo/turbo-build.log +13 -0
- package/CHANGELOG.md +312 -0
- package/README.md +3 -269
- package/dist/index.cjs +2679 -773
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6209 -1539
- package/dist/index.mjs +2638 -755
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -11
- package/.eslintrc.cjs +0 -12
- package/Usage.md +0 -449
- package/rollup.config.js +0 -29
- package/tsconfig.json +0 -23
package/dist/index.cjs
CHANGED
@@ -1,27 +1,8 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
function _interopNamespace(e) {
|
6
|
-
if (e && e.__esModule) return e;
|
7
|
-
var n = Object.create(null);
|
8
|
-
if (e) {
|
9
|
-
Object.keys(e).forEach(function (k) {
|
10
|
-
if (k !== 'default') {
|
11
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
12
|
-
Object.defineProperty(n, k, d.get ? d : {
|
13
|
-
enumerable: true,
|
14
|
-
get: function () { return e[k]; }
|
15
|
-
});
|
16
|
-
}
|
17
|
-
});
|
18
|
-
}
|
19
|
-
n["default"] = e;
|
20
|
-
return Object.freeze(n);
|
21
|
-
}
|
22
|
-
|
23
|
-
const defaultTrace = async (_name, fn, _options) => {
|
3
|
+
const defaultTrace = async (name, fn, _options) => {
|
24
4
|
return await fn({
|
5
|
+
name,
|
25
6
|
setAttributes: () => {
|
26
7
|
return;
|
27
8
|
}
|
@@ -60,6 +41,21 @@ function isString(value) {
|
|
60
41
|
function isStringArray(value) {
|
61
42
|
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
62
43
|
}
|
44
|
+
function isNumber(value) {
|
45
|
+
return isDefined(value) && typeof value === "number";
|
46
|
+
}
|
47
|
+
function parseNumber(value) {
|
48
|
+
if (isNumber(value)) {
|
49
|
+
return value;
|
50
|
+
}
|
51
|
+
if (isString(value)) {
|
52
|
+
const parsed = Number(value);
|
53
|
+
if (!Number.isNaN(parsed)) {
|
54
|
+
return parsed;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
return void 0;
|
58
|
+
}
|
63
59
|
function toBase64(value) {
|
64
60
|
try {
|
65
61
|
return btoa(value);
|
@@ -68,16 +64,39 @@ function toBase64(value) {
|
|
68
64
|
return buf.from(value).toString("base64");
|
69
65
|
}
|
70
66
|
}
|
67
|
+
function deepMerge(a, b) {
|
68
|
+
const result = { ...a };
|
69
|
+
for (const [key, value] of Object.entries(b)) {
|
70
|
+
if (isObject(value) && isObject(result[key])) {
|
71
|
+
result[key] = deepMerge(result[key], value);
|
72
|
+
} else {
|
73
|
+
result[key] = value;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
return result;
|
77
|
+
}
|
78
|
+
function chunk(array, chunkSize) {
|
79
|
+
const result = [];
|
80
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
81
|
+
result.push(array.slice(i, i + chunkSize));
|
82
|
+
}
|
83
|
+
return result;
|
84
|
+
}
|
85
|
+
async function timeout(ms) {
|
86
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
87
|
+
}
|
71
88
|
|
72
89
|
function getEnvironment() {
|
73
90
|
try {
|
74
|
-
if (
|
91
|
+
if (isDefined(process) && isDefined(process.env)) {
|
75
92
|
return {
|
76
93
|
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
77
94
|
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
78
95
|
branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
|
79
|
-
|
80
|
-
|
96
|
+
deployPreview: process.env.XATA_PREVIEW,
|
97
|
+
deployPreviewBranch: process.env.XATA_PREVIEW_BRANCH,
|
98
|
+
vercelGitCommitRef: process.env.VERCEL_GIT_COMMIT_REF,
|
99
|
+
vercelGitRepoOwner: process.env.VERCEL_GIT_REPO_OWNER
|
81
100
|
};
|
82
101
|
}
|
83
102
|
} catch (err) {
|
@@ -88,8 +107,10 @@ function getEnvironment() {
|
|
88
107
|
apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
|
89
108
|
databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
|
90
109
|
branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
|
91
|
-
|
92
|
-
|
110
|
+
deployPreview: Deno.env.get("XATA_PREVIEW"),
|
111
|
+
deployPreviewBranch: Deno.env.get("XATA_PREVIEW_BRANCH"),
|
112
|
+
vercelGitCommitRef: Deno.env.get("VERCEL_GIT_COMMIT_REF"),
|
113
|
+
vercelGitRepoOwner: Deno.env.get("VERCEL_GIT_REPO_OWNER")
|
93
114
|
};
|
94
115
|
}
|
95
116
|
} catch (err) {
|
@@ -98,10 +119,31 @@ function getEnvironment() {
|
|
98
119
|
apiKey: getGlobalApiKey(),
|
99
120
|
databaseURL: getGlobalDatabaseURL(),
|
100
121
|
branch: getGlobalBranch(),
|
101
|
-
|
102
|
-
|
122
|
+
deployPreview: void 0,
|
123
|
+
deployPreviewBranch: void 0,
|
124
|
+
vercelGitCommitRef: void 0,
|
125
|
+
vercelGitRepoOwner: void 0
|
103
126
|
};
|
104
127
|
}
|
128
|
+
function getEnableBrowserVariable() {
|
129
|
+
try {
|
130
|
+
if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
|
131
|
+
return process.env.XATA_ENABLE_BROWSER === "true";
|
132
|
+
}
|
133
|
+
} catch (err) {
|
134
|
+
}
|
135
|
+
try {
|
136
|
+
if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
|
137
|
+
return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
|
138
|
+
}
|
139
|
+
} catch (err) {
|
140
|
+
}
|
141
|
+
try {
|
142
|
+
return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
|
143
|
+
} catch (err) {
|
144
|
+
return void 0;
|
145
|
+
}
|
146
|
+
}
|
105
147
|
function getGlobalApiKey() {
|
106
148
|
try {
|
107
149
|
return XATA_API_KEY;
|
@@ -123,44 +165,76 @@ function getGlobalBranch() {
|
|
123
165
|
return void 0;
|
124
166
|
}
|
125
167
|
}
|
126
|
-
function
|
168
|
+
function getDatabaseURL() {
|
127
169
|
try {
|
128
|
-
|
170
|
+
const { databaseURL } = getEnvironment();
|
171
|
+
return databaseURL;
|
129
172
|
} catch (err) {
|
130
173
|
return void 0;
|
131
174
|
}
|
132
175
|
}
|
133
|
-
|
134
|
-
const cmd = ["git", "branch", "--show-current"];
|
135
|
-
const fullCmd = cmd.join(" ");
|
136
|
-
const nodeModule = ["child", "process"].join("_");
|
137
|
-
const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
|
176
|
+
function getAPIKey() {
|
138
177
|
try {
|
139
|
-
|
140
|
-
|
141
|
-
}
|
142
|
-
const { execSync } = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(nodeModule);
|
143
|
-
return execSync(fullCmd, execOptions).toString().trim();
|
178
|
+
const { apiKey } = getEnvironment();
|
179
|
+
return apiKey;
|
144
180
|
} catch (err) {
|
181
|
+
return void 0;
|
145
182
|
}
|
183
|
+
}
|
184
|
+
function getBranch() {
|
146
185
|
try {
|
147
|
-
|
148
|
-
|
149
|
-
return new TextDecoder().decode(await process2.output()).trim();
|
150
|
-
}
|
186
|
+
const { branch } = getEnvironment();
|
187
|
+
return branch ?? "main";
|
151
188
|
} catch (err) {
|
189
|
+
return void 0;
|
152
190
|
}
|
153
191
|
}
|
154
|
-
|
155
|
-
|
192
|
+
function buildPreviewBranchName({ org, branch }) {
|
193
|
+
return `preview-${org}-${branch}`;
|
194
|
+
}
|
195
|
+
function getPreviewBranch() {
|
156
196
|
try {
|
157
|
-
const {
|
158
|
-
|
197
|
+
const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = getEnvironment();
|
198
|
+
if (deployPreviewBranch)
|
199
|
+
return deployPreviewBranch;
|
200
|
+
switch (deployPreview) {
|
201
|
+
case "vercel": {
|
202
|
+
if (!vercelGitCommitRef || !vercelGitRepoOwner) {
|
203
|
+
console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
|
204
|
+
return void 0;
|
205
|
+
}
|
206
|
+
return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
|
207
|
+
}
|
208
|
+
}
|
209
|
+
return void 0;
|
159
210
|
} catch (err) {
|
160
211
|
return void 0;
|
161
212
|
}
|
162
213
|
}
|
163
214
|
|
215
|
+
var __accessCheck$8 = (obj, member, msg) => {
|
216
|
+
if (!member.has(obj))
|
217
|
+
throw TypeError("Cannot " + msg);
|
218
|
+
};
|
219
|
+
var __privateGet$8 = (obj, member, getter) => {
|
220
|
+
__accessCheck$8(obj, member, "read from private field");
|
221
|
+
return getter ? getter.call(obj) : member.get(obj);
|
222
|
+
};
|
223
|
+
var __privateAdd$8 = (obj, member, value) => {
|
224
|
+
if (member.has(obj))
|
225
|
+
throw TypeError("Cannot add the same private member more than once");
|
226
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
227
|
+
};
|
228
|
+
var __privateSet$8 = (obj, member, value, setter) => {
|
229
|
+
__accessCheck$8(obj, member, "write to private field");
|
230
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
231
|
+
return value;
|
232
|
+
};
|
233
|
+
var __privateMethod$4 = (obj, member, method) => {
|
234
|
+
__accessCheck$8(obj, member, "access private method");
|
235
|
+
return method;
|
236
|
+
};
|
237
|
+
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
164
238
|
function getFetchImplementation(userFetch) {
|
165
239
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
166
240
|
const fetchImpl = userFetch ?? globalFetch;
|
@@ -171,8 +245,254 @@ function getFetchImplementation(userFetch) {
|
|
171
245
|
}
|
172
246
|
return fetchImpl;
|
173
247
|
}
|
248
|
+
class ApiRequestPool {
|
249
|
+
constructor(concurrency = 10) {
|
250
|
+
__privateAdd$8(this, _enqueue);
|
251
|
+
__privateAdd$8(this, _fetch, void 0);
|
252
|
+
__privateAdd$8(this, _queue, void 0);
|
253
|
+
__privateAdd$8(this, _concurrency, void 0);
|
254
|
+
__privateSet$8(this, _queue, []);
|
255
|
+
__privateSet$8(this, _concurrency, concurrency);
|
256
|
+
this.running = 0;
|
257
|
+
this.started = 0;
|
258
|
+
}
|
259
|
+
setFetch(fetch2) {
|
260
|
+
__privateSet$8(this, _fetch, fetch2);
|
261
|
+
}
|
262
|
+
getFetch() {
|
263
|
+
if (!__privateGet$8(this, _fetch)) {
|
264
|
+
throw new Error("Fetch not set");
|
265
|
+
}
|
266
|
+
return __privateGet$8(this, _fetch);
|
267
|
+
}
|
268
|
+
request(url, options) {
|
269
|
+
const start = /* @__PURE__ */ new Date();
|
270
|
+
const fetch2 = this.getFetch();
|
271
|
+
const runRequest = async (stalled = false) => {
|
272
|
+
const response = await fetch2(url, options);
|
273
|
+
if (response.status === 429) {
|
274
|
+
const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
|
275
|
+
await timeout(rateLimitReset * 1e3);
|
276
|
+
return await runRequest(true);
|
277
|
+
}
|
278
|
+
if (stalled) {
|
279
|
+
const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
|
280
|
+
console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
|
281
|
+
}
|
282
|
+
return response;
|
283
|
+
};
|
284
|
+
return __privateMethod$4(this, _enqueue, enqueue_fn).call(this, async () => {
|
285
|
+
return await runRequest();
|
286
|
+
});
|
287
|
+
}
|
288
|
+
}
|
289
|
+
_fetch = new WeakMap();
|
290
|
+
_queue = new WeakMap();
|
291
|
+
_concurrency = new WeakMap();
|
292
|
+
_enqueue = new WeakSet();
|
293
|
+
enqueue_fn = function(task) {
|
294
|
+
const promise = new Promise((resolve) => __privateGet$8(this, _queue).push(resolve)).finally(() => {
|
295
|
+
this.started--;
|
296
|
+
this.running++;
|
297
|
+
}).then(() => task()).finally(() => {
|
298
|
+
this.running--;
|
299
|
+
const next = __privateGet$8(this, _queue).shift();
|
300
|
+
if (next !== void 0) {
|
301
|
+
this.started++;
|
302
|
+
next();
|
303
|
+
}
|
304
|
+
});
|
305
|
+
if (this.running + this.started < __privateGet$8(this, _concurrency)) {
|
306
|
+
const next = __privateGet$8(this, _queue).shift();
|
307
|
+
if (next !== void 0) {
|
308
|
+
this.started++;
|
309
|
+
next();
|
310
|
+
}
|
311
|
+
}
|
312
|
+
return promise;
|
313
|
+
};
|
314
|
+
|
315
|
+
function generateUUID() {
|
316
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
317
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
318
|
+
return v.toString(16);
|
319
|
+
});
|
320
|
+
}
|
321
|
+
|
322
|
+
async function getBytes(stream, onChunk) {
|
323
|
+
const reader = stream.getReader();
|
324
|
+
let result;
|
325
|
+
while (!(result = await reader.read()).done) {
|
326
|
+
onChunk(result.value);
|
327
|
+
}
|
328
|
+
}
|
329
|
+
function getLines(onLine) {
|
330
|
+
let buffer;
|
331
|
+
let position;
|
332
|
+
let fieldLength;
|
333
|
+
let discardTrailingNewline = false;
|
334
|
+
return function onChunk(arr) {
|
335
|
+
if (buffer === void 0) {
|
336
|
+
buffer = arr;
|
337
|
+
position = 0;
|
338
|
+
fieldLength = -1;
|
339
|
+
} else {
|
340
|
+
buffer = concat(buffer, arr);
|
341
|
+
}
|
342
|
+
const bufLength = buffer.length;
|
343
|
+
let lineStart = 0;
|
344
|
+
while (position < bufLength) {
|
345
|
+
if (discardTrailingNewline) {
|
346
|
+
if (buffer[position] === 10 /* NewLine */) {
|
347
|
+
lineStart = ++position;
|
348
|
+
}
|
349
|
+
discardTrailingNewline = false;
|
350
|
+
}
|
351
|
+
let lineEnd = -1;
|
352
|
+
for (; position < bufLength && lineEnd === -1; ++position) {
|
353
|
+
switch (buffer[position]) {
|
354
|
+
case 58 /* Colon */:
|
355
|
+
if (fieldLength === -1) {
|
356
|
+
fieldLength = position - lineStart;
|
357
|
+
}
|
358
|
+
break;
|
359
|
+
case 13 /* CarriageReturn */:
|
360
|
+
discardTrailingNewline = true;
|
361
|
+
case 10 /* NewLine */:
|
362
|
+
lineEnd = position;
|
363
|
+
break;
|
364
|
+
}
|
365
|
+
}
|
366
|
+
if (lineEnd === -1) {
|
367
|
+
break;
|
368
|
+
}
|
369
|
+
onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
|
370
|
+
lineStart = position;
|
371
|
+
fieldLength = -1;
|
372
|
+
}
|
373
|
+
if (lineStart === bufLength) {
|
374
|
+
buffer = void 0;
|
375
|
+
} else if (lineStart !== 0) {
|
376
|
+
buffer = buffer.subarray(lineStart);
|
377
|
+
position -= lineStart;
|
378
|
+
}
|
379
|
+
};
|
380
|
+
}
|
381
|
+
function getMessages(onId, onRetry, onMessage) {
|
382
|
+
let message = newMessage();
|
383
|
+
const decoder = new TextDecoder();
|
384
|
+
return function onLine(line, fieldLength) {
|
385
|
+
if (line.length === 0) {
|
386
|
+
onMessage?.(message);
|
387
|
+
message = newMessage();
|
388
|
+
} else if (fieldLength > 0) {
|
389
|
+
const field = decoder.decode(line.subarray(0, fieldLength));
|
390
|
+
const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
|
391
|
+
const value = decoder.decode(line.subarray(valueOffset));
|
392
|
+
switch (field) {
|
393
|
+
case "data":
|
394
|
+
message.data = message.data ? message.data + "\n" + value : value;
|
395
|
+
break;
|
396
|
+
case "event":
|
397
|
+
message.event = value;
|
398
|
+
break;
|
399
|
+
case "id":
|
400
|
+
onId(message.id = value);
|
401
|
+
break;
|
402
|
+
case "retry":
|
403
|
+
const retry = parseInt(value, 10);
|
404
|
+
if (!isNaN(retry)) {
|
405
|
+
onRetry(message.retry = retry);
|
406
|
+
}
|
407
|
+
break;
|
408
|
+
}
|
409
|
+
}
|
410
|
+
};
|
411
|
+
}
|
412
|
+
function concat(a, b) {
|
413
|
+
const res = new Uint8Array(a.length + b.length);
|
414
|
+
res.set(a);
|
415
|
+
res.set(b, a.length);
|
416
|
+
return res;
|
417
|
+
}
|
418
|
+
function newMessage() {
|
419
|
+
return {
|
420
|
+
data: "",
|
421
|
+
event: "",
|
422
|
+
id: "",
|
423
|
+
retry: void 0
|
424
|
+
};
|
425
|
+
}
|
426
|
+
const EventStreamContentType = "text/event-stream";
|
427
|
+
const LastEventId = "last-event-id";
|
428
|
+
function fetchEventSource(input, {
|
429
|
+
signal: inputSignal,
|
430
|
+
headers: inputHeaders,
|
431
|
+
onopen: inputOnOpen,
|
432
|
+
onmessage,
|
433
|
+
onclose,
|
434
|
+
onerror,
|
435
|
+
fetch: inputFetch,
|
436
|
+
...rest
|
437
|
+
}) {
|
438
|
+
return new Promise((resolve, reject) => {
|
439
|
+
const headers = { ...inputHeaders };
|
440
|
+
if (!headers.accept) {
|
441
|
+
headers.accept = EventStreamContentType;
|
442
|
+
}
|
443
|
+
let curRequestController;
|
444
|
+
function dispose() {
|
445
|
+
curRequestController.abort();
|
446
|
+
}
|
447
|
+
inputSignal?.addEventListener("abort", () => {
|
448
|
+
dispose();
|
449
|
+
resolve();
|
450
|
+
});
|
451
|
+
const fetchImpl = inputFetch ?? fetch;
|
452
|
+
const onopen = inputOnOpen ?? defaultOnOpen;
|
453
|
+
async function create() {
|
454
|
+
curRequestController = new AbortController();
|
455
|
+
try {
|
456
|
+
const response = await fetchImpl(input, {
|
457
|
+
...rest,
|
458
|
+
headers,
|
459
|
+
signal: curRequestController.signal
|
460
|
+
});
|
461
|
+
await onopen(response);
|
462
|
+
await getBytes(
|
463
|
+
response.body,
|
464
|
+
getLines(
|
465
|
+
getMessages(
|
466
|
+
(id) => {
|
467
|
+
if (id) {
|
468
|
+
headers[LastEventId] = id;
|
469
|
+
} else {
|
470
|
+
delete headers[LastEventId];
|
471
|
+
}
|
472
|
+
},
|
473
|
+
(_retry) => {
|
474
|
+
},
|
475
|
+
onmessage
|
476
|
+
)
|
477
|
+
)
|
478
|
+
);
|
479
|
+
onclose?.();
|
480
|
+
dispose();
|
481
|
+
resolve();
|
482
|
+
} catch (err) {
|
483
|
+
}
|
484
|
+
}
|
485
|
+
create();
|
486
|
+
});
|
487
|
+
}
|
488
|
+
function defaultOnOpen(response) {
|
489
|
+
const contentType = response.headers?.get("content-type");
|
490
|
+
if (!contentType?.startsWith(EventStreamContentType)) {
|
491
|
+
throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
|
492
|
+
}
|
493
|
+
}
|
174
494
|
|
175
|
-
const VERSION = "0.
|
495
|
+
const VERSION = "0.24.0";
|
176
496
|
|
177
497
|
class ErrorWithCause extends Error {
|
178
498
|
constructor(message, options) {
|
@@ -183,7 +503,7 @@ class FetcherError extends ErrorWithCause {
|
|
183
503
|
constructor(status, data, requestId) {
|
184
504
|
super(getMessage(data));
|
185
505
|
this.status = status;
|
186
|
-
this.errors = isBulkError(data) ? data.errors :
|
506
|
+
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
187
507
|
this.requestId = requestId;
|
188
508
|
if (data instanceof Error) {
|
189
509
|
this.stack = data.stack;
|
@@ -215,6 +535,7 @@ function getMessage(data) {
|
|
215
535
|
}
|
216
536
|
}
|
217
537
|
|
538
|
+
const pool = new ApiRequestPool();
|
218
539
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
219
540
|
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
220
541
|
if (value === void 0 || value === null)
|
@@ -224,63 +545,84 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
224
545
|
const query = new URLSearchParams(cleanQueryParams).toString();
|
225
546
|
const queryString = query.length > 0 ? `?${query}` : "";
|
226
547
|
const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
|
227
|
-
return { ...acc, [key]: encodeURIComponent(value).replace("%3A", ":") };
|
548
|
+
return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
|
228
549
|
}, {});
|
229
550
|
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
230
551
|
};
|
231
552
|
function buildBaseUrl({
|
553
|
+
endpoint,
|
232
554
|
path,
|
233
555
|
workspacesApiUrl,
|
234
556
|
apiUrl,
|
235
|
-
pathParams
|
557
|
+
pathParams = {}
|
236
558
|
}) {
|
237
|
-
if (
|
238
|
-
|
239
|
-
|
240
|
-
|
559
|
+
if (endpoint === "dataPlane") {
|
560
|
+
const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
561
|
+
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
562
|
+
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
563
|
+
}
|
564
|
+
return `${apiUrl}${path}`;
|
241
565
|
}
|
242
566
|
function hostHeader(url) {
|
243
567
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
244
568
|
const { groups } = pattern.exec(url) ?? {};
|
245
569
|
return groups?.host ? { Host: groups.host } : {};
|
246
570
|
}
|
571
|
+
const defaultClientID = generateUUID();
|
247
572
|
async function fetch$1({
|
248
573
|
url: path,
|
249
574
|
method,
|
250
575
|
body,
|
251
|
-
headers,
|
576
|
+
headers: customHeaders,
|
252
577
|
pathParams,
|
253
578
|
queryParams,
|
254
|
-
|
579
|
+
fetch: fetch2,
|
255
580
|
apiKey,
|
581
|
+
endpoint,
|
256
582
|
apiUrl,
|
257
583
|
workspacesApiUrl,
|
258
|
-
trace
|
584
|
+
trace,
|
585
|
+
signal,
|
586
|
+
clientID,
|
587
|
+
sessionID,
|
588
|
+
clientName,
|
589
|
+
xataAgentExtra,
|
590
|
+
fetchOptions = {}
|
259
591
|
}) {
|
260
|
-
|
592
|
+
pool.setFetch(fetch2);
|
593
|
+
return await trace(
|
261
594
|
`${method.toUpperCase()} ${path}`,
|
262
595
|
async ({ setAttributes }) => {
|
263
|
-
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
596
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
264
597
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
265
598
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
266
599
|
setAttributes({
|
267
600
|
[TraceAttributes.HTTP_URL]: url,
|
268
601
|
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
269
602
|
});
|
270
|
-
const
|
603
|
+
const xataAgent = compact([
|
604
|
+
["client", "TS_SDK"],
|
605
|
+
["version", VERSION],
|
606
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
607
|
+
...Object.entries(xataAgentExtra ?? {})
|
608
|
+
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
609
|
+
const headers = {
|
610
|
+
"Accept-Encoding": "identity",
|
611
|
+
"Content-Type": "application/json",
|
612
|
+
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
613
|
+
"X-Xata-Session-ID": sessionID ?? generateUUID(),
|
614
|
+
"X-Xata-Agent": xataAgent,
|
615
|
+
...customHeaders,
|
616
|
+
...hostHeader(fullUrl),
|
617
|
+
Authorization: `Bearer ${apiKey}`
|
618
|
+
};
|
619
|
+
const response = await pool.request(url, {
|
620
|
+
...fetchOptions,
|
271
621
|
method: method.toUpperCase(),
|
272
622
|
body: body ? JSON.stringify(body) : void 0,
|
273
|
-
headers
|
274
|
-
|
275
|
-
"User-Agent": `Xata client-ts/${VERSION}`,
|
276
|
-
...headers,
|
277
|
-
...hostHeader(fullUrl),
|
278
|
-
Authorization: `Bearer ${apiKey}`
|
279
|
-
}
|
623
|
+
headers,
|
624
|
+
signal
|
280
625
|
});
|
281
|
-
if (response.status === 204) {
|
282
|
-
return {};
|
283
|
-
}
|
284
626
|
const { host, protocol } = parseUrl(response.url);
|
285
627
|
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
286
628
|
setAttributes({
|
@@ -290,6 +632,12 @@ async function fetch$1({
|
|
290
632
|
[TraceAttributes.HTTP_HOST]: host,
|
291
633
|
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
292
634
|
});
|
635
|
+
if (response.status === 204) {
|
636
|
+
return {};
|
637
|
+
}
|
638
|
+
if (response.status === 429) {
|
639
|
+
throw new FetcherError(response.status, "Rate limit exceeded", requestId);
|
640
|
+
}
|
293
641
|
try {
|
294
642
|
const jsonResponse = await response.json();
|
295
643
|
if (response.ok) {
|
@@ -303,6 +651,59 @@ async function fetch$1({
|
|
303
651
|
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
304
652
|
);
|
305
653
|
}
|
654
|
+
function fetchSSERequest({
|
655
|
+
url: path,
|
656
|
+
method,
|
657
|
+
body,
|
658
|
+
headers: customHeaders,
|
659
|
+
pathParams,
|
660
|
+
queryParams,
|
661
|
+
fetch: fetch2,
|
662
|
+
apiKey,
|
663
|
+
endpoint,
|
664
|
+
apiUrl,
|
665
|
+
workspacesApiUrl,
|
666
|
+
onMessage,
|
667
|
+
onError,
|
668
|
+
onClose,
|
669
|
+
signal,
|
670
|
+
clientID,
|
671
|
+
sessionID,
|
672
|
+
clientName,
|
673
|
+
xataAgentExtra
|
674
|
+
}) {
|
675
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
676
|
+
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
677
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
678
|
+
void fetchEventSource(url, {
|
679
|
+
method,
|
680
|
+
body: JSON.stringify(body),
|
681
|
+
fetch: fetch2,
|
682
|
+
signal,
|
683
|
+
headers: {
|
684
|
+
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
685
|
+
"X-Xata-Session-ID": sessionID ?? generateUUID(),
|
686
|
+
"X-Xata-Agent": compact([
|
687
|
+
["client", "TS_SDK"],
|
688
|
+
["version", VERSION],
|
689
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
690
|
+
...Object.entries(xataAgentExtra ?? {})
|
691
|
+
]).map(([key, value]) => `${key}=${value}`).join("; "),
|
692
|
+
...customHeaders,
|
693
|
+
Authorization: `Bearer ${apiKey}`,
|
694
|
+
"Content-Type": "application/json"
|
695
|
+
},
|
696
|
+
onmessage(ev) {
|
697
|
+
onMessage?.(JSON.parse(ev.data));
|
698
|
+
},
|
699
|
+
onerror(ev) {
|
700
|
+
onError?.(JSON.parse(ev.data));
|
701
|
+
},
|
702
|
+
onclose() {
|
703
|
+
onClose?.();
|
704
|
+
}
|
705
|
+
});
|
706
|
+
}
|
306
707
|
function parseUrl(url) {
|
307
708
|
try {
|
308
709
|
const { host, protocol } = new URL(url);
|
@@ -312,257 +713,249 @@ function parseUrl(url) {
|
|
312
713
|
}
|
313
714
|
}
|
314
715
|
|
315
|
-
const
|
316
|
-
|
317
|
-
const
|
318
|
-
const getUserAPIKeys = (variables) => fetch$1({
|
319
|
-
url: "/user/keys",
|
320
|
-
method: "get",
|
321
|
-
...variables
|
322
|
-
});
|
323
|
-
const createUserAPIKey = (variables) => fetch$1({
|
324
|
-
url: "/user/keys/{keyName}",
|
325
|
-
method: "post",
|
326
|
-
...variables
|
327
|
-
});
|
328
|
-
const deleteUserAPIKey = (variables) => fetch$1({
|
329
|
-
url: "/user/keys/{keyName}",
|
330
|
-
method: "delete",
|
331
|
-
...variables
|
332
|
-
});
|
333
|
-
const createWorkspace = (variables) => fetch$1({
|
334
|
-
url: "/workspaces",
|
335
|
-
method: "post",
|
336
|
-
...variables
|
337
|
-
});
|
338
|
-
const getWorkspacesList = (variables) => fetch$1({
|
339
|
-
url: "/workspaces",
|
340
|
-
method: "get",
|
341
|
-
...variables
|
342
|
-
});
|
343
|
-
const getWorkspace = (variables) => fetch$1({
|
344
|
-
url: "/workspaces/{workspaceId}",
|
345
|
-
method: "get",
|
346
|
-
...variables
|
347
|
-
});
|
348
|
-
const updateWorkspace = (variables) => fetch$1({
|
349
|
-
url: "/workspaces/{workspaceId}",
|
350
|
-
method: "put",
|
351
|
-
...variables
|
352
|
-
});
|
353
|
-
const deleteWorkspace = (variables) => fetch$1({
|
354
|
-
url: "/workspaces/{workspaceId}",
|
355
|
-
method: "delete",
|
356
|
-
...variables
|
357
|
-
});
|
358
|
-
const getWorkspaceMembersList = (variables) => fetch$1({
|
359
|
-
url: "/workspaces/{workspaceId}/members",
|
360
|
-
method: "get",
|
361
|
-
...variables
|
362
|
-
});
|
363
|
-
const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
|
364
|
-
const removeWorkspaceMember = (variables) => fetch$1({
|
365
|
-
url: "/workspaces/{workspaceId}/members/{userId}",
|
366
|
-
method: "delete",
|
367
|
-
...variables
|
368
|
-
});
|
369
|
-
const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
|
370
|
-
const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
|
371
|
-
const cancelWorkspaceMemberInvite = (variables) => fetch$1({
|
372
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
373
|
-
method: "delete",
|
374
|
-
...variables
|
375
|
-
});
|
376
|
-
const resendWorkspaceMemberInvite = (variables) => fetch$1({
|
377
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
|
378
|
-
method: "post",
|
379
|
-
...variables
|
380
|
-
});
|
381
|
-
const acceptWorkspaceMemberInvite = (variables) => fetch$1({
|
382
|
-
url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
|
383
|
-
method: "post",
|
384
|
-
...variables
|
385
|
-
});
|
386
|
-
const getDatabaseList = (variables) => fetch$1({
|
387
|
-
url: "/dbs",
|
388
|
-
method: "get",
|
389
|
-
...variables
|
390
|
-
});
|
391
|
-
const getBranchList = (variables) => fetch$1({
|
392
|
-
url: "/dbs/{dbName}",
|
393
|
-
method: "get",
|
394
|
-
...variables
|
395
|
-
});
|
396
|
-
const createDatabase = (variables) => fetch$1({
|
397
|
-
url: "/dbs/{dbName}",
|
398
|
-
method: "put",
|
399
|
-
...variables
|
400
|
-
});
|
401
|
-
const deleteDatabase = (variables) => fetch$1({
|
716
|
+
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
717
|
+
|
718
|
+
const getBranchList = (variables, signal) => dataPlaneFetch({
|
402
719
|
url: "/dbs/{dbName}",
|
403
|
-
method: "delete",
|
404
|
-
...variables
|
405
|
-
});
|
406
|
-
const getDatabaseMetadata = (variables) => fetch$1({
|
407
|
-
url: "/dbs/{dbName}/metadata",
|
408
|
-
method: "get",
|
409
|
-
...variables
|
410
|
-
});
|
411
|
-
const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
|
412
|
-
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
413
|
-
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
414
|
-
const resolveBranch = (variables) => fetch$1({
|
415
|
-
url: "/dbs/{dbName}/resolveBranch",
|
416
720
|
method: "get",
|
417
|
-
...variables
|
721
|
+
...variables,
|
722
|
+
signal
|
418
723
|
});
|
419
|
-
const getBranchDetails = (variables) =>
|
724
|
+
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
420
725
|
url: "/db/{dbBranchName}",
|
421
726
|
method: "get",
|
422
|
-
...variables
|
727
|
+
...variables,
|
728
|
+
signal
|
423
729
|
});
|
424
|
-
const createBranch = (variables) =>
|
425
|
-
const deleteBranch = (variables) =>
|
730
|
+
const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
|
731
|
+
const deleteBranch = (variables, signal) => dataPlaneFetch({
|
426
732
|
url: "/db/{dbBranchName}",
|
427
733
|
method: "delete",
|
428
|
-
...variables
|
734
|
+
...variables,
|
735
|
+
signal
|
736
|
+
});
|
737
|
+
const copyBranch = (variables, signal) => dataPlaneFetch({
|
738
|
+
url: "/db/{dbBranchName}/copy",
|
739
|
+
method: "post",
|
740
|
+
...variables,
|
741
|
+
signal
|
429
742
|
});
|
430
|
-
const updateBranchMetadata = (variables) =>
|
743
|
+
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
431
744
|
url: "/db/{dbBranchName}/metadata",
|
432
745
|
method: "put",
|
433
|
-
...variables
|
746
|
+
...variables,
|
747
|
+
signal
|
434
748
|
});
|
435
|
-
const getBranchMetadata = (variables) =>
|
749
|
+
const getBranchMetadata = (variables, signal) => dataPlaneFetch({
|
436
750
|
url: "/db/{dbBranchName}/metadata",
|
437
751
|
method: "get",
|
438
|
-
...variables
|
752
|
+
...variables,
|
753
|
+
signal
|
439
754
|
});
|
440
|
-
const
|
441
|
-
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
442
|
-
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
443
|
-
const getBranchStats = (variables) => fetch$1({
|
755
|
+
const getBranchStats = (variables, signal) => dataPlaneFetch({
|
444
756
|
url: "/db/{dbBranchName}/stats",
|
445
757
|
method: "get",
|
446
|
-
...variables
|
758
|
+
...variables,
|
759
|
+
signal
|
760
|
+
});
|
761
|
+
const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
|
762
|
+
const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
|
763
|
+
const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
|
764
|
+
const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
|
765
|
+
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
766
|
+
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
767
|
+
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
768
|
+
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
769
|
+
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
770
|
+
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
771
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
772
|
+
method: "get",
|
773
|
+
...variables,
|
774
|
+
signal
|
775
|
+
});
|
776
|
+
const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
|
777
|
+
const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
|
778
|
+
const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
|
779
|
+
const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
|
780
|
+
const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
|
781
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
782
|
+
method: "post",
|
783
|
+
...variables,
|
784
|
+
signal
|
447
785
|
});
|
448
|
-
const
|
786
|
+
const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
|
787
|
+
const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
|
788
|
+
const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
|
789
|
+
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
790
|
+
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
791
|
+
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
792
|
+
const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
|
793
|
+
const createTable = (variables, signal) => dataPlaneFetch({
|
449
794
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
450
795
|
method: "put",
|
451
|
-
...variables
|
796
|
+
...variables,
|
797
|
+
signal
|
452
798
|
});
|
453
|
-
const deleteTable = (variables) =>
|
799
|
+
const deleteTable = (variables, signal) => dataPlaneFetch({
|
454
800
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
455
801
|
method: "delete",
|
456
|
-
...variables
|
457
|
-
|
458
|
-
const updateTable = (variables) => fetch$1({
|
459
|
-
url: "/db/{dbBranchName}/tables/{tableName}",
|
460
|
-
method: "patch",
|
461
|
-
...variables
|
802
|
+
...variables,
|
803
|
+
signal
|
462
804
|
});
|
463
|
-
const
|
805
|
+
const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
|
806
|
+
const getTableSchema = (variables, signal) => dataPlaneFetch({
|
464
807
|
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
465
808
|
method: "get",
|
466
|
-
...variables
|
467
|
-
|
468
|
-
const setTableSchema = (variables) => fetch$1({
|
469
|
-
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
470
|
-
method: "put",
|
471
|
-
...variables
|
809
|
+
...variables,
|
810
|
+
signal
|
472
811
|
});
|
473
|
-
const
|
812
|
+
const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
|
813
|
+
const getTableColumns = (variables, signal) => dataPlaneFetch({
|
474
814
|
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
475
815
|
method: "get",
|
476
|
-
...variables
|
477
|
-
|
478
|
-
const addTableColumn = (variables) => fetch$1({
|
479
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
480
|
-
method: "post",
|
481
|
-
...variables
|
816
|
+
...variables,
|
817
|
+
signal
|
482
818
|
});
|
483
|
-
const
|
819
|
+
const addTableColumn = (variables, signal) => dataPlaneFetch(
|
820
|
+
{ url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
|
821
|
+
);
|
822
|
+
const getColumn = (variables, signal) => dataPlaneFetch({
|
484
823
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
485
824
|
method: "get",
|
486
|
-
...variables
|
825
|
+
...variables,
|
826
|
+
signal
|
487
827
|
});
|
488
|
-
const
|
828
|
+
const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
|
829
|
+
const deleteColumn = (variables, signal) => dataPlaneFetch({
|
489
830
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
490
831
|
method: "delete",
|
491
|
-
...variables
|
832
|
+
...variables,
|
833
|
+
signal
|
492
834
|
});
|
493
|
-
const
|
494
|
-
|
495
|
-
|
496
|
-
|
835
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
836
|
+
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
837
|
+
const getFileItem = (variables, signal) => dataPlaneFetch({
|
838
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
839
|
+
method: "get",
|
840
|
+
...variables,
|
841
|
+
signal
|
497
842
|
});
|
498
|
-
const
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
843
|
+
const putFileItem = (variables, signal) => dataPlaneFetch({
|
844
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
845
|
+
method: "put",
|
846
|
+
...variables,
|
847
|
+
signal
|
848
|
+
});
|
849
|
+
const deleteFileItem = (variables, signal) => dataPlaneFetch({
|
850
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
851
|
+
method: "delete",
|
852
|
+
...variables,
|
853
|
+
signal
|
854
|
+
});
|
855
|
+
const getFile = (variables, signal) => dataPlaneFetch({
|
856
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
857
|
+
method: "get",
|
858
|
+
...variables,
|
859
|
+
signal
|
860
|
+
});
|
861
|
+
const putFile = (variables, signal) => dataPlaneFetch({
|
862
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
863
|
+
method: "put",
|
864
|
+
...variables,
|
865
|
+
signal
|
866
|
+
});
|
867
|
+
const deleteFile = (variables, signal) => dataPlaneFetch({
|
868
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
504
869
|
method: "delete",
|
505
|
-
...variables
|
870
|
+
...variables,
|
871
|
+
signal
|
506
872
|
});
|
507
|
-
const getRecord = (variables) =>
|
873
|
+
const getRecord = (variables, signal) => dataPlaneFetch({
|
508
874
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
509
875
|
method: "get",
|
510
|
-
...variables
|
876
|
+
...variables,
|
877
|
+
signal
|
511
878
|
});
|
512
|
-
const
|
513
|
-
const
|
879
|
+
const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
|
880
|
+
const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
|
881
|
+
const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
|
882
|
+
const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
|
883
|
+
const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
|
884
|
+
const queryTable = (variables, signal) => dataPlaneFetch({
|
514
885
|
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
515
886
|
method: "post",
|
516
|
-
...variables
|
887
|
+
...variables,
|
888
|
+
signal
|
517
889
|
});
|
518
|
-
const
|
890
|
+
const searchBranch = (variables, signal) => dataPlaneFetch({
|
891
|
+
url: "/db/{dbBranchName}/search",
|
892
|
+
method: "post",
|
893
|
+
...variables,
|
894
|
+
signal
|
895
|
+
});
|
896
|
+
const searchTable = (variables, signal) => dataPlaneFetch({
|
519
897
|
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
520
898
|
method: "post",
|
521
|
-
...variables
|
899
|
+
...variables,
|
900
|
+
signal
|
522
901
|
});
|
523
|
-
const
|
524
|
-
url: "/db/{dbBranchName}/
|
902
|
+
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
903
|
+
url: "/db/{dbBranchName}/sql",
|
525
904
|
method: "post",
|
526
|
-
...variables
|
905
|
+
...variables,
|
906
|
+
signal
|
527
907
|
});
|
528
|
-
const
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
},
|
545
|
-
database: {
|
546
|
-
getDatabaseList,
|
547
|
-
createDatabase,
|
548
|
-
deleteDatabase,
|
549
|
-
getDatabaseMetadata,
|
550
|
-
getGitBranchesMapping,
|
551
|
-
addGitBranchesEntry,
|
552
|
-
removeGitBranchesEntry,
|
553
|
-
resolveBranch
|
554
|
-
},
|
908
|
+
const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
|
909
|
+
const askTable = (variables, signal) => dataPlaneFetch({
|
910
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
911
|
+
method: "post",
|
912
|
+
...variables,
|
913
|
+
signal
|
914
|
+
});
|
915
|
+
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
916
|
+
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
917
|
+
const fileAccess = (variables, signal) => dataPlaneFetch({
|
918
|
+
url: "/file/{fileId}",
|
919
|
+
method: "get",
|
920
|
+
...variables,
|
921
|
+
signal
|
922
|
+
});
|
923
|
+
const operationsByTag$2 = {
|
555
924
|
branch: {
|
556
925
|
getBranchList,
|
557
926
|
getBranchDetails,
|
558
927
|
createBranch,
|
559
928
|
deleteBranch,
|
929
|
+
copyBranch,
|
560
930
|
updateBranchMetadata,
|
561
931
|
getBranchMetadata,
|
932
|
+
getBranchStats,
|
933
|
+
getGitBranchesMapping,
|
934
|
+
addGitBranchesEntry,
|
935
|
+
removeGitBranchesEntry,
|
936
|
+
resolveBranch
|
937
|
+
},
|
938
|
+
migrations: {
|
562
939
|
getBranchMigrationHistory,
|
563
|
-
executeBranchMigrationPlan,
|
564
940
|
getBranchMigrationPlan,
|
565
|
-
|
941
|
+
executeBranchMigrationPlan,
|
942
|
+
getBranchSchemaHistory,
|
943
|
+
compareBranchWithUserSchema,
|
944
|
+
compareBranchSchemas,
|
945
|
+
updateBranchSchema,
|
946
|
+
previewBranchSchemaEdit,
|
947
|
+
applyBranchSchemaEdit,
|
948
|
+
pushBranchMigrations
|
949
|
+
},
|
950
|
+
migrationRequests: {
|
951
|
+
queryMigrationRequests,
|
952
|
+
createMigrationRequest,
|
953
|
+
getMigrationRequest,
|
954
|
+
updateMigrationRequest,
|
955
|
+
listMigrationRequestsCommits,
|
956
|
+
compareMigrationRequest,
|
957
|
+
getMigrationRequestIsMerged,
|
958
|
+
mergeMigrationRequest
|
566
959
|
},
|
567
960
|
table: {
|
568
961
|
createTable,
|
@@ -573,23 +966,174 @@ const operationsByTag = {
|
|
573
966
|
getTableColumns,
|
574
967
|
addTableColumn,
|
575
968
|
getColumn,
|
576
|
-
|
577
|
-
|
969
|
+
updateColumn,
|
970
|
+
deleteColumn
|
578
971
|
},
|
579
972
|
records: {
|
973
|
+
branchTransaction,
|
580
974
|
insertRecord,
|
975
|
+
getRecord,
|
581
976
|
insertRecordWithID,
|
582
977
|
updateRecordWithID,
|
583
978
|
upsertRecordWithID,
|
584
979
|
deleteRecord,
|
585
|
-
|
586
|
-
|
980
|
+
bulkInsertTableRecords
|
981
|
+
},
|
982
|
+
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
|
983
|
+
searchAndFilter: {
|
587
984
|
queryTable,
|
985
|
+
searchBranch,
|
588
986
|
searchTable,
|
589
|
-
|
987
|
+
sqlQuery,
|
988
|
+
vectorSearchTable,
|
989
|
+
askTable,
|
990
|
+
summarizeTable,
|
991
|
+
aggregateTable
|
590
992
|
}
|
591
993
|
};
|
592
994
|
|
995
|
+
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
996
|
+
|
997
|
+
const getUser = (variables, signal) => controlPlaneFetch({
|
998
|
+
url: "/user",
|
999
|
+
method: "get",
|
1000
|
+
...variables,
|
1001
|
+
signal
|
1002
|
+
});
|
1003
|
+
const updateUser = (variables, signal) => controlPlaneFetch({
|
1004
|
+
url: "/user",
|
1005
|
+
method: "put",
|
1006
|
+
...variables,
|
1007
|
+
signal
|
1008
|
+
});
|
1009
|
+
const deleteUser = (variables, signal) => controlPlaneFetch({
|
1010
|
+
url: "/user",
|
1011
|
+
method: "delete",
|
1012
|
+
...variables,
|
1013
|
+
signal
|
1014
|
+
});
|
1015
|
+
const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
|
1016
|
+
url: "/user/keys",
|
1017
|
+
method: "get",
|
1018
|
+
...variables,
|
1019
|
+
signal
|
1020
|
+
});
|
1021
|
+
const createUserAPIKey = (variables, signal) => controlPlaneFetch({
|
1022
|
+
url: "/user/keys/{keyName}",
|
1023
|
+
method: "post",
|
1024
|
+
...variables,
|
1025
|
+
signal
|
1026
|
+
});
|
1027
|
+
const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
1028
|
+
url: "/user/keys/{keyName}",
|
1029
|
+
method: "delete",
|
1030
|
+
...variables,
|
1031
|
+
signal
|
1032
|
+
});
|
1033
|
+
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
1034
|
+
url: "/workspaces",
|
1035
|
+
method: "get",
|
1036
|
+
...variables,
|
1037
|
+
signal
|
1038
|
+
});
|
1039
|
+
const createWorkspace = (variables, signal) => controlPlaneFetch({
|
1040
|
+
url: "/workspaces",
|
1041
|
+
method: "post",
|
1042
|
+
...variables,
|
1043
|
+
signal
|
1044
|
+
});
|
1045
|
+
const getWorkspace = (variables, signal) => controlPlaneFetch({
|
1046
|
+
url: "/workspaces/{workspaceId}",
|
1047
|
+
method: "get",
|
1048
|
+
...variables,
|
1049
|
+
signal
|
1050
|
+
});
|
1051
|
+
const updateWorkspace = (variables, signal) => controlPlaneFetch({
|
1052
|
+
url: "/workspaces/{workspaceId}",
|
1053
|
+
method: "put",
|
1054
|
+
...variables,
|
1055
|
+
signal
|
1056
|
+
});
|
1057
|
+
const deleteWorkspace = (variables, signal) => controlPlaneFetch({
|
1058
|
+
url: "/workspaces/{workspaceId}",
|
1059
|
+
method: "delete",
|
1060
|
+
...variables,
|
1061
|
+
signal
|
1062
|
+
});
|
1063
|
+
const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
|
1064
|
+
const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
|
1065
|
+
const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
1066
|
+
url: "/workspaces/{workspaceId}/members/{userId}",
|
1067
|
+
method: "delete",
|
1068
|
+
...variables,
|
1069
|
+
signal
|
1070
|
+
});
|
1071
|
+
const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
|
1072
|
+
const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
|
1073
|
+
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
1074
|
+
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
1075
|
+
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
1076
|
+
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
1077
|
+
url: "/workspaces/{workspaceId}/dbs",
|
1078
|
+
method: "get",
|
1079
|
+
...variables,
|
1080
|
+
signal
|
1081
|
+
});
|
1082
|
+
const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
|
1083
|
+
const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
1084
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
1085
|
+
method: "delete",
|
1086
|
+
...variables,
|
1087
|
+
signal
|
1088
|
+
});
|
1089
|
+
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
1090
|
+
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
1091
|
+
const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
|
1092
|
+
const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
|
1093
|
+
const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
|
1094
|
+
const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
|
1095
|
+
const listRegions = (variables, signal) => controlPlaneFetch({
|
1096
|
+
url: "/workspaces/{workspaceId}/regions",
|
1097
|
+
method: "get",
|
1098
|
+
...variables,
|
1099
|
+
signal
|
1100
|
+
});
|
1101
|
+
const operationsByTag$1 = {
|
1102
|
+
users: { getUser, updateUser, deleteUser },
|
1103
|
+
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
1104
|
+
workspaces: {
|
1105
|
+
getWorkspacesList,
|
1106
|
+
createWorkspace,
|
1107
|
+
getWorkspace,
|
1108
|
+
updateWorkspace,
|
1109
|
+
deleteWorkspace,
|
1110
|
+
getWorkspaceMembersList,
|
1111
|
+
updateWorkspaceMemberRole,
|
1112
|
+
removeWorkspaceMember
|
1113
|
+
},
|
1114
|
+
invites: {
|
1115
|
+
inviteWorkspaceMember,
|
1116
|
+
updateWorkspaceMemberInvite,
|
1117
|
+
cancelWorkspaceMemberInvite,
|
1118
|
+
acceptWorkspaceMemberInvite,
|
1119
|
+
resendWorkspaceMemberInvite
|
1120
|
+
},
|
1121
|
+
databases: {
|
1122
|
+
getDatabaseList,
|
1123
|
+
createDatabase,
|
1124
|
+
deleteDatabase,
|
1125
|
+
getDatabaseMetadata,
|
1126
|
+
updateDatabaseMetadata,
|
1127
|
+
renameDatabase,
|
1128
|
+
getDatabaseGithubSettings,
|
1129
|
+
updateDatabaseGithubSettings,
|
1130
|
+
deleteDatabaseGithubSettings,
|
1131
|
+
listRegions
|
1132
|
+
}
|
1133
|
+
};
|
1134
|
+
|
1135
|
+
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
1136
|
+
|
593
1137
|
function getHostUrl(provider, type) {
|
594
1138
|
if (isHostProviderAlias(provider)) {
|
595
1139
|
return providers[provider][type];
|
@@ -601,11 +1145,15 @@ function getHostUrl(provider, type) {
|
|
601
1145
|
const providers = {
|
602
1146
|
production: {
|
603
1147
|
main: "https://api.xata.io",
|
604
|
-
workspaces: "https://{workspaceId}.xata.sh"
|
1148
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
605
1149
|
},
|
606
1150
|
staging: {
|
607
|
-
main: "https://staging.
|
608
|
-
workspaces: "https://{workspaceId}.staging.
|
1151
|
+
main: "https://api.staging-xata.dev",
|
1152
|
+
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
1153
|
+
},
|
1154
|
+
dev: {
|
1155
|
+
main: "https://api.dev-xata.dev",
|
1156
|
+
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
609
1157
|
}
|
610
1158
|
};
|
611
1159
|
function isHostProviderAlias(alias) {
|
@@ -614,6 +1162,32 @@ function isHostProviderAlias(alias) {
|
|
614
1162
|
function isHostProviderBuilder(builder) {
|
615
1163
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
616
1164
|
}
|
1165
|
+
function parseProviderString(provider = "production") {
|
1166
|
+
if (isHostProviderAlias(provider)) {
|
1167
|
+
return provider;
|
1168
|
+
}
|
1169
|
+
const [main, workspaces] = provider.split(",");
|
1170
|
+
if (!main || !workspaces)
|
1171
|
+
return null;
|
1172
|
+
return { main, workspaces };
|
1173
|
+
}
|
1174
|
+
function buildProviderString(provider) {
|
1175
|
+
if (isHostProviderAlias(provider))
|
1176
|
+
return provider;
|
1177
|
+
return `${provider.main},${provider.workspaces}`;
|
1178
|
+
}
|
1179
|
+
function parseWorkspacesUrlParts(url) {
|
1180
|
+
if (!isString(url))
|
1181
|
+
return null;
|
1182
|
+
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
1183
|
+
const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
|
1184
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
|
1185
|
+
const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
|
1186
|
+
const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
|
1187
|
+
if (!match)
|
1188
|
+
return null;
|
1189
|
+
return { workspace: match[1], region: match[2] };
|
1190
|
+
}
|
617
1191
|
|
618
1192
|
var __accessCheck$7 = (obj, member, msg) => {
|
619
1193
|
if (!member.has(obj))
|
@@ -641,15 +1215,19 @@ class XataApiClient {
|
|
641
1215
|
const provider = options.host ?? "production";
|
642
1216
|
const apiKey = options.apiKey ?? getAPIKey();
|
643
1217
|
const trace = options.trace ?? defaultTrace;
|
1218
|
+
const clientID = generateUUID();
|
644
1219
|
if (!apiKey) {
|
645
1220
|
throw new Error("Could not resolve a valid apiKey");
|
646
1221
|
}
|
647
1222
|
__privateSet$7(this, _extraProps, {
|
648
1223
|
apiUrl: getHostUrl(provider, "main"),
|
649
1224
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
650
|
-
|
1225
|
+
fetch: getFetchImplementation(options.fetch),
|
651
1226
|
apiKey,
|
652
|
-
trace
|
1227
|
+
trace,
|
1228
|
+
clientName: options.clientName,
|
1229
|
+
xataAgentExtra: options.xataAgentExtra,
|
1230
|
+
clientID
|
653
1231
|
});
|
654
1232
|
}
|
655
1233
|
get user() {
|
@@ -657,21 +1235,41 @@ class XataApiClient {
|
|
657
1235
|
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
658
1236
|
return __privateGet$7(this, _namespaces).user;
|
659
1237
|
}
|
1238
|
+
get authentication() {
|
1239
|
+
if (!__privateGet$7(this, _namespaces).authentication)
|
1240
|
+
__privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
|
1241
|
+
return __privateGet$7(this, _namespaces).authentication;
|
1242
|
+
}
|
660
1243
|
get workspaces() {
|
661
1244
|
if (!__privateGet$7(this, _namespaces).workspaces)
|
662
1245
|
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
663
1246
|
return __privateGet$7(this, _namespaces).workspaces;
|
664
1247
|
}
|
665
|
-
get
|
666
|
-
if (!__privateGet$7(this, _namespaces).
|
667
|
-
__privateGet$7(this, _namespaces).
|
668
|
-
return __privateGet$7(this, _namespaces).
|
1248
|
+
get invites() {
|
1249
|
+
if (!__privateGet$7(this, _namespaces).invites)
|
1250
|
+
__privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
|
1251
|
+
return __privateGet$7(this, _namespaces).invites;
|
1252
|
+
}
|
1253
|
+
get database() {
|
1254
|
+
if (!__privateGet$7(this, _namespaces).database)
|
1255
|
+
__privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
|
1256
|
+
return __privateGet$7(this, _namespaces).database;
|
669
1257
|
}
|
670
1258
|
get branches() {
|
671
1259
|
if (!__privateGet$7(this, _namespaces).branches)
|
672
1260
|
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
673
1261
|
return __privateGet$7(this, _namespaces).branches;
|
674
1262
|
}
|
1263
|
+
get migrations() {
|
1264
|
+
if (!__privateGet$7(this, _namespaces).migrations)
|
1265
|
+
__privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
|
1266
|
+
return __privateGet$7(this, _namespaces).migrations;
|
1267
|
+
}
|
1268
|
+
get migrationRequests() {
|
1269
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
1270
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
1271
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
1272
|
+
}
|
675
1273
|
get tables() {
|
676
1274
|
if (!__privateGet$7(this, _namespaces).tables)
|
677
1275
|
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
@@ -682,6 +1280,16 @@ class XataApiClient {
|
|
682
1280
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
683
1281
|
return __privateGet$7(this, _namespaces).records;
|
684
1282
|
}
|
1283
|
+
get files() {
|
1284
|
+
if (!__privateGet$7(this, _namespaces).files)
|
1285
|
+
__privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
|
1286
|
+
return __privateGet$7(this, _namespaces).files;
|
1287
|
+
}
|
1288
|
+
get searchAndFilter() {
|
1289
|
+
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
1290
|
+
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
1291
|
+
return __privateGet$7(this, _namespaces).searchAndFilter;
|
1292
|
+
}
|
685
1293
|
}
|
686
1294
|
_extraProps = new WeakMap();
|
687
1295
|
_namespaces = new WeakMap();
|
@@ -692,24 +1300,29 @@ class UserApi {
|
|
692
1300
|
getUser() {
|
693
1301
|
return operationsByTag.users.getUser({ ...this.extraProps });
|
694
1302
|
}
|
695
|
-
updateUser(user) {
|
1303
|
+
updateUser({ user }) {
|
696
1304
|
return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
|
697
1305
|
}
|
698
1306
|
deleteUser() {
|
699
1307
|
return operationsByTag.users.deleteUser({ ...this.extraProps });
|
700
1308
|
}
|
1309
|
+
}
|
1310
|
+
class AuthenticationApi {
|
1311
|
+
constructor(extraProps) {
|
1312
|
+
this.extraProps = extraProps;
|
1313
|
+
}
|
701
1314
|
getUserAPIKeys() {
|
702
|
-
return operationsByTag.
|
1315
|
+
return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
|
703
1316
|
}
|
704
|
-
createUserAPIKey(
|
705
|
-
return operationsByTag.
|
706
|
-
pathParams: { keyName },
|
1317
|
+
createUserAPIKey({ name }) {
|
1318
|
+
return operationsByTag.authentication.createUserAPIKey({
|
1319
|
+
pathParams: { keyName: name },
|
707
1320
|
...this.extraProps
|
708
1321
|
});
|
709
1322
|
}
|
710
|
-
deleteUserAPIKey(
|
711
|
-
return operationsByTag.
|
712
|
-
pathParams: { keyName },
|
1323
|
+
deleteUserAPIKey({ name }) {
|
1324
|
+
return operationsByTag.authentication.deleteUserAPIKey({
|
1325
|
+
pathParams: { keyName: name },
|
713
1326
|
...this.extraProps
|
714
1327
|
});
|
715
1328
|
}
|
@@ -718,374 +1331,1178 @@ class WorkspaceApi {
|
|
718
1331
|
constructor(extraProps) {
|
719
1332
|
this.extraProps = extraProps;
|
720
1333
|
}
|
721
|
-
|
1334
|
+
getWorkspacesList() {
|
1335
|
+
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
1336
|
+
}
|
1337
|
+
createWorkspace({ data }) {
|
722
1338
|
return operationsByTag.workspaces.createWorkspace({
|
723
|
-
body:
|
1339
|
+
body: data,
|
724
1340
|
...this.extraProps
|
725
1341
|
});
|
726
1342
|
}
|
727
|
-
|
728
|
-
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
729
|
-
}
|
730
|
-
getWorkspace(workspaceId) {
|
1343
|
+
getWorkspace({ workspace }) {
|
731
1344
|
return operationsByTag.workspaces.getWorkspace({
|
732
|
-
pathParams: { workspaceId },
|
1345
|
+
pathParams: { workspaceId: workspace },
|
733
1346
|
...this.extraProps
|
734
1347
|
});
|
735
1348
|
}
|
736
|
-
updateWorkspace(
|
1349
|
+
updateWorkspace({
|
1350
|
+
workspace,
|
1351
|
+
update
|
1352
|
+
}) {
|
737
1353
|
return operationsByTag.workspaces.updateWorkspace({
|
738
|
-
pathParams: { workspaceId },
|
739
|
-
body:
|
1354
|
+
pathParams: { workspaceId: workspace },
|
1355
|
+
body: update,
|
740
1356
|
...this.extraProps
|
741
1357
|
});
|
742
1358
|
}
|
743
|
-
deleteWorkspace(
|
1359
|
+
deleteWorkspace({ workspace }) {
|
744
1360
|
return operationsByTag.workspaces.deleteWorkspace({
|
745
|
-
pathParams: { workspaceId },
|
1361
|
+
pathParams: { workspaceId: workspace },
|
746
1362
|
...this.extraProps
|
747
1363
|
});
|
748
1364
|
}
|
749
|
-
getWorkspaceMembersList(
|
1365
|
+
getWorkspaceMembersList({ workspace }) {
|
750
1366
|
return operationsByTag.workspaces.getWorkspaceMembersList({
|
751
|
-
pathParams: { workspaceId },
|
1367
|
+
pathParams: { workspaceId: workspace },
|
752
1368
|
...this.extraProps
|
753
1369
|
});
|
754
1370
|
}
|
755
|
-
updateWorkspaceMemberRole(
|
1371
|
+
updateWorkspaceMemberRole({
|
1372
|
+
workspace,
|
1373
|
+
user,
|
1374
|
+
role
|
1375
|
+
}) {
|
756
1376
|
return operationsByTag.workspaces.updateWorkspaceMemberRole({
|
757
|
-
pathParams: { workspaceId, userId },
|
1377
|
+
pathParams: { workspaceId: workspace, userId: user },
|
758
1378
|
body: { role },
|
759
1379
|
...this.extraProps
|
760
1380
|
});
|
761
1381
|
}
|
762
|
-
removeWorkspaceMember(
|
1382
|
+
removeWorkspaceMember({
|
1383
|
+
workspace,
|
1384
|
+
user
|
1385
|
+
}) {
|
763
1386
|
return operationsByTag.workspaces.removeWorkspaceMember({
|
764
|
-
pathParams: { workspaceId, userId },
|
1387
|
+
pathParams: { workspaceId: workspace, userId: user },
|
765
1388
|
...this.extraProps
|
766
1389
|
});
|
767
1390
|
}
|
768
|
-
|
769
|
-
|
770
|
-
|
1391
|
+
}
|
1392
|
+
class InvitesApi {
|
1393
|
+
constructor(extraProps) {
|
1394
|
+
this.extraProps = extraProps;
|
1395
|
+
}
|
1396
|
+
inviteWorkspaceMember({
|
1397
|
+
workspace,
|
1398
|
+
email,
|
1399
|
+
role
|
1400
|
+
}) {
|
1401
|
+
return operationsByTag.invites.inviteWorkspaceMember({
|
1402
|
+
pathParams: { workspaceId: workspace },
|
771
1403
|
body: { email, role },
|
772
1404
|
...this.extraProps
|
773
1405
|
});
|
774
1406
|
}
|
775
|
-
updateWorkspaceMemberInvite(
|
776
|
-
|
777
|
-
|
778
|
-
|
1407
|
+
updateWorkspaceMemberInvite({
|
1408
|
+
workspace,
|
1409
|
+
invite,
|
1410
|
+
role
|
1411
|
+
}) {
|
1412
|
+
return operationsByTag.invites.updateWorkspaceMemberInvite({
|
1413
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
1414
|
+
body: { role },
|
1415
|
+
...this.extraProps
|
1416
|
+
});
|
1417
|
+
}
|
1418
|
+
cancelWorkspaceMemberInvite({
|
1419
|
+
workspace,
|
1420
|
+
invite
|
1421
|
+
}) {
|
1422
|
+
return operationsByTag.invites.cancelWorkspaceMemberInvite({
|
1423
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
1424
|
+
...this.extraProps
|
1425
|
+
});
|
1426
|
+
}
|
1427
|
+
acceptWorkspaceMemberInvite({
|
1428
|
+
workspace,
|
1429
|
+
key
|
1430
|
+
}) {
|
1431
|
+
return operationsByTag.invites.acceptWorkspaceMemberInvite({
|
1432
|
+
pathParams: { workspaceId: workspace, inviteKey: key },
|
1433
|
+
...this.extraProps
|
1434
|
+
});
|
1435
|
+
}
|
1436
|
+
resendWorkspaceMemberInvite({
|
1437
|
+
workspace,
|
1438
|
+
invite
|
1439
|
+
}) {
|
1440
|
+
return operationsByTag.invites.resendWorkspaceMemberInvite({
|
1441
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
1442
|
+
...this.extraProps
|
1443
|
+
});
|
1444
|
+
}
|
1445
|
+
}
|
1446
|
+
class BranchApi {
|
1447
|
+
constructor(extraProps) {
|
1448
|
+
this.extraProps = extraProps;
|
1449
|
+
}
|
1450
|
+
getBranchList({
|
1451
|
+
workspace,
|
1452
|
+
region,
|
1453
|
+
database
|
1454
|
+
}) {
|
1455
|
+
return operationsByTag.branch.getBranchList({
|
1456
|
+
pathParams: { workspace, region, dbName: database },
|
1457
|
+
...this.extraProps
|
1458
|
+
});
|
1459
|
+
}
|
1460
|
+
getBranchDetails({
|
1461
|
+
workspace,
|
1462
|
+
region,
|
1463
|
+
database,
|
1464
|
+
branch
|
1465
|
+
}) {
|
1466
|
+
return operationsByTag.branch.getBranchDetails({
|
1467
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1468
|
+
...this.extraProps
|
1469
|
+
});
|
1470
|
+
}
|
1471
|
+
createBranch({
|
1472
|
+
workspace,
|
1473
|
+
region,
|
1474
|
+
database,
|
1475
|
+
branch,
|
1476
|
+
from,
|
1477
|
+
metadata
|
1478
|
+
}) {
|
1479
|
+
return operationsByTag.branch.createBranch({
|
1480
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1481
|
+
body: { from, metadata },
|
1482
|
+
...this.extraProps
|
1483
|
+
});
|
1484
|
+
}
|
1485
|
+
deleteBranch({
|
1486
|
+
workspace,
|
1487
|
+
region,
|
1488
|
+
database,
|
1489
|
+
branch
|
1490
|
+
}) {
|
1491
|
+
return operationsByTag.branch.deleteBranch({
|
1492
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1493
|
+
...this.extraProps
|
1494
|
+
});
|
1495
|
+
}
|
1496
|
+
copyBranch({
|
1497
|
+
workspace,
|
1498
|
+
region,
|
1499
|
+
database,
|
1500
|
+
branch,
|
1501
|
+
destinationBranch,
|
1502
|
+
limit
|
1503
|
+
}) {
|
1504
|
+
return operationsByTag.branch.copyBranch({
|
1505
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1506
|
+
body: { destinationBranch, limit },
|
1507
|
+
...this.extraProps
|
1508
|
+
});
|
1509
|
+
}
|
1510
|
+
updateBranchMetadata({
|
1511
|
+
workspace,
|
1512
|
+
region,
|
1513
|
+
database,
|
1514
|
+
branch,
|
1515
|
+
metadata
|
1516
|
+
}) {
|
1517
|
+
return operationsByTag.branch.updateBranchMetadata({
|
1518
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1519
|
+
body: metadata,
|
1520
|
+
...this.extraProps
|
1521
|
+
});
|
1522
|
+
}
|
1523
|
+
getBranchMetadata({
|
1524
|
+
workspace,
|
1525
|
+
region,
|
1526
|
+
database,
|
1527
|
+
branch
|
1528
|
+
}) {
|
1529
|
+
return operationsByTag.branch.getBranchMetadata({
|
1530
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1531
|
+
...this.extraProps
|
1532
|
+
});
|
1533
|
+
}
|
1534
|
+
getBranchStats({
|
1535
|
+
workspace,
|
1536
|
+
region,
|
1537
|
+
database,
|
1538
|
+
branch
|
1539
|
+
}) {
|
1540
|
+
return operationsByTag.branch.getBranchStats({
|
1541
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1542
|
+
...this.extraProps
|
1543
|
+
});
|
1544
|
+
}
|
1545
|
+
getGitBranchesMapping({
|
1546
|
+
workspace,
|
1547
|
+
region,
|
1548
|
+
database
|
1549
|
+
}) {
|
1550
|
+
return operationsByTag.branch.getGitBranchesMapping({
|
1551
|
+
pathParams: { workspace, region, dbName: database },
|
1552
|
+
...this.extraProps
|
1553
|
+
});
|
1554
|
+
}
|
1555
|
+
addGitBranchesEntry({
|
1556
|
+
workspace,
|
1557
|
+
region,
|
1558
|
+
database,
|
1559
|
+
gitBranch,
|
1560
|
+
xataBranch
|
1561
|
+
}) {
|
1562
|
+
return operationsByTag.branch.addGitBranchesEntry({
|
1563
|
+
pathParams: { workspace, region, dbName: database },
|
1564
|
+
body: { gitBranch, xataBranch },
|
1565
|
+
...this.extraProps
|
1566
|
+
});
|
1567
|
+
}
|
1568
|
+
removeGitBranchesEntry({
|
1569
|
+
workspace,
|
1570
|
+
region,
|
1571
|
+
database,
|
1572
|
+
gitBranch
|
1573
|
+
}) {
|
1574
|
+
return operationsByTag.branch.removeGitBranchesEntry({
|
1575
|
+
pathParams: { workspace, region, dbName: database },
|
1576
|
+
queryParams: { gitBranch },
|
1577
|
+
...this.extraProps
|
1578
|
+
});
|
1579
|
+
}
|
1580
|
+
resolveBranch({
|
1581
|
+
workspace,
|
1582
|
+
region,
|
1583
|
+
database,
|
1584
|
+
gitBranch,
|
1585
|
+
fallbackBranch
|
1586
|
+
}) {
|
1587
|
+
return operationsByTag.branch.resolveBranch({
|
1588
|
+
pathParams: { workspace, region, dbName: database },
|
1589
|
+
queryParams: { gitBranch, fallbackBranch },
|
1590
|
+
...this.extraProps
|
1591
|
+
});
|
1592
|
+
}
|
1593
|
+
}
|
1594
|
+
class TableApi {
|
1595
|
+
constructor(extraProps) {
|
1596
|
+
this.extraProps = extraProps;
|
1597
|
+
}
|
1598
|
+
createTable({
|
1599
|
+
workspace,
|
1600
|
+
region,
|
1601
|
+
database,
|
1602
|
+
branch,
|
1603
|
+
table
|
1604
|
+
}) {
|
1605
|
+
return operationsByTag.table.createTable({
|
1606
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1607
|
+
...this.extraProps
|
1608
|
+
});
|
1609
|
+
}
|
1610
|
+
deleteTable({
|
1611
|
+
workspace,
|
1612
|
+
region,
|
1613
|
+
database,
|
1614
|
+
branch,
|
1615
|
+
table
|
1616
|
+
}) {
|
1617
|
+
return operationsByTag.table.deleteTable({
|
1618
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1619
|
+
...this.extraProps
|
1620
|
+
});
|
1621
|
+
}
|
1622
|
+
updateTable({
|
1623
|
+
workspace,
|
1624
|
+
region,
|
1625
|
+
database,
|
1626
|
+
branch,
|
1627
|
+
table,
|
1628
|
+
update
|
1629
|
+
}) {
|
1630
|
+
return operationsByTag.table.updateTable({
|
1631
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1632
|
+
body: update,
|
1633
|
+
...this.extraProps
|
1634
|
+
});
|
1635
|
+
}
|
1636
|
+
getTableSchema({
|
1637
|
+
workspace,
|
1638
|
+
region,
|
1639
|
+
database,
|
1640
|
+
branch,
|
1641
|
+
table
|
1642
|
+
}) {
|
1643
|
+
return operationsByTag.table.getTableSchema({
|
1644
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1645
|
+
...this.extraProps
|
1646
|
+
});
|
1647
|
+
}
|
1648
|
+
setTableSchema({
|
1649
|
+
workspace,
|
1650
|
+
region,
|
1651
|
+
database,
|
1652
|
+
branch,
|
1653
|
+
table,
|
1654
|
+
schema
|
1655
|
+
}) {
|
1656
|
+
return operationsByTag.table.setTableSchema({
|
1657
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1658
|
+
body: schema,
|
1659
|
+
...this.extraProps
|
1660
|
+
});
|
1661
|
+
}
|
1662
|
+
getTableColumns({
|
1663
|
+
workspace,
|
1664
|
+
region,
|
1665
|
+
database,
|
1666
|
+
branch,
|
1667
|
+
table
|
1668
|
+
}) {
|
1669
|
+
return operationsByTag.table.getTableColumns({
|
1670
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1671
|
+
...this.extraProps
|
1672
|
+
});
|
1673
|
+
}
|
1674
|
+
addTableColumn({
|
1675
|
+
workspace,
|
1676
|
+
region,
|
1677
|
+
database,
|
1678
|
+
branch,
|
1679
|
+
table,
|
1680
|
+
column
|
1681
|
+
}) {
|
1682
|
+
return operationsByTag.table.addTableColumn({
|
1683
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1684
|
+
body: column,
|
1685
|
+
...this.extraProps
|
1686
|
+
});
|
1687
|
+
}
|
1688
|
+
getColumn({
|
1689
|
+
workspace,
|
1690
|
+
region,
|
1691
|
+
database,
|
1692
|
+
branch,
|
1693
|
+
table,
|
1694
|
+
column
|
1695
|
+
}) {
|
1696
|
+
return operationsByTag.table.getColumn({
|
1697
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1698
|
+
...this.extraProps
|
1699
|
+
});
|
1700
|
+
}
|
1701
|
+
updateColumn({
|
1702
|
+
workspace,
|
1703
|
+
region,
|
1704
|
+
database,
|
1705
|
+
branch,
|
1706
|
+
table,
|
1707
|
+
column,
|
1708
|
+
update
|
1709
|
+
}) {
|
1710
|
+
return operationsByTag.table.updateColumn({
|
1711
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1712
|
+
body: update,
|
1713
|
+
...this.extraProps
|
1714
|
+
});
|
1715
|
+
}
|
1716
|
+
deleteColumn({
|
1717
|
+
workspace,
|
1718
|
+
region,
|
1719
|
+
database,
|
1720
|
+
branch,
|
1721
|
+
table,
|
1722
|
+
column
|
1723
|
+
}) {
|
1724
|
+
return operationsByTag.table.deleteColumn({
|
1725
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1726
|
+
...this.extraProps
|
1727
|
+
});
|
1728
|
+
}
|
1729
|
+
}
|
1730
|
+
class RecordsApi {
|
1731
|
+
constructor(extraProps) {
|
1732
|
+
this.extraProps = extraProps;
|
1733
|
+
}
|
1734
|
+
insertRecord({
|
1735
|
+
workspace,
|
1736
|
+
region,
|
1737
|
+
database,
|
1738
|
+
branch,
|
1739
|
+
table,
|
1740
|
+
record,
|
1741
|
+
columns
|
1742
|
+
}) {
|
1743
|
+
return operationsByTag.records.insertRecord({
|
1744
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1745
|
+
queryParams: { columns },
|
1746
|
+
body: record,
|
1747
|
+
...this.extraProps
|
1748
|
+
});
|
1749
|
+
}
|
1750
|
+
getRecord({
|
1751
|
+
workspace,
|
1752
|
+
region,
|
1753
|
+
database,
|
1754
|
+
branch,
|
1755
|
+
table,
|
1756
|
+
id,
|
1757
|
+
columns
|
1758
|
+
}) {
|
1759
|
+
return operationsByTag.records.getRecord({
|
1760
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1761
|
+
queryParams: { columns },
|
1762
|
+
...this.extraProps
|
1763
|
+
});
|
1764
|
+
}
|
1765
|
+
insertRecordWithID({
|
1766
|
+
workspace,
|
1767
|
+
region,
|
1768
|
+
database,
|
1769
|
+
branch,
|
1770
|
+
table,
|
1771
|
+
id,
|
1772
|
+
record,
|
1773
|
+
columns,
|
1774
|
+
createOnly,
|
1775
|
+
ifVersion
|
1776
|
+
}) {
|
1777
|
+
return operationsByTag.records.insertRecordWithID({
|
1778
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1779
|
+
queryParams: { columns, createOnly, ifVersion },
|
1780
|
+
body: record,
|
1781
|
+
...this.extraProps
|
1782
|
+
});
|
1783
|
+
}
|
1784
|
+
updateRecordWithID({
|
1785
|
+
workspace,
|
1786
|
+
region,
|
1787
|
+
database,
|
1788
|
+
branch,
|
1789
|
+
table,
|
1790
|
+
id,
|
1791
|
+
record,
|
1792
|
+
columns,
|
1793
|
+
ifVersion
|
1794
|
+
}) {
|
1795
|
+
return operationsByTag.records.updateRecordWithID({
|
1796
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1797
|
+
queryParams: { columns, ifVersion },
|
1798
|
+
body: record,
|
1799
|
+
...this.extraProps
|
1800
|
+
});
|
1801
|
+
}
|
1802
|
+
upsertRecordWithID({
|
1803
|
+
workspace,
|
1804
|
+
region,
|
1805
|
+
database,
|
1806
|
+
branch,
|
1807
|
+
table,
|
1808
|
+
id,
|
1809
|
+
record,
|
1810
|
+
columns,
|
1811
|
+
ifVersion
|
1812
|
+
}) {
|
1813
|
+
return operationsByTag.records.upsertRecordWithID({
|
1814
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1815
|
+
queryParams: { columns, ifVersion },
|
1816
|
+
body: record,
|
1817
|
+
...this.extraProps
|
1818
|
+
});
|
1819
|
+
}
|
1820
|
+
deleteRecord({
|
1821
|
+
workspace,
|
1822
|
+
region,
|
1823
|
+
database,
|
1824
|
+
branch,
|
1825
|
+
table,
|
1826
|
+
id,
|
1827
|
+
columns
|
1828
|
+
}) {
|
1829
|
+
return operationsByTag.records.deleteRecord({
|
1830
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1831
|
+
queryParams: { columns },
|
1832
|
+
...this.extraProps
|
1833
|
+
});
|
1834
|
+
}
|
1835
|
+
bulkInsertTableRecords({
|
1836
|
+
workspace,
|
1837
|
+
region,
|
1838
|
+
database,
|
1839
|
+
branch,
|
1840
|
+
table,
|
1841
|
+
records,
|
1842
|
+
columns
|
1843
|
+
}) {
|
1844
|
+
return operationsByTag.records.bulkInsertTableRecords({
|
1845
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1846
|
+
queryParams: { columns },
|
1847
|
+
body: { records },
|
1848
|
+
...this.extraProps
|
1849
|
+
});
|
1850
|
+
}
|
1851
|
+
branchTransaction({
|
1852
|
+
workspace,
|
1853
|
+
region,
|
1854
|
+
database,
|
1855
|
+
branch,
|
1856
|
+
operations
|
1857
|
+
}) {
|
1858
|
+
return operationsByTag.records.branchTransaction({
|
1859
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1860
|
+
body: { operations },
|
1861
|
+
...this.extraProps
|
1862
|
+
});
|
1863
|
+
}
|
1864
|
+
}
|
1865
|
+
class FilesApi {
|
1866
|
+
constructor(extraProps) {
|
1867
|
+
this.extraProps = extraProps;
|
1868
|
+
}
|
1869
|
+
getFileItem({
|
1870
|
+
workspace,
|
1871
|
+
region,
|
1872
|
+
database,
|
1873
|
+
branch,
|
1874
|
+
table,
|
1875
|
+
record,
|
1876
|
+
column,
|
1877
|
+
fileId
|
1878
|
+
}) {
|
1879
|
+
return operationsByTag.files.getFileItem({
|
1880
|
+
pathParams: {
|
1881
|
+
workspace,
|
1882
|
+
region,
|
1883
|
+
dbBranchName: `${database}:${branch}`,
|
1884
|
+
tableName: table,
|
1885
|
+
recordId: record,
|
1886
|
+
columnName: column,
|
1887
|
+
fileId
|
1888
|
+
},
|
1889
|
+
...this.extraProps
|
1890
|
+
});
|
1891
|
+
}
|
1892
|
+
putFileItem({
|
1893
|
+
workspace,
|
1894
|
+
region,
|
1895
|
+
database,
|
1896
|
+
branch,
|
1897
|
+
table,
|
1898
|
+
record,
|
1899
|
+
column,
|
1900
|
+
fileId,
|
1901
|
+
file
|
1902
|
+
}) {
|
1903
|
+
return operationsByTag.files.putFileItem({
|
1904
|
+
pathParams: {
|
1905
|
+
workspace,
|
1906
|
+
region,
|
1907
|
+
dbBranchName: `${database}:${branch}`,
|
1908
|
+
tableName: table,
|
1909
|
+
recordId: record,
|
1910
|
+
columnName: column,
|
1911
|
+
fileId
|
1912
|
+
},
|
1913
|
+
// @ts-ignore
|
1914
|
+
body: file,
|
1915
|
+
...this.extraProps
|
1916
|
+
});
|
1917
|
+
}
|
1918
|
+
deleteFileItem({
|
1919
|
+
workspace,
|
1920
|
+
region,
|
1921
|
+
database,
|
1922
|
+
branch,
|
1923
|
+
table,
|
1924
|
+
record,
|
1925
|
+
column,
|
1926
|
+
fileId
|
1927
|
+
}) {
|
1928
|
+
return operationsByTag.files.deleteFileItem({
|
1929
|
+
pathParams: {
|
1930
|
+
workspace,
|
1931
|
+
region,
|
1932
|
+
dbBranchName: `${database}:${branch}`,
|
1933
|
+
tableName: table,
|
1934
|
+
recordId: record,
|
1935
|
+
columnName: column,
|
1936
|
+
fileId
|
1937
|
+
},
|
1938
|
+
...this.extraProps
|
1939
|
+
});
|
1940
|
+
}
|
1941
|
+
getFile({
|
1942
|
+
workspace,
|
1943
|
+
region,
|
1944
|
+
database,
|
1945
|
+
branch,
|
1946
|
+
table,
|
1947
|
+
record,
|
1948
|
+
column
|
1949
|
+
}) {
|
1950
|
+
return operationsByTag.files.getFile({
|
1951
|
+
pathParams: {
|
1952
|
+
workspace,
|
1953
|
+
region,
|
1954
|
+
dbBranchName: `${database}:${branch}`,
|
1955
|
+
tableName: table,
|
1956
|
+
recordId: record,
|
1957
|
+
columnName: column
|
1958
|
+
},
|
779
1959
|
...this.extraProps
|
780
1960
|
});
|
781
1961
|
}
|
782
|
-
|
783
|
-
|
784
|
-
|
1962
|
+
putFile({
|
1963
|
+
workspace,
|
1964
|
+
region,
|
1965
|
+
database,
|
1966
|
+
branch,
|
1967
|
+
table,
|
1968
|
+
record,
|
1969
|
+
column,
|
1970
|
+
file
|
1971
|
+
}) {
|
1972
|
+
return operationsByTag.files.putFile({
|
1973
|
+
pathParams: {
|
1974
|
+
workspace,
|
1975
|
+
region,
|
1976
|
+
dbBranchName: `${database}:${branch}`,
|
1977
|
+
tableName: table,
|
1978
|
+
recordId: record,
|
1979
|
+
columnName: column
|
1980
|
+
},
|
1981
|
+
body: file,
|
785
1982
|
...this.extraProps
|
786
1983
|
});
|
787
1984
|
}
|
788
|
-
|
789
|
-
|
790
|
-
|
1985
|
+
deleteFile({
|
1986
|
+
workspace,
|
1987
|
+
region,
|
1988
|
+
database,
|
1989
|
+
branch,
|
1990
|
+
table,
|
1991
|
+
record,
|
1992
|
+
column
|
1993
|
+
}) {
|
1994
|
+
return operationsByTag.files.deleteFile({
|
1995
|
+
pathParams: {
|
1996
|
+
workspace,
|
1997
|
+
region,
|
1998
|
+
dbBranchName: `${database}:${branch}`,
|
1999
|
+
tableName: table,
|
2000
|
+
recordId: record,
|
2001
|
+
columnName: column
|
2002
|
+
},
|
791
2003
|
...this.extraProps
|
792
2004
|
});
|
793
2005
|
}
|
794
|
-
|
795
|
-
|
796
|
-
|
2006
|
+
fileAccess({
|
2007
|
+
workspace,
|
2008
|
+
region,
|
2009
|
+
fileId,
|
2010
|
+
verify
|
2011
|
+
}) {
|
2012
|
+
return operationsByTag.files.fileAccess({
|
2013
|
+
pathParams: {
|
2014
|
+
workspace,
|
2015
|
+
region,
|
2016
|
+
fileId
|
2017
|
+
},
|
2018
|
+
queryParams: { verify },
|
797
2019
|
...this.extraProps
|
798
2020
|
});
|
799
2021
|
}
|
800
2022
|
}
|
801
|
-
class
|
2023
|
+
class SearchAndFilterApi {
|
802
2024
|
constructor(extraProps) {
|
803
2025
|
this.extraProps = extraProps;
|
804
2026
|
}
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
2027
|
+
queryTable({
|
2028
|
+
workspace,
|
2029
|
+
region,
|
2030
|
+
database,
|
2031
|
+
branch,
|
2032
|
+
table,
|
2033
|
+
filter,
|
2034
|
+
sort,
|
2035
|
+
page,
|
2036
|
+
columns,
|
2037
|
+
consistency
|
2038
|
+
}) {
|
2039
|
+
return operationsByTag.searchAndFilter.queryTable({
|
2040
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2041
|
+
body: { filter, sort, page, columns, consistency },
|
815
2042
|
...this.extraProps
|
816
2043
|
});
|
817
2044
|
}
|
818
|
-
|
819
|
-
|
820
|
-
|
2045
|
+
searchTable({
|
2046
|
+
workspace,
|
2047
|
+
region,
|
2048
|
+
database,
|
2049
|
+
branch,
|
2050
|
+
table,
|
2051
|
+
query,
|
2052
|
+
fuzziness,
|
2053
|
+
target,
|
2054
|
+
prefix,
|
2055
|
+
filter,
|
2056
|
+
highlight,
|
2057
|
+
boosters
|
2058
|
+
}) {
|
2059
|
+
return operationsByTag.searchAndFilter.searchTable({
|
2060
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2061
|
+
body: { query, fuzziness, target, prefix, filter, highlight, boosters },
|
821
2062
|
...this.extraProps
|
822
2063
|
});
|
823
2064
|
}
|
824
|
-
|
825
|
-
|
826
|
-
|
2065
|
+
searchBranch({
|
2066
|
+
workspace,
|
2067
|
+
region,
|
2068
|
+
database,
|
2069
|
+
branch,
|
2070
|
+
tables,
|
2071
|
+
query,
|
2072
|
+
fuzziness,
|
2073
|
+
prefix,
|
2074
|
+
highlight
|
2075
|
+
}) {
|
2076
|
+
return operationsByTag.searchAndFilter.searchBranch({
|
2077
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2078
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
827
2079
|
...this.extraProps
|
828
2080
|
});
|
829
2081
|
}
|
830
|
-
|
831
|
-
|
832
|
-
|
2082
|
+
vectorSearchTable({
|
2083
|
+
workspace,
|
2084
|
+
region,
|
2085
|
+
database,
|
2086
|
+
branch,
|
2087
|
+
table,
|
2088
|
+
queryVector,
|
2089
|
+
column,
|
2090
|
+
similarityFunction,
|
2091
|
+
size,
|
2092
|
+
filter
|
2093
|
+
}) {
|
2094
|
+
return operationsByTag.searchAndFilter.vectorSearchTable({
|
2095
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2096
|
+
body: { queryVector, column, similarityFunction, size, filter },
|
833
2097
|
...this.extraProps
|
834
2098
|
});
|
835
2099
|
}
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
2100
|
+
askTable({
|
2101
|
+
workspace,
|
2102
|
+
region,
|
2103
|
+
database,
|
2104
|
+
branch,
|
2105
|
+
table,
|
2106
|
+
options
|
2107
|
+
}) {
|
2108
|
+
return operationsByTag.searchAndFilter.askTable({
|
2109
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2110
|
+
body: { ...options },
|
840
2111
|
...this.extraProps
|
841
2112
|
});
|
842
2113
|
}
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
2114
|
+
summarizeTable({
|
2115
|
+
workspace,
|
2116
|
+
region,
|
2117
|
+
database,
|
2118
|
+
branch,
|
2119
|
+
table,
|
2120
|
+
filter,
|
2121
|
+
columns,
|
2122
|
+
summaries,
|
2123
|
+
sort,
|
2124
|
+
summariesFilter,
|
2125
|
+
page,
|
2126
|
+
consistency
|
2127
|
+
}) {
|
2128
|
+
return operationsByTag.searchAndFilter.summarizeTable({
|
2129
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2130
|
+
body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
|
847
2131
|
...this.extraProps
|
848
2132
|
});
|
849
2133
|
}
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
2134
|
+
aggregateTable({
|
2135
|
+
workspace,
|
2136
|
+
region,
|
2137
|
+
database,
|
2138
|
+
branch,
|
2139
|
+
table,
|
2140
|
+
filter,
|
2141
|
+
aggs
|
2142
|
+
}) {
|
2143
|
+
return operationsByTag.searchAndFilter.aggregateTable({
|
2144
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
2145
|
+
body: { filter, aggs },
|
854
2146
|
...this.extraProps
|
855
2147
|
});
|
856
2148
|
}
|
857
2149
|
}
|
858
|
-
class
|
2150
|
+
class MigrationRequestsApi {
|
859
2151
|
constructor(extraProps) {
|
860
2152
|
this.extraProps = extraProps;
|
861
2153
|
}
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
createBranch(workspace, database, branch, from, options = {}) {
|
875
|
-
return operationsByTag.branch.createBranch({
|
876
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
877
|
-
queryParams: isString(from) ? { from } : void 0,
|
878
|
-
body: options,
|
2154
|
+
queryMigrationRequests({
|
2155
|
+
workspace,
|
2156
|
+
region,
|
2157
|
+
database,
|
2158
|
+
filter,
|
2159
|
+
sort,
|
2160
|
+
page,
|
2161
|
+
columns
|
2162
|
+
}) {
|
2163
|
+
return operationsByTag.migrationRequests.queryMigrationRequests({
|
2164
|
+
pathParams: { workspace, region, dbName: database },
|
2165
|
+
body: { filter, sort, page, columns },
|
879
2166
|
...this.extraProps
|
880
2167
|
});
|
881
2168
|
}
|
882
|
-
|
883
|
-
|
884
|
-
|
2169
|
+
createMigrationRequest({
|
2170
|
+
workspace,
|
2171
|
+
region,
|
2172
|
+
database,
|
2173
|
+
migration
|
2174
|
+
}) {
|
2175
|
+
return operationsByTag.migrationRequests.createMigrationRequest({
|
2176
|
+
pathParams: { workspace, region, dbName: database },
|
2177
|
+
body: migration,
|
885
2178
|
...this.extraProps
|
886
2179
|
});
|
887
2180
|
}
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
2181
|
+
getMigrationRequest({
|
2182
|
+
workspace,
|
2183
|
+
region,
|
2184
|
+
database,
|
2185
|
+
migrationRequest
|
2186
|
+
}) {
|
2187
|
+
return operationsByTag.migrationRequests.getMigrationRequest({
|
2188
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
892
2189
|
...this.extraProps
|
893
2190
|
});
|
894
2191
|
}
|
895
|
-
|
896
|
-
|
897
|
-
|
2192
|
+
updateMigrationRequest({
|
2193
|
+
workspace,
|
2194
|
+
region,
|
2195
|
+
database,
|
2196
|
+
migrationRequest,
|
2197
|
+
update
|
2198
|
+
}) {
|
2199
|
+
return operationsByTag.migrationRequests.updateMigrationRequest({
|
2200
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
2201
|
+
body: update,
|
898
2202
|
...this.extraProps
|
899
2203
|
});
|
900
2204
|
}
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
2205
|
+
listMigrationRequestsCommits({
|
2206
|
+
workspace,
|
2207
|
+
region,
|
2208
|
+
database,
|
2209
|
+
migrationRequest,
|
2210
|
+
page
|
2211
|
+
}) {
|
2212
|
+
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
2213
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
2214
|
+
body: { page },
|
905
2215
|
...this.extraProps
|
906
2216
|
});
|
907
2217
|
}
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
2218
|
+
compareMigrationRequest({
|
2219
|
+
workspace,
|
2220
|
+
region,
|
2221
|
+
database,
|
2222
|
+
migrationRequest
|
2223
|
+
}) {
|
2224
|
+
return operationsByTag.migrationRequests.compareMigrationRequest({
|
2225
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
912
2226
|
...this.extraProps
|
913
2227
|
});
|
914
2228
|
}
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
2229
|
+
getMigrationRequestIsMerged({
|
2230
|
+
workspace,
|
2231
|
+
region,
|
2232
|
+
database,
|
2233
|
+
migrationRequest
|
2234
|
+
}) {
|
2235
|
+
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
2236
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
919
2237
|
...this.extraProps
|
920
2238
|
});
|
921
2239
|
}
|
922
|
-
|
923
|
-
|
924
|
-
|
2240
|
+
mergeMigrationRequest({
|
2241
|
+
workspace,
|
2242
|
+
region,
|
2243
|
+
database,
|
2244
|
+
migrationRequest
|
2245
|
+
}) {
|
2246
|
+
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
2247
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
925
2248
|
...this.extraProps
|
926
2249
|
});
|
927
2250
|
}
|
928
2251
|
}
|
929
|
-
class
|
2252
|
+
class MigrationsApi {
|
930
2253
|
constructor(extraProps) {
|
931
2254
|
this.extraProps = extraProps;
|
932
2255
|
}
|
933
|
-
|
934
|
-
|
935
|
-
|
2256
|
+
getBranchMigrationHistory({
|
2257
|
+
workspace,
|
2258
|
+
region,
|
2259
|
+
database,
|
2260
|
+
branch,
|
2261
|
+
limit,
|
2262
|
+
startFrom
|
2263
|
+
}) {
|
2264
|
+
return operationsByTag.migrations.getBranchMigrationHistory({
|
2265
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2266
|
+
body: { limit, startFrom },
|
936
2267
|
...this.extraProps
|
937
2268
|
});
|
938
2269
|
}
|
939
|
-
|
940
|
-
|
941
|
-
|
2270
|
+
getBranchMigrationPlan({
|
2271
|
+
workspace,
|
2272
|
+
region,
|
2273
|
+
database,
|
2274
|
+
branch,
|
2275
|
+
schema
|
2276
|
+
}) {
|
2277
|
+
return operationsByTag.migrations.getBranchMigrationPlan({
|
2278
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2279
|
+
body: schema,
|
942
2280
|
...this.extraProps
|
943
2281
|
});
|
944
2282
|
}
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
2283
|
+
executeBranchMigrationPlan({
|
2284
|
+
workspace,
|
2285
|
+
region,
|
2286
|
+
database,
|
2287
|
+
branch,
|
2288
|
+
plan
|
2289
|
+
}) {
|
2290
|
+
return operationsByTag.migrations.executeBranchMigrationPlan({
|
2291
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2292
|
+
body: plan,
|
949
2293
|
...this.extraProps
|
950
2294
|
});
|
951
2295
|
}
|
952
|
-
|
953
|
-
|
954
|
-
|
2296
|
+
getBranchSchemaHistory({
|
2297
|
+
workspace,
|
2298
|
+
region,
|
2299
|
+
database,
|
2300
|
+
branch,
|
2301
|
+
page
|
2302
|
+
}) {
|
2303
|
+
return operationsByTag.migrations.getBranchSchemaHistory({
|
2304
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2305
|
+
body: { page },
|
955
2306
|
...this.extraProps
|
956
2307
|
});
|
957
2308
|
}
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
2309
|
+
compareBranchWithUserSchema({
|
2310
|
+
workspace,
|
2311
|
+
region,
|
2312
|
+
database,
|
2313
|
+
branch,
|
2314
|
+
schema,
|
2315
|
+
schemaOperations,
|
2316
|
+
branchOperations
|
2317
|
+
}) {
|
2318
|
+
return operationsByTag.migrations.compareBranchWithUserSchema({
|
2319
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2320
|
+
body: { schema, schemaOperations, branchOperations },
|
962
2321
|
...this.extraProps
|
963
2322
|
});
|
964
2323
|
}
|
965
|
-
|
966
|
-
|
967
|
-
|
2324
|
+
compareBranchSchemas({
|
2325
|
+
workspace,
|
2326
|
+
region,
|
2327
|
+
database,
|
2328
|
+
branch,
|
2329
|
+
compare,
|
2330
|
+
sourceBranchOperations,
|
2331
|
+
targetBranchOperations
|
2332
|
+
}) {
|
2333
|
+
return operationsByTag.migrations.compareBranchSchemas({
|
2334
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
2335
|
+
body: { sourceBranchOperations, targetBranchOperations },
|
968
2336
|
...this.extraProps
|
969
2337
|
});
|
970
2338
|
}
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
2339
|
+
updateBranchSchema({
|
2340
|
+
workspace,
|
2341
|
+
region,
|
2342
|
+
database,
|
2343
|
+
branch,
|
2344
|
+
migration
|
2345
|
+
}) {
|
2346
|
+
return operationsByTag.migrations.updateBranchSchema({
|
2347
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2348
|
+
body: migration,
|
975
2349
|
...this.extraProps
|
976
2350
|
});
|
977
2351
|
}
|
978
|
-
|
979
|
-
|
980
|
-
|
2352
|
+
previewBranchSchemaEdit({
|
2353
|
+
workspace,
|
2354
|
+
region,
|
2355
|
+
database,
|
2356
|
+
branch,
|
2357
|
+
data
|
2358
|
+
}) {
|
2359
|
+
return operationsByTag.migrations.previewBranchSchemaEdit({
|
2360
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2361
|
+
body: data,
|
981
2362
|
...this.extraProps
|
982
2363
|
});
|
983
2364
|
}
|
984
|
-
|
985
|
-
|
986
|
-
|
2365
|
+
applyBranchSchemaEdit({
|
2366
|
+
workspace,
|
2367
|
+
region,
|
2368
|
+
database,
|
2369
|
+
branch,
|
2370
|
+
edits
|
2371
|
+
}) {
|
2372
|
+
return operationsByTag.migrations.applyBranchSchemaEdit({
|
2373
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2374
|
+
body: { edits },
|
987
2375
|
...this.extraProps
|
988
2376
|
});
|
989
2377
|
}
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
2378
|
+
pushBranchMigrations({
|
2379
|
+
workspace,
|
2380
|
+
region,
|
2381
|
+
database,
|
2382
|
+
branch,
|
2383
|
+
migrations
|
2384
|
+
}) {
|
2385
|
+
return operationsByTag.migrations.pushBranchMigrations({
|
2386
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2387
|
+
body: { migrations },
|
994
2388
|
...this.extraProps
|
995
2389
|
});
|
996
2390
|
}
|
997
2391
|
}
|
998
|
-
class
|
2392
|
+
class DatabaseApi {
|
999
2393
|
constructor(extraProps) {
|
1000
2394
|
this.extraProps = extraProps;
|
1001
2395
|
}
|
1002
|
-
|
1003
|
-
return operationsByTag.
|
1004
|
-
pathParams: {
|
1005
|
-
queryParams: options,
|
1006
|
-
body: record,
|
2396
|
+
getDatabaseList({ workspace }) {
|
2397
|
+
return operationsByTag.databases.getDatabaseList({
|
2398
|
+
pathParams: { workspaceId: workspace },
|
1007
2399
|
...this.extraProps
|
1008
2400
|
});
|
1009
2401
|
}
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
2402
|
+
createDatabase({
|
2403
|
+
workspace,
|
2404
|
+
database,
|
2405
|
+
data
|
2406
|
+
}) {
|
2407
|
+
return operationsByTag.databases.createDatabase({
|
2408
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2409
|
+
body: data,
|
1015
2410
|
...this.extraProps
|
1016
2411
|
});
|
1017
2412
|
}
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
2413
|
+
deleteDatabase({
|
2414
|
+
workspace,
|
2415
|
+
database
|
2416
|
+
}) {
|
2417
|
+
return operationsByTag.databases.deleteDatabase({
|
2418
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1023
2419
|
...this.extraProps
|
1024
2420
|
});
|
1025
2421
|
}
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
2422
|
+
getDatabaseMetadata({
|
2423
|
+
workspace,
|
2424
|
+
database
|
2425
|
+
}) {
|
2426
|
+
return operationsByTag.databases.getDatabaseMetadata({
|
2427
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1031
2428
|
...this.extraProps
|
1032
2429
|
});
|
1033
2430
|
}
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
2431
|
+
updateDatabaseMetadata({
|
2432
|
+
workspace,
|
2433
|
+
database,
|
2434
|
+
metadata
|
2435
|
+
}) {
|
2436
|
+
return operationsByTag.databases.updateDatabaseMetadata({
|
2437
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2438
|
+
body: metadata,
|
1038
2439
|
...this.extraProps
|
1039
2440
|
});
|
1040
2441
|
}
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
2442
|
+
renameDatabase({
|
2443
|
+
workspace,
|
2444
|
+
database,
|
2445
|
+
newName
|
2446
|
+
}) {
|
2447
|
+
return operationsByTag.databases.renameDatabase({
|
2448
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2449
|
+
body: { newName },
|
1045
2450
|
...this.extraProps
|
1046
2451
|
});
|
1047
2452
|
}
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
2453
|
+
getDatabaseGithubSettings({
|
2454
|
+
workspace,
|
2455
|
+
database
|
2456
|
+
}) {
|
2457
|
+
return operationsByTag.databases.getDatabaseGithubSettings({
|
2458
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1053
2459
|
...this.extraProps
|
1054
2460
|
});
|
1055
2461
|
}
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
2462
|
+
updateDatabaseGithubSettings({
|
2463
|
+
workspace,
|
2464
|
+
database,
|
2465
|
+
settings
|
2466
|
+
}) {
|
2467
|
+
return operationsByTag.databases.updateDatabaseGithubSettings({
|
2468
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2469
|
+
body: settings,
|
1060
2470
|
...this.extraProps
|
1061
2471
|
});
|
1062
2472
|
}
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
2473
|
+
deleteDatabaseGithubSettings({
|
2474
|
+
workspace,
|
2475
|
+
database
|
2476
|
+
}) {
|
2477
|
+
return operationsByTag.databases.deleteDatabaseGithubSettings({
|
2478
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1067
2479
|
...this.extraProps
|
1068
2480
|
});
|
1069
2481
|
}
|
1070
|
-
|
1071
|
-
return operationsByTag.
|
1072
|
-
pathParams: {
|
1073
|
-
body: query,
|
2482
|
+
listRegions({ workspace }) {
|
2483
|
+
return operationsByTag.databases.listRegions({
|
2484
|
+
pathParams: { workspaceId: workspace },
|
1074
2485
|
...this.extraProps
|
1075
2486
|
});
|
1076
2487
|
}
|
1077
2488
|
}
|
1078
2489
|
|
1079
2490
|
class XataApiPlugin {
|
1080
|
-
|
1081
|
-
|
1082
|
-
return new XataApiClient({ fetch: fetchImpl, apiKey });
|
2491
|
+
build(options) {
|
2492
|
+
return new XataApiClient(options);
|
1083
2493
|
}
|
1084
2494
|
}
|
1085
2495
|
|
1086
2496
|
class XataPlugin {
|
1087
2497
|
}
|
1088
2498
|
|
2499
|
+
function cleanFilter(filter) {
|
2500
|
+
if (!filter)
|
2501
|
+
return void 0;
|
2502
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
2503
|
+
return values.length > 0 ? filter : void 0;
|
2504
|
+
}
|
2505
|
+
|
1089
2506
|
var __accessCheck$6 = (obj, member, msg) => {
|
1090
2507
|
if (!member.has(obj))
|
1091
2508
|
throw TypeError("Cannot " + msg);
|
@@ -1112,18 +2529,46 @@ class Page {
|
|
1112
2529
|
this.meta = meta;
|
1113
2530
|
this.records = new RecordArray(this, records);
|
1114
2531
|
}
|
2532
|
+
/**
|
2533
|
+
* Retrieves the next page of results.
|
2534
|
+
* @param size Maximum number of results to be retrieved.
|
2535
|
+
* @param offset Number of results to skip when retrieving the results.
|
2536
|
+
* @returns The next page or results.
|
2537
|
+
*/
|
1115
2538
|
async nextPage(size, offset) {
|
1116
2539
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
1117
2540
|
}
|
2541
|
+
/**
|
2542
|
+
* Retrieves the previous page of results.
|
2543
|
+
* @param size Maximum number of results to be retrieved.
|
2544
|
+
* @param offset Number of results to skip when retrieving the results.
|
2545
|
+
* @returns The previous page or results.
|
2546
|
+
*/
|
1118
2547
|
async previousPage(size, offset) {
|
1119
2548
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
1120
2549
|
}
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
2550
|
+
/**
|
2551
|
+
* Retrieves the start page of results.
|
2552
|
+
* @param size Maximum number of results to be retrieved.
|
2553
|
+
* @param offset Number of results to skip when retrieving the results.
|
2554
|
+
* @returns The start page or results.
|
2555
|
+
*/
|
2556
|
+
async startPage(size, offset) {
|
2557
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
2558
|
+
}
|
2559
|
+
/**
|
2560
|
+
* Retrieves the end page of results.
|
2561
|
+
* @param size Maximum number of results to be retrieved.
|
2562
|
+
* @param offset Number of results to skip when retrieving the results.
|
2563
|
+
* @returns The end page or results.
|
2564
|
+
*/
|
2565
|
+
async endPage(size, offset) {
|
2566
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
2567
|
+
}
|
2568
|
+
/**
|
2569
|
+
* Shortcut method to check if there will be additional results if the next page of results is retrieved.
|
2570
|
+
* @returns Whether or not there will be additional results in the next page of results.
|
2571
|
+
*/
|
1127
2572
|
hasNextPage() {
|
1128
2573
|
return this.meta.page.more;
|
1129
2574
|
}
|
@@ -1134,7 +2579,7 @@ const PAGINATION_DEFAULT_SIZE = 20;
|
|
1134
2579
|
const PAGINATION_MAX_OFFSET = 800;
|
1135
2580
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
1136
2581
|
function isCursorPaginationOptions(options) {
|
1137
|
-
return isDefined(options) && (isDefined(options.
|
2582
|
+
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
1138
2583
|
}
|
1139
2584
|
const _RecordArray = class extends Array {
|
1140
2585
|
constructor(...args) {
|
@@ -1155,25 +2600,54 @@ const _RecordArray = class extends Array {
|
|
1155
2600
|
toArray() {
|
1156
2601
|
return new Array(...this);
|
1157
2602
|
}
|
2603
|
+
toSerializable() {
|
2604
|
+
return JSON.parse(this.toString());
|
2605
|
+
}
|
2606
|
+
toString() {
|
2607
|
+
return JSON.stringify(this.toArray());
|
2608
|
+
}
|
1158
2609
|
map(callbackfn, thisArg) {
|
1159
2610
|
return this.toArray().map(callbackfn, thisArg);
|
1160
2611
|
}
|
2612
|
+
/**
|
2613
|
+
* Retrieve next page of records
|
2614
|
+
*
|
2615
|
+
* @returns A new array of objects
|
2616
|
+
*/
|
1161
2617
|
async nextPage(size, offset) {
|
1162
2618
|
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
1163
2619
|
return new _RecordArray(newPage);
|
1164
2620
|
}
|
2621
|
+
/**
|
2622
|
+
* Retrieve previous page of records
|
2623
|
+
*
|
2624
|
+
* @returns A new array of objects
|
2625
|
+
*/
|
1165
2626
|
async previousPage(size, offset) {
|
1166
2627
|
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
1167
2628
|
return new _RecordArray(newPage);
|
1168
2629
|
}
|
1169
|
-
|
1170
|
-
|
2630
|
+
/**
|
2631
|
+
* Retrieve start page of records
|
2632
|
+
*
|
2633
|
+
* @returns A new array of objects
|
2634
|
+
*/
|
2635
|
+
async startPage(size, offset) {
|
2636
|
+
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
1171
2637
|
return new _RecordArray(newPage);
|
1172
2638
|
}
|
1173
|
-
|
1174
|
-
|
2639
|
+
/**
|
2640
|
+
* Retrieve end page of records
|
2641
|
+
*
|
2642
|
+
* @returns A new array of objects
|
2643
|
+
*/
|
2644
|
+
async endPage(size, offset) {
|
2645
|
+
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
1175
2646
|
return new _RecordArray(newPage);
|
1176
2647
|
}
|
2648
|
+
/**
|
2649
|
+
* @returns Boolean indicating if there is a next page
|
2650
|
+
*/
|
1177
2651
|
hasNextPage() {
|
1178
2652
|
return __privateGet$6(this, _page).meta.page.more;
|
1179
2653
|
}
|
@@ -1199,13 +2673,19 @@ var __privateSet$5 = (obj, member, value, setter) => {
|
|
1199
2673
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1200
2674
|
return value;
|
1201
2675
|
};
|
1202
|
-
var
|
2676
|
+
var __privateMethod$3 = (obj, member, method) => {
|
2677
|
+
__accessCheck$5(obj, member, "access private method");
|
2678
|
+
return method;
|
2679
|
+
};
|
2680
|
+
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
1203
2681
|
const _Query = class {
|
1204
2682
|
constructor(repository, table, data, rawParent) {
|
2683
|
+
__privateAdd$5(this, _cleanFilterConstraint);
|
1205
2684
|
__privateAdd$5(this, _table$1, void 0);
|
1206
2685
|
__privateAdd$5(this, _repository, void 0);
|
1207
2686
|
__privateAdd$5(this, _data, { filter: {} });
|
1208
|
-
|
2687
|
+
// Implements pagination
|
2688
|
+
this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
|
1209
2689
|
this.records = new RecordArray(this, []);
|
1210
2690
|
__privateSet$5(this, _table$1, table);
|
1211
2691
|
if (repository) {
|
@@ -1220,9 +2700,11 @@ const _Query = class {
|
|
1220
2700
|
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
1221
2701
|
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
1222
2702
|
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
1223
|
-
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns
|
2703
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
|
2704
|
+
__privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
|
1224
2705
|
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
1225
2706
|
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
2707
|
+
__privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
|
1226
2708
|
this.any = this.any.bind(this);
|
1227
2709
|
this.all = this.all.bind(this);
|
1228
2710
|
this.not = this.not.bind(this);
|
@@ -1240,45 +2722,65 @@ const _Query = class {
|
|
1240
2722
|
const key = JSON.stringify({ columns, filter, sort, pagination });
|
1241
2723
|
return toBase64(key);
|
1242
2724
|
}
|
2725
|
+
/**
|
2726
|
+
* Builds a new query object representing a logical OR between the given subqueries.
|
2727
|
+
* @param queries An array of subqueries.
|
2728
|
+
* @returns A new Query object.
|
2729
|
+
*/
|
1243
2730
|
any(...queries) {
|
1244
2731
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
1245
2732
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
1246
2733
|
}
|
2734
|
+
/**
|
2735
|
+
* Builds a new query object representing a logical AND between the given subqueries.
|
2736
|
+
* @param queries An array of subqueries.
|
2737
|
+
* @returns A new Query object.
|
2738
|
+
*/
|
1247
2739
|
all(...queries) {
|
1248
2740
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
1249
2741
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1250
2742
|
}
|
2743
|
+
/**
|
2744
|
+
* Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
|
2745
|
+
* @param queries An array of subqueries.
|
2746
|
+
* @returns A new Query object.
|
2747
|
+
*/
|
1251
2748
|
not(...queries) {
|
1252
2749
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
1253
2750
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
1254
2751
|
}
|
2752
|
+
/**
|
2753
|
+
* Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
|
2754
|
+
* @param queries An array of subqueries.
|
2755
|
+
* @returns A new Query object.
|
2756
|
+
*/
|
1255
2757
|
none(...queries) {
|
1256
2758
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
1257
2759
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
1258
2760
|
}
|
1259
2761
|
filter(a, b) {
|
1260
2762
|
if (arguments.length === 1) {
|
1261
|
-
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
2763
|
+
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
2764
|
+
[column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
|
2765
|
+
}));
|
1262
2766
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1263
2767
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1264
2768
|
} else {
|
1265
|
-
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.
|
2769
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
|
1266
2770
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1267
2771
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1268
2772
|
}
|
1269
2773
|
}
|
1270
|
-
defaultFilter(column, value) {
|
1271
|
-
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
1272
|
-
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
1273
|
-
return { $includes: value };
|
1274
|
-
}
|
1275
|
-
return value;
|
1276
|
-
}
|
1277
2774
|
sort(column, direction = "asc") {
|
1278
2775
|
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
1279
2776
|
const sort = [...originalSort, { column, direction }];
|
1280
2777
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
1281
2778
|
}
|
2779
|
+
/**
|
2780
|
+
* Builds a new query specifying the set of columns to be returned in the query response.
|
2781
|
+
* @param columns Array of column names to be returned by the query.
|
2782
|
+
* @returns A new Query object.
|
2783
|
+
*/
|
1282
2784
|
select(columns) {
|
1283
2785
|
return new _Query(
|
1284
2786
|
__privateGet$5(this, _repository),
|
@@ -1291,6 +2793,12 @@ const _Query = class {
|
|
1291
2793
|
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
1292
2794
|
return __privateGet$5(this, _repository).query(query);
|
1293
2795
|
}
|
2796
|
+
/**
|
2797
|
+
* Get results in an iterator
|
2798
|
+
*
|
2799
|
+
* @async
|
2800
|
+
* @returns Async interable of results
|
2801
|
+
*/
|
1294
2802
|
async *[Symbol.asyncIterator]() {
|
1295
2803
|
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
1296
2804
|
yield record;
|
@@ -1308,11 +2816,20 @@ const _Query = class {
|
|
1308
2816
|
}
|
1309
2817
|
}
|
1310
2818
|
async getMany(options = {}) {
|
1311
|
-
const
|
2819
|
+
const { pagination = {}, ...rest } = options;
|
2820
|
+
const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
|
2821
|
+
const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
|
2822
|
+
let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
|
2823
|
+
const results = [...page.records];
|
2824
|
+
while (page.hasNextPage() && results.length < size) {
|
2825
|
+
page = await page.nextPage();
|
2826
|
+
results.push(...page.records);
|
2827
|
+
}
|
1312
2828
|
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
1313
2829
|
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
1314
2830
|
}
|
1315
|
-
|
2831
|
+
const array = new RecordArray(page, results.slice(0, size));
|
2832
|
+
return array;
|
1316
2833
|
}
|
1317
2834
|
async getAll(options = {}) {
|
1318
2835
|
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
@@ -1326,21 +2843,65 @@ const _Query = class {
|
|
1326
2843
|
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1327
2844
|
return records[0] ?? null;
|
1328
2845
|
}
|
2846
|
+
async getFirstOrThrow(options = {}) {
|
2847
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
2848
|
+
if (records[0] === void 0)
|
2849
|
+
throw new Error("No results found.");
|
2850
|
+
return records[0];
|
2851
|
+
}
|
2852
|
+
async summarize(params = {}) {
|
2853
|
+
const { summaries, summariesFilter, ...options } = params;
|
2854
|
+
const query = new _Query(
|
2855
|
+
__privateGet$5(this, _repository),
|
2856
|
+
__privateGet$5(this, _table$1),
|
2857
|
+
options,
|
2858
|
+
__privateGet$5(this, _data)
|
2859
|
+
);
|
2860
|
+
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
2861
|
+
}
|
2862
|
+
/**
|
2863
|
+
* Builds a new query object adding a cache TTL in milliseconds.
|
2864
|
+
* @param ttl The cache TTL in milliseconds.
|
2865
|
+
* @returns A new Query object.
|
2866
|
+
*/
|
1329
2867
|
cache(ttl) {
|
1330
2868
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1331
2869
|
}
|
2870
|
+
/**
|
2871
|
+
* Retrieve next page of records
|
2872
|
+
*
|
2873
|
+
* @returns A new page object.
|
2874
|
+
*/
|
1332
2875
|
nextPage(size, offset) {
|
1333
|
-
return this.
|
2876
|
+
return this.startPage(size, offset);
|
1334
2877
|
}
|
2878
|
+
/**
|
2879
|
+
* Retrieve previous page of records
|
2880
|
+
*
|
2881
|
+
* @returns A new page object
|
2882
|
+
*/
|
1335
2883
|
previousPage(size, offset) {
|
1336
|
-
return this.
|
1337
|
-
}
|
1338
|
-
|
2884
|
+
return this.startPage(size, offset);
|
2885
|
+
}
|
2886
|
+
/**
|
2887
|
+
* Retrieve start page of records
|
2888
|
+
*
|
2889
|
+
* @returns A new page object
|
2890
|
+
*/
|
2891
|
+
startPage(size, offset) {
|
1339
2892
|
return this.getPaginated({ pagination: { size, offset } });
|
1340
2893
|
}
|
1341
|
-
|
2894
|
+
/**
|
2895
|
+
* Retrieve last page of records
|
2896
|
+
*
|
2897
|
+
* @returns A new page object
|
2898
|
+
*/
|
2899
|
+
endPage(size, offset) {
|
1342
2900
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
1343
2901
|
}
|
2902
|
+
/**
|
2903
|
+
* @returns Boolean indicating if there is a next page
|
2904
|
+
*/
|
1344
2905
|
hasNextPage() {
|
1345
2906
|
return this.meta.page.more;
|
1346
2907
|
}
|
@@ -1349,9 +2910,20 @@ let Query = _Query;
|
|
1349
2910
|
_table$1 = new WeakMap();
|
1350
2911
|
_repository = new WeakMap();
|
1351
2912
|
_data = new WeakMap();
|
2913
|
+
_cleanFilterConstraint = new WeakSet();
|
2914
|
+
cleanFilterConstraint_fn = function(column, value) {
|
2915
|
+
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
2916
|
+
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
2917
|
+
return { $includes: value };
|
2918
|
+
}
|
2919
|
+
if (columnType === "link" && isObject(value) && isString(value.id)) {
|
2920
|
+
return value.id;
|
2921
|
+
}
|
2922
|
+
return value;
|
2923
|
+
};
|
1352
2924
|
function cleanParent(data, parent) {
|
1353
2925
|
if (isCursorPaginationOptions(data.pagination)) {
|
1354
|
-
return { ...parent,
|
2926
|
+
return { ...parent, sort: void 0, filter: void 0 };
|
1355
2927
|
}
|
1356
2928
|
return parent;
|
1357
2929
|
}
|
@@ -1369,7 +2941,11 @@ function isSortFilterString(value) {
|
|
1369
2941
|
return isString(value);
|
1370
2942
|
}
|
1371
2943
|
function isSortFilterBase(filter) {
|
1372
|
-
return isObject(filter) && Object.
|
2944
|
+
return isObject(filter) && Object.entries(filter).every(([key, value]) => {
|
2945
|
+
if (key === "*")
|
2946
|
+
return value === "random";
|
2947
|
+
return value === "asc" || value === "desc";
|
2948
|
+
});
|
1373
2949
|
}
|
1374
2950
|
function isSortFilterObject(filter) {
|
1375
2951
|
return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
|
@@ -1410,7 +2986,8 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
1410
2986
|
__accessCheck$4(obj, member, "access private method");
|
1411
2987
|
return method;
|
1412
2988
|
};
|
1413
|
-
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn,
|
2989
|
+
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;
|
2990
|
+
const BULK_OPERATION_MAX_SIZE = 1e3;
|
1414
2991
|
class Repository extends Query {
|
1415
2992
|
}
|
1416
2993
|
class RestRepository extends Query {
|
@@ -1422,10 +2999,12 @@ class RestRepository extends Query {
|
|
1422
2999
|
);
|
1423
3000
|
__privateAdd$4(this, _insertRecordWithoutId);
|
1424
3001
|
__privateAdd$4(this, _insertRecordWithId);
|
1425
|
-
__privateAdd$4(this,
|
3002
|
+
__privateAdd$4(this, _insertRecords);
|
1426
3003
|
__privateAdd$4(this, _updateRecordWithID);
|
3004
|
+
__privateAdd$4(this, _updateRecords);
|
1427
3005
|
__privateAdd$4(this, _upsertRecordWithID);
|
1428
3006
|
__privateAdd$4(this, _deleteRecord);
|
3007
|
+
__privateAdd$4(this, _deleteRecords);
|
1429
3008
|
__privateAdd$4(this, _setCacheQuery);
|
1430
3009
|
__privateAdd$4(this, _getCacheQuery);
|
1431
3010
|
__privateAdd$4(this, _getSchemaTables$1);
|
@@ -1436,10 +3015,10 @@ class RestRepository extends Query {
|
|
1436
3015
|
__privateAdd$4(this, _schemaTables$2, void 0);
|
1437
3016
|
__privateAdd$4(this, _trace, void 0);
|
1438
3017
|
__privateSet$4(this, _table, options.table);
|
1439
|
-
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1440
3018
|
__privateSet$4(this, _db, options.db);
|
1441
3019
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
1442
3020
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
3021
|
+
__privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
|
1443
3022
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
1444
3023
|
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
1445
3024
|
return trace(name, fn, {
|
@@ -1450,25 +3029,28 @@ class RestRepository extends Query {
|
|
1450
3029
|
});
|
1451
3030
|
});
|
1452
3031
|
}
|
1453
|
-
async create(a, b, c) {
|
3032
|
+
async create(a, b, c, d) {
|
1454
3033
|
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
3034
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1455
3035
|
if (Array.isArray(a)) {
|
1456
3036
|
if (a.length === 0)
|
1457
3037
|
return [];
|
1458
|
-
const
|
1459
|
-
|
3038
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
3039
|
+
const columns = isStringArray(b) ? b : ["*"];
|
3040
|
+
const result = await this.read(ids, columns);
|
3041
|
+
return result;
|
1460
3042
|
}
|
1461
3043
|
if (isString(a) && isObject(b)) {
|
1462
3044
|
if (a === "")
|
1463
3045
|
throw new Error("The id can't be empty");
|
1464
3046
|
const columns = isStringArray(c) ? c : void 0;
|
1465
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
3047
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
1466
3048
|
}
|
1467
3049
|
if (isObject(a) && isString(a.id)) {
|
1468
3050
|
if (a.id === "")
|
1469
3051
|
throw new Error("The id can't be empty");
|
1470
3052
|
const columns = isStringArray(b) ? b : void 0;
|
1471
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
3053
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
1472
3054
|
}
|
1473
3055
|
if (isObject(a)) {
|
1474
3056
|
const columns = isStringArray(b) ? b : void 0;
|
@@ -1493,20 +3075,20 @@ class RestRepository extends Query {
|
|
1493
3075
|
}
|
1494
3076
|
const id = extractId(a);
|
1495
3077
|
if (id) {
|
1496
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1497
3078
|
try {
|
1498
3079
|
const response = await getRecord({
|
1499
3080
|
pathParams: {
|
1500
3081
|
workspace: "{workspaceId}",
|
1501
3082
|
dbBranchName: "{dbBranch}",
|
3083
|
+
region: "{region}",
|
1502
3084
|
tableName: __privateGet$4(this, _table),
|
1503
3085
|
recordId: id
|
1504
3086
|
},
|
1505
3087
|
queryParams: { columns },
|
1506
|
-
...
|
3088
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
1507
3089
|
});
|
1508
3090
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1509
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
3091
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1510
3092
|
} catch (e) {
|
1511
3093
|
if (isObject(e) && e.status === 404) {
|
1512
3094
|
return null;
|
@@ -1517,48 +3099,122 @@ class RestRepository extends Query {
|
|
1517
3099
|
return null;
|
1518
3100
|
});
|
1519
3101
|
}
|
1520
|
-
async
|
3102
|
+
async readOrThrow(a, b) {
|
3103
|
+
return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
|
3104
|
+
const result = await this.read(a, b);
|
3105
|
+
if (Array.isArray(result)) {
|
3106
|
+
const missingIds = compact(
|
3107
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
3108
|
+
);
|
3109
|
+
if (missingIds.length > 0) {
|
3110
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
3111
|
+
}
|
3112
|
+
return result;
|
3113
|
+
}
|
3114
|
+
if (result === null) {
|
3115
|
+
const id = extractId(a) ?? "unknown";
|
3116
|
+
throw new Error(`Record with id ${id} not found`);
|
3117
|
+
}
|
3118
|
+
return result;
|
3119
|
+
});
|
3120
|
+
}
|
3121
|
+
async update(a, b, c, d) {
|
1521
3122
|
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
3123
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1522
3124
|
if (Array.isArray(a)) {
|
1523
3125
|
if (a.length === 0)
|
1524
3126
|
return [];
|
1525
|
-
|
1526
|
-
|
3127
|
+
const existing = await this.read(a, ["id"]);
|
3128
|
+
const updates = a.filter((_item, index) => existing[index] !== null);
|
3129
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
|
3130
|
+
ifVersion,
|
3131
|
+
upsert: false
|
3132
|
+
});
|
3133
|
+
const columns = isStringArray(b) ? b : ["*"];
|
3134
|
+
const result = await this.read(a, columns);
|
3135
|
+
return result;
|
3136
|
+
}
|
3137
|
+
try {
|
3138
|
+
if (isString(a) && isObject(b)) {
|
3139
|
+
const columns = isStringArray(c) ? c : void 0;
|
3140
|
+
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
3141
|
+
}
|
3142
|
+
if (isObject(a) && isString(a.id)) {
|
3143
|
+
const columns = isStringArray(b) ? b : void 0;
|
3144
|
+
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3145
|
+
}
|
3146
|
+
} catch (error) {
|
3147
|
+
if (error.status === 422)
|
3148
|
+
return null;
|
3149
|
+
throw error;
|
3150
|
+
}
|
3151
|
+
throw new Error("Invalid arguments for update method");
|
3152
|
+
});
|
3153
|
+
}
|
3154
|
+
async updateOrThrow(a, b, c, d) {
|
3155
|
+
return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
|
3156
|
+
const result = await this.update(a, b, c, d);
|
3157
|
+
if (Array.isArray(result)) {
|
3158
|
+
const missingIds = compact(
|
3159
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
3160
|
+
);
|
3161
|
+
if (missingIds.length > 0) {
|
3162
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
1527
3163
|
}
|
3164
|
+
return result;
|
3165
|
+
}
|
3166
|
+
if (result === null) {
|
3167
|
+
const id = extractId(a) ?? "unknown";
|
3168
|
+
throw new Error(`Record with id ${id} not found`);
|
3169
|
+
}
|
3170
|
+
return result;
|
3171
|
+
});
|
3172
|
+
}
|
3173
|
+
async createOrUpdate(a, b, c, d) {
|
3174
|
+
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
3175
|
+
const ifVersion = parseIfVersion(b, c, d);
|
3176
|
+
if (Array.isArray(a)) {
|
3177
|
+
if (a.length === 0)
|
3178
|
+
return [];
|
3179
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
|
3180
|
+
ifVersion,
|
3181
|
+
upsert: true
|
3182
|
+
});
|
1528
3183
|
const columns = isStringArray(b) ? b : ["*"];
|
1529
|
-
|
3184
|
+
const result = await this.read(a, columns);
|
3185
|
+
return result;
|
1530
3186
|
}
|
1531
3187
|
if (isString(a) && isObject(b)) {
|
1532
3188
|
const columns = isStringArray(c) ? c : void 0;
|
1533
|
-
return __privateMethod$2(this,
|
3189
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
1534
3190
|
}
|
1535
3191
|
if (isObject(a) && isString(a.id)) {
|
1536
|
-
const columns = isStringArray(
|
1537
|
-
return __privateMethod$2(this,
|
3192
|
+
const columns = isStringArray(c) ? c : void 0;
|
3193
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
1538
3194
|
}
|
1539
|
-
throw new Error("Invalid arguments for
|
3195
|
+
throw new Error("Invalid arguments for createOrUpdate method");
|
1540
3196
|
});
|
1541
3197
|
}
|
1542
|
-
async
|
1543
|
-
return __privateGet$4(this, _trace).call(this, "
|
3198
|
+
async createOrReplace(a, b, c, d) {
|
3199
|
+
return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
|
3200
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1544
3201
|
if (Array.isArray(a)) {
|
1545
3202
|
if (a.length === 0)
|
1546
3203
|
return [];
|
1547
|
-
|
1548
|
-
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1549
|
-
}
|
3204
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
1550
3205
|
const columns = isStringArray(b) ? b : ["*"];
|
1551
|
-
|
3206
|
+
const result = await this.read(ids, columns);
|
3207
|
+
return result;
|
1552
3208
|
}
|
1553
3209
|
if (isString(a) && isObject(b)) {
|
1554
3210
|
const columns = isStringArray(c) ? c : void 0;
|
1555
|
-
return __privateMethod$2(this,
|
3211
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
1556
3212
|
}
|
1557
3213
|
if (isObject(a) && isString(a.id)) {
|
1558
3214
|
const columns = isStringArray(c) ? c : void 0;
|
1559
|
-
return __privateMethod$2(this,
|
3215
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
1560
3216
|
}
|
1561
|
-
throw new Error("Invalid arguments for
|
3217
|
+
throw new Error("Invalid arguments for createOrReplace method");
|
1562
3218
|
});
|
1563
3219
|
}
|
1564
3220
|
async delete(a, b) {
|
@@ -1566,10 +3222,17 @@ class RestRepository extends Query {
|
|
1566
3222
|
if (Array.isArray(a)) {
|
1567
3223
|
if (a.length === 0)
|
1568
3224
|
return [];
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
3225
|
+
const ids = a.map((o) => {
|
3226
|
+
if (isString(o))
|
3227
|
+
return o;
|
3228
|
+
if (isString(o.id))
|
3229
|
+
return o.id;
|
3230
|
+
throw new Error("Invalid arguments for delete method");
|
3231
|
+
});
|
3232
|
+
const columns = isStringArray(b) ? b : ["*"];
|
3233
|
+
const result = await this.read(a, columns);
|
3234
|
+
await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
|
3235
|
+
return result;
|
1573
3236
|
}
|
1574
3237
|
if (isString(a)) {
|
1575
3238
|
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
|
@@ -1580,23 +3243,84 @@ class RestRepository extends Query {
|
|
1580
3243
|
throw new Error("Invalid arguments for delete method");
|
1581
3244
|
});
|
1582
3245
|
}
|
3246
|
+
async deleteOrThrow(a, b) {
|
3247
|
+
return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
|
3248
|
+
const result = await this.delete(a, b);
|
3249
|
+
if (Array.isArray(result)) {
|
3250
|
+
const missingIds = compact(
|
3251
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
3252
|
+
);
|
3253
|
+
if (missingIds.length > 0) {
|
3254
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
3255
|
+
}
|
3256
|
+
return result;
|
3257
|
+
} else if (result === null) {
|
3258
|
+
const id = extractId(a) ?? "unknown";
|
3259
|
+
throw new Error(`Record with id ${id} not found`);
|
3260
|
+
}
|
3261
|
+
return result;
|
3262
|
+
});
|
3263
|
+
}
|
1583
3264
|
async search(query, options = {}) {
|
1584
3265
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
1585
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1586
3266
|
const { records } = await searchTable({
|
1587
|
-
pathParams: {
|
3267
|
+
pathParams: {
|
3268
|
+
workspace: "{workspaceId}",
|
3269
|
+
dbBranchName: "{dbBranch}",
|
3270
|
+
region: "{region}",
|
3271
|
+
tableName: __privateGet$4(this, _table)
|
3272
|
+
},
|
1588
3273
|
body: {
|
1589
3274
|
query,
|
1590
3275
|
fuzziness: options.fuzziness,
|
1591
3276
|
prefix: options.prefix,
|
1592
3277
|
highlight: options.highlight,
|
1593
3278
|
filter: options.filter,
|
1594
|
-
boosters: options.boosters
|
3279
|
+
boosters: options.boosters,
|
3280
|
+
page: options.page,
|
3281
|
+
target: options.target
|
3282
|
+
},
|
3283
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3284
|
+
});
|
3285
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3286
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
3287
|
+
});
|
3288
|
+
}
|
3289
|
+
async vectorSearch(column, query, options) {
|
3290
|
+
return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
|
3291
|
+
const { records } = await vectorSearchTable({
|
3292
|
+
pathParams: {
|
3293
|
+
workspace: "{workspaceId}",
|
3294
|
+
dbBranchName: "{dbBranch}",
|
3295
|
+
region: "{region}",
|
3296
|
+
tableName: __privateGet$4(this, _table)
|
1595
3297
|
},
|
1596
|
-
|
3298
|
+
body: {
|
3299
|
+
column,
|
3300
|
+
queryVector: query,
|
3301
|
+
similarityFunction: options?.similarityFunction,
|
3302
|
+
size: options?.size,
|
3303
|
+
filter: options?.filter
|
3304
|
+
},
|
3305
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
1597
3306
|
});
|
1598
3307
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1599
|
-
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
3308
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
3309
|
+
});
|
3310
|
+
}
|
3311
|
+
async aggregate(aggs, filter) {
|
3312
|
+
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
3313
|
+
const result = await aggregateTable({
|
3314
|
+
pathParams: {
|
3315
|
+
workspace: "{workspaceId}",
|
3316
|
+
dbBranchName: "{dbBranch}",
|
3317
|
+
region: "{region}",
|
3318
|
+
tableName: __privateGet$4(this, _table)
|
3319
|
+
},
|
3320
|
+
body: { aggs, filter },
|
3321
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3322
|
+
});
|
3323
|
+
return result;
|
1600
3324
|
});
|
1601
3325
|
}
|
1602
3326
|
async query(query) {
|
@@ -1605,24 +3329,83 @@ class RestRepository extends Query {
|
|
1605
3329
|
if (cacheQuery)
|
1606
3330
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
1607
3331
|
const data = query.getQueryOptions();
|
1608
|
-
const body = {
|
1609
|
-
filter: cleanFilter(data.filter),
|
1610
|
-
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1611
|
-
page: data.pagination,
|
1612
|
-
columns: data.columns
|
1613
|
-
};
|
1614
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1615
3332
|
const { meta, records: objects } = await queryTable({
|
1616
|
-
pathParams: {
|
1617
|
-
|
1618
|
-
|
3333
|
+
pathParams: {
|
3334
|
+
workspace: "{workspaceId}",
|
3335
|
+
dbBranchName: "{dbBranch}",
|
3336
|
+
region: "{region}",
|
3337
|
+
tableName: __privateGet$4(this, _table)
|
3338
|
+
},
|
3339
|
+
body: {
|
3340
|
+
filter: cleanFilter(data.filter),
|
3341
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
3342
|
+
page: data.pagination,
|
3343
|
+
columns: data.columns ?? ["*"],
|
3344
|
+
consistency: data.consistency
|
3345
|
+
},
|
3346
|
+
fetchOptions: data.fetchOptions,
|
3347
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
1619
3348
|
});
|
1620
3349
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1621
|
-
const records = objects.map(
|
3350
|
+
const records = objects.map(
|
3351
|
+
(record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
|
3352
|
+
);
|
1622
3353
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1623
3354
|
return new Page(query, meta, records);
|
1624
3355
|
});
|
1625
3356
|
}
|
3357
|
+
async summarizeTable(query, summaries, summariesFilter) {
|
3358
|
+
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
3359
|
+
const data = query.getQueryOptions();
|
3360
|
+
const result = await summarizeTable({
|
3361
|
+
pathParams: {
|
3362
|
+
workspace: "{workspaceId}",
|
3363
|
+
dbBranchName: "{dbBranch}",
|
3364
|
+
region: "{region}",
|
3365
|
+
tableName: __privateGet$4(this, _table)
|
3366
|
+
},
|
3367
|
+
body: {
|
3368
|
+
filter: cleanFilter(data.filter),
|
3369
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
3370
|
+
columns: data.columns,
|
3371
|
+
consistency: data.consistency,
|
3372
|
+
page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
|
3373
|
+
summaries,
|
3374
|
+
summariesFilter
|
3375
|
+
},
|
3376
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3377
|
+
});
|
3378
|
+
return result;
|
3379
|
+
});
|
3380
|
+
}
|
3381
|
+
ask(question, options) {
|
3382
|
+
const params = {
|
3383
|
+
pathParams: {
|
3384
|
+
workspace: "{workspaceId}",
|
3385
|
+
dbBranchName: "{dbBranch}",
|
3386
|
+
region: "{region}",
|
3387
|
+
tableName: __privateGet$4(this, _table)
|
3388
|
+
},
|
3389
|
+
body: {
|
3390
|
+
question,
|
3391
|
+
...options
|
3392
|
+
},
|
3393
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3394
|
+
};
|
3395
|
+
if (options?.onMessage) {
|
3396
|
+
fetchSSERequest({
|
3397
|
+
endpoint: "dataPlane",
|
3398
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
3399
|
+
method: "POST",
|
3400
|
+
onMessage: (message) => {
|
3401
|
+
options.onMessage?.({ answer: message.text, records: message.records });
|
3402
|
+
},
|
3403
|
+
...params
|
3404
|
+
});
|
3405
|
+
} else {
|
3406
|
+
return askTable(params);
|
3407
|
+
}
|
3408
|
+
}
|
1626
3409
|
}
|
1627
3410
|
_table = new WeakMap();
|
1628
3411
|
_getFetchProps = new WeakMap();
|
@@ -1632,68 +3415,86 @@ _schemaTables$2 = new WeakMap();
|
|
1632
3415
|
_trace = new WeakMap();
|
1633
3416
|
_insertRecordWithoutId = new WeakSet();
|
1634
3417
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
1635
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1636
3418
|
const record = transformObjectLinks(object);
|
1637
3419
|
const response = await insertRecord({
|
1638
3420
|
pathParams: {
|
1639
3421
|
workspace: "{workspaceId}",
|
1640
3422
|
dbBranchName: "{dbBranch}",
|
3423
|
+
region: "{region}",
|
1641
3424
|
tableName: __privateGet$4(this, _table)
|
1642
3425
|
},
|
1643
3426
|
queryParams: { columns },
|
1644
3427
|
body: record,
|
1645
|
-
...
|
3428
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
1646
3429
|
});
|
1647
3430
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1648
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
3431
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1649
3432
|
};
|
1650
3433
|
_insertRecordWithId = new WeakSet();
|
1651
|
-
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
1652
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
3434
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
1653
3435
|
const record = transformObjectLinks(object);
|
1654
3436
|
const response = await insertRecordWithID({
|
1655
3437
|
pathParams: {
|
1656
3438
|
workspace: "{workspaceId}",
|
1657
3439
|
dbBranchName: "{dbBranch}",
|
3440
|
+
region: "{region}",
|
1658
3441
|
tableName: __privateGet$4(this, _table),
|
1659
3442
|
recordId
|
1660
3443
|
},
|
1661
3444
|
body: record,
|
1662
|
-
queryParams: { createOnly
|
1663
|
-
...
|
3445
|
+
queryParams: { createOnly, columns, ifVersion },
|
3446
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
1664
3447
|
});
|
1665
3448
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1666
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1667
|
-
};
|
1668
|
-
|
1669
|
-
|
1670
|
-
const
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
3449
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
3450
|
+
};
|
3451
|
+
_insertRecords = new WeakSet();
|
3452
|
+
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
3453
|
+
const chunkedOperations = chunk(
|
3454
|
+
objects.map((object) => ({
|
3455
|
+
insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
|
3456
|
+
})),
|
3457
|
+
BULK_OPERATION_MAX_SIZE
|
3458
|
+
);
|
3459
|
+
const ids = [];
|
3460
|
+
for (const operations of chunkedOperations) {
|
3461
|
+
const { results } = await branchTransaction({
|
3462
|
+
pathParams: {
|
3463
|
+
workspace: "{workspaceId}",
|
3464
|
+
dbBranchName: "{dbBranch}",
|
3465
|
+
region: "{region}"
|
3466
|
+
},
|
3467
|
+
body: { operations },
|
3468
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3469
|
+
});
|
3470
|
+
for (const result of results) {
|
3471
|
+
if (result.operation === "insert") {
|
3472
|
+
ids.push(result.id);
|
3473
|
+
} else {
|
3474
|
+
ids.push(null);
|
3475
|
+
}
|
3476
|
+
}
|
1680
3477
|
}
|
1681
|
-
|
1682
|
-
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
3478
|
+
return ids;
|
1683
3479
|
};
|
1684
3480
|
_updateRecordWithID = new WeakSet();
|
1685
|
-
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
1686
|
-
const
|
1687
|
-
const record = transformObjectLinks(object);
|
3481
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
3482
|
+
const { id: _id, ...record } = transformObjectLinks(object);
|
1688
3483
|
try {
|
1689
3484
|
const response = await updateRecordWithID({
|
1690
|
-
pathParams: {
|
1691
|
-
|
3485
|
+
pathParams: {
|
3486
|
+
workspace: "{workspaceId}",
|
3487
|
+
dbBranchName: "{dbBranch}",
|
3488
|
+
region: "{region}",
|
3489
|
+
tableName: __privateGet$4(this, _table),
|
3490
|
+
recordId
|
3491
|
+
},
|
3492
|
+
queryParams: { columns, ifVersion },
|
1692
3493
|
body: record,
|
1693
|
-
...
|
3494
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
1694
3495
|
});
|
1695
3496
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1696
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
3497
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1697
3498
|
} catch (e) {
|
1698
3499
|
if (isObject(e) && e.status === 404) {
|
1699
3500
|
return null;
|
@@ -1701,29 +3502,68 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
1701
3502
|
throw e;
|
1702
3503
|
}
|
1703
3504
|
};
|
3505
|
+
_updateRecords = new WeakSet();
|
3506
|
+
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
3507
|
+
const chunkedOperations = chunk(
|
3508
|
+
objects.map(({ id, ...object }) => ({
|
3509
|
+
update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
|
3510
|
+
})),
|
3511
|
+
BULK_OPERATION_MAX_SIZE
|
3512
|
+
);
|
3513
|
+
const ids = [];
|
3514
|
+
for (const operations of chunkedOperations) {
|
3515
|
+
const { results } = await branchTransaction({
|
3516
|
+
pathParams: {
|
3517
|
+
workspace: "{workspaceId}",
|
3518
|
+
dbBranchName: "{dbBranch}",
|
3519
|
+
region: "{region}"
|
3520
|
+
},
|
3521
|
+
body: { operations },
|
3522
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3523
|
+
});
|
3524
|
+
for (const result of results) {
|
3525
|
+
if (result.operation === "update") {
|
3526
|
+
ids.push(result.id);
|
3527
|
+
} else {
|
3528
|
+
ids.push(null);
|
3529
|
+
}
|
3530
|
+
}
|
3531
|
+
}
|
3532
|
+
return ids;
|
3533
|
+
};
|
1704
3534
|
_upsertRecordWithID = new WeakSet();
|
1705
|
-
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
1706
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
3535
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
1707
3536
|
const response = await upsertRecordWithID({
|
1708
|
-
pathParams: {
|
1709
|
-
|
3537
|
+
pathParams: {
|
3538
|
+
workspace: "{workspaceId}",
|
3539
|
+
dbBranchName: "{dbBranch}",
|
3540
|
+
region: "{region}",
|
3541
|
+
tableName: __privateGet$4(this, _table),
|
3542
|
+
recordId
|
3543
|
+
},
|
3544
|
+
queryParams: { columns, ifVersion },
|
1710
3545
|
body: object,
|
1711
|
-
...
|
3546
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
1712
3547
|
});
|
1713
3548
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1714
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
3549
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1715
3550
|
};
|
1716
3551
|
_deleteRecord = new WeakSet();
|
1717
3552
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
1718
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1719
3553
|
try {
|
1720
3554
|
const response = await deleteRecord({
|
1721
|
-
pathParams: {
|
3555
|
+
pathParams: {
|
3556
|
+
workspace: "{workspaceId}",
|
3557
|
+
dbBranchName: "{dbBranch}",
|
3558
|
+
region: "{region}",
|
3559
|
+
tableName: __privateGet$4(this, _table),
|
3560
|
+
recordId
|
3561
|
+
},
|
1722
3562
|
queryParams: { columns },
|
1723
|
-
...
|
3563
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
1724
3564
|
});
|
1725
3565
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1726
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
3566
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1727
3567
|
} catch (e) {
|
1728
3568
|
if (isObject(e) && e.status === 404) {
|
1729
3569
|
return null;
|
@@ -1731,17 +3571,36 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
1731
3571
|
throw e;
|
1732
3572
|
}
|
1733
3573
|
};
|
3574
|
+
_deleteRecords = new WeakSet();
|
3575
|
+
deleteRecords_fn = async function(recordIds) {
|
3576
|
+
const chunkedOperations = chunk(
|
3577
|
+
recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
3578
|
+
BULK_OPERATION_MAX_SIZE
|
3579
|
+
);
|
3580
|
+
for (const operations of chunkedOperations) {
|
3581
|
+
await branchTransaction({
|
3582
|
+
pathParams: {
|
3583
|
+
workspace: "{workspaceId}",
|
3584
|
+
dbBranchName: "{dbBranch}",
|
3585
|
+
region: "{region}"
|
3586
|
+
},
|
3587
|
+
body: { operations },
|
3588
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
3589
|
+
});
|
3590
|
+
}
|
3591
|
+
};
|
1734
3592
|
_setCacheQuery = new WeakSet();
|
1735
3593
|
setCacheQuery_fn = async function(query, meta, records) {
|
1736
|
-
await __privateGet$4(this, _cache)
|
3594
|
+
await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
|
1737
3595
|
};
|
1738
3596
|
_getCacheQuery = new WeakSet();
|
1739
3597
|
getCacheQuery_fn = async function(query) {
|
1740
3598
|
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
1741
|
-
const result = await __privateGet$4(this, _cache)
|
3599
|
+
const result = await __privateGet$4(this, _cache)?.get(key);
|
1742
3600
|
if (!result)
|
1743
3601
|
return null;
|
1744
|
-
const
|
3602
|
+
const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
|
3603
|
+
const { cache: ttl = defaultTTL } = query.getQueryOptions();
|
1745
3604
|
if (ttl < 0)
|
1746
3605
|
return null;
|
1747
3606
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
@@ -1751,10 +3610,9 @@ _getSchemaTables$1 = new WeakSet();
|
|
1751
3610
|
getSchemaTables_fn$1 = async function() {
|
1752
3611
|
if (__privateGet$4(this, _schemaTables$2))
|
1753
3612
|
return __privateGet$4(this, _schemaTables$2);
|
1754
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1755
3613
|
const { schema } = await getBranchDetails({
|
1756
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1757
|
-
...
|
3614
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3615
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
1758
3616
|
});
|
1759
3617
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
1760
3618
|
return schema.tables;
|
@@ -1766,22 +3624,24 @@ const transformObjectLinks = (object) => {
|
|
1766
3624
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1767
3625
|
}, {});
|
1768
3626
|
};
|
1769
|
-
const initObject = (db, schemaTables, table, object) => {
|
1770
|
-
const
|
3627
|
+
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
3628
|
+
const data = {};
|
1771
3629
|
const { xata, ...rest } = object ?? {};
|
1772
|
-
Object.assign(
|
3630
|
+
Object.assign(data, rest);
|
1773
3631
|
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
1774
3632
|
if (!columns)
|
1775
3633
|
console.error(`Table ${table} not found in schema`);
|
1776
3634
|
for (const column of columns ?? []) {
|
1777
|
-
|
3635
|
+
if (!isValidColumn(selectedColumns, column))
|
3636
|
+
continue;
|
3637
|
+
const value = data[column.name];
|
1778
3638
|
switch (column.type) {
|
1779
3639
|
case "datetime": {
|
1780
|
-
const date = value !== void 0 ? new Date(value) :
|
1781
|
-
if (date && isNaN(date.getTime())) {
|
3640
|
+
const date = value !== void 0 ? new Date(value) : null;
|
3641
|
+
if (date !== null && isNaN(date.getTime())) {
|
1782
3642
|
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
1783
|
-
} else
|
1784
|
-
|
3643
|
+
} else {
|
3644
|
+
data[column.name] = date;
|
1785
3645
|
}
|
1786
3646
|
break;
|
1787
3647
|
}
|
@@ -1790,33 +3650,65 @@ const initObject = (db, schemaTables, table, object) => {
|
|
1790
3650
|
if (!linkTable) {
|
1791
3651
|
console.error(`Failed to parse link for field ${column.name}`);
|
1792
3652
|
} else if (isObject(value)) {
|
1793
|
-
|
3653
|
+
const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
|
3654
|
+
if (item === column.name) {
|
3655
|
+
return [...acc, "*"];
|
3656
|
+
}
|
3657
|
+
if (item.startsWith(`${column.name}.`)) {
|
3658
|
+
const [, ...path] = item.split(".");
|
3659
|
+
return [...acc, path.join(".")];
|
3660
|
+
}
|
3661
|
+
return acc;
|
3662
|
+
}, []);
|
3663
|
+
data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
|
3664
|
+
} else {
|
3665
|
+
data[column.name] = null;
|
1794
3666
|
}
|
1795
3667
|
break;
|
1796
3668
|
}
|
3669
|
+
default:
|
3670
|
+
data[column.name] = value ?? null;
|
3671
|
+
if (column.notNull === true && value === null) {
|
3672
|
+
console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
|
3673
|
+
}
|
3674
|
+
break;
|
1797
3675
|
}
|
1798
3676
|
}
|
1799
|
-
|
1800
|
-
|
3677
|
+
const record = { ...data };
|
3678
|
+
const serializable = { xata, ...transformObjectLinks(data) };
|
3679
|
+
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
3680
|
+
record.read = function(columns2) {
|
3681
|
+
return db[table].read(record["id"], columns2);
|
3682
|
+
};
|
3683
|
+
record.update = function(data2, b, c) {
|
3684
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
3685
|
+
const ifVersion = parseIfVersion(b, c);
|
3686
|
+
return db[table].update(record["id"], data2, columns2, { ifVersion });
|
3687
|
+
};
|
3688
|
+
record.replace = function(data2, b, c) {
|
3689
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
3690
|
+
const ifVersion = parseIfVersion(b, c);
|
3691
|
+
return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
|
1801
3692
|
};
|
1802
|
-
|
1803
|
-
return db[table].
|
3693
|
+
record.delete = function() {
|
3694
|
+
return db[table].delete(record["id"]);
|
1804
3695
|
};
|
1805
|
-
|
1806
|
-
|
3696
|
+
record.xata = Object.freeze(metadata);
|
3697
|
+
record.getMetadata = function() {
|
3698
|
+
return record.xata;
|
1807
3699
|
};
|
1808
|
-
|
1809
|
-
return
|
3700
|
+
record.toSerializable = function() {
|
3701
|
+
return JSON.parse(JSON.stringify(serializable));
|
1810
3702
|
};
|
1811
|
-
|
1812
|
-
|
3703
|
+
record.toString = function() {
|
3704
|
+
return JSON.stringify(transformObjectLinks(serializable));
|
3705
|
+
};
|
3706
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
3707
|
+
Object.defineProperty(record, prop, { enumerable: false });
|
1813
3708
|
}
|
1814
|
-
Object.freeze(
|
1815
|
-
return
|
3709
|
+
Object.freeze(record);
|
3710
|
+
return record;
|
1816
3711
|
};
|
1817
|
-
function isResponseWithRecords(value) {
|
1818
|
-
return isObject(value) && Array.isArray(value.records);
|
1819
|
-
}
|
1820
3712
|
function extractId(value) {
|
1821
3713
|
if (isString(value))
|
1822
3714
|
return value;
|
@@ -1824,11 +3716,22 @@ function extractId(value) {
|
|
1824
3716
|
return value.id;
|
1825
3717
|
return void 0;
|
1826
3718
|
}
|
1827
|
-
function
|
1828
|
-
if (
|
1829
|
-
return
|
1830
|
-
|
1831
|
-
|
3719
|
+
function isValidColumn(columns, column) {
|
3720
|
+
if (columns.includes("*"))
|
3721
|
+
return true;
|
3722
|
+
if (column.type === "link") {
|
3723
|
+
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
3724
|
+
return linkColumns.length > 0;
|
3725
|
+
}
|
3726
|
+
return columns.includes(column.name);
|
3727
|
+
}
|
3728
|
+
function parseIfVersion(...args) {
|
3729
|
+
for (const arg of args) {
|
3730
|
+
if (isObject(arg) && isNumber(arg.ifVersion)) {
|
3731
|
+
return arg.ifVersion;
|
3732
|
+
}
|
3733
|
+
}
|
3734
|
+
return void 0;
|
1832
3735
|
}
|
1833
3736
|
|
1834
3737
|
var __accessCheck$3 = (obj, member, msg) => {
|
@@ -1988,23 +3891,23 @@ class SearchPlugin extends XataPlugin {
|
|
1988
3891
|
__privateAdd$1(this, _schemaTables, void 0);
|
1989
3892
|
__privateSet$1(this, _schemaTables, schemaTables);
|
1990
3893
|
}
|
1991
|
-
build(
|
3894
|
+
build(pluginOptions) {
|
1992
3895
|
return {
|
1993
3896
|
all: async (query, options = {}) => {
|
1994
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
1995
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
3897
|
+
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
3898
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
1996
3899
|
return records.map((record) => {
|
1997
3900
|
const { table = "orphan" } = record.xata;
|
1998
|
-
return { table, record: initObject(this.db, schemaTables, table, record) };
|
3901
|
+
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
1999
3902
|
});
|
2000
3903
|
},
|
2001
3904
|
byTable: async (query, options = {}) => {
|
2002
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
2003
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
3905
|
+
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
3906
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
2004
3907
|
return records.reduce((acc, record) => {
|
2005
3908
|
const { table = "orphan" } = record.xata;
|
2006
3909
|
const items = acc[table] ?? [];
|
2007
|
-
const item = initObject(this.db, schemaTables, table, record);
|
3910
|
+
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
2008
3911
|
return { ...acc, [table]: [...items, item] };
|
2009
3912
|
}, {});
|
2010
3913
|
}
|
@@ -2013,108 +3916,40 @@ class SearchPlugin extends XataPlugin {
|
|
2013
3916
|
}
|
2014
3917
|
_schemaTables = new WeakMap();
|
2015
3918
|
_search = new WeakSet();
|
2016
|
-
search_fn = async function(query, options,
|
2017
|
-
const
|
2018
|
-
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
3919
|
+
search_fn = async function(query, options, pluginOptions) {
|
3920
|
+
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
2019
3921
|
const { records } = await searchBranch({
|
2020
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2021
|
-
|
2022
|
-
|
3922
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3923
|
+
// @ts-ignore https://github.com/xataio/client-ts/issues/313
|
3924
|
+
body: { tables, query, fuzziness, prefix, highlight, page },
|
3925
|
+
...pluginOptions
|
2023
3926
|
});
|
2024
3927
|
return records;
|
2025
3928
|
};
|
2026
3929
|
_getSchemaTables = new WeakSet();
|
2027
|
-
getSchemaTables_fn = async function(
|
3930
|
+
getSchemaTables_fn = async function(pluginOptions) {
|
2028
3931
|
if (__privateGet$1(this, _schemaTables))
|
2029
3932
|
return __privateGet$1(this, _schemaTables);
|
2030
|
-
const fetchProps = await getFetchProps();
|
2031
3933
|
const { schema } = await getBranchDetails({
|
2032
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2033
|
-
...
|
3934
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3935
|
+
...pluginOptions
|
2034
3936
|
});
|
2035
3937
|
__privateSet$1(this, _schemaTables, schema.tables);
|
2036
3938
|
return schema.tables;
|
2037
3939
|
};
|
2038
3940
|
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
const gitBranch = envBranch || await getGitBranch();
|
2052
|
-
return resolveXataBranch(gitBranch, options);
|
2053
|
-
}
|
2054
|
-
async function getCurrentBranchDetails(options) {
|
2055
|
-
const branch = await getCurrentBranchName(options);
|
2056
|
-
return getDatabaseBranch(branch, options);
|
2057
|
-
}
|
2058
|
-
async function resolveXataBranch(gitBranch, options) {
|
2059
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
2060
|
-
const apiKey = options?.apiKey || getAPIKey();
|
2061
|
-
if (!databaseURL)
|
2062
|
-
throw new Error(
|
2063
|
-
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
2064
|
-
);
|
2065
|
-
if (!apiKey)
|
2066
|
-
throw new Error(
|
2067
|
-
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2068
|
-
);
|
2069
|
-
const [protocol, , host, , dbName] = databaseURL.split("/");
|
2070
|
-
const [workspace] = host.split(".");
|
2071
|
-
const { fallbackBranch } = getEnvironment();
|
2072
|
-
const { branch } = await resolveBranch({
|
2073
|
-
apiKey,
|
2074
|
-
apiUrl: databaseURL,
|
2075
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2076
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
2077
|
-
pathParams: { dbName, workspace },
|
2078
|
-
queryParams: { gitBranch, fallbackBranch },
|
2079
|
-
trace: defaultTrace
|
2080
|
-
});
|
2081
|
-
return branch;
|
2082
|
-
}
|
2083
|
-
async function getDatabaseBranch(branch, options) {
|
2084
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
2085
|
-
const apiKey = options?.apiKey || getAPIKey();
|
2086
|
-
if (!databaseURL)
|
2087
|
-
throw new Error(
|
2088
|
-
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
2089
|
-
);
|
2090
|
-
if (!apiKey)
|
2091
|
-
throw new Error(
|
2092
|
-
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2093
|
-
);
|
2094
|
-
const [protocol, , host, , database] = databaseURL.split("/");
|
2095
|
-
const [workspace] = host.split(".");
|
2096
|
-
const dbBranchName = `${database}:${branch}`;
|
2097
|
-
try {
|
2098
|
-
return await getBranchDetails({
|
2099
|
-
apiKey,
|
2100
|
-
apiUrl: databaseURL,
|
2101
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2102
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
2103
|
-
pathParams: { dbBranchName, workspace },
|
2104
|
-
trace: defaultTrace
|
2105
|
-
});
|
2106
|
-
} catch (err) {
|
2107
|
-
if (isObject(err) && err.status === 404)
|
2108
|
-
return null;
|
2109
|
-
throw err;
|
2110
|
-
}
|
2111
|
-
}
|
2112
|
-
function getDatabaseURL() {
|
2113
|
-
try {
|
2114
|
-
const { databaseURL } = getEnvironment();
|
2115
|
-
return databaseURL;
|
2116
|
-
} catch (err) {
|
2117
|
-
return void 0;
|
3941
|
+
class TransactionPlugin extends XataPlugin {
|
3942
|
+
build(pluginOptions) {
|
3943
|
+
return {
|
3944
|
+
run: async (operations) => {
|
3945
|
+
const response = await branchTransaction({
|
3946
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3947
|
+
body: { operations },
|
3948
|
+
...pluginOptions
|
3949
|
+
});
|
3950
|
+
return response;
|
3951
|
+
}
|
3952
|
+
};
|
2118
3953
|
}
|
2119
3954
|
}
|
2120
3955
|
|
@@ -2141,88 +3976,116 @@ var __privateMethod = (obj, member, method) => {
|
|
2141
3976
|
return method;
|
2142
3977
|
};
|
2143
3978
|
const buildClient = (plugins) => {
|
2144
|
-
var
|
3979
|
+
var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
|
2145
3980
|
return _a = class {
|
2146
3981
|
constructor(options = {}, schemaTables) {
|
2147
3982
|
__privateAdd(this, _parseOptions);
|
2148
3983
|
__privateAdd(this, _getFetchProps);
|
2149
|
-
__privateAdd(this, _evaluateBranch);
|
2150
|
-
__privateAdd(this, _branch, void 0);
|
2151
3984
|
__privateAdd(this, _options, void 0);
|
2152
3985
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
2153
3986
|
__privateSet(this, _options, safeOptions);
|
2154
3987
|
const pluginOptions = {
|
2155
|
-
|
3988
|
+
...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
2156
3989
|
cache: safeOptions.cache,
|
2157
|
-
|
3990
|
+
host: safeOptions.host
|
2158
3991
|
};
|
2159
3992
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
2160
3993
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
3994
|
+
const transactions = new TransactionPlugin().build(pluginOptions);
|
2161
3995
|
this.db = db;
|
2162
3996
|
this.search = search;
|
3997
|
+
this.transactions = transactions;
|
2163
3998
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
2164
3999
|
if (namespace === void 0)
|
2165
4000
|
continue;
|
2166
|
-
|
2167
|
-
if (result instanceof Promise) {
|
2168
|
-
void result.then((namespace2) => {
|
2169
|
-
this[key] = namespace2;
|
2170
|
-
});
|
2171
|
-
} else {
|
2172
|
-
this[key] = result;
|
2173
|
-
}
|
4001
|
+
this[key] = namespace.build(pluginOptions);
|
2174
4002
|
}
|
2175
4003
|
}
|
2176
4004
|
async getConfig() {
|
2177
4005
|
const databaseURL = __privateGet(this, _options).databaseURL;
|
2178
|
-
const branch =
|
4006
|
+
const branch = __privateGet(this, _options).branch;
|
2179
4007
|
return { databaseURL, branch };
|
2180
4008
|
}
|
2181
|
-
},
|
4009
|
+
}, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
4010
|
+
const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
|
4011
|
+
const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
|
4012
|
+
if (isBrowser && !enableBrowser) {
|
4013
|
+
throw new Error(
|
4014
|
+
"You are trying to use Xata from the browser, which is potentially a non-secure environment. If you understand the security concerns, such as leaking your credentials, pass `enableBrowser: true` to the client options to remove this error."
|
4015
|
+
);
|
4016
|
+
}
|
2182
4017
|
const fetch = getFetchImplementation(options?.fetch);
|
2183
4018
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
2184
4019
|
const apiKey = options?.apiKey || getAPIKey();
|
2185
4020
|
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
2186
4021
|
const trace = options?.trace ?? defaultTrace;
|
2187
|
-
const
|
4022
|
+
const clientName = options?.clientName;
|
4023
|
+
const host = options?.host ?? "production";
|
4024
|
+
const xataAgentExtra = options?.xataAgentExtra;
|
2188
4025
|
if (!apiKey) {
|
2189
4026
|
throw new Error("Option apiKey is required");
|
2190
4027
|
}
|
2191
4028
|
if (!databaseURL) {
|
2192
4029
|
throw new Error("Option databaseURL is required");
|
2193
4030
|
}
|
2194
|
-
|
2195
|
-
|
2196
|
-
const
|
2197
|
-
if (
|
2198
|
-
|
4031
|
+
const envBranch = getBranch();
|
4032
|
+
const previewBranch = getPreviewBranch();
|
4033
|
+
const branch = options?.branch || previewBranch || envBranch || "main";
|
4034
|
+
if (!!previewBranch && branch !== previewBranch) {
|
4035
|
+
console.warn(
|
4036
|
+
`Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
|
4037
|
+
);
|
4038
|
+
} else if (!!envBranch && branch !== envBranch) {
|
4039
|
+
console.warn(
|
4040
|
+
`Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
4041
|
+
);
|
4042
|
+
} else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
|
4043
|
+
console.warn(
|
4044
|
+
`Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
4045
|
+
);
|
4046
|
+
} else if (!previewBranch && !envBranch && options?.branch === void 0) {
|
4047
|
+
console.warn(
|
4048
|
+
`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.`
|
4049
|
+
);
|
4050
|
+
}
|
4051
|
+
return {
|
4052
|
+
fetch,
|
4053
|
+
databaseURL,
|
4054
|
+
apiKey,
|
4055
|
+
branch,
|
4056
|
+
cache,
|
4057
|
+
trace,
|
4058
|
+
host,
|
4059
|
+
clientID: generateUUID(),
|
4060
|
+
enableBrowser,
|
4061
|
+
clientName,
|
4062
|
+
xataAgentExtra
|
4063
|
+
};
|
4064
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
|
4065
|
+
fetch,
|
4066
|
+
apiKey,
|
4067
|
+
databaseURL,
|
4068
|
+
branch,
|
4069
|
+
trace,
|
4070
|
+
clientID,
|
4071
|
+
clientName,
|
4072
|
+
xataAgentExtra
|
4073
|
+
}) {
|
2199
4074
|
return {
|
2200
|
-
|
4075
|
+
fetch,
|
2201
4076
|
apiKey,
|
2202
4077
|
apiUrl: "",
|
4078
|
+
// Instead of using workspace and dbBranch, we inject a probably CNAME'd URL
|
2203
4079
|
workspacesApiUrl: (path, params) => {
|
2204
4080
|
const hasBranch = params.dbBranchName ?? params.branch;
|
2205
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${
|
4081
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
|
2206
4082
|
return databaseURL + newPath;
|
2207
4083
|
},
|
2208
|
-
trace
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
return __privateGet(this, _branch);
|
2213
|
-
if (param === void 0)
|
2214
|
-
return void 0;
|
2215
|
-
const strategies = Array.isArray(param) ? [...param] : [param];
|
2216
|
-
const evaluateBranch = async (strategy) => {
|
2217
|
-
return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
|
4084
|
+
trace,
|
4085
|
+
clientID,
|
4086
|
+
clientName,
|
4087
|
+
xataAgentExtra
|
2218
4088
|
};
|
2219
|
-
for await (const strategy of strategies) {
|
2220
|
-
const branch = await evaluateBranch(strategy);
|
2221
|
-
if (branch) {
|
2222
|
-
__privateSet(this, _branch, branch);
|
2223
|
-
return branch;
|
2224
|
-
}
|
2225
|
-
}
|
2226
4089
|
}, _a;
|
2227
4090
|
};
|
2228
4091
|
class BaseClient extends buildClient() {
|
@@ -2296,7 +4159,7 @@ const deserialize = (json) => {
|
|
2296
4159
|
};
|
2297
4160
|
|
2298
4161
|
function buildWorkerRunner(config) {
|
2299
|
-
return function xataWorker(name,
|
4162
|
+
return function xataWorker(name, worker) {
|
2300
4163
|
return async (...args) => {
|
2301
4164
|
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
2302
4165
|
const result = await fetch(url, {
|
@@ -2318,6 +4181,7 @@ class XataError extends Error {
|
|
2318
4181
|
}
|
2319
4182
|
|
2320
4183
|
exports.BaseClient = BaseClient;
|
4184
|
+
exports.FetcherError = FetcherError;
|
2321
4185
|
exports.Operations = operationsByTag;
|
2322
4186
|
exports.PAGINATION_DEFAULT_OFFSET = PAGINATION_DEFAULT_OFFSET;
|
2323
4187
|
exports.PAGINATION_DEFAULT_SIZE = PAGINATION_DEFAULT_SIZE;
|
@@ -2339,19 +4203,33 @@ exports.XataPlugin = XataPlugin;
|
|
2339
4203
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
2340
4204
|
exports.addGitBranchesEntry = addGitBranchesEntry;
|
2341
4205
|
exports.addTableColumn = addTableColumn;
|
4206
|
+
exports.aggregateTable = aggregateTable;
|
4207
|
+
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
4208
|
+
exports.askTable = askTable;
|
4209
|
+
exports.branchTransaction = branchTransaction;
|
2342
4210
|
exports.buildClient = buildClient;
|
4211
|
+
exports.buildPreviewBranchName = buildPreviewBranchName;
|
4212
|
+
exports.buildProviderString = buildProviderString;
|
2343
4213
|
exports.buildWorkerRunner = buildWorkerRunner;
|
2344
4214
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
2345
4215
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
4216
|
+
exports.compareBranchSchemas = compareBranchSchemas;
|
4217
|
+
exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
|
4218
|
+
exports.compareMigrationRequest = compareMigrationRequest;
|
2346
4219
|
exports.contains = contains;
|
4220
|
+
exports.copyBranch = copyBranch;
|
2347
4221
|
exports.createBranch = createBranch;
|
2348
4222
|
exports.createDatabase = createDatabase;
|
4223
|
+
exports.createMigrationRequest = createMigrationRequest;
|
2349
4224
|
exports.createTable = createTable;
|
2350
4225
|
exports.createUserAPIKey = createUserAPIKey;
|
2351
4226
|
exports.createWorkspace = createWorkspace;
|
2352
4227
|
exports.deleteBranch = deleteBranch;
|
2353
4228
|
exports.deleteColumn = deleteColumn;
|
2354
4229
|
exports.deleteDatabase = deleteDatabase;
|
4230
|
+
exports.deleteDatabaseGithubSettings = deleteDatabaseGithubSettings;
|
4231
|
+
exports.deleteFile = deleteFile;
|
4232
|
+
exports.deleteFileItem = deleteFileItem;
|
2355
4233
|
exports.deleteRecord = deleteRecord;
|
2356
4234
|
exports.deleteTable = deleteTable;
|
2357
4235
|
exports.deleteUser = deleteUser;
|
@@ -2362,21 +4240,29 @@ exports.endsWith = endsWith;
|
|
2362
4240
|
exports.equals = equals;
|
2363
4241
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
2364
4242
|
exports.exists = exists;
|
4243
|
+
exports.fileAccess = fileAccess;
|
2365
4244
|
exports.ge = ge;
|
2366
4245
|
exports.getAPIKey = getAPIKey;
|
4246
|
+
exports.getBranch = getBranch;
|
2367
4247
|
exports.getBranchDetails = getBranchDetails;
|
2368
4248
|
exports.getBranchList = getBranchList;
|
2369
4249
|
exports.getBranchMetadata = getBranchMetadata;
|
2370
4250
|
exports.getBranchMigrationHistory = getBranchMigrationHistory;
|
2371
4251
|
exports.getBranchMigrationPlan = getBranchMigrationPlan;
|
4252
|
+
exports.getBranchSchemaHistory = getBranchSchemaHistory;
|
2372
4253
|
exports.getBranchStats = getBranchStats;
|
2373
4254
|
exports.getColumn = getColumn;
|
2374
|
-
exports.
|
2375
|
-
exports.getCurrentBranchName = getCurrentBranchName;
|
4255
|
+
exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
|
2376
4256
|
exports.getDatabaseList = getDatabaseList;
|
2377
4257
|
exports.getDatabaseMetadata = getDatabaseMetadata;
|
2378
4258
|
exports.getDatabaseURL = getDatabaseURL;
|
4259
|
+
exports.getFile = getFile;
|
4260
|
+
exports.getFileItem = getFileItem;
|
2379
4261
|
exports.getGitBranchesMapping = getGitBranchesMapping;
|
4262
|
+
exports.getHostUrl = getHostUrl;
|
4263
|
+
exports.getMigrationRequest = getMigrationRequest;
|
4264
|
+
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
4265
|
+
exports.getPreviewBranch = getPreviewBranch;
|
2380
4266
|
exports.getRecord = getRecord;
|
2381
4267
|
exports.getTableColumns = getTableColumns;
|
2382
4268
|
exports.getTableSchema = getTableSchema;
|
@@ -2399,6 +4285,8 @@ exports.insertRecordWithID = insertRecordWithID;
|
|
2399
4285
|
exports.inviteWorkspaceMember = inviteWorkspaceMember;
|
2400
4286
|
exports.is = is;
|
2401
4287
|
exports.isCursorPaginationOptions = isCursorPaginationOptions;
|
4288
|
+
exports.isHostProviderAlias = isHostProviderAlias;
|
4289
|
+
exports.isHostProviderBuilder = isHostProviderBuilder;
|
2402
4290
|
exports.isIdentifiable = isIdentifiable;
|
2403
4291
|
exports.isNot = isNot;
|
2404
4292
|
exports.isXataRecord = isXataRecord;
|
@@ -2406,23 +4294,40 @@ exports.le = le;
|
|
2406
4294
|
exports.lessEquals = lessEquals;
|
2407
4295
|
exports.lessThan = lessThan;
|
2408
4296
|
exports.lessThanEquals = lessThanEquals;
|
4297
|
+
exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
|
4298
|
+
exports.listRegions = listRegions;
|
2409
4299
|
exports.lt = lt;
|
2410
4300
|
exports.lte = lte;
|
4301
|
+
exports.mergeMigrationRequest = mergeMigrationRequest;
|
2411
4302
|
exports.notExists = notExists;
|
2412
4303
|
exports.operationsByTag = operationsByTag;
|
4304
|
+
exports.parseProviderString = parseProviderString;
|
4305
|
+
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
2413
4306
|
exports.pattern = pattern;
|
4307
|
+
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
4308
|
+
exports.pushBranchMigrations = pushBranchMigrations;
|
4309
|
+
exports.putFile = putFile;
|
4310
|
+
exports.putFileItem = putFileItem;
|
4311
|
+
exports.queryMigrationRequests = queryMigrationRequests;
|
2414
4312
|
exports.queryTable = queryTable;
|
2415
4313
|
exports.removeGitBranchesEntry = removeGitBranchesEntry;
|
2416
4314
|
exports.removeWorkspaceMember = removeWorkspaceMember;
|
4315
|
+
exports.renameDatabase = renameDatabase;
|
2417
4316
|
exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
|
2418
4317
|
exports.resolveBranch = resolveBranch;
|
2419
4318
|
exports.searchBranch = searchBranch;
|
2420
4319
|
exports.searchTable = searchTable;
|
2421
4320
|
exports.serialize = serialize;
|
2422
4321
|
exports.setTableSchema = setTableSchema;
|
4322
|
+
exports.sqlQuery = sqlQuery;
|
2423
4323
|
exports.startsWith = startsWith;
|
4324
|
+
exports.summarizeTable = summarizeTable;
|
2424
4325
|
exports.updateBranchMetadata = updateBranchMetadata;
|
4326
|
+
exports.updateBranchSchema = updateBranchSchema;
|
2425
4327
|
exports.updateColumn = updateColumn;
|
4328
|
+
exports.updateDatabaseGithubSettings = updateDatabaseGithubSettings;
|
4329
|
+
exports.updateDatabaseMetadata = updateDatabaseMetadata;
|
4330
|
+
exports.updateMigrationRequest = updateMigrationRequest;
|
2426
4331
|
exports.updateRecordWithID = updateRecordWithID;
|
2427
4332
|
exports.updateTable = updateTable;
|
2428
4333
|
exports.updateUser = updateUser;
|
@@ -2430,4 +4335,5 @@ exports.updateWorkspace = updateWorkspace;
|
|
2430
4335
|
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
2431
4336
|
exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
|
2432
4337
|
exports.upsertRecordWithID = upsertRecordWithID;
|
4338
|
+
exports.vectorSearchTable = vectorSearchTable;
|
2433
4339
|
//# sourceMappingURL=index.cjs.map
|