@xata.io/client 0.0.0-alpha.vfbe46c7 → 0.0.0-alpha.vfc52d85
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 +36 -0
- package/README.md +5 -5
- package/dist/index.cjs +1171 -576
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3251 -2065
- package/dist/index.mjs +1164 -577
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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.vfc52d85";
|
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,15 +270,18 @@ async function fetch$1({
|
|
253
270
|
queryParams,
|
254
271
|
fetchImpl,
|
255
272
|
apiKey,
|
273
|
+
endpoint,
|
256
274
|
apiUrl,
|
257
275
|
workspacesApiUrl,
|
258
276
|
trace,
|
259
|
-
signal
|
277
|
+
signal,
|
278
|
+
clientID,
|
279
|
+
sessionID
|
260
280
|
}) {
|
261
281
|
return trace(
|
262
282
|
`${method.toUpperCase()} ${path}`,
|
263
283
|
async ({ setAttributes }) => {
|
264
|
-
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
284
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
265
285
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
266
286
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
267
287
|
setAttributes({
|
@@ -274,6 +294,8 @@ async function fetch$1({
|
|
274
294
|
headers: {
|
275
295
|
"Content-Type": "application/json",
|
276
296
|
"User-Agent": `Xata client-ts/${VERSION}`,
|
297
|
+
"X-Xata-Client-ID": clientID ?? "",
|
298
|
+
"X-Xata-Session-ID": sessionID ?? "",
|
277
299
|
...headers,
|
278
300
|
...hostHeader(fullUrl),
|
279
301
|
Authorization: `Bearer ${apiKey}`
|
@@ -314,390 +336,357 @@ function parseUrl(url) {
|
|
314
336
|
}
|
315
337
|
}
|
316
338
|
|
317
|
-
const
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
signal
|
323
|
-
});
|
324
|
-
const deleteUser = (variables, signal) => fetch$1({ url: "/user", method: "delete", ...variables, signal });
|
325
|
-
const getUserAPIKeys = (variables, signal) => fetch$1({
|
326
|
-
url: "/user/keys",
|
339
|
+
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
340
|
+
|
341
|
+
const dEPRECATEDgetDatabaseList = (variables, signal) => dataPlaneFetch({ url: "/dbs", method: "get", ...variables, signal });
|
342
|
+
const getBranchList = (variables, signal) => dataPlaneFetch({
|
343
|
+
url: "/dbs/{dbName}",
|
327
344
|
method: "get",
|
328
345
|
...variables,
|
329
346
|
signal
|
330
347
|
});
|
331
|
-
const
|
332
|
-
|
333
|
-
|
348
|
+
const dEPRECATEDcreateDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
|
349
|
+
const dEPRECATEDdeleteDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "delete", ...variables, signal });
|
350
|
+
const dEPRECATEDgetDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "get", ...variables, signal });
|
351
|
+
const dEPRECATEDupdateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
|
352
|
+
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
353
|
+
url: "/db/{dbBranchName}",
|
354
|
+
method: "get",
|
334
355
|
...variables,
|
335
356
|
signal
|
336
357
|
});
|
337
|
-
const
|
338
|
-
|
358
|
+
const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
|
359
|
+
const deleteBranch = (variables, signal) => dataPlaneFetch({
|
360
|
+
url: "/db/{dbBranchName}",
|
339
361
|
method: "delete",
|
340
362
|
...variables,
|
341
363
|
signal
|
342
364
|
});
|
343
|
-
const
|
344
|
-
url: "/
|
345
|
-
method: "
|
365
|
+
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
366
|
+
url: "/db/{dbBranchName}/metadata",
|
367
|
+
method: "put",
|
346
368
|
...variables,
|
347
369
|
signal
|
348
370
|
});
|
349
|
-
const
|
350
|
-
url: "/
|
371
|
+
const getBranchMetadata = (variables, signal) => dataPlaneFetch({
|
372
|
+
url: "/db/{dbBranchName}/metadata",
|
351
373
|
method: "get",
|
352
374
|
...variables,
|
353
375
|
signal
|
354
376
|
});
|
355
|
-
const
|
356
|
-
url: "/
|
377
|
+
const getBranchStats = (variables, signal) => dataPlaneFetch({
|
378
|
+
url: "/db/{dbBranchName}/stats",
|
357
379
|
method: "get",
|
358
380
|
...variables,
|
359
381
|
signal
|
360
382
|
});
|
361
|
-
const
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
});
|
367
|
-
const
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
}
|
373
|
-
const getWorkspaceMembersList = (variables, signal) => fetch$1({
|
374
|
-
url: "/workspaces/{workspaceId}/members",
|
383
|
+
const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
|
384
|
+
const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
|
385
|
+
const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
|
386
|
+
const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
|
387
|
+
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
388
|
+
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
389
|
+
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
390
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
391
|
+
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
392
|
+
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
393
|
+
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
394
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
375
395
|
method: "get",
|
376
396
|
...variables,
|
377
397
|
signal
|
378
398
|
});
|
379
|
-
const
|
380
|
-
const
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
});
|
386
|
-
const inviteWorkspaceMember = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
|
387
|
-
const updateWorkspaceMemberInvite = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
|
388
|
-
const cancelWorkspaceMemberInvite = (variables, signal) => fetch$1({
|
389
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
390
|
-
method: "delete",
|
391
|
-
...variables,
|
392
|
-
signal
|
393
|
-
});
|
394
|
-
const resendWorkspaceMemberInvite = (variables, signal) => fetch$1({
|
395
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
|
396
|
-
method: "post",
|
397
|
-
...variables,
|
398
|
-
signal
|
399
|
-
});
|
400
|
-
const acceptWorkspaceMemberInvite = (variables, signal) => fetch$1({
|
401
|
-
url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
|
399
|
+
const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
|
400
|
+
const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
|
401
|
+
const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
|
402
|
+
const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
|
403
|
+
const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
|
404
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
402
405
|
method: "post",
|
403
406
|
...variables,
|
404
407
|
signal
|
405
408
|
});
|
406
|
-
const
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
});
|
412
|
-
const
|
413
|
-
url: "/
|
414
|
-
method: "get",
|
415
|
-
...variables,
|
416
|
-
signal
|
417
|
-
});
|
418
|
-
const createDatabase = (variables, signal) => fetch$1({
|
419
|
-
url: "/dbs/{dbName}",
|
409
|
+
const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
|
410
|
+
const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
|
411
|
+
const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
|
412
|
+
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
413
|
+
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
414
|
+
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
415
|
+
const createTable = (variables, signal) => dataPlaneFetch({
|
416
|
+
url: "/db/{dbBranchName}/tables/{tableName}",
|
420
417
|
method: "put",
|
421
418
|
...variables,
|
422
419
|
signal
|
423
420
|
});
|
424
|
-
const
|
425
|
-
url: "/
|
421
|
+
const deleteTable = (variables, signal) => dataPlaneFetch({
|
422
|
+
url: "/db/{dbBranchName}/tables/{tableName}",
|
426
423
|
method: "delete",
|
427
424
|
...variables,
|
428
425
|
signal
|
429
426
|
});
|
430
|
-
const
|
431
|
-
|
427
|
+
const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
|
428
|
+
const getTableSchema = (variables, signal) => dataPlaneFetch({
|
429
|
+
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
432
430
|
method: "get",
|
433
431
|
...variables,
|
434
432
|
signal
|
435
433
|
});
|
436
|
-
const
|
437
|
-
const
|
438
|
-
|
439
|
-
const removeGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
|
440
|
-
const resolveBranch = (variables, signal) => fetch$1({
|
441
|
-
url: "/dbs/{dbName}/resolveBranch",
|
434
|
+
const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
|
435
|
+
const getTableColumns = (variables, signal) => dataPlaneFetch({
|
436
|
+
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
442
437
|
method: "get",
|
443
438
|
...variables,
|
444
439
|
signal
|
445
440
|
});
|
446
|
-
const
|
447
|
-
|
448
|
-
|
449
|
-
|
441
|
+
const addTableColumn = (variables, signal) => dataPlaneFetch(
|
442
|
+
{ url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
|
443
|
+
);
|
444
|
+
const getColumn = (variables, signal) => dataPlaneFetch({
|
445
|
+
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
450
446
|
method: "get",
|
451
447
|
...variables,
|
452
448
|
signal
|
453
449
|
});
|
454
|
-
const
|
455
|
-
const
|
456
|
-
|
457
|
-
|
458
|
-
const mergeMigrationRequest = (variables, signal) => fetch$1({
|
459
|
-
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
460
|
-
method: "post",
|
450
|
+
const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
|
451
|
+
const deleteColumn = (variables, signal) => dataPlaneFetch({
|
452
|
+
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
453
|
+
method: "delete",
|
461
454
|
...variables,
|
462
455
|
signal
|
463
456
|
});
|
464
|
-
const
|
465
|
-
|
457
|
+
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
458
|
+
const getRecord = (variables, signal) => dataPlaneFetch({
|
459
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
466
460
|
method: "get",
|
467
461
|
...variables,
|
468
462
|
signal
|
469
463
|
});
|
470
|
-
const
|
471
|
-
const
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
}
|
477
|
-
|
478
|
-
url: "/db/{dbBranchName}/metadata",
|
479
|
-
method: "put",
|
464
|
+
const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
|
465
|
+
const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
|
466
|
+
const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
|
467
|
+
const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
|
468
|
+
const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
|
469
|
+
const queryTable = (variables, signal) => dataPlaneFetch({
|
470
|
+
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
471
|
+
method: "post",
|
480
472
|
...variables,
|
481
473
|
signal
|
482
474
|
});
|
483
|
-
const
|
484
|
-
url: "/db/{dbBranchName}/
|
485
|
-
method: "
|
475
|
+
const searchBranch = (variables, signal) => dataPlaneFetch({
|
476
|
+
url: "/db/{dbBranchName}/search",
|
477
|
+
method: "post",
|
486
478
|
...variables,
|
487
479
|
signal
|
488
480
|
});
|
489
|
-
const
|
490
|
-
|
491
|
-
const getBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
492
|
-
const compareBranchWithUserSchema = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
|
493
|
-
const compareBranchSchemas = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
|
494
|
-
const updateBranchSchema = (variables, signal) => fetch$1({
|
495
|
-
url: "/db/{dbBranchName}/schema/update",
|
481
|
+
const searchTable = (variables, signal) => dataPlaneFetch({
|
482
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
496
483
|
method: "post",
|
497
484
|
...variables,
|
498
485
|
signal
|
499
486
|
});
|
500
|
-
const
|
501
|
-
const
|
502
|
-
const
|
503
|
-
|
504
|
-
|
487
|
+
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
488
|
+
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
489
|
+
const operationsByTag$2 = {
|
490
|
+
database: {
|
491
|
+
dEPRECATEDgetDatabaseList,
|
492
|
+
dEPRECATEDcreateDatabase,
|
493
|
+
dEPRECATEDdeleteDatabase,
|
494
|
+
dEPRECATEDgetDatabaseMetadata,
|
495
|
+
dEPRECATEDupdateDatabaseMetadata
|
496
|
+
},
|
497
|
+
branch: {
|
498
|
+
getBranchList,
|
499
|
+
getBranchDetails,
|
500
|
+
createBranch,
|
501
|
+
deleteBranch,
|
502
|
+
updateBranchMetadata,
|
503
|
+
getBranchMetadata,
|
504
|
+
getBranchStats,
|
505
|
+
getGitBranchesMapping,
|
506
|
+
addGitBranchesEntry,
|
507
|
+
removeGitBranchesEntry,
|
508
|
+
resolveBranch
|
509
|
+
},
|
510
|
+
migrations: {
|
511
|
+
getBranchMigrationHistory,
|
512
|
+
getBranchMigrationPlan,
|
513
|
+
executeBranchMigrationPlan,
|
514
|
+
getBranchSchemaHistory,
|
515
|
+
compareBranchWithUserSchema,
|
516
|
+
compareBranchSchemas,
|
517
|
+
updateBranchSchema,
|
518
|
+
previewBranchSchemaEdit,
|
519
|
+
applyBranchSchemaEdit
|
520
|
+
},
|
521
|
+
records: {
|
522
|
+
branchTransaction,
|
523
|
+
insertRecord,
|
524
|
+
getRecord,
|
525
|
+
insertRecordWithID,
|
526
|
+
updateRecordWithID,
|
527
|
+
upsertRecordWithID,
|
528
|
+
deleteRecord,
|
529
|
+
bulkInsertTableRecords
|
530
|
+
},
|
531
|
+
migrationRequests: {
|
532
|
+
queryMigrationRequests,
|
533
|
+
createMigrationRequest,
|
534
|
+
getMigrationRequest,
|
535
|
+
updateMigrationRequest,
|
536
|
+
listMigrationRequestsCommits,
|
537
|
+
compareMigrationRequest,
|
538
|
+
getMigrationRequestIsMerged,
|
539
|
+
mergeMigrationRequest
|
540
|
+
},
|
541
|
+
table: {
|
542
|
+
createTable,
|
543
|
+
deleteTable,
|
544
|
+
updateTable,
|
545
|
+
getTableSchema,
|
546
|
+
setTableSchema,
|
547
|
+
getTableColumns,
|
548
|
+
addTableColumn,
|
549
|
+
getColumn,
|
550
|
+
updateColumn,
|
551
|
+
deleteColumn
|
552
|
+
},
|
553
|
+
searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
|
554
|
+
};
|
555
|
+
|
556
|
+
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
557
|
+
|
558
|
+
const getUser = (variables, signal) => controlPlaneFetch({
|
559
|
+
url: "/user",
|
505
560
|
method: "get",
|
506
561
|
...variables,
|
507
562
|
signal
|
508
563
|
});
|
509
|
-
const
|
510
|
-
url: "/
|
564
|
+
const updateUser = (variables, signal) => controlPlaneFetch({
|
565
|
+
url: "/user",
|
511
566
|
method: "put",
|
512
567
|
...variables,
|
513
568
|
signal
|
514
569
|
});
|
515
|
-
const
|
516
|
-
url: "/
|
570
|
+
const deleteUser = (variables, signal) => controlPlaneFetch({
|
571
|
+
url: "/user",
|
517
572
|
method: "delete",
|
518
573
|
...variables,
|
519
574
|
signal
|
520
575
|
});
|
521
|
-
const
|
522
|
-
url: "/
|
523
|
-
method: "
|
576
|
+
const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
|
577
|
+
url: "/user/keys",
|
578
|
+
method: "get",
|
524
579
|
...variables,
|
525
580
|
signal
|
526
581
|
});
|
527
|
-
const
|
528
|
-
url: "/
|
529
|
-
method: "
|
582
|
+
const createUserAPIKey = (variables, signal) => controlPlaneFetch({
|
583
|
+
url: "/user/keys/{keyName}",
|
584
|
+
method: "post",
|
530
585
|
...variables,
|
531
586
|
signal
|
532
587
|
});
|
533
|
-
const
|
534
|
-
url: "/
|
535
|
-
method: "
|
588
|
+
const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
589
|
+
url: "/user/keys/{keyName}",
|
590
|
+
method: "delete",
|
536
591
|
...variables,
|
537
592
|
signal
|
538
593
|
});
|
539
|
-
const
|
540
|
-
url: "/
|
594
|
+
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
595
|
+
url: "/workspaces",
|
541
596
|
method: "get",
|
542
597
|
...variables,
|
543
598
|
signal
|
544
599
|
});
|
545
|
-
const
|
546
|
-
url: "/
|
600
|
+
const createWorkspace = (variables, signal) => controlPlaneFetch({
|
601
|
+
url: "/workspaces",
|
547
602
|
method: "post",
|
548
603
|
...variables,
|
549
604
|
signal
|
550
605
|
});
|
551
|
-
const
|
552
|
-
url: "/
|
606
|
+
const getWorkspace = (variables, signal) => controlPlaneFetch({
|
607
|
+
url: "/workspaces/{workspaceId}",
|
553
608
|
method: "get",
|
554
609
|
...variables,
|
555
610
|
signal
|
556
611
|
});
|
557
|
-
const
|
558
|
-
url: "/
|
559
|
-
method: "
|
612
|
+
const updateWorkspace = (variables, signal) => controlPlaneFetch({
|
613
|
+
url: "/workspaces/{workspaceId}",
|
614
|
+
method: "put",
|
560
615
|
...variables,
|
561
616
|
signal
|
562
617
|
});
|
563
|
-
const
|
564
|
-
url: "/
|
565
|
-
method: "
|
618
|
+
const deleteWorkspace = (variables, signal) => controlPlaneFetch({
|
619
|
+
url: "/workspaces/{workspaceId}",
|
620
|
+
method: "delete",
|
566
621
|
...variables,
|
567
622
|
signal
|
568
623
|
});
|
569
|
-
const
|
570
|
-
const
|
571
|
-
const
|
572
|
-
|
573
|
-
const deleteRecord = (variables, signal) => fetch$1({
|
574
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
624
|
+
const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
|
625
|
+
const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
|
626
|
+
const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
627
|
+
url: "/workspaces/{workspaceId}/members/{userId}",
|
575
628
|
method: "delete",
|
576
629
|
...variables,
|
577
630
|
signal
|
578
631
|
});
|
579
|
-
const
|
580
|
-
|
632
|
+
const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
|
633
|
+
const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
|
634
|
+
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
635
|
+
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
636
|
+
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
637
|
+
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
638
|
+
url: "/workspaces/{workspaceId}/dbs",
|
581
639
|
method: "get",
|
582
640
|
...variables,
|
583
641
|
signal
|
584
642
|
});
|
585
|
-
const
|
586
|
-
const
|
587
|
-
url: "/
|
588
|
-
method: "
|
589
|
-
...variables,
|
590
|
-
signal
|
591
|
-
});
|
592
|
-
const searchTable = (variables, signal) => fetch$1({
|
593
|
-
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
594
|
-
method: "post",
|
595
|
-
...variables,
|
596
|
-
signal
|
597
|
-
});
|
598
|
-
const searchBranch = (variables, signal) => fetch$1({
|
599
|
-
url: "/db/{dbBranchName}/search",
|
600
|
-
method: "post",
|
643
|
+
const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
|
644
|
+
const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
645
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
646
|
+
method: "delete",
|
601
647
|
...variables,
|
602
648
|
signal
|
603
649
|
});
|
604
|
-
const
|
605
|
-
|
606
|
-
|
650
|
+
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
651
|
+
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
652
|
+
const listRegions = (variables, signal) => controlPlaneFetch({
|
653
|
+
url: "/workspaces/{workspaceId}/regions",
|
654
|
+
method: "get",
|
607
655
|
...variables,
|
608
656
|
signal
|
609
657
|
});
|
610
|
-
const
|
611
|
-
|
612
|
-
|
613
|
-
...variables
|
614
|
-
});
|
615
|
-
const operationsByTag = {
|
616
|
-
users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
658
|
+
const operationsByTag$1 = {
|
659
|
+
users: { getUser, updateUser, deleteUser },
|
660
|
+
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
617
661
|
workspaces: {
|
618
|
-
createWorkspace,
|
619
662
|
getWorkspacesList,
|
663
|
+
createWorkspace,
|
620
664
|
getWorkspace,
|
621
665
|
updateWorkspace,
|
622
666
|
deleteWorkspace,
|
623
667
|
getWorkspaceMembersList,
|
624
668
|
updateWorkspaceMemberRole,
|
625
|
-
removeWorkspaceMember
|
669
|
+
removeWorkspaceMember
|
670
|
+
},
|
671
|
+
invites: {
|
626
672
|
inviteWorkspaceMember,
|
627
673
|
updateWorkspaceMemberInvite,
|
628
674
|
cancelWorkspaceMemberInvite,
|
629
|
-
|
630
|
-
|
675
|
+
acceptWorkspaceMemberInvite,
|
676
|
+
resendWorkspaceMemberInvite
|
631
677
|
},
|
632
|
-
|
678
|
+
databases: {
|
633
679
|
getDatabaseList,
|
634
680
|
createDatabase,
|
635
681
|
deleteDatabase,
|
636
682
|
getDatabaseMetadata,
|
637
683
|
updateDatabaseMetadata,
|
638
|
-
|
639
|
-
addGitBranchesEntry,
|
640
|
-
removeGitBranchesEntry,
|
641
|
-
resolveBranch
|
642
|
-
},
|
643
|
-
branch: {
|
644
|
-
getBranchList,
|
645
|
-
getBranchDetails,
|
646
|
-
createBranch,
|
647
|
-
deleteBranch,
|
648
|
-
updateBranchMetadata,
|
649
|
-
getBranchMetadata,
|
650
|
-
getBranchStats
|
651
|
-
},
|
652
|
-
migrationRequests: {
|
653
|
-
queryMigrationRequests,
|
654
|
-
createMigrationRequest,
|
655
|
-
getMigrationRequest,
|
656
|
-
updateMigrationRequest,
|
657
|
-
listMigrationRequestsCommits,
|
658
|
-
compareMigrationRequest,
|
659
|
-
getMigrationRequestIsMerged,
|
660
|
-
mergeMigrationRequest
|
661
|
-
},
|
662
|
-
branchSchema: {
|
663
|
-
getBranchMigrationHistory,
|
664
|
-
executeBranchMigrationPlan,
|
665
|
-
getBranchMigrationPlan,
|
666
|
-
compareBranchWithUserSchema,
|
667
|
-
compareBranchSchemas,
|
668
|
-
updateBranchSchema,
|
669
|
-
previewBranchSchemaEdit,
|
670
|
-
applyBranchSchemaEdit,
|
671
|
-
getBranchSchemaHistory
|
672
|
-
},
|
673
|
-
table: {
|
674
|
-
createTable,
|
675
|
-
deleteTable,
|
676
|
-
updateTable,
|
677
|
-
getTableSchema,
|
678
|
-
setTableSchema,
|
679
|
-
getTableColumns,
|
680
|
-
addTableColumn,
|
681
|
-
getColumn,
|
682
|
-
deleteColumn,
|
683
|
-
updateColumn
|
684
|
-
},
|
685
|
-
records: {
|
686
|
-
insertRecord,
|
687
|
-
insertRecordWithID,
|
688
|
-
updateRecordWithID,
|
689
|
-
upsertRecordWithID,
|
690
|
-
deleteRecord,
|
691
|
-
getRecord,
|
692
|
-
bulkInsertTableRecords,
|
693
|
-
queryTable,
|
694
|
-
searchTable,
|
695
|
-
searchBranch,
|
696
|
-
summarizeTable,
|
697
|
-
aggregateTable
|
684
|
+
listRegions
|
698
685
|
}
|
699
686
|
};
|
700
687
|
|
688
|
+
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
689
|
+
|
701
690
|
function getHostUrl(provider, type) {
|
702
691
|
if (isHostProviderAlias(provider)) {
|
703
692
|
return providers[provider][type];
|
@@ -709,11 +698,11 @@ function getHostUrl(provider, type) {
|
|
709
698
|
const providers = {
|
710
699
|
production: {
|
711
700
|
main: "https://api.xata.io",
|
712
|
-
workspaces: "https://{workspaceId}.xata.sh"
|
701
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
713
702
|
},
|
714
703
|
staging: {
|
715
704
|
main: "https://staging.xatabase.co",
|
716
|
-
workspaces: "https://{workspaceId}.staging.xatabase.co"
|
705
|
+
workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
|
717
706
|
}
|
718
707
|
};
|
719
708
|
function isHostProviderAlias(alias) {
|
@@ -731,6 +720,16 @@ function parseProviderString(provider = "production") {
|
|
731
720
|
return null;
|
732
721
|
return { main, workspaces };
|
733
722
|
}
|
723
|
+
function parseWorkspacesUrlParts(url) {
|
724
|
+
if (!isString(url))
|
725
|
+
return null;
|
726
|
+
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
|
727
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
|
728
|
+
const match = url.match(regex) || url.match(regexStaging);
|
729
|
+
if (!match)
|
730
|
+
return null;
|
731
|
+
return { workspace: match[1], region: match[2] ?? "eu-west-1" };
|
732
|
+
}
|
734
733
|
|
735
734
|
var __accessCheck$7 = (obj, member, msg) => {
|
736
735
|
if (!member.has(obj))
|
@@ -774,21 +773,41 @@ class XataApiClient {
|
|
774
773
|
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
775
774
|
return __privateGet$7(this, _namespaces).user;
|
776
775
|
}
|
776
|
+
get authentication() {
|
777
|
+
if (!__privateGet$7(this, _namespaces).authentication)
|
778
|
+
__privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
|
779
|
+
return __privateGet$7(this, _namespaces).authentication;
|
780
|
+
}
|
777
781
|
get workspaces() {
|
778
782
|
if (!__privateGet$7(this, _namespaces).workspaces)
|
779
783
|
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
780
784
|
return __privateGet$7(this, _namespaces).workspaces;
|
781
785
|
}
|
782
|
-
get
|
783
|
-
if (!__privateGet$7(this, _namespaces).
|
784
|
-
__privateGet$7(this, _namespaces).
|
785
|
-
return __privateGet$7(this, _namespaces).
|
786
|
+
get invites() {
|
787
|
+
if (!__privateGet$7(this, _namespaces).invites)
|
788
|
+
__privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
|
789
|
+
return __privateGet$7(this, _namespaces).invites;
|
790
|
+
}
|
791
|
+
get database() {
|
792
|
+
if (!__privateGet$7(this, _namespaces).database)
|
793
|
+
__privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
|
794
|
+
return __privateGet$7(this, _namespaces).database;
|
786
795
|
}
|
787
796
|
get branches() {
|
788
797
|
if (!__privateGet$7(this, _namespaces).branches)
|
789
798
|
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
790
799
|
return __privateGet$7(this, _namespaces).branches;
|
791
800
|
}
|
801
|
+
get migrations() {
|
802
|
+
if (!__privateGet$7(this, _namespaces).migrations)
|
803
|
+
__privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
|
804
|
+
return __privateGet$7(this, _namespaces).migrations;
|
805
|
+
}
|
806
|
+
get migrationRequests() {
|
807
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
808
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
809
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
810
|
+
}
|
792
811
|
get tables() {
|
793
812
|
if (!__privateGet$7(this, _namespaces).tables)
|
794
813
|
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
@@ -799,15 +818,10 @@ class XataApiClient {
|
|
799
818
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
800
819
|
return __privateGet$7(this, _namespaces).records;
|
801
820
|
}
|
802
|
-
get
|
803
|
-
if (!__privateGet$7(this, _namespaces).
|
804
|
-
__privateGet$7(this, _namespaces).
|
805
|
-
return __privateGet$7(this, _namespaces).
|
806
|
-
}
|
807
|
-
get branchSchema() {
|
808
|
-
if (!__privateGet$7(this, _namespaces).branchSchema)
|
809
|
-
__privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
|
810
|
-
return __privateGet$7(this, _namespaces).branchSchema;
|
821
|
+
get searchAndFilter() {
|
822
|
+
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
823
|
+
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
824
|
+
return __privateGet$7(this, _namespaces).searchAndFilter;
|
811
825
|
}
|
812
826
|
}
|
813
827
|
_extraProps = new WeakMap();
|
@@ -819,24 +833,29 @@ class UserApi {
|
|
819
833
|
getUser() {
|
820
834
|
return operationsByTag.users.getUser({ ...this.extraProps });
|
821
835
|
}
|
822
|
-
updateUser(user) {
|
836
|
+
updateUser({ user }) {
|
823
837
|
return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
|
824
838
|
}
|
825
839
|
deleteUser() {
|
826
840
|
return operationsByTag.users.deleteUser({ ...this.extraProps });
|
827
841
|
}
|
842
|
+
}
|
843
|
+
class AuthenticationApi {
|
844
|
+
constructor(extraProps) {
|
845
|
+
this.extraProps = extraProps;
|
846
|
+
}
|
828
847
|
getUserAPIKeys() {
|
829
|
-
return operationsByTag.
|
848
|
+
return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
|
830
849
|
}
|
831
|
-
createUserAPIKey(
|
832
|
-
return operationsByTag.
|
833
|
-
pathParams: { keyName },
|
850
|
+
createUserAPIKey({ name }) {
|
851
|
+
return operationsByTag.authentication.createUserAPIKey({
|
852
|
+
pathParams: { keyName: name },
|
834
853
|
...this.extraProps
|
835
854
|
});
|
836
855
|
}
|
837
|
-
deleteUserAPIKey(
|
838
|
-
return operationsByTag.
|
839
|
-
pathParams: { keyName },
|
856
|
+
deleteUserAPIKey({ name }) {
|
857
|
+
return operationsByTag.authentication.deleteUserAPIKey({
|
858
|
+
pathParams: { keyName: name },
|
840
859
|
...this.extraProps
|
841
860
|
});
|
842
861
|
}
|
@@ -845,196 +864,248 @@ class WorkspaceApi {
|
|
845
864
|
constructor(extraProps) {
|
846
865
|
this.extraProps = extraProps;
|
847
866
|
}
|
848
|
-
|
867
|
+
getWorkspacesList() {
|
868
|
+
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
869
|
+
}
|
870
|
+
createWorkspace({ data }) {
|
849
871
|
return operationsByTag.workspaces.createWorkspace({
|
850
|
-
body:
|
872
|
+
body: data,
|
851
873
|
...this.extraProps
|
852
874
|
});
|
853
875
|
}
|
854
|
-
|
855
|
-
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
856
|
-
}
|
857
|
-
getWorkspace(workspaceId) {
|
876
|
+
getWorkspace({ workspace }) {
|
858
877
|
return operationsByTag.workspaces.getWorkspace({
|
859
|
-
pathParams: { workspaceId },
|
878
|
+
pathParams: { workspaceId: workspace },
|
860
879
|
...this.extraProps
|
861
880
|
});
|
862
881
|
}
|
863
|
-
updateWorkspace(
|
882
|
+
updateWorkspace({
|
883
|
+
workspace,
|
884
|
+
update
|
885
|
+
}) {
|
864
886
|
return operationsByTag.workspaces.updateWorkspace({
|
865
|
-
pathParams: { workspaceId },
|
866
|
-
body:
|
887
|
+
pathParams: { workspaceId: workspace },
|
888
|
+
body: update,
|
867
889
|
...this.extraProps
|
868
890
|
});
|
869
891
|
}
|
870
|
-
deleteWorkspace(
|
892
|
+
deleteWorkspace({ workspace }) {
|
871
893
|
return operationsByTag.workspaces.deleteWorkspace({
|
872
|
-
pathParams: { workspaceId },
|
894
|
+
pathParams: { workspaceId: workspace },
|
873
895
|
...this.extraProps
|
874
896
|
});
|
875
897
|
}
|
876
|
-
getWorkspaceMembersList(
|
898
|
+
getWorkspaceMembersList({ workspace }) {
|
877
899
|
return operationsByTag.workspaces.getWorkspaceMembersList({
|
878
|
-
pathParams: { workspaceId },
|
900
|
+
pathParams: { workspaceId: workspace },
|
879
901
|
...this.extraProps
|
880
902
|
});
|
881
903
|
}
|
882
|
-
updateWorkspaceMemberRole(
|
904
|
+
updateWorkspaceMemberRole({
|
905
|
+
workspace,
|
906
|
+
user,
|
907
|
+
role
|
908
|
+
}) {
|
883
909
|
return operationsByTag.workspaces.updateWorkspaceMemberRole({
|
884
|
-
pathParams: { workspaceId, userId },
|
910
|
+
pathParams: { workspaceId: workspace, userId: user },
|
885
911
|
body: { role },
|
886
912
|
...this.extraProps
|
887
913
|
});
|
888
914
|
}
|
889
|
-
removeWorkspaceMember(
|
915
|
+
removeWorkspaceMember({
|
916
|
+
workspace,
|
917
|
+
user
|
918
|
+
}) {
|
890
919
|
return operationsByTag.workspaces.removeWorkspaceMember({
|
891
|
-
pathParams: { workspaceId, userId },
|
920
|
+
pathParams: { workspaceId: workspace, userId: user },
|
892
921
|
...this.extraProps
|
893
922
|
});
|
894
923
|
}
|
895
|
-
|
896
|
-
|
897
|
-
|
924
|
+
}
|
925
|
+
class InvitesApi {
|
926
|
+
constructor(extraProps) {
|
927
|
+
this.extraProps = extraProps;
|
928
|
+
}
|
929
|
+
inviteWorkspaceMember({
|
930
|
+
workspace,
|
931
|
+
email,
|
932
|
+
role
|
933
|
+
}) {
|
934
|
+
return operationsByTag.invites.inviteWorkspaceMember({
|
935
|
+
pathParams: { workspaceId: workspace },
|
898
936
|
body: { email, role },
|
899
937
|
...this.extraProps
|
900
938
|
});
|
901
939
|
}
|
902
|
-
updateWorkspaceMemberInvite(
|
903
|
-
|
904
|
-
|
940
|
+
updateWorkspaceMemberInvite({
|
941
|
+
workspace,
|
942
|
+
invite,
|
943
|
+
role
|
944
|
+
}) {
|
945
|
+
return operationsByTag.invites.updateWorkspaceMemberInvite({
|
946
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
905
947
|
body: { role },
|
906
948
|
...this.extraProps
|
907
949
|
});
|
908
950
|
}
|
909
|
-
cancelWorkspaceMemberInvite(
|
910
|
-
|
911
|
-
|
951
|
+
cancelWorkspaceMemberInvite({
|
952
|
+
workspace,
|
953
|
+
invite
|
954
|
+
}) {
|
955
|
+
return operationsByTag.invites.cancelWorkspaceMemberInvite({
|
956
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
912
957
|
...this.extraProps
|
913
958
|
});
|
914
959
|
}
|
915
|
-
|
916
|
-
|
917
|
-
|
960
|
+
acceptWorkspaceMemberInvite({
|
961
|
+
workspace,
|
962
|
+
key
|
963
|
+
}) {
|
964
|
+
return operationsByTag.invites.acceptWorkspaceMemberInvite({
|
965
|
+
pathParams: { workspaceId: workspace, inviteKey: key },
|
918
966
|
...this.extraProps
|
919
967
|
});
|
920
968
|
}
|
921
|
-
|
922
|
-
|
923
|
-
|
969
|
+
resendWorkspaceMemberInvite({
|
970
|
+
workspace,
|
971
|
+
invite
|
972
|
+
}) {
|
973
|
+
return operationsByTag.invites.resendWorkspaceMemberInvite({
|
974
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
924
975
|
...this.extraProps
|
925
976
|
});
|
926
977
|
}
|
927
978
|
}
|
928
|
-
class
|
979
|
+
class BranchApi {
|
929
980
|
constructor(extraProps) {
|
930
981
|
this.extraProps = extraProps;
|
931
982
|
}
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
return operationsByTag.database.createDatabase({
|
940
|
-
pathParams: { workspace, dbName },
|
941
|
-
body: options,
|
942
|
-
...this.extraProps
|
943
|
-
});
|
944
|
-
}
|
945
|
-
deleteDatabase(workspace, dbName) {
|
946
|
-
return operationsByTag.database.deleteDatabase({
|
947
|
-
pathParams: { workspace, dbName },
|
948
|
-
...this.extraProps
|
949
|
-
});
|
950
|
-
}
|
951
|
-
getDatabaseMetadata(workspace, dbName) {
|
952
|
-
return operationsByTag.database.getDatabaseMetadata({
|
953
|
-
pathParams: { workspace, dbName },
|
954
|
-
...this.extraProps
|
955
|
-
});
|
956
|
-
}
|
957
|
-
updateDatabaseMetadata(workspace, dbName, options = {}) {
|
958
|
-
return operationsByTag.database.updateDatabaseMetadata({
|
959
|
-
pathParams: { workspace, dbName },
|
960
|
-
body: options,
|
961
|
-
...this.extraProps
|
962
|
-
});
|
963
|
-
}
|
964
|
-
getGitBranchesMapping(workspace, dbName) {
|
965
|
-
return operationsByTag.database.getGitBranchesMapping({
|
966
|
-
pathParams: { workspace, dbName },
|
983
|
+
getBranchList({
|
984
|
+
workspace,
|
985
|
+
region,
|
986
|
+
database
|
987
|
+
}) {
|
988
|
+
return operationsByTag.branch.getBranchList({
|
989
|
+
pathParams: { workspace, region, dbName: database },
|
967
990
|
...this.extraProps
|
968
991
|
});
|
969
992
|
}
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
993
|
+
getBranchDetails({
|
994
|
+
workspace,
|
995
|
+
region,
|
996
|
+
database,
|
997
|
+
branch
|
998
|
+
}) {
|
999
|
+
return operationsByTag.branch.getBranchDetails({
|
1000
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
974
1001
|
...this.extraProps
|
975
1002
|
});
|
976
1003
|
}
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
1004
|
+
createBranch({
|
1005
|
+
workspace,
|
1006
|
+
region,
|
1007
|
+
database,
|
1008
|
+
branch,
|
1009
|
+
from,
|
1010
|
+
metadata
|
1011
|
+
}) {
|
1012
|
+
return operationsByTag.branch.createBranch({
|
1013
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1014
|
+
body: { from, metadata },
|
981
1015
|
...this.extraProps
|
982
1016
|
});
|
983
1017
|
}
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
1018
|
+
deleteBranch({
|
1019
|
+
workspace,
|
1020
|
+
region,
|
1021
|
+
database,
|
1022
|
+
branch
|
1023
|
+
}) {
|
1024
|
+
return operationsByTag.branch.deleteBranch({
|
1025
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
988
1026
|
...this.extraProps
|
989
1027
|
});
|
990
1028
|
}
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
1029
|
+
updateBranchMetadata({
|
1030
|
+
workspace,
|
1031
|
+
region,
|
1032
|
+
database,
|
1033
|
+
branch,
|
1034
|
+
metadata
|
1035
|
+
}) {
|
1036
|
+
return operationsByTag.branch.updateBranchMetadata({
|
1037
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1038
|
+
body: metadata,
|
999
1039
|
...this.extraProps
|
1000
1040
|
});
|
1001
1041
|
}
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1042
|
+
getBranchMetadata({
|
1043
|
+
workspace,
|
1044
|
+
region,
|
1045
|
+
database,
|
1046
|
+
branch
|
1047
|
+
}) {
|
1048
|
+
return operationsByTag.branch.getBranchMetadata({
|
1049
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1005
1050
|
...this.extraProps
|
1006
1051
|
});
|
1007
1052
|
}
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1053
|
+
getBranchStats({
|
1054
|
+
workspace,
|
1055
|
+
region,
|
1056
|
+
database,
|
1057
|
+
branch
|
1058
|
+
}) {
|
1059
|
+
return operationsByTag.branch.getBranchStats({
|
1060
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1013
1061
|
...this.extraProps
|
1014
1062
|
});
|
1015
1063
|
}
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1064
|
+
getGitBranchesMapping({
|
1065
|
+
workspace,
|
1066
|
+
region,
|
1067
|
+
database
|
1068
|
+
}) {
|
1069
|
+
return operationsByTag.branch.getGitBranchesMapping({
|
1070
|
+
pathParams: { workspace, region, dbName: database },
|
1019
1071
|
...this.extraProps
|
1020
1072
|
});
|
1021
1073
|
}
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1074
|
+
addGitBranchesEntry({
|
1075
|
+
workspace,
|
1076
|
+
region,
|
1077
|
+
database,
|
1078
|
+
gitBranch,
|
1079
|
+
xataBranch
|
1080
|
+
}) {
|
1081
|
+
return operationsByTag.branch.addGitBranchesEntry({
|
1082
|
+
pathParams: { workspace, region, dbName: database },
|
1083
|
+
body: { gitBranch, xataBranch },
|
1026
1084
|
...this.extraProps
|
1027
1085
|
});
|
1028
1086
|
}
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1087
|
+
removeGitBranchesEntry({
|
1088
|
+
workspace,
|
1089
|
+
region,
|
1090
|
+
database,
|
1091
|
+
gitBranch
|
1092
|
+
}) {
|
1093
|
+
return operationsByTag.branch.removeGitBranchesEntry({
|
1094
|
+
pathParams: { workspace, region, dbName: database },
|
1095
|
+
queryParams: { gitBranch },
|
1032
1096
|
...this.extraProps
|
1033
1097
|
});
|
1034
1098
|
}
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1099
|
+
resolveBranch({
|
1100
|
+
workspace,
|
1101
|
+
region,
|
1102
|
+
database,
|
1103
|
+
gitBranch,
|
1104
|
+
fallbackBranch
|
1105
|
+
}) {
|
1106
|
+
return operationsByTag.branch.resolveBranch({
|
1107
|
+
pathParams: { workspace, region, dbName: database },
|
1108
|
+
queryParams: { gitBranch, fallbackBranch },
|
1038
1109
|
...this.extraProps
|
1039
1110
|
});
|
1040
1111
|
}
|
@@ -1043,67 +1114,134 @@ class TableApi {
|
|
1043
1114
|
constructor(extraProps) {
|
1044
1115
|
this.extraProps = extraProps;
|
1045
1116
|
}
|
1046
|
-
createTable(
|
1117
|
+
createTable({
|
1118
|
+
workspace,
|
1119
|
+
region,
|
1120
|
+
database,
|
1121
|
+
branch,
|
1122
|
+
table
|
1123
|
+
}) {
|
1047
1124
|
return operationsByTag.table.createTable({
|
1048
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1125
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1049
1126
|
...this.extraProps
|
1050
1127
|
});
|
1051
1128
|
}
|
1052
|
-
deleteTable(
|
1129
|
+
deleteTable({
|
1130
|
+
workspace,
|
1131
|
+
region,
|
1132
|
+
database,
|
1133
|
+
branch,
|
1134
|
+
table
|
1135
|
+
}) {
|
1053
1136
|
return operationsByTag.table.deleteTable({
|
1054
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1137
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1055
1138
|
...this.extraProps
|
1056
1139
|
});
|
1057
1140
|
}
|
1058
|
-
updateTable(
|
1141
|
+
updateTable({
|
1142
|
+
workspace,
|
1143
|
+
region,
|
1144
|
+
database,
|
1145
|
+
branch,
|
1146
|
+
table,
|
1147
|
+
update
|
1148
|
+
}) {
|
1059
1149
|
return operationsByTag.table.updateTable({
|
1060
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1061
|
-
body:
|
1150
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1151
|
+
body: update,
|
1062
1152
|
...this.extraProps
|
1063
1153
|
});
|
1064
1154
|
}
|
1065
|
-
getTableSchema(
|
1155
|
+
getTableSchema({
|
1156
|
+
workspace,
|
1157
|
+
region,
|
1158
|
+
database,
|
1159
|
+
branch,
|
1160
|
+
table
|
1161
|
+
}) {
|
1066
1162
|
return operationsByTag.table.getTableSchema({
|
1067
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1163
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1068
1164
|
...this.extraProps
|
1069
1165
|
});
|
1070
1166
|
}
|
1071
|
-
setTableSchema(
|
1167
|
+
setTableSchema({
|
1168
|
+
workspace,
|
1169
|
+
region,
|
1170
|
+
database,
|
1171
|
+
branch,
|
1172
|
+
table,
|
1173
|
+
schema
|
1174
|
+
}) {
|
1072
1175
|
return operationsByTag.table.setTableSchema({
|
1073
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1074
|
-
body:
|
1176
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1177
|
+
body: schema,
|
1075
1178
|
...this.extraProps
|
1076
1179
|
});
|
1077
1180
|
}
|
1078
|
-
getTableColumns(
|
1181
|
+
getTableColumns({
|
1182
|
+
workspace,
|
1183
|
+
region,
|
1184
|
+
database,
|
1185
|
+
branch,
|
1186
|
+
table
|
1187
|
+
}) {
|
1079
1188
|
return operationsByTag.table.getTableColumns({
|
1080
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1189
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1081
1190
|
...this.extraProps
|
1082
1191
|
});
|
1083
1192
|
}
|
1084
|
-
addTableColumn(
|
1193
|
+
addTableColumn({
|
1194
|
+
workspace,
|
1195
|
+
region,
|
1196
|
+
database,
|
1197
|
+
branch,
|
1198
|
+
table,
|
1199
|
+
column
|
1200
|
+
}) {
|
1085
1201
|
return operationsByTag.table.addTableColumn({
|
1086
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1202
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1087
1203
|
body: column,
|
1088
1204
|
...this.extraProps
|
1089
1205
|
});
|
1090
1206
|
}
|
1091
|
-
getColumn(
|
1207
|
+
getColumn({
|
1208
|
+
workspace,
|
1209
|
+
region,
|
1210
|
+
database,
|
1211
|
+
branch,
|
1212
|
+
table,
|
1213
|
+
column
|
1214
|
+
}) {
|
1092
1215
|
return operationsByTag.table.getColumn({
|
1093
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
|
1216
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1094
1217
|
...this.extraProps
|
1095
1218
|
});
|
1096
1219
|
}
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1220
|
+
updateColumn({
|
1221
|
+
workspace,
|
1222
|
+
region,
|
1223
|
+
database,
|
1224
|
+
branch,
|
1225
|
+
table,
|
1226
|
+
column,
|
1227
|
+
update
|
1228
|
+
}) {
|
1229
|
+
return operationsByTag.table.updateColumn({
|
1230
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1231
|
+
body: update,
|
1100
1232
|
...this.extraProps
|
1101
1233
|
});
|
1102
1234
|
}
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1235
|
+
deleteColumn({
|
1236
|
+
workspace,
|
1237
|
+
region,
|
1238
|
+
database,
|
1239
|
+
branch,
|
1240
|
+
table,
|
1241
|
+
column
|
1242
|
+
}) {
|
1243
|
+
return operationsByTag.table.deleteColumn({
|
1244
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1107
1245
|
...this.extraProps
|
1108
1246
|
});
|
1109
1247
|
}
|
@@ -1112,92 +1250,226 @@ class RecordsApi {
|
|
1112
1250
|
constructor(extraProps) {
|
1113
1251
|
this.extraProps = extraProps;
|
1114
1252
|
}
|
1115
|
-
insertRecord(
|
1253
|
+
insertRecord({
|
1254
|
+
workspace,
|
1255
|
+
region,
|
1256
|
+
database,
|
1257
|
+
branch,
|
1258
|
+
table,
|
1259
|
+
record,
|
1260
|
+
columns
|
1261
|
+
}) {
|
1116
1262
|
return operationsByTag.records.insertRecord({
|
1117
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1118
|
-
queryParams:
|
1263
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1264
|
+
queryParams: { columns },
|
1119
1265
|
body: record,
|
1120
1266
|
...this.extraProps
|
1121
1267
|
});
|
1122
1268
|
}
|
1123
|
-
|
1269
|
+
getRecord({
|
1270
|
+
workspace,
|
1271
|
+
region,
|
1272
|
+
database,
|
1273
|
+
branch,
|
1274
|
+
table,
|
1275
|
+
id,
|
1276
|
+
columns
|
1277
|
+
}) {
|
1278
|
+
return operationsByTag.records.getRecord({
|
1279
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1280
|
+
queryParams: { columns },
|
1281
|
+
...this.extraProps
|
1282
|
+
});
|
1283
|
+
}
|
1284
|
+
insertRecordWithID({
|
1285
|
+
workspace,
|
1286
|
+
region,
|
1287
|
+
database,
|
1288
|
+
branch,
|
1289
|
+
table,
|
1290
|
+
id,
|
1291
|
+
record,
|
1292
|
+
columns,
|
1293
|
+
createOnly,
|
1294
|
+
ifVersion
|
1295
|
+
}) {
|
1124
1296
|
return operationsByTag.records.insertRecordWithID({
|
1125
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1126
|
-
queryParams:
|
1297
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1298
|
+
queryParams: { columns, createOnly, ifVersion },
|
1127
1299
|
body: record,
|
1128
1300
|
...this.extraProps
|
1129
1301
|
});
|
1130
1302
|
}
|
1131
|
-
updateRecordWithID(
|
1303
|
+
updateRecordWithID({
|
1304
|
+
workspace,
|
1305
|
+
region,
|
1306
|
+
database,
|
1307
|
+
branch,
|
1308
|
+
table,
|
1309
|
+
id,
|
1310
|
+
record,
|
1311
|
+
columns,
|
1312
|
+
ifVersion
|
1313
|
+
}) {
|
1132
1314
|
return operationsByTag.records.updateRecordWithID({
|
1133
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1134
|
-
queryParams:
|
1315
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1316
|
+
queryParams: { columns, ifVersion },
|
1135
1317
|
body: record,
|
1136
1318
|
...this.extraProps
|
1137
1319
|
});
|
1138
1320
|
}
|
1139
|
-
upsertRecordWithID(
|
1321
|
+
upsertRecordWithID({
|
1322
|
+
workspace,
|
1323
|
+
region,
|
1324
|
+
database,
|
1325
|
+
branch,
|
1326
|
+
table,
|
1327
|
+
id,
|
1328
|
+
record,
|
1329
|
+
columns,
|
1330
|
+
ifVersion
|
1331
|
+
}) {
|
1140
1332
|
return operationsByTag.records.upsertRecordWithID({
|
1141
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1142
|
-
queryParams:
|
1333
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1334
|
+
queryParams: { columns, ifVersion },
|
1143
1335
|
body: record,
|
1144
1336
|
...this.extraProps
|
1145
1337
|
});
|
1146
1338
|
}
|
1147
|
-
deleteRecord(
|
1339
|
+
deleteRecord({
|
1340
|
+
workspace,
|
1341
|
+
region,
|
1342
|
+
database,
|
1343
|
+
branch,
|
1344
|
+
table,
|
1345
|
+
id,
|
1346
|
+
columns
|
1347
|
+
}) {
|
1148
1348
|
return operationsByTag.records.deleteRecord({
|
1149
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1150
|
-
queryParams:
|
1151
|
-
...this.extraProps
|
1152
|
-
});
|
1153
|
-
}
|
1154
|
-
getRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
1155
|
-
return operationsByTag.records.getRecord({
|
1156
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1157
|
-
queryParams: options,
|
1349
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1350
|
+
queryParams: { columns },
|
1158
1351
|
...this.extraProps
|
1159
1352
|
});
|
1160
1353
|
}
|
1161
|
-
bulkInsertTableRecords(
|
1354
|
+
bulkInsertTableRecords({
|
1355
|
+
workspace,
|
1356
|
+
region,
|
1357
|
+
database,
|
1358
|
+
branch,
|
1359
|
+
table,
|
1360
|
+
records,
|
1361
|
+
columns
|
1362
|
+
}) {
|
1162
1363
|
return operationsByTag.records.bulkInsertTableRecords({
|
1163
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1164
|
-
queryParams:
|
1364
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1365
|
+
queryParams: { columns },
|
1165
1366
|
body: { records },
|
1166
1367
|
...this.extraProps
|
1167
1368
|
});
|
1168
1369
|
}
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
}
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
body: query,
|
1180
|
-
...this.extraProps
|
1181
|
-
});
|
1182
|
-
}
|
1183
|
-
searchBranch(workspace, database, branch, query) {
|
1184
|
-
return operationsByTag.records.searchBranch({
|
1185
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1186
|
-
body: query,
|
1370
|
+
branchTransaction({
|
1371
|
+
workspace,
|
1372
|
+
region,
|
1373
|
+
database,
|
1374
|
+
branch,
|
1375
|
+
operations
|
1376
|
+
}) {
|
1377
|
+
return operationsByTag.records.branchTransaction({
|
1378
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1379
|
+
body: { operations },
|
1187
1380
|
...this.extraProps
|
1188
1381
|
});
|
1189
1382
|
}
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
...this.extraProps
|
1195
|
-
});
|
1383
|
+
}
|
1384
|
+
class SearchAndFilterApi {
|
1385
|
+
constructor(extraProps) {
|
1386
|
+
this.extraProps = extraProps;
|
1196
1387
|
}
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1388
|
+
queryTable({
|
1389
|
+
workspace,
|
1390
|
+
region,
|
1391
|
+
database,
|
1392
|
+
branch,
|
1393
|
+
table,
|
1394
|
+
filter,
|
1395
|
+
sort,
|
1396
|
+
page,
|
1397
|
+
columns
|
1398
|
+
}) {
|
1399
|
+
return operationsByTag.searchAndFilter.queryTable({
|
1400
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1401
|
+
body: { filter, sort, page, columns },
|
1402
|
+
...this.extraProps
|
1403
|
+
});
|
1404
|
+
}
|
1405
|
+
searchTable({
|
1406
|
+
workspace,
|
1407
|
+
region,
|
1408
|
+
database,
|
1409
|
+
branch,
|
1410
|
+
table,
|
1411
|
+
query,
|
1412
|
+
fuzziness,
|
1413
|
+
target,
|
1414
|
+
prefix,
|
1415
|
+
filter,
|
1416
|
+
highlight,
|
1417
|
+
boosters
|
1418
|
+
}) {
|
1419
|
+
return operationsByTag.searchAndFilter.searchTable({
|
1420
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1421
|
+
body: { query, fuzziness, target, prefix, filter, highlight, boosters },
|
1422
|
+
...this.extraProps
|
1423
|
+
});
|
1424
|
+
}
|
1425
|
+
searchBranch({
|
1426
|
+
workspace,
|
1427
|
+
region,
|
1428
|
+
database,
|
1429
|
+
branch,
|
1430
|
+
tables,
|
1431
|
+
query,
|
1432
|
+
fuzziness,
|
1433
|
+
prefix,
|
1434
|
+
highlight
|
1435
|
+
}) {
|
1436
|
+
return operationsByTag.searchAndFilter.searchBranch({
|
1437
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1438
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
1439
|
+
...this.extraProps
|
1440
|
+
});
|
1441
|
+
}
|
1442
|
+
summarizeTable({
|
1443
|
+
workspace,
|
1444
|
+
region,
|
1445
|
+
database,
|
1446
|
+
branch,
|
1447
|
+
table,
|
1448
|
+
filter,
|
1449
|
+
columns,
|
1450
|
+
summaries,
|
1451
|
+
sort,
|
1452
|
+
summariesFilter,
|
1453
|
+
page
|
1454
|
+
}) {
|
1455
|
+
return operationsByTag.searchAndFilter.summarizeTable({
|
1456
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1457
|
+
body: { filter, columns, summaries, sort, summariesFilter, page },
|
1458
|
+
...this.extraProps
|
1459
|
+
});
|
1460
|
+
}
|
1461
|
+
aggregateTable({
|
1462
|
+
workspace,
|
1463
|
+
region,
|
1464
|
+
database,
|
1465
|
+
branch,
|
1466
|
+
table,
|
1467
|
+
filter,
|
1468
|
+
aggs
|
1469
|
+
}) {
|
1470
|
+
return operationsByTag.searchAndFilter.aggregateTable({
|
1471
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1472
|
+
body: { filter, aggs },
|
1201
1473
|
...this.extraProps
|
1202
1474
|
});
|
1203
1475
|
}
|
@@ -1206,123 +1478,281 @@ class MigrationRequestsApi {
|
|
1206
1478
|
constructor(extraProps) {
|
1207
1479
|
this.extraProps = extraProps;
|
1208
1480
|
}
|
1209
|
-
queryMigrationRequests(
|
1481
|
+
queryMigrationRequests({
|
1482
|
+
workspace,
|
1483
|
+
region,
|
1484
|
+
database,
|
1485
|
+
filter,
|
1486
|
+
sort,
|
1487
|
+
page,
|
1488
|
+
columns
|
1489
|
+
}) {
|
1210
1490
|
return operationsByTag.migrationRequests.queryMigrationRequests({
|
1211
|
-
pathParams: { workspace, dbName: database },
|
1212
|
-
body:
|
1491
|
+
pathParams: { workspace, region, dbName: database },
|
1492
|
+
body: { filter, sort, page, columns },
|
1213
1493
|
...this.extraProps
|
1214
1494
|
});
|
1215
1495
|
}
|
1216
|
-
createMigrationRequest(
|
1496
|
+
createMigrationRequest({
|
1497
|
+
workspace,
|
1498
|
+
region,
|
1499
|
+
database,
|
1500
|
+
migration
|
1501
|
+
}) {
|
1217
1502
|
return operationsByTag.migrationRequests.createMigrationRequest({
|
1218
|
-
pathParams: { workspace, dbName: database },
|
1219
|
-
body:
|
1503
|
+
pathParams: { workspace, region, dbName: database },
|
1504
|
+
body: migration,
|
1220
1505
|
...this.extraProps
|
1221
1506
|
});
|
1222
1507
|
}
|
1223
|
-
getMigrationRequest(
|
1508
|
+
getMigrationRequest({
|
1509
|
+
workspace,
|
1510
|
+
region,
|
1511
|
+
database,
|
1512
|
+
migrationRequest
|
1513
|
+
}) {
|
1224
1514
|
return operationsByTag.migrationRequests.getMigrationRequest({
|
1225
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1515
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1226
1516
|
...this.extraProps
|
1227
1517
|
});
|
1228
1518
|
}
|
1229
|
-
updateMigrationRequest(
|
1519
|
+
updateMigrationRequest({
|
1520
|
+
workspace,
|
1521
|
+
region,
|
1522
|
+
database,
|
1523
|
+
migrationRequest,
|
1524
|
+
update
|
1525
|
+
}) {
|
1230
1526
|
return operationsByTag.migrationRequests.updateMigrationRequest({
|
1231
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1232
|
-
body:
|
1527
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1528
|
+
body: update,
|
1233
1529
|
...this.extraProps
|
1234
1530
|
});
|
1235
1531
|
}
|
1236
|
-
listMigrationRequestsCommits(
|
1532
|
+
listMigrationRequestsCommits({
|
1533
|
+
workspace,
|
1534
|
+
region,
|
1535
|
+
database,
|
1536
|
+
migrationRequest,
|
1537
|
+
page
|
1538
|
+
}) {
|
1237
1539
|
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
1238
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1239
|
-
body:
|
1540
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1541
|
+
body: { page },
|
1240
1542
|
...this.extraProps
|
1241
1543
|
});
|
1242
1544
|
}
|
1243
|
-
compareMigrationRequest(
|
1545
|
+
compareMigrationRequest({
|
1546
|
+
workspace,
|
1547
|
+
region,
|
1548
|
+
database,
|
1549
|
+
migrationRequest
|
1550
|
+
}) {
|
1244
1551
|
return operationsByTag.migrationRequests.compareMigrationRequest({
|
1245
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1552
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1246
1553
|
...this.extraProps
|
1247
1554
|
});
|
1248
1555
|
}
|
1249
|
-
getMigrationRequestIsMerged(
|
1556
|
+
getMigrationRequestIsMerged({
|
1557
|
+
workspace,
|
1558
|
+
region,
|
1559
|
+
database,
|
1560
|
+
migrationRequest
|
1561
|
+
}) {
|
1250
1562
|
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
1251
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1563
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1252
1564
|
...this.extraProps
|
1253
1565
|
});
|
1254
1566
|
}
|
1255
|
-
mergeMigrationRequest(
|
1567
|
+
mergeMigrationRequest({
|
1568
|
+
workspace,
|
1569
|
+
region,
|
1570
|
+
database,
|
1571
|
+
migrationRequest
|
1572
|
+
}) {
|
1256
1573
|
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
1257
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1574
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1258
1575
|
...this.extraProps
|
1259
1576
|
});
|
1260
1577
|
}
|
1261
1578
|
}
|
1262
|
-
class
|
1579
|
+
class MigrationsApi {
|
1263
1580
|
constructor(extraProps) {
|
1264
1581
|
this.extraProps = extraProps;
|
1265
1582
|
}
|
1266
|
-
getBranchMigrationHistory(
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1583
|
+
getBranchMigrationHistory({
|
1584
|
+
workspace,
|
1585
|
+
region,
|
1586
|
+
database,
|
1587
|
+
branch,
|
1588
|
+
limit,
|
1589
|
+
startFrom
|
1590
|
+
}) {
|
1591
|
+
return operationsByTag.migrations.getBranchMigrationHistory({
|
1592
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1593
|
+
body: { limit, startFrom },
|
1594
|
+
...this.extraProps
|
1595
|
+
});
|
1596
|
+
}
|
1597
|
+
getBranchMigrationPlan({
|
1598
|
+
workspace,
|
1599
|
+
region,
|
1600
|
+
database,
|
1601
|
+
branch,
|
1602
|
+
schema
|
1603
|
+
}) {
|
1604
|
+
return operationsByTag.migrations.getBranchMigrationPlan({
|
1605
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1606
|
+
body: schema,
|
1270
1607
|
...this.extraProps
|
1271
1608
|
});
|
1272
1609
|
}
|
1273
|
-
executeBranchMigrationPlan(
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1610
|
+
executeBranchMigrationPlan({
|
1611
|
+
workspace,
|
1612
|
+
region,
|
1613
|
+
database,
|
1614
|
+
branch,
|
1615
|
+
plan
|
1616
|
+
}) {
|
1617
|
+
return operationsByTag.migrations.executeBranchMigrationPlan({
|
1618
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1619
|
+
body: plan,
|
1277
1620
|
...this.extraProps
|
1278
1621
|
});
|
1279
1622
|
}
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1623
|
+
getBranchSchemaHistory({
|
1624
|
+
workspace,
|
1625
|
+
region,
|
1626
|
+
database,
|
1627
|
+
branch,
|
1628
|
+
page
|
1629
|
+
}) {
|
1630
|
+
return operationsByTag.migrations.getBranchSchemaHistory({
|
1631
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1632
|
+
body: { page },
|
1284
1633
|
...this.extraProps
|
1285
1634
|
});
|
1286
1635
|
}
|
1287
|
-
compareBranchWithUserSchema(
|
1288
|
-
|
1289
|
-
|
1636
|
+
compareBranchWithUserSchema({
|
1637
|
+
workspace,
|
1638
|
+
region,
|
1639
|
+
database,
|
1640
|
+
branch,
|
1641
|
+
schema
|
1642
|
+
}) {
|
1643
|
+
return operationsByTag.migrations.compareBranchWithUserSchema({
|
1644
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1290
1645
|
body: { schema },
|
1291
1646
|
...this.extraProps
|
1292
1647
|
});
|
1293
1648
|
}
|
1294
|
-
compareBranchSchemas(
|
1295
|
-
|
1296
|
-
|
1649
|
+
compareBranchSchemas({
|
1650
|
+
workspace,
|
1651
|
+
region,
|
1652
|
+
database,
|
1653
|
+
branch,
|
1654
|
+
compare,
|
1655
|
+
schema
|
1656
|
+
}) {
|
1657
|
+
return operationsByTag.migrations.compareBranchSchemas({
|
1658
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
1297
1659
|
body: { schema },
|
1298
1660
|
...this.extraProps
|
1299
1661
|
});
|
1300
1662
|
}
|
1301
|
-
updateBranchSchema(
|
1302
|
-
|
1303
|
-
|
1663
|
+
updateBranchSchema({
|
1664
|
+
workspace,
|
1665
|
+
region,
|
1666
|
+
database,
|
1667
|
+
branch,
|
1668
|
+
migration
|
1669
|
+
}) {
|
1670
|
+
return operationsByTag.migrations.updateBranchSchema({
|
1671
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1304
1672
|
body: migration,
|
1305
1673
|
...this.extraProps
|
1306
1674
|
});
|
1307
1675
|
}
|
1308
|
-
previewBranchSchemaEdit(
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1676
|
+
previewBranchSchemaEdit({
|
1677
|
+
workspace,
|
1678
|
+
region,
|
1679
|
+
database,
|
1680
|
+
branch,
|
1681
|
+
data
|
1682
|
+
}) {
|
1683
|
+
return operationsByTag.migrations.previewBranchSchemaEdit({
|
1684
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1685
|
+
body: data,
|
1312
1686
|
...this.extraProps
|
1313
1687
|
});
|
1314
1688
|
}
|
1315
|
-
applyBranchSchemaEdit(
|
1316
|
-
|
1317
|
-
|
1689
|
+
applyBranchSchemaEdit({
|
1690
|
+
workspace,
|
1691
|
+
region,
|
1692
|
+
database,
|
1693
|
+
branch,
|
1694
|
+
edits
|
1695
|
+
}) {
|
1696
|
+
return operationsByTag.migrations.applyBranchSchemaEdit({
|
1697
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1318
1698
|
body: { edits },
|
1319
1699
|
...this.extraProps
|
1320
1700
|
});
|
1321
1701
|
}
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1702
|
+
}
|
1703
|
+
class DatabaseApi {
|
1704
|
+
constructor(extraProps) {
|
1705
|
+
this.extraProps = extraProps;
|
1706
|
+
}
|
1707
|
+
getDatabaseList({ workspace }) {
|
1708
|
+
return operationsByTag.databases.getDatabaseList({
|
1709
|
+
pathParams: { workspaceId: workspace },
|
1710
|
+
...this.extraProps
|
1711
|
+
});
|
1712
|
+
}
|
1713
|
+
createDatabase({
|
1714
|
+
workspace,
|
1715
|
+
database,
|
1716
|
+
data
|
1717
|
+
}) {
|
1718
|
+
return operationsByTag.databases.createDatabase({
|
1719
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1720
|
+
body: data,
|
1721
|
+
...this.extraProps
|
1722
|
+
});
|
1723
|
+
}
|
1724
|
+
deleteDatabase({
|
1725
|
+
workspace,
|
1726
|
+
database
|
1727
|
+
}) {
|
1728
|
+
return operationsByTag.databases.deleteDatabase({
|
1729
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1730
|
+
...this.extraProps
|
1731
|
+
});
|
1732
|
+
}
|
1733
|
+
getDatabaseMetadata({
|
1734
|
+
workspace,
|
1735
|
+
database
|
1736
|
+
}) {
|
1737
|
+
return operationsByTag.databases.getDatabaseMetadata({
|
1738
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1739
|
+
...this.extraProps
|
1740
|
+
});
|
1741
|
+
}
|
1742
|
+
updateDatabaseMetadata({
|
1743
|
+
workspace,
|
1744
|
+
database,
|
1745
|
+
metadata
|
1746
|
+
}) {
|
1747
|
+
return operationsByTag.databases.updateDatabaseMetadata({
|
1748
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1749
|
+
body: metadata,
|
1750
|
+
...this.extraProps
|
1751
|
+
});
|
1752
|
+
}
|
1753
|
+
listRegions({ workspace }) {
|
1754
|
+
return operationsByTag.databases.listRegions({
|
1755
|
+
pathParams: { workspaceId: workspace },
|
1326
1756
|
...this.extraProps
|
1327
1757
|
});
|
1328
1758
|
}
|
@@ -1338,6 +1768,20 @@ class XataApiPlugin {
|
|
1338
1768
|
class XataPlugin {
|
1339
1769
|
}
|
1340
1770
|
|
1771
|
+
function generateUUID() {
|
1772
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
1773
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
1774
|
+
return v.toString(16);
|
1775
|
+
});
|
1776
|
+
}
|
1777
|
+
|
1778
|
+
function cleanFilter(filter) {
|
1779
|
+
if (!filter)
|
1780
|
+
return void 0;
|
1781
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
1782
|
+
return values.length > 0 ? filter : void 0;
|
1783
|
+
}
|
1784
|
+
|
1341
1785
|
var __accessCheck$6 = (obj, member, msg) => {
|
1342
1786
|
if (!member.has(obj))
|
1343
1787
|
throw TypeError("Cannot " + msg);
|
@@ -1477,7 +1921,7 @@ const _Query = class {
|
|
1477
1921
|
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
1478
1922
|
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
1479
1923
|
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
1480
|
-
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns
|
1924
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
|
1481
1925
|
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
1482
1926
|
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
1483
1927
|
this.any = this.any.bind(this);
|
@@ -1593,6 +2037,16 @@ const _Query = class {
|
|
1593
2037
|
throw new Error("No results found.");
|
1594
2038
|
return records[0];
|
1595
2039
|
}
|
2040
|
+
async summarize(params = {}) {
|
2041
|
+
const { summaries, summariesFilter, ...options } = params;
|
2042
|
+
const query = new _Query(
|
2043
|
+
__privateGet$5(this, _repository),
|
2044
|
+
__privateGet$5(this, _table$1),
|
2045
|
+
options,
|
2046
|
+
__privateGet$5(this, _data)
|
2047
|
+
);
|
2048
|
+
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
2049
|
+
}
|
1596
2050
|
cache(ttl) {
|
1597
2051
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1598
2052
|
}
|
@@ -1629,7 +2083,7 @@ cleanFilterConstraint_fn = function(column, value) {
|
|
1629
2083
|
};
|
1630
2084
|
function cleanParent(data, parent) {
|
1631
2085
|
if (isCursorPaginationOptions(data.pagination)) {
|
1632
|
-
return { ...parent,
|
2086
|
+
return { ...parent, sort: void 0, filter: void 0 };
|
1633
2087
|
}
|
1634
2088
|
return parent;
|
1635
2089
|
}
|
@@ -1688,7 +2142,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
1688
2142
|
__accessCheck$4(obj, member, "access private method");
|
1689
2143
|
return method;
|
1690
2144
|
};
|
1691
|
-
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
|
2145
|
+
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _deleteRecords, deleteRecords_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
|
1692
2146
|
class Repository extends Query {
|
1693
2147
|
}
|
1694
2148
|
class RestRepository extends Query {
|
@@ -1704,6 +2158,7 @@ class RestRepository extends Query {
|
|
1704
2158
|
__privateAdd$4(this, _updateRecordWithID);
|
1705
2159
|
__privateAdd$4(this, _upsertRecordWithID);
|
1706
2160
|
__privateAdd$4(this, _deleteRecord);
|
2161
|
+
__privateAdd$4(this, _deleteRecords);
|
1707
2162
|
__privateAdd$4(this, _setCacheQuery);
|
1708
2163
|
__privateAdd$4(this, _getCacheQuery);
|
1709
2164
|
__privateAdd$4(this, _getSchemaTables$1);
|
@@ -1714,10 +2169,13 @@ class RestRepository extends Query {
|
|
1714
2169
|
__privateAdd$4(this, _schemaTables$2, void 0);
|
1715
2170
|
__privateAdd$4(this, _trace, void 0);
|
1716
2171
|
__privateSet$4(this, _table, options.table);
|
1717
|
-
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1718
2172
|
__privateSet$4(this, _db, options.db);
|
1719
2173
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
1720
2174
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
2175
|
+
__privateSet$4(this, _getFetchProps, async () => {
|
2176
|
+
const props = await options.pluginOptions.getFetchProps();
|
2177
|
+
return { ...props, sessionID: generateUUID() };
|
2178
|
+
});
|
1721
2179
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
1722
2180
|
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
1723
2181
|
return trace(name, fn, {
|
@@ -1728,8 +2186,9 @@ class RestRepository extends Query {
|
|
1728
2186
|
});
|
1729
2187
|
});
|
1730
2188
|
}
|
1731
|
-
async create(a, b, c) {
|
2189
|
+
async create(a, b, c, d) {
|
1732
2190
|
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
2191
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1733
2192
|
if (Array.isArray(a)) {
|
1734
2193
|
if (a.length === 0)
|
1735
2194
|
return [];
|
@@ -1740,13 +2199,13 @@ class RestRepository extends Query {
|
|
1740
2199
|
if (a === "")
|
1741
2200
|
throw new Error("The id can't be empty");
|
1742
2201
|
const columns = isStringArray(c) ? c : void 0;
|
1743
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
2202
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
1744
2203
|
}
|
1745
2204
|
if (isObject(a) && isString(a.id)) {
|
1746
2205
|
if (a.id === "")
|
1747
2206
|
throw new Error("The id can't be empty");
|
1748
2207
|
const columns = isStringArray(b) ? b : void 0;
|
1749
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
2208
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
1750
2209
|
}
|
1751
2210
|
if (isObject(a)) {
|
1752
2211
|
const columns = isStringArray(b) ? b : void 0;
|
@@ -1777,6 +2236,7 @@ class RestRepository extends Query {
|
|
1777
2236
|
pathParams: {
|
1778
2237
|
workspace: "{workspaceId}",
|
1779
2238
|
dbBranchName: "{dbBranch}",
|
2239
|
+
region: "{region}",
|
1780
2240
|
tableName: __privateGet$4(this, _table),
|
1781
2241
|
recordId: id
|
1782
2242
|
},
|
@@ -1814,8 +2274,9 @@ class RestRepository extends Query {
|
|
1814
2274
|
return result;
|
1815
2275
|
});
|
1816
2276
|
}
|
1817
|
-
async update(a, b, c) {
|
2277
|
+
async update(a, b, c, d) {
|
1818
2278
|
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
2279
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1819
2280
|
if (Array.isArray(a)) {
|
1820
2281
|
if (a.length === 0)
|
1821
2282
|
return [];
|
@@ -1827,18 +2288,18 @@ class RestRepository extends Query {
|
|
1827
2288
|
}
|
1828
2289
|
if (isString(a) && isObject(b)) {
|
1829
2290
|
const columns = isStringArray(c) ? c : void 0;
|
1830
|
-
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
|
2291
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
1831
2292
|
}
|
1832
2293
|
if (isObject(a) && isString(a.id)) {
|
1833
2294
|
const columns = isStringArray(b) ? b : void 0;
|
1834
|
-
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
2295
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
1835
2296
|
}
|
1836
2297
|
throw new Error("Invalid arguments for update method");
|
1837
2298
|
});
|
1838
2299
|
}
|
1839
|
-
async updateOrThrow(a, b, c) {
|
2300
|
+
async updateOrThrow(a, b, c, d) {
|
1840
2301
|
return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
|
1841
|
-
const result = await this.update(a, b, c);
|
2302
|
+
const result = await this.update(a, b, c, d);
|
1842
2303
|
if (Array.isArray(result)) {
|
1843
2304
|
const missingIds = compact(
|
1844
2305
|
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
@@ -1855,8 +2316,9 @@ class RestRepository extends Query {
|
|
1855
2316
|
return result;
|
1856
2317
|
});
|
1857
2318
|
}
|
1858
|
-
async createOrUpdate(a, b, c) {
|
2319
|
+
async createOrUpdate(a, b, c, d) {
|
1859
2320
|
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
2321
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1860
2322
|
if (Array.isArray(a)) {
|
1861
2323
|
if (a.length === 0)
|
1862
2324
|
return [];
|
@@ -1868,24 +2330,48 @@ class RestRepository extends Query {
|
|
1868
2330
|
}
|
1869
2331
|
if (isString(a) && isObject(b)) {
|
1870
2332
|
const columns = isStringArray(c) ? c : void 0;
|
1871
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
|
2333
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
1872
2334
|
}
|
1873
2335
|
if (isObject(a) && isString(a.id)) {
|
1874
2336
|
const columns = isStringArray(c) ? c : void 0;
|
1875
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
2337
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
1876
2338
|
}
|
1877
2339
|
throw new Error("Invalid arguments for createOrUpdate method");
|
1878
2340
|
});
|
1879
2341
|
}
|
2342
|
+
async createOrReplace(a, b, c, d) {
|
2343
|
+
return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
|
2344
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2345
|
+
if (Array.isArray(a)) {
|
2346
|
+
if (a.length === 0)
|
2347
|
+
return [];
|
2348
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2349
|
+
return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
|
2350
|
+
}
|
2351
|
+
if (isString(a) && isObject(b)) {
|
2352
|
+
const columns = isStringArray(c) ? c : void 0;
|
2353
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
2354
|
+
}
|
2355
|
+
if (isObject(a) && isString(a.id)) {
|
2356
|
+
const columns = isStringArray(c) ? c : void 0;
|
2357
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
2358
|
+
}
|
2359
|
+
throw new Error("Invalid arguments for createOrReplace method");
|
2360
|
+
});
|
2361
|
+
}
|
1880
2362
|
async delete(a, b) {
|
1881
2363
|
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
1882
2364
|
if (Array.isArray(a)) {
|
1883
2365
|
if (a.length === 0)
|
1884
2366
|
return [];
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
2367
|
+
const ids = a.map((o) => {
|
2368
|
+
if (isString(o))
|
2369
|
+
return o;
|
2370
|
+
if (isString(o.id))
|
2371
|
+
return o.id;
|
2372
|
+
throw new Error("Invalid arguments for delete method");
|
2373
|
+
});
|
2374
|
+
return __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids, b);
|
1889
2375
|
}
|
1890
2376
|
if (isString(a)) {
|
1891
2377
|
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
|
@@ -1918,7 +2404,12 @@ class RestRepository extends Query {
|
|
1918
2404
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
1919
2405
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1920
2406
|
const { records } = await searchTable({
|
1921
|
-
pathParams: {
|
2407
|
+
pathParams: {
|
2408
|
+
workspace: "{workspaceId}",
|
2409
|
+
dbBranchName: "{dbBranch}",
|
2410
|
+
region: "{region}",
|
2411
|
+
tableName: __privateGet$4(this, _table)
|
2412
|
+
},
|
1922
2413
|
body: {
|
1923
2414
|
query,
|
1924
2415
|
fuzziness: options.fuzziness,
|
@@ -1937,7 +2428,12 @@ class RestRepository extends Query {
|
|
1937
2428
|
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
1938
2429
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1939
2430
|
const result = await aggregateTable({
|
1940
|
-
pathParams: {
|
2431
|
+
pathParams: {
|
2432
|
+
workspace: "{workspaceId}",
|
2433
|
+
dbBranchName: "{dbBranch}",
|
2434
|
+
region: "{region}",
|
2435
|
+
tableName: __privateGet$4(this, _table)
|
2436
|
+
},
|
1941
2437
|
body: { aggs, filter },
|
1942
2438
|
...fetchProps
|
1943
2439
|
});
|
@@ -1950,16 +2446,20 @@ class RestRepository extends Query {
|
|
1950
2446
|
if (cacheQuery)
|
1951
2447
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
1952
2448
|
const data = query.getQueryOptions();
|
1953
|
-
const body = {
|
1954
|
-
filter: cleanFilter(data.filter),
|
1955
|
-
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1956
|
-
page: data.pagination,
|
1957
|
-
columns: data.columns
|
1958
|
-
};
|
1959
2449
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1960
2450
|
const { meta, records: objects } = await queryTable({
|
1961
|
-
pathParams: {
|
1962
|
-
|
2451
|
+
pathParams: {
|
2452
|
+
workspace: "{workspaceId}",
|
2453
|
+
dbBranchName: "{dbBranch}",
|
2454
|
+
region: "{region}",
|
2455
|
+
tableName: __privateGet$4(this, _table)
|
2456
|
+
},
|
2457
|
+
body: {
|
2458
|
+
filter: cleanFilter(data.filter),
|
2459
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2460
|
+
page: data.pagination,
|
2461
|
+
columns: data.columns ?? ["*"]
|
2462
|
+
},
|
1963
2463
|
...fetchProps
|
1964
2464
|
});
|
1965
2465
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
@@ -1970,6 +2470,30 @@ class RestRepository extends Query {
|
|
1970
2470
|
return new Page(query, meta, records);
|
1971
2471
|
});
|
1972
2472
|
}
|
2473
|
+
async summarizeTable(query, summaries, summariesFilter) {
|
2474
|
+
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
2475
|
+
const data = query.getQueryOptions();
|
2476
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2477
|
+
const result = await summarizeTable({
|
2478
|
+
pathParams: {
|
2479
|
+
workspace: "{workspaceId}",
|
2480
|
+
dbBranchName: "{dbBranch}",
|
2481
|
+
region: "{region}",
|
2482
|
+
tableName: __privateGet$4(this, _table)
|
2483
|
+
},
|
2484
|
+
body: {
|
2485
|
+
filter: cleanFilter(data.filter),
|
2486
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2487
|
+
columns: data.columns,
|
2488
|
+
page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
|
2489
|
+
summaries,
|
2490
|
+
summariesFilter
|
2491
|
+
},
|
2492
|
+
...fetchProps
|
2493
|
+
});
|
2494
|
+
return result;
|
2495
|
+
});
|
2496
|
+
}
|
1973
2497
|
}
|
1974
2498
|
_table = new WeakMap();
|
1975
2499
|
_getFetchProps = new WeakMap();
|
@@ -1985,6 +2509,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1985
2509
|
pathParams: {
|
1986
2510
|
workspace: "{workspaceId}",
|
1987
2511
|
dbBranchName: "{dbBranch}",
|
2512
|
+
region: "{region}",
|
1988
2513
|
tableName: __privateGet$4(this, _table)
|
1989
2514
|
},
|
1990
2515
|
queryParams: { columns },
|
@@ -1995,18 +2520,19 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1995
2520
|
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1996
2521
|
};
|
1997
2522
|
_insertRecordWithId = new WeakSet();
|
1998
|
-
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
2523
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
1999
2524
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2000
2525
|
const record = transformObjectLinks(object);
|
2001
2526
|
const response = await insertRecordWithID({
|
2002
2527
|
pathParams: {
|
2003
2528
|
workspace: "{workspaceId}",
|
2004
2529
|
dbBranchName: "{dbBranch}",
|
2530
|
+
region: "{region}",
|
2005
2531
|
tableName: __privateGet$4(this, _table),
|
2006
2532
|
recordId
|
2007
2533
|
},
|
2008
2534
|
body: record,
|
2009
|
-
queryParams: { createOnly
|
2535
|
+
queryParams: { createOnly, columns, ifVersion },
|
2010
2536
|
...fetchProps
|
2011
2537
|
});
|
2012
2538
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
@@ -2017,7 +2543,12 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
|
2017
2543
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2018
2544
|
const records = objects.map((object) => transformObjectLinks(object));
|
2019
2545
|
const response = await bulkInsertTableRecords({
|
2020
|
-
pathParams: {
|
2546
|
+
pathParams: {
|
2547
|
+
workspace: "{workspaceId}",
|
2548
|
+
dbBranchName: "{dbBranch}",
|
2549
|
+
region: "{region}",
|
2550
|
+
tableName: __privateGet$4(this, _table)
|
2551
|
+
},
|
2021
2552
|
queryParams: { columns },
|
2022
2553
|
body: { records },
|
2023
2554
|
...fetchProps
|
@@ -2029,13 +2560,19 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
|
2029
2560
|
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
|
2030
2561
|
};
|
2031
2562
|
_updateRecordWithID = new WeakSet();
|
2032
|
-
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2563
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
2033
2564
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2034
2565
|
const record = transformObjectLinks(object);
|
2035
2566
|
try {
|
2036
2567
|
const response = await updateRecordWithID({
|
2037
|
-
pathParams: {
|
2038
|
-
|
2568
|
+
pathParams: {
|
2569
|
+
workspace: "{workspaceId}",
|
2570
|
+
dbBranchName: "{dbBranch}",
|
2571
|
+
region: "{region}",
|
2572
|
+
tableName: __privateGet$4(this, _table),
|
2573
|
+
recordId
|
2574
|
+
},
|
2575
|
+
queryParams: { columns, ifVersion },
|
2039
2576
|
body: record,
|
2040
2577
|
...fetchProps
|
2041
2578
|
});
|
@@ -2049,11 +2586,17 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
2049
2586
|
}
|
2050
2587
|
};
|
2051
2588
|
_upsertRecordWithID = new WeakSet();
|
2052
|
-
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2589
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
2053
2590
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2054
2591
|
const response = await upsertRecordWithID({
|
2055
|
-
pathParams: {
|
2056
|
-
|
2592
|
+
pathParams: {
|
2593
|
+
workspace: "{workspaceId}",
|
2594
|
+
dbBranchName: "{dbBranch}",
|
2595
|
+
region: "{region}",
|
2596
|
+
tableName: __privateGet$4(this, _table),
|
2597
|
+
recordId
|
2598
|
+
},
|
2599
|
+
queryParams: { columns, ifVersion },
|
2057
2600
|
body: object,
|
2058
2601
|
...fetchProps
|
2059
2602
|
});
|
@@ -2065,7 +2608,13 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
2065
2608
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2066
2609
|
try {
|
2067
2610
|
const response = await deleteRecord({
|
2068
|
-
pathParams: {
|
2611
|
+
pathParams: {
|
2612
|
+
workspace: "{workspaceId}",
|
2613
|
+
dbBranchName: "{dbBranch}",
|
2614
|
+
region: "{region}",
|
2615
|
+
tableName: __privateGet$4(this, _table),
|
2616
|
+
recordId
|
2617
|
+
},
|
2069
2618
|
queryParams: { columns },
|
2070
2619
|
...fetchProps
|
2071
2620
|
});
|
@@ -2078,6 +2627,29 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
2078
2627
|
throw e;
|
2079
2628
|
}
|
2080
2629
|
};
|
2630
|
+
_deleteRecords = new WeakSet();
|
2631
|
+
deleteRecords_fn = async function(recordIds, columns = ["*"]) {
|
2632
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2633
|
+
const operations = recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } }));
|
2634
|
+
try {
|
2635
|
+
const objects = await this.read(recordIds, columns);
|
2636
|
+
await branchTransaction({
|
2637
|
+
pathParams: {
|
2638
|
+
workspace: "{workspaceId}",
|
2639
|
+
dbBranchName: "{dbBranch}",
|
2640
|
+
region: "{region}"
|
2641
|
+
},
|
2642
|
+
body: { operations },
|
2643
|
+
...fetchProps
|
2644
|
+
});
|
2645
|
+
return objects;
|
2646
|
+
} catch (e) {
|
2647
|
+
if (isObject(e) && e.status === 404) {
|
2648
|
+
return null;
|
2649
|
+
}
|
2650
|
+
throw e;
|
2651
|
+
}
|
2652
|
+
};
|
2081
2653
|
_setCacheQuery = new WeakSet();
|
2082
2654
|
setCacheQuery_fn = async function(query, meta, records) {
|
2083
2655
|
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
@@ -2100,7 +2672,7 @@ getSchemaTables_fn$1 = async function() {
|
|
2100
2672
|
return __privateGet$4(this, _schemaTables$2);
|
2101
2673
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2102
2674
|
const { schema } = await getBranchDetails({
|
2103
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2675
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2104
2676
|
...fetchProps
|
2105
2677
|
});
|
2106
2678
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
@@ -2166,8 +2738,15 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2166
2738
|
result.read = function(columns2) {
|
2167
2739
|
return db[table].read(result["id"], columns2);
|
2168
2740
|
};
|
2169
|
-
result.update = function(data,
|
2170
|
-
|
2741
|
+
result.update = function(data, b, c) {
|
2742
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2743
|
+
const ifVersion = parseIfVersion(b, c);
|
2744
|
+
return db[table].update(result["id"], data, columns2, { ifVersion });
|
2745
|
+
};
|
2746
|
+
result.replace = function(data, b, c) {
|
2747
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2748
|
+
const ifVersion = parseIfVersion(b, c);
|
2749
|
+
return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
|
2171
2750
|
};
|
2172
2751
|
result.delete = function() {
|
2173
2752
|
return db[table].delete(result["id"]);
|
@@ -2175,7 +2754,7 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2175
2754
|
result.getMetadata = function() {
|
2176
2755
|
return xata;
|
2177
2756
|
};
|
2178
|
-
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
2757
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
|
2179
2758
|
Object.defineProperty(result, prop, { enumerable: false });
|
2180
2759
|
}
|
2181
2760
|
Object.freeze(result);
|
@@ -2191,12 +2770,6 @@ function extractId(value) {
|
|
2191
2770
|
return value.id;
|
2192
2771
|
return void 0;
|
2193
2772
|
}
|
2194
|
-
function cleanFilter(filter) {
|
2195
|
-
if (!filter)
|
2196
|
-
return void 0;
|
2197
|
-
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
2198
|
-
return values.length > 0 ? filter : void 0;
|
2199
|
-
}
|
2200
2773
|
function isValidColumn(columns, column) {
|
2201
2774
|
if (columns.includes("*"))
|
2202
2775
|
return true;
|
@@ -2206,6 +2779,14 @@ function isValidColumn(columns, column) {
|
|
2206
2779
|
}
|
2207
2780
|
return columns.includes(column.name);
|
2208
2781
|
}
|
2782
|
+
function parseIfVersion(...args) {
|
2783
|
+
for (const arg of args) {
|
2784
|
+
if (isObject(arg) && isNumber(arg.ifVersion)) {
|
2785
|
+
return arg.ifVersion;
|
2786
|
+
}
|
2787
|
+
}
|
2788
|
+
return void 0;
|
2789
|
+
}
|
2209
2790
|
|
2210
2791
|
var __accessCheck$3 = (obj, member, msg) => {
|
2211
2792
|
if (!member.has(obj))
|
@@ -2393,7 +2974,7 @@ search_fn = async function(query, options, getFetchProps) {
|
|
2393
2974
|
const fetchProps = await getFetchProps();
|
2394
2975
|
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
2395
2976
|
const { records } = await searchBranch({
|
2396
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2977
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2397
2978
|
body: { tables, query, fuzziness, prefix, highlight },
|
2398
2979
|
...fetchProps
|
2399
2980
|
});
|
@@ -2405,7 +2986,7 @@ getSchemaTables_fn = async function(getFetchProps) {
|
|
2405
2986
|
return __privateGet$1(this, _schemaTables);
|
2406
2987
|
const fetchProps = await getFetchProps();
|
2407
2988
|
const { schema } = await getBranchDetails({
|
2408
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2989
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2409
2990
|
...fetchProps
|
2410
2991
|
});
|
2411
2992
|
__privateSet$1(this, _schemaTables, schema.tables);
|
@@ -2443,14 +3024,17 @@ async function resolveXataBranch(gitBranch, options) {
|
|
2443
3024
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2444
3025
|
);
|
2445
3026
|
const [protocol, , host, , dbName] = databaseURL.split("/");
|
2446
|
-
const
|
3027
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
3028
|
+
if (!urlParts)
|
3029
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3030
|
+
const { workspace, region } = urlParts;
|
2447
3031
|
const { fallbackBranch } = getEnvironment();
|
2448
3032
|
const { branch } = await resolveBranch({
|
2449
3033
|
apiKey,
|
2450
3034
|
apiUrl: databaseURL,
|
2451
3035
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2452
3036
|
workspacesApiUrl: `${protocol}//${host}`,
|
2453
|
-
pathParams: { dbName, workspace },
|
3037
|
+
pathParams: { dbName, workspace, region },
|
2454
3038
|
queryParams: { gitBranch, fallbackBranch },
|
2455
3039
|
trace: defaultTrace
|
2456
3040
|
});
|
@@ -2468,15 +3052,17 @@ async function getDatabaseBranch(branch, options) {
|
|
2468
3052
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2469
3053
|
);
|
2470
3054
|
const [protocol, , host, , database] = databaseURL.split("/");
|
2471
|
-
const
|
2472
|
-
|
3055
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
3056
|
+
if (!urlParts)
|
3057
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3058
|
+
const { workspace, region } = urlParts;
|
2473
3059
|
try {
|
2474
3060
|
return await getBranchDetails({
|
2475
3061
|
apiKey,
|
2476
3062
|
apiUrl: databaseURL,
|
2477
3063
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2478
3064
|
workspacesApiUrl: `${protocol}//${host}`,
|
2479
|
-
pathParams: { dbBranchName
|
3065
|
+
pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
|
2480
3066
|
trace: defaultTrace
|
2481
3067
|
});
|
2482
3068
|
} catch (err) {
|
@@ -2567,8 +3153,8 @@ const buildClient = (plugins) => {
|
|
2567
3153
|
if (!databaseURL) {
|
2568
3154
|
throw new Error("Option databaseURL is required");
|
2569
3155
|
}
|
2570
|
-
return { fetch, databaseURL, apiKey, branch, cache, trace };
|
2571
|
-
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
|
3156
|
+
return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID() };
|
3157
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
|
2572
3158
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
2573
3159
|
if (!branchValue)
|
2574
3160
|
throw new Error("Unable to resolve branch value");
|
@@ -2581,7 +3167,8 @@ const buildClient = (plugins) => {
|
|
2581
3167
|
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
|
2582
3168
|
return databaseURL + newPath;
|
2583
3169
|
},
|
2584
|
-
trace
|
3170
|
+
trace,
|
3171
|
+
clientID
|
2585
3172
|
};
|
2586
3173
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
2587
3174
|
if (__privateGet(this, _branch))
|
@@ -2717,6 +3304,7 @@ exports.addGitBranchesEntry = addGitBranchesEntry;
|
|
2717
3304
|
exports.addTableColumn = addTableColumn;
|
2718
3305
|
exports.aggregateTable = aggregateTable;
|
2719
3306
|
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
3307
|
+
exports.branchTransaction = branchTransaction;
|
2720
3308
|
exports.buildClient = buildClient;
|
2721
3309
|
exports.buildWorkerRunner = buildWorkerRunner;
|
2722
3310
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
@@ -2731,6 +3319,11 @@ exports.createMigrationRequest = createMigrationRequest;
|
|
2731
3319
|
exports.createTable = createTable;
|
2732
3320
|
exports.createUserAPIKey = createUserAPIKey;
|
2733
3321
|
exports.createWorkspace = createWorkspace;
|
3322
|
+
exports.dEPRECATEDcreateDatabase = dEPRECATEDcreateDatabase;
|
3323
|
+
exports.dEPRECATEDdeleteDatabase = dEPRECATEDdeleteDatabase;
|
3324
|
+
exports.dEPRECATEDgetDatabaseList = dEPRECATEDgetDatabaseList;
|
3325
|
+
exports.dEPRECATEDgetDatabaseMetadata = dEPRECATEDgetDatabaseMetadata;
|
3326
|
+
exports.dEPRECATEDupdateDatabaseMetadata = dEPRECATEDupdateDatabaseMetadata;
|
2734
3327
|
exports.deleteBranch = deleteBranch;
|
2735
3328
|
exports.deleteColumn = deleteColumn;
|
2736
3329
|
exports.deleteDatabase = deleteDatabase;
|
@@ -2795,12 +3388,14 @@ exports.lessEquals = lessEquals;
|
|
2795
3388
|
exports.lessThan = lessThan;
|
2796
3389
|
exports.lessThanEquals = lessThanEquals;
|
2797
3390
|
exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
|
3391
|
+
exports.listRegions = listRegions;
|
2798
3392
|
exports.lt = lt;
|
2799
3393
|
exports.lte = lte;
|
2800
3394
|
exports.mergeMigrationRequest = mergeMigrationRequest;
|
2801
3395
|
exports.notExists = notExists;
|
2802
3396
|
exports.operationsByTag = operationsByTag;
|
2803
3397
|
exports.parseProviderString = parseProviderString;
|
3398
|
+
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
2804
3399
|
exports.pattern = pattern;
|
2805
3400
|
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
2806
3401
|
exports.queryMigrationRequests = queryMigrationRequests;
|