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