@xata.io/client 0.0.0-alpha.vede38ca → 0.0.0-alpha.vede885e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-add-version.log +4 -0
- package/.turbo/turbo-build.log +18 -0
- package/CHANGELOG.md +340 -0
- package/README.md +3 -269
- package/dist/index.cjs +3071 -882
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6492 -1936
- package/dist/index.mjs +3033 -859
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -11
- package/.eslintrc.cjs +0 -12
- package/Usage.md +0 -449
- package/rollup.config.js +0 -29
- package/tsconfig.json +0 -23
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
const defaultTrace = async (
|
|
1
|
+
const defaultTrace = async (name, fn, _options) => {
|
|
2
2
|
return await fn({
|
|
3
|
+
name,
|
|
3
4
|
setAttributes: () => {
|
|
4
5
|
return;
|
|
5
|
-
},
|
|
6
|
-
propagateTrace: () => {
|
|
7
|
-
return;
|
|
8
6
|
}
|
|
9
7
|
});
|
|
10
8
|
};
|
|
@@ -29,8 +27,11 @@ function notEmpty(value) {
|
|
|
29
27
|
function compact(arr) {
|
|
30
28
|
return arr.filter(notEmpty);
|
|
31
29
|
}
|
|
30
|
+
function compactObject(obj) {
|
|
31
|
+
return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
|
|
32
|
+
}
|
|
32
33
|
function isObject(value) {
|
|
33
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
34
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date);
|
|
34
35
|
}
|
|
35
36
|
function isDefined(value) {
|
|
36
37
|
return value !== null && value !== void 0;
|
|
@@ -41,6 +42,21 @@ function isString(value) {
|
|
|
41
42
|
function isStringArray(value) {
|
|
42
43
|
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
|
43
44
|
}
|
|
45
|
+
function isNumber(value) {
|
|
46
|
+
return isDefined(value) && typeof value === "number";
|
|
47
|
+
}
|
|
48
|
+
function parseNumber(value) {
|
|
49
|
+
if (isNumber(value)) {
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
if (isString(value)) {
|
|
53
|
+
const parsed = Number(value);
|
|
54
|
+
if (!Number.isNaN(parsed)) {
|
|
55
|
+
return parsed;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
44
60
|
function toBase64(value) {
|
|
45
61
|
try {
|
|
46
62
|
return btoa(value);
|
|
@@ -49,16 +65,60 @@ function toBase64(value) {
|
|
|
49
65
|
return buf.from(value).toString("base64");
|
|
50
66
|
}
|
|
51
67
|
}
|
|
68
|
+
function deepMerge(a, b) {
|
|
69
|
+
const result = { ...a };
|
|
70
|
+
for (const [key, value] of Object.entries(b)) {
|
|
71
|
+
if (isObject(value) && isObject(result[key])) {
|
|
72
|
+
result[key] = deepMerge(result[key], value);
|
|
73
|
+
} else {
|
|
74
|
+
result[key] = value;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
function chunk(array, chunkSize) {
|
|
80
|
+
const result = [];
|
|
81
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
82
|
+
result.push(array.slice(i, i + chunkSize));
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
async function timeout(ms) {
|
|
87
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
88
|
+
}
|
|
89
|
+
function timeoutWithCancel(ms) {
|
|
90
|
+
let timeoutId;
|
|
91
|
+
const promise = new Promise((resolve) => {
|
|
92
|
+
timeoutId = setTimeout(() => {
|
|
93
|
+
resolve();
|
|
94
|
+
}, ms);
|
|
95
|
+
});
|
|
96
|
+
return {
|
|
97
|
+
cancel: () => clearTimeout(timeoutId),
|
|
98
|
+
promise
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function promiseMap(inputValues, mapper) {
|
|
102
|
+
const reducer = (acc$, inputValue) => acc$.then(
|
|
103
|
+
(acc) => mapper(inputValue).then((result) => {
|
|
104
|
+
acc.push(result);
|
|
105
|
+
return acc;
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
return inputValues.reduce(reducer, Promise.resolve([]));
|
|
109
|
+
}
|
|
52
110
|
|
|
53
111
|
function getEnvironment() {
|
|
54
112
|
try {
|
|
55
|
-
if (
|
|
113
|
+
if (isDefined(process) && isDefined(process.env)) {
|
|
56
114
|
return {
|
|
57
115
|
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
|
58
116
|
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
|
59
117
|
branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
|
|
60
|
-
|
|
61
|
-
|
|
118
|
+
deployPreview: process.env.XATA_PREVIEW,
|
|
119
|
+
deployPreviewBranch: process.env.XATA_PREVIEW_BRANCH,
|
|
120
|
+
vercelGitCommitRef: process.env.VERCEL_GIT_COMMIT_REF,
|
|
121
|
+
vercelGitRepoOwner: process.env.VERCEL_GIT_REPO_OWNER
|
|
62
122
|
};
|
|
63
123
|
}
|
|
64
124
|
} catch (err) {
|
|
@@ -69,8 +129,10 @@ function getEnvironment() {
|
|
|
69
129
|
apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
|
|
70
130
|
databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
|
|
71
131
|
branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
|
|
72
|
-
|
|
73
|
-
|
|
132
|
+
deployPreview: Deno.env.get("XATA_PREVIEW"),
|
|
133
|
+
deployPreviewBranch: Deno.env.get("XATA_PREVIEW_BRANCH"),
|
|
134
|
+
vercelGitCommitRef: Deno.env.get("VERCEL_GIT_COMMIT_REF"),
|
|
135
|
+
vercelGitRepoOwner: Deno.env.get("VERCEL_GIT_REPO_OWNER")
|
|
74
136
|
};
|
|
75
137
|
}
|
|
76
138
|
} catch (err) {
|
|
@@ -79,10 +141,31 @@ function getEnvironment() {
|
|
|
79
141
|
apiKey: getGlobalApiKey(),
|
|
80
142
|
databaseURL: getGlobalDatabaseURL(),
|
|
81
143
|
branch: getGlobalBranch(),
|
|
82
|
-
|
|
83
|
-
|
|
144
|
+
deployPreview: void 0,
|
|
145
|
+
deployPreviewBranch: void 0,
|
|
146
|
+
vercelGitCommitRef: void 0,
|
|
147
|
+
vercelGitRepoOwner: void 0
|
|
84
148
|
};
|
|
85
149
|
}
|
|
150
|
+
function getEnableBrowserVariable() {
|
|
151
|
+
try {
|
|
152
|
+
if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
|
|
153
|
+
return process.env.XATA_ENABLE_BROWSER === "true";
|
|
154
|
+
}
|
|
155
|
+
} catch (err) {
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
|
|
159
|
+
return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
|
|
160
|
+
}
|
|
161
|
+
} catch (err) {
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
|
|
165
|
+
} catch (err) {
|
|
166
|
+
return void 0;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
86
169
|
function getGlobalApiKey() {
|
|
87
170
|
try {
|
|
88
171
|
return XATA_API_KEY;
|
|
@@ -104,44 +187,83 @@ function getGlobalBranch() {
|
|
|
104
187
|
return void 0;
|
|
105
188
|
}
|
|
106
189
|
}
|
|
107
|
-
function
|
|
190
|
+
function getDatabaseURL() {
|
|
108
191
|
try {
|
|
109
|
-
|
|
192
|
+
const { databaseURL } = getEnvironment();
|
|
193
|
+
return databaseURL;
|
|
110
194
|
} catch (err) {
|
|
111
195
|
return void 0;
|
|
112
196
|
}
|
|
113
197
|
}
|
|
114
|
-
|
|
115
|
-
const cmd = ["git", "branch", "--show-current"];
|
|
116
|
-
const fullCmd = cmd.join(" ");
|
|
117
|
-
const nodeModule = ["child", "process"].join("_");
|
|
118
|
-
const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
|
|
198
|
+
function getAPIKey() {
|
|
119
199
|
try {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
const { execSync } = await import(nodeModule);
|
|
124
|
-
return execSync(fullCmd, execOptions).toString().trim();
|
|
200
|
+
const { apiKey } = getEnvironment();
|
|
201
|
+
return apiKey;
|
|
125
202
|
} catch (err) {
|
|
203
|
+
return void 0;
|
|
126
204
|
}
|
|
205
|
+
}
|
|
206
|
+
function getBranch() {
|
|
127
207
|
try {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return new TextDecoder().decode(await process2.output()).trim();
|
|
131
|
-
}
|
|
208
|
+
const { branch } = getEnvironment();
|
|
209
|
+
return branch;
|
|
132
210
|
} catch (err) {
|
|
211
|
+
return void 0;
|
|
133
212
|
}
|
|
134
213
|
}
|
|
135
|
-
|
|
136
|
-
|
|
214
|
+
function buildPreviewBranchName({ org, branch }) {
|
|
215
|
+
return `preview-${org}-${branch}`;
|
|
216
|
+
}
|
|
217
|
+
function getPreviewBranch() {
|
|
137
218
|
try {
|
|
138
|
-
const {
|
|
139
|
-
|
|
219
|
+
const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = getEnvironment();
|
|
220
|
+
if (deployPreviewBranch)
|
|
221
|
+
return deployPreviewBranch;
|
|
222
|
+
switch (deployPreview) {
|
|
223
|
+
case "vercel": {
|
|
224
|
+
if (!vercelGitCommitRef || !vercelGitRepoOwner) {
|
|
225
|
+
console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
|
|
226
|
+
return void 0;
|
|
227
|
+
}
|
|
228
|
+
return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return void 0;
|
|
140
232
|
} catch (err) {
|
|
141
233
|
return void 0;
|
|
142
234
|
}
|
|
143
235
|
}
|
|
144
236
|
|
|
237
|
+
var __defProp$8 = Object.defineProperty;
|
|
238
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
239
|
+
var __publicField$8 = (obj, key, value) => {
|
|
240
|
+
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
241
|
+
return value;
|
|
242
|
+
};
|
|
243
|
+
var __accessCheck$8 = (obj, member, msg) => {
|
|
244
|
+
if (!member.has(obj))
|
|
245
|
+
throw TypeError("Cannot " + msg);
|
|
246
|
+
};
|
|
247
|
+
var __privateGet$8 = (obj, member, getter) => {
|
|
248
|
+
__accessCheck$8(obj, member, "read from private field");
|
|
249
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
250
|
+
};
|
|
251
|
+
var __privateAdd$8 = (obj, member, value) => {
|
|
252
|
+
if (member.has(obj))
|
|
253
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
254
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
255
|
+
};
|
|
256
|
+
var __privateSet$8 = (obj, member, value, setter) => {
|
|
257
|
+
__accessCheck$8(obj, member, "write to private field");
|
|
258
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
259
|
+
return value;
|
|
260
|
+
};
|
|
261
|
+
var __privateMethod$4 = (obj, member, method) => {
|
|
262
|
+
__accessCheck$8(obj, member, "access private method");
|
|
263
|
+
return method;
|
|
264
|
+
};
|
|
265
|
+
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
|
266
|
+
const REQUEST_TIMEOUT = 3e4;
|
|
145
267
|
function getFetchImplementation(userFetch) {
|
|
146
268
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
|
147
269
|
const fetchImpl = userFetch ?? globalFetch;
|
|
@@ -152,19 +274,281 @@ function getFetchImplementation(userFetch) {
|
|
|
152
274
|
}
|
|
153
275
|
return fetchImpl;
|
|
154
276
|
}
|
|
277
|
+
class ApiRequestPool {
|
|
278
|
+
constructor(concurrency = 10) {
|
|
279
|
+
__privateAdd$8(this, _enqueue);
|
|
280
|
+
__privateAdd$8(this, _fetch, void 0);
|
|
281
|
+
__privateAdd$8(this, _queue, void 0);
|
|
282
|
+
__privateAdd$8(this, _concurrency, void 0);
|
|
283
|
+
__publicField$8(this, "running");
|
|
284
|
+
__publicField$8(this, "started");
|
|
285
|
+
__privateSet$8(this, _queue, []);
|
|
286
|
+
__privateSet$8(this, _concurrency, concurrency);
|
|
287
|
+
this.running = 0;
|
|
288
|
+
this.started = 0;
|
|
289
|
+
}
|
|
290
|
+
setFetch(fetch2) {
|
|
291
|
+
__privateSet$8(this, _fetch, fetch2);
|
|
292
|
+
}
|
|
293
|
+
getFetch() {
|
|
294
|
+
if (!__privateGet$8(this, _fetch)) {
|
|
295
|
+
throw new Error("Fetch not set");
|
|
296
|
+
}
|
|
297
|
+
return __privateGet$8(this, _fetch);
|
|
298
|
+
}
|
|
299
|
+
request(url, options) {
|
|
300
|
+
const start = /* @__PURE__ */ new Date();
|
|
301
|
+
const fetchImpl = this.getFetch();
|
|
302
|
+
const runRequest = async (stalled = false) => {
|
|
303
|
+
const { promise, cancel } = timeoutWithCancel(REQUEST_TIMEOUT);
|
|
304
|
+
const response = await Promise.race([fetchImpl(url, options), promise.then(() => null)]).finally(cancel);
|
|
305
|
+
if (!response) {
|
|
306
|
+
throw new Error("Request timed out");
|
|
307
|
+
}
|
|
308
|
+
if (response.status === 429) {
|
|
309
|
+
const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
|
|
310
|
+
await timeout(rateLimitReset * 1e3);
|
|
311
|
+
return await runRequest(true);
|
|
312
|
+
}
|
|
313
|
+
if (stalled) {
|
|
314
|
+
const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
|
|
315
|
+
console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
|
|
316
|
+
}
|
|
317
|
+
return response;
|
|
318
|
+
};
|
|
319
|
+
return __privateMethod$4(this, _enqueue, enqueue_fn).call(this, async () => {
|
|
320
|
+
return await runRequest();
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
_fetch = new WeakMap();
|
|
325
|
+
_queue = new WeakMap();
|
|
326
|
+
_concurrency = new WeakMap();
|
|
327
|
+
_enqueue = new WeakSet();
|
|
328
|
+
enqueue_fn = function(task) {
|
|
329
|
+
const promise = new Promise((resolve) => __privateGet$8(this, _queue).push(resolve)).finally(() => {
|
|
330
|
+
this.started--;
|
|
331
|
+
this.running++;
|
|
332
|
+
}).then(() => task()).finally(() => {
|
|
333
|
+
this.running--;
|
|
334
|
+
const next = __privateGet$8(this, _queue).shift();
|
|
335
|
+
if (next !== void 0) {
|
|
336
|
+
this.started++;
|
|
337
|
+
next();
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
if (this.running + this.started < __privateGet$8(this, _concurrency)) {
|
|
341
|
+
const next = __privateGet$8(this, _queue).shift();
|
|
342
|
+
if (next !== void 0) {
|
|
343
|
+
this.started++;
|
|
344
|
+
next();
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return promise;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
function generateUUID() {
|
|
351
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
352
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
353
|
+
return v.toString(16);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
async function getBytes(stream, onChunk) {
|
|
358
|
+
const reader = stream.getReader();
|
|
359
|
+
let result;
|
|
360
|
+
while (!(result = await reader.read()).done) {
|
|
361
|
+
onChunk(result.value);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
function getLines(onLine) {
|
|
365
|
+
let buffer;
|
|
366
|
+
let position;
|
|
367
|
+
let fieldLength;
|
|
368
|
+
let discardTrailingNewline = false;
|
|
369
|
+
return function onChunk(arr) {
|
|
370
|
+
if (buffer === void 0) {
|
|
371
|
+
buffer = arr;
|
|
372
|
+
position = 0;
|
|
373
|
+
fieldLength = -1;
|
|
374
|
+
} else {
|
|
375
|
+
buffer = concat(buffer, arr);
|
|
376
|
+
}
|
|
377
|
+
const bufLength = buffer.length;
|
|
378
|
+
let lineStart = 0;
|
|
379
|
+
while (position < bufLength) {
|
|
380
|
+
if (discardTrailingNewline) {
|
|
381
|
+
if (buffer[position] === 10 /* NewLine */) {
|
|
382
|
+
lineStart = ++position;
|
|
383
|
+
}
|
|
384
|
+
discardTrailingNewline = false;
|
|
385
|
+
}
|
|
386
|
+
let lineEnd = -1;
|
|
387
|
+
for (; position < bufLength && lineEnd === -1; ++position) {
|
|
388
|
+
switch (buffer[position]) {
|
|
389
|
+
case 58 /* Colon */:
|
|
390
|
+
if (fieldLength === -1) {
|
|
391
|
+
fieldLength = position - lineStart;
|
|
392
|
+
}
|
|
393
|
+
break;
|
|
394
|
+
case 13 /* CarriageReturn */:
|
|
395
|
+
discardTrailingNewline = true;
|
|
396
|
+
case 10 /* NewLine */:
|
|
397
|
+
lineEnd = position;
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (lineEnd === -1) {
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
|
|
405
|
+
lineStart = position;
|
|
406
|
+
fieldLength = -1;
|
|
407
|
+
}
|
|
408
|
+
if (lineStart === bufLength) {
|
|
409
|
+
buffer = void 0;
|
|
410
|
+
} else if (lineStart !== 0) {
|
|
411
|
+
buffer = buffer.subarray(lineStart);
|
|
412
|
+
position -= lineStart;
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
function getMessages(onId, onRetry, onMessage) {
|
|
417
|
+
let message = newMessage();
|
|
418
|
+
const decoder = new TextDecoder();
|
|
419
|
+
return function onLine(line, fieldLength) {
|
|
420
|
+
if (line.length === 0) {
|
|
421
|
+
onMessage?.(message);
|
|
422
|
+
message = newMessage();
|
|
423
|
+
} else if (fieldLength > 0) {
|
|
424
|
+
const field = decoder.decode(line.subarray(0, fieldLength));
|
|
425
|
+
const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
|
|
426
|
+
const value = decoder.decode(line.subarray(valueOffset));
|
|
427
|
+
switch (field) {
|
|
428
|
+
case "data":
|
|
429
|
+
message.data = message.data ? message.data + "\n" + value : value;
|
|
430
|
+
break;
|
|
431
|
+
case "event":
|
|
432
|
+
message.event = value;
|
|
433
|
+
break;
|
|
434
|
+
case "id":
|
|
435
|
+
onId(message.id = value);
|
|
436
|
+
break;
|
|
437
|
+
case "retry":
|
|
438
|
+
const retry = parseInt(value, 10);
|
|
439
|
+
if (!isNaN(retry)) {
|
|
440
|
+
onRetry(message.retry = retry);
|
|
441
|
+
}
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
function concat(a, b) {
|
|
448
|
+
const res = new Uint8Array(a.length + b.length);
|
|
449
|
+
res.set(a);
|
|
450
|
+
res.set(b, a.length);
|
|
451
|
+
return res;
|
|
452
|
+
}
|
|
453
|
+
function newMessage() {
|
|
454
|
+
return {
|
|
455
|
+
data: "",
|
|
456
|
+
event: "",
|
|
457
|
+
id: "",
|
|
458
|
+
retry: void 0
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
const EventStreamContentType = "text/event-stream";
|
|
462
|
+
const LastEventId = "last-event-id";
|
|
463
|
+
function fetchEventSource(input, {
|
|
464
|
+
signal: inputSignal,
|
|
465
|
+
headers: inputHeaders,
|
|
466
|
+
onopen: inputOnOpen,
|
|
467
|
+
onmessage,
|
|
468
|
+
onclose,
|
|
469
|
+
onerror,
|
|
470
|
+
fetch: inputFetch,
|
|
471
|
+
...rest
|
|
472
|
+
}) {
|
|
473
|
+
return new Promise((resolve, reject) => {
|
|
474
|
+
const headers = { ...inputHeaders };
|
|
475
|
+
if (!headers.accept) {
|
|
476
|
+
headers.accept = EventStreamContentType;
|
|
477
|
+
}
|
|
478
|
+
let curRequestController;
|
|
479
|
+
function dispose() {
|
|
480
|
+
curRequestController.abort();
|
|
481
|
+
}
|
|
482
|
+
inputSignal?.addEventListener("abort", () => {
|
|
483
|
+
dispose();
|
|
484
|
+
resolve();
|
|
485
|
+
});
|
|
486
|
+
const fetchImpl = inputFetch ?? fetch;
|
|
487
|
+
const onopen = inputOnOpen ?? defaultOnOpen;
|
|
488
|
+
async function create() {
|
|
489
|
+
curRequestController = new AbortController();
|
|
490
|
+
try {
|
|
491
|
+
const response = await fetchImpl(input, {
|
|
492
|
+
...rest,
|
|
493
|
+
headers,
|
|
494
|
+
signal: curRequestController.signal
|
|
495
|
+
});
|
|
496
|
+
await onopen(response);
|
|
497
|
+
await getBytes(
|
|
498
|
+
response.body,
|
|
499
|
+
getLines(
|
|
500
|
+
getMessages(
|
|
501
|
+
(id) => {
|
|
502
|
+
if (id) {
|
|
503
|
+
headers[LastEventId] = id;
|
|
504
|
+
} else {
|
|
505
|
+
delete headers[LastEventId];
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
(_retry) => {
|
|
509
|
+
},
|
|
510
|
+
onmessage
|
|
511
|
+
)
|
|
512
|
+
)
|
|
513
|
+
);
|
|
514
|
+
onclose?.();
|
|
515
|
+
dispose();
|
|
516
|
+
resolve();
|
|
517
|
+
} catch (err) {
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
create();
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
function defaultOnOpen(response) {
|
|
524
|
+
const contentType = response.headers?.get("content-type");
|
|
525
|
+
if (!contentType?.startsWith(EventStreamContentType)) {
|
|
526
|
+
throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
155
529
|
|
|
156
|
-
const VERSION = "0.
|
|
530
|
+
const VERSION = "0.25.1";
|
|
157
531
|
|
|
532
|
+
var __defProp$7 = Object.defineProperty;
|
|
533
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
534
|
+
var __publicField$7 = (obj, key, value) => {
|
|
535
|
+
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
536
|
+
return value;
|
|
537
|
+
};
|
|
158
538
|
class ErrorWithCause extends Error {
|
|
159
539
|
constructor(message, options) {
|
|
160
540
|
super(message, options);
|
|
541
|
+
__publicField$7(this, "cause");
|
|
161
542
|
}
|
|
162
543
|
}
|
|
163
544
|
class FetcherError extends ErrorWithCause {
|
|
164
545
|
constructor(status, data, requestId) {
|
|
165
546
|
super(getMessage(data));
|
|
547
|
+
__publicField$7(this, "status");
|
|
548
|
+
__publicField$7(this, "requestId");
|
|
549
|
+
__publicField$7(this, "errors");
|
|
166
550
|
this.status = status;
|
|
167
|
-
this.errors = isBulkError(data) ? data.errors :
|
|
551
|
+
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
|
168
552
|
this.requestId = requestId;
|
|
169
553
|
if (data instanceof Error) {
|
|
170
554
|
this.stack = data.stack;
|
|
@@ -196,6 +580,7 @@ function getMessage(data) {
|
|
|
196
580
|
}
|
|
197
581
|
}
|
|
198
582
|
|
|
583
|
+
const pool = new ApiRequestPool();
|
|
199
584
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
200
585
|
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
|
201
586
|
if (value === void 0 || value === null)
|
|
@@ -210,60 +595,89 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
|
210
595
|
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
|
211
596
|
};
|
|
212
597
|
function buildBaseUrl({
|
|
598
|
+
endpoint,
|
|
213
599
|
path,
|
|
214
600
|
workspacesApiUrl,
|
|
215
601
|
apiUrl,
|
|
216
|
-
pathParams
|
|
602
|
+
pathParams = {}
|
|
217
603
|
}) {
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
604
|
+
if (endpoint === "dataPlane") {
|
|
605
|
+
const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
|
606
|
+
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
|
607
|
+
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
|
608
|
+
}
|
|
609
|
+
return `${apiUrl}${path}`;
|
|
222
610
|
}
|
|
223
611
|
function hostHeader(url) {
|
|
224
612
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
|
225
613
|
const { groups } = pattern.exec(url) ?? {};
|
|
226
614
|
return groups?.host ? { Host: groups.host } : {};
|
|
227
615
|
}
|
|
616
|
+
function parseBody(body, headers) {
|
|
617
|
+
if (!isDefined(body))
|
|
618
|
+
return void 0;
|
|
619
|
+
const { "Content-Type": contentType } = headers ?? {};
|
|
620
|
+
if (String(contentType).toLowerCase() === "application/json") {
|
|
621
|
+
return JSON.stringify(body);
|
|
622
|
+
}
|
|
623
|
+
return body;
|
|
624
|
+
}
|
|
625
|
+
const defaultClientID = generateUUID();
|
|
228
626
|
async function fetch$1({
|
|
229
627
|
url: path,
|
|
230
628
|
method,
|
|
231
629
|
body,
|
|
232
|
-
headers,
|
|
630
|
+
headers: customHeaders,
|
|
233
631
|
pathParams,
|
|
234
632
|
queryParams,
|
|
235
|
-
|
|
633
|
+
fetch: fetch2,
|
|
236
634
|
apiKey,
|
|
635
|
+
endpoint,
|
|
237
636
|
apiUrl,
|
|
238
637
|
workspacesApiUrl,
|
|
239
|
-
trace
|
|
638
|
+
trace,
|
|
639
|
+
signal,
|
|
640
|
+
clientID,
|
|
641
|
+
sessionID,
|
|
642
|
+
clientName,
|
|
643
|
+
xataAgentExtra,
|
|
644
|
+
fetchOptions = {},
|
|
645
|
+
rawResponse = false
|
|
240
646
|
}) {
|
|
241
|
-
|
|
647
|
+
pool.setFetch(fetch2);
|
|
648
|
+
return await trace(
|
|
242
649
|
`${method.toUpperCase()} ${path}`,
|
|
243
|
-
async ({ setAttributes
|
|
244
|
-
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
|
650
|
+
async ({ setAttributes }) => {
|
|
651
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
|
245
652
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
|
246
653
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
|
247
654
|
setAttributes({
|
|
248
655
|
[TraceAttributes.HTTP_URL]: url,
|
|
249
656
|
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
|
250
657
|
});
|
|
251
|
-
const
|
|
658
|
+
const xataAgent = compact([
|
|
659
|
+
["client", "TS_SDK"],
|
|
660
|
+
["version", VERSION],
|
|
661
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
|
662
|
+
...Object.entries(xataAgentExtra ?? {})
|
|
663
|
+
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
|
664
|
+
const headers = compactObject({
|
|
665
|
+
"Accept-Encoding": "identity",
|
|
252
666
|
"Content-Type": "application/json",
|
|
253
|
-
"
|
|
254
|
-
|
|
667
|
+
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
|
668
|
+
"X-Xata-Session-ID": sessionID ?? generateUUID(),
|
|
669
|
+
"X-Xata-Agent": xataAgent,
|
|
670
|
+
...customHeaders,
|
|
255
671
|
...hostHeader(fullUrl),
|
|
256
672
|
Authorization: `Bearer ${apiKey}`
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
|
|
673
|
+
});
|
|
674
|
+
const response = await pool.request(url, {
|
|
675
|
+
...fetchOptions,
|
|
260
676
|
method: method.toUpperCase(),
|
|
261
|
-
body: body
|
|
262
|
-
headers
|
|
677
|
+
body: parseBody(body, headers),
|
|
678
|
+
headers,
|
|
679
|
+
signal
|
|
263
680
|
});
|
|
264
|
-
if (response.status === 204) {
|
|
265
|
-
return {};
|
|
266
|
-
}
|
|
267
681
|
const { host, protocol } = parseUrl(response.url);
|
|
268
682
|
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
|
269
683
|
setAttributes({
|
|
@@ -273,8 +687,17 @@ async function fetch$1({
|
|
|
273
687
|
[TraceAttributes.HTTP_HOST]: host,
|
|
274
688
|
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
|
275
689
|
});
|
|
690
|
+
const message = response.headers?.get("x-xata-message");
|
|
691
|
+
if (message)
|
|
692
|
+
console.warn(message);
|
|
693
|
+
if (response.status === 204) {
|
|
694
|
+
return {};
|
|
695
|
+
}
|
|
696
|
+
if (response.status === 429) {
|
|
697
|
+
throw new FetcherError(response.status, "Rate limit exceeded", requestId);
|
|
698
|
+
}
|
|
276
699
|
try {
|
|
277
|
-
const jsonResponse = await response.json();
|
|
700
|
+
const jsonResponse = rawResponse ? await response.blob() : await response.json();
|
|
278
701
|
if (response.ok) {
|
|
279
702
|
return jsonResponse;
|
|
280
703
|
}
|
|
@@ -286,6 +709,59 @@ async function fetch$1({
|
|
|
286
709
|
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
|
287
710
|
);
|
|
288
711
|
}
|
|
712
|
+
function fetchSSERequest({
|
|
713
|
+
url: path,
|
|
714
|
+
method,
|
|
715
|
+
body,
|
|
716
|
+
headers: customHeaders,
|
|
717
|
+
pathParams,
|
|
718
|
+
queryParams,
|
|
719
|
+
fetch: fetch2,
|
|
720
|
+
apiKey,
|
|
721
|
+
endpoint,
|
|
722
|
+
apiUrl,
|
|
723
|
+
workspacesApiUrl,
|
|
724
|
+
onMessage,
|
|
725
|
+
onError,
|
|
726
|
+
onClose,
|
|
727
|
+
signal,
|
|
728
|
+
clientID,
|
|
729
|
+
sessionID,
|
|
730
|
+
clientName,
|
|
731
|
+
xataAgentExtra
|
|
732
|
+
}) {
|
|
733
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
|
734
|
+
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
|
735
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
|
736
|
+
void fetchEventSource(url, {
|
|
737
|
+
method,
|
|
738
|
+
body: JSON.stringify(body),
|
|
739
|
+
fetch: fetch2,
|
|
740
|
+
signal,
|
|
741
|
+
headers: {
|
|
742
|
+
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
|
743
|
+
"X-Xata-Session-ID": sessionID ?? generateUUID(),
|
|
744
|
+
"X-Xata-Agent": compact([
|
|
745
|
+
["client", "TS_SDK"],
|
|
746
|
+
["version", VERSION],
|
|
747
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
|
748
|
+
...Object.entries(xataAgentExtra ?? {})
|
|
749
|
+
]).map(([key, value]) => `${key}=${value}`).join("; "),
|
|
750
|
+
...customHeaders,
|
|
751
|
+
Authorization: `Bearer ${apiKey}`,
|
|
752
|
+
"Content-Type": "application/json"
|
|
753
|
+
},
|
|
754
|
+
onmessage(ev) {
|
|
755
|
+
onMessage?.(JSON.parse(ev.data));
|
|
756
|
+
},
|
|
757
|
+
onerror(ev) {
|
|
758
|
+
onError?.(JSON.parse(ev.data));
|
|
759
|
+
},
|
|
760
|
+
onclose() {
|
|
761
|
+
onClose?.();
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
}
|
|
289
765
|
function parseUrl(url) {
|
|
290
766
|
try {
|
|
291
767
|
const { host, protocol } = new URL(url);
|
|
@@ -295,285 +771,243 @@ function parseUrl(url) {
|
|
|
295
771
|
}
|
|
296
772
|
}
|
|
297
773
|
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
url: "/user/keys",
|
|
303
|
-
method: "get",
|
|
304
|
-
...variables
|
|
305
|
-
});
|
|
306
|
-
const createUserAPIKey = (variables) => fetch$1({
|
|
307
|
-
url: "/user/keys/{keyName}",
|
|
308
|
-
method: "post",
|
|
309
|
-
...variables
|
|
310
|
-
});
|
|
311
|
-
const deleteUserAPIKey = (variables) => fetch$1({
|
|
312
|
-
url: "/user/keys/{keyName}",
|
|
313
|
-
method: "delete",
|
|
314
|
-
...variables
|
|
315
|
-
});
|
|
316
|
-
const createWorkspace = (variables) => fetch$1({
|
|
317
|
-
url: "/workspaces",
|
|
318
|
-
method: "post",
|
|
319
|
-
...variables
|
|
320
|
-
});
|
|
321
|
-
const getWorkspacesList = (variables) => fetch$1({
|
|
322
|
-
url: "/workspaces",
|
|
323
|
-
method: "get",
|
|
324
|
-
...variables
|
|
325
|
-
});
|
|
326
|
-
const getWorkspace = (variables) => fetch$1({
|
|
327
|
-
url: "/workspaces/{workspaceId}",
|
|
774
|
+
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
|
775
|
+
|
|
776
|
+
const getBranchList = (variables, signal) => dataPlaneFetch({
|
|
777
|
+
url: "/dbs/{dbName}",
|
|
328
778
|
method: "get",
|
|
329
|
-
...variables
|
|
330
|
-
|
|
331
|
-
const updateWorkspace = (variables) => fetch$1({
|
|
332
|
-
url: "/workspaces/{workspaceId}",
|
|
333
|
-
method: "put",
|
|
334
|
-
...variables
|
|
779
|
+
...variables,
|
|
780
|
+
signal
|
|
335
781
|
});
|
|
336
|
-
const
|
|
337
|
-
url: "/
|
|
338
|
-
method: "delete",
|
|
339
|
-
...variables
|
|
340
|
-
});
|
|
341
|
-
const getWorkspaceMembersList = (variables) => fetch$1({
|
|
342
|
-
url: "/workspaces/{workspaceId}/members",
|
|
782
|
+
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
|
783
|
+
url: "/db/{dbBranchName}",
|
|
343
784
|
method: "get",
|
|
344
|
-
...variables
|
|
345
|
-
|
|
346
|
-
const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
|
|
347
|
-
const removeWorkspaceMember = (variables) => fetch$1({
|
|
348
|
-
url: "/workspaces/{workspaceId}/members/{userId}",
|
|
349
|
-
method: "delete",
|
|
350
|
-
...variables
|
|
785
|
+
...variables,
|
|
786
|
+
signal
|
|
351
787
|
});
|
|
352
|
-
const
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
|
788
|
+
const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
|
|
789
|
+
const deleteBranch = (variables, signal) => dataPlaneFetch({
|
|
790
|
+
url: "/db/{dbBranchName}",
|
|
356
791
|
method: "delete",
|
|
357
|
-
...variables
|
|
358
|
-
|
|
359
|
-
const resendWorkspaceMemberInvite = (variables) => fetch$1({
|
|
360
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
|
|
361
|
-
method: "post",
|
|
362
|
-
...variables
|
|
792
|
+
...variables,
|
|
793
|
+
signal
|
|
363
794
|
});
|
|
364
|
-
const
|
|
365
|
-
url: "/
|
|
795
|
+
const copyBranch = (variables, signal) => dataPlaneFetch({
|
|
796
|
+
url: "/db/{dbBranchName}/copy",
|
|
366
797
|
method: "post",
|
|
367
|
-
...variables
|
|
798
|
+
...variables,
|
|
799
|
+
signal
|
|
368
800
|
});
|
|
369
|
-
const
|
|
370
|
-
url: "/
|
|
371
|
-
method: "get",
|
|
372
|
-
...variables
|
|
373
|
-
});
|
|
374
|
-
const getBranchList = (variables) => fetch$1({
|
|
375
|
-
url: "/dbs/{dbName}",
|
|
376
|
-
method: "get",
|
|
377
|
-
...variables
|
|
378
|
-
});
|
|
379
|
-
const createDatabase = (variables) => fetch$1({
|
|
380
|
-
url: "/dbs/{dbName}",
|
|
801
|
+
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
|
802
|
+
url: "/db/{dbBranchName}/metadata",
|
|
381
803
|
method: "put",
|
|
382
|
-
...variables
|
|
383
|
-
|
|
384
|
-
const deleteDatabase = (variables) => fetch$1({
|
|
385
|
-
url: "/dbs/{dbName}",
|
|
386
|
-
method: "delete",
|
|
387
|
-
...variables
|
|
804
|
+
...variables,
|
|
805
|
+
signal
|
|
388
806
|
});
|
|
389
|
-
const
|
|
390
|
-
url: "/
|
|
807
|
+
const getBranchMetadata = (variables, signal) => dataPlaneFetch({
|
|
808
|
+
url: "/db/{dbBranchName}/metadata",
|
|
391
809
|
method: "get",
|
|
392
|
-
...variables
|
|
810
|
+
...variables,
|
|
811
|
+
signal
|
|
393
812
|
});
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
|
397
|
-
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
|
398
|
-
const resolveBranch = (variables) => fetch$1({
|
|
399
|
-
url: "/dbs/{dbName}/resolveBranch",
|
|
813
|
+
const getBranchStats = (variables, signal) => dataPlaneFetch({
|
|
814
|
+
url: "/db/{dbBranchName}/stats",
|
|
400
815
|
method: "get",
|
|
401
|
-
...variables
|
|
816
|
+
...variables,
|
|
817
|
+
signal
|
|
402
818
|
});
|
|
403
|
-
const
|
|
404
|
-
const
|
|
405
|
-
const
|
|
819
|
+
const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
|
|
820
|
+
const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
|
|
821
|
+
const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
|
|
822
|
+
const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
|
|
823
|
+
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
|
824
|
+
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
|
825
|
+
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
|
826
|
+
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
|
827
|
+
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
|
828
|
+
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
|
406
829
|
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
|
407
830
|
method: "get",
|
|
408
|
-
...variables
|
|
831
|
+
...variables,
|
|
832
|
+
signal
|
|
409
833
|
});
|
|
410
|
-
const updateMigrationRequest = (variables) =>
|
|
411
|
-
const listMigrationRequestsCommits = (variables) =>
|
|
412
|
-
const compareMigrationRequest = (variables) =>
|
|
413
|
-
const getMigrationRequestIsMerged = (variables) =>
|
|
414
|
-
const mergeMigrationRequest = (variables) =>
|
|
834
|
+
const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
|
|
835
|
+
const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
|
|
836
|
+
const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
|
|
837
|
+
const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
|
|
838
|
+
const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
|
|
415
839
|
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
|
416
840
|
method: "post",
|
|
417
|
-
...variables
|
|
418
|
-
|
|
419
|
-
const getBranchDetails = (variables) => fetch$1({
|
|
420
|
-
url: "/db/{dbBranchName}",
|
|
421
|
-
method: "get",
|
|
422
|
-
...variables
|
|
423
|
-
});
|
|
424
|
-
const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
|
|
425
|
-
const deleteBranch = (variables) => fetch$1({
|
|
426
|
-
url: "/db/{dbBranchName}",
|
|
427
|
-
method: "delete",
|
|
428
|
-
...variables
|
|
429
|
-
});
|
|
430
|
-
const updateBranchMetadata = (variables) => fetch$1({
|
|
431
|
-
url: "/db/{dbBranchName}/metadata",
|
|
432
|
-
method: "put",
|
|
433
|
-
...variables
|
|
434
|
-
});
|
|
435
|
-
const getBranchMetadata = (variables) => fetch$1({
|
|
436
|
-
url: "/db/{dbBranchName}/metadata",
|
|
437
|
-
method: "get",
|
|
438
|
-
...variables
|
|
439
|
-
});
|
|
440
|
-
const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
|
|
441
|
-
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
|
442
|
-
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
|
443
|
-
const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
|
|
444
|
-
const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
|
|
445
|
-
const updateBranchSchema = (variables) => fetch$1({
|
|
446
|
-
url: "/db/{dbBranchName}/schema/update",
|
|
447
|
-
method: "post",
|
|
448
|
-
...variables
|
|
841
|
+
...variables,
|
|
842
|
+
signal
|
|
449
843
|
});
|
|
450
|
-
const
|
|
451
|
-
const
|
|
452
|
-
const
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
const createTable = (variables) => fetch$1({
|
|
844
|
+
const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
|
|
845
|
+
const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
|
|
846
|
+
const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
|
|
847
|
+
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
|
848
|
+
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
|
849
|
+
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
|
850
|
+
const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
|
|
851
|
+
const createTable = (variables, signal) => dataPlaneFetch({
|
|
459
852
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
|
460
853
|
method: "put",
|
|
461
|
-
...variables
|
|
854
|
+
...variables,
|
|
855
|
+
signal
|
|
462
856
|
});
|
|
463
|
-
const deleteTable = (variables) =>
|
|
857
|
+
const deleteTable = (variables, signal) => dataPlaneFetch({
|
|
464
858
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
|
465
859
|
method: "delete",
|
|
466
|
-
...variables
|
|
467
|
-
|
|
468
|
-
const updateTable = (variables) => fetch$1({
|
|
469
|
-
url: "/db/{dbBranchName}/tables/{tableName}",
|
|
470
|
-
method: "patch",
|
|
471
|
-
...variables
|
|
860
|
+
...variables,
|
|
861
|
+
signal
|
|
472
862
|
});
|
|
473
|
-
const
|
|
863
|
+
const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
|
|
864
|
+
const getTableSchema = (variables, signal) => dataPlaneFetch({
|
|
474
865
|
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
|
475
866
|
method: "get",
|
|
476
|
-
...variables
|
|
477
|
-
|
|
478
|
-
const setTableSchema = (variables) => fetch$1({
|
|
479
|
-
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
|
480
|
-
method: "put",
|
|
481
|
-
...variables
|
|
867
|
+
...variables,
|
|
868
|
+
signal
|
|
482
869
|
});
|
|
483
|
-
const
|
|
870
|
+
const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
|
|
871
|
+
const getTableColumns = (variables, signal) => dataPlaneFetch({
|
|
484
872
|
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
|
485
873
|
method: "get",
|
|
486
|
-
...variables
|
|
874
|
+
...variables,
|
|
875
|
+
signal
|
|
487
876
|
});
|
|
488
|
-
const addTableColumn = (variables) =>
|
|
489
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
});
|
|
493
|
-
const getColumn = (variables) => fetch$1({
|
|
877
|
+
const addTableColumn = (variables, signal) => dataPlaneFetch(
|
|
878
|
+
{ url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
|
|
879
|
+
);
|
|
880
|
+
const getColumn = (variables, signal) => dataPlaneFetch({
|
|
494
881
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
|
495
882
|
method: "get",
|
|
496
|
-
...variables
|
|
883
|
+
...variables,
|
|
884
|
+
signal
|
|
497
885
|
});
|
|
498
|
-
const
|
|
886
|
+
const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
|
|
887
|
+
const deleteColumn = (variables, signal) => dataPlaneFetch({
|
|
499
888
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
|
500
889
|
method: "delete",
|
|
501
|
-
...variables
|
|
890
|
+
...variables,
|
|
891
|
+
signal
|
|
502
892
|
});
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
893
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
|
894
|
+
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
|
895
|
+
const getFileItem = (variables, signal) => dataPlaneFetch({
|
|
896
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
|
897
|
+
method: "get",
|
|
898
|
+
...variables,
|
|
899
|
+
signal
|
|
507
900
|
});
|
|
508
|
-
const
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
901
|
+
const putFileItem = (variables, signal) => dataPlaneFetch({
|
|
902
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
|
903
|
+
method: "put",
|
|
904
|
+
...variables,
|
|
905
|
+
signal
|
|
906
|
+
});
|
|
907
|
+
const deleteFileItem = (variables, signal) => dataPlaneFetch({
|
|
908
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
|
514
909
|
method: "delete",
|
|
515
|
-
...variables
|
|
910
|
+
...variables,
|
|
911
|
+
signal
|
|
912
|
+
});
|
|
913
|
+
const getFile = (variables, signal) => dataPlaneFetch({
|
|
914
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
|
915
|
+
method: "get",
|
|
916
|
+
...variables,
|
|
917
|
+
signal
|
|
516
918
|
});
|
|
517
|
-
const
|
|
919
|
+
const putFile = (variables, signal) => dataPlaneFetch({
|
|
920
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
|
921
|
+
method: "put",
|
|
922
|
+
...variables,
|
|
923
|
+
signal
|
|
924
|
+
});
|
|
925
|
+
const deleteFile = (variables, signal) => dataPlaneFetch({
|
|
926
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
|
927
|
+
method: "delete",
|
|
928
|
+
...variables,
|
|
929
|
+
signal
|
|
930
|
+
});
|
|
931
|
+
const getRecord = (variables, signal) => dataPlaneFetch({
|
|
518
932
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
|
519
933
|
method: "get",
|
|
520
|
-
...variables
|
|
934
|
+
...variables,
|
|
935
|
+
signal
|
|
521
936
|
});
|
|
522
|
-
const
|
|
523
|
-
const
|
|
937
|
+
const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
|
|
938
|
+
const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
|
|
939
|
+
const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
|
|
940
|
+
const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
|
|
941
|
+
const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
|
|
942
|
+
const queryTable = (variables, signal) => dataPlaneFetch({
|
|
524
943
|
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
|
525
944
|
method: "post",
|
|
526
|
-
...variables
|
|
945
|
+
...variables,
|
|
946
|
+
signal
|
|
527
947
|
});
|
|
528
|
-
const
|
|
948
|
+
const searchBranch = (variables, signal) => dataPlaneFetch({
|
|
949
|
+
url: "/db/{dbBranchName}/search",
|
|
950
|
+
method: "post",
|
|
951
|
+
...variables,
|
|
952
|
+
signal
|
|
953
|
+
});
|
|
954
|
+
const searchTable = (variables, signal) => dataPlaneFetch({
|
|
529
955
|
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
|
530
956
|
method: "post",
|
|
531
|
-
...variables
|
|
957
|
+
...variables,
|
|
958
|
+
signal
|
|
532
959
|
});
|
|
533
|
-
const
|
|
534
|
-
url: "/db/{dbBranchName}/
|
|
960
|
+
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
|
961
|
+
url: "/db/{dbBranchName}/sql",
|
|
535
962
|
method: "post",
|
|
536
|
-
...variables
|
|
963
|
+
...variables,
|
|
964
|
+
signal
|
|
537
965
|
});
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
database: {
|
|
556
|
-
getDatabaseList,
|
|
557
|
-
createDatabase,
|
|
558
|
-
deleteDatabase,
|
|
559
|
-
getDatabaseMetadata,
|
|
560
|
-
patchDatabaseMetadata,
|
|
561
|
-
getGitBranchesMapping,
|
|
562
|
-
addGitBranchesEntry,
|
|
563
|
-
removeGitBranchesEntry,
|
|
564
|
-
resolveBranch
|
|
565
|
-
},
|
|
966
|
+
const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
|
|
967
|
+
const askTable = (variables, signal) => dataPlaneFetch({
|
|
968
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
|
969
|
+
method: "post",
|
|
970
|
+
...variables,
|
|
971
|
+
signal
|
|
972
|
+
});
|
|
973
|
+
const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
|
|
974
|
+
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
|
975
|
+
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
|
976
|
+
const fileAccess = (variables, signal) => dataPlaneFetch({
|
|
977
|
+
url: "/file/{fileId}",
|
|
978
|
+
method: "get",
|
|
979
|
+
...variables,
|
|
980
|
+
signal
|
|
981
|
+
});
|
|
982
|
+
const operationsByTag$2 = {
|
|
566
983
|
branch: {
|
|
567
984
|
getBranchList,
|
|
568
985
|
getBranchDetails,
|
|
569
986
|
createBranch,
|
|
570
987
|
deleteBranch,
|
|
988
|
+
copyBranch,
|
|
571
989
|
updateBranchMetadata,
|
|
572
990
|
getBranchMetadata,
|
|
573
|
-
getBranchStats
|
|
991
|
+
getBranchStats,
|
|
992
|
+
getGitBranchesMapping,
|
|
993
|
+
addGitBranchesEntry,
|
|
994
|
+
removeGitBranchesEntry,
|
|
995
|
+
resolveBranch
|
|
996
|
+
},
|
|
997
|
+
migrations: {
|
|
998
|
+
getBranchMigrationHistory,
|
|
999
|
+
getBranchMigrationPlan,
|
|
1000
|
+
executeBranchMigrationPlan,
|
|
1001
|
+
getBranchSchemaHistory,
|
|
1002
|
+
compareBranchWithUserSchema,
|
|
1003
|
+
compareBranchSchemas,
|
|
1004
|
+
updateBranchSchema,
|
|
1005
|
+
previewBranchSchemaEdit,
|
|
1006
|
+
applyBranchSchemaEdit,
|
|
1007
|
+
pushBranchMigrations
|
|
574
1008
|
},
|
|
575
1009
|
migrationRequests: {
|
|
576
|
-
|
|
1010
|
+
queryMigrationRequests,
|
|
577
1011
|
createMigrationRequest,
|
|
578
1012
|
getMigrationRequest,
|
|
579
1013
|
updateMigrationRequest,
|
|
@@ -582,17 +1016,6 @@ const operationsByTag = {
|
|
|
582
1016
|
getMigrationRequestIsMerged,
|
|
583
1017
|
mergeMigrationRequest
|
|
584
1018
|
},
|
|
585
|
-
branchSchema: {
|
|
586
|
-
getBranchMigrationHistory,
|
|
587
|
-
executeBranchMigrationPlan,
|
|
588
|
-
getBranchMigrationPlan,
|
|
589
|
-
compareBranchWithUserSchema,
|
|
590
|
-
compareBranchSchemas,
|
|
591
|
-
updateBranchSchema,
|
|
592
|
-
previewBranchSchemaEdit,
|
|
593
|
-
applyBranchSchemaEdit,
|
|
594
|
-
getBranchSchemaHistory
|
|
595
|
-
},
|
|
596
1019
|
table: {
|
|
597
1020
|
createTable,
|
|
598
1021
|
deleteTable,
|
|
@@ -602,23 +1025,183 @@ const operationsByTag = {
|
|
|
602
1025
|
getTableColumns,
|
|
603
1026
|
addTableColumn,
|
|
604
1027
|
getColumn,
|
|
605
|
-
|
|
606
|
-
|
|
1028
|
+
updateColumn,
|
|
1029
|
+
deleteColumn
|
|
1030
|
+
},
|
|
1031
|
+
records: {
|
|
1032
|
+
branchTransaction,
|
|
1033
|
+
insertRecord,
|
|
1034
|
+
getRecord,
|
|
1035
|
+
insertRecordWithID,
|
|
1036
|
+
updateRecordWithID,
|
|
1037
|
+
upsertRecordWithID,
|
|
1038
|
+
deleteRecord,
|
|
1039
|
+
bulkInsertTableRecords
|
|
1040
|
+
},
|
|
1041
|
+
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
|
|
1042
|
+
searchAndFilter: {
|
|
1043
|
+
queryTable,
|
|
1044
|
+
searchBranch,
|
|
1045
|
+
searchTable,
|
|
1046
|
+
sqlQuery,
|
|
1047
|
+
vectorSearchTable,
|
|
1048
|
+
askTable,
|
|
1049
|
+
askTableSession,
|
|
1050
|
+
summarizeTable,
|
|
1051
|
+
aggregateTable
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
|
|
1055
|
+
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
|
1056
|
+
|
|
1057
|
+
const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
|
|
1058
|
+
const getUser = (variables, signal) => controlPlaneFetch({
|
|
1059
|
+
url: "/user",
|
|
1060
|
+
method: "get",
|
|
1061
|
+
...variables,
|
|
1062
|
+
signal
|
|
1063
|
+
});
|
|
1064
|
+
const updateUser = (variables, signal) => controlPlaneFetch({
|
|
1065
|
+
url: "/user",
|
|
1066
|
+
method: "put",
|
|
1067
|
+
...variables,
|
|
1068
|
+
signal
|
|
1069
|
+
});
|
|
1070
|
+
const deleteUser = (variables, signal) => controlPlaneFetch({
|
|
1071
|
+
url: "/user",
|
|
1072
|
+
method: "delete",
|
|
1073
|
+
...variables,
|
|
1074
|
+
signal
|
|
1075
|
+
});
|
|
1076
|
+
const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
|
|
1077
|
+
url: "/user/keys",
|
|
1078
|
+
method: "get",
|
|
1079
|
+
...variables,
|
|
1080
|
+
signal
|
|
1081
|
+
});
|
|
1082
|
+
const createUserAPIKey = (variables, signal) => controlPlaneFetch({
|
|
1083
|
+
url: "/user/keys/{keyName}",
|
|
1084
|
+
method: "post",
|
|
1085
|
+
...variables,
|
|
1086
|
+
signal
|
|
1087
|
+
});
|
|
1088
|
+
const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
|
1089
|
+
url: "/user/keys/{keyName}",
|
|
1090
|
+
method: "delete",
|
|
1091
|
+
...variables,
|
|
1092
|
+
signal
|
|
1093
|
+
});
|
|
1094
|
+
const getUserOAuthClients = (variables, signal) => controlPlaneFetch({
|
|
1095
|
+
url: "/user/oauth/clients",
|
|
1096
|
+
method: "get",
|
|
1097
|
+
...variables,
|
|
1098
|
+
signal
|
|
1099
|
+
});
|
|
1100
|
+
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
|
1101
|
+
url: "/workspaces",
|
|
1102
|
+
method: "get",
|
|
1103
|
+
...variables,
|
|
1104
|
+
signal
|
|
1105
|
+
});
|
|
1106
|
+
const createWorkspace = (variables, signal) => controlPlaneFetch({
|
|
1107
|
+
url: "/workspaces",
|
|
1108
|
+
method: "post",
|
|
1109
|
+
...variables,
|
|
1110
|
+
signal
|
|
1111
|
+
});
|
|
1112
|
+
const getWorkspace = (variables, signal) => controlPlaneFetch({
|
|
1113
|
+
url: "/workspaces/{workspaceId}",
|
|
1114
|
+
method: "get",
|
|
1115
|
+
...variables,
|
|
1116
|
+
signal
|
|
1117
|
+
});
|
|
1118
|
+
const updateWorkspace = (variables, signal) => controlPlaneFetch({
|
|
1119
|
+
url: "/workspaces/{workspaceId}",
|
|
1120
|
+
method: "put",
|
|
1121
|
+
...variables,
|
|
1122
|
+
signal
|
|
1123
|
+
});
|
|
1124
|
+
const deleteWorkspace = (variables, signal) => controlPlaneFetch({
|
|
1125
|
+
url: "/workspaces/{workspaceId}",
|
|
1126
|
+
method: "delete",
|
|
1127
|
+
...variables,
|
|
1128
|
+
signal
|
|
1129
|
+
});
|
|
1130
|
+
const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
|
|
1131
|
+
const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
|
|
1132
|
+
const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
|
1133
|
+
url: "/workspaces/{workspaceId}/members/{userId}",
|
|
1134
|
+
method: "delete",
|
|
1135
|
+
...variables,
|
|
1136
|
+
signal
|
|
1137
|
+
});
|
|
1138
|
+
const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
|
|
1139
|
+
const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
|
|
1140
|
+
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
|
1141
|
+
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
|
1142
|
+
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
|
1143
|
+
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
|
1144
|
+
url: "/workspaces/{workspaceId}/dbs",
|
|
1145
|
+
method: "get",
|
|
1146
|
+
...variables,
|
|
1147
|
+
signal
|
|
1148
|
+
});
|
|
1149
|
+
const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
|
|
1150
|
+
const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
|
1151
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
|
1152
|
+
method: "delete",
|
|
1153
|
+
...variables,
|
|
1154
|
+
signal
|
|
1155
|
+
});
|
|
1156
|
+
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
|
1157
|
+
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
|
1158
|
+
const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
|
|
1159
|
+
const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
|
|
1160
|
+
const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
|
|
1161
|
+
const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
|
|
1162
|
+
const listRegions = (variables, signal) => controlPlaneFetch({
|
|
1163
|
+
url: "/workspaces/{workspaceId}/regions",
|
|
1164
|
+
method: "get",
|
|
1165
|
+
...variables,
|
|
1166
|
+
signal
|
|
1167
|
+
});
|
|
1168
|
+
const operationsByTag$1 = {
|
|
1169
|
+
authOther: { grantAuthorizationCode },
|
|
1170
|
+
users: { getUser, updateUser, deleteUser },
|
|
1171
|
+
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey, getUserOAuthClients },
|
|
1172
|
+
workspaces: {
|
|
1173
|
+
getWorkspacesList,
|
|
1174
|
+
createWorkspace,
|
|
1175
|
+
getWorkspace,
|
|
1176
|
+
updateWorkspace,
|
|
1177
|
+
deleteWorkspace,
|
|
1178
|
+
getWorkspaceMembersList,
|
|
1179
|
+
updateWorkspaceMemberRole,
|
|
1180
|
+
removeWorkspaceMember
|
|
607
1181
|
},
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
1182
|
+
invites: {
|
|
1183
|
+
inviteWorkspaceMember,
|
|
1184
|
+
updateWorkspaceMemberInvite,
|
|
1185
|
+
cancelWorkspaceMemberInvite,
|
|
1186
|
+
acceptWorkspaceMemberInvite,
|
|
1187
|
+
resendWorkspaceMemberInvite
|
|
1188
|
+
},
|
|
1189
|
+
databases: {
|
|
1190
|
+
getDatabaseList,
|
|
1191
|
+
createDatabase,
|
|
1192
|
+
deleteDatabase,
|
|
1193
|
+
getDatabaseMetadata,
|
|
1194
|
+
updateDatabaseMetadata,
|
|
1195
|
+
renameDatabase,
|
|
1196
|
+
getDatabaseGithubSettings,
|
|
1197
|
+
updateDatabaseGithubSettings,
|
|
1198
|
+
deleteDatabaseGithubSettings,
|
|
1199
|
+
listRegions
|
|
619
1200
|
}
|
|
620
1201
|
};
|
|
621
1202
|
|
|
1203
|
+
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
|
1204
|
+
|
|
622
1205
|
function getHostUrl(provider, type) {
|
|
623
1206
|
if (isHostProviderAlias(provider)) {
|
|
624
1207
|
return providers[provider][type];
|
|
@@ -630,11 +1213,15 @@ function getHostUrl(provider, type) {
|
|
|
630
1213
|
const providers = {
|
|
631
1214
|
production: {
|
|
632
1215
|
main: "https://api.xata.io",
|
|
633
|
-
workspaces: "https://{workspaceId}.xata.sh"
|
|
1216
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
|
634
1217
|
},
|
|
635
1218
|
staging: {
|
|
636
|
-
main: "https://staging.
|
|
637
|
-
workspaces: "https://{workspaceId}.staging.
|
|
1219
|
+
main: "https://api.staging-xata.dev",
|
|
1220
|
+
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
|
1221
|
+
},
|
|
1222
|
+
dev: {
|
|
1223
|
+
main: "https://api.dev-xata.dev",
|
|
1224
|
+
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
|
638
1225
|
}
|
|
639
1226
|
};
|
|
640
1227
|
function isHostProviderAlias(alias) {
|
|
@@ -643,6 +1230,32 @@ function isHostProviderAlias(alias) {
|
|
|
643
1230
|
function isHostProviderBuilder(builder) {
|
|
644
1231
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
|
645
1232
|
}
|
|
1233
|
+
function parseProviderString(provider = "production") {
|
|
1234
|
+
if (isHostProviderAlias(provider)) {
|
|
1235
|
+
return provider;
|
|
1236
|
+
}
|
|
1237
|
+
const [main, workspaces] = provider.split(",");
|
|
1238
|
+
if (!main || !workspaces)
|
|
1239
|
+
return null;
|
|
1240
|
+
return { main, workspaces };
|
|
1241
|
+
}
|
|
1242
|
+
function buildProviderString(provider) {
|
|
1243
|
+
if (isHostProviderAlias(provider))
|
|
1244
|
+
return provider;
|
|
1245
|
+
return `${provider.main},${provider.workspaces}`;
|
|
1246
|
+
}
|
|
1247
|
+
function parseWorkspacesUrlParts(url) {
|
|
1248
|
+
if (!isString(url))
|
|
1249
|
+
return null;
|
|
1250
|
+
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
|
1251
|
+
const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
|
|
1252
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
|
|
1253
|
+
const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
|
|
1254
|
+
const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
|
|
1255
|
+
if (!match)
|
|
1256
|
+
return null;
|
|
1257
|
+
return { workspace: match[1], region: match[2] };
|
|
1258
|
+
}
|
|
646
1259
|
|
|
647
1260
|
var __accessCheck$7 = (obj, member, msg) => {
|
|
648
1261
|
if (!member.has(obj))
|
|
@@ -670,15 +1283,19 @@ class XataApiClient {
|
|
|
670
1283
|
const provider = options.host ?? "production";
|
|
671
1284
|
const apiKey = options.apiKey ?? getAPIKey();
|
|
672
1285
|
const trace = options.trace ?? defaultTrace;
|
|
1286
|
+
const clientID = generateUUID();
|
|
673
1287
|
if (!apiKey) {
|
|
674
1288
|
throw new Error("Could not resolve a valid apiKey");
|
|
675
1289
|
}
|
|
676
1290
|
__privateSet$7(this, _extraProps, {
|
|
677
1291
|
apiUrl: getHostUrl(provider, "main"),
|
|
678
1292
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
|
679
|
-
|
|
1293
|
+
fetch: getFetchImplementation(options.fetch),
|
|
680
1294
|
apiKey,
|
|
681
|
-
trace
|
|
1295
|
+
trace,
|
|
1296
|
+
clientName: options.clientName,
|
|
1297
|
+
xataAgentExtra: options.xataAgentExtra,
|
|
1298
|
+
clientID
|
|
682
1299
|
});
|
|
683
1300
|
}
|
|
684
1301
|
get user() {
|
|
@@ -686,21 +1303,41 @@ class XataApiClient {
|
|
|
686
1303
|
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
|
687
1304
|
return __privateGet$7(this, _namespaces).user;
|
|
688
1305
|
}
|
|
1306
|
+
get authentication() {
|
|
1307
|
+
if (!__privateGet$7(this, _namespaces).authentication)
|
|
1308
|
+
__privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
|
|
1309
|
+
return __privateGet$7(this, _namespaces).authentication;
|
|
1310
|
+
}
|
|
689
1311
|
get workspaces() {
|
|
690
1312
|
if (!__privateGet$7(this, _namespaces).workspaces)
|
|
691
1313
|
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
|
692
1314
|
return __privateGet$7(this, _namespaces).workspaces;
|
|
693
1315
|
}
|
|
694
|
-
get
|
|
695
|
-
if (!__privateGet$7(this, _namespaces).
|
|
696
|
-
__privateGet$7(this, _namespaces).
|
|
697
|
-
return __privateGet$7(this, _namespaces).
|
|
1316
|
+
get invites() {
|
|
1317
|
+
if (!__privateGet$7(this, _namespaces).invites)
|
|
1318
|
+
__privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
|
|
1319
|
+
return __privateGet$7(this, _namespaces).invites;
|
|
1320
|
+
}
|
|
1321
|
+
get database() {
|
|
1322
|
+
if (!__privateGet$7(this, _namespaces).database)
|
|
1323
|
+
__privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
|
|
1324
|
+
return __privateGet$7(this, _namespaces).database;
|
|
698
1325
|
}
|
|
699
1326
|
get branches() {
|
|
700
1327
|
if (!__privateGet$7(this, _namespaces).branches)
|
|
701
1328
|
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
|
702
1329
|
return __privateGet$7(this, _namespaces).branches;
|
|
703
1330
|
}
|
|
1331
|
+
get migrations() {
|
|
1332
|
+
if (!__privateGet$7(this, _namespaces).migrations)
|
|
1333
|
+
__privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
|
|
1334
|
+
return __privateGet$7(this, _namespaces).migrations;
|
|
1335
|
+
}
|
|
1336
|
+
get migrationRequests() {
|
|
1337
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
|
1338
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
|
1339
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
|
1340
|
+
}
|
|
704
1341
|
get tables() {
|
|
705
1342
|
if (!__privateGet$7(this, _namespaces).tables)
|
|
706
1343
|
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
|
@@ -711,15 +1348,15 @@ class XataApiClient {
|
|
|
711
1348
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
|
712
1349
|
return __privateGet$7(this, _namespaces).records;
|
|
713
1350
|
}
|
|
714
|
-
get
|
|
715
|
-
if (!__privateGet$7(this, _namespaces).
|
|
716
|
-
__privateGet$7(this, _namespaces).
|
|
717
|
-
return __privateGet$7(this, _namespaces).
|
|
1351
|
+
get files() {
|
|
1352
|
+
if (!__privateGet$7(this, _namespaces).files)
|
|
1353
|
+
__privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
|
|
1354
|
+
return __privateGet$7(this, _namespaces).files;
|
|
718
1355
|
}
|
|
719
|
-
get
|
|
720
|
-
if (!__privateGet$7(this, _namespaces).
|
|
721
|
-
__privateGet$7(this, _namespaces).
|
|
722
|
-
return __privateGet$7(this, _namespaces).
|
|
1356
|
+
get searchAndFilter() {
|
|
1357
|
+
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
|
1358
|
+
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
|
1359
|
+
return __privateGet$7(this, _namespaces).searchAndFilter;
|
|
723
1360
|
}
|
|
724
1361
|
}
|
|
725
1362
|
_extraProps = new WeakMap();
|
|
@@ -731,24 +1368,29 @@ class UserApi {
|
|
|
731
1368
|
getUser() {
|
|
732
1369
|
return operationsByTag.users.getUser({ ...this.extraProps });
|
|
733
1370
|
}
|
|
734
|
-
updateUser(user) {
|
|
1371
|
+
updateUser({ user }) {
|
|
735
1372
|
return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
|
|
736
1373
|
}
|
|
737
1374
|
deleteUser() {
|
|
738
1375
|
return operationsByTag.users.deleteUser({ ...this.extraProps });
|
|
739
1376
|
}
|
|
1377
|
+
}
|
|
1378
|
+
class AuthenticationApi {
|
|
1379
|
+
constructor(extraProps) {
|
|
1380
|
+
this.extraProps = extraProps;
|
|
1381
|
+
}
|
|
740
1382
|
getUserAPIKeys() {
|
|
741
|
-
return operationsByTag.
|
|
1383
|
+
return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
|
|
742
1384
|
}
|
|
743
|
-
createUserAPIKey(
|
|
744
|
-
return operationsByTag.
|
|
745
|
-
pathParams: { keyName },
|
|
1385
|
+
createUserAPIKey({ name }) {
|
|
1386
|
+
return operationsByTag.authentication.createUserAPIKey({
|
|
1387
|
+
pathParams: { keyName: name },
|
|
746
1388
|
...this.extraProps
|
|
747
1389
|
});
|
|
748
1390
|
}
|
|
749
|
-
deleteUserAPIKey(
|
|
750
|
-
return operationsByTag.
|
|
751
|
-
pathParams: { keyName },
|
|
1391
|
+
deleteUserAPIKey({ name }) {
|
|
1392
|
+
return operationsByTag.authentication.deleteUserAPIKey({
|
|
1393
|
+
pathParams: { keyName: name },
|
|
752
1394
|
...this.extraProps
|
|
753
1395
|
});
|
|
754
1396
|
}
|
|
@@ -757,196 +1399,262 @@ class WorkspaceApi {
|
|
|
757
1399
|
constructor(extraProps) {
|
|
758
1400
|
this.extraProps = extraProps;
|
|
759
1401
|
}
|
|
760
|
-
|
|
1402
|
+
getWorkspacesList() {
|
|
1403
|
+
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
|
1404
|
+
}
|
|
1405
|
+
createWorkspace({ data }) {
|
|
761
1406
|
return operationsByTag.workspaces.createWorkspace({
|
|
762
|
-
body:
|
|
1407
|
+
body: data,
|
|
763
1408
|
...this.extraProps
|
|
764
1409
|
});
|
|
765
1410
|
}
|
|
766
|
-
|
|
767
|
-
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
|
768
|
-
}
|
|
769
|
-
getWorkspace(workspaceId) {
|
|
1411
|
+
getWorkspace({ workspace }) {
|
|
770
1412
|
return operationsByTag.workspaces.getWorkspace({
|
|
771
|
-
pathParams: { workspaceId },
|
|
1413
|
+
pathParams: { workspaceId: workspace },
|
|
772
1414
|
...this.extraProps
|
|
773
1415
|
});
|
|
774
1416
|
}
|
|
775
|
-
updateWorkspace(
|
|
1417
|
+
updateWorkspace({
|
|
1418
|
+
workspace,
|
|
1419
|
+
update
|
|
1420
|
+
}) {
|
|
776
1421
|
return operationsByTag.workspaces.updateWorkspace({
|
|
777
|
-
pathParams: { workspaceId },
|
|
778
|
-
body:
|
|
1422
|
+
pathParams: { workspaceId: workspace },
|
|
1423
|
+
body: update,
|
|
779
1424
|
...this.extraProps
|
|
780
1425
|
});
|
|
781
1426
|
}
|
|
782
|
-
deleteWorkspace(
|
|
1427
|
+
deleteWorkspace({ workspace }) {
|
|
783
1428
|
return operationsByTag.workspaces.deleteWorkspace({
|
|
784
|
-
pathParams: { workspaceId },
|
|
1429
|
+
pathParams: { workspaceId: workspace },
|
|
785
1430
|
...this.extraProps
|
|
786
1431
|
});
|
|
787
1432
|
}
|
|
788
|
-
getWorkspaceMembersList(
|
|
1433
|
+
getWorkspaceMembersList({ workspace }) {
|
|
789
1434
|
return operationsByTag.workspaces.getWorkspaceMembersList({
|
|
790
|
-
pathParams: { workspaceId },
|
|
1435
|
+
pathParams: { workspaceId: workspace },
|
|
791
1436
|
...this.extraProps
|
|
792
1437
|
});
|
|
793
1438
|
}
|
|
794
|
-
updateWorkspaceMemberRole(
|
|
1439
|
+
updateWorkspaceMemberRole({
|
|
1440
|
+
workspace,
|
|
1441
|
+
user,
|
|
1442
|
+
role
|
|
1443
|
+
}) {
|
|
795
1444
|
return operationsByTag.workspaces.updateWorkspaceMemberRole({
|
|
796
|
-
pathParams: { workspaceId, userId },
|
|
1445
|
+
pathParams: { workspaceId: workspace, userId: user },
|
|
797
1446
|
body: { role },
|
|
798
1447
|
...this.extraProps
|
|
799
1448
|
});
|
|
800
1449
|
}
|
|
801
|
-
removeWorkspaceMember(
|
|
1450
|
+
removeWorkspaceMember({
|
|
1451
|
+
workspace,
|
|
1452
|
+
user
|
|
1453
|
+
}) {
|
|
802
1454
|
return operationsByTag.workspaces.removeWorkspaceMember({
|
|
803
|
-
pathParams: { workspaceId, userId },
|
|
1455
|
+
pathParams: { workspaceId: workspace, userId: user },
|
|
804
1456
|
...this.extraProps
|
|
805
1457
|
});
|
|
806
1458
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
1459
|
+
}
|
|
1460
|
+
class InvitesApi {
|
|
1461
|
+
constructor(extraProps) {
|
|
1462
|
+
this.extraProps = extraProps;
|
|
1463
|
+
}
|
|
1464
|
+
inviteWorkspaceMember({
|
|
1465
|
+
workspace,
|
|
1466
|
+
email,
|
|
1467
|
+
role
|
|
1468
|
+
}) {
|
|
1469
|
+
return operationsByTag.invites.inviteWorkspaceMember({
|
|
1470
|
+
pathParams: { workspaceId: workspace },
|
|
810
1471
|
body: { email, role },
|
|
811
1472
|
...this.extraProps
|
|
812
1473
|
});
|
|
813
1474
|
}
|
|
814
|
-
updateWorkspaceMemberInvite(
|
|
815
|
-
|
|
816
|
-
|
|
1475
|
+
updateWorkspaceMemberInvite({
|
|
1476
|
+
workspace,
|
|
1477
|
+
invite,
|
|
1478
|
+
role
|
|
1479
|
+
}) {
|
|
1480
|
+
return operationsByTag.invites.updateWorkspaceMemberInvite({
|
|
1481
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
|
817
1482
|
body: { role },
|
|
818
1483
|
...this.extraProps
|
|
819
1484
|
});
|
|
820
1485
|
}
|
|
821
|
-
cancelWorkspaceMemberInvite(
|
|
822
|
-
|
|
823
|
-
|
|
1486
|
+
cancelWorkspaceMemberInvite({
|
|
1487
|
+
workspace,
|
|
1488
|
+
invite
|
|
1489
|
+
}) {
|
|
1490
|
+
return operationsByTag.invites.cancelWorkspaceMemberInvite({
|
|
1491
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
|
824
1492
|
...this.extraProps
|
|
825
1493
|
});
|
|
826
1494
|
}
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
1495
|
+
acceptWorkspaceMemberInvite({
|
|
1496
|
+
workspace,
|
|
1497
|
+
key
|
|
1498
|
+
}) {
|
|
1499
|
+
return operationsByTag.invites.acceptWorkspaceMemberInvite({
|
|
1500
|
+
pathParams: { workspaceId: workspace, inviteKey: key },
|
|
830
1501
|
...this.extraProps
|
|
831
1502
|
});
|
|
832
1503
|
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
1504
|
+
resendWorkspaceMemberInvite({
|
|
1505
|
+
workspace,
|
|
1506
|
+
invite
|
|
1507
|
+
}) {
|
|
1508
|
+
return operationsByTag.invites.resendWorkspaceMemberInvite({
|
|
1509
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
|
836
1510
|
...this.extraProps
|
|
837
1511
|
});
|
|
838
1512
|
}
|
|
839
1513
|
}
|
|
840
|
-
class
|
|
1514
|
+
class BranchApi {
|
|
841
1515
|
constructor(extraProps) {
|
|
842
1516
|
this.extraProps = extraProps;
|
|
843
1517
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
return operationsByTag.database.createDatabase({
|
|
852
|
-
pathParams: { workspace, dbName },
|
|
853
|
-
body: options,
|
|
854
|
-
...this.extraProps
|
|
855
|
-
});
|
|
856
|
-
}
|
|
857
|
-
deleteDatabase(workspace, dbName) {
|
|
858
|
-
return operationsByTag.database.deleteDatabase({
|
|
859
|
-
pathParams: { workspace, dbName },
|
|
860
|
-
...this.extraProps
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
|
-
getDatabaseMetadata(workspace, dbName) {
|
|
864
|
-
return operationsByTag.database.getDatabaseMetadata({
|
|
865
|
-
pathParams: { workspace, dbName },
|
|
866
|
-
...this.extraProps
|
|
867
|
-
});
|
|
868
|
-
}
|
|
869
|
-
patchDatabaseMetadata(workspace, dbName, options = {}) {
|
|
870
|
-
return operationsByTag.database.patchDatabaseMetadata({
|
|
871
|
-
pathParams: { workspace, dbName },
|
|
872
|
-
body: options,
|
|
1518
|
+
getBranchList({
|
|
1519
|
+
workspace,
|
|
1520
|
+
region,
|
|
1521
|
+
database
|
|
1522
|
+
}) {
|
|
1523
|
+
return operationsByTag.branch.getBranchList({
|
|
1524
|
+
pathParams: { workspace, region, dbName: database },
|
|
873
1525
|
...this.extraProps
|
|
874
1526
|
});
|
|
875
1527
|
}
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
1528
|
+
getBranchDetails({
|
|
1529
|
+
workspace,
|
|
1530
|
+
region,
|
|
1531
|
+
database,
|
|
1532
|
+
branch
|
|
1533
|
+
}) {
|
|
1534
|
+
return operationsByTag.branch.getBranchDetails({
|
|
1535
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
879
1536
|
...this.extraProps
|
|
880
1537
|
});
|
|
881
1538
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
1539
|
+
createBranch({
|
|
1540
|
+
workspace,
|
|
1541
|
+
region,
|
|
1542
|
+
database,
|
|
1543
|
+
branch,
|
|
1544
|
+
from,
|
|
1545
|
+
metadata
|
|
1546
|
+
}) {
|
|
1547
|
+
return operationsByTag.branch.createBranch({
|
|
1548
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1549
|
+
body: { from, metadata },
|
|
886
1550
|
...this.extraProps
|
|
887
1551
|
});
|
|
888
1552
|
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
1553
|
+
deleteBranch({
|
|
1554
|
+
workspace,
|
|
1555
|
+
region,
|
|
1556
|
+
database,
|
|
1557
|
+
branch
|
|
1558
|
+
}) {
|
|
1559
|
+
return operationsByTag.branch.deleteBranch({
|
|
1560
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
893
1561
|
...this.extraProps
|
|
894
1562
|
});
|
|
895
1563
|
}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
1564
|
+
copyBranch({
|
|
1565
|
+
workspace,
|
|
1566
|
+
region,
|
|
1567
|
+
database,
|
|
1568
|
+
branch,
|
|
1569
|
+
destinationBranch,
|
|
1570
|
+
limit
|
|
1571
|
+
}) {
|
|
1572
|
+
return operationsByTag.branch.copyBranch({
|
|
1573
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1574
|
+
body: { destinationBranch, limit },
|
|
900
1575
|
...this.extraProps
|
|
901
1576
|
});
|
|
902
1577
|
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
1578
|
+
updateBranchMetadata({
|
|
1579
|
+
workspace,
|
|
1580
|
+
region,
|
|
1581
|
+
database,
|
|
1582
|
+
branch,
|
|
1583
|
+
metadata
|
|
1584
|
+
}) {
|
|
1585
|
+
return operationsByTag.branch.updateBranchMetadata({
|
|
1586
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1587
|
+
body: metadata,
|
|
911
1588
|
...this.extraProps
|
|
912
1589
|
});
|
|
913
1590
|
}
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1591
|
+
getBranchMetadata({
|
|
1592
|
+
workspace,
|
|
1593
|
+
region,
|
|
1594
|
+
database,
|
|
1595
|
+
branch
|
|
1596
|
+
}) {
|
|
1597
|
+
return operationsByTag.branch.getBranchMetadata({
|
|
1598
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
917
1599
|
...this.extraProps
|
|
918
1600
|
});
|
|
919
1601
|
}
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
1602
|
+
getBranchStats({
|
|
1603
|
+
workspace,
|
|
1604
|
+
region,
|
|
1605
|
+
database,
|
|
1606
|
+
branch
|
|
1607
|
+
}) {
|
|
1608
|
+
return operationsByTag.branch.getBranchStats({
|
|
1609
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
925
1610
|
...this.extraProps
|
|
926
1611
|
});
|
|
927
1612
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1613
|
+
getGitBranchesMapping({
|
|
1614
|
+
workspace,
|
|
1615
|
+
region,
|
|
1616
|
+
database
|
|
1617
|
+
}) {
|
|
1618
|
+
return operationsByTag.branch.getGitBranchesMapping({
|
|
1619
|
+
pathParams: { workspace, region, dbName: database },
|
|
931
1620
|
...this.extraProps
|
|
932
1621
|
});
|
|
933
1622
|
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
1623
|
+
addGitBranchesEntry({
|
|
1624
|
+
workspace,
|
|
1625
|
+
region,
|
|
1626
|
+
database,
|
|
1627
|
+
gitBranch,
|
|
1628
|
+
xataBranch
|
|
1629
|
+
}) {
|
|
1630
|
+
return operationsByTag.branch.addGitBranchesEntry({
|
|
1631
|
+
pathParams: { workspace, region, dbName: database },
|
|
1632
|
+
body: { gitBranch, xataBranch },
|
|
938
1633
|
...this.extraProps
|
|
939
1634
|
});
|
|
940
1635
|
}
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
1636
|
+
removeGitBranchesEntry({
|
|
1637
|
+
workspace,
|
|
1638
|
+
region,
|
|
1639
|
+
database,
|
|
1640
|
+
gitBranch
|
|
1641
|
+
}) {
|
|
1642
|
+
return operationsByTag.branch.removeGitBranchesEntry({
|
|
1643
|
+
pathParams: { workspace, region, dbName: database },
|
|
1644
|
+
queryParams: { gitBranch },
|
|
944
1645
|
...this.extraProps
|
|
945
1646
|
});
|
|
946
1647
|
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
1648
|
+
resolveBranch({
|
|
1649
|
+
workspace,
|
|
1650
|
+
region,
|
|
1651
|
+
database,
|
|
1652
|
+
gitBranch,
|
|
1653
|
+
fallbackBranch
|
|
1654
|
+
}) {
|
|
1655
|
+
return operationsByTag.branch.resolveBranch({
|
|
1656
|
+
pathParams: { workspace, region, dbName: database },
|
|
1657
|
+
queryParams: { gitBranch, fallbackBranch },
|
|
950
1658
|
...this.extraProps
|
|
951
1659
|
});
|
|
952
1660
|
}
|
|
@@ -955,67 +1663,134 @@ class TableApi {
|
|
|
955
1663
|
constructor(extraProps) {
|
|
956
1664
|
this.extraProps = extraProps;
|
|
957
1665
|
}
|
|
958
|
-
createTable(
|
|
1666
|
+
createTable({
|
|
1667
|
+
workspace,
|
|
1668
|
+
region,
|
|
1669
|
+
database,
|
|
1670
|
+
branch,
|
|
1671
|
+
table
|
|
1672
|
+
}) {
|
|
959
1673
|
return operationsByTag.table.createTable({
|
|
960
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1674
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
961
1675
|
...this.extraProps
|
|
962
1676
|
});
|
|
963
1677
|
}
|
|
964
|
-
deleteTable(
|
|
1678
|
+
deleteTable({
|
|
1679
|
+
workspace,
|
|
1680
|
+
region,
|
|
1681
|
+
database,
|
|
1682
|
+
branch,
|
|
1683
|
+
table
|
|
1684
|
+
}) {
|
|
965
1685
|
return operationsByTag.table.deleteTable({
|
|
966
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1686
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
967
1687
|
...this.extraProps
|
|
968
1688
|
});
|
|
969
1689
|
}
|
|
970
|
-
updateTable(
|
|
1690
|
+
updateTable({
|
|
1691
|
+
workspace,
|
|
1692
|
+
region,
|
|
1693
|
+
database,
|
|
1694
|
+
branch,
|
|
1695
|
+
table,
|
|
1696
|
+
update
|
|
1697
|
+
}) {
|
|
971
1698
|
return operationsByTag.table.updateTable({
|
|
972
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
973
|
-
body:
|
|
1699
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1700
|
+
body: update,
|
|
974
1701
|
...this.extraProps
|
|
975
1702
|
});
|
|
976
1703
|
}
|
|
977
|
-
getTableSchema(
|
|
1704
|
+
getTableSchema({
|
|
1705
|
+
workspace,
|
|
1706
|
+
region,
|
|
1707
|
+
database,
|
|
1708
|
+
branch,
|
|
1709
|
+
table
|
|
1710
|
+
}) {
|
|
978
1711
|
return operationsByTag.table.getTableSchema({
|
|
979
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1712
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
980
1713
|
...this.extraProps
|
|
981
1714
|
});
|
|
982
1715
|
}
|
|
983
|
-
setTableSchema(
|
|
1716
|
+
setTableSchema({
|
|
1717
|
+
workspace,
|
|
1718
|
+
region,
|
|
1719
|
+
database,
|
|
1720
|
+
branch,
|
|
1721
|
+
table,
|
|
1722
|
+
schema
|
|
1723
|
+
}) {
|
|
984
1724
|
return operationsByTag.table.setTableSchema({
|
|
985
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
986
|
-
body:
|
|
1725
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1726
|
+
body: schema,
|
|
987
1727
|
...this.extraProps
|
|
988
1728
|
});
|
|
989
1729
|
}
|
|
990
|
-
getTableColumns(
|
|
1730
|
+
getTableColumns({
|
|
1731
|
+
workspace,
|
|
1732
|
+
region,
|
|
1733
|
+
database,
|
|
1734
|
+
branch,
|
|
1735
|
+
table
|
|
1736
|
+
}) {
|
|
991
1737
|
return operationsByTag.table.getTableColumns({
|
|
992
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1738
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
993
1739
|
...this.extraProps
|
|
994
1740
|
});
|
|
995
1741
|
}
|
|
996
|
-
addTableColumn(
|
|
1742
|
+
addTableColumn({
|
|
1743
|
+
workspace,
|
|
1744
|
+
region,
|
|
1745
|
+
database,
|
|
1746
|
+
branch,
|
|
1747
|
+
table,
|
|
1748
|
+
column
|
|
1749
|
+
}) {
|
|
997
1750
|
return operationsByTag.table.addTableColumn({
|
|
998
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1751
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
999
1752
|
body: column,
|
|
1000
1753
|
...this.extraProps
|
|
1001
1754
|
});
|
|
1002
1755
|
}
|
|
1003
|
-
getColumn(
|
|
1756
|
+
getColumn({
|
|
1757
|
+
workspace,
|
|
1758
|
+
region,
|
|
1759
|
+
database,
|
|
1760
|
+
branch,
|
|
1761
|
+
table,
|
|
1762
|
+
column
|
|
1763
|
+
}) {
|
|
1004
1764
|
return operationsByTag.table.getColumn({
|
|
1005
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
|
|
1765
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
|
1006
1766
|
...this.extraProps
|
|
1007
1767
|
});
|
|
1008
1768
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1769
|
+
updateColumn({
|
|
1770
|
+
workspace,
|
|
1771
|
+
region,
|
|
1772
|
+
database,
|
|
1773
|
+
branch,
|
|
1774
|
+
table,
|
|
1775
|
+
column,
|
|
1776
|
+
update
|
|
1777
|
+
}) {
|
|
1778
|
+
return operationsByTag.table.updateColumn({
|
|
1779
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
|
1780
|
+
body: update,
|
|
1012
1781
|
...this.extraProps
|
|
1013
1782
|
});
|
|
1014
1783
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1784
|
+
deleteColumn({
|
|
1785
|
+
workspace,
|
|
1786
|
+
region,
|
|
1787
|
+
database,
|
|
1788
|
+
branch,
|
|
1789
|
+
table,
|
|
1790
|
+
column
|
|
1791
|
+
}) {
|
|
1792
|
+
return operationsByTag.table.deleteColumn({
|
|
1793
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
|
1019
1794
|
...this.extraProps
|
|
1020
1795
|
});
|
|
1021
1796
|
}
|
|
@@ -1024,78 +1799,433 @@ class RecordsApi {
|
|
|
1024
1799
|
constructor(extraProps) {
|
|
1025
1800
|
this.extraProps = extraProps;
|
|
1026
1801
|
}
|
|
1027
|
-
insertRecord(
|
|
1802
|
+
insertRecord({
|
|
1803
|
+
workspace,
|
|
1804
|
+
region,
|
|
1805
|
+
database,
|
|
1806
|
+
branch,
|
|
1807
|
+
table,
|
|
1808
|
+
record,
|
|
1809
|
+
columns
|
|
1810
|
+
}) {
|
|
1028
1811
|
return operationsByTag.records.insertRecord({
|
|
1029
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1030
|
-
queryParams:
|
|
1812
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1813
|
+
queryParams: { columns },
|
|
1031
1814
|
body: record,
|
|
1032
1815
|
...this.extraProps
|
|
1033
1816
|
});
|
|
1034
1817
|
}
|
|
1035
|
-
|
|
1818
|
+
getRecord({
|
|
1819
|
+
workspace,
|
|
1820
|
+
region,
|
|
1821
|
+
database,
|
|
1822
|
+
branch,
|
|
1823
|
+
table,
|
|
1824
|
+
id,
|
|
1825
|
+
columns
|
|
1826
|
+
}) {
|
|
1827
|
+
return operationsByTag.records.getRecord({
|
|
1828
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1829
|
+
queryParams: { columns },
|
|
1830
|
+
...this.extraProps
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
insertRecordWithID({
|
|
1834
|
+
workspace,
|
|
1835
|
+
region,
|
|
1836
|
+
database,
|
|
1837
|
+
branch,
|
|
1838
|
+
table,
|
|
1839
|
+
id,
|
|
1840
|
+
record,
|
|
1841
|
+
columns,
|
|
1842
|
+
createOnly,
|
|
1843
|
+
ifVersion
|
|
1844
|
+
}) {
|
|
1036
1845
|
return operationsByTag.records.insertRecordWithID({
|
|
1037
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1038
|
-
queryParams:
|
|
1846
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1847
|
+
queryParams: { columns, createOnly, ifVersion },
|
|
1039
1848
|
body: record,
|
|
1040
1849
|
...this.extraProps
|
|
1041
1850
|
});
|
|
1042
1851
|
}
|
|
1043
|
-
updateRecordWithID(
|
|
1852
|
+
updateRecordWithID({
|
|
1853
|
+
workspace,
|
|
1854
|
+
region,
|
|
1855
|
+
database,
|
|
1856
|
+
branch,
|
|
1857
|
+
table,
|
|
1858
|
+
id,
|
|
1859
|
+
record,
|
|
1860
|
+
columns,
|
|
1861
|
+
ifVersion
|
|
1862
|
+
}) {
|
|
1044
1863
|
return operationsByTag.records.updateRecordWithID({
|
|
1045
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1046
|
-
queryParams:
|
|
1864
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1865
|
+
queryParams: { columns, ifVersion },
|
|
1047
1866
|
body: record,
|
|
1048
1867
|
...this.extraProps
|
|
1049
1868
|
});
|
|
1050
1869
|
}
|
|
1051
|
-
upsertRecordWithID(
|
|
1870
|
+
upsertRecordWithID({
|
|
1871
|
+
workspace,
|
|
1872
|
+
region,
|
|
1873
|
+
database,
|
|
1874
|
+
branch,
|
|
1875
|
+
table,
|
|
1876
|
+
id,
|
|
1877
|
+
record,
|
|
1878
|
+
columns,
|
|
1879
|
+
ifVersion
|
|
1880
|
+
}) {
|
|
1052
1881
|
return operationsByTag.records.upsertRecordWithID({
|
|
1053
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1054
|
-
queryParams:
|
|
1882
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1883
|
+
queryParams: { columns, ifVersion },
|
|
1055
1884
|
body: record,
|
|
1056
1885
|
...this.extraProps
|
|
1057
1886
|
});
|
|
1058
1887
|
}
|
|
1059
|
-
deleteRecord(
|
|
1888
|
+
deleteRecord({
|
|
1889
|
+
workspace,
|
|
1890
|
+
region,
|
|
1891
|
+
database,
|
|
1892
|
+
branch,
|
|
1893
|
+
table,
|
|
1894
|
+
id,
|
|
1895
|
+
columns
|
|
1896
|
+
}) {
|
|
1060
1897
|
return operationsByTag.records.deleteRecord({
|
|
1061
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1062
|
-
queryParams:
|
|
1898
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1899
|
+
queryParams: { columns },
|
|
1063
1900
|
...this.extraProps
|
|
1064
1901
|
});
|
|
1065
1902
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1903
|
+
bulkInsertTableRecords({
|
|
1904
|
+
workspace,
|
|
1905
|
+
region,
|
|
1906
|
+
database,
|
|
1907
|
+
branch,
|
|
1908
|
+
table,
|
|
1909
|
+
records,
|
|
1910
|
+
columns
|
|
1911
|
+
}) {
|
|
1912
|
+
return operationsByTag.records.bulkInsertTableRecords({
|
|
1913
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1914
|
+
queryParams: { columns },
|
|
1915
|
+
body: { records },
|
|
1070
1916
|
...this.extraProps
|
|
1071
1917
|
});
|
|
1072
1918
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1919
|
+
branchTransaction({
|
|
1920
|
+
workspace,
|
|
1921
|
+
region,
|
|
1922
|
+
database,
|
|
1923
|
+
branch,
|
|
1924
|
+
operations
|
|
1925
|
+
}) {
|
|
1926
|
+
return operationsByTag.records.branchTransaction({
|
|
1927
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1928
|
+
body: { operations },
|
|
1929
|
+
...this.extraProps
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
class FilesApi {
|
|
1934
|
+
constructor(extraProps) {
|
|
1935
|
+
this.extraProps = extraProps;
|
|
1936
|
+
}
|
|
1937
|
+
getFileItem({
|
|
1938
|
+
workspace,
|
|
1939
|
+
region,
|
|
1940
|
+
database,
|
|
1941
|
+
branch,
|
|
1942
|
+
table,
|
|
1943
|
+
record,
|
|
1944
|
+
column,
|
|
1945
|
+
fileId
|
|
1946
|
+
}) {
|
|
1947
|
+
return operationsByTag.files.getFileItem({
|
|
1948
|
+
pathParams: {
|
|
1949
|
+
workspace,
|
|
1950
|
+
region,
|
|
1951
|
+
dbBranchName: `${database}:${branch}`,
|
|
1952
|
+
tableName: table,
|
|
1953
|
+
recordId: record,
|
|
1954
|
+
columnName: column,
|
|
1955
|
+
fileId
|
|
1956
|
+
},
|
|
1957
|
+
...this.extraProps
|
|
1958
|
+
});
|
|
1959
|
+
}
|
|
1960
|
+
putFileItem({
|
|
1961
|
+
workspace,
|
|
1962
|
+
region,
|
|
1963
|
+
database,
|
|
1964
|
+
branch,
|
|
1965
|
+
table,
|
|
1966
|
+
record,
|
|
1967
|
+
column,
|
|
1968
|
+
fileId,
|
|
1969
|
+
file
|
|
1970
|
+
}) {
|
|
1971
|
+
return operationsByTag.files.putFileItem({
|
|
1972
|
+
pathParams: {
|
|
1973
|
+
workspace,
|
|
1974
|
+
region,
|
|
1975
|
+
dbBranchName: `${database}:${branch}`,
|
|
1976
|
+
tableName: table,
|
|
1977
|
+
recordId: record,
|
|
1978
|
+
columnName: column,
|
|
1979
|
+
fileId
|
|
1980
|
+
},
|
|
1981
|
+
// @ts-ignore
|
|
1982
|
+
body: file,
|
|
1983
|
+
...this.extraProps
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
deleteFileItem({
|
|
1987
|
+
workspace,
|
|
1988
|
+
region,
|
|
1989
|
+
database,
|
|
1990
|
+
branch,
|
|
1991
|
+
table,
|
|
1992
|
+
record,
|
|
1993
|
+
column,
|
|
1994
|
+
fileId
|
|
1995
|
+
}) {
|
|
1996
|
+
return operationsByTag.files.deleteFileItem({
|
|
1997
|
+
pathParams: {
|
|
1998
|
+
workspace,
|
|
1999
|
+
region,
|
|
2000
|
+
dbBranchName: `${database}:${branch}`,
|
|
2001
|
+
tableName: table,
|
|
2002
|
+
recordId: record,
|
|
2003
|
+
columnName: column,
|
|
2004
|
+
fileId
|
|
2005
|
+
},
|
|
1078
2006
|
...this.extraProps
|
|
1079
2007
|
});
|
|
1080
2008
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
2009
|
+
getFile({
|
|
2010
|
+
workspace,
|
|
2011
|
+
region,
|
|
2012
|
+
database,
|
|
2013
|
+
branch,
|
|
2014
|
+
table,
|
|
2015
|
+
record,
|
|
2016
|
+
column
|
|
2017
|
+
}) {
|
|
2018
|
+
return operationsByTag.files.getFile({
|
|
2019
|
+
pathParams: {
|
|
2020
|
+
workspace,
|
|
2021
|
+
region,
|
|
2022
|
+
dbBranchName: `${database}:${branch}`,
|
|
2023
|
+
tableName: table,
|
|
2024
|
+
recordId: record,
|
|
2025
|
+
columnName: column
|
|
2026
|
+
},
|
|
2027
|
+
...this.extraProps
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
putFile({
|
|
2031
|
+
workspace,
|
|
2032
|
+
region,
|
|
2033
|
+
database,
|
|
2034
|
+
branch,
|
|
2035
|
+
table,
|
|
2036
|
+
record,
|
|
2037
|
+
column,
|
|
2038
|
+
file
|
|
2039
|
+
}) {
|
|
2040
|
+
return operationsByTag.files.putFile({
|
|
2041
|
+
pathParams: {
|
|
2042
|
+
workspace,
|
|
2043
|
+
region,
|
|
2044
|
+
dbBranchName: `${database}:${branch}`,
|
|
2045
|
+
tableName: table,
|
|
2046
|
+
recordId: record,
|
|
2047
|
+
columnName: column
|
|
2048
|
+
},
|
|
2049
|
+
body: file,
|
|
2050
|
+
...this.extraProps
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
deleteFile({
|
|
2054
|
+
workspace,
|
|
2055
|
+
region,
|
|
2056
|
+
database,
|
|
2057
|
+
branch,
|
|
2058
|
+
table,
|
|
2059
|
+
record,
|
|
2060
|
+
column
|
|
2061
|
+
}) {
|
|
2062
|
+
return operationsByTag.files.deleteFile({
|
|
2063
|
+
pathParams: {
|
|
2064
|
+
workspace,
|
|
2065
|
+
region,
|
|
2066
|
+
dbBranchName: `${database}:${branch}`,
|
|
2067
|
+
tableName: table,
|
|
2068
|
+
recordId: record,
|
|
2069
|
+
columnName: column
|
|
2070
|
+
},
|
|
2071
|
+
...this.extraProps
|
|
2072
|
+
});
|
|
2073
|
+
}
|
|
2074
|
+
fileAccess({
|
|
2075
|
+
workspace,
|
|
2076
|
+
region,
|
|
2077
|
+
fileId,
|
|
2078
|
+
verify
|
|
2079
|
+
}) {
|
|
2080
|
+
return operationsByTag.files.fileAccess({
|
|
2081
|
+
pathParams: {
|
|
2082
|
+
workspace,
|
|
2083
|
+
region,
|
|
2084
|
+
fileId
|
|
2085
|
+
},
|
|
2086
|
+
queryParams: { verify },
|
|
2087
|
+
...this.extraProps
|
|
2088
|
+
});
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
class SearchAndFilterApi {
|
|
2092
|
+
constructor(extraProps) {
|
|
2093
|
+
this.extraProps = extraProps;
|
|
2094
|
+
}
|
|
2095
|
+
queryTable({
|
|
2096
|
+
workspace,
|
|
2097
|
+
region,
|
|
2098
|
+
database,
|
|
2099
|
+
branch,
|
|
2100
|
+
table,
|
|
2101
|
+
filter,
|
|
2102
|
+
sort,
|
|
2103
|
+
page,
|
|
2104
|
+
columns,
|
|
2105
|
+
consistency
|
|
2106
|
+
}) {
|
|
2107
|
+
return operationsByTag.searchAndFilter.queryTable({
|
|
2108
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
2109
|
+
body: { filter, sort, page, columns, consistency },
|
|
2110
|
+
...this.extraProps
|
|
2111
|
+
});
|
|
2112
|
+
}
|
|
2113
|
+
searchTable({
|
|
2114
|
+
workspace,
|
|
2115
|
+
region,
|
|
2116
|
+
database,
|
|
2117
|
+
branch,
|
|
2118
|
+
table,
|
|
2119
|
+
query,
|
|
2120
|
+
fuzziness,
|
|
2121
|
+
target,
|
|
2122
|
+
prefix,
|
|
2123
|
+
filter,
|
|
2124
|
+
highlight,
|
|
2125
|
+
boosters
|
|
2126
|
+
}) {
|
|
2127
|
+
return operationsByTag.searchAndFilter.searchTable({
|
|
2128
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
2129
|
+
body: { query, fuzziness, target, prefix, filter, highlight, boosters },
|
|
2130
|
+
...this.extraProps
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2133
|
+
searchBranch({
|
|
2134
|
+
workspace,
|
|
2135
|
+
region,
|
|
2136
|
+
database,
|
|
2137
|
+
branch,
|
|
2138
|
+
tables,
|
|
2139
|
+
query,
|
|
2140
|
+
fuzziness,
|
|
2141
|
+
prefix,
|
|
2142
|
+
highlight
|
|
2143
|
+
}) {
|
|
2144
|
+
return operationsByTag.searchAndFilter.searchBranch({
|
|
2145
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2146
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
|
2147
|
+
...this.extraProps
|
|
2148
|
+
});
|
|
2149
|
+
}
|
|
2150
|
+
vectorSearchTable({
|
|
2151
|
+
workspace,
|
|
2152
|
+
region,
|
|
2153
|
+
database,
|
|
2154
|
+
branch,
|
|
2155
|
+
table,
|
|
2156
|
+
queryVector,
|
|
2157
|
+
column,
|
|
2158
|
+
similarityFunction,
|
|
2159
|
+
size,
|
|
2160
|
+
filter
|
|
2161
|
+
}) {
|
|
2162
|
+
return operationsByTag.searchAndFilter.vectorSearchTable({
|
|
2163
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
2164
|
+
body: { queryVector, column, similarityFunction, size, filter },
|
|
2165
|
+
...this.extraProps
|
|
2166
|
+
});
|
|
2167
|
+
}
|
|
2168
|
+
askTable({
|
|
2169
|
+
workspace,
|
|
2170
|
+
region,
|
|
2171
|
+
database,
|
|
2172
|
+
branch,
|
|
2173
|
+
table,
|
|
2174
|
+
options
|
|
2175
|
+
}) {
|
|
2176
|
+
return operationsByTag.searchAndFilter.askTable({
|
|
2177
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
2178
|
+
body: { ...options },
|
|
1085
2179
|
...this.extraProps
|
|
1086
2180
|
});
|
|
1087
2181
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
2182
|
+
askTableSession({
|
|
2183
|
+
workspace,
|
|
2184
|
+
region,
|
|
2185
|
+
database,
|
|
2186
|
+
branch,
|
|
2187
|
+
table,
|
|
2188
|
+
sessionId,
|
|
2189
|
+
message
|
|
2190
|
+
}) {
|
|
2191
|
+
return operationsByTag.searchAndFilter.askTableSession({
|
|
2192
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
|
|
2193
|
+
body: { message },
|
|
1092
2194
|
...this.extraProps
|
|
1093
2195
|
});
|
|
1094
2196
|
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
2197
|
+
summarizeTable({
|
|
2198
|
+
workspace,
|
|
2199
|
+
region,
|
|
2200
|
+
database,
|
|
2201
|
+
branch,
|
|
2202
|
+
table,
|
|
2203
|
+
filter,
|
|
2204
|
+
columns,
|
|
2205
|
+
summaries,
|
|
2206
|
+
sort,
|
|
2207
|
+
summariesFilter,
|
|
2208
|
+
page,
|
|
2209
|
+
consistency
|
|
2210
|
+
}) {
|
|
2211
|
+
return operationsByTag.searchAndFilter.summarizeTable({
|
|
2212
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
2213
|
+
body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
|
|
2214
|
+
...this.extraProps
|
|
2215
|
+
});
|
|
2216
|
+
}
|
|
2217
|
+
aggregateTable({
|
|
2218
|
+
workspace,
|
|
2219
|
+
region,
|
|
2220
|
+
database,
|
|
2221
|
+
branch,
|
|
2222
|
+
table,
|
|
2223
|
+
filter,
|
|
2224
|
+
aggs
|
|
2225
|
+
}) {
|
|
2226
|
+
return operationsByTag.searchAndFilter.aggregateTable({
|
|
2227
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
2228
|
+
body: { filter, aggs },
|
|
1099
2229
|
...this.extraProps
|
|
1100
2230
|
});
|
|
1101
2231
|
}
|
|
@@ -1104,138 +2234,608 @@ class MigrationRequestsApi {
|
|
|
1104
2234
|
constructor(extraProps) {
|
|
1105
2235
|
this.extraProps = extraProps;
|
|
1106
2236
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
2237
|
+
queryMigrationRequests({
|
|
2238
|
+
workspace,
|
|
2239
|
+
region,
|
|
2240
|
+
database,
|
|
2241
|
+
filter,
|
|
2242
|
+
sort,
|
|
2243
|
+
page,
|
|
2244
|
+
columns
|
|
2245
|
+
}) {
|
|
2246
|
+
return operationsByTag.migrationRequests.queryMigrationRequests({
|
|
2247
|
+
pathParams: { workspace, region, dbName: database },
|
|
2248
|
+
body: { filter, sort, page, columns },
|
|
1111
2249
|
...this.extraProps
|
|
1112
2250
|
});
|
|
1113
2251
|
}
|
|
1114
|
-
createMigrationRequest(
|
|
2252
|
+
createMigrationRequest({
|
|
2253
|
+
workspace,
|
|
2254
|
+
region,
|
|
2255
|
+
database,
|
|
2256
|
+
migration
|
|
2257
|
+
}) {
|
|
1115
2258
|
return operationsByTag.migrationRequests.createMigrationRequest({
|
|
1116
|
-
pathParams: { workspace, dbName: database },
|
|
1117
|
-
body:
|
|
2259
|
+
pathParams: { workspace, region, dbName: database },
|
|
2260
|
+
body: migration,
|
|
1118
2261
|
...this.extraProps
|
|
1119
2262
|
});
|
|
1120
2263
|
}
|
|
1121
|
-
getMigrationRequest(
|
|
2264
|
+
getMigrationRequest({
|
|
2265
|
+
workspace,
|
|
2266
|
+
region,
|
|
2267
|
+
database,
|
|
2268
|
+
migrationRequest
|
|
2269
|
+
}) {
|
|
1122
2270
|
return operationsByTag.migrationRequests.getMigrationRequest({
|
|
1123
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
2271
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
1124
2272
|
...this.extraProps
|
|
1125
2273
|
});
|
|
1126
2274
|
}
|
|
1127
|
-
updateMigrationRequest(
|
|
2275
|
+
updateMigrationRequest({
|
|
2276
|
+
workspace,
|
|
2277
|
+
region,
|
|
2278
|
+
database,
|
|
2279
|
+
migrationRequest,
|
|
2280
|
+
update
|
|
2281
|
+
}) {
|
|
1128
2282
|
return operationsByTag.migrationRequests.updateMigrationRequest({
|
|
1129
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1130
|
-
body:
|
|
2283
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
2284
|
+
body: update,
|
|
1131
2285
|
...this.extraProps
|
|
1132
2286
|
});
|
|
1133
2287
|
}
|
|
1134
|
-
listMigrationRequestsCommits(
|
|
2288
|
+
listMigrationRequestsCommits({
|
|
2289
|
+
workspace,
|
|
2290
|
+
region,
|
|
2291
|
+
database,
|
|
2292
|
+
migrationRequest,
|
|
2293
|
+
page
|
|
2294
|
+
}) {
|
|
1135
2295
|
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
|
1136
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1137
|
-
body:
|
|
2296
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
2297
|
+
body: { page },
|
|
1138
2298
|
...this.extraProps
|
|
1139
2299
|
});
|
|
1140
2300
|
}
|
|
1141
|
-
compareMigrationRequest(
|
|
2301
|
+
compareMigrationRequest({
|
|
2302
|
+
workspace,
|
|
2303
|
+
region,
|
|
2304
|
+
database,
|
|
2305
|
+
migrationRequest
|
|
2306
|
+
}) {
|
|
1142
2307
|
return operationsByTag.migrationRequests.compareMigrationRequest({
|
|
1143
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
2308
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
1144
2309
|
...this.extraProps
|
|
1145
2310
|
});
|
|
1146
2311
|
}
|
|
1147
|
-
getMigrationRequestIsMerged(
|
|
2312
|
+
getMigrationRequestIsMerged({
|
|
2313
|
+
workspace,
|
|
2314
|
+
region,
|
|
2315
|
+
database,
|
|
2316
|
+
migrationRequest
|
|
2317
|
+
}) {
|
|
1148
2318
|
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
|
1149
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
2319
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
1150
2320
|
...this.extraProps
|
|
1151
2321
|
});
|
|
1152
2322
|
}
|
|
1153
|
-
mergeMigrationRequest(
|
|
2323
|
+
mergeMigrationRequest({
|
|
2324
|
+
workspace,
|
|
2325
|
+
region,
|
|
2326
|
+
database,
|
|
2327
|
+
migrationRequest
|
|
2328
|
+
}) {
|
|
1154
2329
|
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
|
1155
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
2330
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
|
1156
2331
|
...this.extraProps
|
|
1157
2332
|
});
|
|
1158
2333
|
}
|
|
1159
2334
|
}
|
|
1160
|
-
class
|
|
2335
|
+
class MigrationsApi {
|
|
1161
2336
|
constructor(extraProps) {
|
|
1162
2337
|
this.extraProps = extraProps;
|
|
1163
2338
|
}
|
|
1164
|
-
getBranchMigrationHistory(
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
2339
|
+
getBranchMigrationHistory({
|
|
2340
|
+
workspace,
|
|
2341
|
+
region,
|
|
2342
|
+
database,
|
|
2343
|
+
branch,
|
|
2344
|
+
limit,
|
|
2345
|
+
startFrom
|
|
2346
|
+
}) {
|
|
2347
|
+
return operationsByTag.migrations.getBranchMigrationHistory({
|
|
2348
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2349
|
+
body: { limit, startFrom },
|
|
1168
2350
|
...this.extraProps
|
|
1169
2351
|
});
|
|
1170
2352
|
}
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
2353
|
+
getBranchMigrationPlan({
|
|
2354
|
+
workspace,
|
|
2355
|
+
region,
|
|
2356
|
+
database,
|
|
2357
|
+
branch,
|
|
2358
|
+
schema
|
|
2359
|
+
}) {
|
|
2360
|
+
return operationsByTag.migrations.getBranchMigrationPlan({
|
|
2361
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2362
|
+
body: schema,
|
|
1175
2363
|
...this.extraProps
|
|
1176
2364
|
});
|
|
1177
2365
|
}
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
2366
|
+
executeBranchMigrationPlan({
|
|
2367
|
+
workspace,
|
|
2368
|
+
region,
|
|
2369
|
+
database,
|
|
2370
|
+
branch,
|
|
2371
|
+
plan
|
|
2372
|
+
}) {
|
|
2373
|
+
return operationsByTag.migrations.executeBranchMigrationPlan({
|
|
2374
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2375
|
+
body: plan,
|
|
1182
2376
|
...this.extraProps
|
|
1183
2377
|
});
|
|
1184
2378
|
}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
2379
|
+
getBranchSchemaHistory({
|
|
2380
|
+
workspace,
|
|
2381
|
+
region,
|
|
2382
|
+
database,
|
|
2383
|
+
branch,
|
|
2384
|
+
page
|
|
2385
|
+
}) {
|
|
2386
|
+
return operationsByTag.migrations.getBranchSchemaHistory({
|
|
2387
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2388
|
+
body: { page },
|
|
1189
2389
|
...this.extraProps
|
|
1190
2390
|
});
|
|
1191
2391
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
2392
|
+
compareBranchWithUserSchema({
|
|
2393
|
+
workspace,
|
|
2394
|
+
region,
|
|
2395
|
+
database,
|
|
2396
|
+
branch,
|
|
2397
|
+
schema,
|
|
2398
|
+
schemaOperations,
|
|
2399
|
+
branchOperations
|
|
2400
|
+
}) {
|
|
2401
|
+
return operationsByTag.migrations.compareBranchWithUserSchema({
|
|
2402
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2403
|
+
body: { schema, schemaOperations, branchOperations },
|
|
1196
2404
|
...this.extraProps
|
|
1197
2405
|
});
|
|
1198
2406
|
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
2407
|
+
compareBranchSchemas({
|
|
2408
|
+
workspace,
|
|
2409
|
+
region,
|
|
2410
|
+
database,
|
|
2411
|
+
branch,
|
|
2412
|
+
compare,
|
|
2413
|
+
sourceBranchOperations,
|
|
2414
|
+
targetBranchOperations
|
|
2415
|
+
}) {
|
|
2416
|
+
return operationsByTag.migrations.compareBranchSchemas({
|
|
2417
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
|
2418
|
+
body: { sourceBranchOperations, targetBranchOperations },
|
|
1203
2419
|
...this.extraProps
|
|
1204
2420
|
});
|
|
1205
2421
|
}
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
2422
|
+
updateBranchSchema({
|
|
2423
|
+
workspace,
|
|
2424
|
+
region,
|
|
2425
|
+
database,
|
|
2426
|
+
branch,
|
|
2427
|
+
migration
|
|
2428
|
+
}) {
|
|
2429
|
+
return operationsByTag.migrations.updateBranchSchema({
|
|
2430
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1209
2431
|
body: migration,
|
|
1210
2432
|
...this.extraProps
|
|
1211
2433
|
});
|
|
1212
2434
|
}
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
2435
|
+
previewBranchSchemaEdit({
|
|
2436
|
+
workspace,
|
|
2437
|
+
region,
|
|
2438
|
+
database,
|
|
2439
|
+
branch,
|
|
2440
|
+
data
|
|
2441
|
+
}) {
|
|
2442
|
+
return operationsByTag.migrations.previewBranchSchemaEdit({
|
|
2443
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2444
|
+
body: data,
|
|
2445
|
+
...this.extraProps
|
|
2446
|
+
});
|
|
2447
|
+
}
|
|
2448
|
+
applyBranchSchemaEdit({
|
|
2449
|
+
workspace,
|
|
2450
|
+
region,
|
|
2451
|
+
database,
|
|
2452
|
+
branch,
|
|
2453
|
+
edits
|
|
2454
|
+
}) {
|
|
2455
|
+
return operationsByTag.migrations.applyBranchSchemaEdit({
|
|
2456
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1216
2457
|
body: { edits },
|
|
1217
2458
|
...this.extraProps
|
|
1218
2459
|
});
|
|
1219
2460
|
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
2461
|
+
pushBranchMigrations({
|
|
2462
|
+
workspace,
|
|
2463
|
+
region,
|
|
2464
|
+
database,
|
|
2465
|
+
branch,
|
|
2466
|
+
migrations
|
|
2467
|
+
}) {
|
|
2468
|
+
return operationsByTag.migrations.pushBranchMigrations({
|
|
2469
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2470
|
+
body: { migrations },
|
|
2471
|
+
...this.extraProps
|
|
2472
|
+
});
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
class DatabaseApi {
|
|
2476
|
+
constructor(extraProps) {
|
|
2477
|
+
this.extraProps = extraProps;
|
|
2478
|
+
}
|
|
2479
|
+
getDatabaseList({ workspace }) {
|
|
2480
|
+
return operationsByTag.databases.getDatabaseList({
|
|
2481
|
+
pathParams: { workspaceId: workspace },
|
|
2482
|
+
...this.extraProps
|
|
2483
|
+
});
|
|
2484
|
+
}
|
|
2485
|
+
createDatabase({
|
|
2486
|
+
workspace,
|
|
2487
|
+
database,
|
|
2488
|
+
data,
|
|
2489
|
+
headers
|
|
2490
|
+
}) {
|
|
2491
|
+
return operationsByTag.databases.createDatabase({
|
|
2492
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2493
|
+
body: data,
|
|
2494
|
+
headers,
|
|
2495
|
+
...this.extraProps
|
|
2496
|
+
});
|
|
2497
|
+
}
|
|
2498
|
+
deleteDatabase({
|
|
2499
|
+
workspace,
|
|
2500
|
+
database
|
|
2501
|
+
}) {
|
|
2502
|
+
return operationsByTag.databases.deleteDatabase({
|
|
2503
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2504
|
+
...this.extraProps
|
|
2505
|
+
});
|
|
2506
|
+
}
|
|
2507
|
+
getDatabaseMetadata({
|
|
2508
|
+
workspace,
|
|
2509
|
+
database
|
|
2510
|
+
}) {
|
|
2511
|
+
return operationsByTag.databases.getDatabaseMetadata({
|
|
2512
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2513
|
+
...this.extraProps
|
|
2514
|
+
});
|
|
2515
|
+
}
|
|
2516
|
+
updateDatabaseMetadata({
|
|
2517
|
+
workspace,
|
|
2518
|
+
database,
|
|
2519
|
+
metadata
|
|
2520
|
+
}) {
|
|
2521
|
+
return operationsByTag.databases.updateDatabaseMetadata({
|
|
2522
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2523
|
+
body: metadata,
|
|
2524
|
+
...this.extraProps
|
|
2525
|
+
});
|
|
2526
|
+
}
|
|
2527
|
+
renameDatabase({
|
|
2528
|
+
workspace,
|
|
2529
|
+
database,
|
|
2530
|
+
newName
|
|
2531
|
+
}) {
|
|
2532
|
+
return operationsByTag.databases.renameDatabase({
|
|
2533
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2534
|
+
body: { newName },
|
|
2535
|
+
...this.extraProps
|
|
2536
|
+
});
|
|
2537
|
+
}
|
|
2538
|
+
getDatabaseGithubSettings({
|
|
2539
|
+
workspace,
|
|
2540
|
+
database
|
|
2541
|
+
}) {
|
|
2542
|
+
return operationsByTag.databases.getDatabaseGithubSettings({
|
|
2543
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2544
|
+
...this.extraProps
|
|
2545
|
+
});
|
|
2546
|
+
}
|
|
2547
|
+
updateDatabaseGithubSettings({
|
|
2548
|
+
workspace,
|
|
2549
|
+
database,
|
|
2550
|
+
settings
|
|
2551
|
+
}) {
|
|
2552
|
+
return operationsByTag.databases.updateDatabaseGithubSettings({
|
|
2553
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2554
|
+
body: settings,
|
|
2555
|
+
...this.extraProps
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
deleteDatabaseGithubSettings({
|
|
2559
|
+
workspace,
|
|
2560
|
+
database
|
|
2561
|
+
}) {
|
|
2562
|
+
return operationsByTag.databases.deleteDatabaseGithubSettings({
|
|
2563
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2564
|
+
...this.extraProps
|
|
2565
|
+
});
|
|
2566
|
+
}
|
|
2567
|
+
listRegions({ workspace }) {
|
|
2568
|
+
return operationsByTag.databases.listRegions({
|
|
2569
|
+
pathParams: { workspaceId: workspace },
|
|
2570
|
+
...this.extraProps
|
|
2571
|
+
});
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
class XataApiPlugin {
|
|
2576
|
+
build(options) {
|
|
2577
|
+
return new XataApiClient(options);
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2581
|
+
class XataPlugin {
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
class FilesPlugin extends XataPlugin {
|
|
2585
|
+
build(pluginOptions) {
|
|
2586
|
+
return {
|
|
2587
|
+
download: async (location) => {
|
|
2588
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
|
2589
|
+
return await getFileItem({
|
|
2590
|
+
pathParams: {
|
|
2591
|
+
workspace: "{workspaceId}",
|
|
2592
|
+
dbBranchName: "{dbBranch}",
|
|
2593
|
+
region: "{region}",
|
|
2594
|
+
tableName: table ?? "",
|
|
2595
|
+
recordId: record ?? "",
|
|
2596
|
+
columnName: column ?? "",
|
|
2597
|
+
fileId
|
|
2598
|
+
},
|
|
2599
|
+
...pluginOptions,
|
|
2600
|
+
rawResponse: true
|
|
2601
|
+
});
|
|
2602
|
+
},
|
|
2603
|
+
upload: async (location, file) => {
|
|
2604
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
|
2605
|
+
return await putFileItem({
|
|
2606
|
+
pathParams: {
|
|
2607
|
+
workspace: "{workspaceId}",
|
|
2608
|
+
dbBranchName: "{dbBranch}",
|
|
2609
|
+
region: "{region}",
|
|
2610
|
+
tableName: table ?? "",
|
|
2611
|
+
recordId: record ?? "",
|
|
2612
|
+
columnName: column ?? "",
|
|
2613
|
+
fileId
|
|
2614
|
+
},
|
|
2615
|
+
body: file,
|
|
2616
|
+
...pluginOptions
|
|
2617
|
+
});
|
|
2618
|
+
},
|
|
2619
|
+
delete: async (location) => {
|
|
2620
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
|
2621
|
+
return await deleteFileItem({
|
|
2622
|
+
pathParams: {
|
|
2623
|
+
workspace: "{workspaceId}",
|
|
2624
|
+
dbBranchName: "{dbBranch}",
|
|
2625
|
+
region: "{region}",
|
|
2626
|
+
tableName: table ?? "",
|
|
2627
|
+
recordId: record ?? "",
|
|
2628
|
+
columnName: column ?? "",
|
|
2629
|
+
fileId
|
|
2630
|
+
},
|
|
2631
|
+
...pluginOptions
|
|
2632
|
+
});
|
|
2633
|
+
}
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
function buildTransformString(transformations) {
|
|
2639
|
+
return transformations.flatMap(
|
|
2640
|
+
(t) => Object.entries(t).map(([key, value]) => {
|
|
2641
|
+
if (key === "trim") {
|
|
2642
|
+
const { left = 0, top = 0, right = 0, bottom = 0 } = value;
|
|
2643
|
+
return `${key}=${[top, right, bottom, left].join(";")}`;
|
|
2644
|
+
}
|
|
2645
|
+
if (key === "gravity" && typeof value === "object") {
|
|
2646
|
+
const { x = 0.5, y = 0.5 } = value;
|
|
2647
|
+
return `${key}=${[x, y].join("x")}`;
|
|
2648
|
+
}
|
|
2649
|
+
return `${key}=${value}`;
|
|
2650
|
+
})
|
|
2651
|
+
).join(",");
|
|
2652
|
+
}
|
|
2653
|
+
function transformImage(url, transformations) {
|
|
2654
|
+
if (!isDefined(url))
|
|
2655
|
+
return void 0;
|
|
2656
|
+
const transformationsString = buildTransformString(transformations);
|
|
2657
|
+
const { hostname, pathname, search } = new URL(url);
|
|
2658
|
+
return `https://${hostname}/transform/${transformationsString}${pathname}${search}`;
|
|
2659
|
+
}
|
|
2660
|
+
|
|
2661
|
+
var __defProp$6 = Object.defineProperty;
|
|
2662
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2663
|
+
var __publicField$6 = (obj, key, value) => {
|
|
2664
|
+
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2665
|
+
return value;
|
|
2666
|
+
};
|
|
2667
|
+
class XataFile {
|
|
2668
|
+
constructor(file) {
|
|
2669
|
+
/**
|
|
2670
|
+
* Name of this file.
|
|
2671
|
+
*/
|
|
2672
|
+
__publicField$6(this, "name");
|
|
2673
|
+
/**
|
|
2674
|
+
* Media type of this file.
|
|
2675
|
+
*/
|
|
2676
|
+
__publicField$6(this, "mediaType");
|
|
2677
|
+
/**
|
|
2678
|
+
* Base64 encoded content of this file.
|
|
2679
|
+
*/
|
|
2680
|
+
__publicField$6(this, "base64Content");
|
|
2681
|
+
/**
|
|
2682
|
+
* Whether to enable public url for this file.
|
|
2683
|
+
*/
|
|
2684
|
+
__publicField$6(this, "enablePublicUrl");
|
|
2685
|
+
/**
|
|
2686
|
+
* Timeout for the signed url.
|
|
2687
|
+
*/
|
|
2688
|
+
__publicField$6(this, "signedUrlTimeout");
|
|
2689
|
+
/**
|
|
2690
|
+
* Size of this file.
|
|
2691
|
+
*/
|
|
2692
|
+
__publicField$6(this, "size");
|
|
2693
|
+
/**
|
|
2694
|
+
* Version of this file.
|
|
2695
|
+
*/
|
|
2696
|
+
__publicField$6(this, "version");
|
|
2697
|
+
/**
|
|
2698
|
+
* Url of this file.
|
|
2699
|
+
*/
|
|
2700
|
+
__publicField$6(this, "url");
|
|
2701
|
+
/**
|
|
2702
|
+
* Signed url of this file.
|
|
2703
|
+
*/
|
|
2704
|
+
__publicField$6(this, "signedUrl");
|
|
2705
|
+
/**
|
|
2706
|
+
* Attributes of this file.
|
|
2707
|
+
*/
|
|
2708
|
+
__publicField$6(this, "attributes");
|
|
2709
|
+
this.name = file.name;
|
|
2710
|
+
this.mediaType = file.mediaType || "application/octet-stream";
|
|
2711
|
+
this.base64Content = file.base64Content;
|
|
2712
|
+
this.enablePublicUrl = file.enablePublicUrl;
|
|
2713
|
+
this.signedUrlTimeout = file.signedUrlTimeout;
|
|
2714
|
+
this.size = file.size;
|
|
2715
|
+
this.version = file.version;
|
|
2716
|
+
this.url = file.url;
|
|
2717
|
+
this.signedUrl = file.signedUrl;
|
|
2718
|
+
this.attributes = file.attributes;
|
|
2719
|
+
}
|
|
2720
|
+
static fromBuffer(buffer, options = {}) {
|
|
2721
|
+
const base64Content = buffer.toString("base64");
|
|
2722
|
+
return new XataFile({ ...options, base64Content });
|
|
2723
|
+
}
|
|
2724
|
+
toBuffer() {
|
|
2725
|
+
if (!this.base64Content) {
|
|
2726
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
|
2727
|
+
}
|
|
2728
|
+
return Buffer.from(this.base64Content, "base64");
|
|
2729
|
+
}
|
|
2730
|
+
static fromArrayBuffer(arrayBuffer, options = {}) {
|
|
2731
|
+
const uint8Array = new Uint8Array(arrayBuffer);
|
|
2732
|
+
return this.fromUint8Array(uint8Array, options);
|
|
2733
|
+
}
|
|
2734
|
+
toArrayBuffer() {
|
|
2735
|
+
if (!this.base64Content) {
|
|
2736
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
|
2737
|
+
}
|
|
2738
|
+
const binary = atob(this.base64Content);
|
|
2739
|
+
return new ArrayBuffer(binary.length);
|
|
2740
|
+
}
|
|
2741
|
+
static fromUint8Array(uint8Array, options = {}) {
|
|
2742
|
+
let binary = "";
|
|
2743
|
+
for (let i = 0; i < uint8Array.byteLength; i++) {
|
|
2744
|
+
binary += String.fromCharCode(uint8Array[i]);
|
|
2745
|
+
}
|
|
2746
|
+
const base64Content = btoa(binary);
|
|
2747
|
+
return new XataFile({ ...options, base64Content });
|
|
2748
|
+
}
|
|
2749
|
+
toUint8Array() {
|
|
2750
|
+
if (!this.base64Content) {
|
|
2751
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
|
2752
|
+
}
|
|
2753
|
+
const binary = atob(this.base64Content);
|
|
2754
|
+
const uint8Array = new Uint8Array(binary.length);
|
|
2755
|
+
for (let i = 0; i < binary.length; i++) {
|
|
2756
|
+
uint8Array[i] = binary.charCodeAt(i);
|
|
2757
|
+
}
|
|
2758
|
+
return uint8Array;
|
|
2759
|
+
}
|
|
2760
|
+
static async fromBlob(file, options = {}) {
|
|
2761
|
+
const name = options.name ?? file.name;
|
|
2762
|
+
const mediaType = file.type;
|
|
2763
|
+
const arrayBuffer = await file.arrayBuffer();
|
|
2764
|
+
return this.fromArrayBuffer(arrayBuffer, { ...options, name, mediaType });
|
|
2765
|
+
}
|
|
2766
|
+
toBlob() {
|
|
2767
|
+
if (!this.base64Content) {
|
|
2768
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
|
2769
|
+
}
|
|
2770
|
+
const arrayBuffer = this.toArrayBuffer();
|
|
2771
|
+
return new Blob([arrayBuffer], { type: this.mediaType });
|
|
2772
|
+
}
|
|
2773
|
+
static fromString(string, options = {}) {
|
|
2774
|
+
const base64Content = btoa(string);
|
|
2775
|
+
return new XataFile({ ...options, base64Content });
|
|
2776
|
+
}
|
|
2777
|
+
toString() {
|
|
2778
|
+
if (!this.base64Content) {
|
|
2779
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
|
2780
|
+
}
|
|
2781
|
+
return atob(this.base64Content);
|
|
2782
|
+
}
|
|
2783
|
+
static fromBase64(base64Content, options = {}) {
|
|
2784
|
+
return new XataFile({ ...options, base64Content });
|
|
2785
|
+
}
|
|
2786
|
+
toBase64() {
|
|
2787
|
+
if (!this.base64Content) {
|
|
2788
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
|
2789
|
+
}
|
|
2790
|
+
return this.base64Content;
|
|
1226
2791
|
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
return new XataApiClient({ fetch: fetchImpl, apiKey });
|
|
2792
|
+
transform(...options) {
|
|
2793
|
+
return {
|
|
2794
|
+
url: transformImage(this.url, options),
|
|
2795
|
+
signedUrl: transformImage(this.signedUrl, options)
|
|
2796
|
+
};
|
|
1233
2797
|
}
|
|
1234
2798
|
}
|
|
2799
|
+
const parseInputFileEntry = async (entry) => {
|
|
2800
|
+
if (!isDefined(entry))
|
|
2801
|
+
return null;
|
|
2802
|
+
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
|
|
2803
|
+
return compactObject({ id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout });
|
|
2804
|
+
};
|
|
1235
2805
|
|
|
1236
|
-
|
|
2806
|
+
function cleanFilter(filter) {
|
|
2807
|
+
if (!isDefined(filter))
|
|
2808
|
+
return void 0;
|
|
2809
|
+
if (!isObject(filter))
|
|
2810
|
+
return filter;
|
|
2811
|
+
const values = Object.fromEntries(
|
|
2812
|
+
Object.entries(filter).reduce((acc, [key, value]) => {
|
|
2813
|
+
if (!isDefined(value))
|
|
2814
|
+
return acc;
|
|
2815
|
+
if (Array.isArray(value)) {
|
|
2816
|
+
const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
|
|
2817
|
+
if (clean.length === 0)
|
|
2818
|
+
return acc;
|
|
2819
|
+
return [...acc, [key, clean]];
|
|
2820
|
+
}
|
|
2821
|
+
if (isObject(value)) {
|
|
2822
|
+
const clean = cleanFilter(value);
|
|
2823
|
+
if (!isDefined(clean))
|
|
2824
|
+
return acc;
|
|
2825
|
+
return [...acc, [key, clean]];
|
|
2826
|
+
}
|
|
2827
|
+
return [...acc, [key, value]];
|
|
2828
|
+
}, [])
|
|
2829
|
+
);
|
|
2830
|
+
return Object.keys(values).length > 0 ? values : void 0;
|
|
1237
2831
|
}
|
|
1238
2832
|
|
|
2833
|
+
var __defProp$5 = Object.defineProperty;
|
|
2834
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2835
|
+
var __publicField$5 = (obj, key, value) => {
|
|
2836
|
+
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2837
|
+
return value;
|
|
2838
|
+
};
|
|
1239
2839
|
var __accessCheck$6 = (obj, member, msg) => {
|
|
1240
2840
|
if (!member.has(obj))
|
|
1241
2841
|
throw TypeError("Cannot " + msg);
|
|
@@ -1258,22 +2858,58 @@ var _query, _page;
|
|
|
1258
2858
|
class Page {
|
|
1259
2859
|
constructor(query, meta, records = []) {
|
|
1260
2860
|
__privateAdd$6(this, _query, void 0);
|
|
2861
|
+
/**
|
|
2862
|
+
* Page metadata, required to retrieve additional records.
|
|
2863
|
+
*/
|
|
2864
|
+
__publicField$5(this, "meta");
|
|
2865
|
+
/**
|
|
2866
|
+
* The set of results for this page.
|
|
2867
|
+
*/
|
|
2868
|
+
__publicField$5(this, "records");
|
|
1261
2869
|
__privateSet$6(this, _query, query);
|
|
1262
2870
|
this.meta = meta;
|
|
1263
2871
|
this.records = new RecordArray(this, records);
|
|
1264
2872
|
}
|
|
2873
|
+
/**
|
|
2874
|
+
* Retrieves the next page of results.
|
|
2875
|
+
* @param size Maximum number of results to be retrieved.
|
|
2876
|
+
* @param offset Number of results to skip when retrieving the results.
|
|
2877
|
+
* @returns The next page or results.
|
|
2878
|
+
*/
|
|
1265
2879
|
async nextPage(size, offset) {
|
|
1266
2880
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
|
1267
2881
|
}
|
|
2882
|
+
/**
|
|
2883
|
+
* Retrieves the previous page of results.
|
|
2884
|
+
* @param size Maximum number of results to be retrieved.
|
|
2885
|
+
* @param offset Number of results to skip when retrieving the results.
|
|
2886
|
+
* @returns The previous page or results.
|
|
2887
|
+
*/
|
|
1268
2888
|
async previousPage(size, offset) {
|
|
1269
2889
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
|
1270
2890
|
}
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
2891
|
+
/**
|
|
2892
|
+
* Retrieves the start page of results.
|
|
2893
|
+
* @param size Maximum number of results to be retrieved.
|
|
2894
|
+
* @param offset Number of results to skip when retrieving the results.
|
|
2895
|
+
* @returns The start page or results.
|
|
2896
|
+
*/
|
|
2897
|
+
async startPage(size, offset) {
|
|
2898
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
|
2899
|
+
}
|
|
2900
|
+
/**
|
|
2901
|
+
* Retrieves the end page of results.
|
|
2902
|
+
* @param size Maximum number of results to be retrieved.
|
|
2903
|
+
* @param offset Number of results to skip when retrieving the results.
|
|
2904
|
+
* @returns The end page or results.
|
|
2905
|
+
*/
|
|
2906
|
+
async endPage(size, offset) {
|
|
2907
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
|
2908
|
+
}
|
|
2909
|
+
/**
|
|
2910
|
+
* Shortcut method to check if there will be additional results if the next page of results is retrieved.
|
|
2911
|
+
* @returns Whether or not there will be additional results in the next page of results.
|
|
2912
|
+
*/
|
|
1277
2913
|
hasNextPage() {
|
|
1278
2914
|
return this.meta.page.more;
|
|
1279
2915
|
}
|
|
@@ -1284,9 +2920,9 @@ const PAGINATION_DEFAULT_SIZE = 20;
|
|
|
1284
2920
|
const PAGINATION_MAX_OFFSET = 800;
|
|
1285
2921
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
|
1286
2922
|
function isCursorPaginationOptions(options) {
|
|
1287
|
-
return isDefined(options) && (isDefined(options.
|
|
2923
|
+
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
|
1288
2924
|
}
|
|
1289
|
-
const _RecordArray = class extends Array {
|
|
2925
|
+
const _RecordArray = class _RecordArray extends Array {
|
|
1290
2926
|
constructor(...args) {
|
|
1291
2927
|
super(..._RecordArray.parseConstructorParams(...args));
|
|
1292
2928
|
__privateAdd$6(this, _page, void 0);
|
|
@@ -1305,32 +2941,67 @@ const _RecordArray = class extends Array {
|
|
|
1305
2941
|
toArray() {
|
|
1306
2942
|
return new Array(...this);
|
|
1307
2943
|
}
|
|
2944
|
+
toSerializable() {
|
|
2945
|
+
return JSON.parse(this.toString());
|
|
2946
|
+
}
|
|
2947
|
+
toString() {
|
|
2948
|
+
return JSON.stringify(this.toArray());
|
|
2949
|
+
}
|
|
1308
2950
|
map(callbackfn, thisArg) {
|
|
1309
2951
|
return this.toArray().map(callbackfn, thisArg);
|
|
1310
2952
|
}
|
|
2953
|
+
/**
|
|
2954
|
+
* Retrieve next page of records
|
|
2955
|
+
*
|
|
2956
|
+
* @returns A new array of objects
|
|
2957
|
+
*/
|
|
1311
2958
|
async nextPage(size, offset) {
|
|
1312
2959
|
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
|
1313
2960
|
return new _RecordArray(newPage);
|
|
1314
2961
|
}
|
|
2962
|
+
/**
|
|
2963
|
+
* Retrieve previous page of records
|
|
2964
|
+
*
|
|
2965
|
+
* @returns A new array of objects
|
|
2966
|
+
*/
|
|
1315
2967
|
async previousPage(size, offset) {
|
|
1316
2968
|
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
|
1317
2969
|
return new _RecordArray(newPage);
|
|
1318
2970
|
}
|
|
1319
|
-
|
|
1320
|
-
|
|
2971
|
+
/**
|
|
2972
|
+
* Retrieve start page of records
|
|
2973
|
+
*
|
|
2974
|
+
* @returns A new array of objects
|
|
2975
|
+
*/
|
|
2976
|
+
async startPage(size, offset) {
|
|
2977
|
+
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
|
1321
2978
|
return new _RecordArray(newPage);
|
|
1322
2979
|
}
|
|
1323
|
-
|
|
1324
|
-
|
|
2980
|
+
/**
|
|
2981
|
+
* Retrieve end page of records
|
|
2982
|
+
*
|
|
2983
|
+
* @returns A new array of objects
|
|
2984
|
+
*/
|
|
2985
|
+
async endPage(size, offset) {
|
|
2986
|
+
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
|
1325
2987
|
return new _RecordArray(newPage);
|
|
1326
2988
|
}
|
|
2989
|
+
/**
|
|
2990
|
+
* @returns Boolean indicating if there is a next page
|
|
2991
|
+
*/
|
|
1327
2992
|
hasNextPage() {
|
|
1328
2993
|
return __privateGet$6(this, _page).meta.page.more;
|
|
1329
2994
|
}
|
|
1330
2995
|
};
|
|
1331
|
-
let RecordArray = _RecordArray;
|
|
1332
2996
|
_page = new WeakMap();
|
|
2997
|
+
let RecordArray = _RecordArray;
|
|
1333
2998
|
|
|
2999
|
+
var __defProp$4 = Object.defineProperty;
|
|
3000
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3001
|
+
var __publicField$4 = (obj, key, value) => {
|
|
3002
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3003
|
+
return value;
|
|
3004
|
+
};
|
|
1334
3005
|
var __accessCheck$5 = (obj, member, msg) => {
|
|
1335
3006
|
if (!member.has(obj))
|
|
1336
3007
|
throw TypeError("Cannot " + msg);
|
|
@@ -1349,14 +3020,20 @@ var __privateSet$5 = (obj, member, value, setter) => {
|
|
|
1349
3020
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1350
3021
|
return value;
|
|
1351
3022
|
};
|
|
1352
|
-
var
|
|
1353
|
-
|
|
3023
|
+
var __privateMethod$3 = (obj, member, method) => {
|
|
3024
|
+
__accessCheck$5(obj, member, "access private method");
|
|
3025
|
+
return method;
|
|
3026
|
+
};
|
|
3027
|
+
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
|
3028
|
+
const _Query = class _Query {
|
|
1354
3029
|
constructor(repository, table, data, rawParent) {
|
|
3030
|
+
__privateAdd$5(this, _cleanFilterConstraint);
|
|
1355
3031
|
__privateAdd$5(this, _table$1, void 0);
|
|
1356
3032
|
__privateAdd$5(this, _repository, void 0);
|
|
1357
3033
|
__privateAdd$5(this, _data, { filter: {} });
|
|
1358
|
-
|
|
1359
|
-
this
|
|
3034
|
+
// Implements pagination
|
|
3035
|
+
__publicField$4(this, "meta", { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } });
|
|
3036
|
+
__publicField$4(this, "records", new RecordArray(this, []));
|
|
1360
3037
|
__privateSet$5(this, _table$1, table);
|
|
1361
3038
|
if (repository) {
|
|
1362
3039
|
__privateSet$5(this, _repository, repository);
|
|
@@ -1370,9 +3047,11 @@ const _Query = class {
|
|
|
1370
3047
|
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
|
1371
3048
|
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
|
1372
3049
|
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
|
1373
|
-
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns
|
|
3050
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
|
|
3051
|
+
__privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
|
|
1374
3052
|
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
|
1375
3053
|
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
|
3054
|
+
__privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
|
|
1376
3055
|
this.any = this.any.bind(this);
|
|
1377
3056
|
this.all = this.all.bind(this);
|
|
1378
3057
|
this.not = this.not.bind(this);
|
|
@@ -1390,45 +3069,65 @@ const _Query = class {
|
|
|
1390
3069
|
const key = JSON.stringify({ columns, filter, sort, pagination });
|
|
1391
3070
|
return toBase64(key);
|
|
1392
3071
|
}
|
|
3072
|
+
/**
|
|
3073
|
+
* Builds a new query object representing a logical OR between the given subqueries.
|
|
3074
|
+
* @param queries An array of subqueries.
|
|
3075
|
+
* @returns A new Query object.
|
|
3076
|
+
*/
|
|
1393
3077
|
any(...queries) {
|
|
1394
3078
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
1395
3079
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
|
1396
3080
|
}
|
|
3081
|
+
/**
|
|
3082
|
+
* Builds a new query object representing a logical AND between the given subqueries.
|
|
3083
|
+
* @param queries An array of subqueries.
|
|
3084
|
+
* @returns A new Query object.
|
|
3085
|
+
*/
|
|
1397
3086
|
all(...queries) {
|
|
1398
3087
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
1399
3088
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
|
1400
3089
|
}
|
|
3090
|
+
/**
|
|
3091
|
+
* Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
|
|
3092
|
+
* @param queries An array of subqueries.
|
|
3093
|
+
* @returns A new Query object.
|
|
3094
|
+
*/
|
|
1401
3095
|
not(...queries) {
|
|
1402
3096
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
1403
3097
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
|
1404
3098
|
}
|
|
3099
|
+
/**
|
|
3100
|
+
* Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
|
|
3101
|
+
* @param queries An array of subqueries.
|
|
3102
|
+
* @returns A new Query object.
|
|
3103
|
+
*/
|
|
1405
3104
|
none(...queries) {
|
|
1406
3105
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
1407
3106
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
|
1408
3107
|
}
|
|
1409
3108
|
filter(a, b) {
|
|
1410
3109
|
if (arguments.length === 1) {
|
|
1411
|
-
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
|
3110
|
+
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
|
3111
|
+
[column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
|
|
3112
|
+
}));
|
|
1412
3113
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
|
1413
3114
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
|
1414
3115
|
} else {
|
|
1415
|
-
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.
|
|
3116
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
|
|
1416
3117
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
|
1417
3118
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
|
1418
3119
|
}
|
|
1419
3120
|
}
|
|
1420
|
-
defaultFilter(column, value) {
|
|
1421
|
-
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
|
1422
|
-
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
|
1423
|
-
return { $includes: value };
|
|
1424
|
-
}
|
|
1425
|
-
return value;
|
|
1426
|
-
}
|
|
1427
3121
|
sort(column, direction = "asc") {
|
|
1428
3122
|
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
|
1429
3123
|
const sort = [...originalSort, { column, direction }];
|
|
1430
3124
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
|
1431
3125
|
}
|
|
3126
|
+
/**
|
|
3127
|
+
* Builds a new query specifying the set of columns to be returned in the query response.
|
|
3128
|
+
* @param columns Array of column names to be returned by the query.
|
|
3129
|
+
* @returns A new Query object.
|
|
3130
|
+
*/
|
|
1432
3131
|
select(columns) {
|
|
1433
3132
|
return new _Query(
|
|
1434
3133
|
__privateGet$5(this, _repository),
|
|
@@ -1441,6 +3140,12 @@ const _Query = class {
|
|
|
1441
3140
|
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
|
1442
3141
|
return __privateGet$5(this, _repository).query(query);
|
|
1443
3142
|
}
|
|
3143
|
+
/**
|
|
3144
|
+
* Get results in an iterator
|
|
3145
|
+
*
|
|
3146
|
+
* @async
|
|
3147
|
+
* @returns Async interable of results
|
|
3148
|
+
*/
|
|
1444
3149
|
async *[Symbol.asyncIterator]() {
|
|
1445
3150
|
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
|
1446
3151
|
yield record;
|
|
@@ -1458,11 +3163,20 @@ const _Query = class {
|
|
|
1458
3163
|
}
|
|
1459
3164
|
}
|
|
1460
3165
|
async getMany(options = {}) {
|
|
1461
|
-
const
|
|
3166
|
+
const { pagination = {}, ...rest } = options;
|
|
3167
|
+
const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
|
|
3168
|
+
const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
|
|
3169
|
+
let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
|
|
3170
|
+
const results = [...page.records];
|
|
3171
|
+
while (page.hasNextPage() && results.length < size) {
|
|
3172
|
+
page = await page.nextPage();
|
|
3173
|
+
results.push(...page.records);
|
|
3174
|
+
}
|
|
1462
3175
|
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
|
1463
3176
|
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
|
1464
3177
|
}
|
|
1465
|
-
|
|
3178
|
+
const array = new RecordArray(page, results.slice(0, size));
|
|
3179
|
+
return array;
|
|
1466
3180
|
}
|
|
1467
3181
|
async getAll(options = {}) {
|
|
1468
3182
|
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
|
@@ -1476,36 +3190,106 @@ const _Query = class {
|
|
|
1476
3190
|
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
|
1477
3191
|
return records[0] ?? null;
|
|
1478
3192
|
}
|
|
3193
|
+
async getFirstOrThrow(options = {}) {
|
|
3194
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
|
3195
|
+
if (records[0] === void 0)
|
|
3196
|
+
throw new Error("No results found.");
|
|
3197
|
+
return records[0];
|
|
3198
|
+
}
|
|
3199
|
+
async summarize(params = {}) {
|
|
3200
|
+
const { summaries, summariesFilter, ...options } = params;
|
|
3201
|
+
const query = new _Query(
|
|
3202
|
+
__privateGet$5(this, _repository),
|
|
3203
|
+
__privateGet$5(this, _table$1),
|
|
3204
|
+
options,
|
|
3205
|
+
__privateGet$5(this, _data)
|
|
3206
|
+
);
|
|
3207
|
+
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
|
3208
|
+
}
|
|
3209
|
+
/**
|
|
3210
|
+
* Builds a new query object adding a cache TTL in milliseconds.
|
|
3211
|
+
* @param ttl The cache TTL in milliseconds.
|
|
3212
|
+
* @returns A new Query object.
|
|
3213
|
+
*/
|
|
1479
3214
|
cache(ttl) {
|
|
1480
3215
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
|
1481
3216
|
}
|
|
3217
|
+
/**
|
|
3218
|
+
* Retrieve next page of records
|
|
3219
|
+
*
|
|
3220
|
+
* @returns A new page object.
|
|
3221
|
+
*/
|
|
1482
3222
|
nextPage(size, offset) {
|
|
1483
|
-
return this.
|
|
3223
|
+
return this.startPage(size, offset);
|
|
1484
3224
|
}
|
|
3225
|
+
/**
|
|
3226
|
+
* Retrieve previous page of records
|
|
3227
|
+
*
|
|
3228
|
+
* @returns A new page object
|
|
3229
|
+
*/
|
|
1485
3230
|
previousPage(size, offset) {
|
|
1486
|
-
return this.
|
|
1487
|
-
}
|
|
1488
|
-
|
|
3231
|
+
return this.startPage(size, offset);
|
|
3232
|
+
}
|
|
3233
|
+
/**
|
|
3234
|
+
* Retrieve start page of records
|
|
3235
|
+
*
|
|
3236
|
+
* @returns A new page object
|
|
3237
|
+
*/
|
|
3238
|
+
startPage(size, offset) {
|
|
1489
3239
|
return this.getPaginated({ pagination: { size, offset } });
|
|
1490
3240
|
}
|
|
1491
|
-
|
|
3241
|
+
/**
|
|
3242
|
+
* Retrieve last page of records
|
|
3243
|
+
*
|
|
3244
|
+
* @returns A new page object
|
|
3245
|
+
*/
|
|
3246
|
+
endPage(size, offset) {
|
|
1492
3247
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
|
1493
3248
|
}
|
|
3249
|
+
/**
|
|
3250
|
+
* @returns Boolean indicating if there is a next page
|
|
3251
|
+
*/
|
|
1494
3252
|
hasNextPage() {
|
|
1495
3253
|
return this.meta.page.more;
|
|
1496
3254
|
}
|
|
1497
3255
|
};
|
|
1498
|
-
let Query = _Query;
|
|
1499
3256
|
_table$1 = new WeakMap();
|
|
1500
3257
|
_repository = new WeakMap();
|
|
1501
3258
|
_data = new WeakMap();
|
|
3259
|
+
_cleanFilterConstraint = new WeakSet();
|
|
3260
|
+
cleanFilterConstraint_fn = function(column, value) {
|
|
3261
|
+
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
|
3262
|
+
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
|
3263
|
+
return { $includes: value };
|
|
3264
|
+
}
|
|
3265
|
+
if (columnType === "link" && isObject(value) && isString(value.id)) {
|
|
3266
|
+
return value.id;
|
|
3267
|
+
}
|
|
3268
|
+
return value;
|
|
3269
|
+
};
|
|
3270
|
+
let Query = _Query;
|
|
1502
3271
|
function cleanParent(data, parent) {
|
|
1503
3272
|
if (isCursorPaginationOptions(data.pagination)) {
|
|
1504
|
-
return { ...parent,
|
|
3273
|
+
return { ...parent, sort: void 0, filter: void 0 };
|
|
1505
3274
|
}
|
|
1506
3275
|
return parent;
|
|
1507
3276
|
}
|
|
1508
3277
|
|
|
3278
|
+
const RecordColumnTypes = [
|
|
3279
|
+
"bool",
|
|
3280
|
+
"int",
|
|
3281
|
+
"float",
|
|
3282
|
+
"string",
|
|
3283
|
+
"text",
|
|
3284
|
+
"email",
|
|
3285
|
+
"multiple",
|
|
3286
|
+
"link",
|
|
3287
|
+
"object",
|
|
3288
|
+
"datetime",
|
|
3289
|
+
"vector",
|
|
3290
|
+
"file[]",
|
|
3291
|
+
"file"
|
|
3292
|
+
];
|
|
1509
3293
|
function isIdentifiable(x) {
|
|
1510
3294
|
return isObject(x) && isString(x?.id);
|
|
1511
3295
|
}
|
|
@@ -1519,7 +3303,11 @@ function isSortFilterString(value) {
|
|
|
1519
3303
|
return isString(value);
|
|
1520
3304
|
}
|
|
1521
3305
|
function isSortFilterBase(filter) {
|
|
1522
|
-
return isObject(filter) && Object.
|
|
3306
|
+
return isObject(filter) && Object.entries(filter).every(([key, value]) => {
|
|
3307
|
+
if (key === "*")
|
|
3308
|
+
return value === "random";
|
|
3309
|
+
return value === "asc" || value === "desc";
|
|
3310
|
+
});
|
|
1523
3311
|
}
|
|
1524
3312
|
function isSortFilterObject(filter) {
|
|
1525
3313
|
return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
|
|
@@ -1560,7 +3348,8 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
|
1560
3348
|
__accessCheck$4(obj, member, "access private method");
|
|
1561
3349
|
return method;
|
|
1562
3350
|
};
|
|
1563
|
-
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn,
|
|
3351
|
+
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _insertRecords, insertRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _updateRecords, updateRecords_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _deleteRecords, deleteRecords_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1, _transformObjectToApi, transformObjectToApi_fn;
|
|
3352
|
+
const BULK_OPERATION_MAX_SIZE = 1e3;
|
|
1564
3353
|
class Repository extends Query {
|
|
1565
3354
|
}
|
|
1566
3355
|
class RestRepository extends Query {
|
|
@@ -1572,13 +3361,16 @@ class RestRepository extends Query {
|
|
|
1572
3361
|
);
|
|
1573
3362
|
__privateAdd$4(this, _insertRecordWithoutId);
|
|
1574
3363
|
__privateAdd$4(this, _insertRecordWithId);
|
|
1575
|
-
__privateAdd$4(this,
|
|
3364
|
+
__privateAdd$4(this, _insertRecords);
|
|
1576
3365
|
__privateAdd$4(this, _updateRecordWithID);
|
|
3366
|
+
__privateAdd$4(this, _updateRecords);
|
|
1577
3367
|
__privateAdd$4(this, _upsertRecordWithID);
|
|
1578
3368
|
__privateAdd$4(this, _deleteRecord);
|
|
3369
|
+
__privateAdd$4(this, _deleteRecords);
|
|
1579
3370
|
__privateAdd$4(this, _setCacheQuery);
|
|
1580
3371
|
__privateAdd$4(this, _getCacheQuery);
|
|
1581
3372
|
__privateAdd$4(this, _getSchemaTables$1);
|
|
3373
|
+
__privateAdd$4(this, _transformObjectToApi);
|
|
1582
3374
|
__privateAdd$4(this, _table, void 0);
|
|
1583
3375
|
__privateAdd$4(this, _getFetchProps, void 0);
|
|
1584
3376
|
__privateAdd$4(this, _db, void 0);
|
|
@@ -1586,13 +3378,13 @@ class RestRepository extends Query {
|
|
|
1586
3378
|
__privateAdd$4(this, _schemaTables$2, void 0);
|
|
1587
3379
|
__privateAdd$4(this, _trace, void 0);
|
|
1588
3380
|
__privateSet$4(this, _table, options.table);
|
|
1589
|
-
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
|
1590
3381
|
__privateSet$4(this, _db, options.db);
|
|
1591
3382
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
|
1592
3383
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
|
3384
|
+
__privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
|
|
1593
3385
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
|
1594
3386
|
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
|
1595
|
-
return trace(
|
|
3387
|
+
return trace(name, fn, {
|
|
1596
3388
|
...options2,
|
|
1597
3389
|
[TraceAttributes.TABLE]: __privateGet$4(this, _table),
|
|
1598
3390
|
[TraceAttributes.KIND]: "sdk-operation",
|
|
@@ -1600,25 +3392,28 @@ class RestRepository extends Query {
|
|
|
1600
3392
|
});
|
|
1601
3393
|
});
|
|
1602
3394
|
}
|
|
1603
|
-
async create(a, b, c) {
|
|
3395
|
+
async create(a, b, c, d) {
|
|
1604
3396
|
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
|
3397
|
+
const ifVersion = parseIfVersion(b, c, d);
|
|
1605
3398
|
if (Array.isArray(a)) {
|
|
1606
3399
|
if (a.length === 0)
|
|
1607
3400
|
return [];
|
|
1608
|
-
const
|
|
1609
|
-
|
|
3401
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
|
3402
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
3403
|
+
const result = await this.read(ids, columns);
|
|
3404
|
+
return result;
|
|
1610
3405
|
}
|
|
1611
3406
|
if (isString(a) && isObject(b)) {
|
|
1612
3407
|
if (a === "")
|
|
1613
3408
|
throw new Error("The id can't be empty");
|
|
1614
3409
|
const columns = isStringArray(c) ? c : void 0;
|
|
1615
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
|
3410
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
|
1616
3411
|
}
|
|
1617
3412
|
if (isObject(a) && isString(a.id)) {
|
|
1618
3413
|
if (a.id === "")
|
|
1619
3414
|
throw new Error("The id can't be empty");
|
|
1620
3415
|
const columns = isStringArray(b) ? b : void 0;
|
|
1621
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
|
3416
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
|
1622
3417
|
}
|
|
1623
3418
|
if (isObject(a)) {
|
|
1624
3419
|
const columns = isStringArray(b) ? b : void 0;
|
|
@@ -1643,20 +3438,20 @@ class RestRepository extends Query {
|
|
|
1643
3438
|
}
|
|
1644
3439
|
const id = extractId(a);
|
|
1645
3440
|
if (id) {
|
|
1646
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1647
3441
|
try {
|
|
1648
3442
|
const response = await getRecord({
|
|
1649
3443
|
pathParams: {
|
|
1650
3444
|
workspace: "{workspaceId}",
|
|
1651
3445
|
dbBranchName: "{dbBranch}",
|
|
3446
|
+
region: "{region}",
|
|
1652
3447
|
tableName: __privateGet$4(this, _table),
|
|
1653
3448
|
recordId: id
|
|
1654
3449
|
},
|
|
1655
3450
|
queryParams: { columns },
|
|
1656
|
-
...
|
|
3451
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
1657
3452
|
});
|
|
1658
3453
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1659
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
3454
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
1660
3455
|
} catch (e) {
|
|
1661
3456
|
if (isObject(e) && e.status === 404) {
|
|
1662
3457
|
return null;
|
|
@@ -1667,48 +3462,142 @@ class RestRepository extends Query {
|
|
|
1667
3462
|
return null;
|
|
1668
3463
|
});
|
|
1669
3464
|
}
|
|
1670
|
-
async
|
|
3465
|
+
async readOrThrow(a, b) {
|
|
3466
|
+
return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
|
|
3467
|
+
const result = await this.read(a, b);
|
|
3468
|
+
if (Array.isArray(result)) {
|
|
3469
|
+
const missingIds = compact(
|
|
3470
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
|
3471
|
+
);
|
|
3472
|
+
if (missingIds.length > 0) {
|
|
3473
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
|
3474
|
+
}
|
|
3475
|
+
return result;
|
|
3476
|
+
}
|
|
3477
|
+
if (result === null) {
|
|
3478
|
+
const id = extractId(a) ?? "unknown";
|
|
3479
|
+
throw new Error(`Record with id ${id} not found`);
|
|
3480
|
+
}
|
|
3481
|
+
return result;
|
|
3482
|
+
});
|
|
3483
|
+
}
|
|
3484
|
+
async update(a, b, c, d) {
|
|
1671
3485
|
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
|
3486
|
+
const ifVersion = parseIfVersion(b, c, d);
|
|
1672
3487
|
if (Array.isArray(a)) {
|
|
1673
3488
|
if (a.length === 0)
|
|
1674
3489
|
return [];
|
|
1675
|
-
|
|
1676
|
-
|
|
3490
|
+
const existing = await this.read(a, ["id"]);
|
|
3491
|
+
const updates = a.filter((_item, index) => existing[index] !== null);
|
|
3492
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
|
|
3493
|
+
ifVersion,
|
|
3494
|
+
upsert: false
|
|
3495
|
+
});
|
|
3496
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
3497
|
+
const result = await this.read(a, columns);
|
|
3498
|
+
return result;
|
|
3499
|
+
}
|
|
3500
|
+
try {
|
|
3501
|
+
if (isString(a) && isObject(b)) {
|
|
3502
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
3503
|
+
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
|
1677
3504
|
}
|
|
3505
|
+
if (isObject(a) && isString(a.id)) {
|
|
3506
|
+
const columns = isStringArray(b) ? b : void 0;
|
|
3507
|
+
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
|
3508
|
+
}
|
|
3509
|
+
} catch (error) {
|
|
3510
|
+
if (error.status === 422)
|
|
3511
|
+
return null;
|
|
3512
|
+
throw error;
|
|
3513
|
+
}
|
|
3514
|
+
throw new Error("Invalid arguments for update method");
|
|
3515
|
+
});
|
|
3516
|
+
}
|
|
3517
|
+
async updateOrThrow(a, b, c, d) {
|
|
3518
|
+
return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
|
|
3519
|
+
const result = await this.update(a, b, c, d);
|
|
3520
|
+
if (Array.isArray(result)) {
|
|
3521
|
+
const missingIds = compact(
|
|
3522
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
|
3523
|
+
);
|
|
3524
|
+
if (missingIds.length > 0) {
|
|
3525
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
|
3526
|
+
}
|
|
3527
|
+
return result;
|
|
3528
|
+
}
|
|
3529
|
+
if (result === null) {
|
|
3530
|
+
const id = extractId(a) ?? "unknown";
|
|
3531
|
+
throw new Error(`Record with id ${id} not found`);
|
|
3532
|
+
}
|
|
3533
|
+
return result;
|
|
3534
|
+
});
|
|
3535
|
+
}
|
|
3536
|
+
async createOrUpdate(a, b, c, d) {
|
|
3537
|
+
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
|
3538
|
+
const ifVersion = parseIfVersion(b, c, d);
|
|
3539
|
+
if (Array.isArray(a)) {
|
|
3540
|
+
if (a.length === 0)
|
|
3541
|
+
return [];
|
|
3542
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
|
|
3543
|
+
ifVersion,
|
|
3544
|
+
upsert: true
|
|
3545
|
+
});
|
|
1678
3546
|
const columns = isStringArray(b) ? b : ["*"];
|
|
1679
|
-
|
|
3547
|
+
const result = await this.read(a, columns);
|
|
3548
|
+
return result;
|
|
1680
3549
|
}
|
|
1681
3550
|
if (isString(a) && isObject(b)) {
|
|
3551
|
+
if (a === "")
|
|
3552
|
+
throw new Error("The id can't be empty");
|
|
1682
3553
|
const columns = isStringArray(c) ? c : void 0;
|
|
1683
|
-
return __privateMethod$2(this,
|
|
3554
|
+
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
|
1684
3555
|
}
|
|
1685
3556
|
if (isObject(a) && isString(a.id)) {
|
|
1686
|
-
|
|
1687
|
-
|
|
3557
|
+
if (a.id === "")
|
|
3558
|
+
throw new Error("The id can't be empty");
|
|
3559
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
3560
|
+
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
|
1688
3561
|
}
|
|
1689
|
-
|
|
3562
|
+
if (!isDefined(a) && isObject(b)) {
|
|
3563
|
+
return await this.create(b, c);
|
|
3564
|
+
}
|
|
3565
|
+
if (isObject(a) && !isDefined(a.id)) {
|
|
3566
|
+
return await this.create(a, b);
|
|
3567
|
+
}
|
|
3568
|
+
throw new Error("Invalid arguments for createOrUpdate method");
|
|
1690
3569
|
});
|
|
1691
3570
|
}
|
|
1692
|
-
async
|
|
1693
|
-
return __privateGet$4(this, _trace).call(this, "
|
|
3571
|
+
async createOrReplace(a, b, c, d) {
|
|
3572
|
+
return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
|
|
3573
|
+
const ifVersion = parseIfVersion(b, c, d);
|
|
1694
3574
|
if (Array.isArray(a)) {
|
|
1695
3575
|
if (a.length === 0)
|
|
1696
3576
|
return [];
|
|
1697
|
-
|
|
1698
|
-
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
|
1699
|
-
}
|
|
3577
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
|
1700
3578
|
const columns = isStringArray(b) ? b : ["*"];
|
|
1701
|
-
|
|
3579
|
+
const result = await this.read(ids, columns);
|
|
3580
|
+
return result;
|
|
1702
3581
|
}
|
|
1703
3582
|
if (isString(a) && isObject(b)) {
|
|
3583
|
+
if (a === "")
|
|
3584
|
+
throw new Error("The id can't be empty");
|
|
1704
3585
|
const columns = isStringArray(c) ? c : void 0;
|
|
1705
|
-
return __privateMethod$2(this,
|
|
3586
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
|
1706
3587
|
}
|
|
1707
3588
|
if (isObject(a) && isString(a.id)) {
|
|
3589
|
+
if (a.id === "")
|
|
3590
|
+
throw new Error("The id can't be empty");
|
|
1708
3591
|
const columns = isStringArray(c) ? c : void 0;
|
|
1709
|
-
return __privateMethod$2(this,
|
|
3592
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
|
1710
3593
|
}
|
|
1711
|
-
|
|
3594
|
+
if (!isDefined(a) && isObject(b)) {
|
|
3595
|
+
return await this.create(b, c);
|
|
3596
|
+
}
|
|
3597
|
+
if (isObject(a) && !isDefined(a.id)) {
|
|
3598
|
+
return await this.create(a, b);
|
|
3599
|
+
}
|
|
3600
|
+
throw new Error("Invalid arguments for createOrReplace method");
|
|
1712
3601
|
});
|
|
1713
3602
|
}
|
|
1714
3603
|
async delete(a, b) {
|
|
@@ -1716,10 +3605,17 @@ class RestRepository extends Query {
|
|
|
1716
3605
|
if (Array.isArray(a)) {
|
|
1717
3606
|
if (a.length === 0)
|
|
1718
3607
|
return [];
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
3608
|
+
const ids = a.map((o) => {
|
|
3609
|
+
if (isString(o))
|
|
3610
|
+
return o;
|
|
3611
|
+
if (isString(o.id))
|
|
3612
|
+
return o.id;
|
|
3613
|
+
throw new Error("Invalid arguments for delete method");
|
|
3614
|
+
});
|
|
3615
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
3616
|
+
const result = await this.read(a, columns);
|
|
3617
|
+
await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
|
|
3618
|
+
return result;
|
|
1723
3619
|
}
|
|
1724
3620
|
if (isString(a)) {
|
|
1725
3621
|
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
|
|
@@ -1730,23 +3626,84 @@ class RestRepository extends Query {
|
|
|
1730
3626
|
throw new Error("Invalid arguments for delete method");
|
|
1731
3627
|
});
|
|
1732
3628
|
}
|
|
3629
|
+
async deleteOrThrow(a, b) {
|
|
3630
|
+
return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
|
|
3631
|
+
const result = await this.delete(a, b);
|
|
3632
|
+
if (Array.isArray(result)) {
|
|
3633
|
+
const missingIds = compact(
|
|
3634
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
|
3635
|
+
);
|
|
3636
|
+
if (missingIds.length > 0) {
|
|
3637
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
|
3638
|
+
}
|
|
3639
|
+
return result;
|
|
3640
|
+
} else if (result === null) {
|
|
3641
|
+
const id = extractId(a) ?? "unknown";
|
|
3642
|
+
throw new Error(`Record with id ${id} not found`);
|
|
3643
|
+
}
|
|
3644
|
+
return result;
|
|
3645
|
+
});
|
|
3646
|
+
}
|
|
1733
3647
|
async search(query, options = {}) {
|
|
1734
3648
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
|
1735
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1736
3649
|
const { records } = await searchTable({
|
|
1737
|
-
pathParams: {
|
|
3650
|
+
pathParams: {
|
|
3651
|
+
workspace: "{workspaceId}",
|
|
3652
|
+
dbBranchName: "{dbBranch}",
|
|
3653
|
+
region: "{region}",
|
|
3654
|
+
tableName: __privateGet$4(this, _table)
|
|
3655
|
+
},
|
|
1738
3656
|
body: {
|
|
1739
3657
|
query,
|
|
1740
3658
|
fuzziness: options.fuzziness,
|
|
1741
3659
|
prefix: options.prefix,
|
|
1742
3660
|
highlight: options.highlight,
|
|
1743
3661
|
filter: options.filter,
|
|
1744
|
-
boosters: options.boosters
|
|
3662
|
+
boosters: options.boosters,
|
|
3663
|
+
page: options.page,
|
|
3664
|
+
target: options.target
|
|
3665
|
+
},
|
|
3666
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3667
|
+
});
|
|
3668
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
3669
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
|
3670
|
+
});
|
|
3671
|
+
}
|
|
3672
|
+
async vectorSearch(column, query, options) {
|
|
3673
|
+
return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
|
|
3674
|
+
const { records } = await vectorSearchTable({
|
|
3675
|
+
pathParams: {
|
|
3676
|
+
workspace: "{workspaceId}",
|
|
3677
|
+
dbBranchName: "{dbBranch}",
|
|
3678
|
+
region: "{region}",
|
|
3679
|
+
tableName: __privateGet$4(this, _table)
|
|
1745
3680
|
},
|
|
1746
|
-
|
|
3681
|
+
body: {
|
|
3682
|
+
column,
|
|
3683
|
+
queryVector: query,
|
|
3684
|
+
similarityFunction: options?.similarityFunction,
|
|
3685
|
+
size: options?.size,
|
|
3686
|
+
filter: options?.filter
|
|
3687
|
+
},
|
|
3688
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
1747
3689
|
});
|
|
1748
3690
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1749
|
-
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
|
3691
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
|
3692
|
+
});
|
|
3693
|
+
}
|
|
3694
|
+
async aggregate(aggs, filter) {
|
|
3695
|
+
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
|
3696
|
+
const result = await aggregateTable({
|
|
3697
|
+
pathParams: {
|
|
3698
|
+
workspace: "{workspaceId}",
|
|
3699
|
+
dbBranchName: "{dbBranch}",
|
|
3700
|
+
region: "{region}",
|
|
3701
|
+
tableName: __privateGet$4(this, _table)
|
|
3702
|
+
},
|
|
3703
|
+
body: { aggs, filter },
|
|
3704
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3705
|
+
});
|
|
3706
|
+
return result;
|
|
1750
3707
|
});
|
|
1751
3708
|
}
|
|
1752
3709
|
async query(query) {
|
|
@@ -1755,24 +3712,88 @@ class RestRepository extends Query {
|
|
|
1755
3712
|
if (cacheQuery)
|
|
1756
3713
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
|
1757
3714
|
const data = query.getQueryOptions();
|
|
1758
|
-
const body = {
|
|
1759
|
-
filter: cleanFilter(data.filter),
|
|
1760
|
-
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
|
1761
|
-
page: data.pagination,
|
|
1762
|
-
columns: data.columns
|
|
1763
|
-
};
|
|
1764
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1765
3715
|
const { meta, records: objects } = await queryTable({
|
|
1766
|
-
pathParams: {
|
|
1767
|
-
|
|
1768
|
-
|
|
3716
|
+
pathParams: {
|
|
3717
|
+
workspace: "{workspaceId}",
|
|
3718
|
+
dbBranchName: "{dbBranch}",
|
|
3719
|
+
region: "{region}",
|
|
3720
|
+
tableName: __privateGet$4(this, _table)
|
|
3721
|
+
},
|
|
3722
|
+
body: {
|
|
3723
|
+
filter: cleanFilter(data.filter),
|
|
3724
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
|
3725
|
+
page: data.pagination,
|
|
3726
|
+
columns: data.columns ?? ["*"],
|
|
3727
|
+
consistency: data.consistency
|
|
3728
|
+
},
|
|
3729
|
+
fetchOptions: data.fetchOptions,
|
|
3730
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
1769
3731
|
});
|
|
1770
3732
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1771
|
-
const records = objects.map(
|
|
3733
|
+
const records = objects.map(
|
|
3734
|
+
(record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
|
|
3735
|
+
);
|
|
1772
3736
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
|
1773
3737
|
return new Page(query, meta, records);
|
|
1774
3738
|
});
|
|
1775
3739
|
}
|
|
3740
|
+
async summarizeTable(query, summaries, summariesFilter) {
|
|
3741
|
+
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
|
3742
|
+
const data = query.getQueryOptions();
|
|
3743
|
+
const result = await summarizeTable({
|
|
3744
|
+
pathParams: {
|
|
3745
|
+
workspace: "{workspaceId}",
|
|
3746
|
+
dbBranchName: "{dbBranch}",
|
|
3747
|
+
region: "{region}",
|
|
3748
|
+
tableName: __privateGet$4(this, _table)
|
|
3749
|
+
},
|
|
3750
|
+
body: {
|
|
3751
|
+
filter: cleanFilter(data.filter),
|
|
3752
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
|
3753
|
+
columns: data.columns,
|
|
3754
|
+
consistency: data.consistency,
|
|
3755
|
+
page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
|
|
3756
|
+
summaries,
|
|
3757
|
+
summariesFilter
|
|
3758
|
+
},
|
|
3759
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3760
|
+
});
|
|
3761
|
+
return result;
|
|
3762
|
+
});
|
|
3763
|
+
}
|
|
3764
|
+
ask(question, options) {
|
|
3765
|
+
const questionParam = options?.sessionId ? { message: question } : { question };
|
|
3766
|
+
const params = {
|
|
3767
|
+
pathParams: {
|
|
3768
|
+
workspace: "{workspaceId}",
|
|
3769
|
+
dbBranchName: "{dbBranch}",
|
|
3770
|
+
region: "{region}",
|
|
3771
|
+
tableName: __privateGet$4(this, _table),
|
|
3772
|
+
sessionId: options?.sessionId
|
|
3773
|
+
},
|
|
3774
|
+
body: {
|
|
3775
|
+
...questionParam,
|
|
3776
|
+
rules: options?.rules,
|
|
3777
|
+
searchType: options?.searchType,
|
|
3778
|
+
search: options?.searchType === "keyword" ? options?.search : void 0,
|
|
3779
|
+
vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
|
|
3780
|
+
},
|
|
3781
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3782
|
+
};
|
|
3783
|
+
if (options?.onMessage) {
|
|
3784
|
+
fetchSSERequest({
|
|
3785
|
+
endpoint: "dataPlane",
|
|
3786
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
|
|
3787
|
+
method: "POST",
|
|
3788
|
+
onMessage: (message) => {
|
|
3789
|
+
options.onMessage?.({ answer: message.text, records: message.records });
|
|
3790
|
+
},
|
|
3791
|
+
...params
|
|
3792
|
+
});
|
|
3793
|
+
} else {
|
|
3794
|
+
return askTableSession(params);
|
|
3795
|
+
}
|
|
3796
|
+
}
|
|
1776
3797
|
}
|
|
1777
3798
|
_table = new WeakMap();
|
|
1778
3799
|
_getFetchProps = new WeakMap();
|
|
@@ -1782,68 +3803,89 @@ _schemaTables$2 = new WeakMap();
|
|
|
1782
3803
|
_trace = new WeakMap();
|
|
1783
3804
|
_insertRecordWithoutId = new WeakSet();
|
|
1784
3805
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1785
|
-
const
|
|
1786
|
-
const record = transformObjectLinks(object);
|
|
3806
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
|
1787
3807
|
const response = await insertRecord({
|
|
1788
3808
|
pathParams: {
|
|
1789
3809
|
workspace: "{workspaceId}",
|
|
1790
3810
|
dbBranchName: "{dbBranch}",
|
|
3811
|
+
region: "{region}",
|
|
1791
3812
|
tableName: __privateGet$4(this, _table)
|
|
1792
3813
|
},
|
|
1793
3814
|
queryParams: { columns },
|
|
1794
3815
|
body: record,
|
|
1795
|
-
...
|
|
3816
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
1796
3817
|
});
|
|
1797
3818
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1798
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
3819
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
1799
3820
|
};
|
|
1800
3821
|
_insertRecordWithId = new WeakSet();
|
|
1801
|
-
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
|
1802
|
-
|
|
1803
|
-
|
|
3822
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
|
3823
|
+
if (!recordId)
|
|
3824
|
+
return null;
|
|
3825
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
|
1804
3826
|
const response = await insertRecordWithID({
|
|
1805
3827
|
pathParams: {
|
|
1806
3828
|
workspace: "{workspaceId}",
|
|
1807
3829
|
dbBranchName: "{dbBranch}",
|
|
3830
|
+
region: "{region}",
|
|
1808
3831
|
tableName: __privateGet$4(this, _table),
|
|
1809
3832
|
recordId
|
|
1810
3833
|
},
|
|
1811
3834
|
body: record,
|
|
1812
|
-
queryParams: { createOnly
|
|
1813
|
-
...
|
|
3835
|
+
queryParams: { createOnly, columns, ifVersion },
|
|
3836
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
1814
3837
|
});
|
|
1815
3838
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1816
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1817
|
-
};
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
const
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
|
1824
|
-
queryParams: { columns },
|
|
1825
|
-
body: { records },
|
|
1826
|
-
...fetchProps
|
|
3839
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
3840
|
+
};
|
|
3841
|
+
_insertRecords = new WeakSet();
|
|
3842
|
+
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
|
3843
|
+
const operations = await promiseMap(objects, async (object) => {
|
|
3844
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
|
3845
|
+
return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
|
|
1827
3846
|
});
|
|
1828
|
-
|
|
1829
|
-
|
|
3847
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
|
3848
|
+
const ids = [];
|
|
3849
|
+
for (const operations2 of chunkedOperations) {
|
|
3850
|
+
const { results } = await branchTransaction({
|
|
3851
|
+
pathParams: {
|
|
3852
|
+
workspace: "{workspaceId}",
|
|
3853
|
+
dbBranchName: "{dbBranch}",
|
|
3854
|
+
region: "{region}"
|
|
3855
|
+
},
|
|
3856
|
+
body: { operations: operations2 },
|
|
3857
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3858
|
+
});
|
|
3859
|
+
for (const result of results) {
|
|
3860
|
+
if (result.operation === "insert") {
|
|
3861
|
+
ids.push(result.id);
|
|
3862
|
+
} else {
|
|
3863
|
+
ids.push(null);
|
|
3864
|
+
}
|
|
3865
|
+
}
|
|
1830
3866
|
}
|
|
1831
|
-
|
|
1832
|
-
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
|
3867
|
+
return ids;
|
|
1833
3868
|
};
|
|
1834
3869
|
_updateRecordWithID = new WeakSet();
|
|
1835
|
-
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
1836
|
-
|
|
1837
|
-
|
|
3870
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
|
3871
|
+
if (!recordId)
|
|
3872
|
+
return null;
|
|
3873
|
+
const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
|
1838
3874
|
try {
|
|
1839
3875
|
const response = await updateRecordWithID({
|
|
1840
|
-
pathParams: {
|
|
1841
|
-
|
|
3876
|
+
pathParams: {
|
|
3877
|
+
workspace: "{workspaceId}",
|
|
3878
|
+
dbBranchName: "{dbBranch}",
|
|
3879
|
+
region: "{region}",
|
|
3880
|
+
tableName: __privateGet$4(this, _table),
|
|
3881
|
+
recordId
|
|
3882
|
+
},
|
|
3883
|
+
queryParams: { columns, ifVersion },
|
|
1842
3884
|
body: record,
|
|
1843
|
-
...
|
|
3885
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
1844
3886
|
});
|
|
1845
3887
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1846
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
3888
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
1847
3889
|
} catch (e) {
|
|
1848
3890
|
if (isObject(e) && e.status === 404) {
|
|
1849
3891
|
return null;
|
|
@@ -1851,29 +3893,71 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
|
1851
3893
|
throw e;
|
|
1852
3894
|
}
|
|
1853
3895
|
};
|
|
3896
|
+
_updateRecords = new WeakSet();
|
|
3897
|
+
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
|
3898
|
+
const operations = await promiseMap(objects, async ({ id, ...object }) => {
|
|
3899
|
+
const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
|
3900
|
+
return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
|
|
3901
|
+
});
|
|
3902
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
|
3903
|
+
const ids = [];
|
|
3904
|
+
for (const operations2 of chunkedOperations) {
|
|
3905
|
+
const { results } = await branchTransaction({
|
|
3906
|
+
pathParams: {
|
|
3907
|
+
workspace: "{workspaceId}",
|
|
3908
|
+
dbBranchName: "{dbBranch}",
|
|
3909
|
+
region: "{region}"
|
|
3910
|
+
},
|
|
3911
|
+
body: { operations: operations2 },
|
|
3912
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3913
|
+
});
|
|
3914
|
+
for (const result of results) {
|
|
3915
|
+
if (result.operation === "update") {
|
|
3916
|
+
ids.push(result.id);
|
|
3917
|
+
} else {
|
|
3918
|
+
ids.push(null);
|
|
3919
|
+
}
|
|
3920
|
+
}
|
|
3921
|
+
}
|
|
3922
|
+
return ids;
|
|
3923
|
+
};
|
|
1854
3924
|
_upsertRecordWithID = new WeakSet();
|
|
1855
|
-
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
1856
|
-
|
|
3925
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
|
3926
|
+
if (!recordId)
|
|
3927
|
+
return null;
|
|
1857
3928
|
const response = await upsertRecordWithID({
|
|
1858
|
-
pathParams: {
|
|
1859
|
-
|
|
3929
|
+
pathParams: {
|
|
3930
|
+
workspace: "{workspaceId}",
|
|
3931
|
+
dbBranchName: "{dbBranch}",
|
|
3932
|
+
region: "{region}",
|
|
3933
|
+
tableName: __privateGet$4(this, _table),
|
|
3934
|
+
recordId
|
|
3935
|
+
},
|
|
3936
|
+
queryParams: { columns, ifVersion },
|
|
1860
3937
|
body: object,
|
|
1861
|
-
...
|
|
3938
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
1862
3939
|
});
|
|
1863
3940
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1864
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
3941
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
1865
3942
|
};
|
|
1866
3943
|
_deleteRecord = new WeakSet();
|
|
1867
3944
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
1868
|
-
|
|
3945
|
+
if (!recordId)
|
|
3946
|
+
return null;
|
|
1869
3947
|
try {
|
|
1870
3948
|
const response = await deleteRecord({
|
|
1871
|
-
pathParams: {
|
|
3949
|
+
pathParams: {
|
|
3950
|
+
workspace: "{workspaceId}",
|
|
3951
|
+
dbBranchName: "{dbBranch}",
|
|
3952
|
+
region: "{region}",
|
|
3953
|
+
tableName: __privateGet$4(this, _table),
|
|
3954
|
+
recordId
|
|
3955
|
+
},
|
|
1872
3956
|
queryParams: { columns },
|
|
1873
|
-
...
|
|
3957
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
1874
3958
|
});
|
|
1875
3959
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1876
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
3960
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
1877
3961
|
} catch (e) {
|
|
1878
3962
|
if (isObject(e) && e.status === 404) {
|
|
1879
3963
|
return null;
|
|
@@ -1881,17 +3965,36 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
|
1881
3965
|
throw e;
|
|
1882
3966
|
}
|
|
1883
3967
|
};
|
|
3968
|
+
_deleteRecords = new WeakSet();
|
|
3969
|
+
deleteRecords_fn = async function(recordIds) {
|
|
3970
|
+
const chunkedOperations = chunk(
|
|
3971
|
+
compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
|
3972
|
+
BULK_OPERATION_MAX_SIZE
|
|
3973
|
+
);
|
|
3974
|
+
for (const operations of chunkedOperations) {
|
|
3975
|
+
await branchTransaction({
|
|
3976
|
+
pathParams: {
|
|
3977
|
+
workspace: "{workspaceId}",
|
|
3978
|
+
dbBranchName: "{dbBranch}",
|
|
3979
|
+
region: "{region}"
|
|
3980
|
+
},
|
|
3981
|
+
body: { operations },
|
|
3982
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3983
|
+
});
|
|
3984
|
+
}
|
|
3985
|
+
};
|
|
1884
3986
|
_setCacheQuery = new WeakSet();
|
|
1885
3987
|
setCacheQuery_fn = async function(query, meta, records) {
|
|
1886
|
-
await __privateGet$4(this, _cache)
|
|
3988
|
+
await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
|
|
1887
3989
|
};
|
|
1888
3990
|
_getCacheQuery = new WeakSet();
|
|
1889
3991
|
getCacheQuery_fn = async function(query) {
|
|
1890
3992
|
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
|
1891
|
-
const result = await __privateGet$4(this, _cache)
|
|
3993
|
+
const result = await __privateGet$4(this, _cache)?.get(key);
|
|
1892
3994
|
if (!result)
|
|
1893
3995
|
return null;
|
|
1894
|
-
const
|
|
3996
|
+
const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
|
|
3997
|
+
const { cache: ttl = defaultTTL } = query.getQueryOptions();
|
|
1895
3998
|
if (ttl < 0)
|
|
1896
3999
|
return null;
|
|
1897
4000
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
|
@@ -1901,37 +4004,70 @@ _getSchemaTables$1 = new WeakSet();
|
|
|
1901
4004
|
getSchemaTables_fn$1 = async function() {
|
|
1902
4005
|
if (__privateGet$4(this, _schemaTables$2))
|
|
1903
4006
|
return __privateGet$4(this, _schemaTables$2);
|
|
1904
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1905
4007
|
const { schema } = await getBranchDetails({
|
|
1906
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
1907
|
-
...
|
|
4008
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
4009
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
1908
4010
|
});
|
|
1909
4011
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
|
1910
4012
|
return schema.tables;
|
|
1911
4013
|
};
|
|
1912
|
-
|
|
4014
|
+
_transformObjectToApi = new WeakSet();
|
|
4015
|
+
transformObjectToApi_fn = async function(object) {
|
|
4016
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
4017
|
+
const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
|
|
4018
|
+
if (!schema)
|
|
4019
|
+
throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
|
|
4020
|
+
const result = {};
|
|
4021
|
+
for (const [key, value] of Object.entries(object)) {
|
|
4022
|
+
if (key === "xata")
|
|
4023
|
+
continue;
|
|
4024
|
+
const type = schema.columns.find((column) => column.name === key)?.type;
|
|
4025
|
+
switch (type) {
|
|
4026
|
+
case "link": {
|
|
4027
|
+
result[key] = isIdentifiable(value) ? value.id : value;
|
|
4028
|
+
break;
|
|
4029
|
+
}
|
|
4030
|
+
case "datetime": {
|
|
4031
|
+
result[key] = value instanceof Date ? value.toISOString() : value;
|
|
4032
|
+
break;
|
|
4033
|
+
}
|
|
4034
|
+
case `file`:
|
|
4035
|
+
result[key] = await parseInputFileEntry(value);
|
|
4036
|
+
break;
|
|
4037
|
+
case "file[]":
|
|
4038
|
+
result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
|
|
4039
|
+
break;
|
|
4040
|
+
default:
|
|
4041
|
+
result[key] = value;
|
|
4042
|
+
}
|
|
4043
|
+
}
|
|
4044
|
+
return result;
|
|
4045
|
+
};
|
|
4046
|
+
const removeLinksFromObject = (object) => {
|
|
1913
4047
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
|
1914
4048
|
if (key === "xata")
|
|
1915
4049
|
return acc;
|
|
1916
4050
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
|
1917
4051
|
}, {});
|
|
1918
4052
|
};
|
|
1919
|
-
const initObject = (db, schemaTables, table, object) => {
|
|
1920
|
-
const
|
|
4053
|
+
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4054
|
+
const data = {};
|
|
1921
4055
|
const { xata, ...rest } = object ?? {};
|
|
1922
|
-
Object.assign(
|
|
4056
|
+
Object.assign(data, rest);
|
|
1923
4057
|
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
|
1924
4058
|
if (!columns)
|
|
1925
4059
|
console.error(`Table ${table} not found in schema`);
|
|
1926
4060
|
for (const column of columns ?? []) {
|
|
1927
|
-
|
|
4061
|
+
if (!isValidColumn(selectedColumns, column))
|
|
4062
|
+
continue;
|
|
4063
|
+
const value = data[column.name];
|
|
1928
4064
|
switch (column.type) {
|
|
1929
4065
|
case "datetime": {
|
|
1930
|
-
const date = value !== void 0 ? new Date(value) :
|
|
1931
|
-
if (date && isNaN(date.getTime())) {
|
|
4066
|
+
const date = value !== void 0 ? new Date(value) : null;
|
|
4067
|
+
if (date !== null && isNaN(date.getTime())) {
|
|
1932
4068
|
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
|
1933
|
-
} else
|
|
1934
|
-
|
|
4069
|
+
} else {
|
|
4070
|
+
data[column.name] = date;
|
|
1935
4071
|
}
|
|
1936
4072
|
break;
|
|
1937
4073
|
}
|
|
@@ -1940,33 +4076,71 @@ const initObject = (db, schemaTables, table, object) => {
|
|
|
1940
4076
|
if (!linkTable) {
|
|
1941
4077
|
console.error(`Failed to parse link for field ${column.name}`);
|
|
1942
4078
|
} else if (isObject(value)) {
|
|
1943
|
-
|
|
4079
|
+
const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
|
|
4080
|
+
if (item === column.name) {
|
|
4081
|
+
return [...acc, "*"];
|
|
4082
|
+
}
|
|
4083
|
+
if (item.startsWith(`${column.name}.`)) {
|
|
4084
|
+
const [, ...path] = item.split(".");
|
|
4085
|
+
return [...acc, path.join(".")];
|
|
4086
|
+
}
|
|
4087
|
+
return acc;
|
|
4088
|
+
}, []);
|
|
4089
|
+
data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
|
|
4090
|
+
} else {
|
|
4091
|
+
data[column.name] = null;
|
|
1944
4092
|
}
|
|
1945
4093
|
break;
|
|
1946
4094
|
}
|
|
4095
|
+
case "file":
|
|
4096
|
+
data[column.name] = isDefined(value) ? new XataFile(value) : null;
|
|
4097
|
+
break;
|
|
4098
|
+
case "file[]":
|
|
4099
|
+
data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
|
|
4100
|
+
break;
|
|
4101
|
+
default:
|
|
4102
|
+
data[column.name] = value ?? null;
|
|
4103
|
+
if (column.notNull === true && value === null) {
|
|
4104
|
+
console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
|
|
4105
|
+
}
|
|
4106
|
+
break;
|
|
1947
4107
|
}
|
|
1948
4108
|
}
|
|
1949
|
-
|
|
1950
|
-
|
|
4109
|
+
const record = { ...data };
|
|
4110
|
+
const serializable = { xata, ...removeLinksFromObject(data) };
|
|
4111
|
+
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
|
4112
|
+
record.read = function(columns2) {
|
|
4113
|
+
return db[table].read(record["id"], columns2);
|
|
4114
|
+
};
|
|
4115
|
+
record.update = function(data2, b, c) {
|
|
4116
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
|
4117
|
+
const ifVersion = parseIfVersion(b, c);
|
|
4118
|
+
return db[table].update(record["id"], data2, columns2, { ifVersion });
|
|
4119
|
+
};
|
|
4120
|
+
record.replace = function(data2, b, c) {
|
|
4121
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
|
4122
|
+
const ifVersion = parseIfVersion(b, c);
|
|
4123
|
+
return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
|
|
4124
|
+
};
|
|
4125
|
+
record.delete = function() {
|
|
4126
|
+
return db[table].delete(record["id"]);
|
|
1951
4127
|
};
|
|
1952
|
-
|
|
1953
|
-
|
|
4128
|
+
record.xata = Object.freeze(metadata);
|
|
4129
|
+
record.getMetadata = function() {
|
|
4130
|
+
return record.xata;
|
|
1954
4131
|
};
|
|
1955
|
-
|
|
1956
|
-
return
|
|
4132
|
+
record.toSerializable = function() {
|
|
4133
|
+
return JSON.parse(JSON.stringify(serializable));
|
|
1957
4134
|
};
|
|
1958
|
-
|
|
1959
|
-
return
|
|
4135
|
+
record.toString = function() {
|
|
4136
|
+
return JSON.stringify(serializable);
|
|
1960
4137
|
};
|
|
1961
|
-
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
|
1962
|
-
Object.defineProperty(
|
|
4138
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
|
4139
|
+
Object.defineProperty(record, prop, { enumerable: false });
|
|
1963
4140
|
}
|
|
1964
|
-
Object.freeze(
|
|
1965
|
-
return
|
|
4141
|
+
Object.freeze(record);
|
|
4142
|
+
return record;
|
|
1966
4143
|
};
|
|
1967
|
-
function isResponseWithRecords(value) {
|
|
1968
|
-
return isObject(value) && Array.isArray(value.records);
|
|
1969
|
-
}
|
|
1970
4144
|
function extractId(value) {
|
|
1971
4145
|
if (isString(value))
|
|
1972
4146
|
return value;
|
|
@@ -1974,13 +4148,26 @@ function extractId(value) {
|
|
|
1974
4148
|
return value.id;
|
|
1975
4149
|
return void 0;
|
|
1976
4150
|
}
|
|
1977
|
-
function
|
|
1978
|
-
if (
|
|
1979
|
-
return
|
|
1980
|
-
|
|
1981
|
-
|
|
4151
|
+
function isValidColumn(columns, column) {
|
|
4152
|
+
if (columns.includes("*"))
|
|
4153
|
+
return true;
|
|
4154
|
+
return columns.filter((item) => item.startsWith(column.name)).length > 0;
|
|
4155
|
+
}
|
|
4156
|
+
function parseIfVersion(...args) {
|
|
4157
|
+
for (const arg of args) {
|
|
4158
|
+
if (isObject(arg) && isNumber(arg.ifVersion)) {
|
|
4159
|
+
return arg.ifVersion;
|
|
4160
|
+
}
|
|
4161
|
+
}
|
|
4162
|
+
return void 0;
|
|
1982
4163
|
}
|
|
1983
4164
|
|
|
4165
|
+
var __defProp$3 = Object.defineProperty;
|
|
4166
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4167
|
+
var __publicField$3 = (obj, key, value) => {
|
|
4168
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4169
|
+
return value;
|
|
4170
|
+
};
|
|
1984
4171
|
var __accessCheck$3 = (obj, member, msg) => {
|
|
1985
4172
|
if (!member.has(obj))
|
|
1986
4173
|
throw TypeError("Cannot " + msg);
|
|
@@ -2003,6 +4190,8 @@ var _map;
|
|
|
2003
4190
|
class SimpleCache {
|
|
2004
4191
|
constructor(options = {}) {
|
|
2005
4192
|
__privateAdd$3(this, _map, void 0);
|
|
4193
|
+
__publicField$3(this, "capacity");
|
|
4194
|
+
__publicField$3(this, "defaultQueryTTL");
|
|
2006
4195
|
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
|
2007
4196
|
this.capacity = options.max ?? 500;
|
|
2008
4197
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
|
@@ -2138,23 +4327,23 @@ class SearchPlugin extends XataPlugin {
|
|
|
2138
4327
|
__privateAdd$1(this, _schemaTables, void 0);
|
|
2139
4328
|
__privateSet$1(this, _schemaTables, schemaTables);
|
|
2140
4329
|
}
|
|
2141
|
-
build(
|
|
4330
|
+
build(pluginOptions) {
|
|
2142
4331
|
return {
|
|
2143
4332
|
all: async (query, options = {}) => {
|
|
2144
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
|
2145
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
|
4333
|
+
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
|
4334
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
|
2146
4335
|
return records.map((record) => {
|
|
2147
4336
|
const { table = "orphan" } = record.xata;
|
|
2148
|
-
return { table, record: initObject(this.db, schemaTables, table, record) };
|
|
4337
|
+
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
|
2149
4338
|
});
|
|
2150
4339
|
},
|
|
2151
4340
|
byTable: async (query, options = {}) => {
|
|
2152
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
|
2153
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
|
4341
|
+
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
|
4342
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
|
2154
4343
|
return records.reduce((acc, record) => {
|
|
2155
4344
|
const { table = "orphan" } = record.xata;
|
|
2156
4345
|
const items = acc[table] ?? [];
|
|
2157
|
-
const item = initObject(this.db, schemaTables, table, record);
|
|
4346
|
+
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
|
2158
4347
|
return { ...acc, [table]: [...items, item] };
|
|
2159
4348
|
}, {});
|
|
2160
4349
|
}
|
|
@@ -2163,111 +4352,49 @@ class SearchPlugin extends XataPlugin {
|
|
|
2163
4352
|
}
|
|
2164
4353
|
_schemaTables = new WeakMap();
|
|
2165
4354
|
_search = new WeakSet();
|
|
2166
|
-
search_fn = async function(query, options,
|
|
2167
|
-
const
|
|
2168
|
-
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
|
4355
|
+
search_fn = async function(query, options, pluginOptions) {
|
|
4356
|
+
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
|
2169
4357
|
const { records } = await searchBranch({
|
|
2170
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
2171
|
-
|
|
2172
|
-
|
|
4358
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
4359
|
+
// @ts-ignore https://github.com/xataio/client-ts/issues/313
|
|
4360
|
+
body: { tables, query, fuzziness, prefix, highlight, page },
|
|
4361
|
+
...pluginOptions
|
|
2173
4362
|
});
|
|
2174
4363
|
return records;
|
|
2175
4364
|
};
|
|
2176
4365
|
_getSchemaTables = new WeakSet();
|
|
2177
|
-
getSchemaTables_fn = async function(
|
|
4366
|
+
getSchemaTables_fn = async function(pluginOptions) {
|
|
2178
4367
|
if (__privateGet$1(this, _schemaTables))
|
|
2179
4368
|
return __privateGet$1(this, _schemaTables);
|
|
2180
|
-
const fetchProps = await getFetchProps();
|
|
2181
4369
|
const { schema } = await getBranchDetails({
|
|
2182
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
2183
|
-
...
|
|
4370
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
4371
|
+
...pluginOptions
|
|
2184
4372
|
});
|
|
2185
4373
|
__privateSet$1(this, _schemaTables, schema.tables);
|
|
2186
4374
|
return schema.tables;
|
|
2187
4375
|
};
|
|
2188
4376
|
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
const gitBranch = envBranch || await getGitBranch();
|
|
2202
|
-
return resolveXataBranch(gitBranch, options);
|
|
2203
|
-
}
|
|
2204
|
-
async function getCurrentBranchDetails(options) {
|
|
2205
|
-
const branch = await getCurrentBranchName(options);
|
|
2206
|
-
return getDatabaseBranch(branch, options);
|
|
2207
|
-
}
|
|
2208
|
-
async function resolveXataBranch(gitBranch, options) {
|
|
2209
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
2210
|
-
const apiKey = options?.apiKey || getAPIKey();
|
|
2211
|
-
if (!databaseURL)
|
|
2212
|
-
throw new Error(
|
|
2213
|
-
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
|
2214
|
-
);
|
|
2215
|
-
if (!apiKey)
|
|
2216
|
-
throw new Error(
|
|
2217
|
-
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
|
2218
|
-
);
|
|
2219
|
-
const [protocol, , host, , dbName] = databaseURL.split("/");
|
|
2220
|
-
const [workspace] = host.split(".");
|
|
2221
|
-
const { fallbackBranch } = getEnvironment();
|
|
2222
|
-
const { branch } = await resolveBranch({
|
|
2223
|
-
apiKey,
|
|
2224
|
-
apiUrl: databaseURL,
|
|
2225
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
|
2226
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
|
2227
|
-
pathParams: { dbName, workspace },
|
|
2228
|
-
queryParams: { gitBranch, fallbackBranch },
|
|
2229
|
-
trace: defaultTrace
|
|
2230
|
-
});
|
|
2231
|
-
return branch;
|
|
2232
|
-
}
|
|
2233
|
-
async function getDatabaseBranch(branch, options) {
|
|
2234
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
2235
|
-
const apiKey = options?.apiKey || getAPIKey();
|
|
2236
|
-
if (!databaseURL)
|
|
2237
|
-
throw new Error(
|
|
2238
|
-
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
|
2239
|
-
);
|
|
2240
|
-
if (!apiKey)
|
|
2241
|
-
throw new Error(
|
|
2242
|
-
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
|
2243
|
-
);
|
|
2244
|
-
const [protocol, , host, , database] = databaseURL.split("/");
|
|
2245
|
-
const [workspace] = host.split(".");
|
|
2246
|
-
const dbBranchName = `${database}:${branch}`;
|
|
2247
|
-
try {
|
|
2248
|
-
return await getBranchDetails({
|
|
2249
|
-
apiKey,
|
|
2250
|
-
apiUrl: databaseURL,
|
|
2251
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
|
2252
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
|
2253
|
-
pathParams: { dbBranchName, workspace },
|
|
2254
|
-
trace: defaultTrace
|
|
2255
|
-
});
|
|
2256
|
-
} catch (err) {
|
|
2257
|
-
if (isObject(err) && err.status === 404)
|
|
2258
|
-
return null;
|
|
2259
|
-
throw err;
|
|
2260
|
-
}
|
|
2261
|
-
}
|
|
2262
|
-
function getDatabaseURL() {
|
|
2263
|
-
try {
|
|
2264
|
-
const { databaseURL } = getEnvironment();
|
|
2265
|
-
return databaseURL;
|
|
2266
|
-
} catch (err) {
|
|
2267
|
-
return void 0;
|
|
4377
|
+
class TransactionPlugin extends XataPlugin {
|
|
4378
|
+
build(pluginOptions) {
|
|
4379
|
+
return {
|
|
4380
|
+
run: async (operations) => {
|
|
4381
|
+
const response = await branchTransaction({
|
|
4382
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
4383
|
+
body: { operations },
|
|
4384
|
+
...pluginOptions
|
|
4385
|
+
});
|
|
4386
|
+
return response;
|
|
4387
|
+
}
|
|
4388
|
+
};
|
|
2268
4389
|
}
|
|
2269
4390
|
}
|
|
2270
4391
|
|
|
4392
|
+
var __defProp$2 = Object.defineProperty;
|
|
4393
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4394
|
+
var __publicField$2 = (obj, key, value) => {
|
|
4395
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4396
|
+
return value;
|
|
4397
|
+
};
|
|
2271
4398
|
var __accessCheck = (obj, member, msg) => {
|
|
2272
4399
|
if (!member.has(obj))
|
|
2273
4400
|
throw TypeError("Cannot " + msg);
|
|
@@ -2291,98 +4418,138 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2291
4418
|
return method;
|
|
2292
4419
|
};
|
|
2293
4420
|
const buildClient = (plugins) => {
|
|
2294
|
-
var
|
|
4421
|
+
var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
|
|
2295
4422
|
return _a = class {
|
|
2296
4423
|
constructor(options = {}, schemaTables) {
|
|
2297
4424
|
__privateAdd(this, _parseOptions);
|
|
2298
4425
|
__privateAdd(this, _getFetchProps);
|
|
2299
|
-
__privateAdd(this, _evaluateBranch);
|
|
2300
|
-
__privateAdd(this, _branch, void 0);
|
|
2301
4426
|
__privateAdd(this, _options, void 0);
|
|
4427
|
+
__publicField$2(this, "db");
|
|
4428
|
+
__publicField$2(this, "search");
|
|
4429
|
+
__publicField$2(this, "transactions");
|
|
4430
|
+
__publicField$2(this, "files");
|
|
2302
4431
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
|
2303
4432
|
__privateSet(this, _options, safeOptions);
|
|
2304
4433
|
const pluginOptions = {
|
|
2305
|
-
|
|
4434
|
+
...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
|
2306
4435
|
cache: safeOptions.cache,
|
|
2307
|
-
|
|
4436
|
+
host: safeOptions.host
|
|
2308
4437
|
};
|
|
2309
4438
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
|
2310
4439
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
|
4440
|
+
const transactions = new TransactionPlugin().build(pluginOptions);
|
|
4441
|
+
const files = new FilesPlugin().build(pluginOptions);
|
|
2311
4442
|
this.db = db;
|
|
2312
4443
|
this.search = search;
|
|
4444
|
+
this.transactions = transactions;
|
|
4445
|
+
this.files = files;
|
|
2313
4446
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
|
2314
4447
|
if (namespace === void 0)
|
|
2315
4448
|
continue;
|
|
2316
|
-
|
|
2317
|
-
if (result instanceof Promise) {
|
|
2318
|
-
void result.then((namespace2) => {
|
|
2319
|
-
this[key] = namespace2;
|
|
2320
|
-
});
|
|
2321
|
-
} else {
|
|
2322
|
-
this[key] = result;
|
|
2323
|
-
}
|
|
4449
|
+
this[key] = namespace.build(pluginOptions);
|
|
2324
4450
|
}
|
|
2325
4451
|
}
|
|
2326
4452
|
async getConfig() {
|
|
2327
4453
|
const databaseURL = __privateGet(this, _options).databaseURL;
|
|
2328
|
-
const branch =
|
|
4454
|
+
const branch = __privateGet(this, _options).branch;
|
|
2329
4455
|
return { databaseURL, branch };
|
|
2330
4456
|
}
|
|
2331
|
-
},
|
|
4457
|
+
}, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
|
4458
|
+
const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
|
|
4459
|
+
const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
|
|
4460
|
+
if (isBrowser && !enableBrowser) {
|
|
4461
|
+
throw new Error(
|
|
4462
|
+
"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."
|
|
4463
|
+
);
|
|
4464
|
+
}
|
|
2332
4465
|
const fetch = getFetchImplementation(options?.fetch);
|
|
2333
4466
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
2334
4467
|
const apiKey = options?.apiKey || getAPIKey();
|
|
2335
4468
|
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
|
2336
4469
|
const trace = options?.trace ?? defaultTrace;
|
|
2337
|
-
const
|
|
4470
|
+
const clientName = options?.clientName;
|
|
4471
|
+
const host = options?.host ?? "production";
|
|
4472
|
+
const xataAgentExtra = options?.xataAgentExtra;
|
|
2338
4473
|
if (!apiKey) {
|
|
2339
4474
|
throw new Error("Option apiKey is required");
|
|
2340
4475
|
}
|
|
2341
4476
|
if (!databaseURL) {
|
|
2342
4477
|
throw new Error("Option databaseURL is required");
|
|
2343
4478
|
}
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
const
|
|
2347
|
-
if (
|
|
2348
|
-
|
|
4479
|
+
const envBranch = getBranch();
|
|
4480
|
+
const previewBranch = getPreviewBranch();
|
|
4481
|
+
const branch = options?.branch || previewBranch || envBranch || "main";
|
|
4482
|
+
if (!!previewBranch && branch !== previewBranch) {
|
|
4483
|
+
console.warn(
|
|
4484
|
+
`Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
|
|
4485
|
+
);
|
|
4486
|
+
} else if (!!envBranch && branch !== envBranch) {
|
|
4487
|
+
console.warn(
|
|
4488
|
+
`Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
|
4489
|
+
);
|
|
4490
|
+
} else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
|
|
4491
|
+
console.warn(
|
|
4492
|
+
`Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
|
4493
|
+
);
|
|
4494
|
+
} else if (!previewBranch && !envBranch && options?.branch === void 0) {
|
|
4495
|
+
console.warn(
|
|
4496
|
+
`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.`
|
|
4497
|
+
);
|
|
4498
|
+
}
|
|
4499
|
+
return {
|
|
4500
|
+
fetch,
|
|
4501
|
+
databaseURL,
|
|
4502
|
+
apiKey,
|
|
4503
|
+
branch,
|
|
4504
|
+
cache,
|
|
4505
|
+
trace,
|
|
4506
|
+
host,
|
|
4507
|
+
clientID: generateUUID(),
|
|
4508
|
+
enableBrowser,
|
|
4509
|
+
clientName,
|
|
4510
|
+
xataAgentExtra
|
|
4511
|
+
};
|
|
4512
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
|
|
4513
|
+
fetch,
|
|
4514
|
+
apiKey,
|
|
4515
|
+
databaseURL,
|
|
4516
|
+
branch,
|
|
4517
|
+
trace,
|
|
4518
|
+
clientID,
|
|
4519
|
+
clientName,
|
|
4520
|
+
xataAgentExtra
|
|
4521
|
+
}) {
|
|
2349
4522
|
return {
|
|
2350
|
-
|
|
4523
|
+
fetch,
|
|
2351
4524
|
apiKey,
|
|
2352
4525
|
apiUrl: "",
|
|
4526
|
+
// Instead of using workspace and dbBranch, we inject a probably CNAME'd URL
|
|
2353
4527
|
workspacesApiUrl: (path, params) => {
|
|
2354
4528
|
const hasBranch = params.dbBranchName ?? params.branch;
|
|
2355
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${
|
|
4529
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
|
|
2356
4530
|
return databaseURL + newPath;
|
|
2357
4531
|
},
|
|
2358
|
-
trace
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
return __privateGet(this, _branch);
|
|
2363
|
-
if (param === void 0)
|
|
2364
|
-
return void 0;
|
|
2365
|
-
const strategies = Array.isArray(param) ? [...param] : [param];
|
|
2366
|
-
const evaluateBranch = async (strategy) => {
|
|
2367
|
-
return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
|
|
4532
|
+
trace,
|
|
4533
|
+
clientID,
|
|
4534
|
+
clientName,
|
|
4535
|
+
xataAgentExtra
|
|
2368
4536
|
};
|
|
2369
|
-
for await (const strategy of strategies) {
|
|
2370
|
-
const branch = await evaluateBranch(strategy);
|
|
2371
|
-
if (branch) {
|
|
2372
|
-
__privateSet(this, _branch, branch);
|
|
2373
|
-
return branch;
|
|
2374
|
-
}
|
|
2375
|
-
}
|
|
2376
4537
|
}, _a;
|
|
2377
4538
|
};
|
|
2378
4539
|
class BaseClient extends buildClient() {
|
|
2379
4540
|
}
|
|
2380
4541
|
|
|
4542
|
+
var __defProp$1 = Object.defineProperty;
|
|
4543
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4544
|
+
var __publicField$1 = (obj, key, value) => {
|
|
4545
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4546
|
+
return value;
|
|
4547
|
+
};
|
|
2381
4548
|
const META = "__";
|
|
2382
4549
|
const VALUE = "___";
|
|
2383
4550
|
class Serializer {
|
|
2384
4551
|
constructor() {
|
|
2385
|
-
this
|
|
4552
|
+
__publicField$1(this, "classes", {});
|
|
2386
4553
|
}
|
|
2387
4554
|
add(clazz) {
|
|
2388
4555
|
this.classes[clazz.name] = clazz;
|
|
@@ -2446,7 +4613,7 @@ const deserialize = (json) => {
|
|
|
2446
4613
|
};
|
|
2447
4614
|
|
|
2448
4615
|
function buildWorkerRunner(config) {
|
|
2449
|
-
return function xataWorker(name,
|
|
4616
|
+
return function xataWorker(name, worker) {
|
|
2450
4617
|
return async (...args) => {
|
|
2451
4618
|
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
|
2452
4619
|
const result = await fetch(url, {
|
|
@@ -2460,12 +4627,19 @@ function buildWorkerRunner(config) {
|
|
|
2460
4627
|
};
|
|
2461
4628
|
}
|
|
2462
4629
|
|
|
4630
|
+
var __defProp = Object.defineProperty;
|
|
4631
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4632
|
+
var __publicField = (obj, key, value) => {
|
|
4633
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4634
|
+
return value;
|
|
4635
|
+
};
|
|
2463
4636
|
class XataError extends Error {
|
|
2464
4637
|
constructor(message, status) {
|
|
2465
4638
|
super(message);
|
|
4639
|
+
__publicField(this, "status");
|
|
2466
4640
|
this.status = status;
|
|
2467
4641
|
}
|
|
2468
4642
|
}
|
|
2469
4643
|
|
|
2470
|
-
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, applyBranchSchemaEdit, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn,
|
|
4644
|
+
export { BaseClient, FetcherError, FilesPlugin, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, ge, getAPIKey, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getUserOAuthClients, getWorkspace, getWorkspaceMembersList, getWorkspacesList, grantAuthorizationCode, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, transformImage, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
|
|
2471
4645
|
//# sourceMappingURL=index.mjs.map
|