@xata.io/client 0.0.0-alpha.vf9f8ac6 → 0.0.0-alpha.vfa22996
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/CHANGELOG.md +158 -0
- package/README.md +32 -30
- package/Usage.md +34 -11
- package/dist/index.cjs +2050 -720
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4787 -1329
- package/dist/index.mjs +2015 -701
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- /package/{rollup.config.js → rollup.config.mjs} +0 -0
package/dist/index.mjs
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
const defaultTrace = async (_name, fn, _options) => {
|
2
|
+
return await fn({
|
3
|
+
setAttributes: () => {
|
4
|
+
return;
|
5
|
+
}
|
6
|
+
});
|
7
|
+
};
|
8
|
+
const TraceAttributes = {
|
9
|
+
KIND: "xata.trace.kind",
|
10
|
+
VERSION: "xata.sdk.version",
|
11
|
+
TABLE: "xata.table",
|
12
|
+
HTTP_REQUEST_ID: "http.request_id",
|
13
|
+
HTTP_STATUS_CODE: "http.status_code",
|
14
|
+
HTTP_HOST: "http.host",
|
15
|
+
HTTP_SCHEME: "http.scheme",
|
16
|
+
HTTP_USER_AGENT: "http.user_agent",
|
17
|
+
HTTP_METHOD: "http.method",
|
18
|
+
HTTP_URL: "http.url",
|
19
|
+
HTTP_ROUTE: "http.route",
|
20
|
+
HTTP_TARGET: "http.target"
|
21
|
+
};
|
22
|
+
|
1
23
|
function notEmpty(value) {
|
2
24
|
return value !== null && value !== void 0;
|
3
25
|
}
|
@@ -16,6 +38,21 @@ function isString(value) {
|
|
16
38
|
function isStringArray(value) {
|
17
39
|
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
18
40
|
}
|
41
|
+
function isNumber(value) {
|
42
|
+
return isDefined(value) && typeof value === "number";
|
43
|
+
}
|
44
|
+
function parseNumber(value) {
|
45
|
+
if (isNumber(value)) {
|
46
|
+
return value;
|
47
|
+
}
|
48
|
+
if (isString(value)) {
|
49
|
+
const parsed = Number(value);
|
50
|
+
if (!Number.isNaN(parsed)) {
|
51
|
+
return parsed;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
return void 0;
|
55
|
+
}
|
19
56
|
function toBase64(value) {
|
20
57
|
try {
|
21
58
|
return btoa(value);
|
@@ -24,10 +61,31 @@ function toBase64(value) {
|
|
24
61
|
return buf.from(value).toString("base64");
|
25
62
|
}
|
26
63
|
}
|
64
|
+
function deepMerge(a, b) {
|
65
|
+
const result = { ...a };
|
66
|
+
for (const [key, value] of Object.entries(b)) {
|
67
|
+
if (isObject(value) && isObject(result[key])) {
|
68
|
+
result[key] = deepMerge(result[key], value);
|
69
|
+
} else {
|
70
|
+
result[key] = value;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
return result;
|
74
|
+
}
|
75
|
+
function chunk(array, chunkSize) {
|
76
|
+
const result = [];
|
77
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
78
|
+
result.push(array.slice(i, i + chunkSize));
|
79
|
+
}
|
80
|
+
return result;
|
81
|
+
}
|
82
|
+
async function timeout(ms) {
|
83
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
84
|
+
}
|
27
85
|
|
28
86
|
function getEnvironment() {
|
29
87
|
try {
|
30
|
-
if (
|
88
|
+
if (isDefined(process) && isDefined(process.env)) {
|
31
89
|
return {
|
32
90
|
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
33
91
|
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
@@ -58,6 +116,25 @@ function getEnvironment() {
|
|
58
116
|
fallbackBranch: getGlobalFallbackBranch()
|
59
117
|
};
|
60
118
|
}
|
119
|
+
function getEnableBrowserVariable() {
|
120
|
+
try {
|
121
|
+
if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
|
122
|
+
return process.env.XATA_ENABLE_BROWSER === "true";
|
123
|
+
}
|
124
|
+
} catch (err) {
|
125
|
+
}
|
126
|
+
try {
|
127
|
+
if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
|
128
|
+
return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
|
129
|
+
}
|
130
|
+
} catch (err) {
|
131
|
+
}
|
132
|
+
try {
|
133
|
+
return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
|
134
|
+
} catch (err) {
|
135
|
+
return void 0;
|
136
|
+
}
|
137
|
+
}
|
61
138
|
function getGlobalApiKey() {
|
62
139
|
try {
|
63
140
|
return XATA_API_KEY;
|
@@ -117,18 +194,107 @@ function getAPIKey() {
|
|
117
194
|
}
|
118
195
|
}
|
119
196
|
|
197
|
+
var __accessCheck$8 = (obj, member, msg) => {
|
198
|
+
if (!member.has(obj))
|
199
|
+
throw TypeError("Cannot " + msg);
|
200
|
+
};
|
201
|
+
var __privateGet$8 = (obj, member, getter) => {
|
202
|
+
__accessCheck$8(obj, member, "read from private field");
|
203
|
+
return getter ? getter.call(obj) : member.get(obj);
|
204
|
+
};
|
205
|
+
var __privateAdd$8 = (obj, member, value) => {
|
206
|
+
if (member.has(obj))
|
207
|
+
throw TypeError("Cannot add the same private member more than once");
|
208
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
209
|
+
};
|
210
|
+
var __privateSet$8 = (obj, member, value, setter) => {
|
211
|
+
__accessCheck$8(obj, member, "write to private field");
|
212
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
213
|
+
return value;
|
214
|
+
};
|
215
|
+
var __privateMethod$4 = (obj, member, method) => {
|
216
|
+
__accessCheck$8(obj, member, "access private method");
|
217
|
+
return method;
|
218
|
+
};
|
219
|
+
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
120
220
|
function getFetchImplementation(userFetch) {
|
121
221
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
122
222
|
const fetchImpl = userFetch ?? globalFetch;
|
123
223
|
if (!fetchImpl) {
|
124
224
|
throw new Error(
|
125
|
-
`
|
225
|
+
`Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
|
126
226
|
);
|
127
227
|
}
|
128
228
|
return fetchImpl;
|
129
229
|
}
|
230
|
+
class ApiRequestPool {
|
231
|
+
constructor(concurrency = 10) {
|
232
|
+
__privateAdd$8(this, _enqueue);
|
233
|
+
__privateAdd$8(this, _fetch, void 0);
|
234
|
+
__privateAdd$8(this, _queue, void 0);
|
235
|
+
__privateAdd$8(this, _concurrency, void 0);
|
236
|
+
__privateSet$8(this, _queue, []);
|
237
|
+
__privateSet$8(this, _concurrency, concurrency);
|
238
|
+
this.running = 0;
|
239
|
+
this.started = 0;
|
240
|
+
}
|
241
|
+
setFetch(fetch2) {
|
242
|
+
__privateSet$8(this, _fetch, fetch2);
|
243
|
+
}
|
244
|
+
getFetch() {
|
245
|
+
if (!__privateGet$8(this, _fetch)) {
|
246
|
+
throw new Error("Fetch not set");
|
247
|
+
}
|
248
|
+
return __privateGet$8(this, _fetch);
|
249
|
+
}
|
250
|
+
request(url, options) {
|
251
|
+
const start = new Date();
|
252
|
+
const fetch2 = this.getFetch();
|
253
|
+
const runRequest = async (stalled = false) => {
|
254
|
+
const response = await fetch2(url, options);
|
255
|
+
if (response.status === 429) {
|
256
|
+
const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
|
257
|
+
await timeout(rateLimitReset * 1e3);
|
258
|
+
return await runRequest(true);
|
259
|
+
}
|
260
|
+
if (stalled) {
|
261
|
+
const stalledTime = new Date().getTime() - start.getTime();
|
262
|
+
console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
|
263
|
+
}
|
264
|
+
return response;
|
265
|
+
};
|
266
|
+
return __privateMethod$4(this, _enqueue, enqueue_fn).call(this, async () => {
|
267
|
+
return await runRequest();
|
268
|
+
});
|
269
|
+
}
|
270
|
+
}
|
271
|
+
_fetch = new WeakMap();
|
272
|
+
_queue = new WeakMap();
|
273
|
+
_concurrency = new WeakMap();
|
274
|
+
_enqueue = new WeakSet();
|
275
|
+
enqueue_fn = function(task) {
|
276
|
+
const promise = new Promise((resolve) => __privateGet$8(this, _queue).push(resolve)).finally(() => {
|
277
|
+
this.started--;
|
278
|
+
this.running++;
|
279
|
+
}).then(() => task()).finally(() => {
|
280
|
+
this.running--;
|
281
|
+
const next = __privateGet$8(this, _queue).shift();
|
282
|
+
if (next !== void 0) {
|
283
|
+
this.started++;
|
284
|
+
next();
|
285
|
+
}
|
286
|
+
});
|
287
|
+
if (this.running + this.started < __privateGet$8(this, _concurrency)) {
|
288
|
+
const next = __privateGet$8(this, _queue).shift();
|
289
|
+
if (next !== void 0) {
|
290
|
+
this.started++;
|
291
|
+
next();
|
292
|
+
}
|
293
|
+
}
|
294
|
+
return promise;
|
295
|
+
};
|
130
296
|
|
131
|
-
const VERSION = "0.0.0-alpha.
|
297
|
+
const VERSION = "0.0.0-alpha.vfa22996";
|
132
298
|
|
133
299
|
class ErrorWithCause extends Error {
|
134
300
|
constructor(message, options) {
|
@@ -171,6 +337,7 @@ function getMessage(data) {
|
|
171
337
|
}
|
172
338
|
}
|
173
339
|
|
340
|
+
const pool = new ApiRequestPool();
|
174
341
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
175
342
|
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
176
343
|
if (value === void 0 || value === null)
|
@@ -179,18 +346,24 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
179
346
|
}, {});
|
180
347
|
const query = new URLSearchParams(cleanQueryParams).toString();
|
181
348
|
const queryString = query.length > 0 ? `?${query}` : "";
|
182
|
-
|
349
|
+
const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
|
350
|
+
return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
|
351
|
+
}, {});
|
352
|
+
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
183
353
|
};
|
184
354
|
function buildBaseUrl({
|
355
|
+
endpoint,
|
185
356
|
path,
|
186
357
|
workspacesApiUrl,
|
187
358
|
apiUrl,
|
188
|
-
pathParams
|
359
|
+
pathParams = {}
|
189
360
|
}) {
|
190
|
-
if (
|
191
|
-
|
192
|
-
|
193
|
-
|
361
|
+
if (endpoint === "dataPlane") {
|
362
|
+
const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
363
|
+
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
364
|
+
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
365
|
+
}
|
366
|
+
return `${apiUrl}${path}`;
|
194
367
|
}
|
195
368
|
function hostHeader(url) {
|
196
369
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
@@ -206,277 +379,235 @@ async function fetch$1({
|
|
206
379
|
queryParams,
|
207
380
|
fetchImpl,
|
208
381
|
apiKey,
|
382
|
+
endpoint,
|
209
383
|
apiUrl,
|
210
|
-
workspacesApiUrl
|
384
|
+
workspacesApiUrl,
|
385
|
+
trace,
|
386
|
+
signal,
|
387
|
+
clientID,
|
388
|
+
sessionID,
|
389
|
+
fetchOptions = {}
|
211
390
|
}) {
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
391
|
+
pool.setFetch(fetchImpl);
|
392
|
+
return await trace(
|
393
|
+
`${method.toUpperCase()} ${path}`,
|
394
|
+
async ({ setAttributes }) => {
|
395
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
396
|
+
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
397
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
398
|
+
setAttributes({
|
399
|
+
[TraceAttributes.HTTP_URL]: url,
|
400
|
+
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
401
|
+
});
|
402
|
+
const response = await pool.request(url, {
|
403
|
+
...fetchOptions,
|
404
|
+
method: method.toUpperCase(),
|
405
|
+
body: body ? JSON.stringify(body) : void 0,
|
406
|
+
headers: {
|
407
|
+
"Content-Type": "application/json",
|
408
|
+
"User-Agent": `Xata client-ts/${VERSION}`,
|
409
|
+
"X-Xata-Client-ID": clientID ?? "",
|
410
|
+
"X-Xata-Session-ID": sessionID ?? "",
|
411
|
+
...headers,
|
412
|
+
...hostHeader(fullUrl),
|
413
|
+
Authorization: `Bearer ${apiKey}`
|
414
|
+
},
|
415
|
+
signal
|
416
|
+
});
|
417
|
+
const { host, protocol } = parseUrl(response.url);
|
418
|
+
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
419
|
+
setAttributes({
|
420
|
+
[TraceAttributes.KIND]: "http",
|
421
|
+
[TraceAttributes.HTTP_REQUEST_ID]: requestId,
|
422
|
+
[TraceAttributes.HTTP_STATUS_CODE]: response.status,
|
423
|
+
[TraceAttributes.HTTP_HOST]: host,
|
424
|
+
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
425
|
+
});
|
426
|
+
if (response.status === 204) {
|
427
|
+
return {};
|
428
|
+
}
|
429
|
+
if (response.status === 429) {
|
430
|
+
throw new FetcherError(response.status, "Rate limit exceeded", requestId);
|
431
|
+
}
|
432
|
+
try {
|
433
|
+
const jsonResponse = await response.json();
|
434
|
+
if (response.ok) {
|
435
|
+
return jsonResponse;
|
436
|
+
}
|
437
|
+
throw new FetcherError(response.status, jsonResponse, requestId);
|
438
|
+
} catch (error) {
|
439
|
+
throw new FetcherError(response.status, error, requestId);
|
440
|
+
}
|
441
|
+
},
|
442
|
+
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
443
|
+
);
|
444
|
+
}
|
445
|
+
function parseUrl(url) {
|
230
446
|
try {
|
231
|
-
const
|
232
|
-
|
233
|
-
return jsonResponse;
|
234
|
-
}
|
235
|
-
throw new FetcherError(response.status, jsonResponse, requestId);
|
447
|
+
const { host, protocol } = new URL(url);
|
448
|
+
return { host, protocol };
|
236
449
|
} catch (error) {
|
237
|
-
|
450
|
+
return {};
|
238
451
|
}
|
239
452
|
}
|
240
453
|
|
241
|
-
const
|
242
|
-
|
243
|
-
const
|
244
|
-
const
|
245
|
-
url: "/user/keys",
|
246
|
-
method: "get",
|
247
|
-
...variables
|
248
|
-
});
|
249
|
-
const createUserAPIKey = (variables) => fetch$1({
|
250
|
-
url: "/user/keys/{keyName}",
|
251
|
-
method: "post",
|
252
|
-
...variables
|
253
|
-
});
|
254
|
-
const deleteUserAPIKey = (variables) => fetch$1({
|
255
|
-
url: "/user/keys/{keyName}",
|
256
|
-
method: "delete",
|
257
|
-
...variables
|
258
|
-
});
|
259
|
-
const createWorkspace = (variables) => fetch$1({
|
260
|
-
url: "/workspaces",
|
261
|
-
method: "post",
|
262
|
-
...variables
|
263
|
-
});
|
264
|
-
const getWorkspacesList = (variables) => fetch$1({
|
265
|
-
url: "/workspaces",
|
266
|
-
method: "get",
|
267
|
-
...variables
|
268
|
-
});
|
269
|
-
const getWorkspace = (variables) => fetch$1({
|
270
|
-
url: "/workspaces/{workspaceId}",
|
271
|
-
method: "get",
|
272
|
-
...variables
|
273
|
-
});
|
274
|
-
const updateWorkspace = (variables) => fetch$1({
|
275
|
-
url: "/workspaces/{workspaceId}",
|
276
|
-
method: "put",
|
277
|
-
...variables
|
278
|
-
});
|
279
|
-
const deleteWorkspace = (variables) => fetch$1({
|
280
|
-
url: "/workspaces/{workspaceId}",
|
281
|
-
method: "delete",
|
282
|
-
...variables
|
283
|
-
});
|
284
|
-
const getWorkspaceMembersList = (variables) => fetch$1({
|
285
|
-
url: "/workspaces/{workspaceId}/members",
|
286
|
-
method: "get",
|
287
|
-
...variables
|
288
|
-
});
|
289
|
-
const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
|
290
|
-
const removeWorkspaceMember = (variables) => fetch$1({
|
291
|
-
url: "/workspaces/{workspaceId}/members/{userId}",
|
292
|
-
method: "delete",
|
293
|
-
...variables
|
294
|
-
});
|
295
|
-
const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
|
296
|
-
const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
|
297
|
-
const cancelWorkspaceMemberInvite = (variables) => fetch$1({
|
298
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
299
|
-
method: "delete",
|
300
|
-
...variables
|
301
|
-
});
|
302
|
-
const resendWorkspaceMemberInvite = (variables) => fetch$1({
|
303
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
|
304
|
-
method: "post",
|
305
|
-
...variables
|
306
|
-
});
|
307
|
-
const acceptWorkspaceMemberInvite = (variables) => fetch$1({
|
308
|
-
url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
|
309
|
-
method: "post",
|
310
|
-
...variables
|
311
|
-
});
|
312
|
-
const getDatabaseList = (variables) => fetch$1({
|
313
|
-
url: "/dbs",
|
314
|
-
method: "get",
|
315
|
-
...variables
|
316
|
-
});
|
317
|
-
const getBranchList = (variables) => fetch$1({
|
318
|
-
url: "/dbs/{dbName}",
|
319
|
-
method: "get",
|
320
|
-
...variables
|
321
|
-
});
|
322
|
-
const createDatabase = (variables) => fetch$1({
|
323
|
-
url: "/dbs/{dbName}",
|
324
|
-
method: "put",
|
325
|
-
...variables
|
326
|
-
});
|
327
|
-
const deleteDatabase = (variables) => fetch$1({
|
454
|
+
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
455
|
+
|
456
|
+
const dEPRECATEDgetDatabaseList = (variables, signal) => dataPlaneFetch({ url: "/dbs", method: "get", ...variables, signal });
|
457
|
+
const getBranchList = (variables, signal) => dataPlaneFetch({
|
328
458
|
url: "/dbs/{dbName}",
|
329
|
-
method: "delete",
|
330
|
-
...variables
|
331
|
-
});
|
332
|
-
const getDatabaseMetadata = (variables) => fetch$1({
|
333
|
-
url: "/dbs/{dbName}/metadata",
|
334
459
|
method: "get",
|
335
|
-
...variables
|
460
|
+
...variables,
|
461
|
+
signal
|
336
462
|
});
|
337
|
-
const
|
338
|
-
const
|
339
|
-
const
|
340
|
-
const
|
341
|
-
|
342
|
-
method: "get",
|
343
|
-
...variables
|
344
|
-
});
|
345
|
-
const getBranchDetails = (variables) => fetch$1({
|
463
|
+
const dEPRECATEDcreateDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
|
464
|
+
const dEPRECATEDdeleteDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "delete", ...variables, signal });
|
465
|
+
const dEPRECATEDgetDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "get", ...variables, signal });
|
466
|
+
const dEPRECATEDupdateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
|
467
|
+
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
346
468
|
url: "/db/{dbBranchName}",
|
347
469
|
method: "get",
|
348
|
-
...variables
|
470
|
+
...variables,
|
471
|
+
signal
|
349
472
|
});
|
350
|
-
const createBranch = (variables) =>
|
351
|
-
const deleteBranch = (variables) =>
|
473
|
+
const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
|
474
|
+
const deleteBranch = (variables, signal) => dataPlaneFetch({
|
352
475
|
url: "/db/{dbBranchName}",
|
353
476
|
method: "delete",
|
354
|
-
...variables
|
477
|
+
...variables,
|
478
|
+
signal
|
355
479
|
});
|
356
|
-
const updateBranchMetadata = (variables) =>
|
480
|
+
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
357
481
|
url: "/db/{dbBranchName}/metadata",
|
358
482
|
method: "put",
|
359
|
-
...variables
|
483
|
+
...variables,
|
484
|
+
signal
|
360
485
|
});
|
361
|
-
const getBranchMetadata = (variables) =>
|
486
|
+
const getBranchMetadata = (variables, signal) => dataPlaneFetch({
|
362
487
|
url: "/db/{dbBranchName}/metadata",
|
363
488
|
method: "get",
|
364
|
-
...variables
|
489
|
+
...variables,
|
490
|
+
signal
|
365
491
|
});
|
366
|
-
const
|
367
|
-
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
368
|
-
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
369
|
-
const getBranchStats = (variables) => fetch$1({
|
492
|
+
const getBranchStats = (variables, signal) => dataPlaneFetch({
|
370
493
|
url: "/db/{dbBranchName}/stats",
|
371
494
|
method: "get",
|
372
|
-
...variables
|
495
|
+
...variables,
|
496
|
+
signal
|
497
|
+
});
|
498
|
+
const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
|
499
|
+
const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
|
500
|
+
const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
|
501
|
+
const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
|
502
|
+
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
503
|
+
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
504
|
+
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
505
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
506
|
+
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
507
|
+
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
508
|
+
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
509
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
510
|
+
method: "get",
|
511
|
+
...variables,
|
512
|
+
signal
|
513
|
+
});
|
514
|
+
const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
|
515
|
+
const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
|
516
|
+
const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
|
517
|
+
const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
|
518
|
+
const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
|
519
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
520
|
+
method: "post",
|
521
|
+
...variables,
|
522
|
+
signal
|
373
523
|
});
|
374
|
-
const
|
524
|
+
const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
|
525
|
+
const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
|
526
|
+
const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
|
527
|
+
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
528
|
+
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
529
|
+
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
530
|
+
const createTable = (variables, signal) => dataPlaneFetch({
|
375
531
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
376
532
|
method: "put",
|
377
|
-
...variables
|
533
|
+
...variables,
|
534
|
+
signal
|
378
535
|
});
|
379
|
-
const deleteTable = (variables) =>
|
536
|
+
const deleteTable = (variables, signal) => dataPlaneFetch({
|
380
537
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
381
538
|
method: "delete",
|
382
|
-
...variables
|
539
|
+
...variables,
|
540
|
+
signal
|
383
541
|
});
|
384
|
-
const updateTable = (variables) =>
|
385
|
-
|
386
|
-
method: "patch",
|
387
|
-
...variables
|
388
|
-
});
|
389
|
-
const getTableSchema = (variables) => fetch$1({
|
542
|
+
const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
|
543
|
+
const getTableSchema = (variables, signal) => dataPlaneFetch({
|
390
544
|
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
391
545
|
method: "get",
|
392
|
-
...variables
|
546
|
+
...variables,
|
547
|
+
signal
|
393
548
|
});
|
394
|
-
const setTableSchema = (variables) =>
|
395
|
-
|
396
|
-
method: "put",
|
397
|
-
...variables
|
398
|
-
});
|
399
|
-
const getTableColumns = (variables) => fetch$1({
|
549
|
+
const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
|
550
|
+
const getTableColumns = (variables, signal) => dataPlaneFetch({
|
400
551
|
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
401
552
|
method: "get",
|
402
|
-
...variables
|
403
|
-
|
404
|
-
const addTableColumn = (variables) => fetch$1({
|
405
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
406
|
-
method: "post",
|
407
|
-
...variables
|
553
|
+
...variables,
|
554
|
+
signal
|
408
555
|
});
|
409
|
-
const
|
556
|
+
const addTableColumn = (variables, signal) => dataPlaneFetch(
|
557
|
+
{ url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
|
558
|
+
);
|
559
|
+
const getColumn = (variables, signal) => dataPlaneFetch({
|
410
560
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
411
561
|
method: "get",
|
412
|
-
...variables
|
562
|
+
...variables,
|
563
|
+
signal
|
413
564
|
});
|
414
|
-
const
|
565
|
+
const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
|
566
|
+
const deleteColumn = (variables, signal) => dataPlaneFetch({
|
415
567
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
416
568
|
method: "delete",
|
417
|
-
...variables
|
418
|
-
|
419
|
-
const updateColumn = (variables) => fetch$1({
|
420
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
421
|
-
method: "patch",
|
422
|
-
...variables
|
569
|
+
...variables,
|
570
|
+
signal
|
423
571
|
});
|
424
|
-
const insertRecord = (variables) =>
|
425
|
-
const
|
426
|
-
const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
|
427
|
-
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
428
|
-
const deleteRecord = (variables) => fetch$1({
|
429
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
430
|
-
method: "delete",
|
431
|
-
...variables
|
432
|
-
});
|
433
|
-
const getRecord = (variables) => fetch$1({
|
572
|
+
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
573
|
+
const getRecord = (variables, signal) => dataPlaneFetch({
|
434
574
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
435
575
|
method: "get",
|
436
|
-
...variables
|
576
|
+
...variables,
|
577
|
+
signal
|
437
578
|
});
|
438
|
-
const
|
439
|
-
const
|
579
|
+
const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
|
580
|
+
const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
|
581
|
+
const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
|
582
|
+
const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
|
583
|
+
const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
|
584
|
+
const queryTable = (variables, signal) => dataPlaneFetch({
|
440
585
|
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
441
586
|
method: "post",
|
442
|
-
...variables
|
587
|
+
...variables,
|
588
|
+
signal
|
443
589
|
});
|
444
|
-
const
|
445
|
-
url: "/db/{dbBranchName}/
|
590
|
+
const searchBranch = (variables, signal) => dataPlaneFetch({
|
591
|
+
url: "/db/{dbBranchName}/search",
|
446
592
|
method: "post",
|
447
|
-
...variables
|
593
|
+
...variables,
|
594
|
+
signal
|
448
595
|
});
|
449
|
-
const
|
450
|
-
url: "/db/{dbBranchName}/search",
|
596
|
+
const searchTable = (variables, signal) => dataPlaneFetch({
|
597
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
451
598
|
method: "post",
|
452
|
-
...variables
|
599
|
+
...variables,
|
600
|
+
signal
|
453
601
|
});
|
454
|
-
const
|
455
|
-
|
456
|
-
|
457
|
-
createWorkspace,
|
458
|
-
getWorkspacesList,
|
459
|
-
getWorkspace,
|
460
|
-
updateWorkspace,
|
461
|
-
deleteWorkspace,
|
462
|
-
getWorkspaceMembersList,
|
463
|
-
updateWorkspaceMemberRole,
|
464
|
-
removeWorkspaceMember,
|
465
|
-
inviteWorkspaceMember,
|
466
|
-
updateWorkspaceMemberInvite,
|
467
|
-
cancelWorkspaceMemberInvite,
|
468
|
-
resendWorkspaceMemberInvite,
|
469
|
-
acceptWorkspaceMemberInvite
|
470
|
-
},
|
602
|
+
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
603
|
+
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
604
|
+
const operationsByTag$2 = {
|
471
605
|
database: {
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
addGitBranchesEntry,
|
478
|
-
removeGitBranchesEntry,
|
479
|
-
resolveBranch
|
606
|
+
dEPRECATEDgetDatabaseList,
|
607
|
+
dEPRECATEDcreateDatabase,
|
608
|
+
dEPRECATEDdeleteDatabase,
|
609
|
+
dEPRECATEDgetDatabaseMetadata,
|
610
|
+
dEPRECATEDupdateDatabaseMetadata
|
480
611
|
},
|
481
612
|
branch: {
|
482
613
|
getBranchList,
|
@@ -485,10 +616,42 @@ const operationsByTag = {
|
|
485
616
|
deleteBranch,
|
486
617
|
updateBranchMetadata,
|
487
618
|
getBranchMetadata,
|
619
|
+
getBranchStats,
|
620
|
+
getGitBranchesMapping,
|
621
|
+
addGitBranchesEntry,
|
622
|
+
removeGitBranchesEntry,
|
623
|
+
resolveBranch
|
624
|
+
},
|
625
|
+
migrations: {
|
488
626
|
getBranchMigrationHistory,
|
489
|
-
executeBranchMigrationPlan,
|
490
627
|
getBranchMigrationPlan,
|
491
|
-
|
628
|
+
executeBranchMigrationPlan,
|
629
|
+
getBranchSchemaHistory,
|
630
|
+
compareBranchWithUserSchema,
|
631
|
+
compareBranchSchemas,
|
632
|
+
updateBranchSchema,
|
633
|
+
previewBranchSchemaEdit,
|
634
|
+
applyBranchSchemaEdit
|
635
|
+
},
|
636
|
+
records: {
|
637
|
+
branchTransaction,
|
638
|
+
insertRecord,
|
639
|
+
getRecord,
|
640
|
+
insertRecordWithID,
|
641
|
+
updateRecordWithID,
|
642
|
+
upsertRecordWithID,
|
643
|
+
deleteRecord,
|
644
|
+
bulkInsertTableRecords
|
645
|
+
},
|
646
|
+
migrationRequests: {
|
647
|
+
queryMigrationRequests,
|
648
|
+
createMigrationRequest,
|
649
|
+
getMigrationRequest,
|
650
|
+
updateMigrationRequest,
|
651
|
+
listMigrationRequestsCommits,
|
652
|
+
compareMigrationRequest,
|
653
|
+
getMigrationRequestIsMerged,
|
654
|
+
mergeMigrationRequest
|
492
655
|
},
|
493
656
|
table: {
|
494
657
|
createTable,
|
@@ -499,27 +662,150 @@ const operationsByTag = {
|
|
499
662
|
getTableColumns,
|
500
663
|
addTableColumn,
|
501
664
|
getColumn,
|
502
|
-
|
503
|
-
|
665
|
+
updateColumn,
|
666
|
+
deleteColumn
|
504
667
|
},
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
668
|
+
searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
|
669
|
+
};
|
670
|
+
|
671
|
+
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
672
|
+
|
673
|
+
const getUser = (variables, signal) => controlPlaneFetch({
|
674
|
+
url: "/user",
|
675
|
+
method: "get",
|
676
|
+
...variables,
|
677
|
+
signal
|
678
|
+
});
|
679
|
+
const updateUser = (variables, signal) => controlPlaneFetch({
|
680
|
+
url: "/user",
|
681
|
+
method: "put",
|
682
|
+
...variables,
|
683
|
+
signal
|
684
|
+
});
|
685
|
+
const deleteUser = (variables, signal) => controlPlaneFetch({
|
686
|
+
url: "/user",
|
687
|
+
method: "delete",
|
688
|
+
...variables,
|
689
|
+
signal
|
690
|
+
});
|
691
|
+
const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
|
692
|
+
url: "/user/keys",
|
693
|
+
method: "get",
|
694
|
+
...variables,
|
695
|
+
signal
|
696
|
+
});
|
697
|
+
const createUserAPIKey = (variables, signal) => controlPlaneFetch({
|
698
|
+
url: "/user/keys/{keyName}",
|
699
|
+
method: "post",
|
700
|
+
...variables,
|
701
|
+
signal
|
702
|
+
});
|
703
|
+
const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
704
|
+
url: "/user/keys/{keyName}",
|
705
|
+
method: "delete",
|
706
|
+
...variables,
|
707
|
+
signal
|
708
|
+
});
|
709
|
+
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
710
|
+
url: "/workspaces",
|
711
|
+
method: "get",
|
712
|
+
...variables,
|
713
|
+
signal
|
714
|
+
});
|
715
|
+
const createWorkspace = (variables, signal) => controlPlaneFetch({
|
716
|
+
url: "/workspaces",
|
717
|
+
method: "post",
|
718
|
+
...variables,
|
719
|
+
signal
|
720
|
+
});
|
721
|
+
const getWorkspace = (variables, signal) => controlPlaneFetch({
|
722
|
+
url: "/workspaces/{workspaceId}",
|
723
|
+
method: "get",
|
724
|
+
...variables,
|
725
|
+
signal
|
726
|
+
});
|
727
|
+
const updateWorkspace = (variables, signal) => controlPlaneFetch({
|
728
|
+
url: "/workspaces/{workspaceId}",
|
729
|
+
method: "put",
|
730
|
+
...variables,
|
731
|
+
signal
|
732
|
+
});
|
733
|
+
const deleteWorkspace = (variables, signal) => controlPlaneFetch({
|
734
|
+
url: "/workspaces/{workspaceId}",
|
735
|
+
method: "delete",
|
736
|
+
...variables,
|
737
|
+
signal
|
738
|
+
});
|
739
|
+
const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
|
740
|
+
const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
|
741
|
+
const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
742
|
+
url: "/workspaces/{workspaceId}/members/{userId}",
|
743
|
+
method: "delete",
|
744
|
+
...variables,
|
745
|
+
signal
|
746
|
+
});
|
747
|
+
const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
|
748
|
+
const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
|
749
|
+
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
750
|
+
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
751
|
+
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
752
|
+
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
753
|
+
url: "/workspaces/{workspaceId}/dbs",
|
754
|
+
method: "get",
|
755
|
+
...variables,
|
756
|
+
signal
|
757
|
+
});
|
758
|
+
const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
|
759
|
+
const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
760
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
761
|
+
method: "delete",
|
762
|
+
...variables,
|
763
|
+
signal
|
764
|
+
});
|
765
|
+
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
766
|
+
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
767
|
+
const listRegions = (variables, signal) => controlPlaneFetch({
|
768
|
+
url: "/workspaces/{workspaceId}/regions",
|
769
|
+
method: "get",
|
770
|
+
...variables,
|
771
|
+
signal
|
772
|
+
});
|
773
|
+
const operationsByTag$1 = {
|
774
|
+
users: { getUser, updateUser, deleteUser },
|
775
|
+
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
776
|
+
workspaces: {
|
777
|
+
getWorkspacesList,
|
778
|
+
createWorkspace,
|
779
|
+
getWorkspace,
|
780
|
+
updateWorkspace,
|
781
|
+
deleteWorkspace,
|
782
|
+
getWorkspaceMembersList,
|
783
|
+
updateWorkspaceMemberRole,
|
784
|
+
removeWorkspaceMember
|
785
|
+
},
|
786
|
+
invites: {
|
787
|
+
inviteWorkspaceMember,
|
788
|
+
updateWorkspaceMemberInvite,
|
789
|
+
cancelWorkspaceMemberInvite,
|
790
|
+
acceptWorkspaceMemberInvite,
|
791
|
+
resendWorkspaceMemberInvite
|
792
|
+
},
|
793
|
+
databases: {
|
794
|
+
getDatabaseList,
|
795
|
+
createDatabase,
|
796
|
+
deleteDatabase,
|
797
|
+
getDatabaseMetadata,
|
798
|
+
updateDatabaseMetadata,
|
799
|
+
listRegions
|
516
800
|
}
|
517
801
|
};
|
518
802
|
|
803
|
+
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
804
|
+
|
519
805
|
function getHostUrl(provider, type) {
|
520
|
-
if (
|
806
|
+
if (isHostProviderAlias(provider)) {
|
521
807
|
return providers[provider][type];
|
522
|
-
} else if (
|
808
|
+
} else if (isHostProviderBuilder(provider)) {
|
523
809
|
return provider[type];
|
524
810
|
}
|
525
811
|
throw new Error("Invalid API provider");
|
@@ -527,19 +813,38 @@ function getHostUrl(provider, type) {
|
|
527
813
|
const providers = {
|
528
814
|
production: {
|
529
815
|
main: "https://api.xata.io",
|
530
|
-
workspaces: "https://{workspaceId}.xata.sh"
|
816
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
531
817
|
},
|
532
818
|
staging: {
|
533
819
|
main: "https://staging.xatabase.co",
|
534
|
-
workspaces: "https://{workspaceId}.staging.xatabase.co"
|
820
|
+
workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
|
535
821
|
}
|
536
822
|
};
|
537
|
-
function
|
823
|
+
function isHostProviderAlias(alias) {
|
538
824
|
return isString(alias) && Object.keys(providers).includes(alias);
|
539
825
|
}
|
540
|
-
function
|
826
|
+
function isHostProviderBuilder(builder) {
|
541
827
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
542
828
|
}
|
829
|
+
function parseProviderString(provider = "production") {
|
830
|
+
if (isHostProviderAlias(provider)) {
|
831
|
+
return provider;
|
832
|
+
}
|
833
|
+
const [main, workspaces] = provider.split(",");
|
834
|
+
if (!main || !workspaces)
|
835
|
+
return null;
|
836
|
+
return { main, workspaces };
|
837
|
+
}
|
838
|
+
function parseWorkspacesUrlParts(url) {
|
839
|
+
if (!isString(url))
|
840
|
+
return null;
|
841
|
+
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
|
842
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
|
843
|
+
const match = url.match(regex) || url.match(regexStaging);
|
844
|
+
if (!match)
|
845
|
+
return null;
|
846
|
+
return { workspace: match[1], region: match[2] ?? "eu-west-1" };
|
847
|
+
}
|
543
848
|
|
544
849
|
var __accessCheck$7 = (obj, member, msg) => {
|
545
850
|
if (!member.has(obj))
|
@@ -565,7 +870,8 @@ class XataApiClient {
|
|
565
870
|
__privateAdd$7(this, _extraProps, void 0);
|
566
871
|
__privateAdd$7(this, _namespaces, {});
|
567
872
|
const provider = options.host ?? "production";
|
568
|
-
const apiKey = options
|
873
|
+
const apiKey = options.apiKey ?? getAPIKey();
|
874
|
+
const trace = options.trace ?? defaultTrace;
|
569
875
|
if (!apiKey) {
|
570
876
|
throw new Error("Could not resolve a valid apiKey");
|
571
877
|
}
|
@@ -573,7 +879,8 @@ class XataApiClient {
|
|
573
879
|
apiUrl: getHostUrl(provider, "main"),
|
574
880
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
575
881
|
fetchImpl: getFetchImplementation(options.fetch),
|
576
|
-
apiKey
|
882
|
+
apiKey,
|
883
|
+
trace
|
577
884
|
});
|
578
885
|
}
|
579
886
|
get user() {
|
@@ -581,21 +888,41 @@ class XataApiClient {
|
|
581
888
|
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
582
889
|
return __privateGet$7(this, _namespaces).user;
|
583
890
|
}
|
891
|
+
get authentication() {
|
892
|
+
if (!__privateGet$7(this, _namespaces).authentication)
|
893
|
+
__privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
|
894
|
+
return __privateGet$7(this, _namespaces).authentication;
|
895
|
+
}
|
584
896
|
get workspaces() {
|
585
897
|
if (!__privateGet$7(this, _namespaces).workspaces)
|
586
898
|
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
587
899
|
return __privateGet$7(this, _namespaces).workspaces;
|
588
900
|
}
|
589
|
-
get
|
590
|
-
if (!__privateGet$7(this, _namespaces).
|
591
|
-
__privateGet$7(this, _namespaces).
|
592
|
-
return __privateGet$7(this, _namespaces).
|
901
|
+
get invites() {
|
902
|
+
if (!__privateGet$7(this, _namespaces).invites)
|
903
|
+
__privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
|
904
|
+
return __privateGet$7(this, _namespaces).invites;
|
905
|
+
}
|
906
|
+
get database() {
|
907
|
+
if (!__privateGet$7(this, _namespaces).database)
|
908
|
+
__privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
|
909
|
+
return __privateGet$7(this, _namespaces).database;
|
593
910
|
}
|
594
911
|
get branches() {
|
595
912
|
if (!__privateGet$7(this, _namespaces).branches)
|
596
913
|
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
597
914
|
return __privateGet$7(this, _namespaces).branches;
|
598
915
|
}
|
916
|
+
get migrations() {
|
917
|
+
if (!__privateGet$7(this, _namespaces).migrations)
|
918
|
+
__privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
|
919
|
+
return __privateGet$7(this, _namespaces).migrations;
|
920
|
+
}
|
921
|
+
get migrationRequests() {
|
922
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
923
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
924
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
925
|
+
}
|
599
926
|
get tables() {
|
600
927
|
if (!__privateGet$7(this, _namespaces).tables)
|
601
928
|
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
@@ -606,6 +933,11 @@ class XataApiClient {
|
|
606
933
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
607
934
|
return __privateGet$7(this, _namespaces).records;
|
608
935
|
}
|
936
|
+
get searchAndFilter() {
|
937
|
+
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
938
|
+
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
939
|
+
return __privateGet$7(this, _namespaces).searchAndFilter;
|
940
|
+
}
|
609
941
|
}
|
610
942
|
_extraProps = new WeakMap();
|
611
943
|
_namespaces = new WeakMap();
|
@@ -616,24 +948,29 @@ class UserApi {
|
|
616
948
|
getUser() {
|
617
949
|
return operationsByTag.users.getUser({ ...this.extraProps });
|
618
950
|
}
|
619
|
-
updateUser(user) {
|
951
|
+
updateUser({ user }) {
|
620
952
|
return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
|
621
953
|
}
|
622
954
|
deleteUser() {
|
623
955
|
return operationsByTag.users.deleteUser({ ...this.extraProps });
|
624
956
|
}
|
957
|
+
}
|
958
|
+
class AuthenticationApi {
|
959
|
+
constructor(extraProps) {
|
960
|
+
this.extraProps = extraProps;
|
961
|
+
}
|
625
962
|
getUserAPIKeys() {
|
626
|
-
return operationsByTag.
|
963
|
+
return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
|
627
964
|
}
|
628
|
-
createUserAPIKey(
|
629
|
-
return operationsByTag.
|
630
|
-
pathParams: { keyName },
|
965
|
+
createUserAPIKey({ name }) {
|
966
|
+
return operationsByTag.authentication.createUserAPIKey({
|
967
|
+
pathParams: { keyName: name },
|
631
968
|
...this.extraProps
|
632
969
|
});
|
633
970
|
}
|
634
|
-
deleteUserAPIKey(
|
635
|
-
return operationsByTag.
|
636
|
-
pathParams: { keyName },
|
971
|
+
deleteUserAPIKey({ name }) {
|
972
|
+
return operationsByTag.authentication.deleteUserAPIKey({
|
973
|
+
pathParams: { keyName: name },
|
637
974
|
...this.extraProps
|
638
975
|
});
|
639
976
|
}
|
@@ -642,359 +979,897 @@ class WorkspaceApi {
|
|
642
979
|
constructor(extraProps) {
|
643
980
|
this.extraProps = extraProps;
|
644
981
|
}
|
645
|
-
|
982
|
+
getWorkspacesList() {
|
983
|
+
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
984
|
+
}
|
985
|
+
createWorkspace({ data }) {
|
646
986
|
return operationsByTag.workspaces.createWorkspace({
|
647
|
-
body:
|
987
|
+
body: data,
|
648
988
|
...this.extraProps
|
649
989
|
});
|
650
990
|
}
|
651
|
-
|
652
|
-
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
653
|
-
}
|
654
|
-
getWorkspace(workspaceId) {
|
991
|
+
getWorkspace({ workspace }) {
|
655
992
|
return operationsByTag.workspaces.getWorkspace({
|
656
|
-
pathParams: { workspaceId },
|
993
|
+
pathParams: { workspaceId: workspace },
|
657
994
|
...this.extraProps
|
658
995
|
});
|
659
996
|
}
|
660
|
-
updateWorkspace(
|
997
|
+
updateWorkspace({
|
998
|
+
workspace,
|
999
|
+
update
|
1000
|
+
}) {
|
661
1001
|
return operationsByTag.workspaces.updateWorkspace({
|
662
|
-
pathParams: { workspaceId },
|
663
|
-
body:
|
1002
|
+
pathParams: { workspaceId: workspace },
|
1003
|
+
body: update,
|
664
1004
|
...this.extraProps
|
665
1005
|
});
|
666
1006
|
}
|
667
|
-
deleteWorkspace(
|
1007
|
+
deleteWorkspace({ workspace }) {
|
668
1008
|
return operationsByTag.workspaces.deleteWorkspace({
|
669
|
-
pathParams: { workspaceId },
|
1009
|
+
pathParams: { workspaceId: workspace },
|
670
1010
|
...this.extraProps
|
671
1011
|
});
|
672
1012
|
}
|
673
|
-
getWorkspaceMembersList(
|
1013
|
+
getWorkspaceMembersList({ workspace }) {
|
674
1014
|
return operationsByTag.workspaces.getWorkspaceMembersList({
|
675
|
-
pathParams: { workspaceId },
|
1015
|
+
pathParams: { workspaceId: workspace },
|
676
1016
|
...this.extraProps
|
677
1017
|
});
|
678
1018
|
}
|
679
|
-
updateWorkspaceMemberRole(
|
1019
|
+
updateWorkspaceMemberRole({
|
1020
|
+
workspace,
|
1021
|
+
user,
|
1022
|
+
role
|
1023
|
+
}) {
|
680
1024
|
return operationsByTag.workspaces.updateWorkspaceMemberRole({
|
681
|
-
pathParams: { workspaceId, userId },
|
1025
|
+
pathParams: { workspaceId: workspace, userId: user },
|
682
1026
|
body: { role },
|
683
1027
|
...this.extraProps
|
684
1028
|
});
|
685
1029
|
}
|
686
|
-
removeWorkspaceMember(
|
1030
|
+
removeWorkspaceMember({
|
1031
|
+
workspace,
|
1032
|
+
user
|
1033
|
+
}) {
|
687
1034
|
return operationsByTag.workspaces.removeWorkspaceMember({
|
688
|
-
pathParams: { workspaceId, userId },
|
1035
|
+
pathParams: { workspaceId: workspace, userId: user },
|
689
1036
|
...this.extraProps
|
690
1037
|
});
|
691
1038
|
}
|
692
|
-
|
693
|
-
|
694
|
-
|
1039
|
+
}
|
1040
|
+
class InvitesApi {
|
1041
|
+
constructor(extraProps) {
|
1042
|
+
this.extraProps = extraProps;
|
1043
|
+
}
|
1044
|
+
inviteWorkspaceMember({
|
1045
|
+
workspace,
|
1046
|
+
email,
|
1047
|
+
role
|
1048
|
+
}) {
|
1049
|
+
return operationsByTag.invites.inviteWorkspaceMember({
|
1050
|
+
pathParams: { workspaceId: workspace },
|
695
1051
|
body: { email, role },
|
696
1052
|
...this.extraProps
|
697
1053
|
});
|
698
1054
|
}
|
699
|
-
updateWorkspaceMemberInvite(
|
700
|
-
|
701
|
-
|
1055
|
+
updateWorkspaceMemberInvite({
|
1056
|
+
workspace,
|
1057
|
+
invite,
|
1058
|
+
role
|
1059
|
+
}) {
|
1060
|
+
return operationsByTag.invites.updateWorkspaceMemberInvite({
|
1061
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
702
1062
|
body: { role },
|
703
1063
|
...this.extraProps
|
704
1064
|
});
|
705
1065
|
}
|
706
|
-
cancelWorkspaceMemberInvite(
|
707
|
-
|
708
|
-
|
1066
|
+
cancelWorkspaceMemberInvite({
|
1067
|
+
workspace,
|
1068
|
+
invite
|
1069
|
+
}) {
|
1070
|
+
return operationsByTag.invites.cancelWorkspaceMemberInvite({
|
1071
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
709
1072
|
...this.extraProps
|
710
1073
|
});
|
711
1074
|
}
|
712
|
-
|
713
|
-
|
714
|
-
|
1075
|
+
acceptWorkspaceMemberInvite({
|
1076
|
+
workspace,
|
1077
|
+
key
|
1078
|
+
}) {
|
1079
|
+
return operationsByTag.invites.acceptWorkspaceMemberInvite({
|
1080
|
+
pathParams: { workspaceId: workspace, inviteKey: key },
|
715
1081
|
...this.extraProps
|
716
1082
|
});
|
717
1083
|
}
|
718
|
-
|
719
|
-
|
720
|
-
|
1084
|
+
resendWorkspaceMemberInvite({
|
1085
|
+
workspace,
|
1086
|
+
invite
|
1087
|
+
}) {
|
1088
|
+
return operationsByTag.invites.resendWorkspaceMemberInvite({
|
1089
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
721
1090
|
...this.extraProps
|
722
1091
|
});
|
723
1092
|
}
|
724
1093
|
}
|
725
|
-
class
|
1094
|
+
class BranchApi {
|
726
1095
|
constructor(extraProps) {
|
727
1096
|
this.extraProps = extraProps;
|
728
1097
|
}
|
729
|
-
|
730
|
-
|
731
|
-
|
1098
|
+
getBranchList({
|
1099
|
+
workspace,
|
1100
|
+
region,
|
1101
|
+
database
|
1102
|
+
}) {
|
1103
|
+
return operationsByTag.branch.getBranchList({
|
1104
|
+
pathParams: { workspace, region, dbName: database },
|
1105
|
+
...this.extraProps
|
1106
|
+
});
|
1107
|
+
}
|
1108
|
+
getBranchDetails({
|
1109
|
+
workspace,
|
1110
|
+
region,
|
1111
|
+
database,
|
1112
|
+
branch
|
1113
|
+
}) {
|
1114
|
+
return operationsByTag.branch.getBranchDetails({
|
1115
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1116
|
+
...this.extraProps
|
1117
|
+
});
|
1118
|
+
}
|
1119
|
+
createBranch({
|
1120
|
+
workspace,
|
1121
|
+
region,
|
1122
|
+
database,
|
1123
|
+
branch,
|
1124
|
+
from,
|
1125
|
+
metadata
|
1126
|
+
}) {
|
1127
|
+
return operationsByTag.branch.createBranch({
|
1128
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1129
|
+
body: { from, metadata },
|
1130
|
+
...this.extraProps
|
1131
|
+
});
|
1132
|
+
}
|
1133
|
+
deleteBranch({
|
1134
|
+
workspace,
|
1135
|
+
region,
|
1136
|
+
database,
|
1137
|
+
branch
|
1138
|
+
}) {
|
1139
|
+
return operationsByTag.branch.deleteBranch({
|
1140
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1141
|
+
...this.extraProps
|
1142
|
+
});
|
1143
|
+
}
|
1144
|
+
updateBranchMetadata({
|
1145
|
+
workspace,
|
1146
|
+
region,
|
1147
|
+
database,
|
1148
|
+
branch,
|
1149
|
+
metadata
|
1150
|
+
}) {
|
1151
|
+
return operationsByTag.branch.updateBranchMetadata({
|
1152
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1153
|
+
body: metadata,
|
1154
|
+
...this.extraProps
|
1155
|
+
});
|
1156
|
+
}
|
1157
|
+
getBranchMetadata({
|
1158
|
+
workspace,
|
1159
|
+
region,
|
1160
|
+
database,
|
1161
|
+
branch
|
1162
|
+
}) {
|
1163
|
+
return operationsByTag.branch.getBranchMetadata({
|
1164
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1165
|
+
...this.extraProps
|
1166
|
+
});
|
1167
|
+
}
|
1168
|
+
getBranchStats({
|
1169
|
+
workspace,
|
1170
|
+
region,
|
1171
|
+
database,
|
1172
|
+
branch
|
1173
|
+
}) {
|
1174
|
+
return operationsByTag.branch.getBranchStats({
|
1175
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1176
|
+
...this.extraProps
|
1177
|
+
});
|
1178
|
+
}
|
1179
|
+
getGitBranchesMapping({
|
1180
|
+
workspace,
|
1181
|
+
region,
|
1182
|
+
database
|
1183
|
+
}) {
|
1184
|
+
return operationsByTag.branch.getGitBranchesMapping({
|
1185
|
+
pathParams: { workspace, region, dbName: database },
|
1186
|
+
...this.extraProps
|
1187
|
+
});
|
1188
|
+
}
|
1189
|
+
addGitBranchesEntry({
|
1190
|
+
workspace,
|
1191
|
+
region,
|
1192
|
+
database,
|
1193
|
+
gitBranch,
|
1194
|
+
xataBranch
|
1195
|
+
}) {
|
1196
|
+
return operationsByTag.branch.addGitBranchesEntry({
|
1197
|
+
pathParams: { workspace, region, dbName: database },
|
1198
|
+
body: { gitBranch, xataBranch },
|
1199
|
+
...this.extraProps
|
1200
|
+
});
|
1201
|
+
}
|
1202
|
+
removeGitBranchesEntry({
|
1203
|
+
workspace,
|
1204
|
+
region,
|
1205
|
+
database,
|
1206
|
+
gitBranch
|
1207
|
+
}) {
|
1208
|
+
return operationsByTag.branch.removeGitBranchesEntry({
|
1209
|
+
pathParams: { workspace, region, dbName: database },
|
1210
|
+
queryParams: { gitBranch },
|
1211
|
+
...this.extraProps
|
1212
|
+
});
|
1213
|
+
}
|
1214
|
+
resolveBranch({
|
1215
|
+
workspace,
|
1216
|
+
region,
|
1217
|
+
database,
|
1218
|
+
gitBranch,
|
1219
|
+
fallbackBranch
|
1220
|
+
}) {
|
1221
|
+
return operationsByTag.branch.resolveBranch({
|
1222
|
+
pathParams: { workspace, region, dbName: database },
|
1223
|
+
queryParams: { gitBranch, fallbackBranch },
|
1224
|
+
...this.extraProps
|
1225
|
+
});
|
1226
|
+
}
|
1227
|
+
}
|
1228
|
+
class TableApi {
|
1229
|
+
constructor(extraProps) {
|
1230
|
+
this.extraProps = extraProps;
|
1231
|
+
}
|
1232
|
+
createTable({
|
1233
|
+
workspace,
|
1234
|
+
region,
|
1235
|
+
database,
|
1236
|
+
branch,
|
1237
|
+
table
|
1238
|
+
}) {
|
1239
|
+
return operationsByTag.table.createTable({
|
1240
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1241
|
+
...this.extraProps
|
1242
|
+
});
|
1243
|
+
}
|
1244
|
+
deleteTable({
|
1245
|
+
workspace,
|
1246
|
+
region,
|
1247
|
+
database,
|
1248
|
+
branch,
|
1249
|
+
table
|
1250
|
+
}) {
|
1251
|
+
return operationsByTag.table.deleteTable({
|
1252
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1253
|
+
...this.extraProps
|
1254
|
+
});
|
1255
|
+
}
|
1256
|
+
updateTable({
|
1257
|
+
workspace,
|
1258
|
+
region,
|
1259
|
+
database,
|
1260
|
+
branch,
|
1261
|
+
table,
|
1262
|
+
update
|
1263
|
+
}) {
|
1264
|
+
return operationsByTag.table.updateTable({
|
1265
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1266
|
+
body: update,
|
1267
|
+
...this.extraProps
|
1268
|
+
});
|
1269
|
+
}
|
1270
|
+
getTableSchema({
|
1271
|
+
workspace,
|
1272
|
+
region,
|
1273
|
+
database,
|
1274
|
+
branch,
|
1275
|
+
table
|
1276
|
+
}) {
|
1277
|
+
return operationsByTag.table.getTableSchema({
|
1278
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1279
|
+
...this.extraProps
|
1280
|
+
});
|
1281
|
+
}
|
1282
|
+
setTableSchema({
|
1283
|
+
workspace,
|
1284
|
+
region,
|
1285
|
+
database,
|
1286
|
+
branch,
|
1287
|
+
table,
|
1288
|
+
schema
|
1289
|
+
}) {
|
1290
|
+
return operationsByTag.table.setTableSchema({
|
1291
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1292
|
+
body: schema,
|
1293
|
+
...this.extraProps
|
1294
|
+
});
|
1295
|
+
}
|
1296
|
+
getTableColumns({
|
1297
|
+
workspace,
|
1298
|
+
region,
|
1299
|
+
database,
|
1300
|
+
branch,
|
1301
|
+
table
|
1302
|
+
}) {
|
1303
|
+
return operationsByTag.table.getTableColumns({
|
1304
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1305
|
+
...this.extraProps
|
1306
|
+
});
|
1307
|
+
}
|
1308
|
+
addTableColumn({
|
1309
|
+
workspace,
|
1310
|
+
region,
|
1311
|
+
database,
|
1312
|
+
branch,
|
1313
|
+
table,
|
1314
|
+
column
|
1315
|
+
}) {
|
1316
|
+
return operationsByTag.table.addTableColumn({
|
1317
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1318
|
+
body: column,
|
1319
|
+
...this.extraProps
|
1320
|
+
});
|
1321
|
+
}
|
1322
|
+
getColumn({
|
1323
|
+
workspace,
|
1324
|
+
region,
|
1325
|
+
database,
|
1326
|
+
branch,
|
1327
|
+
table,
|
1328
|
+
column
|
1329
|
+
}) {
|
1330
|
+
return operationsByTag.table.getColumn({
|
1331
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1332
|
+
...this.extraProps
|
1333
|
+
});
|
1334
|
+
}
|
1335
|
+
updateColumn({
|
1336
|
+
workspace,
|
1337
|
+
region,
|
1338
|
+
database,
|
1339
|
+
branch,
|
1340
|
+
table,
|
1341
|
+
column,
|
1342
|
+
update
|
1343
|
+
}) {
|
1344
|
+
return operationsByTag.table.updateColumn({
|
1345
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1346
|
+
body: update,
|
1347
|
+
...this.extraProps
|
1348
|
+
});
|
1349
|
+
}
|
1350
|
+
deleteColumn({
|
1351
|
+
workspace,
|
1352
|
+
region,
|
1353
|
+
database,
|
1354
|
+
branch,
|
1355
|
+
table,
|
1356
|
+
column
|
1357
|
+
}) {
|
1358
|
+
return operationsByTag.table.deleteColumn({
|
1359
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1360
|
+
...this.extraProps
|
1361
|
+
});
|
1362
|
+
}
|
1363
|
+
}
|
1364
|
+
class RecordsApi {
|
1365
|
+
constructor(extraProps) {
|
1366
|
+
this.extraProps = extraProps;
|
1367
|
+
}
|
1368
|
+
insertRecord({
|
1369
|
+
workspace,
|
1370
|
+
region,
|
1371
|
+
database,
|
1372
|
+
branch,
|
1373
|
+
table,
|
1374
|
+
record,
|
1375
|
+
columns
|
1376
|
+
}) {
|
1377
|
+
return operationsByTag.records.insertRecord({
|
1378
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1379
|
+
queryParams: { columns },
|
1380
|
+
body: record,
|
1381
|
+
...this.extraProps
|
1382
|
+
});
|
1383
|
+
}
|
1384
|
+
getRecord({
|
1385
|
+
workspace,
|
1386
|
+
region,
|
1387
|
+
database,
|
1388
|
+
branch,
|
1389
|
+
table,
|
1390
|
+
id,
|
1391
|
+
columns
|
1392
|
+
}) {
|
1393
|
+
return operationsByTag.records.getRecord({
|
1394
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1395
|
+
queryParams: { columns },
|
1396
|
+
...this.extraProps
|
1397
|
+
});
|
1398
|
+
}
|
1399
|
+
insertRecordWithID({
|
1400
|
+
workspace,
|
1401
|
+
region,
|
1402
|
+
database,
|
1403
|
+
branch,
|
1404
|
+
table,
|
1405
|
+
id,
|
1406
|
+
record,
|
1407
|
+
columns,
|
1408
|
+
createOnly,
|
1409
|
+
ifVersion
|
1410
|
+
}) {
|
1411
|
+
return operationsByTag.records.insertRecordWithID({
|
1412
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1413
|
+
queryParams: { columns, createOnly, ifVersion },
|
1414
|
+
body: record,
|
1415
|
+
...this.extraProps
|
1416
|
+
});
|
1417
|
+
}
|
1418
|
+
updateRecordWithID({
|
1419
|
+
workspace,
|
1420
|
+
region,
|
1421
|
+
database,
|
1422
|
+
branch,
|
1423
|
+
table,
|
1424
|
+
id,
|
1425
|
+
record,
|
1426
|
+
columns,
|
1427
|
+
ifVersion
|
1428
|
+
}) {
|
1429
|
+
return operationsByTag.records.updateRecordWithID({
|
1430
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1431
|
+
queryParams: { columns, ifVersion },
|
1432
|
+
body: record,
|
1433
|
+
...this.extraProps
|
1434
|
+
});
|
1435
|
+
}
|
1436
|
+
upsertRecordWithID({
|
1437
|
+
workspace,
|
1438
|
+
region,
|
1439
|
+
database,
|
1440
|
+
branch,
|
1441
|
+
table,
|
1442
|
+
id,
|
1443
|
+
record,
|
1444
|
+
columns,
|
1445
|
+
ifVersion
|
1446
|
+
}) {
|
1447
|
+
return operationsByTag.records.upsertRecordWithID({
|
1448
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1449
|
+
queryParams: { columns, ifVersion },
|
1450
|
+
body: record,
|
1451
|
+
...this.extraProps
|
1452
|
+
});
|
1453
|
+
}
|
1454
|
+
deleteRecord({
|
1455
|
+
workspace,
|
1456
|
+
region,
|
1457
|
+
database,
|
1458
|
+
branch,
|
1459
|
+
table,
|
1460
|
+
id,
|
1461
|
+
columns
|
1462
|
+
}) {
|
1463
|
+
return operationsByTag.records.deleteRecord({
|
1464
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1465
|
+
queryParams: { columns },
|
1466
|
+
...this.extraProps
|
1467
|
+
});
|
1468
|
+
}
|
1469
|
+
bulkInsertTableRecords({
|
1470
|
+
workspace,
|
1471
|
+
region,
|
1472
|
+
database,
|
1473
|
+
branch,
|
1474
|
+
table,
|
1475
|
+
records,
|
1476
|
+
columns
|
1477
|
+
}) {
|
1478
|
+
return operationsByTag.records.bulkInsertTableRecords({
|
1479
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1480
|
+
queryParams: { columns },
|
1481
|
+
body: { records },
|
732
1482
|
...this.extraProps
|
733
1483
|
});
|
734
1484
|
}
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
1485
|
+
branchTransaction({
|
1486
|
+
workspace,
|
1487
|
+
region,
|
1488
|
+
database,
|
1489
|
+
branch,
|
1490
|
+
operations
|
1491
|
+
}) {
|
1492
|
+
return operationsByTag.records.branchTransaction({
|
1493
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1494
|
+
body: { operations },
|
739
1495
|
...this.extraProps
|
740
1496
|
});
|
741
1497
|
}
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
});
|
1498
|
+
}
|
1499
|
+
class SearchAndFilterApi {
|
1500
|
+
constructor(extraProps) {
|
1501
|
+
this.extraProps = extraProps;
|
747
1502
|
}
|
748
|
-
|
749
|
-
|
750
|
-
|
1503
|
+
queryTable({
|
1504
|
+
workspace,
|
1505
|
+
region,
|
1506
|
+
database,
|
1507
|
+
branch,
|
1508
|
+
table,
|
1509
|
+
filter,
|
1510
|
+
sort,
|
1511
|
+
page,
|
1512
|
+
columns,
|
1513
|
+
consistency
|
1514
|
+
}) {
|
1515
|
+
return operationsByTag.searchAndFilter.queryTable({
|
1516
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1517
|
+
body: { filter, sort, page, columns, consistency },
|
751
1518
|
...this.extraProps
|
752
1519
|
});
|
753
1520
|
}
|
754
|
-
|
755
|
-
|
756
|
-
|
1521
|
+
searchTable({
|
1522
|
+
workspace,
|
1523
|
+
region,
|
1524
|
+
database,
|
1525
|
+
branch,
|
1526
|
+
table,
|
1527
|
+
query,
|
1528
|
+
fuzziness,
|
1529
|
+
target,
|
1530
|
+
prefix,
|
1531
|
+
filter,
|
1532
|
+
highlight,
|
1533
|
+
boosters
|
1534
|
+
}) {
|
1535
|
+
return operationsByTag.searchAndFilter.searchTable({
|
1536
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1537
|
+
body: { query, fuzziness, target, prefix, filter, highlight, boosters },
|
757
1538
|
...this.extraProps
|
758
1539
|
});
|
759
1540
|
}
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
1541
|
+
searchBranch({
|
1542
|
+
workspace,
|
1543
|
+
region,
|
1544
|
+
database,
|
1545
|
+
branch,
|
1546
|
+
tables,
|
1547
|
+
query,
|
1548
|
+
fuzziness,
|
1549
|
+
prefix,
|
1550
|
+
highlight
|
1551
|
+
}) {
|
1552
|
+
return operationsByTag.searchAndFilter.searchBranch({
|
1553
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1554
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
764
1555
|
...this.extraProps
|
765
1556
|
});
|
766
1557
|
}
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
1558
|
+
summarizeTable({
|
1559
|
+
workspace,
|
1560
|
+
region,
|
1561
|
+
database,
|
1562
|
+
branch,
|
1563
|
+
table,
|
1564
|
+
filter,
|
1565
|
+
columns,
|
1566
|
+
summaries,
|
1567
|
+
sort,
|
1568
|
+
summariesFilter,
|
1569
|
+
page,
|
1570
|
+
consistency
|
1571
|
+
}) {
|
1572
|
+
return operationsByTag.searchAndFilter.summarizeTable({
|
1573
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1574
|
+
body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
|
771
1575
|
...this.extraProps
|
772
1576
|
});
|
773
1577
|
}
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
1578
|
+
aggregateTable({
|
1579
|
+
workspace,
|
1580
|
+
region,
|
1581
|
+
database,
|
1582
|
+
branch,
|
1583
|
+
table,
|
1584
|
+
filter,
|
1585
|
+
aggs
|
1586
|
+
}) {
|
1587
|
+
return operationsByTag.searchAndFilter.aggregateTable({
|
1588
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1589
|
+
body: { filter, aggs },
|
778
1590
|
...this.extraProps
|
779
1591
|
});
|
780
1592
|
}
|
781
1593
|
}
|
782
|
-
class
|
1594
|
+
class MigrationRequestsApi {
|
783
1595
|
constructor(extraProps) {
|
784
1596
|
this.extraProps = extraProps;
|
785
1597
|
}
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
createBranch(workspace, database, branch, from, options = {}) {
|
799
|
-
return operationsByTag.branch.createBranch({
|
800
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
801
|
-
queryParams: isString(from) ? { from } : void 0,
|
802
|
-
body: options,
|
1598
|
+
queryMigrationRequests({
|
1599
|
+
workspace,
|
1600
|
+
region,
|
1601
|
+
database,
|
1602
|
+
filter,
|
1603
|
+
sort,
|
1604
|
+
page,
|
1605
|
+
columns
|
1606
|
+
}) {
|
1607
|
+
return operationsByTag.migrationRequests.queryMigrationRequests({
|
1608
|
+
pathParams: { workspace, region, dbName: database },
|
1609
|
+
body: { filter, sort, page, columns },
|
803
1610
|
...this.extraProps
|
804
1611
|
});
|
805
1612
|
}
|
806
|
-
|
807
|
-
|
808
|
-
|
1613
|
+
createMigrationRequest({
|
1614
|
+
workspace,
|
1615
|
+
region,
|
1616
|
+
database,
|
1617
|
+
migration
|
1618
|
+
}) {
|
1619
|
+
return operationsByTag.migrationRequests.createMigrationRequest({
|
1620
|
+
pathParams: { workspace, region, dbName: database },
|
1621
|
+
body: migration,
|
809
1622
|
...this.extraProps
|
810
1623
|
});
|
811
1624
|
}
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
1625
|
+
getMigrationRequest({
|
1626
|
+
workspace,
|
1627
|
+
region,
|
1628
|
+
database,
|
1629
|
+
migrationRequest
|
1630
|
+
}) {
|
1631
|
+
return operationsByTag.migrationRequests.getMigrationRequest({
|
1632
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
816
1633
|
...this.extraProps
|
817
1634
|
});
|
818
1635
|
}
|
819
|
-
|
820
|
-
|
821
|
-
|
1636
|
+
updateMigrationRequest({
|
1637
|
+
workspace,
|
1638
|
+
region,
|
1639
|
+
database,
|
1640
|
+
migrationRequest,
|
1641
|
+
update
|
1642
|
+
}) {
|
1643
|
+
return operationsByTag.migrationRequests.updateMigrationRequest({
|
1644
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1645
|
+
body: update,
|
822
1646
|
...this.extraProps
|
823
1647
|
});
|
824
1648
|
}
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
1649
|
+
listMigrationRequestsCommits({
|
1650
|
+
workspace,
|
1651
|
+
region,
|
1652
|
+
database,
|
1653
|
+
migrationRequest,
|
1654
|
+
page
|
1655
|
+
}) {
|
1656
|
+
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
1657
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1658
|
+
body: { page },
|
829
1659
|
...this.extraProps
|
830
1660
|
});
|
831
1661
|
}
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
1662
|
+
compareMigrationRequest({
|
1663
|
+
workspace,
|
1664
|
+
region,
|
1665
|
+
database,
|
1666
|
+
migrationRequest
|
1667
|
+
}) {
|
1668
|
+
return operationsByTag.migrationRequests.compareMigrationRequest({
|
1669
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
836
1670
|
...this.extraProps
|
837
1671
|
});
|
838
1672
|
}
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
1673
|
+
getMigrationRequestIsMerged({
|
1674
|
+
workspace,
|
1675
|
+
region,
|
1676
|
+
database,
|
1677
|
+
migrationRequest
|
1678
|
+
}) {
|
1679
|
+
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
1680
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
843
1681
|
...this.extraProps
|
844
1682
|
});
|
845
1683
|
}
|
846
|
-
|
847
|
-
|
848
|
-
|
1684
|
+
mergeMigrationRequest({
|
1685
|
+
workspace,
|
1686
|
+
region,
|
1687
|
+
database,
|
1688
|
+
migrationRequest
|
1689
|
+
}) {
|
1690
|
+
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
1691
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
849
1692
|
...this.extraProps
|
850
1693
|
});
|
851
1694
|
}
|
852
1695
|
}
|
853
|
-
class
|
1696
|
+
class MigrationsApi {
|
854
1697
|
constructor(extraProps) {
|
855
1698
|
this.extraProps = extraProps;
|
856
1699
|
}
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
1700
|
+
getBranchMigrationHistory({
|
1701
|
+
workspace,
|
1702
|
+
region,
|
1703
|
+
database,
|
1704
|
+
branch,
|
1705
|
+
limit,
|
1706
|
+
startFrom
|
1707
|
+
}) {
|
1708
|
+
return operationsByTag.migrations.getBranchMigrationHistory({
|
1709
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1710
|
+
body: { limit, startFrom },
|
866
1711
|
...this.extraProps
|
867
1712
|
});
|
868
1713
|
}
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
1714
|
+
getBranchMigrationPlan({
|
1715
|
+
workspace,
|
1716
|
+
region,
|
1717
|
+
database,
|
1718
|
+
branch,
|
1719
|
+
schema
|
1720
|
+
}) {
|
1721
|
+
return operationsByTag.migrations.getBranchMigrationPlan({
|
1722
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1723
|
+
body: schema,
|
873
1724
|
...this.extraProps
|
874
1725
|
});
|
875
1726
|
}
|
876
|
-
|
877
|
-
|
878
|
-
|
1727
|
+
executeBranchMigrationPlan({
|
1728
|
+
workspace,
|
1729
|
+
region,
|
1730
|
+
database,
|
1731
|
+
branch,
|
1732
|
+
plan
|
1733
|
+
}) {
|
1734
|
+
return operationsByTag.migrations.executeBranchMigrationPlan({
|
1735
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1736
|
+
body: plan,
|
879
1737
|
...this.extraProps
|
880
1738
|
});
|
881
1739
|
}
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
1740
|
+
getBranchSchemaHistory({
|
1741
|
+
workspace,
|
1742
|
+
region,
|
1743
|
+
database,
|
1744
|
+
branch,
|
1745
|
+
page
|
1746
|
+
}) {
|
1747
|
+
return operationsByTag.migrations.getBranchSchemaHistory({
|
1748
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1749
|
+
body: { page },
|
886
1750
|
...this.extraProps
|
887
1751
|
});
|
888
1752
|
}
|
889
|
-
|
890
|
-
|
891
|
-
|
1753
|
+
compareBranchWithUserSchema({
|
1754
|
+
workspace,
|
1755
|
+
region,
|
1756
|
+
database,
|
1757
|
+
branch,
|
1758
|
+
schema
|
1759
|
+
}) {
|
1760
|
+
return operationsByTag.migrations.compareBranchWithUserSchema({
|
1761
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1762
|
+
body: { schema },
|
892
1763
|
...this.extraProps
|
893
1764
|
});
|
894
1765
|
}
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
1766
|
+
compareBranchSchemas({
|
1767
|
+
workspace,
|
1768
|
+
region,
|
1769
|
+
database,
|
1770
|
+
branch,
|
1771
|
+
compare,
|
1772
|
+
schema
|
1773
|
+
}) {
|
1774
|
+
return operationsByTag.migrations.compareBranchSchemas({
|
1775
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
1776
|
+
body: { schema },
|
899
1777
|
...this.extraProps
|
900
1778
|
});
|
901
1779
|
}
|
902
|
-
|
903
|
-
|
904
|
-
|
1780
|
+
updateBranchSchema({
|
1781
|
+
workspace,
|
1782
|
+
region,
|
1783
|
+
database,
|
1784
|
+
branch,
|
1785
|
+
migration
|
1786
|
+
}) {
|
1787
|
+
return operationsByTag.migrations.updateBranchSchema({
|
1788
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1789
|
+
body: migration,
|
905
1790
|
...this.extraProps
|
906
1791
|
});
|
907
1792
|
}
|
908
|
-
|
909
|
-
|
910
|
-
|
1793
|
+
previewBranchSchemaEdit({
|
1794
|
+
workspace,
|
1795
|
+
region,
|
1796
|
+
database,
|
1797
|
+
branch,
|
1798
|
+
data
|
1799
|
+
}) {
|
1800
|
+
return operationsByTag.migrations.previewBranchSchemaEdit({
|
1801
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1802
|
+
body: data,
|
911
1803
|
...this.extraProps
|
912
1804
|
});
|
913
1805
|
}
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
1806
|
+
applyBranchSchemaEdit({
|
1807
|
+
workspace,
|
1808
|
+
region,
|
1809
|
+
database,
|
1810
|
+
branch,
|
1811
|
+
edits
|
1812
|
+
}) {
|
1813
|
+
return operationsByTag.migrations.applyBranchSchemaEdit({
|
1814
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1815
|
+
body: { edits },
|
918
1816
|
...this.extraProps
|
919
1817
|
});
|
920
1818
|
}
|
921
1819
|
}
|
922
|
-
class
|
1820
|
+
class DatabaseApi {
|
923
1821
|
constructor(extraProps) {
|
924
1822
|
this.extraProps = extraProps;
|
925
1823
|
}
|
926
|
-
|
927
|
-
return operationsByTag.
|
928
|
-
pathParams: {
|
929
|
-
queryParams: options,
|
930
|
-
body: record,
|
931
|
-
...this.extraProps
|
932
|
-
});
|
933
|
-
}
|
934
|
-
insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
|
935
|
-
return operationsByTag.records.insertRecordWithID({
|
936
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
937
|
-
queryParams: options,
|
938
|
-
body: record,
|
939
|
-
...this.extraProps
|
940
|
-
});
|
941
|
-
}
|
942
|
-
updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
|
943
|
-
return operationsByTag.records.updateRecordWithID({
|
944
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
945
|
-
queryParams: options,
|
946
|
-
body: record,
|
947
|
-
...this.extraProps
|
948
|
-
});
|
949
|
-
}
|
950
|
-
upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
|
951
|
-
return operationsByTag.records.upsertRecordWithID({
|
952
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
953
|
-
queryParams: options,
|
954
|
-
body: record,
|
955
|
-
...this.extraProps
|
956
|
-
});
|
957
|
-
}
|
958
|
-
deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
959
|
-
return operationsByTag.records.deleteRecord({
|
960
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
961
|
-
queryParams: options,
|
1824
|
+
getDatabaseList({ workspace }) {
|
1825
|
+
return operationsByTag.databases.getDatabaseList({
|
1826
|
+
pathParams: { workspaceId: workspace },
|
962
1827
|
...this.extraProps
|
963
1828
|
});
|
964
1829
|
}
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
1830
|
+
createDatabase({
|
1831
|
+
workspace,
|
1832
|
+
database,
|
1833
|
+
data
|
1834
|
+
}) {
|
1835
|
+
return operationsByTag.databases.createDatabase({
|
1836
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1837
|
+
body: data,
|
969
1838
|
...this.extraProps
|
970
1839
|
});
|
971
1840
|
}
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
1841
|
+
deleteDatabase({
|
1842
|
+
workspace,
|
1843
|
+
database
|
1844
|
+
}) {
|
1845
|
+
return operationsByTag.databases.deleteDatabase({
|
1846
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
977
1847
|
...this.extraProps
|
978
1848
|
});
|
979
1849
|
}
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
1850
|
+
getDatabaseMetadata({
|
1851
|
+
workspace,
|
1852
|
+
database
|
1853
|
+
}) {
|
1854
|
+
return operationsByTag.databases.getDatabaseMetadata({
|
1855
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
984
1856
|
...this.extraProps
|
985
1857
|
});
|
986
1858
|
}
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
1859
|
+
updateDatabaseMetadata({
|
1860
|
+
workspace,
|
1861
|
+
database,
|
1862
|
+
metadata
|
1863
|
+
}) {
|
1864
|
+
return operationsByTag.databases.updateDatabaseMetadata({
|
1865
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1866
|
+
body: metadata,
|
991
1867
|
...this.extraProps
|
992
1868
|
});
|
993
1869
|
}
|
994
|
-
|
995
|
-
return operationsByTag.
|
996
|
-
pathParams: {
|
997
|
-
body: query,
|
1870
|
+
listRegions({ workspace }) {
|
1871
|
+
return operationsByTag.databases.listRegions({
|
1872
|
+
pathParams: { workspaceId: workspace },
|
998
1873
|
...this.extraProps
|
999
1874
|
});
|
1000
1875
|
}
|
@@ -1010,6 +1885,20 @@ class XataApiPlugin {
|
|
1010
1885
|
class XataPlugin {
|
1011
1886
|
}
|
1012
1887
|
|
1888
|
+
function generateUUID() {
|
1889
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
1890
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
1891
|
+
return v.toString(16);
|
1892
|
+
});
|
1893
|
+
}
|
1894
|
+
|
1895
|
+
function cleanFilter(filter) {
|
1896
|
+
if (!filter)
|
1897
|
+
return void 0;
|
1898
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
1899
|
+
return values.length > 0 ? filter : void 0;
|
1900
|
+
}
|
1901
|
+
|
1013
1902
|
var __accessCheck$6 = (obj, member, msg) => {
|
1014
1903
|
if (!member.has(obj))
|
1015
1904
|
throw TypeError("Cannot " + msg);
|
@@ -1042,11 +1931,11 @@ class Page {
|
|
1042
1931
|
async previousPage(size, offset) {
|
1043
1932
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
1044
1933
|
}
|
1045
|
-
async
|
1046
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
1934
|
+
async startPage(size, offset) {
|
1935
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
1047
1936
|
}
|
1048
|
-
async
|
1049
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
1937
|
+
async endPage(size, offset) {
|
1938
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
1050
1939
|
}
|
1051
1940
|
hasNextPage() {
|
1052
1941
|
return this.meta.page.more;
|
@@ -1058,7 +1947,7 @@ const PAGINATION_DEFAULT_SIZE = 20;
|
|
1058
1947
|
const PAGINATION_MAX_OFFSET = 800;
|
1059
1948
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
1060
1949
|
function isCursorPaginationOptions(options) {
|
1061
|
-
return isDefined(options) && (isDefined(options.
|
1950
|
+
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
1062
1951
|
}
|
1063
1952
|
const _RecordArray = class extends Array {
|
1064
1953
|
constructor(...args) {
|
@@ -1090,12 +1979,12 @@ const _RecordArray = class extends Array {
|
|
1090
1979
|
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
1091
1980
|
return new _RecordArray(newPage);
|
1092
1981
|
}
|
1093
|
-
async
|
1094
|
-
const newPage = await __privateGet$6(this, _page).
|
1982
|
+
async startPage(size, offset) {
|
1983
|
+
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
1095
1984
|
return new _RecordArray(newPage);
|
1096
1985
|
}
|
1097
|
-
async
|
1098
|
-
const newPage = await __privateGet$6(this, _page).
|
1986
|
+
async endPage(size, offset) {
|
1987
|
+
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
1099
1988
|
return new _RecordArray(newPage);
|
1100
1989
|
}
|
1101
1990
|
hasNextPage() {
|
@@ -1123,9 +2012,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
|
|
1123
2012
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1124
2013
|
return value;
|
1125
2014
|
};
|
1126
|
-
var
|
2015
|
+
var __privateMethod$3 = (obj, member, method) => {
|
2016
|
+
__accessCheck$5(obj, member, "access private method");
|
2017
|
+
return method;
|
2018
|
+
};
|
2019
|
+
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
1127
2020
|
const _Query = class {
|
1128
2021
|
constructor(repository, table, data, rawParent) {
|
2022
|
+
__privateAdd$5(this, _cleanFilterConstraint);
|
1129
2023
|
__privateAdd$5(this, _table$1, void 0);
|
1130
2024
|
__privateAdd$5(this, _repository, void 0);
|
1131
2025
|
__privateAdd$5(this, _data, { filter: {} });
|
@@ -1144,9 +2038,10 @@ const _Query = class {
|
|
1144
2038
|
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
1145
2039
|
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
1146
2040
|
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
1147
|
-
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns
|
2041
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
|
1148
2042
|
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
1149
2043
|
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
2044
|
+
__privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
|
1150
2045
|
this.any = this.any.bind(this);
|
1151
2046
|
this.all = this.all.bind(this);
|
1152
2047
|
this.not = this.not.bind(this);
|
@@ -1182,15 +2077,18 @@ const _Query = class {
|
|
1182
2077
|
}
|
1183
2078
|
filter(a, b) {
|
1184
2079
|
if (arguments.length === 1) {
|
1185
|
-
const constraints = Object.entries(a).map(([column, constraint]) => ({
|
2080
|
+
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
2081
|
+
[column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
|
2082
|
+
}));
|
1186
2083
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1187
2084
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1188
2085
|
} else {
|
1189
|
-
const
|
2086
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
|
2087
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1190
2088
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1191
2089
|
}
|
1192
2090
|
}
|
1193
|
-
sort(column, direction) {
|
2091
|
+
sort(column, direction = "asc") {
|
1194
2092
|
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
1195
2093
|
const sort = [...originalSort, { column, direction }];
|
1196
2094
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
@@ -1224,11 +2122,20 @@ const _Query = class {
|
|
1224
2122
|
}
|
1225
2123
|
}
|
1226
2124
|
async getMany(options = {}) {
|
1227
|
-
const
|
2125
|
+
const { pagination = {}, ...rest } = options;
|
2126
|
+
const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
|
2127
|
+
const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
|
2128
|
+
let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
|
2129
|
+
const results = [...page.records];
|
2130
|
+
while (page.hasNextPage() && results.length < size) {
|
2131
|
+
page = await page.nextPage();
|
2132
|
+
results.push(...page.records);
|
2133
|
+
}
|
1228
2134
|
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
1229
2135
|
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
1230
2136
|
}
|
1231
|
-
|
2137
|
+
const array = new RecordArray(page, results.slice(0, size));
|
2138
|
+
return array;
|
1232
2139
|
}
|
1233
2140
|
async getAll(options = {}) {
|
1234
2141
|
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
@@ -1242,19 +2149,35 @@ const _Query = class {
|
|
1242
2149
|
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1243
2150
|
return records[0] ?? null;
|
1244
2151
|
}
|
2152
|
+
async getFirstOrThrow(options = {}) {
|
2153
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
2154
|
+
if (records[0] === void 0)
|
2155
|
+
throw new Error("No results found.");
|
2156
|
+
return records[0];
|
2157
|
+
}
|
2158
|
+
async summarize(params = {}) {
|
2159
|
+
const { summaries, summariesFilter, ...options } = params;
|
2160
|
+
const query = new _Query(
|
2161
|
+
__privateGet$5(this, _repository),
|
2162
|
+
__privateGet$5(this, _table$1),
|
2163
|
+
options,
|
2164
|
+
__privateGet$5(this, _data)
|
2165
|
+
);
|
2166
|
+
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
2167
|
+
}
|
1245
2168
|
cache(ttl) {
|
1246
2169
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1247
2170
|
}
|
1248
2171
|
nextPage(size, offset) {
|
1249
|
-
return this.
|
2172
|
+
return this.startPage(size, offset);
|
1250
2173
|
}
|
1251
2174
|
previousPage(size, offset) {
|
1252
|
-
return this.
|
2175
|
+
return this.startPage(size, offset);
|
1253
2176
|
}
|
1254
|
-
|
2177
|
+
startPage(size, offset) {
|
1255
2178
|
return this.getPaginated({ pagination: { size, offset } });
|
1256
2179
|
}
|
1257
|
-
|
2180
|
+
endPage(size, offset) {
|
1258
2181
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
1259
2182
|
}
|
1260
2183
|
hasNextPage() {
|
@@ -1265,9 +2188,20 @@ let Query = _Query;
|
|
1265
2188
|
_table$1 = new WeakMap();
|
1266
2189
|
_repository = new WeakMap();
|
1267
2190
|
_data = new WeakMap();
|
2191
|
+
_cleanFilterConstraint = new WeakSet();
|
2192
|
+
cleanFilterConstraint_fn = function(column, value) {
|
2193
|
+
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
2194
|
+
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
2195
|
+
return { $includes: value };
|
2196
|
+
}
|
2197
|
+
if (columnType === "link" && isObject(value) && isString(value.id)) {
|
2198
|
+
return value.id;
|
2199
|
+
}
|
2200
|
+
return value;
|
2201
|
+
};
|
1268
2202
|
function cleanParent(data, parent) {
|
1269
2203
|
if (isCursorPaginationOptions(data.pagination)) {
|
1270
|
-
return { ...parent,
|
2204
|
+
return { ...parent, sort: void 0, filter: void 0 };
|
1271
2205
|
}
|
1272
2206
|
return parent;
|
1273
2207
|
}
|
@@ -1326,18 +2260,25 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
1326
2260
|
__accessCheck$4(obj, member, "access private method");
|
1327
2261
|
return method;
|
1328
2262
|
};
|
1329
|
-
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn,
|
2263
|
+
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;
|
2264
|
+
const BULK_OPERATION_MAX_SIZE = 1e3;
|
1330
2265
|
class Repository extends Query {
|
1331
2266
|
}
|
1332
2267
|
class RestRepository extends Query {
|
1333
2268
|
constructor(options) {
|
1334
|
-
super(
|
2269
|
+
super(
|
2270
|
+
null,
|
2271
|
+
{ name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
|
2272
|
+
{}
|
2273
|
+
);
|
1335
2274
|
__privateAdd$4(this, _insertRecordWithoutId);
|
1336
2275
|
__privateAdd$4(this, _insertRecordWithId);
|
1337
|
-
__privateAdd$4(this,
|
2276
|
+
__privateAdd$4(this, _insertRecords);
|
1338
2277
|
__privateAdd$4(this, _updateRecordWithID);
|
2278
|
+
__privateAdd$4(this, _updateRecords);
|
1339
2279
|
__privateAdd$4(this, _upsertRecordWithID);
|
1340
2280
|
__privateAdd$4(this, _deleteRecord);
|
2281
|
+
__privateAdd$4(this, _deleteRecords);
|
1341
2282
|
__privateAdd$4(this, _setCacheQuery);
|
1342
2283
|
__privateAdd$4(this, _getCacheQuery);
|
1343
2284
|
__privateAdd$4(this, _getSchemaTables$1);
|
@@ -1346,168 +2287,346 @@ class RestRepository extends Query {
|
|
1346
2287
|
__privateAdd$4(this, _db, void 0);
|
1347
2288
|
__privateAdd$4(this, _cache, void 0);
|
1348
2289
|
__privateAdd$4(this, _schemaTables$2, void 0);
|
2290
|
+
__privateAdd$4(this, _trace, void 0);
|
1349
2291
|
__privateSet$4(this, _table, options.table);
|
1350
|
-
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1351
2292
|
__privateSet$4(this, _db, options.db);
|
1352
2293
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
1353
2294
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
2295
|
+
__privateSet$4(this, _getFetchProps, async () => {
|
2296
|
+
const props = await options.pluginOptions.getFetchProps();
|
2297
|
+
return { ...props, sessionID: generateUUID() };
|
2298
|
+
});
|
2299
|
+
const trace = options.pluginOptions.trace ?? defaultTrace;
|
2300
|
+
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
2301
|
+
return trace(name, fn, {
|
2302
|
+
...options2,
|
2303
|
+
[TraceAttributes.TABLE]: __privateGet$4(this, _table),
|
2304
|
+
[TraceAttributes.KIND]: "sdk-operation",
|
2305
|
+
[TraceAttributes.VERSION]: VERSION
|
2306
|
+
});
|
2307
|
+
});
|
1354
2308
|
}
|
1355
|
-
async create(a, b, c) {
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
2309
|
+
async create(a, b, c, d) {
|
2310
|
+
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
2311
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2312
|
+
if (Array.isArray(a)) {
|
2313
|
+
if (a.length === 0)
|
2314
|
+
return [];
|
2315
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
2316
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2317
|
+
const result = await this.read(ids, columns);
|
2318
|
+
return result;
|
2319
|
+
}
|
2320
|
+
if (isString(a) && isObject(b)) {
|
2321
|
+
if (a === "")
|
2322
|
+
throw new Error("The id can't be empty");
|
2323
|
+
const columns = isStringArray(c) ? c : void 0;
|
2324
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
2325
|
+
}
|
2326
|
+
if (isObject(a) && isString(a.id)) {
|
2327
|
+
if (a.id === "")
|
2328
|
+
throw new Error("The id can't be empty");
|
2329
|
+
const columns = isStringArray(b) ? b : void 0;
|
2330
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
2331
|
+
}
|
2332
|
+
if (isObject(a)) {
|
2333
|
+
const columns = isStringArray(b) ? b : void 0;
|
2334
|
+
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
2335
|
+
}
|
2336
|
+
throw new Error("Invalid arguments for create method");
|
2337
|
+
});
|
1379
2338
|
}
|
1380
2339
|
async read(a, b) {
|
1381
|
-
|
1382
|
-
|
1383
|
-
if (a
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
acc
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
2340
|
+
return __privateGet$4(this, _trace).call(this, "read", async () => {
|
2341
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2342
|
+
if (Array.isArray(a)) {
|
2343
|
+
if (a.length === 0)
|
2344
|
+
return [];
|
2345
|
+
const ids = a.map((item) => extractId(item));
|
2346
|
+
const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
|
2347
|
+
const dictionary = finalObjects.reduce((acc, object) => {
|
2348
|
+
acc[object.id] = object;
|
2349
|
+
return acc;
|
2350
|
+
}, {});
|
2351
|
+
return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
|
2352
|
+
}
|
2353
|
+
const id = extractId(a);
|
2354
|
+
if (id) {
|
2355
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2356
|
+
try {
|
2357
|
+
const response = await getRecord({
|
2358
|
+
pathParams: {
|
2359
|
+
workspace: "{workspaceId}",
|
2360
|
+
dbBranchName: "{dbBranch}",
|
2361
|
+
region: "{region}",
|
2362
|
+
tableName: __privateGet$4(this, _table),
|
2363
|
+
recordId: id
|
2364
|
+
},
|
2365
|
+
queryParams: { columns },
|
2366
|
+
...fetchProps
|
2367
|
+
});
|
2368
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2369
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2370
|
+
} catch (e) {
|
2371
|
+
if (isObject(e) && e.status === 404) {
|
2372
|
+
return null;
|
2373
|
+
}
|
2374
|
+
throw e;
|
2375
|
+
}
|
2376
|
+
}
|
2377
|
+
return null;
|
2378
|
+
});
|
2379
|
+
}
|
2380
|
+
async readOrThrow(a, b) {
|
2381
|
+
return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
|
2382
|
+
const result = await this.read(a, b);
|
2383
|
+
if (Array.isArray(result)) {
|
2384
|
+
const missingIds = compact(
|
2385
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2386
|
+
);
|
2387
|
+
if (missingIds.length > 0) {
|
2388
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
2389
|
+
}
|
2390
|
+
return result;
|
2391
|
+
}
|
2392
|
+
if (result === null) {
|
2393
|
+
const id = extractId(a) ?? "unknown";
|
2394
|
+
throw new Error(`Record with id ${id} not found`);
|
2395
|
+
}
|
2396
|
+
return result;
|
2397
|
+
});
|
2398
|
+
}
|
2399
|
+
async update(a, b, c, d) {
|
2400
|
+
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
2401
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2402
|
+
if (Array.isArray(a)) {
|
2403
|
+
if (a.length === 0)
|
2404
|
+
return [];
|
2405
|
+
const existing = await this.read(a, ["id"]);
|
2406
|
+
const updates = a.filter((_item, index) => existing[index] !== null);
|
2407
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
|
2408
|
+
ifVersion,
|
2409
|
+
upsert: false
|
1401
2410
|
});
|
1402
|
-
const
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
2411
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2412
|
+
const result = await this.read(a, columns);
|
2413
|
+
return result;
|
2414
|
+
}
|
2415
|
+
if (isString(a) && isObject(b)) {
|
2416
|
+
const columns = isStringArray(c) ? c : void 0;
|
2417
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
2418
|
+
}
|
2419
|
+
if (isObject(a) && isString(a.id)) {
|
2420
|
+
const columns = isStringArray(b) ? b : void 0;
|
2421
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
2422
|
+
}
|
2423
|
+
throw new Error("Invalid arguments for update method");
|
2424
|
+
});
|
2425
|
+
}
|
2426
|
+
async updateOrThrow(a, b, c, d) {
|
2427
|
+
return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
|
2428
|
+
const result = await this.update(a, b, c, d);
|
2429
|
+
if (Array.isArray(result)) {
|
2430
|
+
const missingIds = compact(
|
2431
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2432
|
+
);
|
2433
|
+
if (missingIds.length > 0) {
|
2434
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
1407
2435
|
}
|
1408
|
-
|
2436
|
+
return result;
|
1409
2437
|
}
|
1410
|
-
|
1411
|
-
|
2438
|
+
if (result === null) {
|
2439
|
+
const id = extractId(a) ?? "unknown";
|
2440
|
+
throw new Error(`Record with id ${id} not found`);
|
2441
|
+
}
|
2442
|
+
return result;
|
2443
|
+
});
|
1412
2444
|
}
|
1413
|
-
async
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
2445
|
+
async createOrUpdate(a, b, c, d) {
|
2446
|
+
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
2447
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2448
|
+
if (Array.isArray(a)) {
|
2449
|
+
if (a.length === 0)
|
2450
|
+
return [];
|
2451
|
+
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
|
2452
|
+
ifVersion,
|
2453
|
+
upsert: true
|
2454
|
+
});
|
2455
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2456
|
+
const result = await this.read(a, columns);
|
2457
|
+
return result;
|
1419
2458
|
}
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
if (isString(a) && isObject(b)) {
|
1424
|
-
const columns = isStringArray(c) ? c : void 0;
|
1425
|
-
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
|
1426
|
-
}
|
1427
|
-
if (isObject(a) && isString(a.id)) {
|
1428
|
-
const columns = isStringArray(b) ? b : void 0;
|
1429
|
-
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1430
|
-
}
|
1431
|
-
throw new Error("Invalid arguments for update method");
|
1432
|
-
}
|
1433
|
-
async createOrUpdate(a, b, c) {
|
1434
|
-
if (Array.isArray(a)) {
|
1435
|
-
if (a.length === 0)
|
1436
|
-
return [];
|
1437
|
-
if (a.length > 100) {
|
1438
|
-
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
2459
|
+
if (isString(a) && isObject(b)) {
|
2460
|
+
const columns = isStringArray(c) ? c : void 0;
|
2461
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
1439
2462
|
}
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
if (isString(a) && isObject(b)) {
|
1444
|
-
const columns = isStringArray(c) ? c : void 0;
|
1445
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
|
1446
|
-
}
|
1447
|
-
if (isObject(a) && isString(a.id)) {
|
1448
|
-
const columns = isStringArray(c) ? c : void 0;
|
1449
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1450
|
-
}
|
1451
|
-
throw new Error("Invalid arguments for createOrUpdate method");
|
1452
|
-
}
|
1453
|
-
async delete(a) {
|
1454
|
-
if (Array.isArray(a)) {
|
1455
|
-
if (a.length === 0)
|
1456
|
-
return;
|
1457
|
-
if (a.length > 100) {
|
1458
|
-
console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
|
2463
|
+
if (isObject(a) && isString(a.id)) {
|
2464
|
+
const columns = isStringArray(c) ? c : void 0;
|
2465
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
1459
2466
|
}
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
2467
|
+
throw new Error("Invalid arguments for createOrUpdate method");
|
2468
|
+
});
|
2469
|
+
}
|
2470
|
+
async createOrReplace(a, b, c, d) {
|
2471
|
+
return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
|
2472
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2473
|
+
if (Array.isArray(a)) {
|
2474
|
+
if (a.length === 0)
|
2475
|
+
return [];
|
2476
|
+
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
2477
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2478
|
+
const result = await this.read(ids, columns);
|
2479
|
+
return result;
|
2480
|
+
}
|
2481
|
+
if (isString(a) && isObject(b)) {
|
2482
|
+
const columns = isStringArray(c) ? c : void 0;
|
2483
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
2484
|
+
}
|
2485
|
+
if (isObject(a) && isString(a.id)) {
|
2486
|
+
const columns = isStringArray(c) ? c : void 0;
|
2487
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
2488
|
+
}
|
2489
|
+
throw new Error("Invalid arguments for createOrReplace method");
|
2490
|
+
});
|
2491
|
+
}
|
2492
|
+
async delete(a, b) {
|
2493
|
+
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
2494
|
+
if (Array.isArray(a)) {
|
2495
|
+
if (a.length === 0)
|
2496
|
+
return [];
|
2497
|
+
const ids = a.map((o) => {
|
2498
|
+
if (isString(o))
|
2499
|
+
return o;
|
2500
|
+
if (isString(o.id))
|
2501
|
+
return o.id;
|
2502
|
+
throw new Error("Invalid arguments for delete method");
|
2503
|
+
});
|
2504
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2505
|
+
const result = await this.read(a, columns);
|
2506
|
+
await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
|
2507
|
+
return result;
|
2508
|
+
}
|
2509
|
+
if (isString(a)) {
|
2510
|
+
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
|
2511
|
+
}
|
2512
|
+
if (isObject(a) && isString(a.id)) {
|
2513
|
+
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
|
2514
|
+
}
|
2515
|
+
throw new Error("Invalid arguments for delete method");
|
2516
|
+
});
|
2517
|
+
}
|
2518
|
+
async deleteOrThrow(a, b) {
|
2519
|
+
return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
|
2520
|
+
const result = await this.delete(a, b);
|
2521
|
+
if (Array.isArray(result)) {
|
2522
|
+
const missingIds = compact(
|
2523
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2524
|
+
);
|
2525
|
+
if (missingIds.length > 0) {
|
2526
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
2527
|
+
}
|
2528
|
+
return result;
|
2529
|
+
} else if (result === null) {
|
2530
|
+
const id = extractId(a) ?? "unknown";
|
2531
|
+
throw new Error(`Record with id ${id} not found`);
|
2532
|
+
}
|
2533
|
+
return result;
|
2534
|
+
});
|
1472
2535
|
}
|
1473
2536
|
async search(query, options = {}) {
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
2537
|
+
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
2538
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2539
|
+
const { records } = await searchTable({
|
2540
|
+
pathParams: {
|
2541
|
+
workspace: "{workspaceId}",
|
2542
|
+
dbBranchName: "{dbBranch}",
|
2543
|
+
region: "{region}",
|
2544
|
+
tableName: __privateGet$4(this, _table)
|
2545
|
+
},
|
2546
|
+
body: {
|
2547
|
+
query,
|
2548
|
+
fuzziness: options.fuzziness,
|
2549
|
+
prefix: options.prefix,
|
2550
|
+
highlight: options.highlight,
|
2551
|
+
filter: options.filter,
|
2552
|
+
boosters: options.boosters
|
2553
|
+
},
|
2554
|
+
...fetchProps
|
2555
|
+
});
|
2556
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2557
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
2558
|
+
});
|
2559
|
+
}
|
2560
|
+
async aggregate(aggs, filter) {
|
2561
|
+
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
2562
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2563
|
+
const result = await aggregateTable({
|
2564
|
+
pathParams: {
|
2565
|
+
workspace: "{workspaceId}",
|
2566
|
+
dbBranchName: "{dbBranch}",
|
2567
|
+
region: "{region}",
|
2568
|
+
tableName: __privateGet$4(this, _table)
|
2569
|
+
},
|
2570
|
+
body: { aggs, filter },
|
2571
|
+
...fetchProps
|
2572
|
+
});
|
2573
|
+
return result;
|
1486
2574
|
});
|
1487
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1488
|
-
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
1489
2575
|
}
|
1490
2576
|
async query(query) {
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
2577
|
+
return __privateGet$4(this, _trace).call(this, "query", async () => {
|
2578
|
+
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
2579
|
+
if (cacheQuery)
|
2580
|
+
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
2581
|
+
const data = query.getQueryOptions();
|
2582
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2583
|
+
const { meta, records: objects } = await queryTable({
|
2584
|
+
pathParams: {
|
2585
|
+
workspace: "{workspaceId}",
|
2586
|
+
dbBranchName: "{dbBranch}",
|
2587
|
+
region: "{region}",
|
2588
|
+
tableName: __privateGet$4(this, _table)
|
2589
|
+
},
|
2590
|
+
body: {
|
2591
|
+
filter: cleanFilter(data.filter),
|
2592
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2593
|
+
page: data.pagination,
|
2594
|
+
columns: data.columns ?? ["*"]
|
2595
|
+
},
|
2596
|
+
fetchOptions: data.fetchOptions,
|
2597
|
+
...fetchProps
|
2598
|
+
});
|
2599
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2600
|
+
const records = objects.map(
|
2601
|
+
(record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
|
2602
|
+
);
|
2603
|
+
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
2604
|
+
return new Page(query, meta, records);
|
2605
|
+
});
|
2606
|
+
}
|
2607
|
+
async summarizeTable(query, summaries, summariesFilter) {
|
2608
|
+
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
2609
|
+
const data = query.getQueryOptions();
|
2610
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2611
|
+
const result = await summarizeTable({
|
2612
|
+
pathParams: {
|
2613
|
+
workspace: "{workspaceId}",
|
2614
|
+
dbBranchName: "{dbBranch}",
|
2615
|
+
region: "{region}",
|
2616
|
+
tableName: __privateGet$4(this, _table)
|
2617
|
+
},
|
2618
|
+
body: {
|
2619
|
+
filter: cleanFilter(data.filter),
|
2620
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2621
|
+
columns: data.columns,
|
2622
|
+
page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
|
2623
|
+
summaries,
|
2624
|
+
summariesFilter
|
2625
|
+
},
|
2626
|
+
...fetchProps
|
2627
|
+
});
|
2628
|
+
return result;
|
1506
2629
|
});
|
1507
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1508
|
-
const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
|
1509
|
-
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1510
|
-
return new Page(query, meta, records);
|
1511
2630
|
}
|
1512
2631
|
}
|
1513
2632
|
_table = new WeakMap();
|
@@ -1515,6 +2634,7 @@ _getFetchProps = new WeakMap();
|
|
1515
2634
|
_db = new WeakMap();
|
1516
2635
|
_cache = new WeakMap();
|
1517
2636
|
_schemaTables$2 = new WeakMap();
|
2637
|
+
_trace = new WeakMap();
|
1518
2638
|
_insertRecordWithoutId = new WeakSet();
|
1519
2639
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
1520
2640
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
@@ -1523,6 +2643,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1523
2643
|
pathParams: {
|
1524
2644
|
workspace: "{workspaceId}",
|
1525
2645
|
dbBranchName: "{dbBranch}",
|
2646
|
+
region: "{region}",
|
1526
2647
|
tableName: __privateGet$4(this, _table)
|
1527
2648
|
},
|
1528
2649
|
queryParams: { columns },
|
@@ -1530,74 +2651,173 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1530
2651
|
...fetchProps
|
1531
2652
|
});
|
1532
2653
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1533
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2654
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1534
2655
|
};
|
1535
2656
|
_insertRecordWithId = new WeakSet();
|
1536
|
-
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
2657
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
1537
2658
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1538
2659
|
const record = transformObjectLinks(object);
|
1539
2660
|
const response = await insertRecordWithID({
|
1540
2661
|
pathParams: {
|
1541
2662
|
workspace: "{workspaceId}",
|
1542
2663
|
dbBranchName: "{dbBranch}",
|
2664
|
+
region: "{region}",
|
1543
2665
|
tableName: __privateGet$4(this, _table),
|
1544
2666
|
recordId
|
1545
2667
|
},
|
1546
2668
|
body: record,
|
1547
|
-
queryParams: { createOnly
|
2669
|
+
queryParams: { createOnly, columns, ifVersion },
|
1548
2670
|
...fetchProps
|
1549
2671
|
});
|
1550
2672
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1551
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2673
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1552
2674
|
};
|
1553
|
-
|
1554
|
-
|
2675
|
+
_insertRecords = new WeakSet();
|
2676
|
+
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
1555
2677
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1556
|
-
const
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
2678
|
+
const chunkedOperations = chunk(
|
2679
|
+
objects.map((object) => ({
|
2680
|
+
insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
|
2681
|
+
})),
|
2682
|
+
BULK_OPERATION_MAX_SIZE
|
2683
|
+
);
|
2684
|
+
const ids = [];
|
2685
|
+
for (const operations of chunkedOperations) {
|
2686
|
+
const { results } = await branchTransaction({
|
2687
|
+
pathParams: {
|
2688
|
+
workspace: "{workspaceId}",
|
2689
|
+
dbBranchName: "{dbBranch}",
|
2690
|
+
region: "{region}"
|
2691
|
+
},
|
2692
|
+
body: { operations },
|
2693
|
+
...fetchProps
|
2694
|
+
});
|
2695
|
+
for (const result of results) {
|
2696
|
+
if (result.operation === "insert") {
|
2697
|
+
ids.push(result.id);
|
2698
|
+
} else {
|
2699
|
+
ids.push(null);
|
2700
|
+
}
|
2701
|
+
}
|
1565
2702
|
}
|
1566
|
-
|
1567
|
-
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
2703
|
+
return ids;
|
1568
2704
|
};
|
1569
2705
|
_updateRecordWithID = new WeakSet();
|
1570
|
-
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2706
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
1571
2707
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1572
|
-
const record = transformObjectLinks(object);
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
2708
|
+
const { id: _id, ...record } = transformObjectLinks(object);
|
2709
|
+
try {
|
2710
|
+
const response = await updateRecordWithID({
|
2711
|
+
pathParams: {
|
2712
|
+
workspace: "{workspaceId}",
|
2713
|
+
dbBranchName: "{dbBranch}",
|
2714
|
+
region: "{region}",
|
2715
|
+
tableName: __privateGet$4(this, _table),
|
2716
|
+
recordId
|
2717
|
+
},
|
2718
|
+
queryParams: { columns, ifVersion },
|
2719
|
+
body: record,
|
2720
|
+
...fetchProps
|
2721
|
+
});
|
2722
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2723
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2724
|
+
} catch (e) {
|
2725
|
+
if (isObject(e) && e.status === 404) {
|
2726
|
+
return null;
|
2727
|
+
}
|
2728
|
+
throw e;
|
2729
|
+
}
|
2730
|
+
};
|
2731
|
+
_updateRecords = new WeakSet();
|
2732
|
+
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
2733
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2734
|
+
const chunkedOperations = chunk(
|
2735
|
+
objects.map(({ id, ...object }) => ({
|
2736
|
+
update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
|
2737
|
+
})),
|
2738
|
+
BULK_OPERATION_MAX_SIZE
|
2739
|
+
);
|
2740
|
+
const ids = [];
|
2741
|
+
for (const operations of chunkedOperations) {
|
2742
|
+
const { results } = await branchTransaction({
|
2743
|
+
pathParams: {
|
2744
|
+
workspace: "{workspaceId}",
|
2745
|
+
dbBranchName: "{dbBranch}",
|
2746
|
+
region: "{region}"
|
2747
|
+
},
|
2748
|
+
body: { operations },
|
2749
|
+
...fetchProps
|
2750
|
+
});
|
2751
|
+
for (const result of results) {
|
2752
|
+
if (result.operation === "update") {
|
2753
|
+
ids.push(result.id);
|
2754
|
+
} else {
|
2755
|
+
ids.push(null);
|
2756
|
+
}
|
2757
|
+
}
|
2758
|
+
}
|
2759
|
+
return ids;
|
1581
2760
|
};
|
1582
2761
|
_upsertRecordWithID = new WeakSet();
|
1583
|
-
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2762
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
1584
2763
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1585
2764
|
const response = await upsertRecordWithID({
|
1586
|
-
pathParams: {
|
1587
|
-
|
2765
|
+
pathParams: {
|
2766
|
+
workspace: "{workspaceId}",
|
2767
|
+
dbBranchName: "{dbBranch}",
|
2768
|
+
region: "{region}",
|
2769
|
+
tableName: __privateGet$4(this, _table),
|
2770
|
+
recordId
|
2771
|
+
},
|
2772
|
+
queryParams: { columns, ifVersion },
|
1588
2773
|
body: object,
|
1589
2774
|
...fetchProps
|
1590
2775
|
});
|
1591
2776
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1592
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2777
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1593
2778
|
};
|
1594
2779
|
_deleteRecord = new WeakSet();
|
1595
|
-
deleteRecord_fn = async function(recordId) {
|
2780
|
+
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
1596
2781
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
2782
|
+
try {
|
2783
|
+
const response = await deleteRecord({
|
2784
|
+
pathParams: {
|
2785
|
+
workspace: "{workspaceId}",
|
2786
|
+
dbBranchName: "{dbBranch}",
|
2787
|
+
region: "{region}",
|
2788
|
+
tableName: __privateGet$4(this, _table),
|
2789
|
+
recordId
|
2790
|
+
},
|
2791
|
+
queryParams: { columns },
|
2792
|
+
...fetchProps
|
2793
|
+
});
|
2794
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2795
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2796
|
+
} catch (e) {
|
2797
|
+
if (isObject(e) && e.status === 404) {
|
2798
|
+
return null;
|
2799
|
+
}
|
2800
|
+
throw e;
|
2801
|
+
}
|
2802
|
+
};
|
2803
|
+
_deleteRecords = new WeakSet();
|
2804
|
+
deleteRecords_fn = async function(recordIds) {
|
2805
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2806
|
+
const chunkedOperations = chunk(
|
2807
|
+
recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
2808
|
+
BULK_OPERATION_MAX_SIZE
|
2809
|
+
);
|
2810
|
+
for (const operations of chunkedOperations) {
|
2811
|
+
await branchTransaction({
|
2812
|
+
pathParams: {
|
2813
|
+
workspace: "{workspaceId}",
|
2814
|
+
dbBranchName: "{dbBranch}",
|
2815
|
+
region: "{region}"
|
2816
|
+
},
|
2817
|
+
body: { operations },
|
2818
|
+
...fetchProps
|
2819
|
+
});
|
2820
|
+
}
|
1601
2821
|
};
|
1602
2822
|
_setCacheQuery = new WeakSet();
|
1603
2823
|
setCacheQuery_fn = async function(query, meta, records) {
|
@@ -1621,7 +2841,7 @@ getSchemaTables_fn$1 = async function() {
|
|
1621
2841
|
return __privateGet$4(this, _schemaTables$2);
|
1622
2842
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1623
2843
|
const { schema } = await getBranchDetails({
|
1624
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2844
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
1625
2845
|
...fetchProps
|
1626
2846
|
});
|
1627
2847
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
@@ -1634,7 +2854,7 @@ const transformObjectLinks = (object) => {
|
|
1634
2854
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1635
2855
|
}, {});
|
1636
2856
|
};
|
1637
|
-
const initObject = (db, schemaTables, table, object) => {
|
2857
|
+
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
1638
2858
|
const result = {};
|
1639
2859
|
const { xata, ...rest } = object ?? {};
|
1640
2860
|
Object.assign(result, rest);
|
@@ -1642,13 +2862,15 @@ const initObject = (db, schemaTables, table, object) => {
|
|
1642
2862
|
if (!columns)
|
1643
2863
|
console.error(`Table ${table} not found in schema`);
|
1644
2864
|
for (const column of columns ?? []) {
|
2865
|
+
if (!isValidColumn(selectedColumns, column))
|
2866
|
+
continue;
|
1645
2867
|
const value = result[column.name];
|
1646
2868
|
switch (column.type) {
|
1647
2869
|
case "datetime": {
|
1648
|
-
const date = value !== void 0 ? new Date(value) :
|
1649
|
-
if (date && isNaN(date.getTime())) {
|
2870
|
+
const date = value !== void 0 ? new Date(value) : null;
|
2871
|
+
if (date !== null && isNaN(date.getTime())) {
|
1650
2872
|
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
1651
|
-
} else
|
2873
|
+
} else {
|
1652
2874
|
result[column.name] = date;
|
1653
2875
|
}
|
1654
2876
|
break;
|
@@ -1658,17 +2880,42 @@ const initObject = (db, schemaTables, table, object) => {
|
|
1658
2880
|
if (!linkTable) {
|
1659
2881
|
console.error(`Failed to parse link for field ${column.name}`);
|
1660
2882
|
} else if (isObject(value)) {
|
1661
|
-
|
2883
|
+
const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
|
2884
|
+
if (item === column.name) {
|
2885
|
+
return [...acc, "*"];
|
2886
|
+
}
|
2887
|
+
if (item.startsWith(`${column.name}.`)) {
|
2888
|
+
const [, ...path] = item.split(".");
|
2889
|
+
return [...acc, path.join(".")];
|
2890
|
+
}
|
2891
|
+
return acc;
|
2892
|
+
}, []);
|
2893
|
+
result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
|
2894
|
+
} else {
|
2895
|
+
result[column.name] = null;
|
1662
2896
|
}
|
1663
2897
|
break;
|
1664
2898
|
}
|
2899
|
+
default:
|
2900
|
+
result[column.name] = value ?? null;
|
2901
|
+
if (column.notNull === true && value === null) {
|
2902
|
+
console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
|
2903
|
+
}
|
2904
|
+
break;
|
1665
2905
|
}
|
1666
2906
|
}
|
1667
2907
|
result.read = function(columns2) {
|
1668
2908
|
return db[table].read(result["id"], columns2);
|
1669
2909
|
};
|
1670
|
-
result.update = function(data,
|
1671
|
-
|
2910
|
+
result.update = function(data, b, c) {
|
2911
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2912
|
+
const ifVersion = parseIfVersion(b, c);
|
2913
|
+
return db[table].update(result["id"], data, columns2, { ifVersion });
|
2914
|
+
};
|
2915
|
+
result.replace = function(data, b, c) {
|
2916
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2917
|
+
const ifVersion = parseIfVersion(b, c);
|
2918
|
+
return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
|
1672
2919
|
};
|
1673
2920
|
result.delete = function() {
|
1674
2921
|
return db[table].delete(result["id"]);
|
@@ -1676,14 +2923,35 @@ const initObject = (db, schemaTables, table, object) => {
|
|
1676
2923
|
result.getMetadata = function() {
|
1677
2924
|
return xata;
|
1678
2925
|
};
|
1679
|
-
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
2926
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
|
1680
2927
|
Object.defineProperty(result, prop, { enumerable: false });
|
1681
2928
|
}
|
1682
2929
|
Object.freeze(result);
|
1683
2930
|
return result;
|
1684
2931
|
};
|
1685
|
-
function
|
1686
|
-
|
2932
|
+
function extractId(value) {
|
2933
|
+
if (isString(value))
|
2934
|
+
return value;
|
2935
|
+
if (isObject(value) && isString(value.id))
|
2936
|
+
return value.id;
|
2937
|
+
return void 0;
|
2938
|
+
}
|
2939
|
+
function isValidColumn(columns, column) {
|
2940
|
+
if (columns.includes("*"))
|
2941
|
+
return true;
|
2942
|
+
if (column.type === "link") {
|
2943
|
+
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
2944
|
+
return linkColumns.length > 0;
|
2945
|
+
}
|
2946
|
+
return columns.includes(column.name);
|
2947
|
+
}
|
2948
|
+
function parseIfVersion(...args) {
|
2949
|
+
for (const arg of args) {
|
2950
|
+
if (isObject(arg) && isNumber(arg.ifVersion)) {
|
2951
|
+
return arg.ifVersion;
|
2952
|
+
}
|
2953
|
+
}
|
2954
|
+
return void 0;
|
1687
2955
|
}
|
1688
2956
|
|
1689
2957
|
var __accessCheck$3 = (obj, member, msg) => {
|
@@ -1735,18 +3003,25 @@ class SimpleCache {
|
|
1735
3003
|
}
|
1736
3004
|
_map = new WeakMap();
|
1737
3005
|
|
1738
|
-
const
|
1739
|
-
const
|
1740
|
-
const
|
1741
|
-
const
|
1742
|
-
const
|
1743
|
-
const
|
3006
|
+
const greaterThan = (value) => ({ $gt: value });
|
3007
|
+
const gt = greaterThan;
|
3008
|
+
const greaterThanEquals = (value) => ({ $ge: value });
|
3009
|
+
const greaterEquals = greaterThanEquals;
|
3010
|
+
const gte = greaterThanEquals;
|
3011
|
+
const ge = greaterThanEquals;
|
3012
|
+
const lessThan = (value) => ({ $lt: value });
|
3013
|
+
const lt = lessThan;
|
3014
|
+
const lessThanEquals = (value) => ({ $le: value });
|
3015
|
+
const lessEquals = lessThanEquals;
|
3016
|
+
const lte = lessThanEquals;
|
3017
|
+
const le = lessThanEquals;
|
1744
3018
|
const exists = (column) => ({ $exists: column });
|
1745
3019
|
const notExists = (column) => ({ $notExists: column });
|
1746
3020
|
const startsWith = (value) => ({ $startsWith: value });
|
1747
3021
|
const endsWith = (value) => ({ $endsWith: value });
|
1748
3022
|
const pattern = (value) => ({ $pattern: value });
|
1749
3023
|
const is = (value) => ({ $is: value });
|
3024
|
+
const equals = is;
|
1750
3025
|
const isNot = (value) => ({ $isNot: value });
|
1751
3026
|
const contains = (value) => ({ $contains: value });
|
1752
3027
|
const includes = (value) => ({ $includes: value });
|
@@ -1843,7 +3118,7 @@ class SearchPlugin extends XataPlugin {
|
|
1843
3118
|
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1844
3119
|
return records.map((record) => {
|
1845
3120
|
const { table = "orphan" } = record.xata;
|
1846
|
-
return { table, record: initObject(this.db, schemaTables, table, record) };
|
3121
|
+
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
1847
3122
|
});
|
1848
3123
|
},
|
1849
3124
|
byTable: async (query, options = {}) => {
|
@@ -1852,7 +3127,7 @@ class SearchPlugin extends XataPlugin {
|
|
1852
3127
|
return records.reduce((acc, record) => {
|
1853
3128
|
const { table = "orphan" } = record.xata;
|
1854
3129
|
const items = acc[table] ?? [];
|
1855
|
-
const item = initObject(this.db, schemaTables, table, record);
|
3130
|
+
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
1856
3131
|
return { ...acc, [table]: [...items, item] };
|
1857
3132
|
}, {});
|
1858
3133
|
}
|
@@ -1865,7 +3140,7 @@ search_fn = async function(query, options, getFetchProps) {
|
|
1865
3140
|
const fetchProps = await getFetchProps();
|
1866
3141
|
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
1867
3142
|
const { records } = await searchBranch({
|
1868
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
3143
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
1869
3144
|
body: { tables, query, fuzziness, prefix, highlight },
|
1870
3145
|
...fetchProps
|
1871
3146
|
});
|
@@ -1877,13 +3152,29 @@ getSchemaTables_fn = async function(getFetchProps) {
|
|
1877
3152
|
return __privateGet$1(this, _schemaTables);
|
1878
3153
|
const fetchProps = await getFetchProps();
|
1879
3154
|
const { schema } = await getBranchDetails({
|
1880
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
3155
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
1881
3156
|
...fetchProps
|
1882
3157
|
});
|
1883
3158
|
__privateSet$1(this, _schemaTables, schema.tables);
|
1884
3159
|
return schema.tables;
|
1885
3160
|
};
|
1886
3161
|
|
3162
|
+
class TransactionPlugin extends XataPlugin {
|
3163
|
+
build({ getFetchProps }) {
|
3164
|
+
return {
|
3165
|
+
run: async (operations) => {
|
3166
|
+
const fetchProps = await getFetchProps();
|
3167
|
+
const response = await branchTransaction({
|
3168
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3169
|
+
body: { operations },
|
3170
|
+
...fetchProps
|
3171
|
+
});
|
3172
|
+
return response;
|
3173
|
+
}
|
3174
|
+
};
|
3175
|
+
}
|
3176
|
+
}
|
3177
|
+
|
1887
3178
|
const isBranchStrategyBuilder = (strategy) => {
|
1888
3179
|
return typeof strategy === "function";
|
1889
3180
|
};
|
@@ -1915,15 +3206,19 @@ async function resolveXataBranch(gitBranch, options) {
|
|
1915
3206
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
1916
3207
|
);
|
1917
3208
|
const [protocol, , host, , dbName] = databaseURL.split("/");
|
1918
|
-
const
|
3209
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
3210
|
+
if (!urlParts)
|
3211
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3212
|
+
const { workspace, region } = urlParts;
|
1919
3213
|
const { fallbackBranch } = getEnvironment();
|
1920
3214
|
const { branch } = await resolveBranch({
|
1921
3215
|
apiKey,
|
1922
3216
|
apiUrl: databaseURL,
|
1923
3217
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1924
3218
|
workspacesApiUrl: `${protocol}//${host}`,
|
1925
|
-
pathParams: { dbName, workspace },
|
1926
|
-
queryParams: { gitBranch, fallbackBranch }
|
3219
|
+
pathParams: { dbName, workspace, region },
|
3220
|
+
queryParams: { gitBranch, fallbackBranch },
|
3221
|
+
trace: defaultTrace
|
1927
3222
|
});
|
1928
3223
|
return branch;
|
1929
3224
|
}
|
@@ -1939,15 +3234,18 @@ async function getDatabaseBranch(branch, options) {
|
|
1939
3234
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
1940
3235
|
);
|
1941
3236
|
const [protocol, , host, , database] = databaseURL.split("/");
|
1942
|
-
const
|
1943
|
-
|
3237
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
3238
|
+
if (!urlParts)
|
3239
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3240
|
+
const { workspace, region } = urlParts;
|
1944
3241
|
try {
|
1945
3242
|
return await getBranchDetails({
|
1946
3243
|
apiKey,
|
1947
3244
|
apiUrl: databaseURL,
|
1948
3245
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1949
3246
|
workspacesApiUrl: `${protocol}//${host}`,
|
1950
|
-
pathParams: { dbBranchName
|
3247
|
+
pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
|
3248
|
+
trace: defaultTrace
|
1951
3249
|
});
|
1952
3250
|
} catch (err) {
|
1953
3251
|
if (isObject(err) && err.status === 404)
|
@@ -1999,12 +3297,15 @@ const buildClient = (plugins) => {
|
|
1999
3297
|
__privateSet(this, _options, safeOptions);
|
2000
3298
|
const pluginOptions = {
|
2001
3299
|
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
2002
|
-
cache: safeOptions.cache
|
3300
|
+
cache: safeOptions.cache,
|
3301
|
+
trace: safeOptions.trace
|
2003
3302
|
};
|
2004
3303
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
2005
3304
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
3305
|
+
const transactions = new TransactionPlugin().build(pluginOptions);
|
2006
3306
|
this.db = db;
|
2007
3307
|
this.search = search;
|
3308
|
+
this.transactions = transactions;
|
2008
3309
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
2009
3310
|
if (namespace === void 0)
|
2010
3311
|
continue;
|
@@ -2024,16 +3325,27 @@ const buildClient = (plugins) => {
|
|
2024
3325
|
return { databaseURL, branch };
|
2025
3326
|
}
|
2026
3327
|
}, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
3328
|
+
const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
|
3329
|
+
const isBrowser = typeof window !== "undefined";
|
3330
|
+
if (isBrowser && !enableBrowser) {
|
3331
|
+
throw new Error(
|
3332
|
+
"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."
|
3333
|
+
);
|
3334
|
+
}
|
2027
3335
|
const fetch = getFetchImplementation(options?.fetch);
|
2028
3336
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
2029
3337
|
const apiKey = options?.apiKey || getAPIKey();
|
2030
3338
|
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
3339
|
+
const trace = options?.trace ?? defaultTrace;
|
2031
3340
|
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
2032
|
-
if (!
|
2033
|
-
throw new Error("
|
3341
|
+
if (!apiKey) {
|
3342
|
+
throw new Error("Option apiKey is required");
|
3343
|
+
}
|
3344
|
+
if (!databaseURL) {
|
3345
|
+
throw new Error("Option databaseURL is required");
|
2034
3346
|
}
|
2035
|
-
return { fetch, databaseURL, apiKey, branch, cache };
|
2036
|
-
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch }) {
|
3347
|
+
return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser };
|
3348
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
|
2037
3349
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
2038
3350
|
if (!branchValue)
|
2039
3351
|
throw new Error("Unable to resolve branch value");
|
@@ -2043,9 +3355,11 @@ const buildClient = (plugins) => {
|
|
2043
3355
|
apiUrl: "",
|
2044
3356
|
workspacesApiUrl: (path, params) => {
|
2045
3357
|
const hasBranch = params.dbBranchName ?? params.branch;
|
2046
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
|
3358
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
|
2047
3359
|
return databaseURL + newPath;
|
2048
|
-
}
|
3360
|
+
},
|
3361
|
+
trace,
|
3362
|
+
clientID
|
2049
3363
|
};
|
2050
3364
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
2051
3365
|
if (__privateGet(this, _branch))
|
@@ -2157,5 +3471,5 @@ class XataError extends Error {
|
|
2157
3471
|
}
|
2158
3472
|
}
|
2159
3473
|
|
2160
|
-
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
|
3474
|
+
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, branchTransaction, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, dEPRECATEDcreateDatabase, dEPRECATEDdeleteDatabase, dEPRECATEDgetDatabaseList, dEPRECATEDgetDatabaseMetadata, dEPRECATEDupdateDatabaseMetadata, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
|
2161
3475
|
//# sourceMappingURL=index.mjs.map
|