@xata.io/client 0.0.0-alpha.vf14d496 → 0.0.0-alpha.vf162e72
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 +212 -0
- package/README.md +3 -269
- package/dist/index.cjs +1339 -386
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2978 -1554
- package/dist/index.mjs +1319 -360
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -10
- package/.eslintrc.cjs +0 -12
- package/Usage.md +0 -451
- package/rollup.config.mjs +0 -29
- package/tsconfig.json +0 -23
package/dist/index.cjs
CHANGED
|
@@ -1,27 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function _interopNamespace(e) {
|
|
6
|
-
if (e && e.__esModule) return e;
|
|
7
|
-
var n = Object.create(null);
|
|
8
|
-
if (e) {
|
|
9
|
-
Object.keys(e).forEach(function (k) {
|
|
10
|
-
if (k !== 'default') {
|
|
11
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () { return e[k]; }
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
n["default"] = e;
|
|
20
|
-
return Object.freeze(n);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const defaultTrace = async (_name, fn, _options) => {
|
|
3
|
+
const defaultTrace = async (name, fn, _options) => {
|
|
24
4
|
return await fn({
|
|
5
|
+
name,
|
|
25
6
|
setAttributes: () => {
|
|
26
7
|
return;
|
|
27
8
|
}
|
|
@@ -63,6 +44,18 @@ function isStringArray(value) {
|
|
|
63
44
|
function isNumber(value) {
|
|
64
45
|
return isDefined(value) && typeof value === "number";
|
|
65
46
|
}
|
|
47
|
+
function parseNumber(value) {
|
|
48
|
+
if (isNumber(value)) {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
if (isString(value)) {
|
|
52
|
+
const parsed = Number(value);
|
|
53
|
+
if (!Number.isNaN(parsed)) {
|
|
54
|
+
return parsed;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
66
59
|
function toBase64(value) {
|
|
67
60
|
try {
|
|
68
61
|
return btoa(value);
|
|
@@ -82,16 +75,28 @@ function deepMerge(a, b) {
|
|
|
82
75
|
}
|
|
83
76
|
return result;
|
|
84
77
|
}
|
|
78
|
+
function chunk(array, chunkSize) {
|
|
79
|
+
const result = [];
|
|
80
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
81
|
+
result.push(array.slice(i, i + chunkSize));
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
async function timeout(ms) {
|
|
86
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
87
|
+
}
|
|
85
88
|
|
|
86
89
|
function getEnvironment() {
|
|
87
90
|
try {
|
|
88
|
-
if (
|
|
91
|
+
if (isDefined(process) && isDefined(process.env)) {
|
|
89
92
|
return {
|
|
90
93
|
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
|
91
94
|
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
|
92
95
|
branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
deployPreview: process.env.XATA_PREVIEW,
|
|
97
|
+
deployPreviewBranch: process.env.XATA_PREVIEW_BRANCH,
|
|
98
|
+
vercelGitCommitRef: process.env.VERCEL_GIT_COMMIT_REF,
|
|
99
|
+
vercelGitRepoOwner: process.env.VERCEL_GIT_REPO_OWNER
|
|
95
100
|
};
|
|
96
101
|
}
|
|
97
102
|
} catch (err) {
|
|
@@ -102,8 +107,10 @@ function getEnvironment() {
|
|
|
102
107
|
apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
|
|
103
108
|
databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
|
|
104
109
|
branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
deployPreview: Deno.env.get("XATA_PREVIEW"),
|
|
111
|
+
deployPreviewBranch: Deno.env.get("XATA_PREVIEW_BRANCH"),
|
|
112
|
+
vercelGitCommitRef: Deno.env.get("VERCEL_GIT_COMMIT_REF"),
|
|
113
|
+
vercelGitRepoOwner: Deno.env.get("VERCEL_GIT_REPO_OWNER")
|
|
107
114
|
};
|
|
108
115
|
}
|
|
109
116
|
} catch (err) {
|
|
@@ -112,10 +119,31 @@ function getEnvironment() {
|
|
|
112
119
|
apiKey: getGlobalApiKey(),
|
|
113
120
|
databaseURL: getGlobalDatabaseURL(),
|
|
114
121
|
branch: getGlobalBranch(),
|
|
115
|
-
|
|
116
|
-
|
|
122
|
+
deployPreview: void 0,
|
|
123
|
+
deployPreviewBranch: void 0,
|
|
124
|
+
vercelGitCommitRef: void 0,
|
|
125
|
+
vercelGitRepoOwner: void 0
|
|
117
126
|
};
|
|
118
127
|
}
|
|
128
|
+
function getEnableBrowserVariable() {
|
|
129
|
+
try {
|
|
130
|
+
if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
|
|
131
|
+
return process.env.XATA_ENABLE_BROWSER === "true";
|
|
132
|
+
}
|
|
133
|
+
} catch (err) {
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
|
|
137
|
+
return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
|
|
138
|
+
}
|
|
139
|
+
} catch (err) {
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
|
|
143
|
+
} catch (err) {
|
|
144
|
+
return void 0;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
119
147
|
function getGlobalApiKey() {
|
|
120
148
|
try {
|
|
121
149
|
return XATA_API_KEY;
|
|
@@ -137,44 +165,76 @@ function getGlobalBranch() {
|
|
|
137
165
|
return void 0;
|
|
138
166
|
}
|
|
139
167
|
}
|
|
140
|
-
function
|
|
168
|
+
function getDatabaseURL() {
|
|
141
169
|
try {
|
|
142
|
-
|
|
170
|
+
const { databaseURL } = getEnvironment();
|
|
171
|
+
return databaseURL;
|
|
143
172
|
} catch (err) {
|
|
144
173
|
return void 0;
|
|
145
174
|
}
|
|
146
175
|
}
|
|
147
|
-
|
|
148
|
-
const cmd = ["git", "branch", "--show-current"];
|
|
149
|
-
const fullCmd = cmd.join(" ");
|
|
150
|
-
const nodeModule = ["child", "process"].join("_");
|
|
151
|
-
const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
|
|
176
|
+
function getAPIKey() {
|
|
152
177
|
try {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
const { execSync } = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(nodeModule);
|
|
157
|
-
return execSync(fullCmd, execOptions).toString().trim();
|
|
178
|
+
const { apiKey } = getEnvironment();
|
|
179
|
+
return apiKey;
|
|
158
180
|
} catch (err) {
|
|
181
|
+
return void 0;
|
|
159
182
|
}
|
|
183
|
+
}
|
|
184
|
+
function getBranch() {
|
|
160
185
|
try {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return new TextDecoder().decode(await process2.output()).trim();
|
|
164
|
-
}
|
|
186
|
+
const { branch } = getEnvironment();
|
|
187
|
+
return branch ?? "main";
|
|
165
188
|
} catch (err) {
|
|
189
|
+
return void 0;
|
|
166
190
|
}
|
|
167
191
|
}
|
|
168
|
-
|
|
169
|
-
|
|
192
|
+
function buildPreviewBranchName({ org, branch }) {
|
|
193
|
+
return `preview-${org}-${branch}`;
|
|
194
|
+
}
|
|
195
|
+
function getPreviewBranch() {
|
|
170
196
|
try {
|
|
171
|
-
const {
|
|
172
|
-
|
|
197
|
+
const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = getEnvironment();
|
|
198
|
+
if (deployPreviewBranch)
|
|
199
|
+
return deployPreviewBranch;
|
|
200
|
+
switch (deployPreview) {
|
|
201
|
+
case "vercel": {
|
|
202
|
+
if (!vercelGitCommitRef || !vercelGitRepoOwner) {
|
|
203
|
+
console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
|
|
204
|
+
return void 0;
|
|
205
|
+
}
|
|
206
|
+
return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return void 0;
|
|
173
210
|
} catch (err) {
|
|
174
211
|
return void 0;
|
|
175
212
|
}
|
|
176
213
|
}
|
|
177
214
|
|
|
215
|
+
var __accessCheck$8 = (obj, member, msg) => {
|
|
216
|
+
if (!member.has(obj))
|
|
217
|
+
throw TypeError("Cannot " + msg);
|
|
218
|
+
};
|
|
219
|
+
var __privateGet$8 = (obj, member, getter) => {
|
|
220
|
+
__accessCheck$8(obj, member, "read from private field");
|
|
221
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
222
|
+
};
|
|
223
|
+
var __privateAdd$8 = (obj, member, value) => {
|
|
224
|
+
if (member.has(obj))
|
|
225
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
226
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
227
|
+
};
|
|
228
|
+
var __privateSet$8 = (obj, member, value, setter) => {
|
|
229
|
+
__accessCheck$8(obj, member, "write to private field");
|
|
230
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
231
|
+
return value;
|
|
232
|
+
};
|
|
233
|
+
var __privateMethod$4 = (obj, member, method) => {
|
|
234
|
+
__accessCheck$8(obj, member, "access private method");
|
|
235
|
+
return method;
|
|
236
|
+
};
|
|
237
|
+
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
|
178
238
|
function getFetchImplementation(userFetch) {
|
|
179
239
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
|
180
240
|
const fetchImpl = userFetch ?? globalFetch;
|
|
@@ -185,8 +245,254 @@ function getFetchImplementation(userFetch) {
|
|
|
185
245
|
}
|
|
186
246
|
return fetchImpl;
|
|
187
247
|
}
|
|
248
|
+
class ApiRequestPool {
|
|
249
|
+
constructor(concurrency = 10) {
|
|
250
|
+
__privateAdd$8(this, _enqueue);
|
|
251
|
+
__privateAdd$8(this, _fetch, void 0);
|
|
252
|
+
__privateAdd$8(this, _queue, void 0);
|
|
253
|
+
__privateAdd$8(this, _concurrency, void 0);
|
|
254
|
+
__privateSet$8(this, _queue, []);
|
|
255
|
+
__privateSet$8(this, _concurrency, concurrency);
|
|
256
|
+
this.running = 0;
|
|
257
|
+
this.started = 0;
|
|
258
|
+
}
|
|
259
|
+
setFetch(fetch2) {
|
|
260
|
+
__privateSet$8(this, _fetch, fetch2);
|
|
261
|
+
}
|
|
262
|
+
getFetch() {
|
|
263
|
+
if (!__privateGet$8(this, _fetch)) {
|
|
264
|
+
throw new Error("Fetch not set");
|
|
265
|
+
}
|
|
266
|
+
return __privateGet$8(this, _fetch);
|
|
267
|
+
}
|
|
268
|
+
request(url, options) {
|
|
269
|
+
const start = /* @__PURE__ */ new Date();
|
|
270
|
+
const fetch2 = this.getFetch();
|
|
271
|
+
const runRequest = async (stalled = false) => {
|
|
272
|
+
const response = await fetch2(url, options);
|
|
273
|
+
if (response.status === 429) {
|
|
274
|
+
const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
|
|
275
|
+
await timeout(rateLimitReset * 1e3);
|
|
276
|
+
return await runRequest(true);
|
|
277
|
+
}
|
|
278
|
+
if (stalled) {
|
|
279
|
+
const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
|
|
280
|
+
console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
|
|
281
|
+
}
|
|
282
|
+
return response;
|
|
283
|
+
};
|
|
284
|
+
return __privateMethod$4(this, _enqueue, enqueue_fn).call(this, async () => {
|
|
285
|
+
return await runRequest();
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
_fetch = new WeakMap();
|
|
290
|
+
_queue = new WeakMap();
|
|
291
|
+
_concurrency = new WeakMap();
|
|
292
|
+
_enqueue = new WeakSet();
|
|
293
|
+
enqueue_fn = function(task) {
|
|
294
|
+
const promise = new Promise((resolve) => __privateGet$8(this, _queue).push(resolve)).finally(() => {
|
|
295
|
+
this.started--;
|
|
296
|
+
this.running++;
|
|
297
|
+
}).then(() => task()).finally(() => {
|
|
298
|
+
this.running--;
|
|
299
|
+
const next = __privateGet$8(this, _queue).shift();
|
|
300
|
+
if (next !== void 0) {
|
|
301
|
+
this.started++;
|
|
302
|
+
next();
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
if (this.running + this.started < __privateGet$8(this, _concurrency)) {
|
|
306
|
+
const next = __privateGet$8(this, _queue).shift();
|
|
307
|
+
if (next !== void 0) {
|
|
308
|
+
this.started++;
|
|
309
|
+
next();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return promise;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
function generateUUID() {
|
|
316
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
317
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
318
|
+
return v.toString(16);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
188
321
|
|
|
189
|
-
|
|
322
|
+
async function getBytes(stream, onChunk) {
|
|
323
|
+
const reader = stream.getReader();
|
|
324
|
+
let result;
|
|
325
|
+
while (!(result = await reader.read()).done) {
|
|
326
|
+
onChunk(result.value);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function getLines(onLine) {
|
|
330
|
+
let buffer;
|
|
331
|
+
let position;
|
|
332
|
+
let fieldLength;
|
|
333
|
+
let discardTrailingNewline = false;
|
|
334
|
+
return function onChunk(arr) {
|
|
335
|
+
if (buffer === void 0) {
|
|
336
|
+
buffer = arr;
|
|
337
|
+
position = 0;
|
|
338
|
+
fieldLength = -1;
|
|
339
|
+
} else {
|
|
340
|
+
buffer = concat(buffer, arr);
|
|
341
|
+
}
|
|
342
|
+
const bufLength = buffer.length;
|
|
343
|
+
let lineStart = 0;
|
|
344
|
+
while (position < bufLength) {
|
|
345
|
+
if (discardTrailingNewline) {
|
|
346
|
+
if (buffer[position] === 10 /* NewLine */) {
|
|
347
|
+
lineStart = ++position;
|
|
348
|
+
}
|
|
349
|
+
discardTrailingNewline = false;
|
|
350
|
+
}
|
|
351
|
+
let lineEnd = -1;
|
|
352
|
+
for (; position < bufLength && lineEnd === -1; ++position) {
|
|
353
|
+
switch (buffer[position]) {
|
|
354
|
+
case 58 /* Colon */:
|
|
355
|
+
if (fieldLength === -1) {
|
|
356
|
+
fieldLength = position - lineStart;
|
|
357
|
+
}
|
|
358
|
+
break;
|
|
359
|
+
case 13 /* CarriageReturn */:
|
|
360
|
+
discardTrailingNewline = true;
|
|
361
|
+
case 10 /* NewLine */:
|
|
362
|
+
lineEnd = position;
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (lineEnd === -1) {
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
|
|
370
|
+
lineStart = position;
|
|
371
|
+
fieldLength = -1;
|
|
372
|
+
}
|
|
373
|
+
if (lineStart === bufLength) {
|
|
374
|
+
buffer = void 0;
|
|
375
|
+
} else if (lineStart !== 0) {
|
|
376
|
+
buffer = buffer.subarray(lineStart);
|
|
377
|
+
position -= lineStart;
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
function getMessages(onId, onRetry, onMessage) {
|
|
382
|
+
let message = newMessage();
|
|
383
|
+
const decoder = new TextDecoder();
|
|
384
|
+
return function onLine(line, fieldLength) {
|
|
385
|
+
if (line.length === 0) {
|
|
386
|
+
onMessage?.(message);
|
|
387
|
+
message = newMessage();
|
|
388
|
+
} else if (fieldLength > 0) {
|
|
389
|
+
const field = decoder.decode(line.subarray(0, fieldLength));
|
|
390
|
+
const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
|
|
391
|
+
const value = decoder.decode(line.subarray(valueOffset));
|
|
392
|
+
switch (field) {
|
|
393
|
+
case "data":
|
|
394
|
+
message.data = message.data ? message.data + "\n" + value : value;
|
|
395
|
+
break;
|
|
396
|
+
case "event":
|
|
397
|
+
message.event = value;
|
|
398
|
+
break;
|
|
399
|
+
case "id":
|
|
400
|
+
onId(message.id = value);
|
|
401
|
+
break;
|
|
402
|
+
case "retry":
|
|
403
|
+
const retry = parseInt(value, 10);
|
|
404
|
+
if (!isNaN(retry)) {
|
|
405
|
+
onRetry(message.retry = retry);
|
|
406
|
+
}
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
function concat(a, b) {
|
|
413
|
+
const res = new Uint8Array(a.length + b.length);
|
|
414
|
+
res.set(a);
|
|
415
|
+
res.set(b, a.length);
|
|
416
|
+
return res;
|
|
417
|
+
}
|
|
418
|
+
function newMessage() {
|
|
419
|
+
return {
|
|
420
|
+
data: "",
|
|
421
|
+
event: "",
|
|
422
|
+
id: "",
|
|
423
|
+
retry: void 0
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
const EventStreamContentType = "text/event-stream";
|
|
427
|
+
const LastEventId = "last-event-id";
|
|
428
|
+
function fetchEventSource(input, {
|
|
429
|
+
signal: inputSignal,
|
|
430
|
+
headers: inputHeaders,
|
|
431
|
+
onopen: inputOnOpen,
|
|
432
|
+
onmessage,
|
|
433
|
+
onclose,
|
|
434
|
+
onerror,
|
|
435
|
+
fetch: inputFetch,
|
|
436
|
+
...rest
|
|
437
|
+
}) {
|
|
438
|
+
return new Promise((resolve, reject) => {
|
|
439
|
+
const headers = { ...inputHeaders };
|
|
440
|
+
if (!headers.accept) {
|
|
441
|
+
headers.accept = EventStreamContentType;
|
|
442
|
+
}
|
|
443
|
+
let curRequestController;
|
|
444
|
+
function dispose() {
|
|
445
|
+
curRequestController.abort();
|
|
446
|
+
}
|
|
447
|
+
inputSignal?.addEventListener("abort", () => {
|
|
448
|
+
dispose();
|
|
449
|
+
resolve();
|
|
450
|
+
});
|
|
451
|
+
const fetchImpl = inputFetch ?? fetch;
|
|
452
|
+
const onopen = inputOnOpen ?? defaultOnOpen;
|
|
453
|
+
async function create() {
|
|
454
|
+
curRequestController = new AbortController();
|
|
455
|
+
try {
|
|
456
|
+
const response = await fetchImpl(input, {
|
|
457
|
+
...rest,
|
|
458
|
+
headers,
|
|
459
|
+
signal: curRequestController.signal
|
|
460
|
+
});
|
|
461
|
+
await onopen(response);
|
|
462
|
+
await getBytes(
|
|
463
|
+
response.body,
|
|
464
|
+
getLines(
|
|
465
|
+
getMessages(
|
|
466
|
+
(id) => {
|
|
467
|
+
if (id) {
|
|
468
|
+
headers[LastEventId] = id;
|
|
469
|
+
} else {
|
|
470
|
+
delete headers[LastEventId];
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
(_retry) => {
|
|
474
|
+
},
|
|
475
|
+
onmessage
|
|
476
|
+
)
|
|
477
|
+
)
|
|
478
|
+
);
|
|
479
|
+
onclose?.();
|
|
480
|
+
dispose();
|
|
481
|
+
resolve();
|
|
482
|
+
} catch (err) {
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
create();
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
function defaultOnOpen(response) {
|
|
489
|
+
const contentType = response.headers?.get("content-type");
|
|
490
|
+
if (!contentType?.startsWith(EventStreamContentType)) {
|
|
491
|
+
throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
const VERSION = "0.24.1";
|
|
190
496
|
|
|
191
497
|
class ErrorWithCause extends Error {
|
|
192
498
|
constructor(message, options) {
|
|
@@ -197,7 +503,7 @@ class FetcherError extends ErrorWithCause {
|
|
|
197
503
|
constructor(status, data, requestId) {
|
|
198
504
|
super(getMessage(data));
|
|
199
505
|
this.status = status;
|
|
200
|
-
this.errors = isBulkError(data) ? data.errors :
|
|
506
|
+
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
|
201
507
|
this.requestId = requestId;
|
|
202
508
|
if (data instanceof Error) {
|
|
203
509
|
this.stack = data.stack;
|
|
@@ -229,6 +535,7 @@ function getMessage(data) {
|
|
|
229
535
|
}
|
|
230
536
|
}
|
|
231
537
|
|
|
538
|
+
const pool = new ApiRequestPool();
|
|
232
539
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
233
540
|
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
|
234
541
|
if (value === void 0 || value === null)
|
|
@@ -261,14 +568,15 @@ function hostHeader(url) {
|
|
|
261
568
|
const { groups } = pattern.exec(url) ?? {};
|
|
262
569
|
return groups?.host ? { Host: groups.host } : {};
|
|
263
570
|
}
|
|
571
|
+
const defaultClientID = generateUUID();
|
|
264
572
|
async function fetch$1({
|
|
265
573
|
url: path,
|
|
266
574
|
method,
|
|
267
575
|
body,
|
|
268
|
-
headers,
|
|
576
|
+
headers: customHeaders,
|
|
269
577
|
pathParams,
|
|
270
578
|
queryParams,
|
|
271
|
-
|
|
579
|
+
fetch: fetch2,
|
|
272
580
|
apiKey,
|
|
273
581
|
endpoint,
|
|
274
582
|
apiUrl,
|
|
@@ -276,9 +584,13 @@ async function fetch$1({
|
|
|
276
584
|
trace,
|
|
277
585
|
signal,
|
|
278
586
|
clientID,
|
|
279
|
-
sessionID
|
|
587
|
+
sessionID,
|
|
588
|
+
clientName,
|
|
589
|
+
xataAgentExtra,
|
|
590
|
+
fetchOptions = {}
|
|
280
591
|
}) {
|
|
281
|
-
|
|
592
|
+
pool.setFetch(fetch2);
|
|
593
|
+
return await trace(
|
|
282
594
|
`${method.toUpperCase()} ${path}`,
|
|
283
595
|
async ({ setAttributes }) => {
|
|
284
596
|
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
|
@@ -288,23 +600,29 @@ async function fetch$1({
|
|
|
288
600
|
[TraceAttributes.HTTP_URL]: url,
|
|
289
601
|
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
|
290
602
|
});
|
|
291
|
-
const
|
|
603
|
+
const xataAgent = compact([
|
|
604
|
+
["client", "TS_SDK"],
|
|
605
|
+
["version", VERSION],
|
|
606
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
|
607
|
+
...Object.entries(xataAgentExtra ?? {})
|
|
608
|
+
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
|
609
|
+
const headers = {
|
|
610
|
+
"Accept-Encoding": "identity",
|
|
611
|
+
"Content-Type": "application/json",
|
|
612
|
+
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
|
613
|
+
"X-Xata-Session-ID": sessionID ?? generateUUID(),
|
|
614
|
+
"X-Xata-Agent": xataAgent,
|
|
615
|
+
...customHeaders,
|
|
616
|
+
...hostHeader(fullUrl),
|
|
617
|
+
Authorization: `Bearer ${apiKey}`
|
|
618
|
+
};
|
|
619
|
+
const response = await pool.request(url, {
|
|
620
|
+
...fetchOptions,
|
|
292
621
|
method: method.toUpperCase(),
|
|
293
622
|
body: body ? JSON.stringify(body) : void 0,
|
|
294
|
-
headers
|
|
295
|
-
"Content-Type": "application/json",
|
|
296
|
-
"User-Agent": `Xata client-ts/${VERSION}`,
|
|
297
|
-
"X-Xata-Client-ID": clientID ?? "",
|
|
298
|
-
"X-Xata-Session-ID": sessionID ?? "",
|
|
299
|
-
...headers,
|
|
300
|
-
...hostHeader(fullUrl),
|
|
301
|
-
Authorization: `Bearer ${apiKey}`
|
|
302
|
-
},
|
|
623
|
+
headers,
|
|
303
624
|
signal
|
|
304
625
|
});
|
|
305
|
-
if (response.status === 204) {
|
|
306
|
-
return {};
|
|
307
|
-
}
|
|
308
626
|
const { host, protocol } = parseUrl(response.url);
|
|
309
627
|
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
|
310
628
|
setAttributes({
|
|
@@ -314,6 +632,12 @@ async function fetch$1({
|
|
|
314
632
|
[TraceAttributes.HTTP_HOST]: host,
|
|
315
633
|
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
|
316
634
|
});
|
|
635
|
+
if (response.status === 204) {
|
|
636
|
+
return {};
|
|
637
|
+
}
|
|
638
|
+
if (response.status === 429) {
|
|
639
|
+
throw new FetcherError(response.status, "Rate limit exceeded", requestId);
|
|
640
|
+
}
|
|
317
641
|
try {
|
|
318
642
|
const jsonResponse = await response.json();
|
|
319
643
|
if (response.ok) {
|
|
@@ -327,6 +651,59 @@ async function fetch$1({
|
|
|
327
651
|
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
|
328
652
|
);
|
|
329
653
|
}
|
|
654
|
+
function fetchSSERequest({
|
|
655
|
+
url: path,
|
|
656
|
+
method,
|
|
657
|
+
body,
|
|
658
|
+
headers: customHeaders,
|
|
659
|
+
pathParams,
|
|
660
|
+
queryParams,
|
|
661
|
+
fetch: fetch2,
|
|
662
|
+
apiKey,
|
|
663
|
+
endpoint,
|
|
664
|
+
apiUrl,
|
|
665
|
+
workspacesApiUrl,
|
|
666
|
+
onMessage,
|
|
667
|
+
onError,
|
|
668
|
+
onClose,
|
|
669
|
+
signal,
|
|
670
|
+
clientID,
|
|
671
|
+
sessionID,
|
|
672
|
+
clientName,
|
|
673
|
+
xataAgentExtra
|
|
674
|
+
}) {
|
|
675
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
|
676
|
+
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
|
677
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
|
678
|
+
void fetchEventSource(url, {
|
|
679
|
+
method,
|
|
680
|
+
body: JSON.stringify(body),
|
|
681
|
+
fetch: fetch2,
|
|
682
|
+
signal,
|
|
683
|
+
headers: {
|
|
684
|
+
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
|
685
|
+
"X-Xata-Session-ID": sessionID ?? generateUUID(),
|
|
686
|
+
"X-Xata-Agent": compact([
|
|
687
|
+
["client", "TS_SDK"],
|
|
688
|
+
["version", VERSION],
|
|
689
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
|
690
|
+
...Object.entries(xataAgentExtra ?? {})
|
|
691
|
+
]).map(([key, value]) => `${key}=${value}`).join("; "),
|
|
692
|
+
...customHeaders,
|
|
693
|
+
Authorization: `Bearer ${apiKey}`,
|
|
694
|
+
"Content-Type": "application/json"
|
|
695
|
+
},
|
|
696
|
+
onmessage(ev) {
|
|
697
|
+
onMessage?.(JSON.parse(ev.data));
|
|
698
|
+
},
|
|
699
|
+
onerror(ev) {
|
|
700
|
+
onError?.(JSON.parse(ev.data));
|
|
701
|
+
},
|
|
702
|
+
onclose() {
|
|
703
|
+
onClose?.();
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
}
|
|
330
707
|
function parseUrl(url) {
|
|
331
708
|
try {
|
|
332
709
|
const { host, protocol } = new URL(url);
|
|
@@ -338,17 +715,12 @@ function parseUrl(url) {
|
|
|
338
715
|
|
|
339
716
|
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
|
340
717
|
|
|
341
|
-
const dEPRECATEDgetDatabaseList = (variables, signal) => dataPlaneFetch({ url: "/dbs", method: "get", ...variables, signal });
|
|
342
718
|
const getBranchList = (variables, signal) => dataPlaneFetch({
|
|
343
719
|
url: "/dbs/{dbName}",
|
|
344
720
|
method: "get",
|
|
345
721
|
...variables,
|
|
346
722
|
signal
|
|
347
723
|
});
|
|
348
|
-
const dEPRECATEDcreateDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
|
|
349
|
-
const dEPRECATEDdeleteDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "delete", ...variables, signal });
|
|
350
|
-
const dEPRECATEDgetDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "get", ...variables, signal });
|
|
351
|
-
const dEPRECATEDupdateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
|
|
352
724
|
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
|
353
725
|
url: "/db/{dbBranchName}",
|
|
354
726
|
method: "get",
|
|
@@ -362,6 +734,12 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
|
|
|
362
734
|
...variables,
|
|
363
735
|
signal
|
|
364
736
|
});
|
|
737
|
+
const copyBranch = (variables, signal) => dataPlaneFetch({
|
|
738
|
+
url: "/db/{dbBranchName}/copy",
|
|
739
|
+
method: "post",
|
|
740
|
+
...variables,
|
|
741
|
+
signal
|
|
742
|
+
});
|
|
365
743
|
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
|
366
744
|
url: "/db/{dbBranchName}/metadata",
|
|
367
745
|
method: "put",
|
|
@@ -387,7 +765,6 @@ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName
|
|
|
387
765
|
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
|
388
766
|
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
|
389
767
|
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
|
390
|
-
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
|
391
768
|
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
|
392
769
|
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
|
393
770
|
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
|
@@ -412,6 +789,7 @@ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{
|
|
|
412
789
|
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
|
413
790
|
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
|
414
791
|
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
|
792
|
+
const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
|
|
415
793
|
const createTable = (variables, signal) => dataPlaneFetch({
|
|
416
794
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
|
417
795
|
method: "put",
|
|
@@ -454,7 +832,44 @@ const deleteColumn = (variables, signal) => dataPlaneFetch({
|
|
|
454
832
|
...variables,
|
|
455
833
|
signal
|
|
456
834
|
});
|
|
835
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
|
457
836
|
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
|
837
|
+
const getFileItem = (variables, signal) => dataPlaneFetch({
|
|
838
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
|
839
|
+
method: "get",
|
|
840
|
+
...variables,
|
|
841
|
+
signal
|
|
842
|
+
});
|
|
843
|
+
const putFileItem = (variables, signal) => dataPlaneFetch({
|
|
844
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
|
845
|
+
method: "put",
|
|
846
|
+
...variables,
|
|
847
|
+
signal
|
|
848
|
+
});
|
|
849
|
+
const deleteFileItem = (variables, signal) => dataPlaneFetch({
|
|
850
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
|
851
|
+
method: "delete",
|
|
852
|
+
...variables,
|
|
853
|
+
signal
|
|
854
|
+
});
|
|
855
|
+
const getFile = (variables, signal) => dataPlaneFetch({
|
|
856
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
|
857
|
+
method: "get",
|
|
858
|
+
...variables,
|
|
859
|
+
signal
|
|
860
|
+
});
|
|
861
|
+
const putFile = (variables, signal) => dataPlaneFetch({
|
|
862
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
|
863
|
+
method: "put",
|
|
864
|
+
...variables,
|
|
865
|
+
signal
|
|
866
|
+
});
|
|
867
|
+
const deleteFile = (variables, signal) => dataPlaneFetch({
|
|
868
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
|
869
|
+
method: "delete",
|
|
870
|
+
...variables,
|
|
871
|
+
signal
|
|
872
|
+
});
|
|
458
873
|
const getRecord = (variables, signal) => dataPlaneFetch({
|
|
459
874
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
|
460
875
|
method: "get",
|
|
@@ -484,21 +899,34 @@ const searchTable = (variables, signal) => dataPlaneFetch({
|
|
|
484
899
|
...variables,
|
|
485
900
|
signal
|
|
486
901
|
});
|
|
902
|
+
const sqlQuery = (variables, signal) => dataPlaneFetch({
|
|
903
|
+
url: "/db/{dbBranchName}/sql",
|
|
904
|
+
method: "post",
|
|
905
|
+
...variables,
|
|
906
|
+
signal
|
|
907
|
+
});
|
|
908
|
+
const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
|
|
909
|
+
const askTable = (variables, signal) => dataPlaneFetch({
|
|
910
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
|
911
|
+
method: "post",
|
|
912
|
+
...variables,
|
|
913
|
+
signal
|
|
914
|
+
});
|
|
487
915
|
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
|
488
916
|
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
|
917
|
+
const fileAccess = (variables, signal) => dataPlaneFetch({
|
|
918
|
+
url: "/file/{fileId}",
|
|
919
|
+
method: "get",
|
|
920
|
+
...variables,
|
|
921
|
+
signal
|
|
922
|
+
});
|
|
489
923
|
const operationsByTag$2 = {
|
|
490
|
-
database: {
|
|
491
|
-
dEPRECATEDgetDatabaseList,
|
|
492
|
-
dEPRECATEDcreateDatabase,
|
|
493
|
-
dEPRECATEDdeleteDatabase,
|
|
494
|
-
dEPRECATEDgetDatabaseMetadata,
|
|
495
|
-
dEPRECATEDupdateDatabaseMetadata
|
|
496
|
-
},
|
|
497
924
|
branch: {
|
|
498
925
|
getBranchList,
|
|
499
926
|
getBranchDetails,
|
|
500
927
|
createBranch,
|
|
501
928
|
deleteBranch,
|
|
929
|
+
copyBranch,
|
|
502
930
|
updateBranchMetadata,
|
|
503
931
|
getBranchMetadata,
|
|
504
932
|
getBranchStats,
|
|
@@ -516,17 +944,8 @@ const operationsByTag$2 = {
|
|
|
516
944
|
compareBranchSchemas,
|
|
517
945
|
updateBranchSchema,
|
|
518
946
|
previewBranchSchemaEdit,
|
|
519
|
-
applyBranchSchemaEdit
|
|
520
|
-
|
|
521
|
-
records: {
|
|
522
|
-
branchTransaction,
|
|
523
|
-
insertRecord,
|
|
524
|
-
getRecord,
|
|
525
|
-
insertRecordWithID,
|
|
526
|
-
updateRecordWithID,
|
|
527
|
-
upsertRecordWithID,
|
|
528
|
-
deleteRecord,
|
|
529
|
-
bulkInsertTableRecords
|
|
947
|
+
applyBranchSchemaEdit,
|
|
948
|
+
pushBranchMigrations
|
|
530
949
|
},
|
|
531
950
|
migrationRequests: {
|
|
532
951
|
queryMigrationRequests,
|
|
@@ -550,7 +969,27 @@ const operationsByTag$2 = {
|
|
|
550
969
|
updateColumn,
|
|
551
970
|
deleteColumn
|
|
552
971
|
},
|
|
553
|
-
|
|
972
|
+
records: {
|
|
973
|
+
branchTransaction,
|
|
974
|
+
insertRecord,
|
|
975
|
+
getRecord,
|
|
976
|
+
insertRecordWithID,
|
|
977
|
+
updateRecordWithID,
|
|
978
|
+
upsertRecordWithID,
|
|
979
|
+
deleteRecord,
|
|
980
|
+
bulkInsertTableRecords
|
|
981
|
+
},
|
|
982
|
+
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
|
|
983
|
+
searchAndFilter: {
|
|
984
|
+
queryTable,
|
|
985
|
+
searchBranch,
|
|
986
|
+
searchTable,
|
|
987
|
+
sqlQuery,
|
|
988
|
+
vectorSearchTable,
|
|
989
|
+
askTable,
|
|
990
|
+
summarizeTable,
|
|
991
|
+
aggregateTable
|
|
992
|
+
}
|
|
554
993
|
};
|
|
555
994
|
|
|
556
995
|
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
|
@@ -649,6 +1088,10 @@ const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
|
|
649
1088
|
});
|
|
650
1089
|
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
|
651
1090
|
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
|
1091
|
+
const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
|
|
1092
|
+
const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
|
|
1093
|
+
const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
|
|
1094
|
+
const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
|
|
652
1095
|
const listRegions = (variables, signal) => controlPlaneFetch({
|
|
653
1096
|
url: "/workspaces/{workspaceId}/regions",
|
|
654
1097
|
method: "get",
|
|
@@ -681,6 +1124,10 @@ const operationsByTag$1 = {
|
|
|
681
1124
|
deleteDatabase,
|
|
682
1125
|
getDatabaseMetadata,
|
|
683
1126
|
updateDatabaseMetadata,
|
|
1127
|
+
renameDatabase,
|
|
1128
|
+
getDatabaseGithubSettings,
|
|
1129
|
+
updateDatabaseGithubSettings,
|
|
1130
|
+
deleteDatabaseGithubSettings,
|
|
684
1131
|
listRegions
|
|
685
1132
|
}
|
|
686
1133
|
};
|
|
@@ -701,8 +1148,12 @@ const providers = {
|
|
|
701
1148
|
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
|
702
1149
|
},
|
|
703
1150
|
staging: {
|
|
704
|
-
main: "https://staging.
|
|
705
|
-
workspaces: "https://{workspaceId}.
|
|
1151
|
+
main: "https://api.staging-xata.dev",
|
|
1152
|
+
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
|
1153
|
+
},
|
|
1154
|
+
dev: {
|
|
1155
|
+
main: "https://api.dev-xata.dev",
|
|
1156
|
+
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
|
706
1157
|
}
|
|
707
1158
|
};
|
|
708
1159
|
function isHostProviderAlias(alias) {
|
|
@@ -720,15 +1171,22 @@ function parseProviderString(provider = "production") {
|
|
|
720
1171
|
return null;
|
|
721
1172
|
return { main, workspaces };
|
|
722
1173
|
}
|
|
1174
|
+
function buildProviderString(provider) {
|
|
1175
|
+
if (isHostProviderAlias(provider))
|
|
1176
|
+
return provider;
|
|
1177
|
+
return `${provider.main},${provider.workspaces}`;
|
|
1178
|
+
}
|
|
723
1179
|
function parseWorkspacesUrlParts(url) {
|
|
724
1180
|
if (!isString(url))
|
|
725
1181
|
return null;
|
|
726
|
-
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))
|
|
727
|
-
const
|
|
728
|
-
const
|
|
1182
|
+
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
|
1183
|
+
const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
|
|
1184
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
|
|
1185
|
+
const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
|
|
1186
|
+
const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
|
|
729
1187
|
if (!match)
|
|
730
1188
|
return null;
|
|
731
|
-
return { workspace: match[1], region: match[2]
|
|
1189
|
+
return { workspace: match[1], region: match[2] };
|
|
732
1190
|
}
|
|
733
1191
|
|
|
734
1192
|
var __accessCheck$7 = (obj, member, msg) => {
|
|
@@ -757,15 +1215,19 @@ class XataApiClient {
|
|
|
757
1215
|
const provider = options.host ?? "production";
|
|
758
1216
|
const apiKey = options.apiKey ?? getAPIKey();
|
|
759
1217
|
const trace = options.trace ?? defaultTrace;
|
|
1218
|
+
const clientID = generateUUID();
|
|
760
1219
|
if (!apiKey) {
|
|
761
1220
|
throw new Error("Could not resolve a valid apiKey");
|
|
762
1221
|
}
|
|
763
1222
|
__privateSet$7(this, _extraProps, {
|
|
764
1223
|
apiUrl: getHostUrl(provider, "main"),
|
|
765
1224
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
|
766
|
-
|
|
1225
|
+
fetch: getFetchImplementation(options.fetch),
|
|
767
1226
|
apiKey,
|
|
768
|
-
trace
|
|
1227
|
+
trace,
|
|
1228
|
+
clientName: options.clientName,
|
|
1229
|
+
xataAgentExtra: options.xataAgentExtra,
|
|
1230
|
+
clientID
|
|
769
1231
|
});
|
|
770
1232
|
}
|
|
771
1233
|
get user() {
|
|
@@ -818,6 +1280,11 @@ class XataApiClient {
|
|
|
818
1280
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
|
819
1281
|
return __privateGet$7(this, _namespaces).records;
|
|
820
1282
|
}
|
|
1283
|
+
get files() {
|
|
1284
|
+
if (!__privateGet$7(this, _namespaces).files)
|
|
1285
|
+
__privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
|
|
1286
|
+
return __privateGet$7(this, _namespaces).files;
|
|
1287
|
+
}
|
|
821
1288
|
get searchAndFilter() {
|
|
822
1289
|
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
|
823
1290
|
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
|
@@ -1026,6 +1493,20 @@ class BranchApi {
|
|
|
1026
1493
|
...this.extraProps
|
|
1027
1494
|
});
|
|
1028
1495
|
}
|
|
1496
|
+
copyBranch({
|
|
1497
|
+
workspace,
|
|
1498
|
+
region,
|
|
1499
|
+
database,
|
|
1500
|
+
branch,
|
|
1501
|
+
destinationBranch,
|
|
1502
|
+
limit
|
|
1503
|
+
}) {
|
|
1504
|
+
return operationsByTag.branch.copyBranch({
|
|
1505
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1506
|
+
body: { destinationBranch, limit },
|
|
1507
|
+
...this.extraProps
|
|
1508
|
+
});
|
|
1509
|
+
}
|
|
1029
1510
|
updateBranchMetadata({
|
|
1030
1511
|
workspace,
|
|
1031
1512
|
region,
|
|
@@ -1318,52 +1799,223 @@ class RecordsApi {
|
|
|
1318
1799
|
...this.extraProps
|
|
1319
1800
|
});
|
|
1320
1801
|
}
|
|
1321
|
-
upsertRecordWithID({
|
|
1802
|
+
upsertRecordWithID({
|
|
1803
|
+
workspace,
|
|
1804
|
+
region,
|
|
1805
|
+
database,
|
|
1806
|
+
branch,
|
|
1807
|
+
table,
|
|
1808
|
+
id,
|
|
1809
|
+
record,
|
|
1810
|
+
columns,
|
|
1811
|
+
ifVersion
|
|
1812
|
+
}) {
|
|
1813
|
+
return operationsByTag.records.upsertRecordWithID({
|
|
1814
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1815
|
+
queryParams: { columns, ifVersion },
|
|
1816
|
+
body: record,
|
|
1817
|
+
...this.extraProps
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1820
|
+
deleteRecord({
|
|
1821
|
+
workspace,
|
|
1822
|
+
region,
|
|
1823
|
+
database,
|
|
1824
|
+
branch,
|
|
1825
|
+
table,
|
|
1826
|
+
id,
|
|
1827
|
+
columns
|
|
1828
|
+
}) {
|
|
1829
|
+
return operationsByTag.records.deleteRecord({
|
|
1830
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
|
1831
|
+
queryParams: { columns },
|
|
1832
|
+
...this.extraProps
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1835
|
+
bulkInsertTableRecords({
|
|
1836
|
+
workspace,
|
|
1837
|
+
region,
|
|
1838
|
+
database,
|
|
1839
|
+
branch,
|
|
1840
|
+
table,
|
|
1841
|
+
records,
|
|
1842
|
+
columns
|
|
1843
|
+
}) {
|
|
1844
|
+
return operationsByTag.records.bulkInsertTableRecords({
|
|
1845
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
1846
|
+
queryParams: { columns },
|
|
1847
|
+
body: { records },
|
|
1848
|
+
...this.extraProps
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1851
|
+
branchTransaction({
|
|
1852
|
+
workspace,
|
|
1853
|
+
region,
|
|
1854
|
+
database,
|
|
1855
|
+
branch,
|
|
1856
|
+
operations
|
|
1857
|
+
}) {
|
|
1858
|
+
return operationsByTag.records.branchTransaction({
|
|
1859
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1860
|
+
body: { operations },
|
|
1861
|
+
...this.extraProps
|
|
1862
|
+
});
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
class FilesApi {
|
|
1866
|
+
constructor(extraProps) {
|
|
1867
|
+
this.extraProps = extraProps;
|
|
1868
|
+
}
|
|
1869
|
+
getFileItem({
|
|
1870
|
+
workspace,
|
|
1871
|
+
region,
|
|
1872
|
+
database,
|
|
1873
|
+
branch,
|
|
1874
|
+
table,
|
|
1875
|
+
record,
|
|
1876
|
+
column,
|
|
1877
|
+
fileId
|
|
1878
|
+
}) {
|
|
1879
|
+
return operationsByTag.files.getFileItem({
|
|
1880
|
+
pathParams: {
|
|
1881
|
+
workspace,
|
|
1882
|
+
region,
|
|
1883
|
+
dbBranchName: `${database}:${branch}`,
|
|
1884
|
+
tableName: table,
|
|
1885
|
+
recordId: record,
|
|
1886
|
+
columnName: column,
|
|
1887
|
+
fileId
|
|
1888
|
+
},
|
|
1889
|
+
...this.extraProps
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1892
|
+
putFileItem({
|
|
1893
|
+
workspace,
|
|
1894
|
+
region,
|
|
1895
|
+
database,
|
|
1896
|
+
branch,
|
|
1897
|
+
table,
|
|
1898
|
+
record,
|
|
1899
|
+
column,
|
|
1900
|
+
fileId,
|
|
1901
|
+
file
|
|
1902
|
+
}) {
|
|
1903
|
+
return operationsByTag.files.putFileItem({
|
|
1904
|
+
pathParams: {
|
|
1905
|
+
workspace,
|
|
1906
|
+
region,
|
|
1907
|
+
dbBranchName: `${database}:${branch}`,
|
|
1908
|
+
tableName: table,
|
|
1909
|
+
recordId: record,
|
|
1910
|
+
columnName: column,
|
|
1911
|
+
fileId
|
|
1912
|
+
},
|
|
1913
|
+
// @ts-ignore
|
|
1914
|
+
body: file,
|
|
1915
|
+
...this.extraProps
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
deleteFileItem({
|
|
1919
|
+
workspace,
|
|
1920
|
+
region,
|
|
1921
|
+
database,
|
|
1922
|
+
branch,
|
|
1923
|
+
table,
|
|
1924
|
+
record,
|
|
1925
|
+
column,
|
|
1926
|
+
fileId
|
|
1927
|
+
}) {
|
|
1928
|
+
return operationsByTag.files.deleteFileItem({
|
|
1929
|
+
pathParams: {
|
|
1930
|
+
workspace,
|
|
1931
|
+
region,
|
|
1932
|
+
dbBranchName: `${database}:${branch}`,
|
|
1933
|
+
tableName: table,
|
|
1934
|
+
recordId: record,
|
|
1935
|
+
columnName: column,
|
|
1936
|
+
fileId
|
|
1937
|
+
},
|
|
1938
|
+
...this.extraProps
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
getFile({
|
|
1322
1942
|
workspace,
|
|
1323
1943
|
region,
|
|
1324
1944
|
database,
|
|
1325
1945
|
branch,
|
|
1326
1946
|
table,
|
|
1327
|
-
id,
|
|
1328
1947
|
record,
|
|
1329
|
-
|
|
1330
|
-
ifVersion
|
|
1948
|
+
column
|
|
1331
1949
|
}) {
|
|
1332
|
-
return operationsByTag.
|
|
1333
|
-
pathParams: {
|
|
1334
|
-
|
|
1335
|
-
|
|
1950
|
+
return operationsByTag.files.getFile({
|
|
1951
|
+
pathParams: {
|
|
1952
|
+
workspace,
|
|
1953
|
+
region,
|
|
1954
|
+
dbBranchName: `${database}:${branch}`,
|
|
1955
|
+
tableName: table,
|
|
1956
|
+
recordId: record,
|
|
1957
|
+
columnName: column
|
|
1958
|
+
},
|
|
1336
1959
|
...this.extraProps
|
|
1337
1960
|
});
|
|
1338
1961
|
}
|
|
1339
|
-
|
|
1962
|
+
putFile({
|
|
1340
1963
|
workspace,
|
|
1341
1964
|
region,
|
|
1342
1965
|
database,
|
|
1343
1966
|
branch,
|
|
1344
1967
|
table,
|
|
1345
|
-
|
|
1346
|
-
|
|
1968
|
+
record,
|
|
1969
|
+
column,
|
|
1970
|
+
file
|
|
1347
1971
|
}) {
|
|
1348
|
-
return operationsByTag.
|
|
1349
|
-
pathParams: {
|
|
1350
|
-
|
|
1972
|
+
return operationsByTag.files.putFile({
|
|
1973
|
+
pathParams: {
|
|
1974
|
+
workspace,
|
|
1975
|
+
region,
|
|
1976
|
+
dbBranchName: `${database}:${branch}`,
|
|
1977
|
+
tableName: table,
|
|
1978
|
+
recordId: record,
|
|
1979
|
+
columnName: column
|
|
1980
|
+
},
|
|
1981
|
+
body: file,
|
|
1351
1982
|
...this.extraProps
|
|
1352
1983
|
});
|
|
1353
1984
|
}
|
|
1354
|
-
|
|
1985
|
+
deleteFile({
|
|
1355
1986
|
workspace,
|
|
1356
1987
|
region,
|
|
1357
1988
|
database,
|
|
1358
1989
|
branch,
|
|
1359
1990
|
table,
|
|
1360
|
-
|
|
1361
|
-
|
|
1991
|
+
record,
|
|
1992
|
+
column
|
|
1362
1993
|
}) {
|
|
1363
|
-
return operationsByTag.
|
|
1364
|
-
pathParams: {
|
|
1365
|
-
|
|
1366
|
-
|
|
1994
|
+
return operationsByTag.files.deleteFile({
|
|
1995
|
+
pathParams: {
|
|
1996
|
+
workspace,
|
|
1997
|
+
region,
|
|
1998
|
+
dbBranchName: `${database}:${branch}`,
|
|
1999
|
+
tableName: table,
|
|
2000
|
+
recordId: record,
|
|
2001
|
+
columnName: column
|
|
2002
|
+
},
|
|
2003
|
+
...this.extraProps
|
|
2004
|
+
});
|
|
2005
|
+
}
|
|
2006
|
+
fileAccess({
|
|
2007
|
+
workspace,
|
|
2008
|
+
region,
|
|
2009
|
+
fileId,
|
|
2010
|
+
verify
|
|
2011
|
+
}) {
|
|
2012
|
+
return operationsByTag.files.fileAccess({
|
|
2013
|
+
pathParams: {
|
|
2014
|
+
workspace,
|
|
2015
|
+
region,
|
|
2016
|
+
fileId
|
|
2017
|
+
},
|
|
2018
|
+
queryParams: { verify },
|
|
1367
2019
|
...this.extraProps
|
|
1368
2020
|
});
|
|
1369
2021
|
}
|
|
@@ -1427,6 +2079,38 @@ class SearchAndFilterApi {
|
|
|
1427
2079
|
...this.extraProps
|
|
1428
2080
|
});
|
|
1429
2081
|
}
|
|
2082
|
+
vectorSearchTable({
|
|
2083
|
+
workspace,
|
|
2084
|
+
region,
|
|
2085
|
+
database,
|
|
2086
|
+
branch,
|
|
2087
|
+
table,
|
|
2088
|
+
queryVector,
|
|
2089
|
+
column,
|
|
2090
|
+
similarityFunction,
|
|
2091
|
+
size,
|
|
2092
|
+
filter
|
|
2093
|
+
}) {
|
|
2094
|
+
return operationsByTag.searchAndFilter.vectorSearchTable({
|
|
2095
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
2096
|
+
body: { queryVector, column, similarityFunction, size, filter },
|
|
2097
|
+
...this.extraProps
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
2100
|
+
askTable({
|
|
2101
|
+
workspace,
|
|
2102
|
+
region,
|
|
2103
|
+
database,
|
|
2104
|
+
branch,
|
|
2105
|
+
table,
|
|
2106
|
+
options
|
|
2107
|
+
}) {
|
|
2108
|
+
return operationsByTag.searchAndFilter.askTable({
|
|
2109
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
|
2110
|
+
body: { ...options },
|
|
2111
|
+
...this.extraProps
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
1430
2114
|
summarizeTable({
|
|
1431
2115
|
workspace,
|
|
1432
2116
|
region,
|
|
@@ -1627,11 +2311,13 @@ class MigrationsApi {
|
|
|
1627
2311
|
region,
|
|
1628
2312
|
database,
|
|
1629
2313
|
branch,
|
|
1630
|
-
schema
|
|
2314
|
+
schema,
|
|
2315
|
+
schemaOperations,
|
|
2316
|
+
branchOperations
|
|
1631
2317
|
}) {
|
|
1632
2318
|
return operationsByTag.migrations.compareBranchWithUserSchema({
|
|
1633
2319
|
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
1634
|
-
body: { schema },
|
|
2320
|
+
body: { schema, schemaOperations, branchOperations },
|
|
1635
2321
|
...this.extraProps
|
|
1636
2322
|
});
|
|
1637
2323
|
}
|
|
@@ -1641,11 +2327,12 @@ class MigrationsApi {
|
|
|
1641
2327
|
database,
|
|
1642
2328
|
branch,
|
|
1643
2329
|
compare,
|
|
1644
|
-
|
|
2330
|
+
sourceBranchOperations,
|
|
2331
|
+
targetBranchOperations
|
|
1645
2332
|
}) {
|
|
1646
2333
|
return operationsByTag.migrations.compareBranchSchemas({
|
|
1647
2334
|
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
|
1648
|
-
body: {
|
|
2335
|
+
body: { sourceBranchOperations, targetBranchOperations },
|
|
1649
2336
|
...this.extraProps
|
|
1650
2337
|
});
|
|
1651
2338
|
}
|
|
@@ -1688,6 +2375,19 @@ class MigrationsApi {
|
|
|
1688
2375
|
...this.extraProps
|
|
1689
2376
|
});
|
|
1690
2377
|
}
|
|
2378
|
+
pushBranchMigrations({
|
|
2379
|
+
workspace,
|
|
2380
|
+
region,
|
|
2381
|
+
database,
|
|
2382
|
+
branch,
|
|
2383
|
+
migrations
|
|
2384
|
+
}) {
|
|
2385
|
+
return operationsByTag.migrations.pushBranchMigrations({
|
|
2386
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
|
2387
|
+
body: { migrations },
|
|
2388
|
+
...this.extraProps
|
|
2389
|
+
});
|
|
2390
|
+
}
|
|
1691
2391
|
}
|
|
1692
2392
|
class DatabaseApi {
|
|
1693
2393
|
constructor(extraProps) {
|
|
@@ -1739,6 +2439,46 @@ class DatabaseApi {
|
|
|
1739
2439
|
...this.extraProps
|
|
1740
2440
|
});
|
|
1741
2441
|
}
|
|
2442
|
+
renameDatabase({
|
|
2443
|
+
workspace,
|
|
2444
|
+
database,
|
|
2445
|
+
newName
|
|
2446
|
+
}) {
|
|
2447
|
+
return operationsByTag.databases.renameDatabase({
|
|
2448
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2449
|
+
body: { newName },
|
|
2450
|
+
...this.extraProps
|
|
2451
|
+
});
|
|
2452
|
+
}
|
|
2453
|
+
getDatabaseGithubSettings({
|
|
2454
|
+
workspace,
|
|
2455
|
+
database
|
|
2456
|
+
}) {
|
|
2457
|
+
return operationsByTag.databases.getDatabaseGithubSettings({
|
|
2458
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2459
|
+
...this.extraProps
|
|
2460
|
+
});
|
|
2461
|
+
}
|
|
2462
|
+
updateDatabaseGithubSettings({
|
|
2463
|
+
workspace,
|
|
2464
|
+
database,
|
|
2465
|
+
settings
|
|
2466
|
+
}) {
|
|
2467
|
+
return operationsByTag.databases.updateDatabaseGithubSettings({
|
|
2468
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2469
|
+
body: settings,
|
|
2470
|
+
...this.extraProps
|
|
2471
|
+
});
|
|
2472
|
+
}
|
|
2473
|
+
deleteDatabaseGithubSettings({
|
|
2474
|
+
workspace,
|
|
2475
|
+
database
|
|
2476
|
+
}) {
|
|
2477
|
+
return operationsByTag.databases.deleteDatabaseGithubSettings({
|
|
2478
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
|
2479
|
+
...this.extraProps
|
|
2480
|
+
});
|
|
2481
|
+
}
|
|
1742
2482
|
listRegions({ workspace }) {
|
|
1743
2483
|
return operationsByTag.databases.listRegions({
|
|
1744
2484
|
pathParams: { workspaceId: workspace },
|
|
@@ -1748,22 +2488,14 @@ class DatabaseApi {
|
|
|
1748
2488
|
}
|
|
1749
2489
|
|
|
1750
2490
|
class XataApiPlugin {
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
return new XataApiClient({ fetch: fetchImpl, apiKey });
|
|
2491
|
+
build(options) {
|
|
2492
|
+
return new XataApiClient(options);
|
|
1754
2493
|
}
|
|
1755
2494
|
}
|
|
1756
2495
|
|
|
1757
2496
|
class XataPlugin {
|
|
1758
2497
|
}
|
|
1759
2498
|
|
|
1760
|
-
function generateUUID() {
|
|
1761
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
1762
|
-
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
1763
|
-
return v.toString(16);
|
|
1764
|
-
});
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1767
2499
|
function cleanFilter(filter) {
|
|
1768
2500
|
if (!filter)
|
|
1769
2501
|
return void 0;
|
|
@@ -1797,18 +2529,46 @@ class Page {
|
|
|
1797
2529
|
this.meta = meta;
|
|
1798
2530
|
this.records = new RecordArray(this, records);
|
|
1799
2531
|
}
|
|
2532
|
+
/**
|
|
2533
|
+
* Retrieves the next page of results.
|
|
2534
|
+
* @param size Maximum number of results to be retrieved.
|
|
2535
|
+
* @param offset Number of results to skip when retrieving the results.
|
|
2536
|
+
* @returns The next page or results.
|
|
2537
|
+
*/
|
|
1800
2538
|
async nextPage(size, offset) {
|
|
1801
2539
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
|
1802
2540
|
}
|
|
2541
|
+
/**
|
|
2542
|
+
* Retrieves the previous page of results.
|
|
2543
|
+
* @param size Maximum number of results to be retrieved.
|
|
2544
|
+
* @param offset Number of results to skip when retrieving the results.
|
|
2545
|
+
* @returns The previous page or results.
|
|
2546
|
+
*/
|
|
1803
2547
|
async previousPage(size, offset) {
|
|
1804
2548
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
|
1805
2549
|
}
|
|
2550
|
+
/**
|
|
2551
|
+
* Retrieves the start page of results.
|
|
2552
|
+
* @param size Maximum number of results to be retrieved.
|
|
2553
|
+
* @param offset Number of results to skip when retrieving the results.
|
|
2554
|
+
* @returns The start page or results.
|
|
2555
|
+
*/
|
|
1806
2556
|
async startPage(size, offset) {
|
|
1807
2557
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
|
1808
2558
|
}
|
|
2559
|
+
/**
|
|
2560
|
+
* Retrieves the end page of results.
|
|
2561
|
+
* @param size Maximum number of results to be retrieved.
|
|
2562
|
+
* @param offset Number of results to skip when retrieving the results.
|
|
2563
|
+
* @returns The end page or results.
|
|
2564
|
+
*/
|
|
1809
2565
|
async endPage(size, offset) {
|
|
1810
2566
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
|
1811
2567
|
}
|
|
2568
|
+
/**
|
|
2569
|
+
* Shortcut method to check if there will be additional results if the next page of results is retrieved.
|
|
2570
|
+
* @returns Whether or not there will be additional results in the next page of results.
|
|
2571
|
+
*/
|
|
1812
2572
|
hasNextPage() {
|
|
1813
2573
|
return this.meta.page.more;
|
|
1814
2574
|
}
|
|
@@ -1840,25 +2600,54 @@ const _RecordArray = class extends Array {
|
|
|
1840
2600
|
toArray() {
|
|
1841
2601
|
return new Array(...this);
|
|
1842
2602
|
}
|
|
2603
|
+
toSerializable() {
|
|
2604
|
+
return JSON.parse(this.toString());
|
|
2605
|
+
}
|
|
2606
|
+
toString() {
|
|
2607
|
+
return JSON.stringify(this.toArray());
|
|
2608
|
+
}
|
|
1843
2609
|
map(callbackfn, thisArg) {
|
|
1844
2610
|
return this.toArray().map(callbackfn, thisArg);
|
|
1845
2611
|
}
|
|
2612
|
+
/**
|
|
2613
|
+
* Retrieve next page of records
|
|
2614
|
+
*
|
|
2615
|
+
* @returns A new array of objects
|
|
2616
|
+
*/
|
|
1846
2617
|
async nextPage(size, offset) {
|
|
1847
2618
|
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
|
1848
2619
|
return new _RecordArray(newPage);
|
|
1849
2620
|
}
|
|
2621
|
+
/**
|
|
2622
|
+
* Retrieve previous page of records
|
|
2623
|
+
*
|
|
2624
|
+
* @returns A new array of objects
|
|
2625
|
+
*/
|
|
1850
2626
|
async previousPage(size, offset) {
|
|
1851
2627
|
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
|
1852
2628
|
return new _RecordArray(newPage);
|
|
1853
2629
|
}
|
|
2630
|
+
/**
|
|
2631
|
+
* Retrieve start page of records
|
|
2632
|
+
*
|
|
2633
|
+
* @returns A new array of objects
|
|
2634
|
+
*/
|
|
1854
2635
|
async startPage(size, offset) {
|
|
1855
2636
|
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
|
1856
2637
|
return new _RecordArray(newPage);
|
|
1857
2638
|
}
|
|
2639
|
+
/**
|
|
2640
|
+
* Retrieve end page of records
|
|
2641
|
+
*
|
|
2642
|
+
* @returns A new array of objects
|
|
2643
|
+
*/
|
|
1858
2644
|
async endPage(size, offset) {
|
|
1859
2645
|
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
|
1860
2646
|
return new _RecordArray(newPage);
|
|
1861
2647
|
}
|
|
2648
|
+
/**
|
|
2649
|
+
* @returns Boolean indicating if there is a next page
|
|
2650
|
+
*/
|
|
1862
2651
|
hasNextPage() {
|
|
1863
2652
|
return __privateGet$6(this, _page).meta.page.more;
|
|
1864
2653
|
}
|
|
@@ -1895,7 +2684,8 @@ const _Query = class {
|
|
|
1895
2684
|
__privateAdd$5(this, _table$1, void 0);
|
|
1896
2685
|
__privateAdd$5(this, _repository, void 0);
|
|
1897
2686
|
__privateAdd$5(this, _data, { filter: {} });
|
|
1898
|
-
|
|
2687
|
+
// Implements pagination
|
|
2688
|
+
this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
|
|
1899
2689
|
this.records = new RecordArray(this, []);
|
|
1900
2690
|
__privateSet$5(this, _table$1, table);
|
|
1901
2691
|
if (repository) {
|
|
@@ -1911,8 +2701,10 @@ const _Query = class {
|
|
|
1911
2701
|
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
|
1912
2702
|
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
|
1913
2703
|
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
|
|
2704
|
+
__privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
|
|
1914
2705
|
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
|
1915
2706
|
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
|
2707
|
+
__privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
|
|
1916
2708
|
this.any = this.any.bind(this);
|
|
1917
2709
|
this.all = this.all.bind(this);
|
|
1918
2710
|
this.not = this.not.bind(this);
|
|
@@ -1930,18 +2722,38 @@ const _Query = class {
|
|
|
1930
2722
|
const key = JSON.stringify({ columns, filter, sort, pagination });
|
|
1931
2723
|
return toBase64(key);
|
|
1932
2724
|
}
|
|
2725
|
+
/**
|
|
2726
|
+
* Builds a new query object representing a logical OR between the given subqueries.
|
|
2727
|
+
* @param queries An array of subqueries.
|
|
2728
|
+
* @returns A new Query object.
|
|
2729
|
+
*/
|
|
1933
2730
|
any(...queries) {
|
|
1934
2731
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
1935
2732
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
|
1936
2733
|
}
|
|
2734
|
+
/**
|
|
2735
|
+
* Builds a new query object representing a logical AND between the given subqueries.
|
|
2736
|
+
* @param queries An array of subqueries.
|
|
2737
|
+
* @returns A new Query object.
|
|
2738
|
+
*/
|
|
1937
2739
|
all(...queries) {
|
|
1938
2740
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
1939
2741
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
|
1940
2742
|
}
|
|
2743
|
+
/**
|
|
2744
|
+
* Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
|
|
2745
|
+
* @param queries An array of subqueries.
|
|
2746
|
+
* @returns A new Query object.
|
|
2747
|
+
*/
|
|
1941
2748
|
not(...queries) {
|
|
1942
2749
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
1943
2750
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
|
1944
2751
|
}
|
|
2752
|
+
/**
|
|
2753
|
+
* Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
|
|
2754
|
+
* @param queries An array of subqueries.
|
|
2755
|
+
* @returns A new Query object.
|
|
2756
|
+
*/
|
|
1945
2757
|
none(...queries) {
|
|
1946
2758
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
1947
2759
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
|
@@ -1964,6 +2776,11 @@ const _Query = class {
|
|
|
1964
2776
|
const sort = [...originalSort, { column, direction }];
|
|
1965
2777
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
|
1966
2778
|
}
|
|
2779
|
+
/**
|
|
2780
|
+
* Builds a new query specifying the set of columns to be returned in the query response.
|
|
2781
|
+
* @param columns Array of column names to be returned by the query.
|
|
2782
|
+
* @returns A new Query object.
|
|
2783
|
+
*/
|
|
1967
2784
|
select(columns) {
|
|
1968
2785
|
return new _Query(
|
|
1969
2786
|
__privateGet$5(this, _repository),
|
|
@@ -1976,6 +2793,12 @@ const _Query = class {
|
|
|
1976
2793
|
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
|
1977
2794
|
return __privateGet$5(this, _repository).query(query);
|
|
1978
2795
|
}
|
|
2796
|
+
/**
|
|
2797
|
+
* Get results in an iterator
|
|
2798
|
+
*
|
|
2799
|
+
* @async
|
|
2800
|
+
* @returns Async interable of results
|
|
2801
|
+
*/
|
|
1979
2802
|
async *[Symbol.asyncIterator]() {
|
|
1980
2803
|
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
|
1981
2804
|
yield record;
|
|
@@ -2036,21 +2859,49 @@ const _Query = class {
|
|
|
2036
2859
|
);
|
|
2037
2860
|
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
|
2038
2861
|
}
|
|
2862
|
+
/**
|
|
2863
|
+
* Builds a new query object adding a cache TTL in milliseconds.
|
|
2864
|
+
* @param ttl The cache TTL in milliseconds.
|
|
2865
|
+
* @returns A new Query object.
|
|
2866
|
+
*/
|
|
2039
2867
|
cache(ttl) {
|
|
2040
2868
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
|
2041
2869
|
}
|
|
2870
|
+
/**
|
|
2871
|
+
* Retrieve next page of records
|
|
2872
|
+
*
|
|
2873
|
+
* @returns A new page object.
|
|
2874
|
+
*/
|
|
2042
2875
|
nextPage(size, offset) {
|
|
2043
2876
|
return this.startPage(size, offset);
|
|
2044
2877
|
}
|
|
2878
|
+
/**
|
|
2879
|
+
* Retrieve previous page of records
|
|
2880
|
+
*
|
|
2881
|
+
* @returns A new page object
|
|
2882
|
+
*/
|
|
2045
2883
|
previousPage(size, offset) {
|
|
2046
2884
|
return this.startPage(size, offset);
|
|
2047
2885
|
}
|
|
2886
|
+
/**
|
|
2887
|
+
* Retrieve start page of records
|
|
2888
|
+
*
|
|
2889
|
+
* @returns A new page object
|
|
2890
|
+
*/
|
|
2048
2891
|
startPage(size, offset) {
|
|
2049
2892
|
return this.getPaginated({ pagination: { size, offset } });
|
|
2050
2893
|
}
|
|
2894
|
+
/**
|
|
2895
|
+
* Retrieve last page of records
|
|
2896
|
+
*
|
|
2897
|
+
* @returns A new page object
|
|
2898
|
+
*/
|
|
2051
2899
|
endPage(size, offset) {
|
|
2052
2900
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
|
2053
2901
|
}
|
|
2902
|
+
/**
|
|
2903
|
+
* @returns Boolean indicating if there is a next page
|
|
2904
|
+
*/
|
|
2054
2905
|
hasNextPage() {
|
|
2055
2906
|
return this.meta.page.more;
|
|
2056
2907
|
}
|
|
@@ -2090,7 +2941,11 @@ function isSortFilterString(value) {
|
|
|
2090
2941
|
return isString(value);
|
|
2091
2942
|
}
|
|
2092
2943
|
function isSortFilterBase(filter) {
|
|
2093
|
-
return isObject(filter) && Object.
|
|
2944
|
+
return isObject(filter) && Object.entries(filter).every(([key, value]) => {
|
|
2945
|
+
if (key === "*")
|
|
2946
|
+
return value === "random";
|
|
2947
|
+
return value === "asc" || value === "desc";
|
|
2948
|
+
});
|
|
2094
2949
|
}
|
|
2095
2950
|
function isSortFilterObject(filter) {
|
|
2096
2951
|
return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
|
|
@@ -2131,7 +2986,8 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
|
2131
2986
|
__accessCheck$4(obj, member, "access private method");
|
|
2132
2987
|
return method;
|
|
2133
2988
|
};
|
|
2134
|
-
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn,
|
|
2989
|
+
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;
|
|
2990
|
+
const BULK_OPERATION_MAX_SIZE = 1e3;
|
|
2135
2991
|
class Repository extends Query {
|
|
2136
2992
|
}
|
|
2137
2993
|
class RestRepository extends Query {
|
|
@@ -2143,10 +2999,12 @@ class RestRepository extends Query {
|
|
|
2143
2999
|
);
|
|
2144
3000
|
__privateAdd$4(this, _insertRecordWithoutId);
|
|
2145
3001
|
__privateAdd$4(this, _insertRecordWithId);
|
|
2146
|
-
__privateAdd$4(this,
|
|
3002
|
+
__privateAdd$4(this, _insertRecords);
|
|
2147
3003
|
__privateAdd$4(this, _updateRecordWithID);
|
|
3004
|
+
__privateAdd$4(this, _updateRecords);
|
|
2148
3005
|
__privateAdd$4(this, _upsertRecordWithID);
|
|
2149
3006
|
__privateAdd$4(this, _deleteRecord);
|
|
3007
|
+
__privateAdd$4(this, _deleteRecords);
|
|
2150
3008
|
__privateAdd$4(this, _setCacheQuery);
|
|
2151
3009
|
__privateAdd$4(this, _getCacheQuery);
|
|
2152
3010
|
__privateAdd$4(this, _getSchemaTables$1);
|
|
@@ -2160,10 +3018,7 @@ class RestRepository extends Query {
|
|
|
2160
3018
|
__privateSet$4(this, _db, options.db);
|
|
2161
3019
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
|
2162
3020
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
|
2163
|
-
__privateSet$4(this, _getFetchProps,
|
|
2164
|
-
const props = await options.pluginOptions.getFetchProps();
|
|
2165
|
-
return { ...props, sessionID: generateUUID() };
|
|
2166
|
-
});
|
|
3021
|
+
__privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
|
|
2167
3022
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
|
2168
3023
|
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
|
2169
3024
|
return trace(name, fn, {
|
|
@@ -2180,20 +3035,22 @@ class RestRepository extends Query {
|
|
|
2180
3035
|
if (Array.isArray(a)) {
|
|
2181
3036
|
if (a.length === 0)
|
|
2182
3037
|
return [];
|
|
2183
|
-
const
|
|
2184
|
-
|
|
3038
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
|
3039
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
3040
|
+
const result = await this.read(ids, columns);
|
|
3041
|
+
return result;
|
|
2185
3042
|
}
|
|
2186
3043
|
if (isString(a) && isObject(b)) {
|
|
2187
3044
|
if (a === "")
|
|
2188
3045
|
throw new Error("The id can't be empty");
|
|
2189
3046
|
const columns = isStringArray(c) ? c : void 0;
|
|
2190
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
|
3047
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
|
2191
3048
|
}
|
|
2192
3049
|
if (isObject(a) && isString(a.id)) {
|
|
2193
3050
|
if (a.id === "")
|
|
2194
3051
|
throw new Error("The id can't be empty");
|
|
2195
3052
|
const columns = isStringArray(b) ? b : void 0;
|
|
2196
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
|
3053
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
|
2197
3054
|
}
|
|
2198
3055
|
if (isObject(a)) {
|
|
2199
3056
|
const columns = isStringArray(b) ? b : void 0;
|
|
@@ -2218,7 +3075,6 @@ class RestRepository extends Query {
|
|
|
2218
3075
|
}
|
|
2219
3076
|
const id = extractId(a);
|
|
2220
3077
|
if (id) {
|
|
2221
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2222
3078
|
try {
|
|
2223
3079
|
const response = await getRecord({
|
|
2224
3080
|
pathParams: {
|
|
@@ -2229,7 +3085,7 @@ class RestRepository extends Query {
|
|
|
2229
3085
|
recordId: id
|
|
2230
3086
|
},
|
|
2231
3087
|
queryParams: { columns },
|
|
2232
|
-
...
|
|
3088
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2233
3089
|
});
|
|
2234
3090
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
2235
3091
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
@@ -2268,19 +3124,29 @@ class RestRepository extends Query {
|
|
|
2268
3124
|
if (Array.isArray(a)) {
|
|
2269
3125
|
if (a.length === 0)
|
|
2270
3126
|
return [];
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
3127
|
+
const existing = await this.read(a, ["id"]);
|
|
3128
|
+
const updates = a.filter((_item, index) => existing[index] !== null);
|
|
3129
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
|
|
3130
|
+
ifVersion,
|
|
3131
|
+
upsert: false
|
|
3132
|
+
});
|
|
2274
3133
|
const columns = isStringArray(b) ? b : ["*"];
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
if (isString(a) && isObject(b)) {
|
|
2278
|
-
const columns = isStringArray(c) ? c : void 0;
|
|
2279
|
-
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
|
3134
|
+
const result = await this.read(a, columns);
|
|
3135
|
+
return result;
|
|
2280
3136
|
}
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
3137
|
+
try {
|
|
3138
|
+
if (isString(a) && isObject(b)) {
|
|
3139
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
3140
|
+
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
|
3141
|
+
}
|
|
3142
|
+
if (isObject(a) && isString(a.id)) {
|
|
3143
|
+
const columns = isStringArray(b) ? b : void 0;
|
|
3144
|
+
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
|
3145
|
+
}
|
|
3146
|
+
} catch (error) {
|
|
3147
|
+
if (error.status === 422)
|
|
3148
|
+
return null;
|
|
3149
|
+
throw error;
|
|
2284
3150
|
}
|
|
2285
3151
|
throw new Error("Invalid arguments for update method");
|
|
2286
3152
|
});
|
|
@@ -2310,11 +3176,13 @@ class RestRepository extends Query {
|
|
|
2310
3176
|
if (Array.isArray(a)) {
|
|
2311
3177
|
if (a.length === 0)
|
|
2312
3178
|
return [];
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
3179
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
|
|
3180
|
+
ifVersion,
|
|
3181
|
+
upsert: true
|
|
3182
|
+
});
|
|
2316
3183
|
const columns = isStringArray(b) ? b : ["*"];
|
|
2317
|
-
|
|
3184
|
+
const result = await this.read(a, columns);
|
|
3185
|
+
return result;
|
|
2318
3186
|
}
|
|
2319
3187
|
if (isString(a) && isObject(b)) {
|
|
2320
3188
|
const columns = isStringArray(c) ? c : void 0;
|
|
@@ -2333,8 +3201,10 @@ class RestRepository extends Query {
|
|
|
2333
3201
|
if (Array.isArray(a)) {
|
|
2334
3202
|
if (a.length === 0)
|
|
2335
3203
|
return [];
|
|
3204
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
|
2336
3205
|
const columns = isStringArray(b) ? b : ["*"];
|
|
2337
|
-
|
|
3206
|
+
const result = await this.read(ids, columns);
|
|
3207
|
+
return result;
|
|
2338
3208
|
}
|
|
2339
3209
|
if (isString(a) && isObject(b)) {
|
|
2340
3210
|
const columns = isStringArray(c) ? c : void 0;
|
|
@@ -2352,10 +3222,17 @@ class RestRepository extends Query {
|
|
|
2352
3222
|
if (Array.isArray(a)) {
|
|
2353
3223
|
if (a.length === 0)
|
|
2354
3224
|
return [];
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
3225
|
+
const ids = a.map((o) => {
|
|
3226
|
+
if (isString(o))
|
|
3227
|
+
return o;
|
|
3228
|
+
if (isString(o.id))
|
|
3229
|
+
return o.id;
|
|
3230
|
+
throw new Error("Invalid arguments for delete method");
|
|
3231
|
+
});
|
|
3232
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
3233
|
+
const result = await this.read(a, columns);
|
|
3234
|
+
await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
|
|
3235
|
+
return result;
|
|
2359
3236
|
}
|
|
2360
3237
|
if (isString(a)) {
|
|
2361
3238
|
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
|
|
@@ -2386,7 +3263,6 @@ class RestRepository extends Query {
|
|
|
2386
3263
|
}
|
|
2387
3264
|
async search(query, options = {}) {
|
|
2388
3265
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
|
2389
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2390
3266
|
const { records } = await searchTable({
|
|
2391
3267
|
pathParams: {
|
|
2392
3268
|
workspace: "{workspaceId}",
|
|
@@ -2400,9 +3276,33 @@ class RestRepository extends Query {
|
|
|
2400
3276
|
prefix: options.prefix,
|
|
2401
3277
|
highlight: options.highlight,
|
|
2402
3278
|
filter: options.filter,
|
|
2403
|
-
boosters: options.boosters
|
|
3279
|
+
boosters: options.boosters,
|
|
3280
|
+
page: options.page,
|
|
3281
|
+
target: options.target
|
|
3282
|
+
},
|
|
3283
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3284
|
+
});
|
|
3285
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
3286
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
|
3287
|
+
});
|
|
3288
|
+
}
|
|
3289
|
+
async vectorSearch(column, query, options) {
|
|
3290
|
+
return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
|
|
3291
|
+
const { records } = await vectorSearchTable({
|
|
3292
|
+
pathParams: {
|
|
3293
|
+
workspace: "{workspaceId}",
|
|
3294
|
+
dbBranchName: "{dbBranch}",
|
|
3295
|
+
region: "{region}",
|
|
3296
|
+
tableName: __privateGet$4(this, _table)
|
|
3297
|
+
},
|
|
3298
|
+
body: {
|
|
3299
|
+
column,
|
|
3300
|
+
queryVector: query,
|
|
3301
|
+
similarityFunction: options?.similarityFunction,
|
|
3302
|
+
size: options?.size,
|
|
3303
|
+
filter: options?.filter
|
|
2404
3304
|
},
|
|
2405
|
-
...
|
|
3305
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2406
3306
|
});
|
|
2407
3307
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
2408
3308
|
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
|
@@ -2410,7 +3310,6 @@ class RestRepository extends Query {
|
|
|
2410
3310
|
}
|
|
2411
3311
|
async aggregate(aggs, filter) {
|
|
2412
3312
|
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
|
2413
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2414
3313
|
const result = await aggregateTable({
|
|
2415
3314
|
pathParams: {
|
|
2416
3315
|
workspace: "{workspaceId}",
|
|
@@ -2419,7 +3318,7 @@ class RestRepository extends Query {
|
|
|
2419
3318
|
tableName: __privateGet$4(this, _table)
|
|
2420
3319
|
},
|
|
2421
3320
|
body: { aggs, filter },
|
|
2422
|
-
...
|
|
3321
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2423
3322
|
});
|
|
2424
3323
|
return result;
|
|
2425
3324
|
});
|
|
@@ -2430,7 +3329,6 @@ class RestRepository extends Query {
|
|
|
2430
3329
|
if (cacheQuery)
|
|
2431
3330
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
|
2432
3331
|
const data = query.getQueryOptions();
|
|
2433
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2434
3332
|
const { meta, records: objects } = await queryTable({
|
|
2435
3333
|
pathParams: {
|
|
2436
3334
|
workspace: "{workspaceId}",
|
|
@@ -2442,9 +3340,11 @@ class RestRepository extends Query {
|
|
|
2442
3340
|
filter: cleanFilter(data.filter),
|
|
2443
3341
|
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
|
2444
3342
|
page: data.pagination,
|
|
2445
|
-
columns: data.columns ?? ["*"]
|
|
3343
|
+
columns: data.columns ?? ["*"],
|
|
3344
|
+
consistency: data.consistency
|
|
2446
3345
|
},
|
|
2447
|
-
|
|
3346
|
+
fetchOptions: data.fetchOptions,
|
|
3347
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2448
3348
|
});
|
|
2449
3349
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
2450
3350
|
const records = objects.map(
|
|
@@ -2457,7 +3357,6 @@ class RestRepository extends Query {
|
|
|
2457
3357
|
async summarizeTable(query, summaries, summariesFilter) {
|
|
2458
3358
|
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
|
2459
3359
|
const data = query.getQueryOptions();
|
|
2460
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2461
3360
|
const result = await summarizeTable({
|
|
2462
3361
|
pathParams: {
|
|
2463
3362
|
workspace: "{workspaceId}",
|
|
@@ -2469,15 +3368,44 @@ class RestRepository extends Query {
|
|
|
2469
3368
|
filter: cleanFilter(data.filter),
|
|
2470
3369
|
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
|
2471
3370
|
columns: data.columns,
|
|
3371
|
+
consistency: data.consistency,
|
|
2472
3372
|
page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
|
|
2473
3373
|
summaries,
|
|
2474
3374
|
summariesFilter
|
|
2475
3375
|
},
|
|
2476
|
-
...
|
|
3376
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2477
3377
|
});
|
|
2478
3378
|
return result;
|
|
2479
3379
|
});
|
|
2480
3380
|
}
|
|
3381
|
+
ask(question, options) {
|
|
3382
|
+
const params = {
|
|
3383
|
+
pathParams: {
|
|
3384
|
+
workspace: "{workspaceId}",
|
|
3385
|
+
dbBranchName: "{dbBranch}",
|
|
3386
|
+
region: "{region}",
|
|
3387
|
+
tableName: __privateGet$4(this, _table)
|
|
3388
|
+
},
|
|
3389
|
+
body: {
|
|
3390
|
+
question,
|
|
3391
|
+
...options
|
|
3392
|
+
},
|
|
3393
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3394
|
+
};
|
|
3395
|
+
if (options?.onMessage) {
|
|
3396
|
+
fetchSSERequest({
|
|
3397
|
+
endpoint: "dataPlane",
|
|
3398
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
|
3399
|
+
method: "POST",
|
|
3400
|
+
onMessage: (message) => {
|
|
3401
|
+
options.onMessage?.({ answer: message.text, records: message.records });
|
|
3402
|
+
},
|
|
3403
|
+
...params
|
|
3404
|
+
});
|
|
3405
|
+
} else {
|
|
3406
|
+
return askTable(params);
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
2481
3409
|
}
|
|
2482
3410
|
_table = new WeakMap();
|
|
2483
3411
|
_getFetchProps = new WeakMap();
|
|
@@ -2487,7 +3415,6 @@ _schemaTables$2 = new WeakMap();
|
|
|
2487
3415
|
_trace = new WeakMap();
|
|
2488
3416
|
_insertRecordWithoutId = new WeakSet();
|
|
2489
3417
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
2490
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2491
3418
|
const record = transformObjectLinks(object);
|
|
2492
3419
|
const response = await insertRecord({
|
|
2493
3420
|
pathParams: {
|
|
@@ -2498,14 +3425,13 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
|
2498
3425
|
},
|
|
2499
3426
|
queryParams: { columns },
|
|
2500
3427
|
body: record,
|
|
2501
|
-
...
|
|
3428
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2502
3429
|
});
|
|
2503
3430
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
2504
3431
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
2505
3432
|
};
|
|
2506
3433
|
_insertRecordWithId = new WeakSet();
|
|
2507
3434
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
|
2508
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2509
3435
|
const record = transformObjectLinks(object);
|
|
2510
3436
|
const response = await insertRecordWithID({
|
|
2511
3437
|
pathParams: {
|
|
@@ -2517,36 +3443,43 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
|
|
|
2517
3443
|
},
|
|
2518
3444
|
body: record,
|
|
2519
3445
|
queryParams: { createOnly, columns, ifVersion },
|
|
2520
|
-
...
|
|
3446
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2521
3447
|
});
|
|
2522
3448
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
2523
3449
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
2524
3450
|
};
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
const
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
}
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
3451
|
+
_insertRecords = new WeakSet();
|
|
3452
|
+
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
|
3453
|
+
const chunkedOperations = chunk(
|
|
3454
|
+
objects.map((object) => ({
|
|
3455
|
+
insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
|
|
3456
|
+
})),
|
|
3457
|
+
BULK_OPERATION_MAX_SIZE
|
|
3458
|
+
);
|
|
3459
|
+
const ids = [];
|
|
3460
|
+
for (const operations of chunkedOperations) {
|
|
3461
|
+
const { results } = await branchTransaction({
|
|
3462
|
+
pathParams: {
|
|
3463
|
+
workspace: "{workspaceId}",
|
|
3464
|
+
dbBranchName: "{dbBranch}",
|
|
3465
|
+
region: "{region}"
|
|
3466
|
+
},
|
|
3467
|
+
body: { operations },
|
|
3468
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3469
|
+
});
|
|
3470
|
+
for (const result of results) {
|
|
3471
|
+
if (result.operation === "insert") {
|
|
3472
|
+
ids.push(result.id);
|
|
3473
|
+
} else {
|
|
3474
|
+
ids.push(null);
|
|
3475
|
+
}
|
|
3476
|
+
}
|
|
2542
3477
|
}
|
|
2543
|
-
|
|
2544
|
-
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
|
|
3478
|
+
return ids;
|
|
2545
3479
|
};
|
|
2546
3480
|
_updateRecordWithID = new WeakSet();
|
|
2547
3481
|
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
|
2548
|
-
const
|
|
2549
|
-
const record = transformObjectLinks(object);
|
|
3482
|
+
const { id: _id, ...record } = transformObjectLinks(object);
|
|
2550
3483
|
try {
|
|
2551
3484
|
const response = await updateRecordWithID({
|
|
2552
3485
|
pathParams: {
|
|
@@ -2558,7 +3491,7 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
|
2558
3491
|
},
|
|
2559
3492
|
queryParams: { columns, ifVersion },
|
|
2560
3493
|
body: record,
|
|
2561
|
-
...
|
|
3494
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2562
3495
|
});
|
|
2563
3496
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
2564
3497
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
@@ -2569,9 +3502,37 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
|
2569
3502
|
throw e;
|
|
2570
3503
|
}
|
|
2571
3504
|
};
|
|
3505
|
+
_updateRecords = new WeakSet();
|
|
3506
|
+
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
|
3507
|
+
const chunkedOperations = chunk(
|
|
3508
|
+
objects.map(({ id, ...object }) => ({
|
|
3509
|
+
update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
|
|
3510
|
+
})),
|
|
3511
|
+
BULK_OPERATION_MAX_SIZE
|
|
3512
|
+
);
|
|
3513
|
+
const ids = [];
|
|
3514
|
+
for (const operations of chunkedOperations) {
|
|
3515
|
+
const { results } = await branchTransaction({
|
|
3516
|
+
pathParams: {
|
|
3517
|
+
workspace: "{workspaceId}",
|
|
3518
|
+
dbBranchName: "{dbBranch}",
|
|
3519
|
+
region: "{region}"
|
|
3520
|
+
},
|
|
3521
|
+
body: { operations },
|
|
3522
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3523
|
+
});
|
|
3524
|
+
for (const result of results) {
|
|
3525
|
+
if (result.operation === "update") {
|
|
3526
|
+
ids.push(result.id);
|
|
3527
|
+
} else {
|
|
3528
|
+
ids.push(null);
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
}
|
|
3532
|
+
return ids;
|
|
3533
|
+
};
|
|
2572
3534
|
_upsertRecordWithID = new WeakSet();
|
|
2573
3535
|
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
|
2574
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2575
3536
|
const response = await upsertRecordWithID({
|
|
2576
3537
|
pathParams: {
|
|
2577
3538
|
workspace: "{workspaceId}",
|
|
@@ -2582,14 +3543,13 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
|
2582
3543
|
},
|
|
2583
3544
|
queryParams: { columns, ifVersion },
|
|
2584
3545
|
body: object,
|
|
2585
|
-
...
|
|
3546
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2586
3547
|
});
|
|
2587
3548
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
2588
3549
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
2589
3550
|
};
|
|
2590
3551
|
_deleteRecord = new WeakSet();
|
|
2591
3552
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
2592
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2593
3553
|
try {
|
|
2594
3554
|
const response = await deleteRecord({
|
|
2595
3555
|
pathParams: {
|
|
@@ -2600,7 +3560,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
|
2600
3560
|
recordId
|
|
2601
3561
|
},
|
|
2602
3562
|
queryParams: { columns },
|
|
2603
|
-
...
|
|
3563
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2604
3564
|
});
|
|
2605
3565
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
2606
3566
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
|
@@ -2611,17 +3571,36 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
|
2611
3571
|
throw e;
|
|
2612
3572
|
}
|
|
2613
3573
|
};
|
|
3574
|
+
_deleteRecords = new WeakSet();
|
|
3575
|
+
deleteRecords_fn = async function(recordIds) {
|
|
3576
|
+
const chunkedOperations = chunk(
|
|
3577
|
+
recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
|
3578
|
+
BULK_OPERATION_MAX_SIZE
|
|
3579
|
+
);
|
|
3580
|
+
for (const operations of chunkedOperations) {
|
|
3581
|
+
await branchTransaction({
|
|
3582
|
+
pathParams: {
|
|
3583
|
+
workspace: "{workspaceId}",
|
|
3584
|
+
dbBranchName: "{dbBranch}",
|
|
3585
|
+
region: "{region}"
|
|
3586
|
+
},
|
|
3587
|
+
body: { operations },
|
|
3588
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
3589
|
+
});
|
|
3590
|
+
}
|
|
3591
|
+
};
|
|
2614
3592
|
_setCacheQuery = new WeakSet();
|
|
2615
3593
|
setCacheQuery_fn = async function(query, meta, records) {
|
|
2616
|
-
await __privateGet$4(this, _cache)
|
|
3594
|
+
await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
|
|
2617
3595
|
};
|
|
2618
3596
|
_getCacheQuery = new WeakSet();
|
|
2619
3597
|
getCacheQuery_fn = async function(query) {
|
|
2620
3598
|
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
|
2621
|
-
const result = await __privateGet$4(this, _cache)
|
|
3599
|
+
const result = await __privateGet$4(this, _cache)?.get(key);
|
|
2622
3600
|
if (!result)
|
|
2623
3601
|
return null;
|
|
2624
|
-
const
|
|
3602
|
+
const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
|
|
3603
|
+
const { cache: ttl = defaultTTL } = query.getQueryOptions();
|
|
2625
3604
|
if (ttl < 0)
|
|
2626
3605
|
return null;
|
|
2627
3606
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
|
@@ -2631,10 +3610,9 @@ _getSchemaTables$1 = new WeakSet();
|
|
|
2631
3610
|
getSchemaTables_fn$1 = async function() {
|
|
2632
3611
|
if (__privateGet$4(this, _schemaTables$2))
|
|
2633
3612
|
return __privateGet$4(this, _schemaTables$2);
|
|
2634
|
-
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
2635
3613
|
const { schema } = await getBranchDetails({
|
|
2636
3614
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
2637
|
-
...
|
|
3615
|
+
...__privateGet$4(this, _getFetchProps).call(this)
|
|
2638
3616
|
});
|
|
2639
3617
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
|
2640
3618
|
return schema.tables;
|
|
@@ -2647,23 +3625,23 @@ const transformObjectLinks = (object) => {
|
|
|
2647
3625
|
}, {});
|
|
2648
3626
|
};
|
|
2649
3627
|
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2650
|
-
const
|
|
3628
|
+
const data = {};
|
|
2651
3629
|
const { xata, ...rest } = object ?? {};
|
|
2652
|
-
Object.assign(
|
|
3630
|
+
Object.assign(data, rest);
|
|
2653
3631
|
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
|
2654
3632
|
if (!columns)
|
|
2655
3633
|
console.error(`Table ${table} not found in schema`);
|
|
2656
3634
|
for (const column of columns ?? []) {
|
|
2657
3635
|
if (!isValidColumn(selectedColumns, column))
|
|
2658
3636
|
continue;
|
|
2659
|
-
const value =
|
|
3637
|
+
const value = data[column.name];
|
|
2660
3638
|
switch (column.type) {
|
|
2661
3639
|
case "datetime": {
|
|
2662
|
-
const date = value !== void 0 ? new Date(value) :
|
|
2663
|
-
if (date && isNaN(date.getTime())) {
|
|
3640
|
+
const date = value !== void 0 ? new Date(value) : null;
|
|
3641
|
+
if (date !== null && isNaN(date.getTime())) {
|
|
2664
3642
|
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
|
2665
|
-
} else
|
|
2666
|
-
|
|
3643
|
+
} else {
|
|
3644
|
+
data[column.name] = date;
|
|
2667
3645
|
}
|
|
2668
3646
|
break;
|
|
2669
3647
|
}
|
|
@@ -2682,48 +3660,55 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
|
2682
3660
|
}
|
|
2683
3661
|
return acc;
|
|
2684
3662
|
}, []);
|
|
2685
|
-
|
|
3663
|
+
data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
|
|
2686
3664
|
} else {
|
|
2687
|
-
|
|
3665
|
+
data[column.name] = null;
|
|
2688
3666
|
}
|
|
2689
3667
|
break;
|
|
2690
3668
|
}
|
|
2691
3669
|
default:
|
|
2692
|
-
|
|
3670
|
+
data[column.name] = value ?? null;
|
|
2693
3671
|
if (column.notNull === true && value === null) {
|
|
2694
3672
|
console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
|
|
2695
3673
|
}
|
|
2696
3674
|
break;
|
|
2697
3675
|
}
|
|
2698
3676
|
}
|
|
2699
|
-
|
|
2700
|
-
|
|
3677
|
+
const record = { ...data };
|
|
3678
|
+
const serializable = { xata, ...transformObjectLinks(data) };
|
|
3679
|
+
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
|
3680
|
+
record.read = function(columns2) {
|
|
3681
|
+
return db[table].read(record["id"], columns2);
|
|
2701
3682
|
};
|
|
2702
|
-
|
|
3683
|
+
record.update = function(data2, b, c) {
|
|
2703
3684
|
const columns2 = isStringArray(b) ? b : ["*"];
|
|
2704
3685
|
const ifVersion = parseIfVersion(b, c);
|
|
2705
|
-
return db[table].update(
|
|
3686
|
+
return db[table].update(record["id"], data2, columns2, { ifVersion });
|
|
2706
3687
|
};
|
|
2707
|
-
|
|
3688
|
+
record.replace = function(data2, b, c) {
|
|
2708
3689
|
const columns2 = isStringArray(b) ? b : ["*"];
|
|
2709
3690
|
const ifVersion = parseIfVersion(b, c);
|
|
2710
|
-
return db[table].createOrReplace(
|
|
3691
|
+
return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
|
|
3692
|
+
};
|
|
3693
|
+
record.delete = function() {
|
|
3694
|
+
return db[table].delete(record["id"]);
|
|
2711
3695
|
};
|
|
2712
|
-
|
|
2713
|
-
|
|
3696
|
+
record.xata = Object.freeze(metadata);
|
|
3697
|
+
record.getMetadata = function() {
|
|
3698
|
+
return record.xata;
|
|
2714
3699
|
};
|
|
2715
|
-
|
|
2716
|
-
return
|
|
3700
|
+
record.toSerializable = function() {
|
|
3701
|
+
return JSON.parse(JSON.stringify(serializable));
|
|
2717
3702
|
};
|
|
2718
|
-
|
|
2719
|
-
|
|
3703
|
+
record.toString = function() {
|
|
3704
|
+
return JSON.stringify(transformObjectLinks(serializable));
|
|
3705
|
+
};
|
|
3706
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
|
3707
|
+
Object.defineProperty(record, prop, { enumerable: false });
|
|
2720
3708
|
}
|
|
2721
|
-
Object.freeze(
|
|
2722
|
-
return
|
|
3709
|
+
Object.freeze(record);
|
|
3710
|
+
return record;
|
|
2723
3711
|
};
|
|
2724
|
-
function isResponseWithRecords(value) {
|
|
2725
|
-
return isObject(value) && Array.isArray(value.records);
|
|
2726
|
-
}
|
|
2727
3712
|
function extractId(value) {
|
|
2728
3713
|
if (isString(value))
|
|
2729
3714
|
return value;
|
|
@@ -2906,19 +3891,19 @@ class SearchPlugin extends XataPlugin {
|
|
|
2906
3891
|
__privateAdd$1(this, _schemaTables, void 0);
|
|
2907
3892
|
__privateSet$1(this, _schemaTables, schemaTables);
|
|
2908
3893
|
}
|
|
2909
|
-
build(
|
|
3894
|
+
build(pluginOptions) {
|
|
2910
3895
|
return {
|
|
2911
3896
|
all: async (query, options = {}) => {
|
|
2912
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
|
2913
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
|
3897
|
+
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
|
3898
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
|
2914
3899
|
return records.map((record) => {
|
|
2915
3900
|
const { table = "orphan" } = record.xata;
|
|
2916
3901
|
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
|
2917
3902
|
});
|
|
2918
3903
|
},
|
|
2919
3904
|
byTable: async (query, options = {}) => {
|
|
2920
|
-
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options,
|
|
2921
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this,
|
|
3905
|
+
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
|
3906
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
|
2922
3907
|
return records.reduce((acc, record) => {
|
|
2923
3908
|
const { table = "orphan" } = record.xata;
|
|
2924
3909
|
const items = acc[table] ?? [];
|
|
@@ -2931,113 +3916,40 @@ class SearchPlugin extends XataPlugin {
|
|
|
2931
3916
|
}
|
|
2932
3917
|
_schemaTables = new WeakMap();
|
|
2933
3918
|
_search = new WeakSet();
|
|
2934
|
-
search_fn = async function(query, options,
|
|
2935
|
-
const
|
|
2936
|
-
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
|
3919
|
+
search_fn = async function(query, options, pluginOptions) {
|
|
3920
|
+
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
|
2937
3921
|
const { records } = await searchBranch({
|
|
2938
3922
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
2939
|
-
|
|
2940
|
-
|
|
3923
|
+
// @ts-ignore https://github.com/xataio/client-ts/issues/313
|
|
3924
|
+
body: { tables, query, fuzziness, prefix, highlight, page },
|
|
3925
|
+
...pluginOptions
|
|
2941
3926
|
});
|
|
2942
3927
|
return records;
|
|
2943
3928
|
};
|
|
2944
3929
|
_getSchemaTables = new WeakSet();
|
|
2945
|
-
getSchemaTables_fn = async function(
|
|
3930
|
+
getSchemaTables_fn = async function(pluginOptions) {
|
|
2946
3931
|
if (__privateGet$1(this, _schemaTables))
|
|
2947
3932
|
return __privateGet$1(this, _schemaTables);
|
|
2948
|
-
const fetchProps = await getFetchProps();
|
|
2949
3933
|
const { schema } = await getBranchDetails({
|
|
2950
3934
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
2951
|
-
...
|
|
3935
|
+
...pluginOptions
|
|
2952
3936
|
});
|
|
2953
3937
|
__privateSet$1(this, _schemaTables, schema.tables);
|
|
2954
3938
|
return schema.tables;
|
|
2955
3939
|
};
|
|
2956
3940
|
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
const gitBranch = envBranch || await getGitBranch();
|
|
2970
|
-
return resolveXataBranch(gitBranch, options);
|
|
2971
|
-
}
|
|
2972
|
-
async function getCurrentBranchDetails(options) {
|
|
2973
|
-
const branch = await getCurrentBranchName(options);
|
|
2974
|
-
return getDatabaseBranch(branch, options);
|
|
2975
|
-
}
|
|
2976
|
-
async function resolveXataBranch(gitBranch, options) {
|
|
2977
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
2978
|
-
const apiKey = options?.apiKey || getAPIKey();
|
|
2979
|
-
if (!databaseURL)
|
|
2980
|
-
throw new Error(
|
|
2981
|
-
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
|
2982
|
-
);
|
|
2983
|
-
if (!apiKey)
|
|
2984
|
-
throw new Error(
|
|
2985
|
-
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
|
2986
|
-
);
|
|
2987
|
-
const [protocol, , host, , dbName] = databaseURL.split("/");
|
|
2988
|
-
const urlParts = parseWorkspacesUrlParts(host);
|
|
2989
|
-
if (!urlParts)
|
|
2990
|
-
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
|
2991
|
-
const { workspace, region } = urlParts;
|
|
2992
|
-
const { fallbackBranch } = getEnvironment();
|
|
2993
|
-
const { branch } = await resolveBranch({
|
|
2994
|
-
apiKey,
|
|
2995
|
-
apiUrl: databaseURL,
|
|
2996
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
|
2997
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
|
2998
|
-
pathParams: { dbName, workspace, region },
|
|
2999
|
-
queryParams: { gitBranch, fallbackBranch },
|
|
3000
|
-
trace: defaultTrace
|
|
3001
|
-
});
|
|
3002
|
-
return branch;
|
|
3003
|
-
}
|
|
3004
|
-
async function getDatabaseBranch(branch, options) {
|
|
3005
|
-
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
3006
|
-
const apiKey = options?.apiKey || getAPIKey();
|
|
3007
|
-
if (!databaseURL)
|
|
3008
|
-
throw new Error(
|
|
3009
|
-
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
|
3010
|
-
);
|
|
3011
|
-
if (!apiKey)
|
|
3012
|
-
throw new Error(
|
|
3013
|
-
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
|
3014
|
-
);
|
|
3015
|
-
const [protocol, , host, , database] = databaseURL.split("/");
|
|
3016
|
-
const urlParts = parseWorkspacesUrlParts(host);
|
|
3017
|
-
if (!urlParts)
|
|
3018
|
-
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
|
3019
|
-
const { workspace, region } = urlParts;
|
|
3020
|
-
try {
|
|
3021
|
-
return await getBranchDetails({
|
|
3022
|
-
apiKey,
|
|
3023
|
-
apiUrl: databaseURL,
|
|
3024
|
-
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
|
3025
|
-
workspacesApiUrl: `${protocol}//${host}`,
|
|
3026
|
-
pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
|
|
3027
|
-
trace: defaultTrace
|
|
3028
|
-
});
|
|
3029
|
-
} catch (err) {
|
|
3030
|
-
if (isObject(err) && err.status === 404)
|
|
3031
|
-
return null;
|
|
3032
|
-
throw err;
|
|
3033
|
-
}
|
|
3034
|
-
}
|
|
3035
|
-
function getDatabaseURL() {
|
|
3036
|
-
try {
|
|
3037
|
-
const { databaseURL } = getEnvironment();
|
|
3038
|
-
return databaseURL;
|
|
3039
|
-
} catch (err) {
|
|
3040
|
-
return void 0;
|
|
3941
|
+
class TransactionPlugin extends XataPlugin {
|
|
3942
|
+
build(pluginOptions) {
|
|
3943
|
+
return {
|
|
3944
|
+
run: async (operations) => {
|
|
3945
|
+
const response = await branchTransaction({
|
|
3946
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
|
3947
|
+
body: { operations },
|
|
3948
|
+
...pluginOptions
|
|
3949
|
+
});
|
|
3950
|
+
return response;
|
|
3951
|
+
}
|
|
3952
|
+
};
|
|
3041
3953
|
}
|
|
3042
3954
|
}
|
|
3043
3955
|
|
|
@@ -3064,89 +3976,116 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3064
3976
|
return method;
|
|
3065
3977
|
};
|
|
3066
3978
|
const buildClient = (plugins) => {
|
|
3067
|
-
var
|
|
3979
|
+
var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
|
|
3068
3980
|
return _a = class {
|
|
3069
3981
|
constructor(options = {}, schemaTables) {
|
|
3070
3982
|
__privateAdd(this, _parseOptions);
|
|
3071
3983
|
__privateAdd(this, _getFetchProps);
|
|
3072
|
-
__privateAdd(this, _evaluateBranch);
|
|
3073
|
-
__privateAdd(this, _branch, void 0);
|
|
3074
3984
|
__privateAdd(this, _options, void 0);
|
|
3075
3985
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
|
3076
3986
|
__privateSet(this, _options, safeOptions);
|
|
3077
3987
|
const pluginOptions = {
|
|
3078
|
-
|
|
3988
|
+
...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
|
3079
3989
|
cache: safeOptions.cache,
|
|
3080
|
-
|
|
3990
|
+
host: safeOptions.host
|
|
3081
3991
|
};
|
|
3082
3992
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
|
3083
3993
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
|
3994
|
+
const transactions = new TransactionPlugin().build(pluginOptions);
|
|
3084
3995
|
this.db = db;
|
|
3085
3996
|
this.search = search;
|
|
3997
|
+
this.transactions = transactions;
|
|
3086
3998
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
|
3087
3999
|
if (namespace === void 0)
|
|
3088
4000
|
continue;
|
|
3089
|
-
|
|
3090
|
-
if (result instanceof Promise) {
|
|
3091
|
-
void result.then((namespace2) => {
|
|
3092
|
-
this[key] = namespace2;
|
|
3093
|
-
});
|
|
3094
|
-
} else {
|
|
3095
|
-
this[key] = result;
|
|
3096
|
-
}
|
|
4001
|
+
this[key] = namespace.build(pluginOptions);
|
|
3097
4002
|
}
|
|
3098
4003
|
}
|
|
3099
4004
|
async getConfig() {
|
|
3100
4005
|
const databaseURL = __privateGet(this, _options).databaseURL;
|
|
3101
|
-
const branch =
|
|
4006
|
+
const branch = __privateGet(this, _options).branch;
|
|
3102
4007
|
return { databaseURL, branch };
|
|
3103
4008
|
}
|
|
3104
|
-
},
|
|
4009
|
+
}, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
|
4010
|
+
const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
|
|
4011
|
+
const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
|
|
4012
|
+
if (isBrowser && !enableBrowser) {
|
|
4013
|
+
throw new Error(
|
|
4014
|
+
"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."
|
|
4015
|
+
);
|
|
4016
|
+
}
|
|
3105
4017
|
const fetch = getFetchImplementation(options?.fetch);
|
|
3106
4018
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
3107
4019
|
const apiKey = options?.apiKey || getAPIKey();
|
|
3108
4020
|
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
|
3109
4021
|
const trace = options?.trace ?? defaultTrace;
|
|
3110
|
-
const
|
|
4022
|
+
const clientName = options?.clientName;
|
|
4023
|
+
const host = options?.host ?? "production";
|
|
4024
|
+
const xataAgentExtra = options?.xataAgentExtra;
|
|
3111
4025
|
if (!apiKey) {
|
|
3112
4026
|
throw new Error("Option apiKey is required");
|
|
3113
4027
|
}
|
|
3114
4028
|
if (!databaseURL) {
|
|
3115
4029
|
throw new Error("Option databaseURL is required");
|
|
3116
4030
|
}
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
const
|
|
3120
|
-
if (
|
|
3121
|
-
|
|
4031
|
+
const envBranch = getBranch();
|
|
4032
|
+
const previewBranch = getPreviewBranch();
|
|
4033
|
+
const branch = options?.branch || previewBranch || envBranch || "main";
|
|
4034
|
+
if (!!previewBranch && branch !== previewBranch) {
|
|
4035
|
+
console.warn(
|
|
4036
|
+
`Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
|
|
4037
|
+
);
|
|
4038
|
+
} else if (!!envBranch && branch !== envBranch) {
|
|
4039
|
+
console.warn(
|
|
4040
|
+
`Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
|
4041
|
+
);
|
|
4042
|
+
} else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
|
|
4043
|
+
console.warn(
|
|
4044
|
+
`Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
|
4045
|
+
);
|
|
4046
|
+
} else if (!previewBranch && !envBranch && options?.branch === void 0) {
|
|
4047
|
+
console.warn(
|
|
4048
|
+
`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.`
|
|
4049
|
+
);
|
|
4050
|
+
}
|
|
4051
|
+
return {
|
|
4052
|
+
fetch,
|
|
4053
|
+
databaseURL,
|
|
4054
|
+
apiKey,
|
|
4055
|
+
branch,
|
|
4056
|
+
cache,
|
|
4057
|
+
trace,
|
|
4058
|
+
host,
|
|
4059
|
+
clientID: generateUUID(),
|
|
4060
|
+
enableBrowser,
|
|
4061
|
+
clientName,
|
|
4062
|
+
xataAgentExtra
|
|
4063
|
+
};
|
|
4064
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
|
|
4065
|
+
fetch,
|
|
4066
|
+
apiKey,
|
|
4067
|
+
databaseURL,
|
|
4068
|
+
branch,
|
|
4069
|
+
trace,
|
|
4070
|
+
clientID,
|
|
4071
|
+
clientName,
|
|
4072
|
+
xataAgentExtra
|
|
4073
|
+
}) {
|
|
3122
4074
|
return {
|
|
3123
|
-
|
|
4075
|
+
fetch,
|
|
3124
4076
|
apiKey,
|
|
3125
4077
|
apiUrl: "",
|
|
4078
|
+
// Instead of using workspace and dbBranch, we inject a probably CNAME'd URL
|
|
3126
4079
|
workspacesApiUrl: (path, params) => {
|
|
3127
4080
|
const hasBranch = params.dbBranchName ?? params.branch;
|
|
3128
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${
|
|
4081
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
|
|
3129
4082
|
return databaseURL + newPath;
|
|
3130
4083
|
},
|
|
3131
4084
|
trace,
|
|
3132
|
-
clientID
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
if (__privateGet(this, _branch))
|
|
3136
|
-
return __privateGet(this, _branch);
|
|
3137
|
-
if (param === void 0)
|
|
3138
|
-
return void 0;
|
|
3139
|
-
const strategies = Array.isArray(param) ? [...param] : [param];
|
|
3140
|
-
const evaluateBranch = async (strategy) => {
|
|
3141
|
-
return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
|
|
4085
|
+
clientID,
|
|
4086
|
+
clientName,
|
|
4087
|
+
xataAgentExtra
|
|
3142
4088
|
};
|
|
3143
|
-
for await (const strategy of strategies) {
|
|
3144
|
-
const branch = await evaluateBranch(strategy);
|
|
3145
|
-
if (branch) {
|
|
3146
|
-
__privateSet(this, _branch, branch);
|
|
3147
|
-
return branch;
|
|
3148
|
-
}
|
|
3149
|
-
}
|
|
3150
4089
|
}, _a;
|
|
3151
4090
|
};
|
|
3152
4091
|
class BaseClient extends buildClient() {
|
|
@@ -3220,7 +4159,7 @@ const deserialize = (json) => {
|
|
|
3220
4159
|
};
|
|
3221
4160
|
|
|
3222
4161
|
function buildWorkerRunner(config) {
|
|
3223
|
-
return function xataWorker(name,
|
|
4162
|
+
return function xataWorker(name, worker) {
|
|
3224
4163
|
return async (...args) => {
|
|
3225
4164
|
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
|
3226
4165
|
const result = await fetch(url, {
|
|
@@ -3242,6 +4181,7 @@ class XataError extends Error {
|
|
|
3242
4181
|
}
|
|
3243
4182
|
|
|
3244
4183
|
exports.BaseClient = BaseClient;
|
|
4184
|
+
exports.FetcherError = FetcherError;
|
|
3245
4185
|
exports.Operations = operationsByTag;
|
|
3246
4186
|
exports.PAGINATION_DEFAULT_OFFSET = PAGINATION_DEFAULT_OFFSET;
|
|
3247
4187
|
exports.PAGINATION_DEFAULT_SIZE = PAGINATION_DEFAULT_SIZE;
|
|
@@ -3265,8 +4205,11 @@ exports.addGitBranchesEntry = addGitBranchesEntry;
|
|
|
3265
4205
|
exports.addTableColumn = addTableColumn;
|
|
3266
4206
|
exports.aggregateTable = aggregateTable;
|
|
3267
4207
|
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
|
4208
|
+
exports.askTable = askTable;
|
|
3268
4209
|
exports.branchTransaction = branchTransaction;
|
|
3269
4210
|
exports.buildClient = buildClient;
|
|
4211
|
+
exports.buildPreviewBranchName = buildPreviewBranchName;
|
|
4212
|
+
exports.buildProviderString = buildProviderString;
|
|
3270
4213
|
exports.buildWorkerRunner = buildWorkerRunner;
|
|
3271
4214
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
|
3272
4215
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
|
@@ -3274,20 +4217,19 @@ exports.compareBranchSchemas = compareBranchSchemas;
|
|
|
3274
4217
|
exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
|
|
3275
4218
|
exports.compareMigrationRequest = compareMigrationRequest;
|
|
3276
4219
|
exports.contains = contains;
|
|
4220
|
+
exports.copyBranch = copyBranch;
|
|
3277
4221
|
exports.createBranch = createBranch;
|
|
3278
4222
|
exports.createDatabase = createDatabase;
|
|
3279
4223
|
exports.createMigrationRequest = createMigrationRequest;
|
|
3280
4224
|
exports.createTable = createTable;
|
|
3281
4225
|
exports.createUserAPIKey = createUserAPIKey;
|
|
3282
4226
|
exports.createWorkspace = createWorkspace;
|
|
3283
|
-
exports.dEPRECATEDcreateDatabase = dEPRECATEDcreateDatabase;
|
|
3284
|
-
exports.dEPRECATEDdeleteDatabase = dEPRECATEDdeleteDatabase;
|
|
3285
|
-
exports.dEPRECATEDgetDatabaseList = dEPRECATEDgetDatabaseList;
|
|
3286
|
-
exports.dEPRECATEDgetDatabaseMetadata = dEPRECATEDgetDatabaseMetadata;
|
|
3287
|
-
exports.dEPRECATEDupdateDatabaseMetadata = dEPRECATEDupdateDatabaseMetadata;
|
|
3288
4227
|
exports.deleteBranch = deleteBranch;
|
|
3289
4228
|
exports.deleteColumn = deleteColumn;
|
|
3290
4229
|
exports.deleteDatabase = deleteDatabase;
|
|
4230
|
+
exports.deleteDatabaseGithubSettings = deleteDatabaseGithubSettings;
|
|
4231
|
+
exports.deleteFile = deleteFile;
|
|
4232
|
+
exports.deleteFileItem = deleteFileItem;
|
|
3291
4233
|
exports.deleteRecord = deleteRecord;
|
|
3292
4234
|
exports.deleteTable = deleteTable;
|
|
3293
4235
|
exports.deleteUser = deleteUser;
|
|
@@ -3298,8 +4240,10 @@ exports.endsWith = endsWith;
|
|
|
3298
4240
|
exports.equals = equals;
|
|
3299
4241
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
|
3300
4242
|
exports.exists = exists;
|
|
4243
|
+
exports.fileAccess = fileAccess;
|
|
3301
4244
|
exports.ge = ge;
|
|
3302
4245
|
exports.getAPIKey = getAPIKey;
|
|
4246
|
+
exports.getBranch = getBranch;
|
|
3303
4247
|
exports.getBranchDetails = getBranchDetails;
|
|
3304
4248
|
exports.getBranchList = getBranchList;
|
|
3305
4249
|
exports.getBranchMetadata = getBranchMetadata;
|
|
@@ -3308,15 +4252,17 @@ exports.getBranchMigrationPlan = getBranchMigrationPlan;
|
|
|
3308
4252
|
exports.getBranchSchemaHistory = getBranchSchemaHistory;
|
|
3309
4253
|
exports.getBranchStats = getBranchStats;
|
|
3310
4254
|
exports.getColumn = getColumn;
|
|
3311
|
-
exports.
|
|
3312
|
-
exports.getCurrentBranchName = getCurrentBranchName;
|
|
4255
|
+
exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
|
|
3313
4256
|
exports.getDatabaseList = getDatabaseList;
|
|
3314
4257
|
exports.getDatabaseMetadata = getDatabaseMetadata;
|
|
3315
4258
|
exports.getDatabaseURL = getDatabaseURL;
|
|
4259
|
+
exports.getFile = getFile;
|
|
4260
|
+
exports.getFileItem = getFileItem;
|
|
3316
4261
|
exports.getGitBranchesMapping = getGitBranchesMapping;
|
|
3317
4262
|
exports.getHostUrl = getHostUrl;
|
|
3318
4263
|
exports.getMigrationRequest = getMigrationRequest;
|
|
3319
4264
|
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
|
4265
|
+
exports.getPreviewBranch = getPreviewBranch;
|
|
3320
4266
|
exports.getRecord = getRecord;
|
|
3321
4267
|
exports.getTableColumns = getTableColumns;
|
|
3322
4268
|
exports.getTableSchema = getTableSchema;
|
|
@@ -3359,21 +4305,27 @@ exports.parseProviderString = parseProviderString;
|
|
|
3359
4305
|
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
|
3360
4306
|
exports.pattern = pattern;
|
|
3361
4307
|
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
|
4308
|
+
exports.pushBranchMigrations = pushBranchMigrations;
|
|
4309
|
+
exports.putFile = putFile;
|
|
4310
|
+
exports.putFileItem = putFileItem;
|
|
3362
4311
|
exports.queryMigrationRequests = queryMigrationRequests;
|
|
3363
4312
|
exports.queryTable = queryTable;
|
|
3364
4313
|
exports.removeGitBranchesEntry = removeGitBranchesEntry;
|
|
3365
4314
|
exports.removeWorkspaceMember = removeWorkspaceMember;
|
|
4315
|
+
exports.renameDatabase = renameDatabase;
|
|
3366
4316
|
exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
|
|
3367
4317
|
exports.resolveBranch = resolveBranch;
|
|
3368
4318
|
exports.searchBranch = searchBranch;
|
|
3369
4319
|
exports.searchTable = searchTable;
|
|
3370
4320
|
exports.serialize = serialize;
|
|
3371
4321
|
exports.setTableSchema = setTableSchema;
|
|
4322
|
+
exports.sqlQuery = sqlQuery;
|
|
3372
4323
|
exports.startsWith = startsWith;
|
|
3373
4324
|
exports.summarizeTable = summarizeTable;
|
|
3374
4325
|
exports.updateBranchMetadata = updateBranchMetadata;
|
|
3375
4326
|
exports.updateBranchSchema = updateBranchSchema;
|
|
3376
4327
|
exports.updateColumn = updateColumn;
|
|
4328
|
+
exports.updateDatabaseGithubSettings = updateDatabaseGithubSettings;
|
|
3377
4329
|
exports.updateDatabaseMetadata = updateDatabaseMetadata;
|
|
3378
4330
|
exports.updateMigrationRequest = updateMigrationRequest;
|
|
3379
4331
|
exports.updateRecordWithID = updateRecordWithID;
|
|
@@ -3383,4 +4335,5 @@ exports.updateWorkspace = updateWorkspace;
|
|
|
3383
4335
|
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
|
3384
4336
|
exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
|
|
3385
4337
|
exports.upsertRecordWithID = upsertRecordWithID;
|
|
4338
|
+
exports.vectorSearchTable = vectorSearchTable;
|
|
3386
4339
|
//# sourceMappingURL=index.cjs.map
|