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