@xata.io/client 0.0.0-alpha.vec26c56 → 0.0.0-alpha.vec3a2b1
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/.eslintrc.cjs +3 -2
- package/.turbo/turbo-add-version.log +4 -0
- package/.turbo/turbo-build.log +13 -0
- package/CHANGELOG.md +220 -0
- package/README.md +3 -269
- package/dist/index.cjs +2183 -876
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4950 -2475
- package/dist/index.mjs +2171 -859
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -8
- package/rollup.config.mjs +44 -0
- package/Usage.md +0 -451
- package/rollup.config.js +0 -29
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const defaultTrace = async (
|
|
1
|
+
const defaultTrace = async (name, fn, _options) => {
|
|
2
2
|
return await fn({
|
|
3
|
+
name,
|
|
3
4
|
setAttributes: () => {
|
|
4
5
|
return;
|
|
5
6
|
}
|
|
@@ -38,6 +39,21 @@ function isString(value) {
|
|
|
38
39
|
function isStringArray(value) {
|
|
39
40
|
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
|
40
41
|
}
|
|
42
|
+
function isNumber(value) {
|
|
43
|
+
return isDefined(value) && typeof value === "number";
|
|
44
|
+
}
|
|
45
|
+
function parseNumber(value) {
|
|
46
|
+
if (isNumber(value)) {
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
if (isString(value)) {
|
|
50
|
+
const parsed = Number(value);
|
|
51
|
+
if (!Number.isNaN(parsed)) {
|
|
52
|
+
return parsed;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
41
57
|
function toBase64(value) {
|
|
42
58
|
try {
|
|
43
59
|
return btoa(value);
|
|
@@ -46,16 +62,39 @@ function toBase64(value) {
|
|
|
46
62
|
return buf.from(value).toString("base64");
|
|
47
63
|
}
|
|
48
64
|
}
|
|
65
|
+
function deepMerge(a, b) {
|
|
66
|
+
const result = { ...a };
|
|
67
|
+
for (const [key, value] of Object.entries(b)) {
|
|
68
|
+
if (isObject(value) && isObject(result[key])) {
|
|
69
|
+
result[key] = deepMerge(result[key], value);
|
|
70
|
+
} else {
|
|
71
|
+
result[key] = value;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
function chunk(array, chunkSize) {
|
|
77
|
+
const result = [];
|
|
78
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
79
|
+
result.push(array.slice(i, i + chunkSize));
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
async function timeout(ms) {
|
|
84
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
85
|
+
}
|
|
49
86
|
|
|
50
87
|
function getEnvironment() {
|
|
51
88
|
try {
|
|
52
|
-
if (
|
|
89
|
+
if (isDefined(process) && isDefined(process.env)) {
|
|
53
90
|
return {
|
|
54
91
|
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
|
55
92
|
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
|
56
93
|
branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
|
|
57
|
-
|
|
58
|
-
|
|
94
|
+
deployPreview: process.env.XATA_PREVIEW,
|
|
95
|
+
deployPreviewBranch: process.env.XATA_PREVIEW_BRANCH,
|
|
96
|
+
vercelGitCommitRef: process.env.VERCEL_GIT_COMMIT_REF,
|
|
97
|
+
vercelGitRepoOwner: process.env.VERCEL_GIT_REPO_OWNER
|
|
59
98
|
};
|
|
60
99
|
}
|
|
61
100
|
} catch (err) {
|
|
@@ -66,8 +105,10 @@ function getEnvironment() {
|
|
|
66
105
|
apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
|
|
67
106
|
databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
|
|
68
107
|
branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
|
|
69
|
-
|
|
70
|
-
|
|
108
|
+
deployPreview: Deno.env.get("XATA_PREVIEW"),
|
|
109
|
+
deployPreviewBranch: Deno.env.get("XATA_PREVIEW_BRANCH"),
|
|
110
|
+
vercelGitCommitRef: Deno.env.get("VERCEL_GIT_COMMIT_REF"),
|
|
111
|
+
vercelGitRepoOwner: Deno.env.get("VERCEL_GIT_REPO_OWNER")
|
|
71
112
|
};
|
|
72
113
|
}
|
|
73
114
|
} catch (err) {
|
|
@@ -76,10 +117,31 @@ function getEnvironment() {
|
|
|
76
117
|
apiKey: getGlobalApiKey(),
|
|
77
118
|
databaseURL: getGlobalDatabaseURL(),
|
|
78
119
|
branch: getGlobalBranch(),
|
|
79
|
-
|
|
80
|
-
|
|
120
|
+
deployPreview: void 0,
|
|
121
|
+
deployPreviewBranch: void 0,
|
|
122
|
+
vercelGitCommitRef: void 0,
|
|
123
|
+
vercelGitRepoOwner: void 0
|
|
81
124
|
};
|
|
82
125
|
}
|
|
126
|
+
function getEnableBrowserVariable() {
|
|
127
|
+
try {
|
|
128
|
+
if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
|
|
129
|
+
return process.env.XATA_ENABLE_BROWSER === "true";
|
|
130
|
+
}
|
|
131
|
+
} catch (err) {
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
|
|
135
|
+
return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
|
|
136
|
+
}
|
|
137
|
+
} catch (err) {
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
|
|
141
|
+
} catch (err) {
|
|
142
|
+
return void 0;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
83
145
|
function getGlobalApiKey() {
|
|
84
146
|
try {
|
|
85
147
|
return XATA_API_KEY;
|
|
@@ -101,44 +163,76 @@ function getGlobalBranch() {
|
|
|
101
163
|
return void 0;
|
|
102
164
|
}
|
|
103
165
|
}
|
|
104
|
-
function
|
|
166
|
+
function getDatabaseURL() {
|
|
105
167
|
try {
|
|
106
|
-
|
|
168
|
+
const { databaseURL } = getEnvironment();
|
|
169
|
+
return databaseURL;
|
|
107
170
|
} catch (err) {
|
|
108
171
|
return void 0;
|
|
109
172
|
}
|
|
110
173
|
}
|
|
111
|
-
|
|
112
|
-
const cmd = ["git", "branch", "--show-current"];
|
|
113
|
-
const fullCmd = cmd.join(" ");
|
|
114
|
-
const nodeModule = ["child", "process"].join("_");
|
|
115
|
-
const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
|
|
174
|
+
function getAPIKey() {
|
|
116
175
|
try {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
const { execSync } = await import(nodeModule);
|
|
121
|
-
return execSync(fullCmd, execOptions).toString().trim();
|
|
176
|
+
const { apiKey } = getEnvironment();
|
|
177
|
+
return apiKey;
|
|
122
178
|
} catch (err) {
|
|
179
|
+
return void 0;
|
|
123
180
|
}
|
|
181
|
+
}
|
|
182
|
+
function getBranch() {
|
|
124
183
|
try {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return new TextDecoder().decode(await process2.output()).trim();
|
|
128
|
-
}
|
|
184
|
+
const { branch } = getEnvironment();
|
|
185
|
+
return branch ?? "main";
|
|
129
186
|
} catch (err) {
|
|
187
|
+
return void 0;
|
|
130
188
|
}
|
|
131
189
|
}
|
|
132
|
-
|
|
133
|
-
|
|
190
|
+
function buildPreviewBranchName({ org, branch }) {
|
|
191
|
+
return `preview-${org}-${branch}`;
|
|
192
|
+
}
|
|
193
|
+
function getPreviewBranch() {
|
|
134
194
|
try {
|
|
135
|
-
const {
|
|
136
|
-
|
|
195
|
+
const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = getEnvironment();
|
|
196
|
+
if (deployPreviewBranch)
|
|
197
|
+
return deployPreviewBranch;
|
|
198
|
+
switch (deployPreview) {
|
|
199
|
+
case "vercel": {
|
|
200
|
+
if (!vercelGitCommitRef || !vercelGitRepoOwner) {
|
|
201
|
+
console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
|
|
202
|
+
return void 0;
|
|
203
|
+
}
|
|
204
|
+
return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return void 0;
|
|
137
208
|
} catch (err) {
|
|
138
209
|
return void 0;
|
|
139
210
|
}
|
|
140
211
|
}
|
|
141
212
|
|
|
213
|
+
var __accessCheck$8 = (obj, member, msg) => {
|
|
214
|
+
if (!member.has(obj))
|
|
215
|
+
throw TypeError("Cannot " + msg);
|
|
216
|
+
};
|
|
217
|
+
var __privateGet$8 = (obj, member, getter) => {
|
|
218
|
+
__accessCheck$8(obj, member, "read from private field");
|
|
219
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
220
|
+
};
|
|
221
|
+
var __privateAdd$8 = (obj, member, value) => {
|
|
222
|
+
if (member.has(obj))
|
|
223
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
224
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
225
|
+
};
|
|
226
|
+
var __privateSet$8 = (obj, member, value, setter) => {
|
|
227
|
+
__accessCheck$8(obj, member, "write to private field");
|
|
228
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
229
|
+
return value;
|
|
230
|
+
};
|
|
231
|
+
var __privateMethod$4 = (obj, member, method) => {
|
|
232
|
+
__accessCheck$8(obj, member, "access private method");
|
|
233
|
+
return method;
|
|
234
|
+
};
|
|
235
|
+
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
|
142
236
|
function getFetchImplementation(userFetch) {
|
|
143
237
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
|
144
238
|
const fetchImpl = userFetch ?? globalFetch;
|
|
@@ -149,8 +243,254 @@ function getFetchImplementation(userFetch) {
|
|
|
149
243
|
}
|
|
150
244
|
return fetchImpl;
|
|
151
245
|
}
|
|
246
|
+
class ApiRequestPool {
|
|
247
|
+
constructor(concurrency = 10) {
|
|
248
|
+
__privateAdd$8(this, _enqueue);
|
|
249
|
+
__privateAdd$8(this, _fetch, void 0);
|
|
250
|
+
__privateAdd$8(this, _queue, void 0);
|
|
251
|
+
__privateAdd$8(this, _concurrency, void 0);
|
|
252
|
+
__privateSet$8(this, _queue, []);
|
|
253
|
+
__privateSet$8(this, _concurrency, concurrency);
|
|
254
|
+
this.running = 0;
|
|
255
|
+
this.started = 0;
|
|
256
|
+
}
|
|
257
|
+
setFetch(fetch2) {
|
|
258
|
+
__privateSet$8(this, _fetch, fetch2);
|
|
259
|
+
}
|
|
260
|
+
getFetch() {
|
|
261
|
+
if (!__privateGet$8(this, _fetch)) {
|
|
262
|
+
throw new Error("Fetch not set");
|
|
263
|
+
}
|
|
264
|
+
return __privateGet$8(this, _fetch);
|
|
265
|
+
}
|
|
266
|
+
request(url, options) {
|
|
267
|
+
const start = new Date();
|
|
268
|
+
const fetch2 = this.getFetch();
|
|
269
|
+
const runRequest = async (stalled = false) => {
|
|
270
|
+
const response = await fetch2(url, options);
|
|
271
|
+
if (response.status === 429) {
|
|
272
|
+
const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
|
|
273
|
+
await timeout(rateLimitReset * 1e3);
|
|
274
|
+
return await runRequest(true);
|
|
275
|
+
}
|
|
276
|
+
if (stalled) {
|
|
277
|
+
const stalledTime = new Date().getTime() - start.getTime();
|
|
278
|
+
console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
|
|
279
|
+
}
|
|
280
|
+
return response;
|
|
281
|
+
};
|
|
282
|
+
return __privateMethod$4(this, _enqueue, enqueue_fn).call(this, async () => {
|
|
283
|
+
return await runRequest();
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
_fetch = new WeakMap();
|
|
288
|
+
_queue = new WeakMap();
|
|
289
|
+
_concurrency = new WeakMap();
|
|
290
|
+
_enqueue = new WeakSet();
|
|
291
|
+
enqueue_fn = function(task) {
|
|
292
|
+
const promise = new Promise((resolve) => __privateGet$8(this, _queue).push(resolve)).finally(() => {
|
|
293
|
+
this.started--;
|
|
294
|
+
this.running++;
|
|
295
|
+
}).then(() => task()).finally(() => {
|
|
296
|
+
this.running--;
|
|
297
|
+
const next = __privateGet$8(this, _queue).shift();
|
|
298
|
+
if (next !== void 0) {
|
|
299
|
+
this.started++;
|
|
300
|
+
next();
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
if (this.running + this.started < __privateGet$8(this, _concurrency)) {
|
|
304
|
+
const next = __privateGet$8(this, _queue).shift();
|
|
305
|
+
if (next !== void 0) {
|
|
306
|
+
this.started++;
|
|
307
|
+
next();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return promise;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
function generateUUID() {
|
|
314
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
315
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
316
|
+
return v.toString(16);
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
async function getBytes(stream, onChunk) {
|
|
321
|
+
const reader = stream.getReader();
|
|
322
|
+
let result;
|
|
323
|
+
while (!(result = await reader.read()).done) {
|
|
324
|
+
onChunk(result.value);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
function getLines(onLine) {
|
|
328
|
+
let buffer;
|
|
329
|
+
let position;
|
|
330
|
+
let fieldLength;
|
|
331
|
+
let discardTrailingNewline = false;
|
|
332
|
+
return function onChunk(arr) {
|
|
333
|
+
if (buffer === void 0) {
|
|
334
|
+
buffer = arr;
|
|
335
|
+
position = 0;
|
|
336
|
+
fieldLength = -1;
|
|
337
|
+
} else {
|
|
338
|
+
buffer = concat(buffer, arr);
|
|
339
|
+
}
|
|
340
|
+
const bufLength = buffer.length;
|
|
341
|
+
let lineStart = 0;
|
|
342
|
+
while (position < bufLength) {
|
|
343
|
+
if (discardTrailingNewline) {
|
|
344
|
+
if (buffer[position] === 10 /* NewLine */) {
|
|
345
|
+
lineStart = ++position;
|
|
346
|
+
}
|
|
347
|
+
discardTrailingNewline = false;
|
|
348
|
+
}
|
|
349
|
+
let lineEnd = -1;
|
|
350
|
+
for (; position < bufLength && lineEnd === -1; ++position) {
|
|
351
|
+
switch (buffer[position]) {
|
|
352
|
+
case 58 /* Colon */:
|
|
353
|
+
if (fieldLength === -1) {
|
|
354
|
+
fieldLength = position - lineStart;
|
|
355
|
+
}
|
|
356
|
+
break;
|
|
357
|
+
case 13 /* CarriageReturn */:
|
|
358
|
+
discardTrailingNewline = true;
|
|
359
|
+
case 10 /* NewLine */:
|
|
360
|
+
lineEnd = position;
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (lineEnd === -1) {
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
|
|
368
|
+
lineStart = position;
|
|
369
|
+
fieldLength = -1;
|
|
370
|
+
}
|
|
371
|
+
if (lineStart === bufLength) {
|
|
372
|
+
buffer = void 0;
|
|
373
|
+
} else if (lineStart !== 0) {
|
|
374
|
+
buffer = buffer.subarray(lineStart);
|
|
375
|
+
position -= lineStart;
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
function getMessages(onId, onRetry, onMessage) {
|
|
380
|
+
let message = newMessage();
|
|
381
|
+
const decoder = new TextDecoder();
|
|
382
|
+
return function onLine(line, fieldLength) {
|
|
383
|
+
if (line.length === 0) {
|
|
384
|
+
onMessage?.(message);
|
|
385
|
+
message = newMessage();
|
|
386
|
+
} else if (fieldLength > 0) {
|
|
387
|
+
const field = decoder.decode(line.subarray(0, fieldLength));
|
|
388
|
+
const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
|
|
389
|
+
const value = decoder.decode(line.subarray(valueOffset));
|
|
390
|
+
switch (field) {
|
|
391
|
+
case "data":
|
|
392
|
+
message.data = message.data ? message.data + "\n" + value : value;
|
|
393
|
+
break;
|
|
394
|
+
case "event":
|
|
395
|
+
message.event = value;
|
|
396
|
+
break;
|
|
397
|
+
case "id":
|
|
398
|
+
onId(message.id = value);
|
|
399
|
+
break;
|
|
400
|
+
case "retry":
|
|
401
|
+
const retry = parseInt(value, 10);
|
|
402
|
+
if (!isNaN(retry)) {
|
|
403
|
+
onRetry(message.retry = retry);
|
|
404
|
+
}
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
function concat(a, b) {
|
|
411
|
+
const res = new Uint8Array(a.length + b.length);
|
|
412
|
+
res.set(a);
|
|
413
|
+
res.set(b, a.length);
|
|
414
|
+
return res;
|
|
415
|
+
}
|
|
416
|
+
function newMessage() {
|
|
417
|
+
return {
|
|
418
|
+
data: "",
|
|
419
|
+
event: "",
|
|
420
|
+
id: "",
|
|
421
|
+
retry: void 0
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
const EventStreamContentType = "text/event-stream";
|
|
425
|
+
const LastEventId = "last-event-id";
|
|
426
|
+
function fetchEventSource(input, {
|
|
427
|
+
signal: inputSignal,
|
|
428
|
+
headers: inputHeaders,
|
|
429
|
+
onopen: inputOnOpen,
|
|
430
|
+
onmessage,
|
|
431
|
+
onclose,
|
|
432
|
+
onerror,
|
|
433
|
+
fetch: inputFetch,
|
|
434
|
+
...rest
|
|
435
|
+
}) {
|
|
436
|
+
return new Promise((resolve, reject) => {
|
|
437
|
+
const headers = { ...inputHeaders };
|
|
438
|
+
if (!headers.accept) {
|
|
439
|
+
headers.accept = EventStreamContentType;
|
|
440
|
+
}
|
|
441
|
+
let curRequestController;
|
|
442
|
+
function dispose() {
|
|
443
|
+
curRequestController.abort();
|
|
444
|
+
}
|
|
445
|
+
inputSignal?.addEventListener("abort", () => {
|
|
446
|
+
dispose();
|
|
447
|
+
resolve();
|
|
448
|
+
});
|
|
449
|
+
const fetchImpl = inputFetch ?? fetch;
|
|
450
|
+
const onopen = inputOnOpen ?? defaultOnOpen;
|
|
451
|
+
async function create() {
|
|
452
|
+
curRequestController = new AbortController();
|
|
453
|
+
try {
|
|
454
|
+
const response = await fetchImpl(input, {
|
|
455
|
+
...rest,
|
|
456
|
+
headers,
|
|
457
|
+
signal: curRequestController.signal
|
|
458
|
+
});
|
|
459
|
+
await onopen(response);
|
|
460
|
+
await getBytes(
|
|
461
|
+
response.body,
|
|
462
|
+
getLines(
|
|
463
|
+
getMessages(
|
|
464
|
+
(id) => {
|
|
465
|
+
if (id) {
|
|
466
|
+
headers[LastEventId] = id;
|
|
467
|
+
} else {
|
|
468
|
+
delete headers[LastEventId];
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
(_retry) => {
|
|
472
|
+
},
|
|
473
|
+
onmessage
|
|
474
|
+
)
|
|
475
|
+
)
|
|
476
|
+
);
|
|
477
|
+
onclose?.();
|
|
478
|
+
dispose();
|
|
479
|
+
resolve();
|
|
480
|
+
} catch (err) {
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
create();
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
function defaultOnOpen(response) {
|
|
487
|
+
const contentType = response.headers?.get("content-type");
|
|
488
|
+
if (!contentType?.startsWith(EventStreamContentType)) {
|
|
489
|
+
throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
152
492
|
|
|
153
|
-
const VERSION = "0.
|
|
493
|
+
const VERSION = "0.23.4";
|
|
154
494
|
|
|
155
495
|
class ErrorWithCause extends Error {
|
|
156
496
|
constructor(message, options) {
|
|
@@ -161,7 +501,7 @@ class FetcherError extends ErrorWithCause {
|
|
|
161
501
|
constructor(status, data, requestId) {
|
|
162
502
|
super(getMessage(data));
|
|
163
503
|
this.status = status;
|
|
164
|
-
this.errors = isBulkError(data) ? data.errors :
|
|
504
|
+
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
|
165
505
|
this.requestId = requestId;
|
|
166
506
|
if (data instanceof Error) {
|
|
167
507
|
this.stack = data.stack;
|
|
@@ -193,6 +533,7 @@ function getMessage(data) {
|
|
|
193
533
|
}
|
|
194
534
|
}
|
|
195
535
|
|
|
536
|
+
const pool = new ApiRequestPool();
|
|
196
537
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
197
538
|
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
|
198
539
|
if (value === void 0 || value === null)
|
|
@@ -207,64 +548,79 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
|
207
548
|
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
|
208
549
|
};
|
|
209
550
|
function buildBaseUrl({
|
|
551
|
+
endpoint,
|
|
210
552
|
path,
|
|
211
553
|
workspacesApiUrl,
|
|
212
554
|
apiUrl,
|
|
213
|
-
pathParams
|
|
555
|
+
pathParams = {}
|
|
214
556
|
}) {
|
|
215
|
-
if (
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
557
|
+
if (endpoint === "dataPlane") {
|
|
558
|
+
const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
|
559
|
+
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
|
560
|
+
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
|
561
|
+
}
|
|
562
|
+
return `${apiUrl}${path}`;
|
|
219
563
|
}
|
|
220
564
|
function hostHeader(url) {
|
|
221
565
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
|
222
566
|
const { groups } = pattern.exec(url) ?? {};
|
|
223
567
|
return groups?.host ? { Host: groups.host } : {};
|
|
224
568
|
}
|
|
569
|
+
const defaultClientID = generateUUID();
|
|
225
570
|
async function fetch$1({
|
|
226
571
|
url: path,
|
|
227
572
|
method,
|
|
228
573
|
body,
|
|
229
|
-
headers,
|
|
574
|
+
headers: customHeaders,
|
|
230
575
|
pathParams,
|
|
231
576
|
queryParams,
|
|
232
|
-
|
|
577
|
+
fetch: fetch2,
|
|
233
578
|
apiKey,
|
|
579
|
+
endpoint,
|
|
234
580
|
apiUrl,
|
|
235
581
|
workspacesApiUrl,
|
|
236
582
|
trace,
|
|
237
583
|
signal,
|
|
238
584
|
clientID,
|
|
239
|
-
sessionID
|
|
585
|
+
sessionID,
|
|
586
|
+
clientName,
|
|
587
|
+
xataAgentExtra,
|
|
588
|
+
fetchOptions = {}
|
|
240
589
|
}) {
|
|
241
|
-
|
|
590
|
+
pool.setFetch(fetch2);
|
|
591
|
+
return await trace(
|
|
242
592
|
`${method.toUpperCase()} ${path}`,
|
|
243
593
|
async ({ setAttributes }) => {
|
|
244
|
-
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
|
594
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
|
245
595
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
|
246
596
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
|
247
597
|
setAttributes({
|
|
248
598
|
[TraceAttributes.HTTP_URL]: url,
|
|
249
599
|
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
|
250
600
|
});
|
|
251
|
-
const
|
|
601
|
+
const xataAgent = compact([
|
|
602
|
+
["client", "TS_SDK"],
|
|
603
|
+
["version", VERSION],
|
|
604
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
|
605
|
+
...Object.entries(xataAgentExtra ?? {})
|
|
606
|
+
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
|
607
|
+
const headers = {
|
|
608
|
+
"Accept-Encoding": "identity",
|
|
609
|
+
"Content-Type": "application/json",
|
|
610
|
+
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
|
611
|
+
"X-Xata-Session-ID": sessionID ?? generateUUID(),
|
|
612
|
+
"X-Xata-Agent": xataAgent,
|
|
613
|
+
...customHeaders,
|
|
614
|
+
...hostHeader(fullUrl),
|
|
615
|
+
Authorization: `Bearer ${apiKey}`
|
|
616
|
+
};
|
|
617
|
+
const response = await pool.request(url, {
|
|
618
|
+
...fetchOptions,
|
|
252
619
|
method: method.toUpperCase(),
|
|
253
620
|
body: body ? JSON.stringify(body) : void 0,
|
|
254
|
-
headers
|
|
255
|
-
"Content-Type": "application/json",
|
|
256
|
-
"User-Agent": `Xata client-ts/${VERSION}`,
|
|
257
|
-
"X-Xata-Client-ID": clientID ?? "",
|
|
258
|
-
"X-Xata-Session-ID": sessionID ?? "",
|
|
259
|
-
...headers,
|
|
260
|
-
...hostHeader(fullUrl),
|
|
261
|
-
Authorization: `Bearer ${apiKey}`
|
|
262
|
-
},
|
|
621
|
+
headers,
|
|
263
622
|
signal
|
|
264
623
|
});
|
|
265
|
-
if (response.status === 204) {
|
|
266
|
-
return {};
|
|
267
|
-
}
|
|
268
624
|
const { host, protocol } = parseUrl(response.url);
|
|
269
625
|
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
|
270
626
|
setAttributes({
|
|
@@ -274,6 +630,12 @@ async function fetch$1({
|
|
|
274
630
|
[TraceAttributes.HTTP_HOST]: host,
|
|
275
631
|
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
|
276
632
|
});
|
|
633
|
+
if (response.status === 204) {
|
|
634
|
+
return {};
|
|
635
|
+
}
|
|
636
|
+
if (response.status === 429) {
|
|
637
|
+
throw new FetcherError(response.status, "Rate limit exceeded", requestId);
|
|
638
|
+
}
|
|
277
639
|
try {
|
|
278
640
|
const jsonResponse = await response.json();
|
|
279
641
|
if (response.ok) {
|
|
@@ -287,6 +649,59 @@ async function fetch$1({
|
|
|
287
649
|
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
|
288
650
|
);
|
|
289
651
|
}
|
|
652
|
+
function fetchSSERequest({
|
|
653
|
+
url: path,
|
|
654
|
+
method,
|
|
655
|
+
body,
|
|
656
|
+
headers: customHeaders,
|
|
657
|
+
pathParams,
|
|
658
|
+
queryParams,
|
|
659
|
+
fetch: fetch2,
|
|
660
|
+
apiKey,
|
|
661
|
+
endpoint,
|
|
662
|
+
apiUrl,
|
|
663
|
+
workspacesApiUrl,
|
|
664
|
+
onMessage,
|
|
665
|
+
onError,
|
|
666
|
+
onClose,
|
|
667
|
+
signal,
|
|
668
|
+
clientID,
|
|
669
|
+
sessionID,
|
|
670
|
+
clientName,
|
|
671
|
+
xataAgentExtra
|
|
672
|
+
}) {
|
|
673
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
|
674
|
+
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
|
675
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
|
676
|
+
void fetchEventSource(url, {
|
|
677
|
+
method,
|
|
678
|
+
body: JSON.stringify(body),
|
|
679
|
+
fetch: fetch2,
|
|
680
|
+
signal,
|
|
681
|
+
headers: {
|
|
682
|
+
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
|
683
|
+
"X-Xata-Session-ID": sessionID ?? generateUUID(),
|
|
684
|
+
"X-Xata-Agent": compact([
|
|
685
|
+
["client", "TS_SDK"],
|
|
686
|
+
["version", VERSION],
|
|
687
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
|
688
|
+
...Object.entries(xataAgentExtra ?? {})
|
|
689
|
+
]).map(([key, value]) => `${key}=${value}`).join("; "),
|
|
690
|
+
...customHeaders,
|
|
691
|
+
Authorization: `Bearer ${apiKey}`,
|
|
692
|
+
"Content-Type": "application/json"
|
|
693
|
+
},
|
|
694
|
+
onmessage(ev) {
|
|
695
|
+
onMessage?.(JSON.parse(ev.data));
|
|
696
|
+
},
|
|
697
|
+
onerror(ev) {
|
|
698
|
+
onError?.(JSON.parse(ev.data));
|
|
699
|
+
},
|
|
700
|
+
onclose() {
|
|
701
|
+
onClose?.();
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
}
|
|
290
705
|
function parseUrl(url) {
|
|
291
706
|
try {
|
|
292
707
|
const { host, protocol } = new URL(url);
|
|
@@ -296,415 +711,415 @@ function parseUrl(url) {
|
|
|
296
711
|
}
|
|
297
712
|
}
|
|
298
713
|
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
...variables,
|
|
304
|
-
signal
|
|
305
|
-
});
|
|
306
|
-
const deleteUser = (variables, signal) => fetch$1({ url: "/user", method: "delete", ...variables, signal });
|
|
307
|
-
const getUserAPIKeys = (variables, signal) => fetch$1({
|
|
308
|
-
url: "/user/keys",
|
|
714
|
+
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
|
715
|
+
|
|
716
|
+
const getBranchList = (variables, signal) => dataPlaneFetch({
|
|
717
|
+
url: "/dbs/{dbName}",
|
|
309
718
|
method: "get",
|
|
310
719
|
...variables,
|
|
311
720
|
signal
|
|
312
721
|
});
|
|
313
|
-
const
|
|
314
|
-
url: "/
|
|
315
|
-
method: "
|
|
722
|
+
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
|
723
|
+
url: "/db/{dbBranchName}",
|
|
724
|
+
method: "get",
|
|
316
725
|
...variables,
|
|
317
726
|
signal
|
|
318
727
|
});
|
|
319
|
-
const
|
|
320
|
-
|
|
728
|
+
const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
|
|
729
|
+
const deleteBranch = (variables, signal) => dataPlaneFetch({
|
|
730
|
+
url: "/db/{dbBranchName}",
|
|
321
731
|
method: "delete",
|
|
322
732
|
...variables,
|
|
323
733
|
signal
|
|
324
734
|
});
|
|
325
|
-
const
|
|
326
|
-
url: "/
|
|
735
|
+
const copyBranch = (variables, signal) => dataPlaneFetch({
|
|
736
|
+
url: "/db/{dbBranchName}/copy",
|
|
327
737
|
method: "post",
|
|
328
738
|
...variables,
|
|
329
739
|
signal
|
|
330
740
|
});
|
|
331
|
-
const
|
|
332
|
-
url: "/
|
|
333
|
-
method: "get",
|
|
334
|
-
...variables,
|
|
335
|
-
signal
|
|
336
|
-
});
|
|
337
|
-
const getWorkspace = (variables, signal) => fetch$1({
|
|
338
|
-
url: "/workspaces/{workspaceId}",
|
|
339
|
-
method: "get",
|
|
340
|
-
...variables,
|
|
341
|
-
signal
|
|
342
|
-
});
|
|
343
|
-
const updateWorkspace = (variables, signal) => fetch$1({
|
|
344
|
-
url: "/workspaces/{workspaceId}",
|
|
741
|
+
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
|
742
|
+
url: "/db/{dbBranchName}/metadata",
|
|
345
743
|
method: "put",
|
|
346
744
|
...variables,
|
|
347
745
|
signal
|
|
348
746
|
});
|
|
349
|
-
const
|
|
350
|
-
url: "/
|
|
351
|
-
method: "delete",
|
|
352
|
-
...variables,
|
|
353
|
-
signal
|
|
354
|
-
});
|
|
355
|
-
const getWorkspaceMembersList = (variables, signal) => fetch$1({
|
|
356
|
-
url: "/workspaces/{workspaceId}/members",
|
|
747
|
+
const getBranchMetadata = (variables, signal) => dataPlaneFetch({
|
|
748
|
+
url: "/db/{dbBranchName}/metadata",
|
|
357
749
|
method: "get",
|
|
358
750
|
...variables,
|
|
359
751
|
signal
|
|
360
752
|
});
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
method: "delete",
|
|
365
|
-
...variables,
|
|
366
|
-
signal
|
|
367
|
-
});
|
|
368
|
-
const inviteWorkspaceMember = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
|
|
369
|
-
const updateWorkspaceMemberInvite = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
|
|
370
|
-
const cancelWorkspaceMemberInvite = (variables, signal) => fetch$1({
|
|
371
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
|
372
|
-
method: "delete",
|
|
373
|
-
...variables,
|
|
374
|
-
signal
|
|
375
|
-
});
|
|
376
|
-
const resendWorkspaceMemberInvite = (variables, signal) => fetch$1({
|
|
377
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
|
|
378
|
-
method: "post",
|
|
379
|
-
...variables,
|
|
380
|
-
signal
|
|
381
|
-
});
|
|
382
|
-
const acceptWorkspaceMemberInvite = (variables, signal) => fetch$1({
|
|
383
|
-
url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
|
|
384
|
-
method: "post",
|
|
753
|
+
const getBranchStats = (variables, signal) => dataPlaneFetch({
|
|
754
|
+
url: "/db/{dbBranchName}/stats",
|
|
755
|
+
method: "get",
|
|
385
756
|
...variables,
|
|
386
757
|
signal
|
|
387
758
|
});
|
|
388
|
-
const
|
|
389
|
-
|
|
759
|
+
const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
|
|
760
|
+
const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
|
|
761
|
+
const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
|
|
762
|
+
const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
|
|
763
|
+
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
|
764
|
+
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
|
765
|
+
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
|
766
|
+
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
|
767
|
+
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
|
768
|
+
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
|
769
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
|
390
770
|
method: "get",
|
|
391
771
|
...variables,
|
|
392
772
|
signal
|
|
393
773
|
});
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
774
|
+
const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
|
|
775
|
+
const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
|
|
776
|
+
const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
|
|
777
|
+
const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
|
|
778
|
+
const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
|
|
779
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
|
780
|
+
method: "post",
|
|
397
781
|
...variables,
|
|
398
782
|
signal
|
|
399
783
|
});
|
|
400
|
-
const
|
|
401
|
-
|
|
784
|
+
const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
|
|
785
|
+
const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
|
|
786
|
+
const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
|
|
787
|
+
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
|
788
|
+
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
|
789
|
+
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
|
790
|
+
const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
|
|
791
|
+
const createTable = (variables, signal) => dataPlaneFetch({
|
|
792
|
+
url: "/db/{dbBranchName}/tables/{tableName}",
|
|
402
793
|
method: "put",
|
|
403
794
|
...variables,
|
|
404
795
|
signal
|
|
405
796
|
});
|
|
406
|
-
const
|
|
407
|
-
url: "/
|
|
797
|
+
const deleteTable = (variables, signal) => dataPlaneFetch({
|
|
798
|
+
url: "/db/{dbBranchName}/tables/{tableName}",
|
|
408
799
|
method: "delete",
|
|
409
800
|
...variables,
|
|
410
801
|
signal
|
|
411
802
|
});
|
|
412
|
-
const
|
|
413
|
-
|
|
803
|
+
const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
|
|
804
|
+
const getTableSchema = (variables, signal) => dataPlaneFetch({
|
|
805
|
+
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
|
414
806
|
method: "get",
|
|
415
807
|
...variables,
|
|
416
808
|
signal
|
|
417
809
|
});
|
|
418
|
-
const
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
const removeGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
|
|
422
|
-
const resolveBranch = (variables, signal) => fetch$1({
|
|
423
|
-
url: "/dbs/{dbName}/resolveBranch",
|
|
810
|
+
const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
|
|
811
|
+
const getTableColumns = (variables, signal) => dataPlaneFetch({
|
|
812
|
+
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
|
424
813
|
method: "get",
|
|
425
814
|
...variables,
|
|
426
815
|
signal
|
|
427
816
|
});
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
817
|
+
const addTableColumn = (variables, signal) => dataPlaneFetch(
|
|
818
|
+
{ url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
|
|
819
|
+
);
|
|
820
|
+
const getColumn = (variables, signal) => dataPlaneFetch({
|
|
821
|
+
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
|
432
822
|
method: "get",
|
|
433
823
|
...variables,
|
|
434
824
|
signal
|
|
435
825
|
});
|
|
436
|
-
const
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
const mergeMigrationRequest = (variables, signal) => fetch$1({
|
|
441
|
-
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
|
442
|
-
method: "post",
|
|
826
|
+
const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
|
|
827
|
+
const deleteColumn = (variables, signal) => dataPlaneFetch({
|
|
828
|
+
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
|
829
|
+
method: "delete",
|
|
443
830
|
...variables,
|
|
444
831
|
signal
|
|
445
832
|
});
|
|
446
|
-
const
|
|
447
|
-
|
|
833
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
|
834
|
+
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
|
835
|
+
const getFileItem = (variables, signal) => dataPlaneFetch({
|
|
836
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
|
448
837
|
method: "get",
|
|
449
838
|
...variables,
|
|
450
839
|
signal
|
|
451
840
|
});
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
url: "/db/{dbBranchName}",
|
|
455
|
-
method: "delete",
|
|
456
|
-
...variables,
|
|
457
|
-
signal
|
|
458
|
-
});
|
|
459
|
-
const updateBranchMetadata = (variables, signal) => fetch$1({
|
|
460
|
-
url: "/db/{dbBranchName}/metadata",
|
|
841
|
+
const putFileItem = (variables, signal) => dataPlaneFetch({
|
|
842
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
|
461
843
|
method: "put",
|
|
462
844
|
...variables,
|
|
463
845
|
signal
|
|
464
846
|
});
|
|
465
|
-
const
|
|
466
|
-
url: "/db/{dbBranchName}/
|
|
467
|
-
method: "
|
|
468
|
-
...variables,
|
|
469
|
-
signal
|
|
470
|
-
});
|
|
471
|
-
const getBranchMigrationHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
|
472
|
-
const executeBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
|
473
|
-
const getBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
|
474
|
-
const compareBranchWithUserSchema = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
|
|
475
|
-
const compareBranchSchemas = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
|
|
476
|
-
const updateBranchSchema = (variables, signal) => fetch$1({
|
|
477
|
-
url: "/db/{dbBranchName}/schema/update",
|
|
478
|
-
method: "post",
|
|
847
|
+
const deleteFileItem = (variables, signal) => dataPlaneFetch({
|
|
848
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
|
849
|
+
method: "delete",
|
|
479
850
|
...variables,
|
|
480
851
|
signal
|
|
481
852
|
});
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
const getBranchSchemaHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
|
|
485
|
-
const getBranchStats = (variables, signal) => fetch$1({
|
|
486
|
-
url: "/db/{dbBranchName}/stats",
|
|
853
|
+
const getFile = (variables, signal) => dataPlaneFetch({
|
|
854
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
|
487
855
|
method: "get",
|
|
488
856
|
...variables,
|
|
489
857
|
signal
|
|
490
858
|
});
|
|
491
|
-
const
|
|
492
|
-
url: "/db/{dbBranchName}/tables/{tableName}",
|
|
859
|
+
const putFile = (variables, signal) => dataPlaneFetch({
|
|
860
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
|
493
861
|
method: "put",
|
|
494
862
|
...variables,
|
|
495
863
|
signal
|
|
496
864
|
});
|
|
497
|
-
const
|
|
498
|
-
url: "/db/{dbBranchName}/tables/{tableName}",
|
|
499
|
-
method: "delete",
|
|
500
|
-
...variables,
|
|
501
|
-
signal
|
|
502
|
-
});
|
|
503
|
-
const updateTable = (variables, signal) => fetch$1({
|
|
504
|
-
url: "/db/{dbBranchName}/tables/{tableName}",
|
|
505
|
-
method: "patch",
|
|
506
|
-
...variables,
|
|
507
|
-
signal
|
|
508
|
-
});
|
|
509
|
-
const getTableSchema = (variables, signal) => fetch$1({
|
|
510
|
-
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
|
865
|
+
const getRecord = (variables, signal) => dataPlaneFetch({
|
|
866
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
|
511
867
|
method: "get",
|
|
512
868
|
...variables,
|
|
513
869
|
signal
|
|
514
870
|
});
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
method: "get",
|
|
871
|
+
const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
|
|
872
|
+
const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
|
|
873
|
+
const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
|
|
874
|
+
const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
|
|
875
|
+
const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
|
|
876
|
+
const queryTable = (variables, signal) => dataPlaneFetch({
|
|
877
|
+
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
|
878
|
+
method: "post",
|
|
524
879
|
...variables,
|
|
525
880
|
signal
|
|
526
881
|
});
|
|
527
|
-
const
|
|
528
|
-
url: "/db/{dbBranchName}/
|
|
882
|
+
const searchBranch = (variables, signal) => dataPlaneFetch({
|
|
883
|
+
url: "/db/{dbBranchName}/search",
|
|
529
884
|
method: "post",
|
|
530
885
|
...variables,
|
|
531
886
|
signal
|
|
532
887
|
});
|
|
533
|
-
const
|
|
534
|
-
url: "/db/{dbBranchName}/tables/{tableName}/
|
|
535
|
-
method: "
|
|
888
|
+
const searchTable = (variables, signal) => dataPlaneFetch({
|
|
889
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
|
890
|
+
method: "post",
|
|
536
891
|
...variables,
|
|
537
892
|
signal
|
|
538
893
|
});
|
|
539
|
-
const
|
|
540
|
-
url: "/db/{dbBranchName}/
|
|
541
|
-
method: "
|
|
894
|
+
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
|
895
|
+
url: "/db/{dbBranchName}/sql",
|
|
896
|
+
method: "post",
|
|
542
897
|
...variables,
|
|
543
898
|
signal
|
|
544
899
|
});
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
|
|
900
|
+
const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
|
|
901
|
+
const askTable = (variables, signal) => dataPlaneFetch({
|
|
902
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
|
903
|
+
method: "post",
|
|
548
904
|
...variables,
|
|
549
905
|
signal
|
|
550
906
|
});
|
|
551
|
-
const
|
|
552
|
-
const
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
907
|
+
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
|
908
|
+
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
|
909
|
+
const operationsByTag$2 = {
|
|
910
|
+
branch: {
|
|
911
|
+
getBranchList,
|
|
912
|
+
getBranchDetails,
|
|
913
|
+
createBranch,
|
|
914
|
+
deleteBranch,
|
|
915
|
+
copyBranch,
|
|
916
|
+
updateBranchMetadata,
|
|
917
|
+
getBranchMetadata,
|
|
918
|
+
getBranchStats,
|
|
919
|
+
getGitBranchesMapping,
|
|
920
|
+
addGitBranchesEntry,
|
|
921
|
+
removeGitBranchesEntry,
|
|
922
|
+
resolveBranch
|
|
923
|
+
},
|
|
924
|
+
migrations: {
|
|
925
|
+
getBranchMigrationHistory,
|
|
926
|
+
getBranchMigrationPlan,
|
|
927
|
+
executeBranchMigrationPlan,
|
|
928
|
+
getBranchSchemaHistory,
|
|
929
|
+
compareBranchWithUserSchema,
|
|
930
|
+
compareBranchSchemas,
|
|
931
|
+
updateBranchSchema,
|
|
932
|
+
previewBranchSchemaEdit,
|
|
933
|
+
applyBranchSchemaEdit,
|
|
934
|
+
pushBranchMigrations
|
|
935
|
+
},
|
|
936
|
+
migrationRequests: {
|
|
937
|
+
queryMigrationRequests,
|
|
938
|
+
createMigrationRequest,
|
|
939
|
+
getMigrationRequest,
|
|
940
|
+
updateMigrationRequest,
|
|
941
|
+
listMigrationRequestsCommits,
|
|
942
|
+
compareMigrationRequest,
|
|
943
|
+
getMigrationRequestIsMerged,
|
|
944
|
+
mergeMigrationRequest
|
|
945
|
+
},
|
|
946
|
+
table: {
|
|
947
|
+
createTable,
|
|
948
|
+
deleteTable,
|
|
949
|
+
updateTable,
|
|
950
|
+
getTableSchema,
|
|
951
|
+
setTableSchema,
|
|
952
|
+
getTableColumns,
|
|
953
|
+
addTableColumn,
|
|
954
|
+
getColumn,
|
|
955
|
+
updateColumn,
|
|
956
|
+
deleteColumn
|
|
957
|
+
},
|
|
958
|
+
records: {
|
|
959
|
+
branchTransaction,
|
|
960
|
+
insertRecord,
|
|
961
|
+
getRecord,
|
|
962
|
+
insertRecordWithID,
|
|
963
|
+
updateRecordWithID,
|
|
964
|
+
upsertRecordWithID,
|
|
965
|
+
deleteRecord,
|
|
966
|
+
bulkInsertTableRecords
|
|
967
|
+
},
|
|
968
|
+
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile },
|
|
969
|
+
searchAndFilter: {
|
|
970
|
+
queryTable,
|
|
971
|
+
searchBranch,
|
|
972
|
+
searchTable,
|
|
973
|
+
sqlQuery,
|
|
974
|
+
vectorSearchTable,
|
|
975
|
+
askTable,
|
|
976
|
+
summarizeTable,
|
|
977
|
+
aggregateTable
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
|
|
981
|
+
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
|
982
|
+
|
|
983
|
+
const getUser = (variables, signal) => controlPlaneFetch({
|
|
984
|
+
url: "/user",
|
|
985
|
+
method: "get",
|
|
986
|
+
...variables,
|
|
987
|
+
signal
|
|
988
|
+
});
|
|
989
|
+
const updateUser = (variables, signal) => controlPlaneFetch({
|
|
990
|
+
url: "/user",
|
|
991
|
+
method: "put",
|
|
992
|
+
...variables,
|
|
993
|
+
signal
|
|
994
|
+
});
|
|
995
|
+
const deleteUser = (variables, signal) => controlPlaneFetch({
|
|
996
|
+
url: "/user",
|
|
557
997
|
method: "delete",
|
|
558
998
|
...variables,
|
|
559
999
|
signal
|
|
560
1000
|
});
|
|
561
|
-
const
|
|
562
|
-
url: "/
|
|
1001
|
+
const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
|
|
1002
|
+
url: "/user/keys",
|
|
563
1003
|
method: "get",
|
|
564
1004
|
...variables,
|
|
565
1005
|
signal
|
|
566
1006
|
});
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
|
1007
|
+
const createUserAPIKey = (variables, signal) => controlPlaneFetch({
|
|
1008
|
+
url: "/user/keys/{keyName}",
|
|
570
1009
|
method: "post",
|
|
571
1010
|
...variables,
|
|
572
1011
|
signal
|
|
573
1012
|
});
|
|
574
|
-
const
|
|
575
|
-
url: "/
|
|
576
|
-
method: "
|
|
1013
|
+
const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
|
1014
|
+
url: "/user/keys/{keyName}",
|
|
1015
|
+
method: "delete",
|
|
577
1016
|
...variables,
|
|
578
1017
|
signal
|
|
579
1018
|
});
|
|
580
|
-
const
|
|
581
|
-
url: "/
|
|
582
|
-
method: "
|
|
1019
|
+
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
|
1020
|
+
url: "/workspaces",
|
|
1021
|
+
method: "get",
|
|
583
1022
|
...variables,
|
|
584
1023
|
signal
|
|
585
1024
|
});
|
|
586
|
-
const
|
|
587
|
-
url: "/
|
|
1025
|
+
const createWorkspace = (variables, signal) => controlPlaneFetch({
|
|
1026
|
+
url: "/workspaces",
|
|
588
1027
|
method: "post",
|
|
589
1028
|
...variables,
|
|
590
1029
|
signal
|
|
591
1030
|
});
|
|
592
|
-
const
|
|
593
|
-
url: "/
|
|
594
|
-
method: "
|
|
1031
|
+
const getWorkspace = (variables, signal) => controlPlaneFetch({
|
|
1032
|
+
url: "/workspaces/{workspaceId}",
|
|
1033
|
+
method: "get",
|
|
1034
|
+
...variables,
|
|
1035
|
+
signal
|
|
1036
|
+
});
|
|
1037
|
+
const updateWorkspace = (variables, signal) => controlPlaneFetch({
|
|
1038
|
+
url: "/workspaces/{workspaceId}",
|
|
1039
|
+
method: "put",
|
|
595
1040
|
...variables,
|
|
596
1041
|
signal
|
|
597
1042
|
});
|
|
598
|
-
const
|
|
1043
|
+
const deleteWorkspace = (variables, signal) => controlPlaneFetch({
|
|
1044
|
+
url: "/workspaces/{workspaceId}",
|
|
1045
|
+
method: "delete",
|
|
1046
|
+
...variables,
|
|
1047
|
+
signal
|
|
1048
|
+
});
|
|
1049
|
+
const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
|
|
1050
|
+
const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
|
|
1051
|
+
const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
|
1052
|
+
url: "/workspaces/{workspaceId}/members/{userId}",
|
|
1053
|
+
method: "delete",
|
|
1054
|
+
...variables,
|
|
1055
|
+
signal
|
|
1056
|
+
});
|
|
1057
|
+
const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
|
|
1058
|
+
const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
|
|
1059
|
+
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
|
1060
|
+
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
|
1061
|
+
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
|
1062
|
+
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
|
599
1063
|
url: "/workspaces/{workspaceId}/dbs",
|
|
600
1064
|
method: "get",
|
|
601
1065
|
...variables,
|
|
602
1066
|
signal
|
|
603
1067
|
});
|
|
604
|
-
const
|
|
605
|
-
const
|
|
1068
|
+
const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
|
|
1069
|
+
const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
|
606
1070
|
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
|
607
1071
|
method: "delete",
|
|
608
1072
|
...variables,
|
|
609
1073
|
signal
|
|
610
1074
|
});
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
);
|
|
614
|
-
const
|
|
615
|
-
const
|
|
616
|
-
|
|
1075
|
+
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
|
1076
|
+
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
|
1077
|
+
const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
|
|
1078
|
+
const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
|
|
1079
|
+
const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
|
|
1080
|
+
const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
|
|
1081
|
+
const listRegions = (variables, signal) => controlPlaneFetch({
|
|
1082
|
+
url: "/workspaces/{workspaceId}/regions",
|
|
1083
|
+
method: "get",
|
|
1084
|
+
...variables,
|
|
1085
|
+
signal
|
|
1086
|
+
});
|
|
1087
|
+
const operationsByTag$1 = {
|
|
1088
|
+
users: { getUser, updateUser, deleteUser },
|
|
1089
|
+
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
|
617
1090
|
workspaces: {
|
|
618
|
-
createWorkspace,
|
|
619
1091
|
getWorkspacesList,
|
|
1092
|
+
createWorkspace,
|
|
620
1093
|
getWorkspace,
|
|
621
1094
|
updateWorkspace,
|
|
622
1095
|
deleteWorkspace,
|
|
623
1096
|
getWorkspaceMembersList,
|
|
624
1097
|
updateWorkspaceMemberRole,
|
|
625
|
-
removeWorkspaceMember
|
|
1098
|
+
removeWorkspaceMember
|
|
1099
|
+
},
|
|
1100
|
+
invites: {
|
|
626
1101
|
inviteWorkspaceMember,
|
|
627
1102
|
updateWorkspaceMemberInvite,
|
|
628
1103
|
cancelWorkspaceMemberInvite,
|
|
629
|
-
|
|
630
|
-
|
|
1104
|
+
acceptWorkspaceMemberInvite,
|
|
1105
|
+
resendWorkspaceMemberInvite
|
|
631
1106
|
},
|
|
632
|
-
|
|
1107
|
+
databases: {
|
|
633
1108
|
getDatabaseList,
|
|
634
1109
|
createDatabase,
|
|
635
1110
|
deleteDatabase,
|
|
636
1111
|
getDatabaseMetadata,
|
|
637
1112
|
updateDatabaseMetadata,
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
branch: {
|
|
644
|
-
getBranchList,
|
|
645
|
-
getBranchDetails,
|
|
646
|
-
createBranch,
|
|
647
|
-
deleteBranch,
|
|
648
|
-
updateBranchMetadata,
|
|
649
|
-
getBranchMetadata,
|
|
650
|
-
getBranchStats
|
|
651
|
-
},
|
|
652
|
-
migrationRequests: {
|
|
653
|
-
queryMigrationRequests,
|
|
654
|
-
createMigrationRequest,
|
|
655
|
-
getMigrationRequest,
|
|
656
|
-
updateMigrationRequest,
|
|
657
|
-
listMigrationRequestsCommits,
|
|
658
|
-
compareMigrationRequest,
|
|
659
|
-
getMigrationRequestIsMerged,
|
|
660
|
-
mergeMigrationRequest
|
|
661
|
-
},
|
|
662
|
-
branchSchema: {
|
|
663
|
-
getBranchMigrationHistory,
|
|
664
|
-
executeBranchMigrationPlan,
|
|
665
|
-
getBranchMigrationPlan,
|
|
666
|
-
compareBranchWithUserSchema,
|
|
667
|
-
compareBranchSchemas,
|
|
668
|
-
updateBranchSchema,
|
|
669
|
-
previewBranchSchemaEdit,
|
|
670
|
-
applyBranchSchemaEdit,
|
|
671
|
-
getBranchSchemaHistory
|
|
672
|
-
},
|
|
673
|
-
table: {
|
|
674
|
-
createTable,
|
|
675
|
-
deleteTable,
|
|
676
|
-
updateTable,
|
|
677
|
-
getTableSchema,
|
|
678
|
-
setTableSchema,
|
|
679
|
-
getTableColumns,
|
|
680
|
-
addTableColumn,
|
|
681
|
-
getColumn,
|
|
682
|
-
deleteColumn,
|
|
683
|
-
updateColumn
|
|
684
|
-
},
|
|
685
|
-
records: {
|
|
686
|
-
insertRecord,
|
|
687
|
-
insertRecordWithID,
|
|
688
|
-
updateRecordWithID,
|
|
689
|
-
upsertRecordWithID,
|
|
690
|
-
deleteRecord,
|
|
691
|
-
getRecord,
|
|
692
|
-
bulkInsertTableRecords,
|
|
693
|
-
queryTable,
|
|
694
|
-
searchTable,
|
|
695
|
-
searchBranch,
|
|
696
|
-
summarizeTable,
|
|
697
|
-
aggregateTable
|
|
698
|
-
},
|
|
699
|
-
databases: {
|
|
700
|
-
cPGetDatabaseList,
|
|
701
|
-
cPCreateDatabase,
|
|
702
|
-
cPDeleteDatabase,
|
|
703
|
-
cPGetCPDatabaseMetadata,
|
|
704
|
-
cPUpdateCPDatabaseMetadata
|
|
1113
|
+
renameDatabase,
|
|
1114
|
+
getDatabaseGithubSettings,
|
|
1115
|
+
updateDatabaseGithubSettings,
|
|
1116
|
+
deleteDatabaseGithubSettings,
|
|
1117
|
+
listRegions
|
|
705
1118
|
}
|
|
706
1119
|
};
|
|
707
1120
|
|
|
1121
|
+
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
|
1122
|
+
|
|
708
1123
|
function getHostUrl(provider, type) {
|
|
709
1124
|
if (isHostProviderAlias(provider)) {
|
|
710
1125
|
return providers[provider][type];
|
|
@@ -716,11 +1131,15 @@ function getHostUrl(provider, type) {
|
|
|
716
1131
|
const providers = {
|
|
717
1132
|
production: {
|
|
718
1133
|
main: "https://api.xata.io",
|
|
719
|
-
workspaces: "https://{workspaceId}.xata.sh"
|
|
1134
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
|
720
1135
|
},
|
|
721
1136
|
staging: {
|
|
722
|
-
main: "https://staging.
|
|
723
|
-
workspaces: "https://{workspaceId}.staging.
|
|
1137
|
+
main: "https://api.staging-xata.dev",
|
|
1138
|
+
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
|
1139
|
+
},
|
|
1140
|
+
dev: {
|
|
1141
|
+
main: "https://api.dev-xata.dev",
|
|
1142
|
+
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
|
724
1143
|
}
|
|
725
1144
|
};
|
|
726
1145
|
function isHostProviderAlias(alias) {
|
|
@@ -738,6 +1157,23 @@ function parseProviderString(provider = "production") {
|
|
|
738
1157
|
return null;
|
|
739
1158
|
return { main, workspaces };
|
|
740
1159
|
}
|
|
1160
|
+
function buildProviderString(provider) {
|
|
1161
|
+
if (isHostProviderAlias(provider))
|
|
1162
|
+
return provider;
|
|
1163
|
+
return `${provider.main},${provider.workspaces}`;
|
|
1164
|
+
}
|
|
1165
|
+
function parseWorkspacesUrlParts(url) {
|
|
1166
|
+
if (!isString(url))
|
|
1167
|
+
return null;
|
|
1168
|
+
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
|
1169
|
+
const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
|
|
1170
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
|
|
1171
|
+
const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
|
|
1172
|
+
const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
|
|
1173
|
+
if (!match)
|
|
1174
|
+
return null;
|
|
1175
|
+
return { workspace: match[1], region: match[2] };
|
|
1176
|
+
}
|
|
741
1177
|
|
|
742
1178
|
var __accessCheck$7 = (obj, member, msg) => {
|
|
743
1179
|
if (!member.has(obj))
|
|
@@ -765,15 +1201,19 @@ class XataApiClient {
|
|
|
765
1201
|
const provider = options.host ?? "production";
|
|
766
1202
|
const apiKey = options.apiKey ?? getAPIKey();
|
|
767
1203
|
const trace = options.trace ?? defaultTrace;
|
|
1204
|
+
const clientID = generateUUID();
|
|
768
1205
|
if (!apiKey) {
|
|
769
1206
|
throw new Error("Could not resolve a valid apiKey");
|
|
770
1207
|
}
|
|
771
1208
|
__privateSet$7(this, _extraProps, {
|
|
772
1209
|
apiUrl: getHostUrl(provider, "main"),
|
|
773
1210
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
|
774
|
-
|
|
1211
|
+
fetch: getFetchImplementation(options.fetch),
|
|
775
1212
|
apiKey,
|
|
776
|
-
trace
|
|
1213
|
+
trace,
|
|
1214
|
+
clientName: options.clientName,
|
|
1215
|
+
xataAgentExtra: options.xataAgentExtra,
|
|
1216
|
+
clientID
|
|
777
1217
|
});
|
|
778
1218
|
}
|
|
779
1219
|
get user() {
|
|
@@ -781,21 +1221,41 @@ class XataApiClient {
|
|
|
781
1221
|
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
|
782
1222
|
return __privateGet$7(this, _namespaces).user;
|
|
783
1223
|
}
|
|
1224
|
+
get authentication() {
|
|
1225
|
+
if (!__privateGet$7(this, _namespaces).authentication)
|
|
1226
|
+
__privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
|
|
1227
|
+
return __privateGet$7(this, _namespaces).authentication;
|
|
1228
|
+
}
|
|
784
1229
|
get workspaces() {
|
|
785
1230
|
if (!__privateGet$7(this, _namespaces).workspaces)
|
|
786
1231
|
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
|
787
1232
|
return __privateGet$7(this, _namespaces).workspaces;
|
|
788
1233
|
}
|
|
789
|
-
get
|
|
790
|
-
if (!__privateGet$7(this, _namespaces).
|
|
791
|
-
__privateGet$7(this, _namespaces).
|
|
792
|
-
return __privateGet$7(this, _namespaces).
|
|
1234
|
+
get invites() {
|
|
1235
|
+
if (!__privateGet$7(this, _namespaces).invites)
|
|
1236
|
+
__privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
|
|
1237
|
+
return __privateGet$7(this, _namespaces).invites;
|
|
1238
|
+
}
|
|
1239
|
+
get database() {
|
|
1240
|
+
if (!__privateGet$7(this, _namespaces).database)
|
|
1241
|
+
__privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
|
|
1242
|
+
return __privateGet$7(this, _namespaces).database;
|
|
793
1243
|
}
|
|
794
1244
|
get branches() {
|
|
795
1245
|
if (!__privateGet$7(this, _namespaces).branches)
|
|
796
1246
|
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
|
797
1247
|
return __privateGet$7(this, _namespaces).branches;
|
|
798
1248
|
}
|
|
1249
|
+
get migrations() {
|
|
1250
|
+
if (!__privateGet$7(this, _namespaces).migrations)
|
|
1251
|
+
__privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
|
|
1252
|
+
return __privateGet$7(this, _namespaces).migrations;
|
|
1253
|
+
}
|
|
1254
|
+
get migrationRequests() {
|
|
1255
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
|
1256
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
|
1257
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
|
1258
|
+
}
|
|
799
1259
|
get tables() {
|
|
800
1260
|
if (!__privateGet$7(this, _namespaces).tables)
|
|
801
1261
|
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
|
@@ -806,15 +1266,15 @@ class XataApiClient {
|
|
|
806
1266
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
|
807
1267
|
return __privateGet$7(this, _namespaces).records;
|
|
808
1268
|
}
|
|
809
|
-
get
|
|
810
|
-
if (!__privateGet$7(this, _namespaces).
|
|
811
|
-
__privateGet$7(this, _namespaces).
|
|
812
|
-
return __privateGet$7(this, _namespaces).
|
|
1269
|
+
get files() {
|
|
1270
|
+
if (!__privateGet$7(this, _namespaces).files)
|
|
1271
|
+
__privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
|
|
1272
|
+
return __privateGet$7(this, _namespaces).files;
|
|
813
1273
|
}
|
|
814
|
-
get
|
|
815
|
-
if (!__privateGet$7(this, _namespaces).
|
|
816
|
-
__privateGet$7(this, _namespaces).
|
|
817
|
-
return __privateGet$7(this, _namespaces).
|
|
1274
|
+
get searchAndFilter() {
|
|
1275
|
+
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
|
1276
|
+
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
|
1277
|
+
return __privateGet$7(this, _namespaces).searchAndFilter;
|
|
818
1278
|
}
|
|
819
1279
|
}
|
|
820
1280
|
_extraProps = new WeakMap();
|
|
@@ -826,24 +1286,29 @@ class UserApi {
|
|
|
826
1286
|
getUser() {
|
|
827
1287
|
return operationsByTag.users.getUser({ ...this.extraProps });
|
|
828
1288
|
}
|
|
829
|
-
updateUser(user) {
|
|
1289
|
+
updateUser({ user }) {
|
|
830
1290
|
return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
|
|
831
1291
|
}
|
|
832
1292
|
deleteUser() {
|
|
833
1293
|
return operationsByTag.users.deleteUser({ ...this.extraProps });
|
|
834
1294
|
}
|
|
1295
|
+
}
|
|
1296
|
+
class AuthenticationApi {
|
|
1297
|
+
constructor(extraProps) {
|
|
1298
|
+
this.extraProps = extraProps;
|
|
1299
|
+
}
|
|
835
1300
|
getUserAPIKeys() {
|
|
836
|
-
return operationsByTag.
|
|
1301
|
+
return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
|
|
837
1302
|
}
|
|
838
|
-
createUserAPIKey(
|
|
839
|
-
return operationsByTag.
|
|
840
|
-
pathParams: { keyName },
|
|
1303
|
+
createUserAPIKey({ name }) {
|
|
1304
|
+
return operationsByTag.authentication.createUserAPIKey({
|
|
1305
|
+
pathParams: { keyName: name },
|
|
841
1306
|
...this.extraProps
|
|
842
1307
|
});
|
|
843
1308
|
}
|
|
844
|
-
deleteUserAPIKey(
|
|
845
|
-
return operationsByTag.
|
|
846
|
-
pathParams: { keyName },
|
|
1309
|
+
deleteUserAPIKey({ name }) {
|
|
1310
|
+
return operationsByTag.authentication.deleteUserAPIKey({
|
|
1311
|
+
pathParams: { keyName: name },
|
|
847
1312
|
...this.extraProps
|
|
848
1313
|
});
|
|
849
1314
|
}
|
|
@@ -852,196 +1317,262 @@ class WorkspaceApi {
|
|
|
852
1317
|
constructor(extraProps) {
|
|
853
1318
|
this.extraProps = extraProps;
|
|
854
1319
|
}
|
|
855
|
-
|
|
1320
|
+
getWorkspacesList() {
|
|
1321
|
+
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
|
1322
|
+
}
|
|
1323
|
+
createWorkspace({ data }) {
|
|
856
1324
|
return operationsByTag.workspaces.createWorkspace({
|
|
857
|
-
body:
|
|
1325
|
+
body: data,
|
|
858
1326
|
...this.extraProps
|
|
859
1327
|
});
|
|
860
1328
|
}
|
|
861
|
-
|
|
862
|
-
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
|
863
|
-
}
|
|
864
|
-
getWorkspace(workspaceId) {
|
|
1329
|
+
getWorkspace({ workspace }) {
|
|
865
1330
|
return operationsByTag.workspaces.getWorkspace({
|
|
866
|
-
pathParams: { workspaceId },
|
|
1331
|
+
pathParams: { workspaceId: workspace },
|
|
867
1332
|
...this.extraProps
|
|
868
1333
|
});
|
|
869
1334
|
}
|
|
870
|
-
updateWorkspace(
|
|
1335
|
+
updateWorkspace({
|
|
1336
|
+
workspace,
|
|
1337
|
+
update
|
|
1338
|
+
}) {
|
|
871
1339
|
return operationsByTag.workspaces.updateWorkspace({
|
|
872
|
-
pathParams: { workspaceId },
|
|
873
|
-
body:
|
|
1340
|
+
pathParams: { workspaceId: workspace },
|
|
1341
|
+
body: update,
|
|
874
1342
|
...this.extraProps
|
|
875
1343
|
});
|
|
876
1344
|
}
|
|
877
|
-
deleteWorkspace(
|
|
1345
|
+
deleteWorkspace({ workspace }) {
|
|
878
1346
|
return operationsByTag.workspaces.deleteWorkspace({
|
|
879
|
-
pathParams: { workspaceId },
|
|
1347
|
+
pathParams: { workspaceId: workspace },
|
|
880
1348
|
...this.extraProps
|
|
881
1349
|
});
|
|
882
1350
|
}
|
|
883
|
-
getWorkspaceMembersList(
|
|
1351
|
+
getWorkspaceMembersList({ workspace }) {
|
|
884
1352
|
return operationsByTag.workspaces.getWorkspaceMembersList({
|
|
885
|
-
pathParams: { workspaceId },
|
|
1353
|
+
pathParams: { workspaceId: workspace },
|
|
886
1354
|
...this.extraProps
|
|
887
1355
|
});
|
|
888
1356
|
}
|
|
889
|
-
updateWorkspaceMemberRole(
|
|
1357
|
+
updateWorkspaceMemberRole({
|
|
1358
|
+
workspace,
|
|
1359
|
+
user,
|
|
1360
|
+
role
|
|
1361
|
+
}) {
|
|
890
1362
|
return operationsByTag.workspaces.updateWorkspaceMemberRole({
|
|
891
|
-
pathParams: { workspaceId, userId },
|
|
1363
|
+
pathParams: { workspaceId: workspace, userId: user },
|
|
892
1364
|
body: { role },
|
|
893
1365
|
...this.extraProps
|
|
894
1366
|
});
|
|
895
1367
|
}
|
|
896
|
-
removeWorkspaceMember(
|
|
1368
|
+
removeWorkspaceMember({
|
|
1369
|
+
workspace,
|
|
1370
|
+
user
|
|
1371
|
+
}) {
|
|
897
1372
|
return operationsByTag.workspaces.removeWorkspaceMember({
|
|
898
|
-
pathParams: { workspaceId, userId },
|
|
1373
|
+
pathParams: { workspaceId: workspace, userId: user },
|
|
899
1374
|
...this.extraProps
|
|
900
1375
|
});
|
|
901
1376
|
}
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
1377
|
+
}
|
|
1378
|
+
class InvitesApi {
|
|
1379
|
+
constructor(extraProps) {
|
|
1380
|
+
this.extraProps = extraProps;
|
|
1381
|
+
}
|
|
1382
|
+
inviteWorkspaceMember({
|
|
1383
|
+
workspace,
|
|
1384
|
+
email,
|
|
1385
|
+
role
|
|
1386
|
+
}) {
|
|
1387
|
+
return operationsByTag.invites.inviteWorkspaceMember({
|
|
1388
|
+
pathParams: { workspaceId: workspace },
|
|
905
1389
|
body: { email, role },
|
|
906
1390
|
...this.extraProps
|
|
907
1391
|
});
|
|
908
1392
|
}
|
|
909
|
-
updateWorkspaceMemberInvite(
|
|
910
|
-
|
|
911
|
-
|
|
1393
|
+
updateWorkspaceMemberInvite({
|
|
1394
|
+
workspace,
|
|
1395
|
+
invite,
|
|
1396
|
+
role
|
|
1397
|
+
}) {
|
|
1398
|
+
return operationsByTag.invites.updateWorkspaceMemberInvite({
|
|
1399
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
|
912
1400
|
body: { role },
|
|
913
1401
|
...this.extraProps
|
|
914
1402
|
});
|
|
915
1403
|
}
|
|
916
|
-
cancelWorkspaceMemberInvite(
|
|
917
|
-
|
|
918
|
-
|
|
1404
|
+
cancelWorkspaceMemberInvite({
|
|
1405
|
+
workspace,
|
|
1406
|
+
invite
|
|
1407
|
+
}) {
|
|
1408
|
+
return operationsByTag.invites.cancelWorkspaceMemberInvite({
|
|
1409
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
|
919
1410
|
...this.extraProps
|
|
920
1411
|
});
|
|
921
1412
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
1413
|
+
acceptWorkspaceMemberInvite({
|
|
1414
|
+
workspace,
|
|
1415
|
+
key
|
|
1416
|
+
}) {
|
|
1417
|
+
return operationsByTag.invites.acceptWorkspaceMemberInvite({
|
|
1418
|
+
pathParams: { workspaceId: workspace, inviteKey: key },
|
|
925
1419
|
...this.extraProps
|
|
926
1420
|
});
|
|
927
1421
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1422
|
+
resendWorkspaceMemberInvite({
|
|
1423
|
+
workspace,
|
|
1424
|
+
invite
|
|
1425
|
+
}) {
|
|
1426
|
+
return operationsByTag.invites.resendWorkspaceMemberInvite({
|
|
1427
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
|
931
1428
|
...this.extraProps
|
|
932
1429
|
});
|
|
933
1430
|
}
|
|
934
1431
|
}
|
|
935
|
-
class
|
|
1432
|
+
class BranchApi {
|
|
936
1433
|
constructor(extraProps) {
|
|
937
1434
|
this.extraProps = extraProps;
|
|
938
1435
|
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
return operationsByTag.database.createDatabase({
|
|
947
|
-
pathParams: { workspace, dbName },
|
|
948
|
-
body: options,
|
|
949
|
-
...this.extraProps
|
|
950
|
-
});
|
|
951
|
-
}
|
|
952
|
-
deleteDatabase(workspace, dbName) {
|
|
953
|
-
return operationsByTag.database.deleteDatabase({
|
|
954
|
-
pathParams: { workspace, dbName },
|
|
955
|
-
...this.extraProps
|
|
956
|
-
});
|
|
957
|
-
}
|
|
958
|
-
getDatabaseMetadata(workspace, dbName) {
|
|
959
|
-
return operationsByTag.database.getDatabaseMetadata({
|
|
960
|
-
pathParams: { workspace, dbName },
|
|
961
|
-
...this.extraProps
|
|
962
|
-
});
|
|
963
|
-
}
|
|
964
|
-
updateDatabaseMetadata(workspace, dbName, options = {}) {
|
|
965
|
-
return operationsByTag.database.updateDatabaseMetadata({
|
|
966
|
-
pathParams: { workspace, dbName },
|
|
967
|
-
body: options,
|
|
1436
|
+
getBranchList({
|
|
1437
|
+
workspace,
|
|
1438
|
+
region,
|
|
1439
|
+
database
|
|
1440
|
+
}) {
|
|
1441
|
+
return operationsByTag.branch.getBranchList({
|
|
1442
|
+
pathParams: { workspace, region, dbName: database },
|
|
968
1443
|
...this.extraProps
|
|
969
1444
|
});
|
|
970
1445
|
}
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
1446
|
+
getBranchDetails({
|
|
1447
|
+
workspace,
|
|
1448
|
+
region,
|
|
1449
|
+
database,
|
|
1450
|
+
branch
|
|
1451
|
+
}) {
|
|
1452
|
+
return operationsByTag.branch.getBranchDetails({
|
|
1453
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
974
1454
|
...this.extraProps
|
|
975
1455
|
});
|
|
976
1456
|
}
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1457
|
+
createBranch({
|
|
1458
|
+
workspace,
|
|
1459
|
+
region,
|
|
1460
|
+
database,
|
|
1461
|
+
branch,
|
|
1462
|
+
from,
|
|
1463
|
+
metadata
|
|
1464
|
+
}) {
|
|
1465
|
+
return operationsByTag.branch.createBranch({
|
|
1466
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1467
|
+
body: { from, metadata },
|
|
981
1468
|
...this.extraProps
|
|
982
1469
|
});
|
|
983
1470
|
}
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1471
|
+
deleteBranch({
|
|
1472
|
+
workspace,
|
|
1473
|
+
region,
|
|
1474
|
+
database,
|
|
1475
|
+
branch
|
|
1476
|
+
}) {
|
|
1477
|
+
return operationsByTag.branch.deleteBranch({
|
|
1478
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
988
1479
|
...this.extraProps
|
|
989
1480
|
});
|
|
990
1481
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1482
|
+
copyBranch({
|
|
1483
|
+
workspace,
|
|
1484
|
+
region,
|
|
1485
|
+
database,
|
|
1486
|
+
branch,
|
|
1487
|
+
destinationBranch,
|
|
1488
|
+
limit
|
|
1489
|
+
}) {
|
|
1490
|
+
return operationsByTag.branch.copyBranch({
|
|
1491
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1492
|
+
body: { destinationBranch, limit },
|
|
995
1493
|
...this.extraProps
|
|
996
1494
|
});
|
|
997
1495
|
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1496
|
+
updateBranchMetadata({
|
|
1497
|
+
workspace,
|
|
1498
|
+
region,
|
|
1499
|
+
database,
|
|
1500
|
+
branch,
|
|
1501
|
+
metadata
|
|
1502
|
+
}) {
|
|
1503
|
+
return operationsByTag.branch.updateBranchMetadata({
|
|
1504
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1505
|
+
body: metadata,
|
|
1006
1506
|
...this.extraProps
|
|
1007
1507
|
});
|
|
1008
1508
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1509
|
+
getBranchMetadata({
|
|
1510
|
+
workspace,
|
|
1511
|
+
region,
|
|
1512
|
+
database,
|
|
1513
|
+
branch
|
|
1514
|
+
}) {
|
|
1515
|
+
return operationsByTag.branch.getBranchMetadata({
|
|
1516
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1012
1517
|
...this.extraProps
|
|
1013
1518
|
});
|
|
1014
1519
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1520
|
+
getBranchStats({
|
|
1521
|
+
workspace,
|
|
1522
|
+
region,
|
|
1523
|
+
database,
|
|
1524
|
+
branch
|
|
1525
|
+
}) {
|
|
1526
|
+
return operationsByTag.branch.getBranchStats({
|
|
1527
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1020
1528
|
...this.extraProps
|
|
1021
1529
|
});
|
|
1022
1530
|
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1531
|
+
getGitBranchesMapping({
|
|
1532
|
+
workspace,
|
|
1533
|
+
region,
|
|
1534
|
+
database
|
|
1535
|
+
}) {
|
|
1536
|
+
return operationsByTag.branch.getGitBranchesMapping({
|
|
1537
|
+
pathParams: { workspace, region, dbName: database },
|
|
1026
1538
|
...this.extraProps
|
|
1027
1539
|
});
|
|
1028
1540
|
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1541
|
+
addGitBranchesEntry({
|
|
1542
|
+
workspace,
|
|
1543
|
+
region,
|
|
1544
|
+
database,
|
|
1545
|
+
gitBranch,
|
|
1546
|
+
xataBranch
|
|
1547
|
+
}) {
|
|
1548
|
+
return operationsByTag.branch.addGitBranchesEntry({
|
|
1549
|
+
pathParams: { workspace, region, dbName: database },
|
|
1550
|
+
body: { gitBranch, xataBranch },
|
|
1033
1551
|
...this.extraProps
|
|
1034
1552
|
});
|
|
1035
1553
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1554
|
+
removeGitBranchesEntry({
|
|
1555
|
+
workspace,
|
|
1556
|
+
region,
|
|
1557
|
+
database,
|
|
1558
|
+
gitBranch
|
|
1559
|
+
}) {
|
|
1560
|
+
return operationsByTag.branch.removeGitBranchesEntry({
|
|
1561
|
+
pathParams: { workspace, region, dbName: database },
|
|
1562
|
+
queryParams: { gitBranch },
|
|
1039
1563
|
...this.extraProps
|
|
1040
1564
|
});
|
|
1041
1565
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1566
|
+
resolveBranch({
|
|
1567
|
+
workspace,
|
|
1568
|
+
region,
|
|
1569
|
+
database,
|
|
1570
|
+
gitBranch,
|
|
1571
|
+
fallbackBranch
|
|
1572
|
+
}) {
|
|
1573
|
+
return operationsByTag.branch.resolveBranch({
|
|
1574
|
+
pathParams: { workspace, region, dbName: database },
|
|
1575
|
+
queryParams: { gitBranch, fallbackBranch },
|
|
1045
1576
|
...this.extraProps
|
|
1046
1577
|
});
|
|
1047
1578
|
}
|
|
@@ -1050,67 +1581,134 @@ class TableApi {
|
|
|
1050
1581
|
constructor(extraProps) {
|
|
1051
1582
|
this.extraProps = extraProps;
|
|
1052
1583
|
}
|
|
1053
|
-
createTable(
|
|
1584
|
+
createTable({
|
|
1585
|
+
workspace,
|
|
1586
|
+
region,
|
|
1587
|
+
database,
|
|
1588
|
+
branch,
|
|
1589
|
+
table
|
|
1590
|
+
}) {
|
|
1054
1591
|
return operationsByTag.table.createTable({
|
|
1055
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1592
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1056
1593
|
...this.extraProps
|
|
1057
1594
|
});
|
|
1058
1595
|
}
|
|
1059
|
-
deleteTable(
|
|
1596
|
+
deleteTable({
|
|
1597
|
+
workspace,
|
|
1598
|
+
region,
|
|
1599
|
+
database,
|
|
1600
|
+
branch,
|
|
1601
|
+
table
|
|
1602
|
+
}) {
|
|
1060
1603
|
return operationsByTag.table.deleteTable({
|
|
1061
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1604
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1062
1605
|
...this.extraProps
|
|
1063
1606
|
});
|
|
1064
1607
|
}
|
|
1065
|
-
updateTable(
|
|
1608
|
+
updateTable({
|
|
1609
|
+
workspace,
|
|
1610
|
+
region,
|
|
1611
|
+
database,
|
|
1612
|
+
branch,
|
|
1613
|
+
table,
|
|
1614
|
+
update
|
|
1615
|
+
}) {
|
|
1066
1616
|
return operationsByTag.table.updateTable({
|
|
1067
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1068
|
-
body:
|
|
1617
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1618
|
+
body: update,
|
|
1069
1619
|
...this.extraProps
|
|
1070
1620
|
});
|
|
1071
1621
|
}
|
|
1072
|
-
getTableSchema(
|
|
1622
|
+
getTableSchema({
|
|
1623
|
+
workspace,
|
|
1624
|
+
region,
|
|
1625
|
+
database,
|
|
1626
|
+
branch,
|
|
1627
|
+
table
|
|
1628
|
+
}) {
|
|
1073
1629
|
return operationsByTag.table.getTableSchema({
|
|
1074
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1630
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1075
1631
|
...this.extraProps
|
|
1076
1632
|
});
|
|
1077
1633
|
}
|
|
1078
|
-
setTableSchema(
|
|
1634
|
+
setTableSchema({
|
|
1635
|
+
workspace,
|
|
1636
|
+
region,
|
|
1637
|
+
database,
|
|
1638
|
+
branch,
|
|
1639
|
+
table,
|
|
1640
|
+
schema
|
|
1641
|
+
}) {
|
|
1079
1642
|
return operationsByTag.table.setTableSchema({
|
|
1080
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1081
|
-
body:
|
|
1643
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1644
|
+
body: schema,
|
|
1082
1645
|
...this.extraProps
|
|
1083
1646
|
});
|
|
1084
1647
|
}
|
|
1085
|
-
getTableColumns(
|
|
1648
|
+
getTableColumns({
|
|
1649
|
+
workspace,
|
|
1650
|
+
region,
|
|
1651
|
+
database,
|
|
1652
|
+
branch,
|
|
1653
|
+
table
|
|
1654
|
+
}) {
|
|
1086
1655
|
return operationsByTag.table.getTableColumns({
|
|
1087
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1656
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1088
1657
|
...this.extraProps
|
|
1089
1658
|
});
|
|
1090
1659
|
}
|
|
1091
|
-
addTableColumn(
|
|
1660
|
+
addTableColumn({
|
|
1661
|
+
workspace,
|
|
1662
|
+
region,
|
|
1663
|
+
database,
|
|
1664
|
+
branch,
|
|
1665
|
+
table,
|
|
1666
|
+
column
|
|
1667
|
+
}) {
|
|
1092
1668
|
return operationsByTag.table.addTableColumn({
|
|
1093
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1669
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1094
1670
|
body: column,
|
|
1095
1671
|
...this.extraProps
|
|
1096
1672
|
});
|
|
1097
1673
|
}
|
|
1098
|
-
getColumn(
|
|
1674
|
+
getColumn({
|
|
1675
|
+
workspace,
|
|
1676
|
+
region,
|
|
1677
|
+
database,
|
|
1678
|
+
branch,
|
|
1679
|
+
table,
|
|
1680
|
+
column
|
|
1681
|
+
}) {
|
|
1099
1682
|
return operationsByTag.table.getColumn({
|
|
1100
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
|
|
1683
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
|
1101
1684
|
...this.extraProps
|
|
1102
1685
|
});
|
|
1103
1686
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1687
|
+
updateColumn({
|
|
1688
|
+
workspace,
|
|
1689
|
+
region,
|
|
1690
|
+
database,
|
|
1691
|
+
branch,
|
|
1692
|
+
table,
|
|
1693
|
+
column,
|
|
1694
|
+
update
|
|
1695
|
+
}) {
|
|
1696
|
+
return operationsByTag.table.updateColumn({
|
|
1697
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
|
1698
|
+
body: update,
|
|
1107
1699
|
...this.extraProps
|
|
1108
1700
|
});
|
|
1109
1701
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1702
|
+
deleteColumn({
|
|
1703
|
+
workspace,
|
|
1704
|
+
region,
|
|
1705
|
+
database,
|
|
1706
|
+
branch,
|
|
1707
|
+
table,
|
|
1708
|
+
column
|
|
1709
|
+
}) {
|
|
1710
|
+
return operationsByTag.table.deleteColumn({
|
|
1711
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
|
1114
1712
|
...this.extraProps
|
|
1115
1713
|
});
|
|
1116
1714
|
}
|
|
@@ -1119,230 +1717,738 @@ class RecordsApi {
|
|
|
1119
1717
|
constructor(extraProps) {
|
|
1120
1718
|
this.extraProps = extraProps;
|
|
1121
1719
|
}
|
|
1122
|
-
insertRecord(
|
|
1720
|
+
insertRecord({
|
|
1721
|
+
workspace,
|
|
1722
|
+
region,
|
|
1723
|
+
database,
|
|
1724
|
+
branch,
|
|
1725
|
+
table,
|
|
1726
|
+
record,
|
|
1727
|
+
columns
|
|
1728
|
+
}) {
|
|
1123
1729
|
return operationsByTag.records.insertRecord({
|
|
1124
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1125
|
-
queryParams:
|
|
1730
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1731
|
+
queryParams: { columns },
|
|
1126
1732
|
body: record,
|
|
1127
1733
|
...this.extraProps
|
|
1128
1734
|
});
|
|
1129
1735
|
}
|
|
1130
|
-
|
|
1736
|
+
getRecord({
|
|
1737
|
+
workspace,
|
|
1738
|
+
region,
|
|
1739
|
+
database,
|
|
1740
|
+
branch,
|
|
1741
|
+
table,
|
|
1742
|
+
id,
|
|
1743
|
+
columns
|
|
1744
|
+
}) {
|
|
1745
|
+
return operationsByTag.records.getRecord({
|
|
1746
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1747
|
+
queryParams: { columns },
|
|
1748
|
+
...this.extraProps
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
insertRecordWithID({
|
|
1752
|
+
workspace,
|
|
1753
|
+
region,
|
|
1754
|
+
database,
|
|
1755
|
+
branch,
|
|
1756
|
+
table,
|
|
1757
|
+
id,
|
|
1758
|
+
record,
|
|
1759
|
+
columns,
|
|
1760
|
+
createOnly,
|
|
1761
|
+
ifVersion
|
|
1762
|
+
}) {
|
|
1131
1763
|
return operationsByTag.records.insertRecordWithID({
|
|
1132
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1133
|
-
queryParams:
|
|
1764
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1765
|
+
queryParams: { columns, createOnly, ifVersion },
|
|
1134
1766
|
body: record,
|
|
1135
1767
|
...this.extraProps
|
|
1136
1768
|
});
|
|
1137
1769
|
}
|
|
1138
|
-
updateRecordWithID(
|
|
1770
|
+
updateRecordWithID({
|
|
1771
|
+
workspace,
|
|
1772
|
+
region,
|
|
1773
|
+
database,
|
|
1774
|
+
branch,
|
|
1775
|
+
table,
|
|
1776
|
+
id,
|
|
1777
|
+
record,
|
|
1778
|
+
columns,
|
|
1779
|
+
ifVersion
|
|
1780
|
+
}) {
|
|
1139
1781
|
return operationsByTag.records.updateRecordWithID({
|
|
1140
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1141
|
-
queryParams:
|
|
1782
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1783
|
+
queryParams: { columns, ifVersion },
|
|
1142
1784
|
body: record,
|
|
1143
1785
|
...this.extraProps
|
|
1144
1786
|
});
|
|
1145
1787
|
}
|
|
1146
|
-
upsertRecordWithID(
|
|
1788
|
+
upsertRecordWithID({
|
|
1789
|
+
workspace,
|
|
1790
|
+
region,
|
|
1791
|
+
database,
|
|
1792
|
+
branch,
|
|
1793
|
+
table,
|
|
1794
|
+
id,
|
|
1795
|
+
record,
|
|
1796
|
+
columns,
|
|
1797
|
+
ifVersion
|
|
1798
|
+
}) {
|
|
1147
1799
|
return operationsByTag.records.upsertRecordWithID({
|
|
1148
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1149
|
-
queryParams:
|
|
1800
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1801
|
+
queryParams: { columns, ifVersion },
|
|
1150
1802
|
body: record,
|
|
1151
1803
|
...this.extraProps
|
|
1152
1804
|
});
|
|
1153
1805
|
}
|
|
1154
|
-
deleteRecord(
|
|
1806
|
+
deleteRecord({
|
|
1807
|
+
workspace,
|
|
1808
|
+
region,
|
|
1809
|
+
database,
|
|
1810
|
+
branch,
|
|
1811
|
+
table,
|
|
1812
|
+
id,
|
|
1813
|
+
columns
|
|
1814
|
+
}) {
|
|
1155
1815
|
return operationsByTag.records.deleteRecord({
|
|
1156
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1157
|
-
queryParams:
|
|
1816
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1817
|
+
queryParams: { columns },
|
|
1818
|
+
...this.extraProps
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1821
|
+
bulkInsertTableRecords({
|
|
1822
|
+
workspace,
|
|
1823
|
+
region,
|
|
1824
|
+
database,
|
|
1825
|
+
branch,
|
|
1826
|
+
table,
|
|
1827
|
+
records,
|
|
1828
|
+
columns
|
|
1829
|
+
}) {
|
|
1830
|
+
return operationsByTag.records.bulkInsertTableRecords({
|
|
1831
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1832
|
+
queryParams: { columns },
|
|
1833
|
+
body: { records },
|
|
1834
|
+
...this.extraProps
|
|
1835
|
+
});
|
|
1836
|
+
}
|
|
1837
|
+
branchTransaction({
|
|
1838
|
+
workspace,
|
|
1839
|
+
region,
|
|
1840
|
+
database,
|
|
1841
|
+
branch,
|
|
1842
|
+
operations
|
|
1843
|
+
}) {
|
|
1844
|
+
return operationsByTag.records.branchTransaction({
|
|
1845
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1846
|
+
body: { operations },
|
|
1847
|
+
...this.extraProps
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
class FilesApi {
|
|
1852
|
+
constructor(extraProps) {
|
|
1853
|
+
this.extraProps = extraProps;
|
|
1854
|
+
}
|
|
1855
|
+
getFileItem({
|
|
1856
|
+
workspace,
|
|
1857
|
+
region,
|
|
1858
|
+
database,
|
|
1859
|
+
branch,
|
|
1860
|
+
table,
|
|
1861
|
+
record,
|
|
1862
|
+
column,
|
|
1863
|
+
fileId
|
|
1864
|
+
}) {
|
|
1865
|
+
return operationsByTag.files.getFileItem({
|
|
1866
|
+
pathParams: {
|
|
1867
|
+
workspace,
|
|
1868
|
+
region,
|
|
1869
|
+
dbBranchName: `${database}:${branch}`,
|
|
1870
|
+
tableName: table,
|
|
1871
|
+
recordId: record,
|
|
1872
|
+
columnName: column,
|
|
1873
|
+
fileId
|
|
1874
|
+
},
|
|
1875
|
+
...this.extraProps
|
|
1876
|
+
});
|
|
1877
|
+
}
|
|
1878
|
+
putFileItem({
|
|
1879
|
+
workspace,
|
|
1880
|
+
region,
|
|
1881
|
+
database,
|
|
1882
|
+
branch,
|
|
1883
|
+
table,
|
|
1884
|
+
record,
|
|
1885
|
+
column,
|
|
1886
|
+
fileId,
|
|
1887
|
+
file
|
|
1888
|
+
}) {
|
|
1889
|
+
return operationsByTag.files.putFileItem({
|
|
1890
|
+
pathParams: {
|
|
1891
|
+
workspace,
|
|
1892
|
+
region,
|
|
1893
|
+
dbBranchName: `${database}:${branch}`,
|
|
1894
|
+
tableName: table,
|
|
1895
|
+
recordId: record,
|
|
1896
|
+
columnName: column,
|
|
1897
|
+
fileId
|
|
1898
|
+
},
|
|
1899
|
+
body: file,
|
|
1900
|
+
...this.extraProps
|
|
1901
|
+
});
|
|
1902
|
+
}
|
|
1903
|
+
deleteFileItem({
|
|
1904
|
+
workspace,
|
|
1905
|
+
region,
|
|
1906
|
+
database,
|
|
1907
|
+
branch,
|
|
1908
|
+
table,
|
|
1909
|
+
record,
|
|
1910
|
+
column,
|
|
1911
|
+
fileId
|
|
1912
|
+
}) {
|
|
1913
|
+
return operationsByTag.files.deleteFileItem({
|
|
1914
|
+
pathParams: {
|
|
1915
|
+
workspace,
|
|
1916
|
+
region,
|
|
1917
|
+
dbBranchName: `${database}:${branch}`,
|
|
1918
|
+
tableName: table,
|
|
1919
|
+
recordId: record,
|
|
1920
|
+
columnName: column,
|
|
1921
|
+
fileId
|
|
1922
|
+
},
|
|
1923
|
+
...this.extraProps
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1926
|
+
getFile({
|
|
1927
|
+
workspace,
|
|
1928
|
+
region,
|
|
1929
|
+
database,
|
|
1930
|
+
branch,
|
|
1931
|
+
table,
|
|
1932
|
+
record,
|
|
1933
|
+
column
|
|
1934
|
+
}) {
|
|
1935
|
+
return operationsByTag.files.getFile({
|
|
1936
|
+
pathParams: {
|
|
1937
|
+
workspace,
|
|
1938
|
+
region,
|
|
1939
|
+
dbBranchName: `${database}:${branch}`,
|
|
1940
|
+
tableName: table,
|
|
1941
|
+
recordId: record,
|
|
1942
|
+
columnName: column
|
|
1943
|
+
},
|
|
1944
|
+
...this.extraProps
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
putFile({
|
|
1948
|
+
workspace,
|
|
1949
|
+
region,
|
|
1950
|
+
database,
|
|
1951
|
+
branch,
|
|
1952
|
+
table,
|
|
1953
|
+
record,
|
|
1954
|
+
column,
|
|
1955
|
+
file
|
|
1956
|
+
}) {
|
|
1957
|
+
return operationsByTag.files.putFile({
|
|
1958
|
+
pathParams: {
|
|
1959
|
+
workspace,
|
|
1960
|
+
region,
|
|
1961
|
+
dbBranchName: `${database}:${branch}`,
|
|
1962
|
+
tableName: table,
|
|
1963
|
+
recordId: record,
|
|
1964
|
+
columnName: column
|
|
1965
|
+
},
|
|
1966
|
+
body: file,
|
|
1967
|
+
...this.extraProps
|
|
1968
|
+
});
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
class SearchAndFilterApi {
|
|
1972
|
+
constructor(extraProps) {
|
|
1973
|
+
this.extraProps = extraProps;
|
|
1974
|
+
}
|
|
1975
|
+
queryTable({
|
|
1976
|
+
workspace,
|
|
1977
|
+
region,
|
|
1978
|
+
database,
|
|
1979
|
+
branch,
|
|
1980
|
+
table,
|
|
1981
|
+
filter,
|
|
1982
|
+
sort,
|
|
1983
|
+
page,
|
|
1984
|
+
columns,
|
|
1985
|
+
consistency
|
|
1986
|
+
}) {
|
|
1987
|
+
return operationsByTag.searchAndFilter.queryTable({
|
|
1988
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1989
|
+
body: { filter, sort, page, columns, consistency },
|
|
1990
|
+
...this.extraProps
|
|
1991
|
+
});
|
|
1992
|
+
}
|
|
1993
|
+
searchTable({
|
|
1994
|
+
workspace,
|
|
1995
|
+
region,
|
|
1996
|
+
database,
|
|
1997
|
+
branch,
|
|
1998
|
+
table,
|
|
1999
|
+
query,
|
|
2000
|
+
fuzziness,
|
|
2001
|
+
target,
|
|
2002
|
+
prefix,
|
|
2003
|
+
filter,
|
|
2004
|
+
highlight,
|
|
2005
|
+
boosters
|
|
2006
|
+
}) {
|
|
2007
|
+
return operationsByTag.searchAndFilter.searchTable({
|
|
2008
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
2009
|
+
body: { query, fuzziness, target, prefix, filter, highlight, boosters },
|
|
2010
|
+
...this.extraProps
|
|
2011
|
+
});
|
|
2012
|
+
}
|
|
2013
|
+
searchBranch({
|
|
2014
|
+
workspace,
|
|
2015
|
+
region,
|
|
2016
|
+
database,
|
|
2017
|
+
branch,
|
|
2018
|
+
tables,
|
|
2019
|
+
query,
|
|
2020
|
+
fuzziness,
|
|
2021
|
+
prefix,
|
|
2022
|
+
highlight
|
|
2023
|
+
}) {
|
|
2024
|
+
return operationsByTag.searchAndFilter.searchBranch({
|
|
2025
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2026
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
|
2027
|
+
...this.extraProps
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
vectorSearchTable({
|
|
2031
|
+
workspace,
|
|
2032
|
+
region,
|
|
2033
|
+
database,
|
|
2034
|
+
branch,
|
|
2035
|
+
table,
|
|
2036
|
+
queryVector,
|
|
2037
|
+
column,
|
|
2038
|
+
similarityFunction,
|
|
2039
|
+
size,
|
|
2040
|
+
filter
|
|
2041
|
+
}) {
|
|
2042
|
+
return operationsByTag.searchAndFilter.vectorSearchTable({
|
|
2043
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
2044
|
+
body: { queryVector, column, similarityFunction, size, filter },
|
|
2045
|
+
...this.extraProps
|
|
2046
|
+
});
|
|
2047
|
+
}
|
|
2048
|
+
askTable({
|
|
2049
|
+
workspace,
|
|
2050
|
+
region,
|
|
2051
|
+
database,
|
|
2052
|
+
branch,
|
|
2053
|
+
table,
|
|
2054
|
+
options
|
|
2055
|
+
}) {
|
|
2056
|
+
return operationsByTag.searchAndFilter.askTable({
|
|
2057
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
2058
|
+
body: { ...options },
|
|
2059
|
+
...this.extraProps
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
summarizeTable({
|
|
2063
|
+
workspace,
|
|
2064
|
+
region,
|
|
2065
|
+
database,
|
|
2066
|
+
branch,
|
|
2067
|
+
table,
|
|
2068
|
+
filter,
|
|
2069
|
+
columns,
|
|
2070
|
+
summaries,
|
|
2071
|
+
sort,
|
|
2072
|
+
summariesFilter,
|
|
2073
|
+
page,
|
|
2074
|
+
consistency
|
|
2075
|
+
}) {
|
|
2076
|
+
return operationsByTag.searchAndFilter.summarizeTable({
|
|
2077
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
2078
|
+
body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
|
|
2079
|
+
...this.extraProps
|
|
2080
|
+
});
|
|
2081
|
+
}
|
|
2082
|
+
aggregateTable({
|
|
2083
|
+
workspace,
|
|
2084
|
+
region,
|
|
2085
|
+
database,
|
|
2086
|
+
branch,
|
|
2087
|
+
table,
|
|
2088
|
+
filter,
|
|
2089
|
+
aggs
|
|
2090
|
+
}) {
|
|
2091
|
+
return operationsByTag.searchAndFilter.aggregateTable({
|
|
2092
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
2093
|
+
body: { filter, aggs },
|
|
2094
|
+
...this.extraProps
|
|
2095
|
+
});
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
class MigrationRequestsApi {
|
|
2099
|
+
constructor(extraProps) {
|
|
2100
|
+
this.extraProps = extraProps;
|
|
2101
|
+
}
|
|
2102
|
+
queryMigrationRequests({
|
|
2103
|
+
workspace,
|
|
2104
|
+
region,
|
|
2105
|
+
database,
|
|
2106
|
+
filter,
|
|
2107
|
+
sort,
|
|
2108
|
+
page,
|
|
2109
|
+
columns
|
|
2110
|
+
}) {
|
|
2111
|
+
return operationsByTag.migrationRequests.queryMigrationRequests({
|
|
2112
|
+
pathParams: { workspace, region, dbName: database },
|
|
2113
|
+
body: { filter, sort, page, columns },
|
|
2114
|
+
...this.extraProps
|
|
2115
|
+
});
|
|
2116
|
+
}
|
|
2117
|
+
createMigrationRequest({
|
|
2118
|
+
workspace,
|
|
2119
|
+
region,
|
|
2120
|
+
database,
|
|
2121
|
+
migration
|
|
2122
|
+
}) {
|
|
2123
|
+
return operationsByTag.migrationRequests.createMigrationRequest({
|
|
2124
|
+
pathParams: { workspace, region, dbName: database },
|
|
2125
|
+
body: migration,
|
|
1158
2126
|
...this.extraProps
|
|
1159
2127
|
});
|
|
1160
2128
|
}
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
2129
|
+
getMigrationRequest({
|
|
2130
|
+
workspace,
|
|
2131
|
+
region,
|
|
2132
|
+
database,
|
|
2133
|
+
migrationRequest
|
|
2134
|
+
}) {
|
|
2135
|
+
return operationsByTag.migrationRequests.getMigrationRequest({
|
|
2136
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
1165
2137
|
...this.extraProps
|
|
1166
2138
|
});
|
|
1167
2139
|
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
2140
|
+
updateMigrationRequest({
|
|
2141
|
+
workspace,
|
|
2142
|
+
region,
|
|
2143
|
+
database,
|
|
2144
|
+
migrationRequest,
|
|
2145
|
+
update
|
|
2146
|
+
}) {
|
|
2147
|
+
return operationsByTag.migrationRequests.updateMigrationRequest({
|
|
2148
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
2149
|
+
body: update,
|
|
1173
2150
|
...this.extraProps
|
|
1174
2151
|
});
|
|
1175
2152
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
2153
|
+
listMigrationRequestsCommits({
|
|
2154
|
+
workspace,
|
|
2155
|
+
region,
|
|
2156
|
+
database,
|
|
2157
|
+
migrationRequest,
|
|
2158
|
+
page
|
|
2159
|
+
}) {
|
|
2160
|
+
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
|
2161
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
2162
|
+
body: { page },
|
|
1180
2163
|
...this.extraProps
|
|
1181
2164
|
});
|
|
1182
2165
|
}
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
2166
|
+
compareMigrationRequest({
|
|
2167
|
+
workspace,
|
|
2168
|
+
region,
|
|
2169
|
+
database,
|
|
2170
|
+
migrationRequest
|
|
2171
|
+
}) {
|
|
2172
|
+
return operationsByTag.migrationRequests.compareMigrationRequest({
|
|
2173
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
1187
2174
|
...this.extraProps
|
|
1188
2175
|
});
|
|
1189
2176
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
2177
|
+
getMigrationRequestIsMerged({
|
|
2178
|
+
workspace,
|
|
2179
|
+
region,
|
|
2180
|
+
database,
|
|
2181
|
+
migrationRequest
|
|
2182
|
+
}) {
|
|
2183
|
+
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
|
2184
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
1194
2185
|
...this.extraProps
|
|
1195
2186
|
});
|
|
1196
2187
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
2188
|
+
mergeMigrationRequest({
|
|
2189
|
+
workspace,
|
|
2190
|
+
region,
|
|
2191
|
+
database,
|
|
2192
|
+
migrationRequest
|
|
2193
|
+
}) {
|
|
2194
|
+
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
|
2195
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
1201
2196
|
...this.extraProps
|
|
1202
2197
|
});
|
|
1203
2198
|
}
|
|
1204
2199
|
}
|
|
1205
|
-
class
|
|
2200
|
+
class MigrationsApi {
|
|
1206
2201
|
constructor(extraProps) {
|
|
1207
2202
|
this.extraProps = extraProps;
|
|
1208
2203
|
}
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
2204
|
+
getBranchMigrationHistory({
|
|
2205
|
+
workspace,
|
|
2206
|
+
region,
|
|
2207
|
+
database,
|
|
2208
|
+
branch,
|
|
2209
|
+
limit,
|
|
2210
|
+
startFrom
|
|
2211
|
+
}) {
|
|
2212
|
+
return operationsByTag.migrations.getBranchMigrationHistory({
|
|
2213
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2214
|
+
body: { limit, startFrom },
|
|
1213
2215
|
...this.extraProps
|
|
1214
2216
|
});
|
|
1215
2217
|
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
2218
|
+
getBranchMigrationPlan({
|
|
2219
|
+
workspace,
|
|
2220
|
+
region,
|
|
2221
|
+
database,
|
|
2222
|
+
branch,
|
|
2223
|
+
schema
|
|
2224
|
+
}) {
|
|
2225
|
+
return operationsByTag.migrations.getBranchMigrationPlan({
|
|
2226
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2227
|
+
body: schema,
|
|
1220
2228
|
...this.extraProps
|
|
1221
2229
|
});
|
|
1222
2230
|
}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
2231
|
+
executeBranchMigrationPlan({
|
|
2232
|
+
workspace,
|
|
2233
|
+
region,
|
|
2234
|
+
database,
|
|
2235
|
+
branch,
|
|
2236
|
+
plan
|
|
2237
|
+
}) {
|
|
2238
|
+
return operationsByTag.migrations.executeBranchMigrationPlan({
|
|
2239
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2240
|
+
body: plan,
|
|
1226
2241
|
...this.extraProps
|
|
1227
2242
|
});
|
|
1228
2243
|
}
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
2244
|
+
getBranchSchemaHistory({
|
|
2245
|
+
workspace,
|
|
2246
|
+
region,
|
|
2247
|
+
database,
|
|
2248
|
+
branch,
|
|
2249
|
+
page
|
|
2250
|
+
}) {
|
|
2251
|
+
return operationsByTag.migrations.getBranchSchemaHistory({
|
|
2252
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2253
|
+
body: { page },
|
|
1233
2254
|
...this.extraProps
|
|
1234
2255
|
});
|
|
1235
2256
|
}
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
2257
|
+
compareBranchWithUserSchema({
|
|
2258
|
+
workspace,
|
|
2259
|
+
region,
|
|
2260
|
+
database,
|
|
2261
|
+
branch,
|
|
2262
|
+
schema,
|
|
2263
|
+
schemaOperations,
|
|
2264
|
+
branchOperations
|
|
2265
|
+
}) {
|
|
2266
|
+
return operationsByTag.migrations.compareBranchWithUserSchema({
|
|
2267
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2268
|
+
body: { schema, schemaOperations, branchOperations },
|
|
1240
2269
|
...this.extraProps
|
|
1241
2270
|
});
|
|
1242
2271
|
}
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
2272
|
+
compareBranchSchemas({
|
|
2273
|
+
workspace,
|
|
2274
|
+
region,
|
|
2275
|
+
database,
|
|
2276
|
+
branch,
|
|
2277
|
+
compare,
|
|
2278
|
+
sourceBranchOperations,
|
|
2279
|
+
targetBranchOperations
|
|
2280
|
+
}) {
|
|
2281
|
+
return operationsByTag.migrations.compareBranchSchemas({
|
|
2282
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
|
2283
|
+
body: { sourceBranchOperations, targetBranchOperations },
|
|
1246
2284
|
...this.extraProps
|
|
1247
2285
|
});
|
|
1248
2286
|
}
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
2287
|
+
updateBranchSchema({
|
|
2288
|
+
workspace,
|
|
2289
|
+
region,
|
|
2290
|
+
database,
|
|
2291
|
+
branch,
|
|
2292
|
+
migration
|
|
2293
|
+
}) {
|
|
2294
|
+
return operationsByTag.migrations.updateBranchSchema({
|
|
2295
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2296
|
+
body: migration,
|
|
1252
2297
|
...this.extraProps
|
|
1253
2298
|
});
|
|
1254
2299
|
}
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
2300
|
+
previewBranchSchemaEdit({
|
|
2301
|
+
workspace,
|
|
2302
|
+
region,
|
|
2303
|
+
database,
|
|
2304
|
+
branch,
|
|
2305
|
+
data
|
|
2306
|
+
}) {
|
|
2307
|
+
return operationsByTag.migrations.previewBranchSchemaEdit({
|
|
2308
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2309
|
+
body: data,
|
|
2310
|
+
...this.extraProps
|
|
2311
|
+
});
|
|
2312
|
+
}
|
|
2313
|
+
applyBranchSchemaEdit({
|
|
2314
|
+
workspace,
|
|
2315
|
+
region,
|
|
2316
|
+
database,
|
|
2317
|
+
branch,
|
|
2318
|
+
edits
|
|
2319
|
+
}) {
|
|
2320
|
+
return operationsByTag.migrations.applyBranchSchemaEdit({
|
|
2321
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2322
|
+
body: { edits },
|
|
2323
|
+
...this.extraProps
|
|
2324
|
+
});
|
|
2325
|
+
}
|
|
2326
|
+
pushBranchMigrations({
|
|
2327
|
+
workspace,
|
|
2328
|
+
region,
|
|
2329
|
+
database,
|
|
2330
|
+
branch,
|
|
2331
|
+
migrations
|
|
2332
|
+
}) {
|
|
2333
|
+
return operationsByTag.migrations.pushBranchMigrations({
|
|
2334
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2335
|
+
body: { migrations },
|
|
1258
2336
|
...this.extraProps
|
|
1259
2337
|
});
|
|
1260
2338
|
}
|
|
1261
2339
|
}
|
|
1262
|
-
class
|
|
2340
|
+
class DatabaseApi {
|
|
1263
2341
|
constructor(extraProps) {
|
|
1264
2342
|
this.extraProps = extraProps;
|
|
1265
2343
|
}
|
|
1266
|
-
|
|
1267
|
-
return operationsByTag.
|
|
1268
|
-
pathParams: {
|
|
1269
|
-
body: options,
|
|
2344
|
+
getDatabaseList({ workspace }) {
|
|
2345
|
+
return operationsByTag.databases.getDatabaseList({
|
|
2346
|
+
pathParams: { workspaceId: workspace },
|
|
1270
2347
|
...this.extraProps
|
|
1271
2348
|
});
|
|
1272
2349
|
}
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
2350
|
+
createDatabase({
|
|
2351
|
+
workspace,
|
|
2352
|
+
database,
|
|
2353
|
+
data
|
|
2354
|
+
}) {
|
|
2355
|
+
return operationsByTag.databases.createDatabase({
|
|
2356
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2357
|
+
body: data,
|
|
1277
2358
|
...this.extraProps
|
|
1278
2359
|
});
|
|
1279
2360
|
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
2361
|
+
deleteDatabase({
|
|
2362
|
+
workspace,
|
|
2363
|
+
database
|
|
2364
|
+
}) {
|
|
2365
|
+
return operationsByTag.databases.deleteDatabase({
|
|
2366
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
1284
2367
|
...this.extraProps
|
|
1285
2368
|
});
|
|
1286
2369
|
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
2370
|
+
getDatabaseMetadata({
|
|
2371
|
+
workspace,
|
|
2372
|
+
database
|
|
2373
|
+
}) {
|
|
2374
|
+
return operationsByTag.databases.getDatabaseMetadata({
|
|
2375
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
1291
2376
|
...this.extraProps
|
|
1292
2377
|
});
|
|
1293
2378
|
}
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
2379
|
+
updateDatabaseMetadata({
|
|
2380
|
+
workspace,
|
|
2381
|
+
database,
|
|
2382
|
+
metadata
|
|
2383
|
+
}) {
|
|
2384
|
+
return operationsByTag.databases.updateDatabaseMetadata({
|
|
2385
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2386
|
+
body: metadata,
|
|
1298
2387
|
...this.extraProps
|
|
1299
2388
|
});
|
|
1300
2389
|
}
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
2390
|
+
renameDatabase({
|
|
2391
|
+
workspace,
|
|
2392
|
+
database,
|
|
2393
|
+
newName
|
|
2394
|
+
}) {
|
|
2395
|
+
return operationsByTag.databases.renameDatabase({
|
|
2396
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2397
|
+
body: { newName },
|
|
1305
2398
|
...this.extraProps
|
|
1306
2399
|
});
|
|
1307
2400
|
}
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
2401
|
+
getDatabaseGithubSettings({
|
|
2402
|
+
workspace,
|
|
2403
|
+
database
|
|
2404
|
+
}) {
|
|
2405
|
+
return operationsByTag.databases.getDatabaseGithubSettings({
|
|
2406
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
1312
2407
|
...this.extraProps
|
|
1313
2408
|
});
|
|
1314
2409
|
}
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
2410
|
+
updateDatabaseGithubSettings({
|
|
2411
|
+
workspace,
|
|
2412
|
+
database,
|
|
2413
|
+
settings
|
|
2414
|
+
}) {
|
|
2415
|
+
return operationsByTag.databases.updateDatabaseGithubSettings({
|
|
2416
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2417
|
+
body: settings,
|
|
2418
|
+
...this.extraProps
|
|
2419
|
+
});
|
|
2420
|
+
}
|
|
2421
|
+
deleteDatabaseGithubSettings({
|
|
2422
|
+
workspace,
|
|
2423
|
+
database
|
|
2424
|
+
}) {
|
|
2425
|
+
return operationsByTag.databases.deleteDatabaseGithubSettings({
|
|
2426
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
1319
2427
|
...this.extraProps
|
|
1320
2428
|
});
|
|
1321
2429
|
}
|
|
1322
|
-
|
|
1323
|
-
return operationsByTag.
|
|
1324
|
-
pathParams: {
|
|
1325
|
-
body: options,
|
|
2430
|
+
listRegions({ workspace }) {
|
|
2431
|
+
return operationsByTag.databases.listRegions({
|
|
2432
|
+
pathParams: { workspaceId: workspace },
|
|
1326
2433
|
...this.extraProps
|
|
1327
2434
|
});
|
|
1328
2435
|
}
|
|
1329
2436
|
}
|
|
1330
2437
|
|
|
1331
2438
|
class XataApiPlugin {
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
return new XataApiClient({ fetch: fetchImpl, apiKey });
|
|
2439
|
+
build(options) {
|
|
2440
|
+
return new XataApiClient(options);
|
|
1335
2441
|
}
|
|
1336
2442
|
}
|
|
1337
2443
|
|
|
1338
2444
|
class XataPlugin {
|
|
1339
2445
|
}
|
|
1340
2446
|
|
|
1341
|
-
function
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
2447
|
+
function cleanFilter(filter) {
|
|
2448
|
+
if (!filter)
|
|
2449
|
+
return void 0;
|
|
2450
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
|
2451
|
+
return values.length > 0 ? filter : void 0;
|
|
1346
2452
|
}
|
|
1347
2453
|
|
|
1348
2454
|
var __accessCheck$6 = (obj, member, msg) => {
|
|
@@ -1377,11 +2483,11 @@ class Page {
|
|
|
1377
2483
|
async previousPage(size, offset) {
|
|
1378
2484
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
|
1379
2485
|
}
|
|
1380
|
-
async
|
|
1381
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
|
2486
|
+
async startPage(size, offset) {
|
|
2487
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
|
1382
2488
|
}
|
|
1383
|
-
async
|
|
1384
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
|
2489
|
+
async endPage(size, offset) {
|
|
2490
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
|
1385
2491
|
}
|
|
1386
2492
|
hasNextPage() {
|
|
1387
2493
|
return this.meta.page.more;
|
|
@@ -1393,7 +2499,7 @@ const PAGINATION_DEFAULT_SIZE = 20;
|
|
|
1393
2499
|
const PAGINATION_MAX_OFFSET = 800;
|
|
1394
2500
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
|
1395
2501
|
function isCursorPaginationOptions(options) {
|
|
1396
|
-
return isDefined(options) && (isDefined(options.
|
|
2502
|
+
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
|
1397
2503
|
}
|
|
1398
2504
|
const _RecordArray = class extends Array {
|
|
1399
2505
|
constructor(...args) {
|
|
@@ -1414,6 +2520,12 @@ const _RecordArray = class extends Array {
|
|
|
1414
2520
|
toArray() {
|
|
1415
2521
|
return new Array(...this);
|
|
1416
2522
|
}
|
|
2523
|
+
toSerializable() {
|
|
2524
|
+
return JSON.parse(this.toString());
|
|
2525
|
+
}
|
|
2526
|
+
toString() {
|
|
2527
|
+
return JSON.stringify(this.toArray());
|
|
2528
|
+
}
|
|
1417
2529
|
map(callbackfn, thisArg) {
|
|
1418
2530
|
return this.toArray().map(callbackfn, thisArg);
|
|
1419
2531
|
}
|
|
@@ -1425,12 +2537,12 @@ const _RecordArray = class extends Array {
|
|
|
1425
2537
|
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
|
1426
2538
|
return new _RecordArray(newPage);
|
|
1427
2539
|
}
|
|
1428
|
-
async
|
|
1429
|
-
const newPage = await __privateGet$6(this, _page).
|
|
2540
|
+
async startPage(size, offset) {
|
|
2541
|
+
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
|
1430
2542
|
return new _RecordArray(newPage);
|
|
1431
2543
|
}
|
|
1432
|
-
async
|
|
1433
|
-
const newPage = await __privateGet$6(this, _page).
|
|
2544
|
+
async endPage(size, offset) {
|
|
2545
|
+
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
|
1434
2546
|
return new _RecordArray(newPage);
|
|
1435
2547
|
}
|
|
1436
2548
|
hasNextPage() {
|
|
@@ -1484,9 +2596,11 @@ const _Query = class {
|
|
|
1484
2596
|
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
|
1485
2597
|
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
|
1486
2598
|
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
|
1487
|
-
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns
|
|
2599
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
|
|
2600
|
+
__privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
|
|
1488
2601
|
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
|
1489
2602
|
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
|
2603
|
+
__privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
|
|
1490
2604
|
this.any = this.any.bind(this);
|
|
1491
2605
|
this.all = this.all.bind(this);
|
|
1492
2606
|
this.not = this.not.bind(this);
|
|
@@ -1600,19 +2714,29 @@ const _Query = class {
|
|
|
1600
2714
|
throw new Error("No results found.");
|
|
1601
2715
|
return records[0];
|
|
1602
2716
|
}
|
|
2717
|
+
async summarize(params = {}) {
|
|
2718
|
+
const { summaries, summariesFilter, ...options } = params;
|
|
2719
|
+
const query = new _Query(
|
|
2720
|
+
__privateGet$5(this, _repository),
|
|
2721
|
+
__privateGet$5(this, _table$1),
|
|
2722
|
+
options,
|
|
2723
|
+
__privateGet$5(this, _data)
|
|
2724
|
+
);
|
|
2725
|
+
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
|
2726
|
+
}
|
|
1603
2727
|
cache(ttl) {
|
|
1604
2728
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
|
1605
2729
|
}
|
|
1606
2730
|
nextPage(size, offset) {
|
|
1607
|
-
return this.
|
|
2731
|
+
return this.startPage(size, offset);
|
|
1608
2732
|
}
|
|
1609
2733
|
previousPage(size, offset) {
|
|
1610
|
-
return this.
|
|
2734
|
+
return this.startPage(size, offset);
|
|
1611
2735
|
}
|
|
1612
|
-
|
|
2736
|
+
startPage(size, offset) {
|
|
1613
2737
|
return this.getPaginated({ pagination: { size, offset } });
|
|
1614
2738
|
}
|
|
1615
|
-
|
|
2739
|
+
endPage(size, offset) {
|
|
1616
2740
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
|
1617
2741
|
}
|
|
1618
2742
|
hasNextPage() {
|
|
@@ -1636,7 +2760,7 @@ cleanFilterConstraint_fn = function(column, value) {
|
|
|
1636
2760
|
};
|
|
1637
2761
|
function cleanParent(data, parent) {
|
|
1638
2762
|
if (isCursorPaginationOptions(data.pagination)) {
|
|
1639
|
-
return { ...parent,
|
|
2763
|
+
return { ...parent, sort: void 0, filter: void 0 };
|
|
1640
2764
|
}
|
|
1641
2765
|
return parent;
|
|
1642
2766
|
}
|
|
@@ -1654,7 +2778,11 @@ function isSortFilterString(value) {
|
|
|
1654
2778
|
return isString(value);
|
|
1655
2779
|
}
|
|
1656
2780
|
function isSortFilterBase(filter) {
|
|
1657
|
-
return isObject(filter) && Object.
|
|
2781
|
+
return isObject(filter) && Object.entries(filter).every(([key, value]) => {
|
|
2782
|
+
if (key === "*")
|
|
2783
|
+
return value === "random";
|
|
2784
|
+
return value === "asc" || value === "desc";
|
|
2785
|
+
});
|
|
1658
2786
|
}
|
|
1659
2787
|
function isSortFilterObject(filter) {
|
|
1660
2788
|
return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
|
|
@@ -1695,7 +2823,8 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
|
1695
2823
|
__accessCheck$4(obj, member, "access private method");
|
|
1696
2824
|
return method;
|
|
1697
2825
|
};
|
|
1698
|
-
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn,
|
|
2826
|
+
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;
|
|
2827
|
+
const BULK_OPERATION_MAX_SIZE = 1e3;
|
|
1699
2828
|
class Repository extends Query {
|
|
1700
2829
|
}
|
|
1701
2830
|
class RestRepository extends Query {
|
|
@@ -1707,10 +2836,12 @@ class RestRepository extends Query {
|
|
|
1707
2836
|
);
|
|
1708
2837
|
__privateAdd$4(this, _insertRecordWithoutId);
|
|
1709
2838
|
__privateAdd$4(this, _insertRecordWithId);
|
|
1710
|
-
__privateAdd$4(this,
|
|
2839
|
+
__privateAdd$4(this, _insertRecords);
|
|
1711
2840
|
__privateAdd$4(this, _updateRecordWithID);
|
|
2841
|
+
__privateAdd$4(this, _updateRecords);
|
|
1712
2842
|
__privateAdd$4(this, _upsertRecordWithID);
|
|
1713
2843
|
__privateAdd$4(this, _deleteRecord);
|
|
2844
|
+
__privateAdd$4(this, _deleteRecords);
|
|
1714
2845
|
__privateAdd$4(this, _setCacheQuery);
|
|
1715
2846
|
__privateAdd$4(this, _getCacheQuery);
|
|
1716
2847
|
__privateAdd$4(this, _getSchemaTables$1);
|
|
@@ -1724,10 +2855,7 @@ class RestRepository extends Query {
|
|
|
1724
2855
|
__privateSet$4(this, _db, options.db);
|
|
1725
2856
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
|
1726
2857
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
|
1727
|
-
__privateSet$4(this, _getFetchProps,
|
|
1728
|
-
const props = await options.pluginOptions.getFetchProps();
|
|
1729
|
-
return { ...props, sessionID: generateUUID() };
|
|
1730
|
-
});
|
|
2858
|
+
__privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
|
|
1731
2859
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
|
1732
2860
|
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
|
1733
2861
|
return trace(name, fn, {
|
|
@@ -1738,25 +2866,28 @@ class RestRepository extends Query {
|
|
|
1738
2866
|
});
|
|
1739
2867
|
});
|
|
1740
2868
|
}
|
|
1741
|
-
async create(a, b, c) {
|
|
2869
|
+
async create(a, b, c, d) {
|
|
1742
2870
|
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
|
2871
|
+
const ifVersion = parseIfVersion(b, c, d);
|
|
1743
2872
|
if (Array.isArray(a)) {
|
|
1744
2873
|
if (a.length === 0)
|
|
1745
2874
|
return [];
|
|
1746
|
-
const
|
|
1747
|
-
|
|
2875
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
|
2876
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
2877
|
+
const result = await this.read(ids, columns);
|
|
2878
|
+
return result;
|
|
1748
2879
|
}
|
|
1749
2880
|
if (isString(a) && isObject(b)) {
|
|
1750
2881
|
if (a === "")
|
|
1751
2882
|
throw new Error("The id can't be empty");
|
|
1752
2883
|
const columns = isStringArray(c) ? c : void 0;
|
|
1753
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
|
2884
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
|
1754
2885
|
}
|
|
1755
2886
|
if (isObject(a) && isString(a.id)) {
|
|
1756
2887
|
if (a.id === "")
|
|
1757
2888
|
throw new Error("The id can't be empty");
|
|
1758
2889
|
const columns = isStringArray(b) ? b : void 0;
|
|
1759
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
|
2890
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
|
1760
2891
|
}
|
|
1761
2892
|
if (isObject(a)) {
|
|
1762
2893
|
const columns = isStringArray(b) ? b : void 0;
|
|
@@ -1781,17 +2912,17 @@ class RestRepository extends Query {
|
|
|
1781
2912
|
}
|
|
1782
2913
|
const id = extractId(a);
|
|
1783
2914
|
if (id) {
|
|
1784
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1785
2915
|
try {
|
|
1786
2916
|
const response = await getRecord({
|
|
1787
2917
|
pathParams: {
|
|
1788
2918
|
workspace: "{workspaceId}",
|
|
1789
2919
|
dbBranchName: "{dbBranch}",
|
|
2920
|
+
region: "{region}",
|
|
1790
2921
|
tableName: __privateGet$4(this, _table),
|
|
1791
2922
|
recordId: id
|
|
1792
2923
|
},
|
|
1793
2924
|
queryParams: { columns },
|
|
1794
|
-
...
|
|
2925
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
1795
2926
|
});
|
|
1796
2927
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1797
2928
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
@@ -1824,31 +2955,42 @@ class RestRepository extends Query {
|
|
|
1824
2955
|
return result;
|
|
1825
2956
|
});
|
|
1826
2957
|
}
|
|
1827
|
-
async update(a, b, c) {
|
|
2958
|
+
async update(a, b, c, d) {
|
|
1828
2959
|
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
|
2960
|
+
const ifVersion = parseIfVersion(b, c, d);
|
|
1829
2961
|
if (Array.isArray(a)) {
|
|
1830
2962
|
if (a.length === 0)
|
|
1831
2963
|
return [];
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
2964
|
+
const existing = await this.read(a, ["id"]);
|
|
2965
|
+
const updates = a.filter((_item, index) => existing[index] !== null);
|
|
2966
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
|
|
2967
|
+
ifVersion,
|
|
2968
|
+
upsert: false
|
|
2969
|
+
});
|
|
1835
2970
|
const columns = isStringArray(b) ? b : ["*"];
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
if (isString(a) && isObject(b)) {
|
|
1839
|
-
const columns = isStringArray(c) ? c : void 0;
|
|
1840
|
-
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
|
|
2971
|
+
const result = await this.read(a, columns);
|
|
2972
|
+
return result;
|
|
1841
2973
|
}
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
2974
|
+
try {
|
|
2975
|
+
if (isString(a) && isObject(b)) {
|
|
2976
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
2977
|
+
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
|
2978
|
+
}
|
|
2979
|
+
if (isObject(a) && isString(a.id)) {
|
|
2980
|
+
const columns = isStringArray(b) ? b : void 0;
|
|
2981
|
+
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
|
2982
|
+
}
|
|
2983
|
+
} catch (error) {
|
|
2984
|
+
if (error.status === 422)
|
|
2985
|
+
return null;
|
|
2986
|
+
throw error;
|
|
1845
2987
|
}
|
|
1846
2988
|
throw new Error("Invalid arguments for update method");
|
|
1847
2989
|
});
|
|
1848
2990
|
}
|
|
1849
|
-
async updateOrThrow(a, b, c) {
|
|
2991
|
+
async updateOrThrow(a, b, c, d) {
|
|
1850
2992
|
return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
|
|
1851
|
-
const result = await this.update(a, b, c);
|
|
2993
|
+
const result = await this.update(a, b, c, d);
|
|
1852
2994
|
if (Array.isArray(result)) {
|
|
1853
2995
|
const missingIds = compact(
|
|
1854
2996
|
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
|
@@ -1865,37 +3007,69 @@ class RestRepository extends Query {
|
|
|
1865
3007
|
return result;
|
|
1866
3008
|
});
|
|
1867
3009
|
}
|
|
1868
|
-
async createOrUpdate(a, b, c) {
|
|
3010
|
+
async createOrUpdate(a, b, c, d) {
|
|
1869
3011
|
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
|
3012
|
+
const ifVersion = parseIfVersion(b, c, d);
|
|
1870
3013
|
if (Array.isArray(a)) {
|
|
1871
3014
|
if (a.length === 0)
|
|
1872
3015
|
return [];
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
3016
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
|
|
3017
|
+
ifVersion,
|
|
3018
|
+
upsert: true
|
|
3019
|
+
});
|
|
1876
3020
|
const columns = isStringArray(b) ? b : ["*"];
|
|
1877
|
-
|
|
3021
|
+
const result = await this.read(a, columns);
|
|
3022
|
+
return result;
|
|
1878
3023
|
}
|
|
1879
3024
|
if (isString(a) && isObject(b)) {
|
|
1880
3025
|
const columns = isStringArray(c) ? c : void 0;
|
|
1881
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
|
|
3026
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
|
1882
3027
|
}
|
|
1883
3028
|
if (isObject(a) && isString(a.id)) {
|
|
1884
3029
|
const columns = isStringArray(c) ? c : void 0;
|
|
1885
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
|
3030
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
|
1886
3031
|
}
|
|
1887
3032
|
throw new Error("Invalid arguments for createOrUpdate method");
|
|
1888
3033
|
});
|
|
1889
3034
|
}
|
|
3035
|
+
async createOrReplace(a, b, c, d) {
|
|
3036
|
+
return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
|
|
3037
|
+
const ifVersion = parseIfVersion(b, c, d);
|
|
3038
|
+
if (Array.isArray(a)) {
|
|
3039
|
+
if (a.length === 0)
|
|
3040
|
+
return [];
|
|
3041
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
|
3042
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
3043
|
+
const result = await this.read(ids, columns);
|
|
3044
|
+
return result;
|
|
3045
|
+
}
|
|
3046
|
+
if (isString(a) && isObject(b)) {
|
|
3047
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
3048
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
|
3049
|
+
}
|
|
3050
|
+
if (isObject(a) && isString(a.id)) {
|
|
3051
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
3052
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
|
3053
|
+
}
|
|
3054
|
+
throw new Error("Invalid arguments for createOrReplace method");
|
|
3055
|
+
});
|
|
3056
|
+
}
|
|
1890
3057
|
async delete(a, b) {
|
|
1891
3058
|
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
|
1892
3059
|
if (Array.isArray(a)) {
|
|
1893
3060
|
if (a.length === 0)
|
|
1894
3061
|
return [];
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
3062
|
+
const ids = a.map((o) => {
|
|
3063
|
+
if (isString(o))
|
|
3064
|
+
return o;
|
|
3065
|
+
if (isString(o.id))
|
|
3066
|
+
return o.id;
|
|
3067
|
+
throw new Error("Invalid arguments for delete method");
|
|
3068
|
+
});
|
|
3069
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
3070
|
+
const result = await this.read(a, columns);
|
|
3071
|
+
await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
|
|
3072
|
+
return result;
|
|
1899
3073
|
}
|
|
1900
3074
|
if (isString(a)) {
|
|
1901
3075
|
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
|
|
@@ -1926,40 +3100,88 @@ class RestRepository extends Query {
|
|
|
1926
3100
|
}
|
|
1927
3101
|
async search(query, options = {}) {
|
|
1928
3102
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
|
1929
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1930
3103
|
const { records } = await searchTable({
|
|
1931
|
-
pathParams: {
|
|
3104
|
+
pathParams: {
|
|
3105
|
+
workspace: "{workspaceId}",
|
|
3106
|
+
dbBranchName: "{dbBranch}",
|
|
3107
|
+
region: "{region}",
|
|
3108
|
+
tableName: __privateGet$4(this, _table)
|
|
3109
|
+
},
|
|
1932
3110
|
body: {
|
|
1933
3111
|
query,
|
|
1934
3112
|
fuzziness: options.fuzziness,
|
|
1935
3113
|
prefix: options.prefix,
|
|
1936
3114
|
highlight: options.highlight,
|
|
1937
3115
|
filter: options.filter,
|
|
1938
|
-
boosters: options.boosters
|
|
3116
|
+
boosters: options.boosters,
|
|
3117
|
+
page: options.page,
|
|
3118
|
+
target: options.target
|
|
3119
|
+
},
|
|
3120
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3121
|
+
});
|
|
3122
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
3123
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
|
3124
|
+
});
|
|
3125
|
+
}
|
|
3126
|
+
async vectorSearch(column, query, options) {
|
|
3127
|
+
return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
|
|
3128
|
+
const { records } = await vectorSearchTable({
|
|
3129
|
+
pathParams: {
|
|
3130
|
+
workspace: "{workspaceId}",
|
|
3131
|
+
dbBranchName: "{dbBranch}",
|
|
3132
|
+
region: "{region}",
|
|
3133
|
+
tableName: __privateGet$4(this, _table)
|
|
3134
|
+
},
|
|
3135
|
+
body: {
|
|
3136
|
+
column,
|
|
3137
|
+
queryVector: query,
|
|
3138
|
+
similarityFunction: options?.similarityFunction,
|
|
3139
|
+
size: options?.size,
|
|
3140
|
+
filter: options?.filter
|
|
1939
3141
|
},
|
|
1940
|
-
...
|
|
3142
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
1941
3143
|
});
|
|
1942
3144
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1943
3145
|
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
|
1944
3146
|
});
|
|
1945
3147
|
}
|
|
3148
|
+
async aggregate(aggs, filter) {
|
|
3149
|
+
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
|
3150
|
+
const result = await aggregateTable({
|
|
3151
|
+
pathParams: {
|
|
3152
|
+
workspace: "{workspaceId}",
|
|
3153
|
+
dbBranchName: "{dbBranch}",
|
|
3154
|
+
region: "{region}",
|
|
3155
|
+
tableName: __privateGet$4(this, _table)
|
|
3156
|
+
},
|
|
3157
|
+
body: { aggs, filter },
|
|
3158
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3159
|
+
});
|
|
3160
|
+
return result;
|
|
3161
|
+
});
|
|
3162
|
+
}
|
|
1946
3163
|
async query(query) {
|
|
1947
3164
|
return __privateGet$4(this, _trace).call(this, "query", async () => {
|
|
1948
3165
|
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
|
1949
3166
|
if (cacheQuery)
|
|
1950
3167
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
|
1951
3168
|
const data = query.getQueryOptions();
|
|
1952
|
-
const body = {
|
|
1953
|
-
filter: cleanFilter(data.filter),
|
|
1954
|
-
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
|
1955
|
-
page: data.pagination,
|
|
1956
|
-
columns: data.columns
|
|
1957
|
-
};
|
|
1958
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1959
3169
|
const { meta, records: objects } = await queryTable({
|
|
1960
|
-
pathParams: {
|
|
1961
|
-
|
|
1962
|
-
|
|
3170
|
+
pathParams: {
|
|
3171
|
+
workspace: "{workspaceId}",
|
|
3172
|
+
dbBranchName: "{dbBranch}",
|
|
3173
|
+
region: "{region}",
|
|
3174
|
+
tableName: __privateGet$4(this, _table)
|
|
3175
|
+
},
|
|
3176
|
+
body: {
|
|
3177
|
+
filter: cleanFilter(data.filter),
|
|
3178
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
|
3179
|
+
page: data.pagination,
|
|
3180
|
+
columns: data.columns ?? ["*"],
|
|
3181
|
+
consistency: data.consistency
|
|
3182
|
+
},
|
|
3183
|
+
fetchOptions: data.fetchOptions,
|
|
3184
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
1963
3185
|
});
|
|
1964
3186
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1965
3187
|
const records = objects.map(
|
|
@@ -1969,6 +3191,58 @@ class RestRepository extends Query {
|
|
|
1969
3191
|
return new Page(query, meta, records);
|
|
1970
3192
|
});
|
|
1971
3193
|
}
|
|
3194
|
+
async summarizeTable(query, summaries, summariesFilter) {
|
|
3195
|
+
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
|
3196
|
+
const data = query.getQueryOptions();
|
|
3197
|
+
const result = await summarizeTable({
|
|
3198
|
+
pathParams: {
|
|
3199
|
+
workspace: "{workspaceId}",
|
|
3200
|
+
dbBranchName: "{dbBranch}",
|
|
3201
|
+
region: "{region}",
|
|
3202
|
+
tableName: __privateGet$4(this, _table)
|
|
3203
|
+
},
|
|
3204
|
+
body: {
|
|
3205
|
+
filter: cleanFilter(data.filter),
|
|
3206
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
|
3207
|
+
columns: data.columns,
|
|
3208
|
+
consistency: data.consistency,
|
|
3209
|
+
page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
|
|
3210
|
+
summaries,
|
|
3211
|
+
summariesFilter
|
|
3212
|
+
},
|
|
3213
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3214
|
+
});
|
|
3215
|
+
return result;
|
|
3216
|
+
});
|
|
3217
|
+
}
|
|
3218
|
+
ask(question, options) {
|
|
3219
|
+
const params = {
|
|
3220
|
+
pathParams: {
|
|
3221
|
+
workspace: "{workspaceId}",
|
|
3222
|
+
dbBranchName: "{dbBranch}",
|
|
3223
|
+
region: "{region}",
|
|
3224
|
+
tableName: __privateGet$4(this, _table)
|
|
3225
|
+
},
|
|
3226
|
+
body: {
|
|
3227
|
+
question,
|
|
3228
|
+
...options
|
|
3229
|
+
},
|
|
3230
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3231
|
+
};
|
|
3232
|
+
if (options?.onMessage) {
|
|
3233
|
+
fetchSSERequest({
|
|
3234
|
+
endpoint: "dataPlane",
|
|
3235
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
|
3236
|
+
method: "POST",
|
|
3237
|
+
onMessage: (message) => {
|
|
3238
|
+
options.onMessage?.({ answer: message.text, records: message.records });
|
|
3239
|
+
},
|
|
3240
|
+
...params
|
|
3241
|
+
});
|
|
3242
|
+
} else {
|
|
3243
|
+
return askTable(params);
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
1972
3246
|
}
|
|
1973
3247
|
_table = new WeakMap();
|
|
1974
3248
|
_getFetchProps = new WeakMap();
|
|
@@ -1978,65 +3252,83 @@ _schemaTables$2 = new WeakMap();
|
|
|
1978
3252
|
_trace = new WeakMap();
|
|
1979
3253
|
_insertRecordWithoutId = new WeakSet();
|
|
1980
3254
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1981
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1982
3255
|
const record = transformObjectLinks(object);
|
|
1983
3256
|
const response = await insertRecord({
|
|
1984
3257
|
pathParams: {
|
|
1985
3258
|
workspace: "{workspaceId}",
|
|
1986
3259
|
dbBranchName: "{dbBranch}",
|
|
3260
|
+
region: "{region}",
|
|
1987
3261
|
tableName: __privateGet$4(this, _table)
|
|
1988
3262
|
},
|
|
1989
3263
|
queryParams: { columns },
|
|
1990
3264
|
body: record,
|
|
1991
|
-
...
|
|
3265
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
1992
3266
|
});
|
|
1993
3267
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1994
3268
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
1995
3269
|
};
|
|
1996
3270
|
_insertRecordWithId = new WeakSet();
|
|
1997
|
-
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
|
1998
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
3271
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
|
1999
3272
|
const record = transformObjectLinks(object);
|
|
2000
3273
|
const response = await insertRecordWithID({
|
|
2001
3274
|
pathParams: {
|
|
2002
3275
|
workspace: "{workspaceId}",
|
|
2003
3276
|
dbBranchName: "{dbBranch}",
|
|
3277
|
+
region: "{region}",
|
|
2004
3278
|
tableName: __privateGet$4(this, _table),
|
|
2005
3279
|
recordId
|
|
2006
3280
|
},
|
|
2007
3281
|
body: record,
|
|
2008
|
-
queryParams: { createOnly
|
|
2009
|
-
...
|
|
3282
|
+
queryParams: { createOnly, columns, ifVersion },
|
|
3283
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2010
3284
|
});
|
|
2011
3285
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
2012
3286
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
2013
3287
|
};
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
const
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
3288
|
+
_insertRecords = new WeakSet();
|
|
3289
|
+
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
|
3290
|
+
const chunkedOperations = chunk(
|
|
3291
|
+
objects.map((object) => ({
|
|
3292
|
+
insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
|
|
3293
|
+
})),
|
|
3294
|
+
BULK_OPERATION_MAX_SIZE
|
|
3295
|
+
);
|
|
3296
|
+
const ids = [];
|
|
3297
|
+
for (const operations of chunkedOperations) {
|
|
3298
|
+
const { results } = await branchTransaction({
|
|
3299
|
+
pathParams: {
|
|
3300
|
+
workspace: "{workspaceId}",
|
|
3301
|
+
dbBranchName: "{dbBranch}",
|
|
3302
|
+
region: "{region}"
|
|
3303
|
+
},
|
|
3304
|
+
body: { operations },
|
|
3305
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3306
|
+
});
|
|
3307
|
+
for (const result of results) {
|
|
3308
|
+
if (result.operation === "insert") {
|
|
3309
|
+
ids.push(result.id);
|
|
3310
|
+
} else {
|
|
3311
|
+
ids.push(null);
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
2026
3314
|
}
|
|
2027
|
-
|
|
2028
|
-
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
|
|
3315
|
+
return ids;
|
|
2029
3316
|
};
|
|
2030
3317
|
_updateRecordWithID = new WeakSet();
|
|
2031
|
-
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
2032
|
-
const
|
|
2033
|
-
const record = transformObjectLinks(object);
|
|
3318
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
|
3319
|
+
const { id: _id, ...record } = transformObjectLinks(object);
|
|
2034
3320
|
try {
|
|
2035
3321
|
const response = await updateRecordWithID({
|
|
2036
|
-
pathParams: {
|
|
2037
|
-
|
|
3322
|
+
pathParams: {
|
|
3323
|
+
workspace: "{workspaceId}",
|
|
3324
|
+
dbBranchName: "{dbBranch}",
|
|
3325
|
+
region: "{region}",
|
|
3326
|
+
tableName: __privateGet$4(this, _table),
|
|
3327
|
+
recordId
|
|
3328
|
+
},
|
|
3329
|
+
queryParams: { columns, ifVersion },
|
|
2038
3330
|
body: record,
|
|
2039
|
-
...
|
|
3331
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2040
3332
|
});
|
|
2041
3333
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
2042
3334
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
@@ -2047,26 +3339,65 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
|
2047
3339
|
throw e;
|
|
2048
3340
|
}
|
|
2049
3341
|
};
|
|
3342
|
+
_updateRecords = new WeakSet();
|
|
3343
|
+
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
|
3344
|
+
const chunkedOperations = chunk(
|
|
3345
|
+
objects.map(({ id, ...object }) => ({
|
|
3346
|
+
update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
|
|
3347
|
+
})),
|
|
3348
|
+
BULK_OPERATION_MAX_SIZE
|
|
3349
|
+
);
|
|
3350
|
+
const ids = [];
|
|
3351
|
+
for (const operations of chunkedOperations) {
|
|
3352
|
+
const { results } = await branchTransaction({
|
|
3353
|
+
pathParams: {
|
|
3354
|
+
workspace: "{workspaceId}",
|
|
3355
|
+
dbBranchName: "{dbBranch}",
|
|
3356
|
+
region: "{region}"
|
|
3357
|
+
},
|
|
3358
|
+
body: { operations },
|
|
3359
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3360
|
+
});
|
|
3361
|
+
for (const result of results) {
|
|
3362
|
+
if (result.operation === "update") {
|
|
3363
|
+
ids.push(result.id);
|
|
3364
|
+
} else {
|
|
3365
|
+
ids.push(null);
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
return ids;
|
|
3370
|
+
};
|
|
2050
3371
|
_upsertRecordWithID = new WeakSet();
|
|
2051
|
-
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
2052
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
3372
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
|
2053
3373
|
const response = await upsertRecordWithID({
|
|
2054
|
-
pathParams: {
|
|
2055
|
-
|
|
3374
|
+
pathParams: {
|
|
3375
|
+
workspace: "{workspaceId}",
|
|
3376
|
+
dbBranchName: "{dbBranch}",
|
|
3377
|
+
region: "{region}",
|
|
3378
|
+
tableName: __privateGet$4(this, _table),
|
|
3379
|
+
recordId
|
|
3380
|
+
},
|
|
3381
|
+
queryParams: { columns, ifVersion },
|
|
2056
3382
|
body: object,
|
|
2057
|
-
...
|
|
3383
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2058
3384
|
});
|
|
2059
3385
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
2060
3386
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
2061
3387
|
};
|
|
2062
3388
|
_deleteRecord = new WeakSet();
|
|
2063
3389
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
2064
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2065
3390
|
try {
|
|
2066
3391
|
const response = await deleteRecord({
|
|
2067
|
-
pathParams: {
|
|
3392
|
+
pathParams: {
|
|
3393
|
+
workspace: "{workspaceId}",
|
|
3394
|
+
dbBranchName: "{dbBranch}",
|
|
3395
|
+
region: "{region}",
|
|
3396
|
+
tableName: __privateGet$4(this, _table),
|
|
3397
|
+
recordId
|
|
3398
|
+
},
|
|
2068
3399
|
queryParams: { columns },
|
|
2069
|
-
...
|
|
3400
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2070
3401
|
});
|
|
2071
3402
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
2072
3403
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
@@ -2077,17 +3408,36 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
|
2077
3408
|
throw e;
|
|
2078
3409
|
}
|
|
2079
3410
|
};
|
|
3411
|
+
_deleteRecords = new WeakSet();
|
|
3412
|
+
deleteRecords_fn = async function(recordIds) {
|
|
3413
|
+
const chunkedOperations = chunk(
|
|
3414
|
+
recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
|
3415
|
+
BULK_OPERATION_MAX_SIZE
|
|
3416
|
+
);
|
|
3417
|
+
for (const operations of chunkedOperations) {
|
|
3418
|
+
await branchTransaction({
|
|
3419
|
+
pathParams: {
|
|
3420
|
+
workspace: "{workspaceId}",
|
|
3421
|
+
dbBranchName: "{dbBranch}",
|
|
3422
|
+
region: "{region}"
|
|
3423
|
+
},
|
|
3424
|
+
body: { operations },
|
|
3425
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3426
|
+
});
|
|
3427
|
+
}
|
|
3428
|
+
};
|
|
2080
3429
|
_setCacheQuery = new WeakSet();
|
|
2081
3430
|
setCacheQuery_fn = async function(query, meta, records) {
|
|
2082
|
-
await __privateGet$4(this, _cache)
|
|
3431
|
+
await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
|
2083
3432
|
};
|
|
2084
3433
|
_getCacheQuery = new WeakSet();
|
|
2085
3434
|
getCacheQuery_fn = async function(query) {
|
|
2086
3435
|
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
|
2087
|
-
const result = await __privateGet$4(this, _cache)
|
|
3436
|
+
const result = await __privateGet$4(this, _cache)?.get(key);
|
|
2088
3437
|
if (!result)
|
|
2089
3438
|
return null;
|
|
2090
|
-
const
|
|
3439
|
+
const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
|
|
3440
|
+
const { cache: ttl = defaultTTL } = query.getQueryOptions();
|
|
2091
3441
|
if (ttl < 0)
|
|
2092
3442
|
return null;
|
|
2093
3443
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
|
@@ -2097,10 +3447,9 @@ _getSchemaTables$1 = new WeakSet();
|
|
|
2097
3447
|
getSchemaTables_fn$1 = async function() {
|
|
2098
3448
|
if (__privateGet$4(this, _schemaTables$2))
|
|
2099
3449
|
return __privateGet$4(this, _schemaTables$2);
|
|
2100
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2101
3450
|
const { schema } = await getBranchDetails({
|
|
2102
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
2103
|
-
...
|
|
3451
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
3452
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2104
3453
|
});
|
|
2105
3454
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
|
2106
3455
|
return schema.tables;
|
|
@@ -2113,23 +3462,23 @@ const transformObjectLinks = (object) => {
|
|
|
2113
3462
|
}, {});
|
|
2114
3463
|
};
|
|
2115
3464
|
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2116
|
-
const
|
|
3465
|
+
const data = {};
|
|
2117
3466
|
const { xata, ...rest } = object ?? {};
|
|
2118
|
-
Object.assign(
|
|
3467
|
+
Object.assign(data, rest);
|
|
2119
3468
|
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
|
2120
3469
|
if (!columns)
|
|
2121
3470
|
console.error(`Table ${table} not found in schema`);
|
|
2122
3471
|
for (const column of columns ?? []) {
|
|
2123
3472
|
if (!isValidColumn(selectedColumns, column))
|
|
2124
3473
|
continue;
|
|
2125
|
-
const value =
|
|
3474
|
+
const value = data[column.name];
|
|
2126
3475
|
switch (column.type) {
|
|
2127
3476
|
case "datetime": {
|
|
2128
|
-
const date = value !== void 0 ? new Date(value) :
|
|
2129
|
-
if (date && isNaN(date.getTime())) {
|
|
3477
|
+
const date = value !== void 0 ? new Date(value) : null;
|
|
3478
|
+
if (date !== null && isNaN(date.getTime())) {
|
|
2130
3479
|
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
|
2131
|
-
} else
|
|
2132
|
-
|
|
3480
|
+
} else {
|
|
3481
|
+
data[column.name] = date;
|
|
2133
3482
|
}
|
|
2134
3483
|
break;
|
|
2135
3484
|
}
|
|
@@ -2148,41 +3497,52 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
|
2148
3497
|
}
|
|
2149
3498
|
return acc;
|
|
2150
3499
|
}, []);
|
|
2151
|
-
|
|
3500
|
+
data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
|
|
2152
3501
|
} else {
|
|
2153
|
-
|
|
3502
|
+
data[column.name] = null;
|
|
2154
3503
|
}
|
|
2155
3504
|
break;
|
|
2156
3505
|
}
|
|
2157
3506
|
default:
|
|
2158
|
-
|
|
3507
|
+
data[column.name] = value ?? null;
|
|
2159
3508
|
if (column.notNull === true && value === null) {
|
|
2160
3509
|
console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
|
|
2161
3510
|
}
|
|
2162
3511
|
break;
|
|
2163
3512
|
}
|
|
2164
3513
|
}
|
|
2165
|
-
|
|
2166
|
-
|
|
3514
|
+
const record = { ...data };
|
|
3515
|
+
record.read = function(columns2) {
|
|
3516
|
+
return db[table].read(record["id"], columns2);
|
|
3517
|
+
};
|
|
3518
|
+
record.update = function(data2, b, c) {
|
|
3519
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
|
3520
|
+
const ifVersion = parseIfVersion(b, c);
|
|
3521
|
+
return db[table].update(record["id"], data2, columns2, { ifVersion });
|
|
2167
3522
|
};
|
|
2168
|
-
|
|
2169
|
-
|
|
3523
|
+
record.replace = function(data2, b, c) {
|
|
3524
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
|
3525
|
+
const ifVersion = parseIfVersion(b, c);
|
|
3526
|
+
return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
|
|
2170
3527
|
};
|
|
2171
|
-
|
|
2172
|
-
return db[table].delete(
|
|
3528
|
+
record.delete = function() {
|
|
3529
|
+
return db[table].delete(record["id"]);
|
|
2173
3530
|
};
|
|
2174
|
-
|
|
3531
|
+
record.getMetadata = function() {
|
|
2175
3532
|
return xata;
|
|
2176
3533
|
};
|
|
2177
|
-
|
|
2178
|
-
|
|
3534
|
+
record.toSerializable = function() {
|
|
3535
|
+
return JSON.parse(JSON.stringify(transformObjectLinks(data)));
|
|
3536
|
+
};
|
|
3537
|
+
record.toString = function() {
|
|
3538
|
+
return JSON.stringify(transformObjectLinks(data));
|
|
3539
|
+
};
|
|
3540
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
|
3541
|
+
Object.defineProperty(record, prop, { enumerable: false });
|
|
2179
3542
|
}
|
|
2180
|
-
Object.freeze(
|
|
2181
|
-
return
|
|
3543
|
+
Object.freeze(record);
|
|
3544
|
+
return record;
|
|
2182
3545
|
};
|
|
2183
|
-
function isResponseWithRecords(value) {
|
|
2184
|
-
return isObject(value) && Array.isArray(value.records);
|
|
2185
|
-
}
|
|
2186
3546
|
function extractId(value) {
|
|
2187
3547
|
if (isString(value))
|
|
2188
3548
|
return value;
|
|
@@ -2190,12 +3550,6 @@ function extractId(value) {
|
|
|
2190
3550
|
return value.id;
|
|
2191
3551
|
return void 0;
|
|
2192
3552
|
}
|
|
2193
|
-
function cleanFilter(filter) {
|
|
2194
|
-
if (!filter)
|
|
2195
|
-
return void 0;
|
|
2196
|
-
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
|
2197
|
-
return values.length > 0 ? filter : void 0;
|
|
2198
|
-
}
|
|
2199
3553
|
function isValidColumn(columns, column) {
|
|
2200
3554
|
if (columns.includes("*"))
|
|
2201
3555
|
return true;
|
|
@@ -2205,6 +3559,14 @@ function isValidColumn(columns, column) {
|
|
|
2205
3559
|
}
|
|
2206
3560
|
return columns.includes(column.name);
|
|
2207
3561
|
}
|
|
3562
|
+
function parseIfVersion(...args) {
|
|
3563
|
+
for (const arg of args) {
|
|
3564
|
+
if (isObject(arg) && isNumber(arg.ifVersion)) {
|
|
3565
|
+
return arg.ifVersion;
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
return void 0;
|
|
3569
|
+
}
|
|
2208
3570
|
|
|
2209
3571
|
var __accessCheck$3 = (obj, member, msg) => {
|
|
2210
3572
|
if (!member.has(obj))
|
|
@@ -2363,19 +3725,19 @@ class SearchPlugin extends XataPlugin {
|
|
|
2363
3725
|
__privateAdd$1(this, _schemaTables, void 0);
|
|
2364
3726
|
__privateSet$1(this, _schemaTables, schemaTables);
|
|
2365
3727
|
}
|
|
2366
|
-
build(
|
|
3728
|
+
build(pluginOptions) {
|
|
2367
3729
|
return {
|
|
2368
3730
|
all: async (query, options = {}) => {
|
|
2369
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
|
2370
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
|
3731
|
+
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
|
3732
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
|
2371
3733
|
return records.map((record) => {
|
|
2372
3734
|
const { table = "orphan" } = record.xata;
|
|
2373
3735
|
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
|
2374
3736
|
});
|
|
2375
3737
|
},
|
|
2376
3738
|
byTable: async (query, options = {}) => {
|
|
2377
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
|
2378
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
|
3739
|
+
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
|
3740
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
|
2379
3741
|
return records.reduce((acc, record) => {
|
|
2380
3742
|
const { table = "orphan" } = record.xata;
|
|
2381
3743
|
const items = acc[table] ?? [];
|
|
@@ -2388,108 +3750,39 @@ class SearchPlugin extends XataPlugin {
|
|
|
2388
3750
|
}
|
|
2389
3751
|
_schemaTables = new WeakMap();
|
|
2390
3752
|
_search = new WeakSet();
|
|
2391
|
-
search_fn = async function(query, options,
|
|
2392
|
-
const
|
|
2393
|
-
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
|
3753
|
+
search_fn = async function(query, options, pluginOptions) {
|
|
3754
|
+
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
|
2394
3755
|
const { records } = await searchBranch({
|
|
2395
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
2396
|
-
body: { tables, query, fuzziness, prefix, highlight },
|
|
2397
|
-
...
|
|
3756
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
3757
|
+
body: { tables, query, fuzziness, prefix, highlight, page },
|
|
3758
|
+
...pluginOptions
|
|
2398
3759
|
});
|
|
2399
3760
|
return records;
|
|
2400
3761
|
};
|
|
2401
3762
|
_getSchemaTables = new WeakSet();
|
|
2402
|
-
getSchemaTables_fn = async function(
|
|
3763
|
+
getSchemaTables_fn = async function(pluginOptions) {
|
|
2403
3764
|
if (__privateGet$1(this, _schemaTables))
|
|
2404
3765
|
return __privateGet$1(this, _schemaTables);
|
|
2405
|
-
const fetchProps = await getFetchProps();
|
|
2406
3766
|
const { schema } = await getBranchDetails({
|
|
2407
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
2408
|
-
...
|
|
3767
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
3768
|
+
...pluginOptions
|
|
2409
3769
|
});
|
|
2410
3770
|
__privateSet$1(this, _schemaTables, schema.tables);
|
|
2411
3771
|
return schema.tables;
|
|
2412
3772
|
};
|
|
2413
3773
|
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
const gitBranch = envBranch || await getGitBranch();
|
|
2427
|
-
return resolveXataBranch(gitBranch, options);
|
|
2428
|
-
}
|
|
2429
|
-
async function getCurrentBranchDetails(options) {
|
|
2430
|
-
const branch = await getCurrentBranchName(options);
|
|
2431
|
-
return getDatabaseBranch(branch, options);
|
|
2432
|
-
}
|
|
2433
|
-
async function resolveXataBranch(gitBranch, options) {
|
|
2434
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
2435
|
-
const apiKey = options?.apiKey || getAPIKey();
|
|
2436
|
-
if (!databaseURL)
|
|
2437
|
-
throw new Error(
|
|
2438
|
-
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
|
2439
|
-
);
|
|
2440
|
-
if (!apiKey)
|
|
2441
|
-
throw new Error(
|
|
2442
|
-
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
|
2443
|
-
);
|
|
2444
|
-
const [protocol, , host, , dbName] = databaseURL.split("/");
|
|
2445
|
-
const [workspace] = host.split(".");
|
|
2446
|
-
const { fallbackBranch } = getEnvironment();
|
|
2447
|
-
const { branch } = await resolveBranch({
|
|
2448
|
-
apiKey,
|
|
2449
|
-
apiUrl: databaseURL,
|
|
2450
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
|
2451
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
|
2452
|
-
pathParams: { dbName, workspace },
|
|
2453
|
-
queryParams: { gitBranch, fallbackBranch },
|
|
2454
|
-
trace: defaultTrace
|
|
2455
|
-
});
|
|
2456
|
-
return branch;
|
|
2457
|
-
}
|
|
2458
|
-
async function getDatabaseBranch(branch, options) {
|
|
2459
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
2460
|
-
const apiKey = options?.apiKey || getAPIKey();
|
|
2461
|
-
if (!databaseURL)
|
|
2462
|
-
throw new Error(
|
|
2463
|
-
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
|
2464
|
-
);
|
|
2465
|
-
if (!apiKey)
|
|
2466
|
-
throw new Error(
|
|
2467
|
-
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
|
2468
|
-
);
|
|
2469
|
-
const [protocol, , host, , database] = databaseURL.split("/");
|
|
2470
|
-
const [workspace] = host.split(".");
|
|
2471
|
-
const dbBranchName = `${database}:${branch}`;
|
|
2472
|
-
try {
|
|
2473
|
-
return await getBranchDetails({
|
|
2474
|
-
apiKey,
|
|
2475
|
-
apiUrl: databaseURL,
|
|
2476
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
|
2477
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
|
2478
|
-
pathParams: { dbBranchName, workspace },
|
|
2479
|
-
trace: defaultTrace
|
|
2480
|
-
});
|
|
2481
|
-
} catch (err) {
|
|
2482
|
-
if (isObject(err) && err.status === 404)
|
|
2483
|
-
return null;
|
|
2484
|
-
throw err;
|
|
2485
|
-
}
|
|
2486
|
-
}
|
|
2487
|
-
function getDatabaseURL() {
|
|
2488
|
-
try {
|
|
2489
|
-
const { databaseURL } = getEnvironment();
|
|
2490
|
-
return databaseURL;
|
|
2491
|
-
} catch (err) {
|
|
2492
|
-
return void 0;
|
|
3774
|
+
class TransactionPlugin extends XataPlugin {
|
|
3775
|
+
build(pluginOptions) {
|
|
3776
|
+
return {
|
|
3777
|
+
run: async (operations) => {
|
|
3778
|
+
const response = await branchTransaction({
|
|
3779
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
3780
|
+
body: { operations },
|
|
3781
|
+
...pluginOptions
|
|
3782
|
+
});
|
|
3783
|
+
return response;
|
|
3784
|
+
}
|
|
3785
|
+
};
|
|
2493
3786
|
}
|
|
2494
3787
|
}
|
|
2495
3788
|
|
|
@@ -2516,96 +3809,115 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2516
3809
|
return method;
|
|
2517
3810
|
};
|
|
2518
3811
|
const buildClient = (plugins) => {
|
|
2519
|
-
var
|
|
3812
|
+
var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
|
|
2520
3813
|
return _a = class {
|
|
2521
3814
|
constructor(options = {}, schemaTables) {
|
|
2522
3815
|
__privateAdd(this, _parseOptions);
|
|
2523
3816
|
__privateAdd(this, _getFetchProps);
|
|
2524
|
-
__privateAdd(this, _evaluateBranch);
|
|
2525
|
-
__privateAdd(this, _branch, void 0);
|
|
2526
3817
|
__privateAdd(this, _options, void 0);
|
|
2527
3818
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
|
2528
3819
|
__privateSet(this, _options, safeOptions);
|
|
2529
3820
|
const pluginOptions = {
|
|
2530
|
-
|
|
3821
|
+
...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
|
2531
3822
|
cache: safeOptions.cache,
|
|
2532
|
-
|
|
3823
|
+
host: safeOptions.host
|
|
2533
3824
|
};
|
|
2534
3825
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
|
2535
3826
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
|
3827
|
+
const transactions = new TransactionPlugin().build(pluginOptions);
|
|
2536
3828
|
this.db = db;
|
|
2537
3829
|
this.search = search;
|
|
3830
|
+
this.transactions = transactions;
|
|
2538
3831
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
|
2539
3832
|
if (namespace === void 0)
|
|
2540
3833
|
continue;
|
|
2541
|
-
|
|
2542
|
-
if (result instanceof Promise) {
|
|
2543
|
-
void result.then((namespace2) => {
|
|
2544
|
-
this[key] = namespace2;
|
|
2545
|
-
});
|
|
2546
|
-
} else {
|
|
2547
|
-
this[key] = result;
|
|
2548
|
-
}
|
|
3834
|
+
this[key] = namespace.build(pluginOptions);
|
|
2549
3835
|
}
|
|
2550
3836
|
}
|
|
2551
3837
|
async getConfig() {
|
|
2552
3838
|
const databaseURL = __privateGet(this, _options).databaseURL;
|
|
2553
|
-
const branch =
|
|
3839
|
+
const branch = __privateGet(this, _options).branch;
|
|
2554
3840
|
return { databaseURL, branch };
|
|
2555
3841
|
}
|
|
2556
|
-
},
|
|
3842
|
+
}, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
|
3843
|
+
const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
|
|
3844
|
+
const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
|
|
3845
|
+
if (isBrowser && !enableBrowser) {
|
|
3846
|
+
throw new Error(
|
|
3847
|
+
"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."
|
|
3848
|
+
);
|
|
3849
|
+
}
|
|
2557
3850
|
const fetch = getFetchImplementation(options?.fetch);
|
|
2558
3851
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
2559
3852
|
const apiKey = options?.apiKey || getAPIKey();
|
|
2560
3853
|
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
|
2561
3854
|
const trace = options?.trace ?? defaultTrace;
|
|
2562
|
-
const
|
|
3855
|
+
const clientName = options?.clientName;
|
|
3856
|
+
const host = options?.host ?? "production";
|
|
3857
|
+
const xataAgentExtra = options?.xataAgentExtra;
|
|
2563
3858
|
if (!apiKey) {
|
|
2564
3859
|
throw new Error("Option apiKey is required");
|
|
2565
3860
|
}
|
|
2566
3861
|
if (!databaseURL) {
|
|
2567
3862
|
throw new Error("Option databaseURL is required");
|
|
2568
3863
|
}
|
|
2569
|
-
|
|
2570
|
-
|
|
3864
|
+
const envBranch = getBranch();
|
|
3865
|
+
const previewBranch = getPreviewBranch();
|
|
3866
|
+
const branch = options?.branch || previewBranch || envBranch || "main";
|
|
3867
|
+
if (!!previewBranch && branch !== previewBranch) {
|
|
3868
|
+
console.warn(
|
|
3869
|
+
`Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
|
|
3870
|
+
);
|
|
3871
|
+
} else if (!!envBranch && branch !== envBranch) {
|
|
3872
|
+
console.warn(
|
|
3873
|
+
`Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
|
3874
|
+
);
|
|
3875
|
+
} else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
|
|
3876
|
+
console.warn(
|
|
3877
|
+
`Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
|
3878
|
+
);
|
|
3879
|
+
} else if (!previewBranch && !envBranch && options?.branch === void 0) {
|
|
3880
|
+
console.warn(
|
|
3881
|
+
`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.`
|
|
3882
|
+
);
|
|
3883
|
+
}
|
|
3884
|
+
return {
|
|
3885
|
+
fetch,
|
|
3886
|
+
databaseURL,
|
|
3887
|
+
apiKey,
|
|
3888
|
+
branch,
|
|
3889
|
+
cache,
|
|
3890
|
+
trace,
|
|
3891
|
+
host,
|
|
3892
|
+
clientID: generateUUID(),
|
|
3893
|
+
enableBrowser,
|
|
3894
|
+
clientName,
|
|
3895
|
+
xataAgentExtra
|
|
3896
|
+
};
|
|
3897
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
|
|
2571
3898
|
fetch,
|
|
2572
3899
|
apiKey,
|
|
2573
3900
|
databaseURL,
|
|
2574
3901
|
branch,
|
|
2575
3902
|
trace,
|
|
2576
|
-
clientID
|
|
3903
|
+
clientID,
|
|
3904
|
+
clientName,
|
|
3905
|
+
xataAgentExtra
|
|
2577
3906
|
}) {
|
|
2578
|
-
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
|
2579
|
-
if (!branchValue)
|
|
2580
|
-
throw new Error("Unable to resolve branch value");
|
|
2581
3907
|
return {
|
|
2582
|
-
|
|
3908
|
+
fetch,
|
|
2583
3909
|
apiKey,
|
|
2584
3910
|
apiUrl: "",
|
|
2585
3911
|
workspacesApiUrl: (path, params) => {
|
|
2586
3912
|
const hasBranch = params.dbBranchName ?? params.branch;
|
|
2587
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${
|
|
3913
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
|
|
2588
3914
|
return databaseURL + newPath;
|
|
2589
3915
|
},
|
|
2590
3916
|
trace,
|
|
2591
|
-
clientID
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
if (__privateGet(this, _branch))
|
|
2595
|
-
return __privateGet(this, _branch);
|
|
2596
|
-
if (param === void 0)
|
|
2597
|
-
return void 0;
|
|
2598
|
-
const strategies = Array.isArray(param) ? [...param] : [param];
|
|
2599
|
-
const evaluateBranch = async (strategy) => {
|
|
2600
|
-
return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
|
|
3917
|
+
clientID,
|
|
3918
|
+
clientName,
|
|
3919
|
+
xataAgentExtra
|
|
2601
3920
|
};
|
|
2602
|
-
for await (const strategy of strategies) {
|
|
2603
|
-
const branch = await evaluateBranch(strategy);
|
|
2604
|
-
if (branch) {
|
|
2605
|
-
__privateSet(this, _branch, branch);
|
|
2606
|
-
return branch;
|
|
2607
|
-
}
|
|
2608
|
-
}
|
|
2609
3921
|
}, _a;
|
|
2610
3922
|
};
|
|
2611
3923
|
class BaseClient extends buildClient() {
|
|
@@ -2679,7 +3991,7 @@ const deserialize = (json) => {
|
|
|
2679
3991
|
};
|
|
2680
3992
|
|
|
2681
3993
|
function buildWorkerRunner(config) {
|
|
2682
|
-
return function xataWorker(name,
|
|
3994
|
+
return function xataWorker(name, worker) {
|
|
2683
3995
|
return async (...args) => {
|
|
2684
3996
|
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
|
2685
3997
|
const result = await fetch(url, {
|
|
@@ -2700,5 +4012,5 @@ class XataError extends Error {
|
|
|
2700
4012
|
}
|
|
2701
4013
|
}
|
|
2702
4014
|
|
|
2703
|
-
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit,
|
|
4015
|
+
export { BaseClient, FetcherError, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, askTable, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFileItem, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
|
|
2704
4016
|
//# sourceMappingURL=index.mjs.map
|