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