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