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