@xata.io/client 0.0.0-alpha.vf79e7d8 → 0.0.0-alpha.vf7c7a24
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 +126 -0
- package/README.md +30 -30
- package/Usage.md +7 -5
- package/dist/index.cjs +1495 -520
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4465 -1200
- package/dist/index.mjs +1466 -500
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- /package/{rollup.config.js → rollup.config.mjs} +0 -0
package/dist/index.cjs
CHANGED
@@ -1,36 +1,14 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
-
|
5
|
-
function _interopNamespace(e) {
|
6
|
-
if (e && e.__esModule) return e;
|
7
|
-
var n = Object.create(null);
|
8
|
-
if (e) {
|
9
|
-
Object.keys(e).forEach(function (k) {
|
10
|
-
if (k !== 'default') {
|
11
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
12
|
-
Object.defineProperty(n, k, d.get ? d : {
|
13
|
-
enumerable: true,
|
14
|
-
get: function () { return e[k]; }
|
15
|
-
});
|
16
|
-
}
|
17
|
-
});
|
18
|
-
}
|
19
|
-
n["default"] = e;
|
20
|
-
return Object.freeze(n);
|
21
|
-
}
|
22
|
-
|
23
3
|
const defaultTrace = async (_name, fn, _options) => {
|
24
4
|
return await fn({
|
25
5
|
setAttributes: () => {
|
26
6
|
return;
|
27
|
-
},
|
28
|
-
onError: () => {
|
29
|
-
return;
|
30
7
|
}
|
31
8
|
});
|
32
9
|
};
|
33
10
|
const TraceAttributes = {
|
11
|
+
KIND: "xata.trace.kind",
|
34
12
|
VERSION: "xata.sdk.version",
|
35
13
|
TABLE: "xata.table",
|
36
14
|
HTTP_REQUEST_ID: "http.request_id",
|
@@ -62,6 +40,9 @@ function isString(value) {
|
|
62
40
|
function isStringArray(value) {
|
63
41
|
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
64
42
|
}
|
43
|
+
function isNumber(value) {
|
44
|
+
return isDefined(value) && typeof value === "number";
|
45
|
+
}
|
65
46
|
function toBase64(value) {
|
66
47
|
try {
|
67
48
|
return btoa(value);
|
@@ -70,6 +51,17 @@ function toBase64(value) {
|
|
70
51
|
return buf.from(value).toString("base64");
|
71
52
|
}
|
72
53
|
}
|
54
|
+
function deepMerge(a, b) {
|
55
|
+
const result = { ...a };
|
56
|
+
for (const [key, value] of Object.entries(b)) {
|
57
|
+
if (isObject(value) && isObject(result[key])) {
|
58
|
+
result[key] = deepMerge(result[key], value);
|
59
|
+
} else {
|
60
|
+
result[key] = value;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
return result;
|
64
|
+
}
|
73
65
|
|
74
66
|
function getEnvironment() {
|
75
67
|
try {
|
@@ -104,6 +96,25 @@ function getEnvironment() {
|
|
104
96
|
fallbackBranch: getGlobalFallbackBranch()
|
105
97
|
};
|
106
98
|
}
|
99
|
+
function getEnableBrowserVariable() {
|
100
|
+
try {
|
101
|
+
if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
|
102
|
+
return process.env.XATA_ENABLE_BROWSER === "true";
|
103
|
+
}
|
104
|
+
} catch (err) {
|
105
|
+
}
|
106
|
+
try {
|
107
|
+
if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
|
108
|
+
return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
|
109
|
+
}
|
110
|
+
} catch (err) {
|
111
|
+
}
|
112
|
+
try {
|
113
|
+
return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
|
114
|
+
} catch (err) {
|
115
|
+
return void 0;
|
116
|
+
}
|
117
|
+
}
|
107
118
|
function getGlobalApiKey() {
|
108
119
|
try {
|
109
120
|
return XATA_API_KEY;
|
@@ -141,7 +152,7 @@ async function getGitBranch() {
|
|
141
152
|
if (typeof require === "function") {
|
142
153
|
return require(nodeModule).execSync(fullCmd, execOptions).trim();
|
143
154
|
}
|
144
|
-
const { execSync } = await (
|
155
|
+
const { execSync } = await import(nodeModule);
|
145
156
|
return execSync(fullCmd, execOptions).toString().trim();
|
146
157
|
} catch (err) {
|
147
158
|
}
|
@@ -174,7 +185,7 @@ function getFetchImplementation(userFetch) {
|
|
174
185
|
return fetchImpl;
|
175
186
|
}
|
176
187
|
|
177
|
-
const VERSION = "0.0.0-alpha.
|
188
|
+
const VERSION = "0.0.0-alpha.vf7c7a24";
|
178
189
|
|
179
190
|
class ErrorWithCause extends Error {
|
180
191
|
constructor(message, options) {
|
@@ -225,18 +236,24 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
225
236
|
}, {});
|
226
237
|
const query = new URLSearchParams(cleanQueryParams).toString();
|
227
238
|
const queryString = query.length > 0 ? `?${query}` : "";
|
228
|
-
|
239
|
+
const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
|
240
|
+
return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
|
241
|
+
}, {});
|
242
|
+
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
229
243
|
};
|
230
244
|
function buildBaseUrl({
|
245
|
+
endpoint,
|
231
246
|
path,
|
232
247
|
workspacesApiUrl,
|
233
248
|
apiUrl,
|
234
|
-
pathParams
|
249
|
+
pathParams = {}
|
235
250
|
}) {
|
236
|
-
if (
|
237
|
-
|
238
|
-
|
239
|
-
|
251
|
+
if (endpoint === "dataPlane") {
|
252
|
+
const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
253
|
+
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
254
|
+
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
255
|
+
}
|
256
|
+
return `${apiUrl}${path}`;
|
240
257
|
}
|
241
258
|
function hostHeader(url) {
|
242
259
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
@@ -252,14 +269,19 @@ async function fetch$1({
|
|
252
269
|
queryParams,
|
253
270
|
fetchImpl,
|
254
271
|
apiKey,
|
272
|
+
endpoint,
|
255
273
|
apiUrl,
|
256
274
|
workspacesApiUrl,
|
257
|
-
trace
|
275
|
+
trace,
|
276
|
+
signal,
|
277
|
+
clientID,
|
278
|
+
sessionID,
|
279
|
+
fetchOptions = {}
|
258
280
|
}) {
|
259
281
|
return trace(
|
260
282
|
`${method.toUpperCase()} ${path}`,
|
261
|
-
async ({ setAttributes
|
262
|
-
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
283
|
+
async ({ setAttributes }) => {
|
284
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
263
285
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
264
286
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
265
287
|
setAttributes({
|
@@ -267,15 +289,19 @@ async function fetch$1({
|
|
267
289
|
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
268
290
|
});
|
269
291
|
const response = await fetchImpl(url, {
|
292
|
+
...fetchOptions,
|
270
293
|
method: method.toUpperCase(),
|
271
294
|
body: body ? JSON.stringify(body) : void 0,
|
272
295
|
headers: {
|
273
296
|
"Content-Type": "application/json",
|
274
297
|
"User-Agent": `Xata client-ts/${VERSION}`,
|
298
|
+
"X-Xata-Client-ID": clientID ?? "",
|
299
|
+
"X-Xata-Session-ID": sessionID ?? "",
|
275
300
|
...headers,
|
276
301
|
...hostHeader(fullUrl),
|
277
302
|
Authorization: `Bearer ${apiKey}`
|
278
|
-
}
|
303
|
+
},
|
304
|
+
signal
|
279
305
|
});
|
280
306
|
if (response.status === 204) {
|
281
307
|
return {};
|
@@ -283,6 +309,7 @@ async function fetch$1({
|
|
283
309
|
const { host, protocol } = parseUrl(response.url);
|
284
310
|
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
285
311
|
setAttributes({
|
312
|
+
[TraceAttributes.KIND]: "http",
|
286
313
|
[TraceAttributes.HTTP_REQUEST_ID]: requestId,
|
287
314
|
[TraceAttributes.HTTP_STATUS_CODE]: response.status,
|
288
315
|
[TraceAttributes.HTTP_HOST]: host,
|
@@ -295,9 +322,7 @@ async function fetch$1({
|
|
295
322
|
}
|
296
323
|
throw new FetcherError(response.status, jsonResponse, requestId);
|
297
324
|
} catch (error) {
|
298
|
-
|
299
|
-
onError(fetcherError.message);
|
300
|
-
throw fetcherError;
|
325
|
+
throw new FetcherError(response.status, error, requestId);
|
301
326
|
}
|
302
327
|
},
|
303
328
|
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
@@ -312,245 +337,163 @@ function parseUrl(url) {
|
|
312
337
|
}
|
313
338
|
}
|
314
339
|
|
315
|
-
const
|
316
|
-
|
317
|
-
const
|
318
|
-
const
|
319
|
-
url: "/user/keys",
|
320
|
-
method: "get",
|
321
|
-
...variables
|
322
|
-
});
|
323
|
-
const createUserAPIKey = (variables) => fetch$1({
|
324
|
-
url: "/user/keys/{keyName}",
|
325
|
-
method: "post",
|
326
|
-
...variables
|
327
|
-
});
|
328
|
-
const deleteUserAPIKey = (variables) => fetch$1({
|
329
|
-
url: "/user/keys/{keyName}",
|
330
|
-
method: "delete",
|
331
|
-
...variables
|
332
|
-
});
|
333
|
-
const createWorkspace = (variables) => fetch$1({
|
334
|
-
url: "/workspaces",
|
335
|
-
method: "post",
|
336
|
-
...variables
|
337
|
-
});
|
338
|
-
const getWorkspacesList = (variables) => fetch$1({
|
339
|
-
url: "/workspaces",
|
340
|
-
method: "get",
|
341
|
-
...variables
|
342
|
-
});
|
343
|
-
const getWorkspace = (variables) => fetch$1({
|
344
|
-
url: "/workspaces/{workspaceId}",
|
345
|
-
method: "get",
|
346
|
-
...variables
|
347
|
-
});
|
348
|
-
const updateWorkspace = (variables) => fetch$1({
|
349
|
-
url: "/workspaces/{workspaceId}",
|
350
|
-
method: "put",
|
351
|
-
...variables
|
352
|
-
});
|
353
|
-
const deleteWorkspace = (variables) => fetch$1({
|
354
|
-
url: "/workspaces/{workspaceId}",
|
355
|
-
method: "delete",
|
356
|
-
...variables
|
357
|
-
});
|
358
|
-
const getWorkspaceMembersList = (variables) => fetch$1({
|
359
|
-
url: "/workspaces/{workspaceId}/members",
|
360
|
-
method: "get",
|
361
|
-
...variables
|
362
|
-
});
|
363
|
-
const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
|
364
|
-
const removeWorkspaceMember = (variables) => fetch$1({
|
365
|
-
url: "/workspaces/{workspaceId}/members/{userId}",
|
366
|
-
method: "delete",
|
367
|
-
...variables
|
368
|
-
});
|
369
|
-
const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
|
370
|
-
const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
|
371
|
-
const cancelWorkspaceMemberInvite = (variables) => fetch$1({
|
372
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
373
|
-
method: "delete",
|
374
|
-
...variables
|
375
|
-
});
|
376
|
-
const resendWorkspaceMemberInvite = (variables) => fetch$1({
|
377
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
|
378
|
-
method: "post",
|
379
|
-
...variables
|
380
|
-
});
|
381
|
-
const acceptWorkspaceMemberInvite = (variables) => fetch$1({
|
382
|
-
url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
|
383
|
-
method: "post",
|
384
|
-
...variables
|
385
|
-
});
|
386
|
-
const getDatabaseList = (variables) => fetch$1({
|
387
|
-
url: "/dbs",
|
388
|
-
method: "get",
|
389
|
-
...variables
|
390
|
-
});
|
391
|
-
const getBranchList = (variables) => fetch$1({
|
392
|
-
url: "/dbs/{dbName}",
|
393
|
-
method: "get",
|
394
|
-
...variables
|
395
|
-
});
|
396
|
-
const createDatabase = (variables) => fetch$1({
|
397
|
-
url: "/dbs/{dbName}",
|
398
|
-
method: "put",
|
399
|
-
...variables
|
400
|
-
});
|
401
|
-
const deleteDatabase = (variables) => fetch$1({
|
340
|
+
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
341
|
+
|
342
|
+
const dEPRECATEDgetDatabaseList = (variables, signal) => dataPlaneFetch({ url: "/dbs", method: "get", ...variables, signal });
|
343
|
+
const getBranchList = (variables, signal) => dataPlaneFetch({
|
402
344
|
url: "/dbs/{dbName}",
|
403
|
-
method: "delete",
|
404
|
-
...variables
|
405
|
-
});
|
406
|
-
const getDatabaseMetadata = (variables) => fetch$1({
|
407
|
-
url: "/dbs/{dbName}/metadata",
|
408
|
-
method: "get",
|
409
|
-
...variables
|
410
|
-
});
|
411
|
-
const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
|
412
|
-
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
413
|
-
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
414
|
-
const resolveBranch = (variables) => fetch$1({
|
415
|
-
url: "/dbs/{dbName}/resolveBranch",
|
416
345
|
method: "get",
|
417
|
-
...variables
|
346
|
+
...variables,
|
347
|
+
signal
|
418
348
|
});
|
419
|
-
const
|
349
|
+
const dEPRECATEDcreateDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
|
350
|
+
const dEPRECATEDdeleteDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "delete", ...variables, signal });
|
351
|
+
const dEPRECATEDgetDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "get", ...variables, signal });
|
352
|
+
const dEPRECATEDupdateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
|
353
|
+
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
420
354
|
url: "/db/{dbBranchName}",
|
421
355
|
method: "get",
|
422
|
-
...variables
|
356
|
+
...variables,
|
357
|
+
signal
|
423
358
|
});
|
424
|
-
const createBranch = (variables) =>
|
425
|
-
const deleteBranch = (variables) =>
|
359
|
+
const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
|
360
|
+
const deleteBranch = (variables, signal) => dataPlaneFetch({
|
426
361
|
url: "/db/{dbBranchName}",
|
427
362
|
method: "delete",
|
428
|
-
...variables
|
363
|
+
...variables,
|
364
|
+
signal
|
429
365
|
});
|
430
|
-
const updateBranchMetadata = (variables) =>
|
366
|
+
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
431
367
|
url: "/db/{dbBranchName}/metadata",
|
432
368
|
method: "put",
|
433
|
-
...variables
|
369
|
+
...variables,
|
370
|
+
signal
|
434
371
|
});
|
435
|
-
const getBranchMetadata = (variables) =>
|
372
|
+
const getBranchMetadata = (variables, signal) => dataPlaneFetch({
|
436
373
|
url: "/db/{dbBranchName}/metadata",
|
437
374
|
method: "get",
|
438
|
-
...variables
|
375
|
+
...variables,
|
376
|
+
signal
|
439
377
|
});
|
440
|
-
const
|
441
|
-
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
442
|
-
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
443
|
-
const getBranchStats = (variables) => fetch$1({
|
378
|
+
const getBranchStats = (variables, signal) => dataPlaneFetch({
|
444
379
|
url: "/db/{dbBranchName}/stats",
|
445
380
|
method: "get",
|
446
|
-
...variables
|
381
|
+
...variables,
|
382
|
+
signal
|
383
|
+
});
|
384
|
+
const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
|
385
|
+
const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
|
386
|
+
const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
|
387
|
+
const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
|
388
|
+
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
389
|
+
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
390
|
+
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
391
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
392
|
+
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
393
|
+
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
394
|
+
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
395
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
396
|
+
method: "get",
|
397
|
+
...variables,
|
398
|
+
signal
|
447
399
|
});
|
448
|
-
const
|
400
|
+
const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
|
401
|
+
const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
|
402
|
+
const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
|
403
|
+
const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
|
404
|
+
const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
|
405
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
406
|
+
method: "post",
|
407
|
+
...variables,
|
408
|
+
signal
|
409
|
+
});
|
410
|
+
const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
|
411
|
+
const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
|
412
|
+
const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
|
413
|
+
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
414
|
+
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
415
|
+
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
416
|
+
const createTable = (variables, signal) => dataPlaneFetch({
|
449
417
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
450
418
|
method: "put",
|
451
|
-
...variables
|
419
|
+
...variables,
|
420
|
+
signal
|
452
421
|
});
|
453
|
-
const deleteTable = (variables) =>
|
422
|
+
const deleteTable = (variables, signal) => dataPlaneFetch({
|
454
423
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
455
424
|
method: "delete",
|
456
|
-
...variables
|
457
|
-
|
458
|
-
const updateTable = (variables) => fetch$1({
|
459
|
-
url: "/db/{dbBranchName}/tables/{tableName}",
|
460
|
-
method: "patch",
|
461
|
-
...variables
|
425
|
+
...variables,
|
426
|
+
signal
|
462
427
|
});
|
463
|
-
const
|
428
|
+
const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
|
429
|
+
const getTableSchema = (variables, signal) => dataPlaneFetch({
|
464
430
|
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
465
431
|
method: "get",
|
466
|
-
...variables
|
432
|
+
...variables,
|
433
|
+
signal
|
467
434
|
});
|
468
|
-
const setTableSchema = (variables) =>
|
469
|
-
|
470
|
-
method: "put",
|
471
|
-
...variables
|
472
|
-
});
|
473
|
-
const getTableColumns = (variables) => fetch$1({
|
435
|
+
const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
|
436
|
+
const getTableColumns = (variables, signal) => dataPlaneFetch({
|
474
437
|
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
475
438
|
method: "get",
|
476
|
-
...variables
|
477
|
-
|
478
|
-
const addTableColumn = (variables) => fetch$1({
|
479
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
480
|
-
method: "post",
|
481
|
-
...variables
|
439
|
+
...variables,
|
440
|
+
signal
|
482
441
|
});
|
483
|
-
const
|
442
|
+
const addTableColumn = (variables, signal) => dataPlaneFetch(
|
443
|
+
{ url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
|
444
|
+
);
|
445
|
+
const getColumn = (variables, signal) => dataPlaneFetch({
|
484
446
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
485
447
|
method: "get",
|
486
|
-
...variables
|
487
|
-
|
488
|
-
const deleteColumn = (variables) => fetch$1({
|
489
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
490
|
-
method: "delete",
|
491
|
-
...variables
|
448
|
+
...variables,
|
449
|
+
signal
|
492
450
|
});
|
493
|
-
const updateColumn = (variables) =>
|
451
|
+
const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
|
452
|
+
const deleteColumn = (variables, signal) => dataPlaneFetch({
|
494
453
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
495
|
-
method: "patch",
|
496
|
-
...variables
|
497
|
-
});
|
498
|
-
const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
|
499
|
-
const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
|
500
|
-
const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
|
501
|
-
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
502
|
-
const deleteRecord = (variables) => fetch$1({
|
503
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
504
454
|
method: "delete",
|
505
|
-
...variables
|
455
|
+
...variables,
|
456
|
+
signal
|
506
457
|
});
|
507
|
-
const
|
458
|
+
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
459
|
+
const getRecord = (variables, signal) => dataPlaneFetch({
|
508
460
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
509
461
|
method: "get",
|
510
|
-
...variables
|
462
|
+
...variables,
|
463
|
+
signal
|
511
464
|
});
|
512
|
-
const
|
513
|
-
const
|
465
|
+
const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
|
466
|
+
const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
|
467
|
+
const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
|
468
|
+
const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
|
469
|
+
const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
|
470
|
+
const queryTable = (variables, signal) => dataPlaneFetch({
|
514
471
|
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
515
472
|
method: "post",
|
516
|
-
...variables
|
473
|
+
...variables,
|
474
|
+
signal
|
517
475
|
});
|
518
|
-
const
|
519
|
-
url: "/db/{dbBranchName}/
|
476
|
+
const searchBranch = (variables, signal) => dataPlaneFetch({
|
477
|
+
url: "/db/{dbBranchName}/search",
|
520
478
|
method: "post",
|
521
|
-
...variables
|
479
|
+
...variables,
|
480
|
+
signal
|
522
481
|
});
|
523
|
-
const
|
524
|
-
url: "/db/{dbBranchName}/search",
|
482
|
+
const searchTable = (variables, signal) => dataPlaneFetch({
|
483
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
525
484
|
method: "post",
|
526
|
-
...variables
|
485
|
+
...variables,
|
486
|
+
signal
|
527
487
|
});
|
528
|
-
const
|
529
|
-
|
530
|
-
|
531
|
-
createWorkspace,
|
532
|
-
getWorkspacesList,
|
533
|
-
getWorkspace,
|
534
|
-
updateWorkspace,
|
535
|
-
deleteWorkspace,
|
536
|
-
getWorkspaceMembersList,
|
537
|
-
updateWorkspaceMemberRole,
|
538
|
-
removeWorkspaceMember,
|
539
|
-
inviteWorkspaceMember,
|
540
|
-
updateWorkspaceMemberInvite,
|
541
|
-
cancelWorkspaceMemberInvite,
|
542
|
-
resendWorkspaceMemberInvite,
|
543
|
-
acceptWorkspaceMemberInvite
|
544
|
-
},
|
488
|
+
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
489
|
+
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
490
|
+
const operationsByTag$2 = {
|
545
491
|
database: {
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
addGitBranchesEntry,
|
552
|
-
removeGitBranchesEntry,
|
553
|
-
resolveBranch
|
492
|
+
dEPRECATEDgetDatabaseList,
|
493
|
+
dEPRECATEDcreateDatabase,
|
494
|
+
dEPRECATEDdeleteDatabase,
|
495
|
+
dEPRECATEDgetDatabaseMetadata,
|
496
|
+
dEPRECATEDupdateDatabaseMetadata
|
554
497
|
},
|
555
498
|
branch: {
|
556
499
|
getBranchList,
|
@@ -559,10 +502,42 @@ const operationsByTag = {
|
|
559
502
|
deleteBranch,
|
560
503
|
updateBranchMetadata,
|
561
504
|
getBranchMetadata,
|
505
|
+
getBranchStats,
|
506
|
+
getGitBranchesMapping,
|
507
|
+
addGitBranchesEntry,
|
508
|
+
removeGitBranchesEntry,
|
509
|
+
resolveBranch
|
510
|
+
},
|
511
|
+
migrations: {
|
562
512
|
getBranchMigrationHistory,
|
563
|
-
executeBranchMigrationPlan,
|
564
513
|
getBranchMigrationPlan,
|
565
|
-
|
514
|
+
executeBranchMigrationPlan,
|
515
|
+
getBranchSchemaHistory,
|
516
|
+
compareBranchWithUserSchema,
|
517
|
+
compareBranchSchemas,
|
518
|
+
updateBranchSchema,
|
519
|
+
previewBranchSchemaEdit,
|
520
|
+
applyBranchSchemaEdit
|
521
|
+
},
|
522
|
+
records: {
|
523
|
+
branchTransaction,
|
524
|
+
insertRecord,
|
525
|
+
getRecord,
|
526
|
+
insertRecordWithID,
|
527
|
+
updateRecordWithID,
|
528
|
+
upsertRecordWithID,
|
529
|
+
deleteRecord,
|
530
|
+
bulkInsertTableRecords
|
531
|
+
},
|
532
|
+
migrationRequests: {
|
533
|
+
queryMigrationRequests,
|
534
|
+
createMigrationRequest,
|
535
|
+
getMigrationRequest,
|
536
|
+
updateMigrationRequest,
|
537
|
+
listMigrationRequestsCommits,
|
538
|
+
compareMigrationRequest,
|
539
|
+
getMigrationRequestIsMerged,
|
540
|
+
mergeMigrationRequest
|
566
541
|
},
|
567
542
|
table: {
|
568
543
|
createTable,
|
@@ -573,23 +548,146 @@ const operationsByTag = {
|
|
573
548
|
getTableColumns,
|
574
549
|
addTableColumn,
|
575
550
|
getColumn,
|
576
|
-
|
577
|
-
|
551
|
+
updateColumn,
|
552
|
+
deleteColumn
|
578
553
|
},
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
554
|
+
searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
|
555
|
+
};
|
556
|
+
|
557
|
+
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
558
|
+
|
559
|
+
const getUser = (variables, signal) => controlPlaneFetch({
|
560
|
+
url: "/user",
|
561
|
+
method: "get",
|
562
|
+
...variables,
|
563
|
+
signal
|
564
|
+
});
|
565
|
+
const updateUser = (variables, signal) => controlPlaneFetch({
|
566
|
+
url: "/user",
|
567
|
+
method: "put",
|
568
|
+
...variables,
|
569
|
+
signal
|
570
|
+
});
|
571
|
+
const deleteUser = (variables, signal) => controlPlaneFetch({
|
572
|
+
url: "/user",
|
573
|
+
method: "delete",
|
574
|
+
...variables,
|
575
|
+
signal
|
576
|
+
});
|
577
|
+
const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
|
578
|
+
url: "/user/keys",
|
579
|
+
method: "get",
|
580
|
+
...variables,
|
581
|
+
signal
|
582
|
+
});
|
583
|
+
const createUserAPIKey = (variables, signal) => controlPlaneFetch({
|
584
|
+
url: "/user/keys/{keyName}",
|
585
|
+
method: "post",
|
586
|
+
...variables,
|
587
|
+
signal
|
588
|
+
});
|
589
|
+
const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
590
|
+
url: "/user/keys/{keyName}",
|
591
|
+
method: "delete",
|
592
|
+
...variables,
|
593
|
+
signal
|
594
|
+
});
|
595
|
+
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
596
|
+
url: "/workspaces",
|
597
|
+
method: "get",
|
598
|
+
...variables,
|
599
|
+
signal
|
600
|
+
});
|
601
|
+
const createWorkspace = (variables, signal) => controlPlaneFetch({
|
602
|
+
url: "/workspaces",
|
603
|
+
method: "post",
|
604
|
+
...variables,
|
605
|
+
signal
|
606
|
+
});
|
607
|
+
const getWorkspace = (variables, signal) => controlPlaneFetch({
|
608
|
+
url: "/workspaces/{workspaceId}",
|
609
|
+
method: "get",
|
610
|
+
...variables,
|
611
|
+
signal
|
612
|
+
});
|
613
|
+
const updateWorkspace = (variables, signal) => controlPlaneFetch({
|
614
|
+
url: "/workspaces/{workspaceId}",
|
615
|
+
method: "put",
|
616
|
+
...variables,
|
617
|
+
signal
|
618
|
+
});
|
619
|
+
const deleteWorkspace = (variables, signal) => controlPlaneFetch({
|
620
|
+
url: "/workspaces/{workspaceId}",
|
621
|
+
method: "delete",
|
622
|
+
...variables,
|
623
|
+
signal
|
624
|
+
});
|
625
|
+
const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
|
626
|
+
const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
|
627
|
+
const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
628
|
+
url: "/workspaces/{workspaceId}/members/{userId}",
|
629
|
+
method: "delete",
|
630
|
+
...variables,
|
631
|
+
signal
|
632
|
+
});
|
633
|
+
const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
|
634
|
+
const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
|
635
|
+
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
636
|
+
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
637
|
+
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
638
|
+
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
639
|
+
url: "/workspaces/{workspaceId}/dbs",
|
640
|
+
method: "get",
|
641
|
+
...variables,
|
642
|
+
signal
|
643
|
+
});
|
644
|
+
const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
|
645
|
+
const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
646
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
647
|
+
method: "delete",
|
648
|
+
...variables,
|
649
|
+
signal
|
650
|
+
});
|
651
|
+
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
652
|
+
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
653
|
+
const listRegions = (variables, signal) => controlPlaneFetch({
|
654
|
+
url: "/workspaces/{workspaceId}/regions",
|
655
|
+
method: "get",
|
656
|
+
...variables,
|
657
|
+
signal
|
658
|
+
});
|
659
|
+
const operationsByTag$1 = {
|
660
|
+
users: { getUser, updateUser, deleteUser },
|
661
|
+
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
662
|
+
workspaces: {
|
663
|
+
getWorkspacesList,
|
664
|
+
createWorkspace,
|
665
|
+
getWorkspace,
|
666
|
+
updateWorkspace,
|
667
|
+
deleteWorkspace,
|
668
|
+
getWorkspaceMembersList,
|
669
|
+
updateWorkspaceMemberRole,
|
670
|
+
removeWorkspaceMember
|
671
|
+
},
|
672
|
+
invites: {
|
673
|
+
inviteWorkspaceMember,
|
674
|
+
updateWorkspaceMemberInvite,
|
675
|
+
cancelWorkspaceMemberInvite,
|
676
|
+
acceptWorkspaceMemberInvite,
|
677
|
+
resendWorkspaceMemberInvite
|
678
|
+
},
|
679
|
+
databases: {
|
680
|
+
getDatabaseList,
|
681
|
+
createDatabase,
|
682
|
+
deleteDatabase,
|
683
|
+
getDatabaseMetadata,
|
684
|
+
updateDatabaseMetadata,
|
685
|
+
listRegions
|
590
686
|
}
|
591
687
|
};
|
592
688
|
|
689
|
+
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
690
|
+
|
593
691
|
function getHostUrl(provider, type) {
|
594
692
|
if (isHostProviderAlias(provider)) {
|
595
693
|
return providers[provider][type];
|
@@ -601,11 +699,11 @@ function getHostUrl(provider, type) {
|
|
601
699
|
const providers = {
|
602
700
|
production: {
|
603
701
|
main: "https://api.xata.io",
|
604
|
-
workspaces: "https://{workspaceId}.xata.sh"
|
702
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
605
703
|
},
|
606
704
|
staging: {
|
607
705
|
main: "https://staging.xatabase.co",
|
608
|
-
workspaces: "https://{workspaceId}.staging.xatabase.co"
|
706
|
+
workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
|
609
707
|
}
|
610
708
|
};
|
611
709
|
function isHostProviderAlias(alias) {
|
@@ -614,6 +712,25 @@ function isHostProviderAlias(alias) {
|
|
614
712
|
function isHostProviderBuilder(builder) {
|
615
713
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
616
714
|
}
|
715
|
+
function parseProviderString(provider = "production") {
|
716
|
+
if (isHostProviderAlias(provider)) {
|
717
|
+
return provider;
|
718
|
+
}
|
719
|
+
const [main, workspaces] = provider.split(",");
|
720
|
+
if (!main || !workspaces)
|
721
|
+
return null;
|
722
|
+
return { main, workspaces };
|
723
|
+
}
|
724
|
+
function parseWorkspacesUrlParts(url) {
|
725
|
+
if (!isString(url))
|
726
|
+
return null;
|
727
|
+
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
|
728
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
|
729
|
+
const match = url.match(regex) || url.match(regexStaging);
|
730
|
+
if (!match)
|
731
|
+
return null;
|
732
|
+
return { workspace: match[1], region: match[2] ?? "eu-west-1" };
|
733
|
+
}
|
617
734
|
|
618
735
|
var __accessCheck$7 = (obj, member, msg) => {
|
619
736
|
if (!member.has(obj))
|
@@ -657,21 +774,41 @@ class XataApiClient {
|
|
657
774
|
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
658
775
|
return __privateGet$7(this, _namespaces).user;
|
659
776
|
}
|
777
|
+
get authentication() {
|
778
|
+
if (!__privateGet$7(this, _namespaces).authentication)
|
779
|
+
__privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
|
780
|
+
return __privateGet$7(this, _namespaces).authentication;
|
781
|
+
}
|
660
782
|
get workspaces() {
|
661
783
|
if (!__privateGet$7(this, _namespaces).workspaces)
|
662
784
|
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
663
785
|
return __privateGet$7(this, _namespaces).workspaces;
|
664
786
|
}
|
665
|
-
get
|
666
|
-
if (!__privateGet$7(this, _namespaces).
|
667
|
-
__privateGet$7(this, _namespaces).
|
668
|
-
return __privateGet$7(this, _namespaces).
|
787
|
+
get invites() {
|
788
|
+
if (!__privateGet$7(this, _namespaces).invites)
|
789
|
+
__privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
|
790
|
+
return __privateGet$7(this, _namespaces).invites;
|
791
|
+
}
|
792
|
+
get database() {
|
793
|
+
if (!__privateGet$7(this, _namespaces).database)
|
794
|
+
__privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
|
795
|
+
return __privateGet$7(this, _namespaces).database;
|
669
796
|
}
|
670
797
|
get branches() {
|
671
798
|
if (!__privateGet$7(this, _namespaces).branches)
|
672
799
|
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
673
800
|
return __privateGet$7(this, _namespaces).branches;
|
674
801
|
}
|
802
|
+
get migrations() {
|
803
|
+
if (!__privateGet$7(this, _namespaces).migrations)
|
804
|
+
__privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
|
805
|
+
return __privateGet$7(this, _namespaces).migrations;
|
806
|
+
}
|
807
|
+
get migrationRequests() {
|
808
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
809
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
810
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
811
|
+
}
|
675
812
|
get tables() {
|
676
813
|
if (!__privateGet$7(this, _namespaces).tables)
|
677
814
|
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
@@ -682,6 +819,11 @@ class XataApiClient {
|
|
682
819
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
683
820
|
return __privateGet$7(this, _namespaces).records;
|
684
821
|
}
|
822
|
+
get searchAndFilter() {
|
823
|
+
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
824
|
+
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
825
|
+
return __privateGet$7(this, _namespaces).searchAndFilter;
|
826
|
+
}
|
685
827
|
}
|
686
828
|
_extraProps = new WeakMap();
|
687
829
|
_namespaces = new WeakMap();
|
@@ -692,24 +834,29 @@ class UserApi {
|
|
692
834
|
getUser() {
|
693
835
|
return operationsByTag.users.getUser({ ...this.extraProps });
|
694
836
|
}
|
695
|
-
updateUser(user) {
|
837
|
+
updateUser({ user }) {
|
696
838
|
return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
|
697
839
|
}
|
698
840
|
deleteUser() {
|
699
841
|
return operationsByTag.users.deleteUser({ ...this.extraProps });
|
700
842
|
}
|
843
|
+
}
|
844
|
+
class AuthenticationApi {
|
845
|
+
constructor(extraProps) {
|
846
|
+
this.extraProps = extraProps;
|
847
|
+
}
|
701
848
|
getUserAPIKeys() {
|
702
|
-
return operationsByTag.
|
849
|
+
return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
|
703
850
|
}
|
704
|
-
createUserAPIKey(
|
705
|
-
return operationsByTag.
|
706
|
-
pathParams: { keyName },
|
851
|
+
createUserAPIKey({ name }) {
|
852
|
+
return operationsByTag.authentication.createUserAPIKey({
|
853
|
+
pathParams: { keyName: name },
|
707
854
|
...this.extraProps
|
708
855
|
});
|
709
856
|
}
|
710
|
-
deleteUserAPIKey(
|
711
|
-
return operationsByTag.
|
712
|
-
pathParams: { keyName },
|
857
|
+
deleteUserAPIKey({ name }) {
|
858
|
+
return operationsByTag.authentication.deleteUserAPIKey({
|
859
|
+
pathParams: { keyName: name },
|
713
860
|
...this.extraProps
|
714
861
|
});
|
715
862
|
}
|
@@ -718,139 +865,114 @@ class WorkspaceApi {
|
|
718
865
|
constructor(extraProps) {
|
719
866
|
this.extraProps = extraProps;
|
720
867
|
}
|
721
|
-
|
868
|
+
getWorkspacesList() {
|
869
|
+
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
870
|
+
}
|
871
|
+
createWorkspace({ data }) {
|
722
872
|
return operationsByTag.workspaces.createWorkspace({
|
723
|
-
body:
|
873
|
+
body: data,
|
724
874
|
...this.extraProps
|
725
875
|
});
|
726
876
|
}
|
727
|
-
|
728
|
-
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
729
|
-
}
|
730
|
-
getWorkspace(workspaceId) {
|
877
|
+
getWorkspace({ workspace }) {
|
731
878
|
return operationsByTag.workspaces.getWorkspace({
|
732
|
-
pathParams: { workspaceId },
|
879
|
+
pathParams: { workspaceId: workspace },
|
733
880
|
...this.extraProps
|
734
881
|
});
|
735
882
|
}
|
736
|
-
updateWorkspace(
|
883
|
+
updateWorkspace({
|
884
|
+
workspace,
|
885
|
+
update
|
886
|
+
}) {
|
737
887
|
return operationsByTag.workspaces.updateWorkspace({
|
738
|
-
pathParams: { workspaceId },
|
739
|
-
body:
|
888
|
+
pathParams: { workspaceId: workspace },
|
889
|
+
body: update,
|
740
890
|
...this.extraProps
|
741
891
|
});
|
742
892
|
}
|
743
|
-
deleteWorkspace(
|
893
|
+
deleteWorkspace({ workspace }) {
|
744
894
|
return operationsByTag.workspaces.deleteWorkspace({
|
745
|
-
pathParams: { workspaceId },
|
895
|
+
pathParams: { workspaceId: workspace },
|
746
896
|
...this.extraProps
|
747
897
|
});
|
748
898
|
}
|
749
|
-
getWorkspaceMembersList(
|
899
|
+
getWorkspaceMembersList({ workspace }) {
|
750
900
|
return operationsByTag.workspaces.getWorkspaceMembersList({
|
751
|
-
pathParams: { workspaceId },
|
901
|
+
pathParams: { workspaceId: workspace },
|
752
902
|
...this.extraProps
|
753
903
|
});
|
754
904
|
}
|
755
|
-
updateWorkspaceMemberRole(
|
905
|
+
updateWorkspaceMemberRole({
|
906
|
+
workspace,
|
907
|
+
user,
|
908
|
+
role
|
909
|
+
}) {
|
756
910
|
return operationsByTag.workspaces.updateWorkspaceMemberRole({
|
757
|
-
pathParams: { workspaceId, userId },
|
911
|
+
pathParams: { workspaceId: workspace, userId: user },
|
758
912
|
body: { role },
|
759
913
|
...this.extraProps
|
760
914
|
});
|
761
915
|
}
|
762
|
-
removeWorkspaceMember(
|
916
|
+
removeWorkspaceMember({
|
917
|
+
workspace,
|
918
|
+
user
|
919
|
+
}) {
|
763
920
|
return operationsByTag.workspaces.removeWorkspaceMember({
|
764
|
-
pathParams: { workspaceId, userId },
|
765
|
-
...this.extraProps
|
766
|
-
});
|
767
|
-
}
|
768
|
-
inviteWorkspaceMember(workspaceId, email, role) {
|
769
|
-
return operationsByTag.workspaces.inviteWorkspaceMember({
|
770
|
-
pathParams: { workspaceId },
|
771
|
-
body: { email, role },
|
772
|
-
...this.extraProps
|
773
|
-
});
|
774
|
-
}
|
775
|
-
updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
|
776
|
-
return operationsByTag.workspaces.updateWorkspaceMemberInvite({
|
777
|
-
pathParams: { workspaceId, inviteId },
|
778
|
-
body: { role },
|
779
|
-
...this.extraProps
|
780
|
-
});
|
781
|
-
}
|
782
|
-
cancelWorkspaceMemberInvite(workspaceId, inviteId) {
|
783
|
-
return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
|
784
|
-
pathParams: { workspaceId, inviteId },
|
785
|
-
...this.extraProps
|
786
|
-
});
|
787
|
-
}
|
788
|
-
resendWorkspaceMemberInvite(workspaceId, inviteId) {
|
789
|
-
return operationsByTag.workspaces.resendWorkspaceMemberInvite({
|
790
|
-
pathParams: { workspaceId, inviteId },
|
791
|
-
...this.extraProps
|
792
|
-
});
|
793
|
-
}
|
794
|
-
acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
|
795
|
-
return operationsByTag.workspaces.acceptWorkspaceMemberInvite({
|
796
|
-
pathParams: { workspaceId, inviteKey },
|
921
|
+
pathParams: { workspaceId: workspace, userId: user },
|
797
922
|
...this.extraProps
|
798
923
|
});
|
799
924
|
}
|
800
925
|
}
|
801
|
-
class
|
926
|
+
class InvitesApi {
|
802
927
|
constructor(extraProps) {
|
803
928
|
this.extraProps = extraProps;
|
804
929
|
}
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
pathParams: { workspace, dbName },
|
814
|
-
body: options,
|
815
|
-
...this.extraProps
|
816
|
-
});
|
817
|
-
}
|
818
|
-
deleteDatabase(workspace, dbName) {
|
819
|
-
return operationsByTag.database.deleteDatabase({
|
820
|
-
pathParams: { workspace, dbName },
|
821
|
-
...this.extraProps
|
822
|
-
});
|
823
|
-
}
|
824
|
-
getDatabaseMetadata(workspace, dbName) {
|
825
|
-
return operationsByTag.database.getDatabaseMetadata({
|
826
|
-
pathParams: { workspace, dbName },
|
930
|
+
inviteWorkspaceMember({
|
931
|
+
workspace,
|
932
|
+
email,
|
933
|
+
role
|
934
|
+
}) {
|
935
|
+
return operationsByTag.invites.inviteWorkspaceMember({
|
936
|
+
pathParams: { workspaceId: workspace },
|
937
|
+
body: { email, role },
|
827
938
|
...this.extraProps
|
828
939
|
});
|
829
940
|
}
|
830
|
-
|
831
|
-
|
832
|
-
|
941
|
+
updateWorkspaceMemberInvite({
|
942
|
+
workspace,
|
943
|
+
invite,
|
944
|
+
role
|
945
|
+
}) {
|
946
|
+
return operationsByTag.invites.updateWorkspaceMemberInvite({
|
947
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
948
|
+
body: { role },
|
833
949
|
...this.extraProps
|
834
950
|
});
|
835
951
|
}
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
952
|
+
cancelWorkspaceMemberInvite({
|
953
|
+
workspace,
|
954
|
+
invite
|
955
|
+
}) {
|
956
|
+
return operationsByTag.invites.cancelWorkspaceMemberInvite({
|
957
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
840
958
|
...this.extraProps
|
841
959
|
});
|
842
960
|
}
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
961
|
+
acceptWorkspaceMemberInvite({
|
962
|
+
workspace,
|
963
|
+
key
|
964
|
+
}) {
|
965
|
+
return operationsByTag.invites.acceptWorkspaceMemberInvite({
|
966
|
+
pathParams: { workspaceId: workspace, inviteKey: key },
|
847
967
|
...this.extraProps
|
848
968
|
});
|
849
969
|
}
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
970
|
+
resendWorkspaceMemberInvite({
|
971
|
+
workspace,
|
972
|
+
invite
|
973
|
+
}) {
|
974
|
+
return operationsByTag.invites.resendWorkspaceMemberInvite({
|
975
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
854
976
|
...this.extraProps
|
855
977
|
});
|
856
978
|
}
|
@@ -859,69 +981,132 @@ class BranchApi {
|
|
859
981
|
constructor(extraProps) {
|
860
982
|
this.extraProps = extraProps;
|
861
983
|
}
|
862
|
-
getBranchList(
|
984
|
+
getBranchList({
|
985
|
+
workspace,
|
986
|
+
region,
|
987
|
+
database
|
988
|
+
}) {
|
863
989
|
return operationsByTag.branch.getBranchList({
|
864
|
-
pathParams: { workspace, dbName },
|
990
|
+
pathParams: { workspace, region, dbName: database },
|
865
991
|
...this.extraProps
|
866
992
|
});
|
867
993
|
}
|
868
|
-
getBranchDetails(
|
994
|
+
getBranchDetails({
|
995
|
+
workspace,
|
996
|
+
region,
|
997
|
+
database,
|
998
|
+
branch
|
999
|
+
}) {
|
869
1000
|
return operationsByTag.branch.getBranchDetails({
|
870
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1001
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
871
1002
|
...this.extraProps
|
872
1003
|
});
|
873
1004
|
}
|
874
|
-
createBranch(
|
1005
|
+
createBranch({
|
1006
|
+
workspace,
|
1007
|
+
region,
|
1008
|
+
database,
|
1009
|
+
branch,
|
1010
|
+
from,
|
1011
|
+
metadata
|
1012
|
+
}) {
|
875
1013
|
return operationsByTag.branch.createBranch({
|
876
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
877
|
-
|
878
|
-
body: options,
|
1014
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1015
|
+
body: { from, metadata },
|
879
1016
|
...this.extraProps
|
880
1017
|
});
|
881
1018
|
}
|
882
|
-
deleteBranch(
|
1019
|
+
deleteBranch({
|
1020
|
+
workspace,
|
1021
|
+
region,
|
1022
|
+
database,
|
1023
|
+
branch
|
1024
|
+
}) {
|
883
1025
|
return operationsByTag.branch.deleteBranch({
|
884
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1026
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
885
1027
|
...this.extraProps
|
886
1028
|
});
|
887
1029
|
}
|
888
|
-
updateBranchMetadata(
|
1030
|
+
updateBranchMetadata({
|
1031
|
+
workspace,
|
1032
|
+
region,
|
1033
|
+
database,
|
1034
|
+
branch,
|
1035
|
+
metadata
|
1036
|
+
}) {
|
889
1037
|
return operationsByTag.branch.updateBranchMetadata({
|
890
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1038
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
891
1039
|
body: metadata,
|
892
1040
|
...this.extraProps
|
893
1041
|
});
|
894
1042
|
}
|
895
|
-
getBranchMetadata(
|
1043
|
+
getBranchMetadata({
|
1044
|
+
workspace,
|
1045
|
+
region,
|
1046
|
+
database,
|
1047
|
+
branch
|
1048
|
+
}) {
|
896
1049
|
return operationsByTag.branch.getBranchMetadata({
|
897
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1050
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
898
1051
|
...this.extraProps
|
899
1052
|
});
|
900
1053
|
}
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
1054
|
+
getBranchStats({
|
1055
|
+
workspace,
|
1056
|
+
region,
|
1057
|
+
database,
|
1058
|
+
branch
|
1059
|
+
}) {
|
1060
|
+
return operationsByTag.branch.getBranchStats({
|
1061
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
905
1062
|
...this.extraProps
|
906
1063
|
});
|
907
1064
|
}
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
1065
|
+
getGitBranchesMapping({
|
1066
|
+
workspace,
|
1067
|
+
region,
|
1068
|
+
database
|
1069
|
+
}) {
|
1070
|
+
return operationsByTag.branch.getGitBranchesMapping({
|
1071
|
+
pathParams: { workspace, region, dbName: database },
|
912
1072
|
...this.extraProps
|
913
1073
|
});
|
914
1074
|
}
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
1075
|
+
addGitBranchesEntry({
|
1076
|
+
workspace,
|
1077
|
+
region,
|
1078
|
+
database,
|
1079
|
+
gitBranch,
|
1080
|
+
xataBranch
|
1081
|
+
}) {
|
1082
|
+
return operationsByTag.branch.addGitBranchesEntry({
|
1083
|
+
pathParams: { workspace, region, dbName: database },
|
1084
|
+
body: { gitBranch, xataBranch },
|
919
1085
|
...this.extraProps
|
920
1086
|
});
|
921
1087
|
}
|
922
|
-
|
923
|
-
|
924
|
-
|
1088
|
+
removeGitBranchesEntry({
|
1089
|
+
workspace,
|
1090
|
+
region,
|
1091
|
+
database,
|
1092
|
+
gitBranch
|
1093
|
+
}) {
|
1094
|
+
return operationsByTag.branch.removeGitBranchesEntry({
|
1095
|
+
pathParams: { workspace, region, dbName: database },
|
1096
|
+
queryParams: { gitBranch },
|
1097
|
+
...this.extraProps
|
1098
|
+
});
|
1099
|
+
}
|
1100
|
+
resolveBranch({
|
1101
|
+
workspace,
|
1102
|
+
region,
|
1103
|
+
database,
|
1104
|
+
gitBranch,
|
1105
|
+
fallbackBranch
|
1106
|
+
}) {
|
1107
|
+
return operationsByTag.branch.resolveBranch({
|
1108
|
+
pathParams: { workspace, region, dbName: database },
|
1109
|
+
queryParams: { gitBranch, fallbackBranch },
|
925
1110
|
...this.extraProps
|
926
1111
|
});
|
927
1112
|
}
|
@@ -930,67 +1115,134 @@ class TableApi {
|
|
930
1115
|
constructor(extraProps) {
|
931
1116
|
this.extraProps = extraProps;
|
932
1117
|
}
|
933
|
-
createTable(
|
1118
|
+
createTable({
|
1119
|
+
workspace,
|
1120
|
+
region,
|
1121
|
+
database,
|
1122
|
+
branch,
|
1123
|
+
table
|
1124
|
+
}) {
|
934
1125
|
return operationsByTag.table.createTable({
|
935
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1126
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
936
1127
|
...this.extraProps
|
937
1128
|
});
|
938
1129
|
}
|
939
|
-
deleteTable(
|
1130
|
+
deleteTable({
|
1131
|
+
workspace,
|
1132
|
+
region,
|
1133
|
+
database,
|
1134
|
+
branch,
|
1135
|
+
table
|
1136
|
+
}) {
|
940
1137
|
return operationsByTag.table.deleteTable({
|
941
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1138
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
942
1139
|
...this.extraProps
|
943
1140
|
});
|
944
1141
|
}
|
945
|
-
updateTable(
|
1142
|
+
updateTable({
|
1143
|
+
workspace,
|
1144
|
+
region,
|
1145
|
+
database,
|
1146
|
+
branch,
|
1147
|
+
table,
|
1148
|
+
update
|
1149
|
+
}) {
|
946
1150
|
return operationsByTag.table.updateTable({
|
947
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
948
|
-
body:
|
1151
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1152
|
+
body: update,
|
949
1153
|
...this.extraProps
|
950
1154
|
});
|
951
1155
|
}
|
952
|
-
getTableSchema(
|
1156
|
+
getTableSchema({
|
1157
|
+
workspace,
|
1158
|
+
region,
|
1159
|
+
database,
|
1160
|
+
branch,
|
1161
|
+
table
|
1162
|
+
}) {
|
953
1163
|
return operationsByTag.table.getTableSchema({
|
954
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1164
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
955
1165
|
...this.extraProps
|
956
1166
|
});
|
957
1167
|
}
|
958
|
-
setTableSchema(
|
1168
|
+
setTableSchema({
|
1169
|
+
workspace,
|
1170
|
+
region,
|
1171
|
+
database,
|
1172
|
+
branch,
|
1173
|
+
table,
|
1174
|
+
schema
|
1175
|
+
}) {
|
959
1176
|
return operationsByTag.table.setTableSchema({
|
960
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
961
|
-
body:
|
1177
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1178
|
+
body: schema,
|
962
1179
|
...this.extraProps
|
963
1180
|
});
|
964
1181
|
}
|
965
|
-
getTableColumns(
|
1182
|
+
getTableColumns({
|
1183
|
+
workspace,
|
1184
|
+
region,
|
1185
|
+
database,
|
1186
|
+
branch,
|
1187
|
+
table
|
1188
|
+
}) {
|
966
1189
|
return operationsByTag.table.getTableColumns({
|
967
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1190
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
968
1191
|
...this.extraProps
|
969
1192
|
});
|
970
1193
|
}
|
971
|
-
addTableColumn(
|
1194
|
+
addTableColumn({
|
1195
|
+
workspace,
|
1196
|
+
region,
|
1197
|
+
database,
|
1198
|
+
branch,
|
1199
|
+
table,
|
1200
|
+
column
|
1201
|
+
}) {
|
972
1202
|
return operationsByTag.table.addTableColumn({
|
973
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1203
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
974
1204
|
body: column,
|
975
1205
|
...this.extraProps
|
976
1206
|
});
|
977
1207
|
}
|
978
|
-
getColumn(
|
1208
|
+
getColumn({
|
1209
|
+
workspace,
|
1210
|
+
region,
|
1211
|
+
database,
|
1212
|
+
branch,
|
1213
|
+
table,
|
1214
|
+
column
|
1215
|
+
}) {
|
979
1216
|
return operationsByTag.table.getColumn({
|
980
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
|
1217
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
981
1218
|
...this.extraProps
|
982
1219
|
});
|
983
1220
|
}
|
984
|
-
|
985
|
-
|
986
|
-
|
1221
|
+
updateColumn({
|
1222
|
+
workspace,
|
1223
|
+
region,
|
1224
|
+
database,
|
1225
|
+
branch,
|
1226
|
+
table,
|
1227
|
+
column,
|
1228
|
+
update
|
1229
|
+
}) {
|
1230
|
+
return operationsByTag.table.updateColumn({
|
1231
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1232
|
+
body: update,
|
987
1233
|
...this.extraProps
|
988
1234
|
});
|
989
1235
|
}
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
1236
|
+
deleteColumn({
|
1237
|
+
workspace,
|
1238
|
+
region,
|
1239
|
+
database,
|
1240
|
+
branch,
|
1241
|
+
table,
|
1242
|
+
column
|
1243
|
+
}) {
|
1244
|
+
return operationsByTag.table.deleteColumn({
|
1245
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
994
1246
|
...this.extraProps
|
995
1247
|
});
|
996
1248
|
}
|
@@ -999,78 +1251,498 @@ class RecordsApi {
|
|
999
1251
|
constructor(extraProps) {
|
1000
1252
|
this.extraProps = extraProps;
|
1001
1253
|
}
|
1002
|
-
insertRecord(
|
1254
|
+
insertRecord({
|
1255
|
+
workspace,
|
1256
|
+
region,
|
1257
|
+
database,
|
1258
|
+
branch,
|
1259
|
+
table,
|
1260
|
+
record,
|
1261
|
+
columns
|
1262
|
+
}) {
|
1003
1263
|
return operationsByTag.records.insertRecord({
|
1004
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1005
|
-
queryParams:
|
1264
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1265
|
+
queryParams: { columns },
|
1006
1266
|
body: record,
|
1007
1267
|
...this.extraProps
|
1008
1268
|
});
|
1009
1269
|
}
|
1010
|
-
|
1270
|
+
getRecord({
|
1271
|
+
workspace,
|
1272
|
+
region,
|
1273
|
+
database,
|
1274
|
+
branch,
|
1275
|
+
table,
|
1276
|
+
id,
|
1277
|
+
columns
|
1278
|
+
}) {
|
1279
|
+
return operationsByTag.records.getRecord({
|
1280
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1281
|
+
queryParams: { columns },
|
1282
|
+
...this.extraProps
|
1283
|
+
});
|
1284
|
+
}
|
1285
|
+
insertRecordWithID({
|
1286
|
+
workspace,
|
1287
|
+
region,
|
1288
|
+
database,
|
1289
|
+
branch,
|
1290
|
+
table,
|
1291
|
+
id,
|
1292
|
+
record,
|
1293
|
+
columns,
|
1294
|
+
createOnly,
|
1295
|
+
ifVersion
|
1296
|
+
}) {
|
1011
1297
|
return operationsByTag.records.insertRecordWithID({
|
1012
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1013
|
-
queryParams:
|
1298
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1299
|
+
queryParams: { columns, createOnly, ifVersion },
|
1014
1300
|
body: record,
|
1015
1301
|
...this.extraProps
|
1016
1302
|
});
|
1017
1303
|
}
|
1018
|
-
updateRecordWithID(
|
1304
|
+
updateRecordWithID({
|
1305
|
+
workspace,
|
1306
|
+
region,
|
1307
|
+
database,
|
1308
|
+
branch,
|
1309
|
+
table,
|
1310
|
+
id,
|
1311
|
+
record,
|
1312
|
+
columns,
|
1313
|
+
ifVersion
|
1314
|
+
}) {
|
1019
1315
|
return operationsByTag.records.updateRecordWithID({
|
1020
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1021
|
-
queryParams:
|
1316
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1317
|
+
queryParams: { columns, ifVersion },
|
1022
1318
|
body: record,
|
1023
1319
|
...this.extraProps
|
1024
1320
|
});
|
1025
1321
|
}
|
1026
|
-
upsertRecordWithID(
|
1322
|
+
upsertRecordWithID({
|
1323
|
+
workspace,
|
1324
|
+
region,
|
1325
|
+
database,
|
1326
|
+
branch,
|
1327
|
+
table,
|
1328
|
+
id,
|
1329
|
+
record,
|
1330
|
+
columns,
|
1331
|
+
ifVersion
|
1332
|
+
}) {
|
1027
1333
|
return operationsByTag.records.upsertRecordWithID({
|
1028
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1029
|
-
queryParams:
|
1334
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1335
|
+
queryParams: { columns, ifVersion },
|
1030
1336
|
body: record,
|
1031
1337
|
...this.extraProps
|
1032
1338
|
});
|
1033
1339
|
}
|
1034
|
-
deleteRecord(
|
1340
|
+
deleteRecord({
|
1341
|
+
workspace,
|
1342
|
+
region,
|
1343
|
+
database,
|
1344
|
+
branch,
|
1345
|
+
table,
|
1346
|
+
id,
|
1347
|
+
columns
|
1348
|
+
}) {
|
1035
1349
|
return operationsByTag.records.deleteRecord({
|
1036
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1037
|
-
queryParams:
|
1350
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1351
|
+
queryParams: { columns },
|
1038
1352
|
...this.extraProps
|
1039
1353
|
});
|
1040
1354
|
}
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1355
|
+
bulkInsertTableRecords({
|
1356
|
+
workspace,
|
1357
|
+
region,
|
1358
|
+
database,
|
1359
|
+
branch,
|
1360
|
+
table,
|
1361
|
+
records,
|
1362
|
+
columns
|
1363
|
+
}) {
|
1364
|
+
return operationsByTag.records.bulkInsertTableRecords({
|
1365
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1366
|
+
queryParams: { columns },
|
1367
|
+
body: { records },
|
1045
1368
|
...this.extraProps
|
1046
1369
|
});
|
1047
1370
|
}
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1371
|
+
}
|
1372
|
+
class SearchAndFilterApi {
|
1373
|
+
constructor(extraProps) {
|
1374
|
+
this.extraProps = extraProps;
|
1375
|
+
}
|
1376
|
+
queryTable({
|
1377
|
+
workspace,
|
1378
|
+
region,
|
1379
|
+
database,
|
1380
|
+
branch,
|
1381
|
+
table,
|
1382
|
+
filter,
|
1383
|
+
sort,
|
1384
|
+
page,
|
1385
|
+
columns,
|
1386
|
+
consistency
|
1387
|
+
}) {
|
1388
|
+
return operationsByTag.searchAndFilter.queryTable({
|
1389
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1390
|
+
body: { filter, sort, page, columns, consistency },
|
1391
|
+
...this.extraProps
|
1392
|
+
});
|
1393
|
+
}
|
1394
|
+
searchTable({
|
1395
|
+
workspace,
|
1396
|
+
region,
|
1397
|
+
database,
|
1398
|
+
branch,
|
1399
|
+
table,
|
1400
|
+
query,
|
1401
|
+
fuzziness,
|
1402
|
+
target,
|
1403
|
+
prefix,
|
1404
|
+
filter,
|
1405
|
+
highlight,
|
1406
|
+
boosters
|
1407
|
+
}) {
|
1408
|
+
return operationsByTag.searchAndFilter.searchTable({
|
1409
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1410
|
+
body: { query, fuzziness, target, prefix, filter, highlight, boosters },
|
1411
|
+
...this.extraProps
|
1412
|
+
});
|
1413
|
+
}
|
1414
|
+
searchBranch({
|
1415
|
+
workspace,
|
1416
|
+
region,
|
1417
|
+
database,
|
1418
|
+
branch,
|
1419
|
+
tables,
|
1420
|
+
query,
|
1421
|
+
fuzziness,
|
1422
|
+
prefix,
|
1423
|
+
highlight
|
1424
|
+
}) {
|
1425
|
+
return operationsByTag.searchAndFilter.searchBranch({
|
1426
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1427
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
1428
|
+
...this.extraProps
|
1429
|
+
});
|
1430
|
+
}
|
1431
|
+
summarizeTable({
|
1432
|
+
workspace,
|
1433
|
+
region,
|
1434
|
+
database,
|
1435
|
+
branch,
|
1436
|
+
table,
|
1437
|
+
filter,
|
1438
|
+
columns,
|
1439
|
+
summaries,
|
1440
|
+
sort,
|
1441
|
+
summariesFilter,
|
1442
|
+
page,
|
1443
|
+
consistency
|
1444
|
+
}) {
|
1445
|
+
return operationsByTag.searchAndFilter.summarizeTable({
|
1446
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1447
|
+
body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
|
1448
|
+
...this.extraProps
|
1449
|
+
});
|
1450
|
+
}
|
1451
|
+
aggregateTable({
|
1452
|
+
workspace,
|
1453
|
+
region,
|
1454
|
+
database,
|
1455
|
+
branch,
|
1456
|
+
table,
|
1457
|
+
filter,
|
1458
|
+
aggs
|
1459
|
+
}) {
|
1460
|
+
return operationsByTag.searchAndFilter.aggregateTable({
|
1461
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1462
|
+
body: { filter, aggs },
|
1463
|
+
...this.extraProps
|
1464
|
+
});
|
1465
|
+
}
|
1466
|
+
}
|
1467
|
+
class MigrationRequestsApi {
|
1468
|
+
constructor(extraProps) {
|
1469
|
+
this.extraProps = extraProps;
|
1470
|
+
}
|
1471
|
+
queryMigrationRequests({
|
1472
|
+
workspace,
|
1473
|
+
region,
|
1474
|
+
database,
|
1475
|
+
filter,
|
1476
|
+
sort,
|
1477
|
+
page,
|
1478
|
+
columns
|
1479
|
+
}) {
|
1480
|
+
return operationsByTag.migrationRequests.queryMigrationRequests({
|
1481
|
+
pathParams: { workspace, region, dbName: database },
|
1482
|
+
body: { filter, sort, page, columns },
|
1483
|
+
...this.extraProps
|
1484
|
+
});
|
1485
|
+
}
|
1486
|
+
createMigrationRequest({
|
1487
|
+
workspace,
|
1488
|
+
region,
|
1489
|
+
database,
|
1490
|
+
migration
|
1491
|
+
}) {
|
1492
|
+
return operationsByTag.migrationRequests.createMigrationRequest({
|
1493
|
+
pathParams: { workspace, region, dbName: database },
|
1494
|
+
body: migration,
|
1495
|
+
...this.extraProps
|
1496
|
+
});
|
1497
|
+
}
|
1498
|
+
getMigrationRequest({
|
1499
|
+
workspace,
|
1500
|
+
region,
|
1501
|
+
database,
|
1502
|
+
migrationRequest
|
1503
|
+
}) {
|
1504
|
+
return operationsByTag.migrationRequests.getMigrationRequest({
|
1505
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1506
|
+
...this.extraProps
|
1507
|
+
});
|
1508
|
+
}
|
1509
|
+
updateMigrationRequest({
|
1510
|
+
workspace,
|
1511
|
+
region,
|
1512
|
+
database,
|
1513
|
+
migrationRequest,
|
1514
|
+
update
|
1515
|
+
}) {
|
1516
|
+
return operationsByTag.migrationRequests.updateMigrationRequest({
|
1517
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1518
|
+
body: update,
|
1519
|
+
...this.extraProps
|
1520
|
+
});
|
1521
|
+
}
|
1522
|
+
listMigrationRequestsCommits({
|
1523
|
+
workspace,
|
1524
|
+
region,
|
1525
|
+
database,
|
1526
|
+
migrationRequest,
|
1527
|
+
page
|
1528
|
+
}) {
|
1529
|
+
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
1530
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1531
|
+
body: { page },
|
1532
|
+
...this.extraProps
|
1533
|
+
});
|
1534
|
+
}
|
1535
|
+
compareMigrationRequest({
|
1536
|
+
workspace,
|
1537
|
+
region,
|
1538
|
+
database,
|
1539
|
+
migrationRequest
|
1540
|
+
}) {
|
1541
|
+
return operationsByTag.migrationRequests.compareMigrationRequest({
|
1542
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1543
|
+
...this.extraProps
|
1544
|
+
});
|
1545
|
+
}
|
1546
|
+
getMigrationRequestIsMerged({
|
1547
|
+
workspace,
|
1548
|
+
region,
|
1549
|
+
database,
|
1550
|
+
migrationRequest
|
1551
|
+
}) {
|
1552
|
+
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
1553
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1554
|
+
...this.extraProps
|
1555
|
+
});
|
1556
|
+
}
|
1557
|
+
mergeMigrationRequest({
|
1558
|
+
workspace,
|
1559
|
+
region,
|
1560
|
+
database,
|
1561
|
+
migrationRequest
|
1562
|
+
}) {
|
1563
|
+
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
1564
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1565
|
+
...this.extraProps
|
1566
|
+
});
|
1567
|
+
}
|
1568
|
+
}
|
1569
|
+
class MigrationsApi {
|
1570
|
+
constructor(extraProps) {
|
1571
|
+
this.extraProps = extraProps;
|
1572
|
+
}
|
1573
|
+
getBranchMigrationHistory({
|
1574
|
+
workspace,
|
1575
|
+
region,
|
1576
|
+
database,
|
1577
|
+
branch,
|
1578
|
+
limit,
|
1579
|
+
startFrom
|
1580
|
+
}) {
|
1581
|
+
return operationsByTag.migrations.getBranchMigrationHistory({
|
1582
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1583
|
+
body: { limit, startFrom },
|
1584
|
+
...this.extraProps
|
1585
|
+
});
|
1586
|
+
}
|
1587
|
+
getBranchMigrationPlan({
|
1588
|
+
workspace,
|
1589
|
+
region,
|
1590
|
+
database,
|
1591
|
+
branch,
|
1592
|
+
schema
|
1593
|
+
}) {
|
1594
|
+
return operationsByTag.migrations.getBranchMigrationPlan({
|
1595
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1596
|
+
body: schema,
|
1597
|
+
...this.extraProps
|
1598
|
+
});
|
1599
|
+
}
|
1600
|
+
executeBranchMigrationPlan({
|
1601
|
+
workspace,
|
1602
|
+
region,
|
1603
|
+
database,
|
1604
|
+
branch,
|
1605
|
+
plan
|
1606
|
+
}) {
|
1607
|
+
return operationsByTag.migrations.executeBranchMigrationPlan({
|
1608
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1609
|
+
body: plan,
|
1610
|
+
...this.extraProps
|
1611
|
+
});
|
1612
|
+
}
|
1613
|
+
getBranchSchemaHistory({
|
1614
|
+
workspace,
|
1615
|
+
region,
|
1616
|
+
database,
|
1617
|
+
branch,
|
1618
|
+
page
|
1619
|
+
}) {
|
1620
|
+
return operationsByTag.migrations.getBranchSchemaHistory({
|
1621
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1622
|
+
body: { page },
|
1623
|
+
...this.extraProps
|
1624
|
+
});
|
1625
|
+
}
|
1626
|
+
compareBranchWithUserSchema({
|
1627
|
+
workspace,
|
1628
|
+
region,
|
1629
|
+
database,
|
1630
|
+
branch,
|
1631
|
+
schema
|
1632
|
+
}) {
|
1633
|
+
return operationsByTag.migrations.compareBranchWithUserSchema({
|
1634
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1635
|
+
body: { schema },
|
1636
|
+
...this.extraProps
|
1637
|
+
});
|
1638
|
+
}
|
1639
|
+
compareBranchSchemas({
|
1640
|
+
workspace,
|
1641
|
+
region,
|
1642
|
+
database,
|
1643
|
+
branch,
|
1644
|
+
compare,
|
1645
|
+
schema
|
1646
|
+
}) {
|
1647
|
+
return operationsByTag.migrations.compareBranchSchemas({
|
1648
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
1649
|
+
body: { schema },
|
1650
|
+
...this.extraProps
|
1651
|
+
});
|
1652
|
+
}
|
1653
|
+
updateBranchSchema({
|
1654
|
+
workspace,
|
1655
|
+
region,
|
1656
|
+
database,
|
1657
|
+
branch,
|
1658
|
+
migration
|
1659
|
+
}) {
|
1660
|
+
return operationsByTag.migrations.updateBranchSchema({
|
1661
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1662
|
+
body: migration,
|
1663
|
+
...this.extraProps
|
1664
|
+
});
|
1665
|
+
}
|
1666
|
+
previewBranchSchemaEdit({
|
1667
|
+
workspace,
|
1668
|
+
region,
|
1669
|
+
database,
|
1670
|
+
branch,
|
1671
|
+
data
|
1672
|
+
}) {
|
1673
|
+
return operationsByTag.migrations.previewBranchSchemaEdit({
|
1674
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1675
|
+
body: data,
|
1676
|
+
...this.extraProps
|
1677
|
+
});
|
1678
|
+
}
|
1679
|
+
applyBranchSchemaEdit({
|
1680
|
+
workspace,
|
1681
|
+
region,
|
1682
|
+
database,
|
1683
|
+
branch,
|
1684
|
+
edits
|
1685
|
+
}) {
|
1686
|
+
return operationsByTag.migrations.applyBranchSchemaEdit({
|
1687
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1688
|
+
body: { edits },
|
1689
|
+
...this.extraProps
|
1690
|
+
});
|
1691
|
+
}
|
1692
|
+
}
|
1693
|
+
class DatabaseApi {
|
1694
|
+
constructor(extraProps) {
|
1695
|
+
this.extraProps = extraProps;
|
1696
|
+
}
|
1697
|
+
getDatabaseList({ workspace }) {
|
1698
|
+
return operationsByTag.databases.getDatabaseList({
|
1699
|
+
pathParams: { workspaceId: workspace },
|
1053
1700
|
...this.extraProps
|
1054
1701
|
});
|
1055
1702
|
}
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1703
|
+
createDatabase({
|
1704
|
+
workspace,
|
1705
|
+
database,
|
1706
|
+
data
|
1707
|
+
}) {
|
1708
|
+
return operationsByTag.databases.createDatabase({
|
1709
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1710
|
+
body: data,
|
1060
1711
|
...this.extraProps
|
1061
1712
|
});
|
1062
1713
|
}
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1714
|
+
deleteDatabase({
|
1715
|
+
workspace,
|
1716
|
+
database
|
1717
|
+
}) {
|
1718
|
+
return operationsByTag.databases.deleteDatabase({
|
1719
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1067
1720
|
...this.extraProps
|
1068
1721
|
});
|
1069
1722
|
}
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1723
|
+
getDatabaseMetadata({
|
1724
|
+
workspace,
|
1725
|
+
database
|
1726
|
+
}) {
|
1727
|
+
return operationsByTag.databases.getDatabaseMetadata({
|
1728
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1729
|
+
...this.extraProps
|
1730
|
+
});
|
1731
|
+
}
|
1732
|
+
updateDatabaseMetadata({
|
1733
|
+
workspace,
|
1734
|
+
database,
|
1735
|
+
metadata
|
1736
|
+
}) {
|
1737
|
+
return operationsByTag.databases.updateDatabaseMetadata({
|
1738
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1739
|
+
body: metadata,
|
1740
|
+
...this.extraProps
|
1741
|
+
});
|
1742
|
+
}
|
1743
|
+
listRegions({ workspace }) {
|
1744
|
+
return operationsByTag.databases.listRegions({
|
1745
|
+
pathParams: { workspaceId: workspace },
|
1074
1746
|
...this.extraProps
|
1075
1747
|
});
|
1076
1748
|
}
|
@@ -1086,6 +1758,20 @@ class XataApiPlugin {
|
|
1086
1758
|
class XataPlugin {
|
1087
1759
|
}
|
1088
1760
|
|
1761
|
+
function generateUUID() {
|
1762
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
1763
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
1764
|
+
return v.toString(16);
|
1765
|
+
});
|
1766
|
+
}
|
1767
|
+
|
1768
|
+
function cleanFilter(filter) {
|
1769
|
+
if (!filter)
|
1770
|
+
return void 0;
|
1771
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
1772
|
+
return values.length > 0 ? filter : void 0;
|
1773
|
+
}
|
1774
|
+
|
1089
1775
|
var __accessCheck$6 = (obj, member, msg) => {
|
1090
1776
|
if (!member.has(obj))
|
1091
1777
|
throw TypeError("Cannot " + msg);
|
@@ -1118,11 +1804,11 @@ class Page {
|
|
1118
1804
|
async previousPage(size, offset) {
|
1119
1805
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
1120
1806
|
}
|
1121
|
-
async
|
1122
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
1807
|
+
async startPage(size, offset) {
|
1808
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
1123
1809
|
}
|
1124
|
-
async
|
1125
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
1810
|
+
async endPage(size, offset) {
|
1811
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
1126
1812
|
}
|
1127
1813
|
hasNextPage() {
|
1128
1814
|
return this.meta.page.more;
|
@@ -1134,7 +1820,7 @@ const PAGINATION_DEFAULT_SIZE = 20;
|
|
1134
1820
|
const PAGINATION_MAX_OFFSET = 800;
|
1135
1821
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
1136
1822
|
function isCursorPaginationOptions(options) {
|
1137
|
-
return isDefined(options) && (isDefined(options.
|
1823
|
+
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
1138
1824
|
}
|
1139
1825
|
const _RecordArray = class extends Array {
|
1140
1826
|
constructor(...args) {
|
@@ -1166,12 +1852,12 @@ const _RecordArray = class extends Array {
|
|
1166
1852
|
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
1167
1853
|
return new _RecordArray(newPage);
|
1168
1854
|
}
|
1169
|
-
async
|
1170
|
-
const newPage = await __privateGet$6(this, _page).
|
1855
|
+
async startPage(size, offset) {
|
1856
|
+
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
1171
1857
|
return new _RecordArray(newPage);
|
1172
1858
|
}
|
1173
|
-
async
|
1174
|
-
const newPage = await __privateGet$6(this, _page).
|
1859
|
+
async endPage(size, offset) {
|
1860
|
+
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
1175
1861
|
return new _RecordArray(newPage);
|
1176
1862
|
}
|
1177
1863
|
hasNextPage() {
|
@@ -1199,9 +1885,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
|
|
1199
1885
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1200
1886
|
return value;
|
1201
1887
|
};
|
1202
|
-
var
|
1888
|
+
var __privateMethod$3 = (obj, member, method) => {
|
1889
|
+
__accessCheck$5(obj, member, "access private method");
|
1890
|
+
return method;
|
1891
|
+
};
|
1892
|
+
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
1203
1893
|
const _Query = class {
|
1204
1894
|
constructor(repository, table, data, rawParent) {
|
1895
|
+
__privateAdd$5(this, _cleanFilterConstraint);
|
1205
1896
|
__privateAdd$5(this, _table$1, void 0);
|
1206
1897
|
__privateAdd$5(this, _repository, void 0);
|
1207
1898
|
__privateAdd$5(this, _data, { filter: {} });
|
@@ -1220,9 +1911,10 @@ const _Query = class {
|
|
1220
1911
|
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
1221
1912
|
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
1222
1913
|
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
1223
|
-
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns
|
1914
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
|
1224
1915
|
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
1225
1916
|
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
1917
|
+
__privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
|
1226
1918
|
this.any = this.any.bind(this);
|
1227
1919
|
this.all = this.all.bind(this);
|
1228
1920
|
this.not = this.not.bind(this);
|
@@ -1258,11 +1950,13 @@ const _Query = class {
|
|
1258
1950
|
}
|
1259
1951
|
filter(a, b) {
|
1260
1952
|
if (arguments.length === 1) {
|
1261
|
-
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
1953
|
+
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
1954
|
+
[column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
|
1955
|
+
}));
|
1262
1956
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1263
1957
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1264
1958
|
} else {
|
1265
|
-
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: b }] : void 0;
|
1959
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
|
1266
1960
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1267
1961
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1268
1962
|
}
|
@@ -1301,11 +1995,20 @@ const _Query = class {
|
|
1301
1995
|
}
|
1302
1996
|
}
|
1303
1997
|
async getMany(options = {}) {
|
1304
|
-
const
|
1998
|
+
const { pagination = {}, ...rest } = options;
|
1999
|
+
const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
|
2000
|
+
const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
|
2001
|
+
let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
|
2002
|
+
const results = [...page.records];
|
2003
|
+
while (page.hasNextPage() && results.length < size) {
|
2004
|
+
page = await page.nextPage();
|
2005
|
+
results.push(...page.records);
|
2006
|
+
}
|
1305
2007
|
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
1306
2008
|
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
1307
2009
|
}
|
1308
|
-
|
2010
|
+
const array = new RecordArray(page, results.slice(0, size));
|
2011
|
+
return array;
|
1309
2012
|
}
|
1310
2013
|
async getAll(options = {}) {
|
1311
2014
|
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
@@ -1319,19 +2022,35 @@ const _Query = class {
|
|
1319
2022
|
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1320
2023
|
return records[0] ?? null;
|
1321
2024
|
}
|
2025
|
+
async getFirstOrThrow(options = {}) {
|
2026
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
2027
|
+
if (records[0] === void 0)
|
2028
|
+
throw new Error("No results found.");
|
2029
|
+
return records[0];
|
2030
|
+
}
|
2031
|
+
async summarize(params = {}) {
|
2032
|
+
const { summaries, summariesFilter, ...options } = params;
|
2033
|
+
const query = new _Query(
|
2034
|
+
__privateGet$5(this, _repository),
|
2035
|
+
__privateGet$5(this, _table$1),
|
2036
|
+
options,
|
2037
|
+
__privateGet$5(this, _data)
|
2038
|
+
);
|
2039
|
+
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
2040
|
+
}
|
1322
2041
|
cache(ttl) {
|
1323
2042
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1324
2043
|
}
|
1325
2044
|
nextPage(size, offset) {
|
1326
|
-
return this.
|
2045
|
+
return this.startPage(size, offset);
|
1327
2046
|
}
|
1328
2047
|
previousPage(size, offset) {
|
1329
|
-
return this.
|
2048
|
+
return this.startPage(size, offset);
|
1330
2049
|
}
|
1331
|
-
|
2050
|
+
startPage(size, offset) {
|
1332
2051
|
return this.getPaginated({ pagination: { size, offset } });
|
1333
2052
|
}
|
1334
|
-
|
2053
|
+
endPage(size, offset) {
|
1335
2054
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
1336
2055
|
}
|
1337
2056
|
hasNextPage() {
|
@@ -1342,9 +2061,20 @@ let Query = _Query;
|
|
1342
2061
|
_table$1 = new WeakMap();
|
1343
2062
|
_repository = new WeakMap();
|
1344
2063
|
_data = new WeakMap();
|
2064
|
+
_cleanFilterConstraint = new WeakSet();
|
2065
|
+
cleanFilterConstraint_fn = function(column, value) {
|
2066
|
+
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
2067
|
+
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
2068
|
+
return { $includes: value };
|
2069
|
+
}
|
2070
|
+
if (columnType === "link" && isObject(value) && isString(value.id)) {
|
2071
|
+
return value.id;
|
2072
|
+
}
|
2073
|
+
return value;
|
2074
|
+
};
|
1345
2075
|
function cleanParent(data, parent) {
|
1346
2076
|
if (isCursorPaginationOptions(data.pagination)) {
|
1347
|
-
return { ...parent,
|
2077
|
+
return { ...parent, sort: void 0, filter: void 0 };
|
1348
2078
|
}
|
1349
2079
|
return parent;
|
1350
2080
|
}
|
@@ -1408,7 +2138,11 @@ class Repository extends Query {
|
|
1408
2138
|
}
|
1409
2139
|
class RestRepository extends Query {
|
1410
2140
|
constructor(options) {
|
1411
|
-
super(
|
2141
|
+
super(
|
2142
|
+
null,
|
2143
|
+
{ name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
|
2144
|
+
{}
|
2145
|
+
);
|
1412
2146
|
__privateAdd$4(this, _insertRecordWithoutId);
|
1413
2147
|
__privateAdd$4(this, _insertRecordWithId);
|
1414
2148
|
__privateAdd$4(this, _bulkInsertTableRecords);
|
@@ -1425,21 +2159,26 @@ class RestRepository extends Query {
|
|
1425
2159
|
__privateAdd$4(this, _schemaTables$2, void 0);
|
1426
2160
|
__privateAdd$4(this, _trace, void 0);
|
1427
2161
|
__privateSet$4(this, _table, options.table);
|
1428
|
-
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1429
2162
|
__privateSet$4(this, _db, options.db);
|
1430
2163
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
1431
2164
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
2165
|
+
__privateSet$4(this, _getFetchProps, async () => {
|
2166
|
+
const props = await options.pluginOptions.getFetchProps();
|
2167
|
+
return { ...props, sessionID: generateUUID() };
|
2168
|
+
});
|
1432
2169
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
1433
2170
|
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
1434
2171
|
return trace(name, fn, {
|
1435
2172
|
...options2,
|
1436
2173
|
[TraceAttributes.TABLE]: __privateGet$4(this, _table),
|
2174
|
+
[TraceAttributes.KIND]: "sdk-operation",
|
1437
2175
|
[TraceAttributes.VERSION]: VERSION
|
1438
2176
|
});
|
1439
2177
|
});
|
1440
2178
|
}
|
1441
|
-
async create(a, b, c) {
|
2179
|
+
async create(a, b, c, d) {
|
1442
2180
|
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
2181
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1443
2182
|
if (Array.isArray(a)) {
|
1444
2183
|
if (a.length === 0)
|
1445
2184
|
return [];
|
@@ -1450,13 +2189,13 @@ class RestRepository extends Query {
|
|
1450
2189
|
if (a === "")
|
1451
2190
|
throw new Error("The id can't be empty");
|
1452
2191
|
const columns = isStringArray(c) ? c : void 0;
|
1453
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
2192
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
1454
2193
|
}
|
1455
2194
|
if (isObject(a) && isString(a.id)) {
|
1456
2195
|
if (a.id === "")
|
1457
2196
|
throw new Error("The id can't be empty");
|
1458
2197
|
const columns = isStringArray(b) ? b : void 0;
|
1459
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
2198
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
1460
2199
|
}
|
1461
2200
|
if (isObject(a)) {
|
1462
2201
|
const columns = isStringArray(b) ? b : void 0;
|
@@ -1487,6 +2226,7 @@ class RestRepository extends Query {
|
|
1487
2226
|
pathParams: {
|
1488
2227
|
workspace: "{workspaceId}",
|
1489
2228
|
dbBranchName: "{dbBranch}",
|
2229
|
+
region: "{region}",
|
1490
2230
|
tableName: __privateGet$4(this, _table),
|
1491
2231
|
recordId: id
|
1492
2232
|
},
|
@@ -1494,7 +2234,7 @@ class RestRepository extends Query {
|
|
1494
2234
|
...fetchProps
|
1495
2235
|
});
|
1496
2236
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1497
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2237
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1498
2238
|
} catch (e) {
|
1499
2239
|
if (isObject(e) && e.status === 404) {
|
1500
2240
|
return null;
|
@@ -1505,8 +2245,28 @@ class RestRepository extends Query {
|
|
1505
2245
|
return null;
|
1506
2246
|
});
|
1507
2247
|
}
|
1508
|
-
async
|
2248
|
+
async readOrThrow(a, b) {
|
2249
|
+
return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
|
2250
|
+
const result = await this.read(a, b);
|
2251
|
+
if (Array.isArray(result)) {
|
2252
|
+
const missingIds = compact(
|
2253
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2254
|
+
);
|
2255
|
+
if (missingIds.length > 0) {
|
2256
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
2257
|
+
}
|
2258
|
+
return result;
|
2259
|
+
}
|
2260
|
+
if (result === null) {
|
2261
|
+
const id = extractId(a) ?? "unknown";
|
2262
|
+
throw new Error(`Record with id ${id} not found`);
|
2263
|
+
}
|
2264
|
+
return result;
|
2265
|
+
});
|
2266
|
+
}
|
2267
|
+
async update(a, b, c, d) {
|
1509
2268
|
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
2269
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1510
2270
|
if (Array.isArray(a)) {
|
1511
2271
|
if (a.length === 0)
|
1512
2272
|
return [];
|
@@ -1518,17 +2278,37 @@ class RestRepository extends Query {
|
|
1518
2278
|
}
|
1519
2279
|
if (isString(a) && isObject(b)) {
|
1520
2280
|
const columns = isStringArray(c) ? c : void 0;
|
1521
|
-
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
|
2281
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
1522
2282
|
}
|
1523
2283
|
if (isObject(a) && isString(a.id)) {
|
1524
2284
|
const columns = isStringArray(b) ? b : void 0;
|
1525
|
-
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
2285
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
1526
2286
|
}
|
1527
2287
|
throw new Error("Invalid arguments for update method");
|
1528
2288
|
});
|
1529
2289
|
}
|
1530
|
-
async
|
2290
|
+
async updateOrThrow(a, b, c, d) {
|
2291
|
+
return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
|
2292
|
+
const result = await this.update(a, b, c, d);
|
2293
|
+
if (Array.isArray(result)) {
|
2294
|
+
const missingIds = compact(
|
2295
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2296
|
+
);
|
2297
|
+
if (missingIds.length > 0) {
|
2298
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
2299
|
+
}
|
2300
|
+
return result;
|
2301
|
+
}
|
2302
|
+
if (result === null) {
|
2303
|
+
const id = extractId(a) ?? "unknown";
|
2304
|
+
throw new Error(`Record with id ${id} not found`);
|
2305
|
+
}
|
2306
|
+
return result;
|
2307
|
+
});
|
2308
|
+
}
|
2309
|
+
async createOrUpdate(a, b, c, d) {
|
1531
2310
|
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
2311
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1532
2312
|
if (Array.isArray(a)) {
|
1533
2313
|
if (a.length === 0)
|
1534
2314
|
return [];
|
@@ -1540,15 +2320,35 @@ class RestRepository extends Query {
|
|
1540
2320
|
}
|
1541
2321
|
if (isString(a) && isObject(b)) {
|
1542
2322
|
const columns = isStringArray(c) ? c : void 0;
|
1543
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
|
2323
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
1544
2324
|
}
|
1545
2325
|
if (isObject(a) && isString(a.id)) {
|
1546
2326
|
const columns = isStringArray(c) ? c : void 0;
|
1547
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
2327
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
1548
2328
|
}
|
1549
2329
|
throw new Error("Invalid arguments for createOrUpdate method");
|
1550
2330
|
});
|
1551
2331
|
}
|
2332
|
+
async createOrReplace(a, b, c, d) {
|
2333
|
+
return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
|
2334
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2335
|
+
if (Array.isArray(a)) {
|
2336
|
+
if (a.length === 0)
|
2337
|
+
return [];
|
2338
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2339
|
+
return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
|
2340
|
+
}
|
2341
|
+
if (isString(a) && isObject(b)) {
|
2342
|
+
const columns = isStringArray(c) ? c : void 0;
|
2343
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
2344
|
+
}
|
2345
|
+
if (isObject(a) && isString(a.id)) {
|
2346
|
+
const columns = isStringArray(c) ? c : void 0;
|
2347
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
2348
|
+
}
|
2349
|
+
throw new Error("Invalid arguments for createOrReplace method");
|
2350
|
+
});
|
2351
|
+
}
|
1552
2352
|
async delete(a, b) {
|
1553
2353
|
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
1554
2354
|
if (Array.isArray(a)) {
|
@@ -1568,11 +2368,34 @@ class RestRepository extends Query {
|
|
1568
2368
|
throw new Error("Invalid arguments for delete method");
|
1569
2369
|
});
|
1570
2370
|
}
|
2371
|
+
async deleteOrThrow(a, b) {
|
2372
|
+
return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
|
2373
|
+
const result = await this.delete(a, b);
|
2374
|
+
if (Array.isArray(result)) {
|
2375
|
+
const missingIds = compact(
|
2376
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2377
|
+
);
|
2378
|
+
if (missingIds.length > 0) {
|
2379
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
2380
|
+
}
|
2381
|
+
return result;
|
2382
|
+
} else if (result === null) {
|
2383
|
+
const id = extractId(a) ?? "unknown";
|
2384
|
+
throw new Error(`Record with id ${id} not found`);
|
2385
|
+
}
|
2386
|
+
return result;
|
2387
|
+
});
|
2388
|
+
}
|
1571
2389
|
async search(query, options = {}) {
|
1572
2390
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
1573
2391
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1574
2392
|
const { records } = await searchTable({
|
1575
|
-
pathParams: {
|
2393
|
+
pathParams: {
|
2394
|
+
workspace: "{workspaceId}",
|
2395
|
+
dbBranchName: "{dbBranch}",
|
2396
|
+
region: "{region}",
|
2397
|
+
tableName: __privateGet$4(this, _table)
|
2398
|
+
},
|
1576
2399
|
body: {
|
1577
2400
|
query,
|
1578
2401
|
fuzziness: options.fuzziness,
|
@@ -1584,7 +2407,23 @@ class RestRepository extends Query {
|
|
1584
2407
|
...fetchProps
|
1585
2408
|
});
|
1586
2409
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1587
|
-
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
2410
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
2411
|
+
});
|
2412
|
+
}
|
2413
|
+
async aggregate(aggs, filter) {
|
2414
|
+
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
2415
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2416
|
+
const result = await aggregateTable({
|
2417
|
+
pathParams: {
|
2418
|
+
workspace: "{workspaceId}",
|
2419
|
+
dbBranchName: "{dbBranch}",
|
2420
|
+
region: "{region}",
|
2421
|
+
tableName: __privateGet$4(this, _table)
|
2422
|
+
},
|
2423
|
+
body: { aggs, filter },
|
2424
|
+
...fetchProps
|
2425
|
+
});
|
2426
|
+
return result;
|
1588
2427
|
});
|
1589
2428
|
}
|
1590
2429
|
async query(query) {
|
@@ -1593,24 +2432,55 @@ class RestRepository extends Query {
|
|
1593
2432
|
if (cacheQuery)
|
1594
2433
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
1595
2434
|
const data = query.getQueryOptions();
|
1596
|
-
const body = {
|
1597
|
-
filter: cleanFilter(data.filter),
|
1598
|
-
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1599
|
-
page: data.pagination,
|
1600
|
-
columns: data.columns
|
1601
|
-
};
|
1602
2435
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1603
2436
|
const { meta, records: objects } = await queryTable({
|
1604
|
-
pathParams: {
|
1605
|
-
|
2437
|
+
pathParams: {
|
2438
|
+
workspace: "{workspaceId}",
|
2439
|
+
dbBranchName: "{dbBranch}",
|
2440
|
+
region: "{region}",
|
2441
|
+
tableName: __privateGet$4(this, _table)
|
2442
|
+
},
|
2443
|
+
body: {
|
2444
|
+
filter: cleanFilter(data.filter),
|
2445
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2446
|
+
page: data.pagination,
|
2447
|
+
columns: data.columns ?? ["*"]
|
2448
|
+
},
|
2449
|
+
fetchOptions: data.fetchOptions,
|
1606
2450
|
...fetchProps
|
1607
2451
|
});
|
1608
2452
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1609
|
-
const records = objects.map(
|
2453
|
+
const records = objects.map(
|
2454
|
+
(record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
|
2455
|
+
);
|
1610
2456
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1611
2457
|
return new Page(query, meta, records);
|
1612
2458
|
});
|
1613
2459
|
}
|
2460
|
+
async summarizeTable(query, summaries, summariesFilter) {
|
2461
|
+
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
2462
|
+
const data = query.getQueryOptions();
|
2463
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2464
|
+
const result = await summarizeTable({
|
2465
|
+
pathParams: {
|
2466
|
+
workspace: "{workspaceId}",
|
2467
|
+
dbBranchName: "{dbBranch}",
|
2468
|
+
region: "{region}",
|
2469
|
+
tableName: __privateGet$4(this, _table)
|
2470
|
+
},
|
2471
|
+
body: {
|
2472
|
+
filter: cleanFilter(data.filter),
|
2473
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2474
|
+
columns: data.columns,
|
2475
|
+
page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
|
2476
|
+
summaries,
|
2477
|
+
summariesFilter
|
2478
|
+
},
|
2479
|
+
...fetchProps
|
2480
|
+
});
|
2481
|
+
return result;
|
2482
|
+
});
|
2483
|
+
}
|
1614
2484
|
}
|
1615
2485
|
_table = new WeakMap();
|
1616
2486
|
_getFetchProps = new WeakMap();
|
@@ -1626,6 +2496,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1626
2496
|
pathParams: {
|
1627
2497
|
workspace: "{workspaceId}",
|
1628
2498
|
dbBranchName: "{dbBranch}",
|
2499
|
+
region: "{region}",
|
1629
2500
|
tableName: __privateGet$4(this, _table)
|
1630
2501
|
},
|
1631
2502
|
queryParams: { columns },
|
@@ -1633,32 +2504,38 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1633
2504
|
...fetchProps
|
1634
2505
|
});
|
1635
2506
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1636
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2507
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1637
2508
|
};
|
1638
2509
|
_insertRecordWithId = new WeakSet();
|
1639
|
-
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
2510
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
1640
2511
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1641
2512
|
const record = transformObjectLinks(object);
|
1642
2513
|
const response = await insertRecordWithID({
|
1643
2514
|
pathParams: {
|
1644
2515
|
workspace: "{workspaceId}",
|
1645
2516
|
dbBranchName: "{dbBranch}",
|
2517
|
+
region: "{region}",
|
1646
2518
|
tableName: __privateGet$4(this, _table),
|
1647
2519
|
recordId
|
1648
2520
|
},
|
1649
2521
|
body: record,
|
1650
|
-
queryParams: { createOnly
|
2522
|
+
queryParams: { createOnly, columns, ifVersion },
|
1651
2523
|
...fetchProps
|
1652
2524
|
});
|
1653
2525
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1654
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2526
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1655
2527
|
};
|
1656
2528
|
_bulkInsertTableRecords = new WeakSet();
|
1657
2529
|
bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
1658
2530
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1659
2531
|
const records = objects.map((object) => transformObjectLinks(object));
|
1660
2532
|
const response = await bulkInsertTableRecords({
|
1661
|
-
pathParams: {
|
2533
|
+
pathParams: {
|
2534
|
+
workspace: "{workspaceId}",
|
2535
|
+
dbBranchName: "{dbBranch}",
|
2536
|
+
region: "{region}",
|
2537
|
+
tableName: __privateGet$4(this, _table)
|
2538
|
+
},
|
1662
2539
|
queryParams: { columns },
|
1663
2540
|
body: { records },
|
1664
2541
|
...fetchProps
|
@@ -1667,21 +2544,27 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
|
1667
2544
|
throw new Error("Request included columns but server didn't include them");
|
1668
2545
|
}
|
1669
2546
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1670
|
-
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
2547
|
+
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
|
1671
2548
|
};
|
1672
2549
|
_updateRecordWithID = new WeakSet();
|
1673
|
-
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2550
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
1674
2551
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1675
2552
|
const record = transformObjectLinks(object);
|
1676
2553
|
try {
|
1677
2554
|
const response = await updateRecordWithID({
|
1678
|
-
pathParams: {
|
1679
|
-
|
2555
|
+
pathParams: {
|
2556
|
+
workspace: "{workspaceId}",
|
2557
|
+
dbBranchName: "{dbBranch}",
|
2558
|
+
region: "{region}",
|
2559
|
+
tableName: __privateGet$4(this, _table),
|
2560
|
+
recordId
|
2561
|
+
},
|
2562
|
+
queryParams: { columns, ifVersion },
|
1680
2563
|
body: record,
|
1681
2564
|
...fetchProps
|
1682
2565
|
});
|
1683
2566
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1684
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2567
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1685
2568
|
} catch (e) {
|
1686
2569
|
if (isObject(e) && e.status === 404) {
|
1687
2570
|
return null;
|
@@ -1690,28 +2573,40 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
1690
2573
|
}
|
1691
2574
|
};
|
1692
2575
|
_upsertRecordWithID = new WeakSet();
|
1693
|
-
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2576
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
1694
2577
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1695
2578
|
const response = await upsertRecordWithID({
|
1696
|
-
pathParams: {
|
1697
|
-
|
2579
|
+
pathParams: {
|
2580
|
+
workspace: "{workspaceId}",
|
2581
|
+
dbBranchName: "{dbBranch}",
|
2582
|
+
region: "{region}",
|
2583
|
+
tableName: __privateGet$4(this, _table),
|
2584
|
+
recordId
|
2585
|
+
},
|
2586
|
+
queryParams: { columns, ifVersion },
|
1698
2587
|
body: object,
|
1699
2588
|
...fetchProps
|
1700
2589
|
});
|
1701
2590
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1702
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2591
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1703
2592
|
};
|
1704
2593
|
_deleteRecord = new WeakSet();
|
1705
2594
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
1706
2595
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1707
2596
|
try {
|
1708
2597
|
const response = await deleteRecord({
|
1709
|
-
pathParams: {
|
2598
|
+
pathParams: {
|
2599
|
+
workspace: "{workspaceId}",
|
2600
|
+
dbBranchName: "{dbBranch}",
|
2601
|
+
region: "{region}",
|
2602
|
+
tableName: __privateGet$4(this, _table),
|
2603
|
+
recordId
|
2604
|
+
},
|
1710
2605
|
queryParams: { columns },
|
1711
2606
|
...fetchProps
|
1712
2607
|
});
|
1713
2608
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1714
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2609
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1715
2610
|
} catch (e) {
|
1716
2611
|
if (isObject(e) && e.status === 404) {
|
1717
2612
|
return null;
|
@@ -1741,7 +2636,7 @@ getSchemaTables_fn$1 = async function() {
|
|
1741
2636
|
return __privateGet$4(this, _schemaTables$2);
|
1742
2637
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1743
2638
|
const { schema } = await getBranchDetails({
|
1744
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2639
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
1745
2640
|
...fetchProps
|
1746
2641
|
});
|
1747
2642
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
@@ -1754,7 +2649,7 @@ const transformObjectLinks = (object) => {
|
|
1754
2649
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1755
2650
|
}, {});
|
1756
2651
|
};
|
1757
|
-
const initObject = (db, schemaTables, table, object) => {
|
2652
|
+
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
1758
2653
|
const result = {};
|
1759
2654
|
const { xata, ...rest } = object ?? {};
|
1760
2655
|
Object.assign(result, rest);
|
@@ -1762,6 +2657,8 @@ const initObject = (db, schemaTables, table, object) => {
|
|
1762
2657
|
if (!columns)
|
1763
2658
|
console.error(`Table ${table} not found in schema`);
|
1764
2659
|
for (const column of columns ?? []) {
|
2660
|
+
if (!isValidColumn(selectedColumns, column))
|
2661
|
+
continue;
|
1765
2662
|
const value = result[column.name];
|
1766
2663
|
switch (column.type) {
|
1767
2664
|
case "datetime": {
|
@@ -1778,17 +2675,42 @@ const initObject = (db, schemaTables, table, object) => {
|
|
1778
2675
|
if (!linkTable) {
|
1779
2676
|
console.error(`Failed to parse link for field ${column.name}`);
|
1780
2677
|
} else if (isObject(value)) {
|
1781
|
-
|
2678
|
+
const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
|
2679
|
+
if (item === column.name) {
|
2680
|
+
return [...acc, "*"];
|
2681
|
+
}
|
2682
|
+
if (item.startsWith(`${column.name}.`)) {
|
2683
|
+
const [, ...path] = item.split(".");
|
2684
|
+
return [...acc, path.join(".")];
|
2685
|
+
}
|
2686
|
+
return acc;
|
2687
|
+
}, []);
|
2688
|
+
result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
|
2689
|
+
} else {
|
2690
|
+
result[column.name] = null;
|
1782
2691
|
}
|
1783
2692
|
break;
|
1784
2693
|
}
|
2694
|
+
default:
|
2695
|
+
result[column.name] = value ?? null;
|
2696
|
+
if (column.notNull === true && value === null) {
|
2697
|
+
console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
|
2698
|
+
}
|
2699
|
+
break;
|
1785
2700
|
}
|
1786
2701
|
}
|
1787
2702
|
result.read = function(columns2) {
|
1788
2703
|
return db[table].read(result["id"], columns2);
|
1789
2704
|
};
|
1790
|
-
result.update = function(data,
|
1791
|
-
|
2705
|
+
result.update = function(data, b, c) {
|
2706
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2707
|
+
const ifVersion = parseIfVersion(b, c);
|
2708
|
+
return db[table].update(result["id"], data, columns2, { ifVersion });
|
2709
|
+
};
|
2710
|
+
result.replace = function(data, b, c) {
|
2711
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2712
|
+
const ifVersion = parseIfVersion(b, c);
|
2713
|
+
return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
|
1792
2714
|
};
|
1793
2715
|
result.delete = function() {
|
1794
2716
|
return db[table].delete(result["id"]);
|
@@ -1796,7 +2718,7 @@ const initObject = (db, schemaTables, table, object) => {
|
|
1796
2718
|
result.getMetadata = function() {
|
1797
2719
|
return xata;
|
1798
2720
|
};
|
1799
|
-
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
2721
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
|
1800
2722
|
Object.defineProperty(result, prop, { enumerable: false });
|
1801
2723
|
}
|
1802
2724
|
Object.freeze(result);
|
@@ -1812,11 +2734,22 @@ function extractId(value) {
|
|
1812
2734
|
return value.id;
|
1813
2735
|
return void 0;
|
1814
2736
|
}
|
1815
|
-
function
|
1816
|
-
if (
|
1817
|
-
return
|
1818
|
-
|
1819
|
-
|
2737
|
+
function isValidColumn(columns, column) {
|
2738
|
+
if (columns.includes("*"))
|
2739
|
+
return true;
|
2740
|
+
if (column.type === "link") {
|
2741
|
+
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
2742
|
+
return linkColumns.length > 0;
|
2743
|
+
}
|
2744
|
+
return columns.includes(column.name);
|
2745
|
+
}
|
2746
|
+
function parseIfVersion(...args) {
|
2747
|
+
for (const arg of args) {
|
2748
|
+
if (isObject(arg) && isNumber(arg.ifVersion)) {
|
2749
|
+
return arg.ifVersion;
|
2750
|
+
}
|
2751
|
+
}
|
2752
|
+
return void 0;
|
1820
2753
|
}
|
1821
2754
|
|
1822
2755
|
var __accessCheck$3 = (obj, member, msg) => {
|
@@ -1983,7 +2916,7 @@ class SearchPlugin extends XataPlugin {
|
|
1983
2916
|
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1984
2917
|
return records.map((record) => {
|
1985
2918
|
const { table = "orphan" } = record.xata;
|
1986
|
-
return { table, record: initObject(this.db, schemaTables, table, record) };
|
2919
|
+
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
1987
2920
|
});
|
1988
2921
|
},
|
1989
2922
|
byTable: async (query, options = {}) => {
|
@@ -1992,7 +2925,7 @@ class SearchPlugin extends XataPlugin {
|
|
1992
2925
|
return records.reduce((acc, record) => {
|
1993
2926
|
const { table = "orphan" } = record.xata;
|
1994
2927
|
const items = acc[table] ?? [];
|
1995
|
-
const item = initObject(this.db, schemaTables, table, record);
|
2928
|
+
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
1996
2929
|
return { ...acc, [table]: [...items, item] };
|
1997
2930
|
}, {});
|
1998
2931
|
}
|
@@ -2005,7 +2938,7 @@ search_fn = async function(query, options, getFetchProps) {
|
|
2005
2938
|
const fetchProps = await getFetchProps();
|
2006
2939
|
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
2007
2940
|
const { records } = await searchBranch({
|
2008
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2941
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2009
2942
|
body: { tables, query, fuzziness, prefix, highlight },
|
2010
2943
|
...fetchProps
|
2011
2944
|
});
|
@@ -2017,7 +2950,7 @@ getSchemaTables_fn = async function(getFetchProps) {
|
|
2017
2950
|
return __privateGet$1(this, _schemaTables);
|
2018
2951
|
const fetchProps = await getFetchProps();
|
2019
2952
|
const { schema } = await getBranchDetails({
|
2020
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2953
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2021
2954
|
...fetchProps
|
2022
2955
|
});
|
2023
2956
|
__privateSet$1(this, _schemaTables, schema.tables);
|
@@ -2055,14 +2988,17 @@ async function resolveXataBranch(gitBranch, options) {
|
|
2055
2988
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2056
2989
|
);
|
2057
2990
|
const [protocol, , host, , dbName] = databaseURL.split("/");
|
2058
|
-
const
|
2991
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
2992
|
+
if (!urlParts)
|
2993
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
2994
|
+
const { workspace, region } = urlParts;
|
2059
2995
|
const { fallbackBranch } = getEnvironment();
|
2060
2996
|
const { branch } = await resolveBranch({
|
2061
2997
|
apiKey,
|
2062
2998
|
apiUrl: databaseURL,
|
2063
2999
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2064
3000
|
workspacesApiUrl: `${protocol}//${host}`,
|
2065
|
-
pathParams: { dbName, workspace },
|
3001
|
+
pathParams: { dbName, workspace, region },
|
2066
3002
|
queryParams: { gitBranch, fallbackBranch },
|
2067
3003
|
trace: defaultTrace
|
2068
3004
|
});
|
@@ -2080,15 +3016,17 @@ async function getDatabaseBranch(branch, options) {
|
|
2080
3016
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2081
3017
|
);
|
2082
3018
|
const [protocol, , host, , database] = databaseURL.split("/");
|
2083
|
-
const
|
2084
|
-
|
3019
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
3020
|
+
if (!urlParts)
|
3021
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3022
|
+
const { workspace, region } = urlParts;
|
2085
3023
|
try {
|
2086
3024
|
return await getBranchDetails({
|
2087
3025
|
apiKey,
|
2088
3026
|
apiUrl: databaseURL,
|
2089
3027
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2090
3028
|
workspacesApiUrl: `${protocol}//${host}`,
|
2091
|
-
pathParams: { dbBranchName
|
3029
|
+
pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
|
2092
3030
|
trace: defaultTrace
|
2093
3031
|
});
|
2094
3032
|
} catch (err) {
|
@@ -2167,6 +3105,13 @@ const buildClient = (plugins) => {
|
|
2167
3105
|
return { databaseURL, branch };
|
2168
3106
|
}
|
2169
3107
|
}, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
3108
|
+
const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
|
3109
|
+
const isBrowser = typeof window !== "undefined";
|
3110
|
+
if (isBrowser && !enableBrowser) {
|
3111
|
+
throw new Error(
|
3112
|
+
"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."
|
3113
|
+
);
|
3114
|
+
}
|
2170
3115
|
const fetch = getFetchImplementation(options?.fetch);
|
2171
3116
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
2172
3117
|
const apiKey = options?.apiKey || getAPIKey();
|
@@ -2179,8 +3124,8 @@ const buildClient = (plugins) => {
|
|
2179
3124
|
if (!databaseURL) {
|
2180
3125
|
throw new Error("Option databaseURL is required");
|
2181
3126
|
}
|
2182
|
-
return { fetch, databaseURL, apiKey, branch, cache, trace };
|
2183
|
-
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
|
3127
|
+
return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser };
|
3128
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
|
2184
3129
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
2185
3130
|
if (!branchValue)
|
2186
3131
|
throw new Error("Unable to resolve branch value");
|
@@ -2190,10 +3135,11 @@ const buildClient = (plugins) => {
|
|
2190
3135
|
apiUrl: "",
|
2191
3136
|
workspacesApiUrl: (path, params) => {
|
2192
3137
|
const hasBranch = params.dbBranchName ?? params.branch;
|
2193
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
|
3138
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
|
2194
3139
|
return databaseURL + newPath;
|
2195
3140
|
},
|
2196
|
-
trace
|
3141
|
+
trace,
|
3142
|
+
clientID
|
2197
3143
|
};
|
2198
3144
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
2199
3145
|
if (__privateGet(this, _branch))
|
@@ -2327,16 +3273,28 @@ exports.XataPlugin = XataPlugin;
|
|
2327
3273
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
2328
3274
|
exports.addGitBranchesEntry = addGitBranchesEntry;
|
2329
3275
|
exports.addTableColumn = addTableColumn;
|
3276
|
+
exports.aggregateTable = aggregateTable;
|
3277
|
+
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
3278
|
+
exports.branchTransaction = branchTransaction;
|
2330
3279
|
exports.buildClient = buildClient;
|
2331
3280
|
exports.buildWorkerRunner = buildWorkerRunner;
|
2332
3281
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
2333
3282
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
3283
|
+
exports.compareBranchSchemas = compareBranchSchemas;
|
3284
|
+
exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
|
3285
|
+
exports.compareMigrationRequest = compareMigrationRequest;
|
2334
3286
|
exports.contains = contains;
|
2335
3287
|
exports.createBranch = createBranch;
|
2336
3288
|
exports.createDatabase = createDatabase;
|
3289
|
+
exports.createMigrationRequest = createMigrationRequest;
|
2337
3290
|
exports.createTable = createTable;
|
2338
3291
|
exports.createUserAPIKey = createUserAPIKey;
|
2339
3292
|
exports.createWorkspace = createWorkspace;
|
3293
|
+
exports.dEPRECATEDcreateDatabase = dEPRECATEDcreateDatabase;
|
3294
|
+
exports.dEPRECATEDdeleteDatabase = dEPRECATEDdeleteDatabase;
|
3295
|
+
exports.dEPRECATEDgetDatabaseList = dEPRECATEDgetDatabaseList;
|
3296
|
+
exports.dEPRECATEDgetDatabaseMetadata = dEPRECATEDgetDatabaseMetadata;
|
3297
|
+
exports.dEPRECATEDupdateDatabaseMetadata = dEPRECATEDupdateDatabaseMetadata;
|
2340
3298
|
exports.deleteBranch = deleteBranch;
|
2341
3299
|
exports.deleteColumn = deleteColumn;
|
2342
3300
|
exports.deleteDatabase = deleteDatabase;
|
@@ -2357,6 +3315,7 @@ exports.getBranchList = getBranchList;
|
|
2357
3315
|
exports.getBranchMetadata = getBranchMetadata;
|
2358
3316
|
exports.getBranchMigrationHistory = getBranchMigrationHistory;
|
2359
3317
|
exports.getBranchMigrationPlan = getBranchMigrationPlan;
|
3318
|
+
exports.getBranchSchemaHistory = getBranchSchemaHistory;
|
2360
3319
|
exports.getBranchStats = getBranchStats;
|
2361
3320
|
exports.getColumn = getColumn;
|
2362
3321
|
exports.getCurrentBranchDetails = getCurrentBranchDetails;
|
@@ -2365,6 +3324,9 @@ exports.getDatabaseList = getDatabaseList;
|
|
2365
3324
|
exports.getDatabaseMetadata = getDatabaseMetadata;
|
2366
3325
|
exports.getDatabaseURL = getDatabaseURL;
|
2367
3326
|
exports.getGitBranchesMapping = getGitBranchesMapping;
|
3327
|
+
exports.getHostUrl = getHostUrl;
|
3328
|
+
exports.getMigrationRequest = getMigrationRequest;
|
3329
|
+
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
2368
3330
|
exports.getRecord = getRecord;
|
2369
3331
|
exports.getTableColumns = getTableColumns;
|
2370
3332
|
exports.getTableSchema = getTableSchema;
|
@@ -2387,6 +3349,8 @@ exports.insertRecordWithID = insertRecordWithID;
|
|
2387
3349
|
exports.inviteWorkspaceMember = inviteWorkspaceMember;
|
2388
3350
|
exports.is = is;
|
2389
3351
|
exports.isCursorPaginationOptions = isCursorPaginationOptions;
|
3352
|
+
exports.isHostProviderAlias = isHostProviderAlias;
|
3353
|
+
exports.isHostProviderBuilder = isHostProviderBuilder;
|
2390
3354
|
exports.isIdentifiable = isIdentifiable;
|
2391
3355
|
exports.isNot = isNot;
|
2392
3356
|
exports.isXataRecord = isXataRecord;
|
@@ -2394,11 +3358,18 @@ exports.le = le;
|
|
2394
3358
|
exports.lessEquals = lessEquals;
|
2395
3359
|
exports.lessThan = lessThan;
|
2396
3360
|
exports.lessThanEquals = lessThanEquals;
|
3361
|
+
exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
|
3362
|
+
exports.listRegions = listRegions;
|
2397
3363
|
exports.lt = lt;
|
2398
3364
|
exports.lte = lte;
|
3365
|
+
exports.mergeMigrationRequest = mergeMigrationRequest;
|
2399
3366
|
exports.notExists = notExists;
|
2400
3367
|
exports.operationsByTag = operationsByTag;
|
3368
|
+
exports.parseProviderString = parseProviderString;
|
3369
|
+
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
2401
3370
|
exports.pattern = pattern;
|
3371
|
+
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
3372
|
+
exports.queryMigrationRequests = queryMigrationRequests;
|
2402
3373
|
exports.queryTable = queryTable;
|
2403
3374
|
exports.removeGitBranchesEntry = removeGitBranchesEntry;
|
2404
3375
|
exports.removeWorkspaceMember = removeWorkspaceMember;
|
@@ -2409,8 +3380,12 @@ exports.searchTable = searchTable;
|
|
2409
3380
|
exports.serialize = serialize;
|
2410
3381
|
exports.setTableSchema = setTableSchema;
|
2411
3382
|
exports.startsWith = startsWith;
|
3383
|
+
exports.summarizeTable = summarizeTable;
|
2412
3384
|
exports.updateBranchMetadata = updateBranchMetadata;
|
3385
|
+
exports.updateBranchSchema = updateBranchSchema;
|
2413
3386
|
exports.updateColumn = updateColumn;
|
3387
|
+
exports.updateDatabaseMetadata = updateDatabaseMetadata;
|
3388
|
+
exports.updateMigrationRequest = updateMigrationRequest;
|
2414
3389
|
exports.updateRecordWithID = updateRecordWithID;
|
2415
3390
|
exports.updateTable = updateTable;
|
2416
3391
|
exports.updateUser = updateUser;
|