@xata.io/client 0.0.0-alpha.vf683143 → 0.0.0-alpha.vf6b372c
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 +64 -0
- package/README.md +5 -5
- package/dist/index.cjs +1263 -586
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3867 -1648
- package/dist/index.mjs +1251 -586
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
@@ -60,6 +60,9 @@ function isString(value) {
|
|
60
60
|
function isStringArray(value) {
|
61
61
|
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
62
62
|
}
|
63
|
+
function isNumber(value) {
|
64
|
+
return isDefined(value) && typeof value === "number";
|
65
|
+
}
|
63
66
|
function toBase64(value) {
|
64
67
|
try {
|
65
68
|
return btoa(value);
|
@@ -68,6 +71,17 @@ function toBase64(value) {
|
|
68
71
|
return buf.from(value).toString("base64");
|
69
72
|
}
|
70
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
|
+
}
|
71
85
|
|
72
86
|
function getEnvironment() {
|
73
87
|
try {
|
@@ -172,7 +186,7 @@ function getFetchImplementation(userFetch) {
|
|
172
186
|
return fetchImpl;
|
173
187
|
}
|
174
188
|
|
175
|
-
const VERSION = "0.0.0-alpha.
|
189
|
+
const VERSION = "0.0.0-alpha.vf6b372c";
|
176
190
|
|
177
191
|
class ErrorWithCause extends Error {
|
178
192
|
constructor(message, options) {
|
@@ -229,15 +243,18 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
229
243
|
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
230
244
|
};
|
231
245
|
function buildBaseUrl({
|
246
|
+
endpoint,
|
232
247
|
path,
|
233
248
|
workspacesApiUrl,
|
234
249
|
apiUrl,
|
235
|
-
pathParams
|
250
|
+
pathParams = {}
|
236
251
|
}) {
|
237
|
-
if (
|
238
|
-
|
239
|
-
|
240
|
-
|
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}`;
|
241
258
|
}
|
242
259
|
function hostHeader(url) {
|
243
260
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
@@ -253,14 +270,18 @@ async function fetch$1({
|
|
253
270
|
queryParams,
|
254
271
|
fetchImpl,
|
255
272
|
apiKey,
|
273
|
+
endpoint,
|
256
274
|
apiUrl,
|
257
275
|
workspacesApiUrl,
|
258
|
-
trace
|
276
|
+
trace,
|
277
|
+
signal,
|
278
|
+
clientID,
|
279
|
+
sessionID
|
259
280
|
}) {
|
260
281
|
return trace(
|
261
282
|
`${method.toUpperCase()} ${path}`,
|
262
283
|
async ({ setAttributes }) => {
|
263
|
-
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
284
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
264
285
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
265
286
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
266
287
|
setAttributes({
|
@@ -273,10 +294,13 @@ async function fetch$1({
|
|
273
294
|
headers: {
|
274
295
|
"Content-Type": "application/json",
|
275
296
|
"User-Agent": `Xata client-ts/${VERSION}`,
|
297
|
+
"X-Xata-Client-ID": clientID ?? "",
|
298
|
+
"X-Xata-Session-ID": sessionID ?? "",
|
276
299
|
...headers,
|
277
300
|
...hostHeader(fullUrl),
|
278
301
|
Authorization: `Bearer ${apiKey}`
|
279
|
-
}
|
302
|
+
},
|
303
|
+
signal
|
280
304
|
});
|
281
305
|
if (response.status === 204) {
|
282
306
|
return {};
|
@@ -312,279 +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 updateDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
|
412
|
-
const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
|
413
|
-
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
414
|
-
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
415
|
-
const resolveBranch = (variables) => fetch$1({
|
416
|
-
url: "/dbs/{dbName}/resolveBranch",
|
417
|
-
method: "get",
|
418
|
-
...variables
|
363
|
+
...variables,
|
364
|
+
signal
|
419
365
|
});
|
420
|
-
const
|
421
|
-
const
|
422
|
-
const getMigrationRequest = (variables) => fetch$1({
|
423
|
-
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
424
|
-
method: "get",
|
425
|
-
...variables
|
426
|
-
});
|
427
|
-
const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
|
428
|
-
const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
|
429
|
-
const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
|
430
|
-
const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
|
431
|
-
const mergeMigrationRequest = (variables) => fetch$1({
|
432
|
-
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
433
|
-
method: "post",
|
434
|
-
...variables
|
435
|
-
});
|
436
|
-
const getBranchDetails = (variables) => fetch$1({
|
366
|
+
const updateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
|
367
|
+
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
437
368
|
url: "/db/{dbBranchName}",
|
438
369
|
method: "get",
|
439
|
-
...variables
|
370
|
+
...variables,
|
371
|
+
signal
|
440
372
|
});
|
441
|
-
const createBranch = (variables) =>
|
442
|
-
const deleteBranch = (variables) =>
|
373
|
+
const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
|
374
|
+
const deleteBranch = (variables, signal) => dataPlaneFetch({
|
443
375
|
url: "/db/{dbBranchName}",
|
444
376
|
method: "delete",
|
445
|
-
...variables
|
377
|
+
...variables,
|
378
|
+
signal
|
446
379
|
});
|
447
|
-
const updateBranchMetadata = (variables) =>
|
380
|
+
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
448
381
|
url: "/db/{dbBranchName}/metadata",
|
449
382
|
method: "put",
|
450
|
-
...variables
|
383
|
+
...variables,
|
384
|
+
signal
|
451
385
|
});
|
452
|
-
const getBranchMetadata = (variables) =>
|
386
|
+
const getBranchMetadata = (variables, signal) => dataPlaneFetch({
|
453
387
|
url: "/db/{dbBranchName}/metadata",
|
454
388
|
method: "get",
|
455
|
-
...variables
|
389
|
+
...variables,
|
390
|
+
signal
|
456
391
|
});
|
457
|
-
const
|
458
|
-
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
459
|
-
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
460
|
-
const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
|
461
|
-
const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
|
462
|
-
const updateBranchSchema = (variables) => fetch$1({
|
463
|
-
url: "/db/{dbBranchName}/schema/update",
|
464
|
-
method: "post",
|
465
|
-
...variables
|
466
|
-
});
|
467
|
-
const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
|
468
|
-
const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
|
469
|
-
const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
|
470
|
-
const getBranchStats = (variables) => fetch$1({
|
392
|
+
const getBranchStats = (variables, signal) => dataPlaneFetch({
|
471
393
|
url: "/db/{dbBranchName}/stats",
|
472
394
|
method: "get",
|
473
|
-
...variables
|
395
|
+
...variables,
|
396
|
+
signal
|
397
|
+
});
|
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
|
474
412
|
});
|
475
|
-
const
|
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({
|
476
430
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
477
431
|
method: "put",
|
478
|
-
...variables
|
432
|
+
...variables,
|
433
|
+
signal
|
479
434
|
});
|
480
|
-
const deleteTable = (variables) =>
|
435
|
+
const deleteTable = (variables, signal) => dataPlaneFetch({
|
481
436
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
482
437
|
method: "delete",
|
483
|
-
...variables
|
484
|
-
|
485
|
-
const updateTable = (variables) => fetch$1({
|
486
|
-
url: "/db/{dbBranchName}/tables/{tableName}",
|
487
|
-
method: "patch",
|
488
|
-
...variables
|
438
|
+
...variables,
|
439
|
+
signal
|
489
440
|
});
|
490
|
-
const
|
441
|
+
const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
|
442
|
+
const getTableSchema = (variables, signal) => dataPlaneFetch({
|
491
443
|
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
492
444
|
method: "get",
|
493
|
-
...variables
|
494
|
-
|
495
|
-
const setTableSchema = (variables) => fetch$1({
|
496
|
-
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
497
|
-
method: "put",
|
498
|
-
...variables
|
445
|
+
...variables,
|
446
|
+
signal
|
499
447
|
});
|
500
|
-
const
|
448
|
+
const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
|
449
|
+
const getTableColumns = (variables, signal) => dataPlaneFetch({
|
501
450
|
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
502
451
|
method: "get",
|
503
|
-
...variables
|
452
|
+
...variables,
|
453
|
+
signal
|
504
454
|
});
|
505
|
-
const addTableColumn = (variables) =>
|
506
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
507
|
-
|
508
|
-
|
509
|
-
});
|
510
|
-
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({
|
511
459
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
512
460
|
method: "get",
|
513
|
-
...variables
|
461
|
+
...variables,
|
462
|
+
signal
|
514
463
|
});
|
515
|
-
const
|
464
|
+
const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
|
465
|
+
const deleteColumn = (variables, signal) => dataPlaneFetch({
|
516
466
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
517
467
|
method: "delete",
|
518
|
-
...variables
|
468
|
+
...variables,
|
469
|
+
signal
|
519
470
|
});
|
520
|
-
const
|
521
|
-
|
522
|
-
method: "patch",
|
523
|
-
...variables
|
524
|
-
});
|
525
|
-
const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
|
526
|
-
const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
|
527
|
-
const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
|
528
|
-
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
529
|
-
const deleteRecord = (variables) => fetch$1({
|
530
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
531
|
-
method: "delete",
|
532
|
-
...variables
|
533
|
-
});
|
534
|
-
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({
|
535
473
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
536
474
|
method: "get",
|
537
|
-
...variables
|
475
|
+
...variables,
|
476
|
+
signal
|
538
477
|
});
|
539
|
-
const
|
540
|
-
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({
|
541
484
|
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
542
485
|
method: "post",
|
543
|
-
...variables
|
544
|
-
|
545
|
-
const searchTable = (variables) => fetch$1({
|
546
|
-
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
547
|
-
method: "post",
|
548
|
-
...variables
|
486
|
+
...variables,
|
487
|
+
signal
|
549
488
|
});
|
550
|
-
const searchBranch = (variables) =>
|
489
|
+
const searchBranch = (variables, signal) => dataPlaneFetch({
|
551
490
|
url: "/db/{dbBranchName}/search",
|
552
491
|
method: "post",
|
553
|
-
...variables
|
492
|
+
...variables,
|
493
|
+
signal
|
554
494
|
});
|
555
|
-
const
|
556
|
-
url: "/db/{dbBranchName}/tables/{tableName}/
|
495
|
+
const searchTable = (variables, signal) => dataPlaneFetch({
|
496
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
557
497
|
method: "post",
|
558
|
-
...variables
|
498
|
+
...variables,
|
499
|
+
signal
|
559
500
|
});
|
560
|
-
const
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
getWorkspacesList,
|
565
|
-
getWorkspace,
|
566
|
-
updateWorkspace,
|
567
|
-
deleteWorkspace,
|
568
|
-
getWorkspaceMembersList,
|
569
|
-
updateWorkspaceMemberRole,
|
570
|
-
removeWorkspaceMember,
|
571
|
-
inviteWorkspaceMember,
|
572
|
-
updateWorkspaceMemberInvite,
|
573
|
-
cancelWorkspaceMemberInvite,
|
574
|
-
resendWorkspaceMemberInvite,
|
575
|
-
acceptWorkspaceMemberInvite
|
576
|
-
},
|
577
|
-
database: {
|
578
|
-
getDatabaseList,
|
579
|
-
createDatabase,
|
580
|
-
deleteDatabase,
|
581
|
-
getDatabaseMetadata,
|
582
|
-
updateDatabaseMetadata,
|
583
|
-
getGitBranchesMapping,
|
584
|
-
addGitBranchesEntry,
|
585
|
-
removeGitBranchesEntry,
|
586
|
-
resolveBranch
|
587
|
-
},
|
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 },
|
588
505
|
branch: {
|
589
506
|
getBranchList,
|
590
507
|
getBranchDetails,
|
@@ -592,10 +509,25 @@ const operationsByTag = {
|
|
592
509
|
deleteBranch,
|
593
510
|
updateBranchMetadata,
|
594
511
|
getBranchMetadata,
|
595
|
-
getBranchStats
|
512
|
+
getBranchStats,
|
513
|
+
getGitBranchesMapping,
|
514
|
+
addGitBranchesEntry,
|
515
|
+
removeGitBranchesEntry,
|
516
|
+
resolveBranch
|
517
|
+
},
|
518
|
+
migrations: {
|
519
|
+
getBranchMigrationHistory,
|
520
|
+
getBranchMigrationPlan,
|
521
|
+
executeBranchMigrationPlan,
|
522
|
+
getBranchSchemaHistory,
|
523
|
+
compareBranchWithUserSchema,
|
524
|
+
compareBranchSchemas,
|
525
|
+
updateBranchSchema,
|
526
|
+
previewBranchSchemaEdit,
|
527
|
+
applyBranchSchemaEdit
|
596
528
|
},
|
597
529
|
migrationRequests: {
|
598
|
-
|
530
|
+
queryMigrationRequests,
|
599
531
|
createMigrationRequest,
|
600
532
|
getMigrationRequest,
|
601
533
|
updateMigrationRequest,
|
@@ -604,17 +536,6 @@ const operationsByTag = {
|
|
604
536
|
getMigrationRequestIsMerged,
|
605
537
|
mergeMigrationRequest
|
606
538
|
},
|
607
|
-
branchSchema: {
|
608
|
-
getBranchMigrationHistory,
|
609
|
-
executeBranchMigrationPlan,
|
610
|
-
getBranchMigrationPlan,
|
611
|
-
compareBranchWithUserSchema,
|
612
|
-
compareBranchSchemas,
|
613
|
-
updateBranchSchema,
|
614
|
-
previewBranchSchemaEdit,
|
615
|
-
applyBranchSchemaEdit,
|
616
|
-
getBranchSchemaHistory
|
617
|
-
},
|
618
539
|
table: {
|
619
540
|
createTable,
|
620
541
|
deleteTable,
|
@@ -624,24 +545,150 @@ const operationsByTag = {
|
|
624
545
|
getTableColumns,
|
625
546
|
addTableColumn,
|
626
547
|
getColumn,
|
627
|
-
|
628
|
-
|
548
|
+
updateColumn,
|
549
|
+
deleteColumn
|
629
550
|
},
|
630
551
|
records: {
|
631
552
|
insertRecord,
|
553
|
+
getRecord,
|
632
554
|
insertRecordWithID,
|
633
555
|
updateRecordWithID,
|
634
556
|
upsertRecordWithID,
|
635
557
|
deleteRecord,
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
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
|
642
687
|
}
|
643
688
|
};
|
644
689
|
|
690
|
+
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
691
|
+
|
645
692
|
function getHostUrl(provider, type) {
|
646
693
|
if (isHostProviderAlias(provider)) {
|
647
694
|
return providers[provider][type];
|
@@ -653,11 +700,11 @@ function getHostUrl(provider, type) {
|
|
653
700
|
const providers = {
|
654
701
|
production: {
|
655
702
|
main: "https://api.xata.io",
|
656
|
-
workspaces: "https://{workspaceId}.xata.sh"
|
703
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
657
704
|
},
|
658
705
|
staging: {
|
659
706
|
main: "https://staging.xatabase.co",
|
660
|
-
workspaces: "https://{workspaceId}.staging.xatabase.co"
|
707
|
+
workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
|
661
708
|
}
|
662
709
|
};
|
663
710
|
function isHostProviderAlias(alias) {
|
@@ -666,6 +713,25 @@ function isHostProviderAlias(alias) {
|
|
666
713
|
function isHostProviderBuilder(builder) {
|
667
714
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
668
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
|
+
}
|
669
735
|
|
670
736
|
var __accessCheck$7 = (obj, member, msg) => {
|
671
737
|
if (!member.has(obj))
|
@@ -709,21 +775,41 @@ class XataApiClient {
|
|
709
775
|
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
710
776
|
return __privateGet$7(this, _namespaces).user;
|
711
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
|
+
}
|
712
783
|
get workspaces() {
|
713
784
|
if (!__privateGet$7(this, _namespaces).workspaces)
|
714
785
|
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
715
786
|
return __privateGet$7(this, _namespaces).workspaces;
|
716
787
|
}
|
717
|
-
get
|
718
|
-
if (!__privateGet$7(this, _namespaces).
|
719
|
-
__privateGet$7(this, _namespaces).
|
720
|
-
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;
|
721
797
|
}
|
722
798
|
get branches() {
|
723
799
|
if (!__privateGet$7(this, _namespaces).branches)
|
724
800
|
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
725
801
|
return __privateGet$7(this, _namespaces).branches;
|
726
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
|
+
}
|
727
813
|
get tables() {
|
728
814
|
if (!__privateGet$7(this, _namespaces).tables)
|
729
815
|
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
@@ -734,15 +820,10 @@ class XataApiClient {
|
|
734
820
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
735
821
|
return __privateGet$7(this, _namespaces).records;
|
736
822
|
}
|
737
|
-
get
|
738
|
-
if (!__privateGet$7(this, _namespaces).
|
739
|
-
__privateGet$7(this, _namespaces).
|
740
|
-
return __privateGet$7(this, _namespaces).
|
741
|
-
}
|
742
|
-
get branchSchema() {
|
743
|
-
if (!__privateGet$7(this, _namespaces).branchSchema)
|
744
|
-
__privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
|
745
|
-
return __privateGet$7(this, _namespaces).branchSchema;
|
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;
|
746
827
|
}
|
747
828
|
}
|
748
829
|
_extraProps = new WeakMap();
|
@@ -754,24 +835,29 @@ class UserApi {
|
|
754
835
|
getUser() {
|
755
836
|
return operationsByTag.users.getUser({ ...this.extraProps });
|
756
837
|
}
|
757
|
-
updateUser(user) {
|
838
|
+
updateUser({ user }) {
|
758
839
|
return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
|
759
840
|
}
|
760
841
|
deleteUser() {
|
761
842
|
return operationsByTag.users.deleteUser({ ...this.extraProps });
|
762
843
|
}
|
844
|
+
}
|
845
|
+
class AuthenticationApi {
|
846
|
+
constructor(extraProps) {
|
847
|
+
this.extraProps = extraProps;
|
848
|
+
}
|
763
849
|
getUserAPIKeys() {
|
764
|
-
return operationsByTag.
|
850
|
+
return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
|
765
851
|
}
|
766
|
-
createUserAPIKey(
|
767
|
-
return operationsByTag.
|
768
|
-
pathParams: { keyName },
|
852
|
+
createUserAPIKey({ name }) {
|
853
|
+
return operationsByTag.authentication.createUserAPIKey({
|
854
|
+
pathParams: { keyName: name },
|
769
855
|
...this.extraProps
|
770
856
|
});
|
771
857
|
}
|
772
|
-
deleteUserAPIKey(
|
773
|
-
return operationsByTag.
|
774
|
-
pathParams: { keyName },
|
858
|
+
deleteUserAPIKey({ name }) {
|
859
|
+
return operationsByTag.authentication.deleteUserAPIKey({
|
860
|
+
pathParams: { keyName: name },
|
775
861
|
...this.extraProps
|
776
862
|
});
|
777
863
|
}
|
@@ -780,196 +866,248 @@ class WorkspaceApi {
|
|
780
866
|
constructor(extraProps) {
|
781
867
|
this.extraProps = extraProps;
|
782
868
|
}
|
783
|
-
|
869
|
+
getWorkspacesList() {
|
870
|
+
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
871
|
+
}
|
872
|
+
createWorkspace({ data }) {
|
784
873
|
return operationsByTag.workspaces.createWorkspace({
|
785
|
-
body:
|
874
|
+
body: data,
|
786
875
|
...this.extraProps
|
787
876
|
});
|
788
877
|
}
|
789
|
-
|
790
|
-
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
791
|
-
}
|
792
|
-
getWorkspace(workspaceId) {
|
878
|
+
getWorkspace({ workspace }) {
|
793
879
|
return operationsByTag.workspaces.getWorkspace({
|
794
|
-
pathParams: { workspaceId },
|
880
|
+
pathParams: { workspaceId: workspace },
|
795
881
|
...this.extraProps
|
796
882
|
});
|
797
883
|
}
|
798
|
-
updateWorkspace(
|
884
|
+
updateWorkspace({
|
885
|
+
workspace,
|
886
|
+
update
|
887
|
+
}) {
|
799
888
|
return operationsByTag.workspaces.updateWorkspace({
|
800
|
-
pathParams: { workspaceId },
|
801
|
-
body:
|
889
|
+
pathParams: { workspaceId: workspace },
|
890
|
+
body: update,
|
802
891
|
...this.extraProps
|
803
892
|
});
|
804
893
|
}
|
805
|
-
deleteWorkspace(
|
894
|
+
deleteWorkspace({ workspace }) {
|
806
895
|
return operationsByTag.workspaces.deleteWorkspace({
|
807
|
-
pathParams: { workspaceId },
|
896
|
+
pathParams: { workspaceId: workspace },
|
808
897
|
...this.extraProps
|
809
898
|
});
|
810
899
|
}
|
811
|
-
getWorkspaceMembersList(
|
900
|
+
getWorkspaceMembersList({ workspace }) {
|
812
901
|
return operationsByTag.workspaces.getWorkspaceMembersList({
|
813
|
-
pathParams: { workspaceId },
|
902
|
+
pathParams: { workspaceId: workspace },
|
814
903
|
...this.extraProps
|
815
904
|
});
|
816
905
|
}
|
817
|
-
updateWorkspaceMemberRole(
|
906
|
+
updateWorkspaceMemberRole({
|
907
|
+
workspace,
|
908
|
+
user,
|
909
|
+
role
|
910
|
+
}) {
|
818
911
|
return operationsByTag.workspaces.updateWorkspaceMemberRole({
|
819
|
-
pathParams: { workspaceId, userId },
|
912
|
+
pathParams: { workspaceId: workspace, userId: user },
|
820
913
|
body: { role },
|
821
914
|
...this.extraProps
|
822
915
|
});
|
823
916
|
}
|
824
|
-
removeWorkspaceMember(
|
917
|
+
removeWorkspaceMember({
|
918
|
+
workspace,
|
919
|
+
user
|
920
|
+
}) {
|
825
921
|
return operationsByTag.workspaces.removeWorkspaceMember({
|
826
|
-
pathParams: { workspaceId, userId },
|
922
|
+
pathParams: { workspaceId: workspace, userId: user },
|
827
923
|
...this.extraProps
|
828
924
|
});
|
829
925
|
}
|
830
|
-
|
831
|
-
|
832
|
-
|
926
|
+
}
|
927
|
+
class InvitesApi {
|
928
|
+
constructor(extraProps) {
|
929
|
+
this.extraProps = extraProps;
|
930
|
+
}
|
931
|
+
inviteWorkspaceMember({
|
932
|
+
workspace,
|
933
|
+
email,
|
934
|
+
role
|
935
|
+
}) {
|
936
|
+
return operationsByTag.invites.inviteWorkspaceMember({
|
937
|
+
pathParams: { workspaceId: workspace },
|
833
938
|
body: { email, role },
|
834
939
|
...this.extraProps
|
835
940
|
});
|
836
941
|
}
|
837
|
-
updateWorkspaceMemberInvite(
|
838
|
-
|
839
|
-
|
942
|
+
updateWorkspaceMemberInvite({
|
943
|
+
workspace,
|
944
|
+
invite,
|
945
|
+
role
|
946
|
+
}) {
|
947
|
+
return operationsByTag.invites.updateWorkspaceMemberInvite({
|
948
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
840
949
|
body: { role },
|
841
950
|
...this.extraProps
|
842
951
|
});
|
843
952
|
}
|
844
|
-
cancelWorkspaceMemberInvite(
|
845
|
-
|
846
|
-
|
953
|
+
cancelWorkspaceMemberInvite({
|
954
|
+
workspace,
|
955
|
+
invite
|
956
|
+
}) {
|
957
|
+
return operationsByTag.invites.cancelWorkspaceMemberInvite({
|
958
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
847
959
|
...this.extraProps
|
848
960
|
});
|
849
961
|
}
|
850
|
-
|
851
|
-
|
852
|
-
|
962
|
+
acceptWorkspaceMemberInvite({
|
963
|
+
workspace,
|
964
|
+
key
|
965
|
+
}) {
|
966
|
+
return operationsByTag.invites.acceptWorkspaceMemberInvite({
|
967
|
+
pathParams: { workspaceId: workspace, inviteKey: key },
|
853
968
|
...this.extraProps
|
854
969
|
});
|
855
970
|
}
|
856
|
-
|
857
|
-
|
858
|
-
|
971
|
+
resendWorkspaceMemberInvite({
|
972
|
+
workspace,
|
973
|
+
invite
|
974
|
+
}) {
|
975
|
+
return operationsByTag.invites.resendWorkspaceMemberInvite({
|
976
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
859
977
|
...this.extraProps
|
860
978
|
});
|
861
979
|
}
|
862
980
|
}
|
863
|
-
class
|
981
|
+
class BranchApi {
|
864
982
|
constructor(extraProps) {
|
865
983
|
this.extraProps = extraProps;
|
866
984
|
}
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
return operationsByTag.database.createDatabase({
|
875
|
-
pathParams: { workspace, dbName },
|
876
|
-
body: options,
|
877
|
-
...this.extraProps
|
878
|
-
});
|
879
|
-
}
|
880
|
-
deleteDatabase(workspace, dbName) {
|
881
|
-
return operationsByTag.database.deleteDatabase({
|
882
|
-
pathParams: { workspace, dbName },
|
883
|
-
...this.extraProps
|
884
|
-
});
|
885
|
-
}
|
886
|
-
getDatabaseMetadata(workspace, dbName) {
|
887
|
-
return operationsByTag.database.getDatabaseMetadata({
|
888
|
-
pathParams: { workspace, dbName },
|
889
|
-
...this.extraProps
|
890
|
-
});
|
891
|
-
}
|
892
|
-
updateDatabaseMetadata(workspace, dbName, options = {}) {
|
893
|
-
return operationsByTag.database.updateDatabaseMetadata({
|
894
|
-
pathParams: { workspace, dbName },
|
895
|
-
body: options,
|
896
|
-
...this.extraProps
|
897
|
-
});
|
898
|
-
}
|
899
|
-
getGitBranchesMapping(workspace, dbName) {
|
900
|
-
return operationsByTag.database.getGitBranchesMapping({
|
901
|
-
pathParams: { workspace, dbName },
|
985
|
+
getBranchList({
|
986
|
+
workspace,
|
987
|
+
region,
|
988
|
+
database
|
989
|
+
}) {
|
990
|
+
return operationsByTag.branch.getBranchList({
|
991
|
+
pathParams: { workspace, region, dbName: database },
|
902
992
|
...this.extraProps
|
903
993
|
});
|
904
994
|
}
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
995
|
+
getBranchDetails({
|
996
|
+
workspace,
|
997
|
+
region,
|
998
|
+
database,
|
999
|
+
branch
|
1000
|
+
}) {
|
1001
|
+
return operationsByTag.branch.getBranchDetails({
|
1002
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
909
1003
|
...this.extraProps
|
910
1004
|
});
|
911
1005
|
}
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
1006
|
+
createBranch({
|
1007
|
+
workspace,
|
1008
|
+
region,
|
1009
|
+
database,
|
1010
|
+
branch,
|
1011
|
+
from,
|
1012
|
+
metadata
|
1013
|
+
}) {
|
1014
|
+
return operationsByTag.branch.createBranch({
|
1015
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1016
|
+
body: { from, metadata },
|
916
1017
|
...this.extraProps
|
917
1018
|
});
|
918
1019
|
}
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
1020
|
+
deleteBranch({
|
1021
|
+
workspace,
|
1022
|
+
region,
|
1023
|
+
database,
|
1024
|
+
branch
|
1025
|
+
}) {
|
1026
|
+
return operationsByTag.branch.deleteBranch({
|
1027
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
923
1028
|
...this.extraProps
|
924
1029
|
});
|
925
1030
|
}
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
1031
|
+
updateBranchMetadata({
|
1032
|
+
workspace,
|
1033
|
+
region,
|
1034
|
+
database,
|
1035
|
+
branch,
|
1036
|
+
metadata
|
1037
|
+
}) {
|
1038
|
+
return operationsByTag.branch.updateBranchMetadata({
|
1039
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1040
|
+
body: metadata,
|
934
1041
|
...this.extraProps
|
935
1042
|
});
|
936
1043
|
}
|
937
|
-
|
938
|
-
|
939
|
-
|
1044
|
+
getBranchMetadata({
|
1045
|
+
workspace,
|
1046
|
+
region,
|
1047
|
+
database,
|
1048
|
+
branch
|
1049
|
+
}) {
|
1050
|
+
return operationsByTag.branch.getBranchMetadata({
|
1051
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
940
1052
|
...this.extraProps
|
941
1053
|
});
|
942
1054
|
}
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
1055
|
+
getBranchStats({
|
1056
|
+
workspace,
|
1057
|
+
region,
|
1058
|
+
database,
|
1059
|
+
branch
|
1060
|
+
}) {
|
1061
|
+
return operationsByTag.branch.getBranchStats({
|
1062
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
948
1063
|
...this.extraProps
|
949
1064
|
});
|
950
1065
|
}
|
951
|
-
|
952
|
-
|
953
|
-
|
1066
|
+
getGitBranchesMapping({
|
1067
|
+
workspace,
|
1068
|
+
region,
|
1069
|
+
database
|
1070
|
+
}) {
|
1071
|
+
return operationsByTag.branch.getGitBranchesMapping({
|
1072
|
+
pathParams: { workspace, region, dbName: database },
|
954
1073
|
...this.extraProps
|
955
1074
|
});
|
956
1075
|
}
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
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 },
|
961
1086
|
...this.extraProps
|
962
1087
|
});
|
963
1088
|
}
|
964
|
-
|
965
|
-
|
966
|
-
|
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 },
|
967
1098
|
...this.extraProps
|
968
1099
|
});
|
969
1100
|
}
|
970
|
-
|
971
|
-
|
972
|
-
|
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 },
|
973
1111
|
...this.extraProps
|
974
1112
|
});
|
975
1113
|
}
|
@@ -978,67 +1116,134 @@ class TableApi {
|
|
978
1116
|
constructor(extraProps) {
|
979
1117
|
this.extraProps = extraProps;
|
980
1118
|
}
|
981
|
-
createTable(
|
1119
|
+
createTable({
|
1120
|
+
workspace,
|
1121
|
+
region,
|
1122
|
+
database,
|
1123
|
+
branch,
|
1124
|
+
table
|
1125
|
+
}) {
|
982
1126
|
return operationsByTag.table.createTable({
|
983
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1127
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
984
1128
|
...this.extraProps
|
985
1129
|
});
|
986
1130
|
}
|
987
|
-
deleteTable(
|
1131
|
+
deleteTable({
|
1132
|
+
workspace,
|
1133
|
+
region,
|
1134
|
+
database,
|
1135
|
+
branch,
|
1136
|
+
table
|
1137
|
+
}) {
|
988
1138
|
return operationsByTag.table.deleteTable({
|
989
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1139
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
990
1140
|
...this.extraProps
|
991
1141
|
});
|
992
1142
|
}
|
993
|
-
updateTable(
|
1143
|
+
updateTable({
|
1144
|
+
workspace,
|
1145
|
+
region,
|
1146
|
+
database,
|
1147
|
+
branch,
|
1148
|
+
table,
|
1149
|
+
update
|
1150
|
+
}) {
|
994
1151
|
return operationsByTag.table.updateTable({
|
995
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
996
|
-
body:
|
1152
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1153
|
+
body: update,
|
997
1154
|
...this.extraProps
|
998
1155
|
});
|
999
1156
|
}
|
1000
|
-
getTableSchema(
|
1157
|
+
getTableSchema({
|
1158
|
+
workspace,
|
1159
|
+
region,
|
1160
|
+
database,
|
1161
|
+
branch,
|
1162
|
+
table
|
1163
|
+
}) {
|
1001
1164
|
return operationsByTag.table.getTableSchema({
|
1002
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1165
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1003
1166
|
...this.extraProps
|
1004
1167
|
});
|
1005
1168
|
}
|
1006
|
-
setTableSchema(
|
1169
|
+
setTableSchema({
|
1170
|
+
workspace,
|
1171
|
+
region,
|
1172
|
+
database,
|
1173
|
+
branch,
|
1174
|
+
table,
|
1175
|
+
schema
|
1176
|
+
}) {
|
1007
1177
|
return operationsByTag.table.setTableSchema({
|
1008
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1009
|
-
body:
|
1178
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1179
|
+
body: schema,
|
1010
1180
|
...this.extraProps
|
1011
1181
|
});
|
1012
1182
|
}
|
1013
|
-
getTableColumns(
|
1183
|
+
getTableColumns({
|
1184
|
+
workspace,
|
1185
|
+
region,
|
1186
|
+
database,
|
1187
|
+
branch,
|
1188
|
+
table
|
1189
|
+
}) {
|
1014
1190
|
return operationsByTag.table.getTableColumns({
|
1015
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1191
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1016
1192
|
...this.extraProps
|
1017
1193
|
});
|
1018
1194
|
}
|
1019
|
-
addTableColumn(
|
1195
|
+
addTableColumn({
|
1196
|
+
workspace,
|
1197
|
+
region,
|
1198
|
+
database,
|
1199
|
+
branch,
|
1200
|
+
table,
|
1201
|
+
column
|
1202
|
+
}) {
|
1020
1203
|
return operationsByTag.table.addTableColumn({
|
1021
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1204
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1022
1205
|
body: column,
|
1023
1206
|
...this.extraProps
|
1024
1207
|
});
|
1025
1208
|
}
|
1026
|
-
getColumn(
|
1209
|
+
getColumn({
|
1210
|
+
workspace,
|
1211
|
+
region,
|
1212
|
+
database,
|
1213
|
+
branch,
|
1214
|
+
table,
|
1215
|
+
column
|
1216
|
+
}) {
|
1027
1217
|
return operationsByTag.table.getColumn({
|
1028
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
|
1218
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1029
1219
|
...this.extraProps
|
1030
1220
|
});
|
1031
1221
|
}
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
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,
|
1035
1234
|
...this.extraProps
|
1036
1235
|
});
|
1037
1236
|
}
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
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 },
|
1042
1247
|
...this.extraProps
|
1043
1248
|
});
|
1044
1249
|
}
|
@@ -1047,85 +1252,213 @@ class RecordsApi {
|
|
1047
1252
|
constructor(extraProps) {
|
1048
1253
|
this.extraProps = extraProps;
|
1049
1254
|
}
|
1050
|
-
insertRecord(
|
1255
|
+
insertRecord({
|
1256
|
+
workspace,
|
1257
|
+
region,
|
1258
|
+
database,
|
1259
|
+
branch,
|
1260
|
+
table,
|
1261
|
+
record,
|
1262
|
+
columns
|
1263
|
+
}) {
|
1051
1264
|
return operationsByTag.records.insertRecord({
|
1052
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1053
|
-
queryParams:
|
1265
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1266
|
+
queryParams: { columns },
|
1054
1267
|
body: record,
|
1055
1268
|
...this.extraProps
|
1056
1269
|
});
|
1057
1270
|
}
|
1058
|
-
|
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
|
+
}) {
|
1059
1298
|
return operationsByTag.records.insertRecordWithID({
|
1060
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1061
|
-
queryParams:
|
1299
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1300
|
+
queryParams: { columns, createOnly, ifVersion },
|
1062
1301
|
body: record,
|
1063
1302
|
...this.extraProps
|
1064
1303
|
});
|
1065
1304
|
}
|
1066
|
-
updateRecordWithID(
|
1305
|
+
updateRecordWithID({
|
1306
|
+
workspace,
|
1307
|
+
region,
|
1308
|
+
database,
|
1309
|
+
branch,
|
1310
|
+
table,
|
1311
|
+
id,
|
1312
|
+
record,
|
1313
|
+
columns,
|
1314
|
+
ifVersion
|
1315
|
+
}) {
|
1067
1316
|
return operationsByTag.records.updateRecordWithID({
|
1068
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1069
|
-
queryParams:
|
1317
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1318
|
+
queryParams: { columns, ifVersion },
|
1070
1319
|
body: record,
|
1071
1320
|
...this.extraProps
|
1072
1321
|
});
|
1073
1322
|
}
|
1074
|
-
upsertRecordWithID(
|
1323
|
+
upsertRecordWithID({
|
1324
|
+
workspace,
|
1325
|
+
region,
|
1326
|
+
database,
|
1327
|
+
branch,
|
1328
|
+
table,
|
1329
|
+
id,
|
1330
|
+
record,
|
1331
|
+
columns,
|
1332
|
+
ifVersion
|
1333
|
+
}) {
|
1075
1334
|
return operationsByTag.records.upsertRecordWithID({
|
1076
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1077
|
-
queryParams:
|
1335
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1336
|
+
queryParams: { columns, ifVersion },
|
1078
1337
|
body: record,
|
1079
1338
|
...this.extraProps
|
1080
1339
|
});
|
1081
1340
|
}
|
1082
|
-
deleteRecord(
|
1341
|
+
deleteRecord({
|
1342
|
+
workspace,
|
1343
|
+
region,
|
1344
|
+
database,
|
1345
|
+
branch,
|
1346
|
+
table,
|
1347
|
+
id,
|
1348
|
+
columns
|
1349
|
+
}) {
|
1083
1350
|
return operationsByTag.records.deleteRecord({
|
1084
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1085
|
-
queryParams:
|
1086
|
-
...this.extraProps
|
1087
|
-
});
|
1088
|
-
}
|
1089
|
-
getRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
1090
|
-
return operationsByTag.records.getRecord({
|
1091
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1092
|
-
queryParams: options,
|
1351
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1352
|
+
queryParams: { columns },
|
1093
1353
|
...this.extraProps
|
1094
1354
|
});
|
1095
1355
|
}
|
1096
|
-
bulkInsertTableRecords(
|
1356
|
+
bulkInsertTableRecords({
|
1357
|
+
workspace,
|
1358
|
+
region,
|
1359
|
+
database,
|
1360
|
+
branch,
|
1361
|
+
table,
|
1362
|
+
records,
|
1363
|
+
columns
|
1364
|
+
}) {
|
1097
1365
|
return operationsByTag.records.bulkInsertTableRecords({
|
1098
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1099
|
-
queryParams:
|
1366
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1367
|
+
queryParams: { columns },
|
1100
1368
|
body: { records },
|
1101
1369
|
...this.extraProps
|
1102
1370
|
});
|
1103
1371
|
}
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
...this.extraProps
|
1109
|
-
});
|
1110
|
-
}
|
1111
|
-
searchTable(workspace, database, branch, tableName, query) {
|
1112
|
-
return operationsByTag.records.searchTable({
|
1113
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1114
|
-
body: query,
|
1115
|
-
...this.extraProps
|
1116
|
-
});
|
1117
|
-
}
|
1118
|
-
searchBranch(workspace, database, branch, query) {
|
1119
|
-
return operationsByTag.records.searchBranch({
|
1120
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1121
|
-
body: query,
|
1122
|
-
...this.extraProps
|
1123
|
-
});
|
1372
|
+
}
|
1373
|
+
class SearchAndFilterApi {
|
1374
|
+
constructor(extraProps) {
|
1375
|
+
this.extraProps = extraProps;
|
1124
1376
|
}
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
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 },
|
1129
1462
|
...this.extraProps
|
1130
1463
|
});
|
1131
1464
|
}
|
@@ -1134,123 +1467,281 @@ class MigrationRequestsApi {
|
|
1134
1467
|
constructor(extraProps) {
|
1135
1468
|
this.extraProps = extraProps;
|
1136
1469
|
}
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
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
|
+
}) {
|
1145
1491
|
return operationsByTag.migrationRequests.createMigrationRequest({
|
1146
|
-
pathParams: { workspace, dbName: database },
|
1147
|
-
body:
|
1492
|
+
pathParams: { workspace, region, dbName: database },
|
1493
|
+
body: migration,
|
1148
1494
|
...this.extraProps
|
1149
1495
|
});
|
1150
1496
|
}
|
1151
|
-
getMigrationRequest(
|
1497
|
+
getMigrationRequest({
|
1498
|
+
workspace,
|
1499
|
+
region,
|
1500
|
+
database,
|
1501
|
+
migrationRequest
|
1502
|
+
}) {
|
1152
1503
|
return operationsByTag.migrationRequests.getMigrationRequest({
|
1153
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1504
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1154
1505
|
...this.extraProps
|
1155
1506
|
});
|
1156
1507
|
}
|
1157
|
-
updateMigrationRequest(
|
1508
|
+
updateMigrationRequest({
|
1509
|
+
workspace,
|
1510
|
+
region,
|
1511
|
+
database,
|
1512
|
+
migrationRequest,
|
1513
|
+
update
|
1514
|
+
}) {
|
1158
1515
|
return operationsByTag.migrationRequests.updateMigrationRequest({
|
1159
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1160
|
-
body:
|
1516
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1517
|
+
body: update,
|
1161
1518
|
...this.extraProps
|
1162
1519
|
});
|
1163
1520
|
}
|
1164
|
-
listMigrationRequestsCommits(
|
1521
|
+
listMigrationRequestsCommits({
|
1522
|
+
workspace,
|
1523
|
+
region,
|
1524
|
+
database,
|
1525
|
+
migrationRequest,
|
1526
|
+
page
|
1527
|
+
}) {
|
1165
1528
|
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
1166
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1167
|
-
body:
|
1529
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1530
|
+
body: { page },
|
1168
1531
|
...this.extraProps
|
1169
1532
|
});
|
1170
1533
|
}
|
1171
|
-
compareMigrationRequest(
|
1534
|
+
compareMigrationRequest({
|
1535
|
+
workspace,
|
1536
|
+
region,
|
1537
|
+
database,
|
1538
|
+
migrationRequest
|
1539
|
+
}) {
|
1172
1540
|
return operationsByTag.migrationRequests.compareMigrationRequest({
|
1173
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1541
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1174
1542
|
...this.extraProps
|
1175
1543
|
});
|
1176
1544
|
}
|
1177
|
-
getMigrationRequestIsMerged(
|
1545
|
+
getMigrationRequestIsMerged({
|
1546
|
+
workspace,
|
1547
|
+
region,
|
1548
|
+
database,
|
1549
|
+
migrationRequest
|
1550
|
+
}) {
|
1178
1551
|
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
1179
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1552
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1180
1553
|
...this.extraProps
|
1181
1554
|
});
|
1182
1555
|
}
|
1183
|
-
mergeMigrationRequest(
|
1556
|
+
mergeMigrationRequest({
|
1557
|
+
workspace,
|
1558
|
+
region,
|
1559
|
+
database,
|
1560
|
+
migrationRequest
|
1561
|
+
}) {
|
1184
1562
|
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
1185
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1563
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1186
1564
|
...this.extraProps
|
1187
1565
|
});
|
1188
1566
|
}
|
1189
1567
|
}
|
1190
|
-
class
|
1568
|
+
class MigrationsApi {
|
1191
1569
|
constructor(extraProps) {
|
1192
1570
|
this.extraProps = extraProps;
|
1193
1571
|
}
|
1194
|
-
getBranchMigrationHistory(
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
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,
|
1198
1596
|
...this.extraProps
|
1199
1597
|
});
|
1200
1598
|
}
|
1201
|
-
executeBranchMigrationPlan(
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
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,
|
1205
1609
|
...this.extraProps
|
1206
1610
|
});
|
1207
1611
|
}
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
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 },
|
1212
1622
|
...this.extraProps
|
1213
1623
|
});
|
1214
1624
|
}
|
1215
|
-
compareBranchWithUserSchema(
|
1216
|
-
|
1217
|
-
|
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}` },
|
1218
1634
|
body: { schema },
|
1219
1635
|
...this.extraProps
|
1220
1636
|
});
|
1221
1637
|
}
|
1222
|
-
compareBranchSchemas(
|
1223
|
-
|
1224
|
-
|
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 },
|
1225
1648
|
body: { schema },
|
1226
1649
|
...this.extraProps
|
1227
1650
|
});
|
1228
1651
|
}
|
1229
|
-
updateBranchSchema(
|
1230
|
-
|
1231
|
-
|
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}` },
|
1232
1661
|
body: migration,
|
1233
1662
|
...this.extraProps
|
1234
1663
|
});
|
1235
1664
|
}
|
1236
|
-
previewBranchSchemaEdit(
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
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,
|
1240
1675
|
...this.extraProps
|
1241
1676
|
});
|
1242
1677
|
}
|
1243
|
-
applyBranchSchemaEdit(
|
1244
|
-
|
1245
|
-
|
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}` },
|
1246
1687
|
body: { edits },
|
1247
1688
|
...this.extraProps
|
1248
1689
|
});
|
1249
1690
|
}
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
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 },
|
1254
1745
|
...this.extraProps
|
1255
1746
|
});
|
1256
1747
|
}
|
@@ -1266,6 +1757,20 @@ class XataApiPlugin {
|
|
1266
1757
|
class XataPlugin {
|
1267
1758
|
}
|
1268
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
|
+
|
1269
1774
|
var __accessCheck$6 = (obj, member, msg) => {
|
1270
1775
|
if (!member.has(obj))
|
1271
1776
|
throw TypeError("Cannot " + msg);
|
@@ -1379,9 +1884,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
|
|
1379
1884
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1380
1885
|
return value;
|
1381
1886
|
};
|
1382
|
-
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;
|
1383
1892
|
const _Query = class {
|
1384
1893
|
constructor(repository, table, data, rawParent) {
|
1894
|
+
__privateAdd$5(this, _cleanFilterConstraint);
|
1385
1895
|
__privateAdd$5(this, _table$1, void 0);
|
1386
1896
|
__privateAdd$5(this, _repository, void 0);
|
1387
1897
|
__privateAdd$5(this, _data, { filter: {} });
|
@@ -1400,7 +1910,7 @@ const _Query = class {
|
|
1400
1910
|
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
1401
1911
|
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
1402
1912
|
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
1403
|
-
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns
|
1913
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
|
1404
1914
|
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
1405
1915
|
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
1406
1916
|
this.any = this.any.bind(this);
|
@@ -1438,22 +1948,17 @@ const _Query = class {
|
|
1438
1948
|
}
|
1439
1949
|
filter(a, b) {
|
1440
1950
|
if (arguments.length === 1) {
|
1441
|
-
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
|
+
}));
|
1442
1954
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1443
1955
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1444
1956
|
} else {
|
1445
|
-
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.
|
1957
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
|
1446
1958
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1447
1959
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1448
1960
|
}
|
1449
1961
|
}
|
1450
|
-
defaultFilter(column, value) {
|
1451
|
-
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
1452
|
-
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
1453
|
-
return { $includes: value };
|
1454
|
-
}
|
1455
|
-
return value;
|
1456
|
-
}
|
1457
1962
|
sort(column, direction = "asc") {
|
1458
1963
|
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
1459
1964
|
const sort = [...originalSort, { column, direction }];
|
@@ -1521,6 +2026,16 @@ const _Query = class {
|
|
1521
2026
|
throw new Error("No results found.");
|
1522
2027
|
return records[0];
|
1523
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
|
+
}
|
1524
2039
|
cache(ttl) {
|
1525
2040
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1526
2041
|
}
|
@@ -1544,9 +2059,20 @@ let Query = _Query;
|
|
1544
2059
|
_table$1 = new WeakMap();
|
1545
2060
|
_repository = new WeakMap();
|
1546
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
|
+
};
|
1547
2073
|
function cleanParent(data, parent) {
|
1548
2074
|
if (isCursorPaginationOptions(data.pagination)) {
|
1549
|
-
return { ...parent,
|
2075
|
+
return { ...parent, sort: void 0, filter: void 0 };
|
1550
2076
|
}
|
1551
2077
|
return parent;
|
1552
2078
|
}
|
@@ -1631,10 +2157,13 @@ class RestRepository extends Query {
|
|
1631
2157
|
__privateAdd$4(this, _schemaTables$2, void 0);
|
1632
2158
|
__privateAdd$4(this, _trace, void 0);
|
1633
2159
|
__privateSet$4(this, _table, options.table);
|
1634
|
-
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1635
2160
|
__privateSet$4(this, _db, options.db);
|
1636
2161
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
1637
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
|
+
});
|
1638
2167
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
1639
2168
|
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
1640
2169
|
return trace(name, fn, {
|
@@ -1645,8 +2174,9 @@ class RestRepository extends Query {
|
|
1645
2174
|
});
|
1646
2175
|
});
|
1647
2176
|
}
|
1648
|
-
async create(a, b, c) {
|
2177
|
+
async create(a, b, c, d) {
|
1649
2178
|
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
2179
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1650
2180
|
if (Array.isArray(a)) {
|
1651
2181
|
if (a.length === 0)
|
1652
2182
|
return [];
|
@@ -1657,13 +2187,13 @@ class RestRepository extends Query {
|
|
1657
2187
|
if (a === "")
|
1658
2188
|
throw new Error("The id can't be empty");
|
1659
2189
|
const columns = isStringArray(c) ? c : void 0;
|
1660
|
-
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 });
|
1661
2191
|
}
|
1662
2192
|
if (isObject(a) && isString(a.id)) {
|
1663
2193
|
if (a.id === "")
|
1664
2194
|
throw new Error("The id can't be empty");
|
1665
2195
|
const columns = isStringArray(b) ? b : void 0;
|
1666
|
-
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 });
|
1667
2197
|
}
|
1668
2198
|
if (isObject(a)) {
|
1669
2199
|
const columns = isStringArray(b) ? b : void 0;
|
@@ -1694,6 +2224,7 @@ class RestRepository extends Query {
|
|
1694
2224
|
pathParams: {
|
1695
2225
|
workspace: "{workspaceId}",
|
1696
2226
|
dbBranchName: "{dbBranch}",
|
2227
|
+
region: "{region}",
|
1697
2228
|
tableName: __privateGet$4(this, _table),
|
1698
2229
|
recordId: id
|
1699
2230
|
},
|
@@ -1701,7 +2232,7 @@ class RestRepository extends Query {
|
|
1701
2232
|
...fetchProps
|
1702
2233
|
});
|
1703
2234
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1704
|
-
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);
|
1705
2236
|
} catch (e) {
|
1706
2237
|
if (isObject(e) && e.status === 404) {
|
1707
2238
|
return null;
|
@@ -1731,8 +2262,9 @@ class RestRepository extends Query {
|
|
1731
2262
|
return result;
|
1732
2263
|
});
|
1733
2264
|
}
|
1734
|
-
async update(a, b, c) {
|
2265
|
+
async update(a, b, c, d) {
|
1735
2266
|
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
2267
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1736
2268
|
if (Array.isArray(a)) {
|
1737
2269
|
if (a.length === 0)
|
1738
2270
|
return [];
|
@@ -1744,18 +2276,18 @@ class RestRepository extends Query {
|
|
1744
2276
|
}
|
1745
2277
|
if (isString(a) && isObject(b)) {
|
1746
2278
|
const columns = isStringArray(c) ? c : void 0;
|
1747
|
-
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 });
|
1748
2280
|
}
|
1749
2281
|
if (isObject(a) && isString(a.id)) {
|
1750
2282
|
const columns = isStringArray(b) ? b : void 0;
|
1751
|
-
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 });
|
1752
2284
|
}
|
1753
2285
|
throw new Error("Invalid arguments for update method");
|
1754
2286
|
});
|
1755
2287
|
}
|
1756
|
-
async updateOrThrow(a, b, c) {
|
2288
|
+
async updateOrThrow(a, b, c, d) {
|
1757
2289
|
return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
|
1758
|
-
const result = await this.update(a, b, c);
|
2290
|
+
const result = await this.update(a, b, c, d);
|
1759
2291
|
if (Array.isArray(result)) {
|
1760
2292
|
const missingIds = compact(
|
1761
2293
|
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
@@ -1772,8 +2304,9 @@ class RestRepository extends Query {
|
|
1772
2304
|
return result;
|
1773
2305
|
});
|
1774
2306
|
}
|
1775
|
-
async createOrUpdate(a, b, c) {
|
2307
|
+
async createOrUpdate(a, b, c, d) {
|
1776
2308
|
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
2309
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1777
2310
|
if (Array.isArray(a)) {
|
1778
2311
|
if (a.length === 0)
|
1779
2312
|
return [];
|
@@ -1785,15 +2318,35 @@ class RestRepository extends Query {
|
|
1785
2318
|
}
|
1786
2319
|
if (isString(a) && isObject(b)) {
|
1787
2320
|
const columns = isStringArray(c) ? c : void 0;
|
1788
|
-
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 });
|
1789
2322
|
}
|
1790
2323
|
if (isObject(a) && isString(a.id)) {
|
1791
2324
|
const columns = isStringArray(c) ? c : void 0;
|
1792
|
-
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 });
|
1793
2326
|
}
|
1794
2327
|
throw new Error("Invalid arguments for createOrUpdate method");
|
1795
2328
|
});
|
1796
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
|
+
}
|
1797
2350
|
async delete(a, b) {
|
1798
2351
|
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
1799
2352
|
if (Array.isArray(a)) {
|
@@ -1835,7 +2388,12 @@ class RestRepository extends Query {
|
|
1835
2388
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
1836
2389
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1837
2390
|
const { records } = await searchTable({
|
1838
|
-
pathParams: {
|
2391
|
+
pathParams: {
|
2392
|
+
workspace: "{workspaceId}",
|
2393
|
+
dbBranchName: "{dbBranch}",
|
2394
|
+
region: "{region}",
|
2395
|
+
tableName: __privateGet$4(this, _table)
|
2396
|
+
},
|
1839
2397
|
body: {
|
1840
2398
|
query,
|
1841
2399
|
fuzziness: options.fuzziness,
|
@@ -1847,7 +2405,23 @@ class RestRepository extends Query {
|
|
1847
2405
|
...fetchProps
|
1848
2406
|
});
|
1849
2407
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1850
|
-
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;
|
1851
2425
|
});
|
1852
2426
|
}
|
1853
2427
|
async query(query) {
|
@@ -1856,24 +2430,54 @@ class RestRepository extends Query {
|
|
1856
2430
|
if (cacheQuery)
|
1857
2431
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
1858
2432
|
const data = query.getQueryOptions();
|
1859
|
-
const body = {
|
1860
|
-
filter: cleanFilter(data.filter),
|
1861
|
-
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1862
|
-
page: data.pagination,
|
1863
|
-
columns: data.columns
|
1864
|
-
};
|
1865
2433
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1866
2434
|
const { meta, records: objects } = await queryTable({
|
1867
|
-
pathParams: {
|
1868
|
-
|
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
|
+
},
|
1869
2447
|
...fetchProps
|
1870
2448
|
});
|
1871
2449
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1872
|
-
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
|
+
);
|
1873
2453
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1874
2454
|
return new Page(query, meta, records);
|
1875
2455
|
});
|
1876
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
|
+
}
|
1877
2481
|
}
|
1878
2482
|
_table = new WeakMap();
|
1879
2483
|
_getFetchProps = new WeakMap();
|
@@ -1889,6 +2493,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1889
2493
|
pathParams: {
|
1890
2494
|
workspace: "{workspaceId}",
|
1891
2495
|
dbBranchName: "{dbBranch}",
|
2496
|
+
region: "{region}",
|
1892
2497
|
tableName: __privateGet$4(this, _table)
|
1893
2498
|
},
|
1894
2499
|
queryParams: { columns },
|
@@ -1896,32 +2501,38 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1896
2501
|
...fetchProps
|
1897
2502
|
});
|
1898
2503
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1899
|
-
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);
|
1900
2505
|
};
|
1901
2506
|
_insertRecordWithId = new WeakSet();
|
1902
|
-
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
2507
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
1903
2508
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1904
2509
|
const record = transformObjectLinks(object);
|
1905
2510
|
const response = await insertRecordWithID({
|
1906
2511
|
pathParams: {
|
1907
2512
|
workspace: "{workspaceId}",
|
1908
2513
|
dbBranchName: "{dbBranch}",
|
2514
|
+
region: "{region}",
|
1909
2515
|
tableName: __privateGet$4(this, _table),
|
1910
2516
|
recordId
|
1911
2517
|
},
|
1912
2518
|
body: record,
|
1913
|
-
queryParams: { createOnly
|
2519
|
+
queryParams: { createOnly, columns, ifVersion },
|
1914
2520
|
...fetchProps
|
1915
2521
|
});
|
1916
2522
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1917
|
-
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);
|
1918
2524
|
};
|
1919
2525
|
_bulkInsertTableRecords = new WeakSet();
|
1920
2526
|
bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
1921
2527
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1922
2528
|
const records = objects.map((object) => transformObjectLinks(object));
|
1923
2529
|
const response = await bulkInsertTableRecords({
|
1924
|
-
pathParams: {
|
2530
|
+
pathParams: {
|
2531
|
+
workspace: "{workspaceId}",
|
2532
|
+
dbBranchName: "{dbBranch}",
|
2533
|
+
region: "{region}",
|
2534
|
+
tableName: __privateGet$4(this, _table)
|
2535
|
+
},
|
1925
2536
|
queryParams: { columns },
|
1926
2537
|
body: { records },
|
1927
2538
|
...fetchProps
|
@@ -1930,21 +2541,27 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
|
1930
2541
|
throw new Error("Request included columns but server didn't include them");
|
1931
2542
|
}
|
1932
2543
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1933
|
-
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));
|
1934
2545
|
};
|
1935
2546
|
_updateRecordWithID = new WeakSet();
|
1936
|
-
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2547
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
1937
2548
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1938
2549
|
const record = transformObjectLinks(object);
|
1939
2550
|
try {
|
1940
2551
|
const response = await updateRecordWithID({
|
1941
|
-
pathParams: {
|
1942
|
-
|
2552
|
+
pathParams: {
|
2553
|
+
workspace: "{workspaceId}",
|
2554
|
+
dbBranchName: "{dbBranch}",
|
2555
|
+
region: "{region}",
|
2556
|
+
tableName: __privateGet$4(this, _table),
|
2557
|
+
recordId
|
2558
|
+
},
|
2559
|
+
queryParams: { columns, ifVersion },
|
1943
2560
|
body: record,
|
1944
2561
|
...fetchProps
|
1945
2562
|
});
|
1946
2563
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1947
|
-
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);
|
1948
2565
|
} catch (e) {
|
1949
2566
|
if (isObject(e) && e.status === 404) {
|
1950
2567
|
return null;
|
@@ -1953,28 +2570,40 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
1953
2570
|
}
|
1954
2571
|
};
|
1955
2572
|
_upsertRecordWithID = new WeakSet();
|
1956
|
-
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2573
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
1957
2574
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1958
2575
|
const response = await upsertRecordWithID({
|
1959
|
-
pathParams: {
|
1960
|
-
|
2576
|
+
pathParams: {
|
2577
|
+
workspace: "{workspaceId}",
|
2578
|
+
dbBranchName: "{dbBranch}",
|
2579
|
+
region: "{region}",
|
2580
|
+
tableName: __privateGet$4(this, _table),
|
2581
|
+
recordId
|
2582
|
+
},
|
2583
|
+
queryParams: { columns, ifVersion },
|
1961
2584
|
body: object,
|
1962
2585
|
...fetchProps
|
1963
2586
|
});
|
1964
2587
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1965
|
-
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);
|
1966
2589
|
};
|
1967
2590
|
_deleteRecord = new WeakSet();
|
1968
2591
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
1969
2592
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1970
2593
|
try {
|
1971
2594
|
const response = await deleteRecord({
|
1972
|
-
pathParams: {
|
2595
|
+
pathParams: {
|
2596
|
+
workspace: "{workspaceId}",
|
2597
|
+
dbBranchName: "{dbBranch}",
|
2598
|
+
region: "{region}",
|
2599
|
+
tableName: __privateGet$4(this, _table),
|
2600
|
+
recordId
|
2601
|
+
},
|
1973
2602
|
queryParams: { columns },
|
1974
2603
|
...fetchProps
|
1975
2604
|
});
|
1976
2605
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1977
|
-
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);
|
1978
2607
|
} catch (e) {
|
1979
2608
|
if (isObject(e) && e.status === 404) {
|
1980
2609
|
return null;
|
@@ -2004,7 +2633,7 @@ getSchemaTables_fn$1 = async function() {
|
|
2004
2633
|
return __privateGet$4(this, _schemaTables$2);
|
2005
2634
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2006
2635
|
const { schema } = await getBranchDetails({
|
2007
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2636
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2008
2637
|
...fetchProps
|
2009
2638
|
});
|
2010
2639
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
@@ -2017,7 +2646,7 @@ const transformObjectLinks = (object) => {
|
|
2017
2646
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
2018
2647
|
}, {});
|
2019
2648
|
};
|
2020
|
-
const initObject = (db, schemaTables, table, object) => {
|
2649
|
+
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
2021
2650
|
const result = {};
|
2022
2651
|
const { xata, ...rest } = object ?? {};
|
2023
2652
|
Object.assign(result, rest);
|
@@ -2025,6 +2654,8 @@ const initObject = (db, schemaTables, table, object) => {
|
|
2025
2654
|
if (!columns)
|
2026
2655
|
console.error(`Table ${table} not found in schema`);
|
2027
2656
|
for (const column of columns ?? []) {
|
2657
|
+
if (!isValidColumn(selectedColumns, column))
|
2658
|
+
continue;
|
2028
2659
|
const value = result[column.name];
|
2029
2660
|
switch (column.type) {
|
2030
2661
|
case "datetime": {
|
@@ -2041,7 +2672,17 @@ const initObject = (db, schemaTables, table, object) => {
|
|
2041
2672
|
if (!linkTable) {
|
2042
2673
|
console.error(`Failed to parse link for field ${column.name}`);
|
2043
2674
|
} else if (isObject(value)) {
|
2044
|
-
|
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);
|
2045
2686
|
} else {
|
2046
2687
|
result[column.name] = null;
|
2047
2688
|
}
|
@@ -2058,8 +2699,15 @@ const initObject = (db, schemaTables, table, object) => {
|
|
2058
2699
|
result.read = function(columns2) {
|
2059
2700
|
return db[table].read(result["id"], columns2);
|
2060
2701
|
};
|
2061
|
-
result.update = function(data,
|
2062
|
-
|
2702
|
+
result.update = function(data, b, c) {
|
2703
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2704
|
+
const ifVersion = parseIfVersion(b, c);
|
2705
|
+
return db[table].update(result["id"], data, columns2, { ifVersion });
|
2706
|
+
};
|
2707
|
+
result.replace = function(data, b, c) {
|
2708
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2709
|
+
const ifVersion = parseIfVersion(b, c);
|
2710
|
+
return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
|
2063
2711
|
};
|
2064
2712
|
result.delete = function() {
|
2065
2713
|
return db[table].delete(result["id"]);
|
@@ -2083,11 +2731,22 @@ function extractId(value) {
|
|
2083
2731
|
return value.id;
|
2084
2732
|
return void 0;
|
2085
2733
|
}
|
2086
|
-
function
|
2087
|
-
if (
|
2088
|
-
return
|
2089
|
-
|
2090
|
-
|
2734
|
+
function isValidColumn(columns, column) {
|
2735
|
+
if (columns.includes("*"))
|
2736
|
+
return true;
|
2737
|
+
if (column.type === "link") {
|
2738
|
+
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
2739
|
+
return linkColumns.length > 0;
|
2740
|
+
}
|
2741
|
+
return columns.includes(column.name);
|
2742
|
+
}
|
2743
|
+
function parseIfVersion(...args) {
|
2744
|
+
for (const arg of args) {
|
2745
|
+
if (isObject(arg) && isNumber(arg.ifVersion)) {
|
2746
|
+
return arg.ifVersion;
|
2747
|
+
}
|
2748
|
+
}
|
2749
|
+
return void 0;
|
2091
2750
|
}
|
2092
2751
|
|
2093
2752
|
var __accessCheck$3 = (obj, member, msg) => {
|
@@ -2254,7 +2913,7 @@ class SearchPlugin extends XataPlugin {
|
|
2254
2913
|
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
2255
2914
|
return records.map((record) => {
|
2256
2915
|
const { table = "orphan" } = record.xata;
|
2257
|
-
return { table, record: initObject(this.db, schemaTables, table, record) };
|
2916
|
+
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
2258
2917
|
});
|
2259
2918
|
},
|
2260
2919
|
byTable: async (query, options = {}) => {
|
@@ -2263,7 +2922,7 @@ class SearchPlugin extends XataPlugin {
|
|
2263
2922
|
return records.reduce((acc, record) => {
|
2264
2923
|
const { table = "orphan" } = record.xata;
|
2265
2924
|
const items = acc[table] ?? [];
|
2266
|
-
const item = initObject(this.db, schemaTables, table, record);
|
2925
|
+
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
2267
2926
|
return { ...acc, [table]: [...items, item] };
|
2268
2927
|
}, {});
|
2269
2928
|
}
|
@@ -2276,7 +2935,7 @@ search_fn = async function(query, options, getFetchProps) {
|
|
2276
2935
|
const fetchProps = await getFetchProps();
|
2277
2936
|
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
2278
2937
|
const { records } = await searchBranch({
|
2279
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2938
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2280
2939
|
body: { tables, query, fuzziness, prefix, highlight },
|
2281
2940
|
...fetchProps
|
2282
2941
|
});
|
@@ -2288,7 +2947,7 @@ getSchemaTables_fn = async function(getFetchProps) {
|
|
2288
2947
|
return __privateGet$1(this, _schemaTables);
|
2289
2948
|
const fetchProps = await getFetchProps();
|
2290
2949
|
const { schema } = await getBranchDetails({
|
2291
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2950
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2292
2951
|
...fetchProps
|
2293
2952
|
});
|
2294
2953
|
__privateSet$1(this, _schemaTables, schema.tables);
|
@@ -2326,14 +2985,17 @@ async function resolveXataBranch(gitBranch, options) {
|
|
2326
2985
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2327
2986
|
);
|
2328
2987
|
const [protocol, , host, , dbName] = databaseURL.split("/");
|
2329
|
-
const
|
2988
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
2989
|
+
if (!urlParts)
|
2990
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
2991
|
+
const { workspace, region } = urlParts;
|
2330
2992
|
const { fallbackBranch } = getEnvironment();
|
2331
2993
|
const { branch } = await resolveBranch({
|
2332
2994
|
apiKey,
|
2333
2995
|
apiUrl: databaseURL,
|
2334
2996
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2335
2997
|
workspacesApiUrl: `${protocol}//${host}`,
|
2336
|
-
pathParams: { dbName, workspace },
|
2998
|
+
pathParams: { dbName, workspace, region },
|
2337
2999
|
queryParams: { gitBranch, fallbackBranch },
|
2338
3000
|
trace: defaultTrace
|
2339
3001
|
});
|
@@ -2351,15 +3013,17 @@ async function getDatabaseBranch(branch, options) {
|
|
2351
3013
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2352
3014
|
);
|
2353
3015
|
const [protocol, , host, , database] = databaseURL.split("/");
|
2354
|
-
const
|
2355
|
-
|
3016
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
3017
|
+
if (!urlParts)
|
3018
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3019
|
+
const { workspace, region } = urlParts;
|
2356
3020
|
try {
|
2357
3021
|
return await getBranchDetails({
|
2358
3022
|
apiKey,
|
2359
3023
|
apiUrl: databaseURL,
|
2360
3024
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2361
3025
|
workspacesApiUrl: `${protocol}//${host}`,
|
2362
|
-
pathParams: { dbBranchName
|
3026
|
+
pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
|
2363
3027
|
trace: defaultTrace
|
2364
3028
|
});
|
2365
3029
|
} catch (err) {
|
@@ -2450,8 +3114,8 @@ const buildClient = (plugins) => {
|
|
2450
3114
|
if (!databaseURL) {
|
2451
3115
|
throw new Error("Option databaseURL is required");
|
2452
3116
|
}
|
2453
|
-
return { fetch, databaseURL, apiKey, branch, cache, trace };
|
2454
|
-
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
|
3117
|
+
return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID() };
|
3118
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
|
2455
3119
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
2456
3120
|
if (!branchValue)
|
2457
3121
|
throw new Error("Unable to resolve branch value");
|
@@ -2464,7 +3128,8 @@ const buildClient = (plugins) => {
|
|
2464
3128
|
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
|
2465
3129
|
return databaseURL + newPath;
|
2466
3130
|
},
|
2467
|
-
trace
|
3131
|
+
trace,
|
3132
|
+
clientID
|
2468
3133
|
};
|
2469
3134
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
2470
3135
|
if (__privateGet(this, _branch))
|
@@ -2598,10 +3263,16 @@ exports.XataPlugin = XataPlugin;
|
|
2598
3263
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
2599
3264
|
exports.addGitBranchesEntry = addGitBranchesEntry;
|
2600
3265
|
exports.addTableColumn = addTableColumn;
|
3266
|
+
exports.aggregateTable = aggregateTable;
|
2601
3267
|
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
2602
3268
|
exports.buildClient = buildClient;
|
2603
3269
|
exports.buildWorkerRunner = buildWorkerRunner;
|
2604
3270
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
3271
|
+
exports.cPCreateDatabase = cPCreateDatabase;
|
3272
|
+
exports.cPDeleteDatabase = cPDeleteDatabase;
|
3273
|
+
exports.cPGetCPDatabaseMetadata = cPGetCPDatabaseMetadata;
|
3274
|
+
exports.cPGetDatabaseList = cPGetDatabaseList;
|
3275
|
+
exports.cPUpdateCPDatabaseMetadata = cPUpdateCPDatabaseMetadata;
|
2605
3276
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
2606
3277
|
exports.compareBranchSchemas = compareBranchSchemas;
|
2607
3278
|
exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
|
@@ -2642,6 +3313,7 @@ exports.getDatabaseList = getDatabaseList;
|
|
2642
3313
|
exports.getDatabaseMetadata = getDatabaseMetadata;
|
2643
3314
|
exports.getDatabaseURL = getDatabaseURL;
|
2644
3315
|
exports.getGitBranchesMapping = getGitBranchesMapping;
|
3316
|
+
exports.getHostUrl = getHostUrl;
|
2645
3317
|
exports.getMigrationRequest = getMigrationRequest;
|
2646
3318
|
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
2647
3319
|
exports.getRecord = getRecord;
|
@@ -2666,6 +3338,8 @@ exports.insertRecordWithID = insertRecordWithID;
|
|
2666
3338
|
exports.inviteWorkspaceMember = inviteWorkspaceMember;
|
2667
3339
|
exports.is = is;
|
2668
3340
|
exports.isCursorPaginationOptions = isCursorPaginationOptions;
|
3341
|
+
exports.isHostProviderAlias = isHostProviderAlias;
|
3342
|
+
exports.isHostProviderBuilder = isHostProviderBuilder;
|
2669
3343
|
exports.isIdentifiable = isIdentifiable;
|
2670
3344
|
exports.isNot = isNot;
|
2671
3345
|
exports.isXataRecord = isXataRecord;
|
@@ -2673,15 +3347,18 @@ exports.le = le;
|
|
2673
3347
|
exports.lessEquals = lessEquals;
|
2674
3348
|
exports.lessThan = lessThan;
|
2675
3349
|
exports.lessThanEquals = lessThanEquals;
|
2676
|
-
exports.listMigrationRequests = listMigrationRequests;
|
2677
3350
|
exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
|
3351
|
+
exports.listRegions = listRegions;
|
2678
3352
|
exports.lt = lt;
|
2679
3353
|
exports.lte = lte;
|
2680
3354
|
exports.mergeMigrationRequest = mergeMigrationRequest;
|
2681
3355
|
exports.notExists = notExists;
|
2682
3356
|
exports.operationsByTag = operationsByTag;
|
3357
|
+
exports.parseProviderString = parseProviderString;
|
3358
|
+
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
2683
3359
|
exports.pattern = pattern;
|
2684
3360
|
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
3361
|
+
exports.queryMigrationRequests = queryMigrationRequests;
|
2685
3362
|
exports.queryTable = queryTable;
|
2686
3363
|
exports.removeGitBranchesEntry = removeGitBranchesEntry;
|
2687
3364
|
exports.removeWorkspaceMember = removeWorkspaceMember;
|