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