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