@xata.io/client 0.0.0-alpha.vf683143 → 0.0.0-alpha.vf6a5dcf
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 +88 -0
- package/README.md +5 -5
- package/dist/index.cjs +1276 -600
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4000 -1627
- package/dist/index.mjs +1263 -600
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- /package/{rollup.config.js → rollup.config.mjs} +0 -0
package/dist/index.mjs
CHANGED
@@ -38,6 +38,9 @@ function isString(value) {
|
|
38
38
|
function isStringArray(value) {
|
39
39
|
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
40
40
|
}
|
41
|
+
function isNumber(value) {
|
42
|
+
return isDefined(value) && typeof value === "number";
|
43
|
+
}
|
41
44
|
function toBase64(value) {
|
42
45
|
try {
|
43
46
|
return btoa(value);
|
@@ -46,6 +49,17 @@ function toBase64(value) {
|
|
46
49
|
return buf.from(value).toString("base64");
|
47
50
|
}
|
48
51
|
}
|
52
|
+
function deepMerge(a, b) {
|
53
|
+
const result = { ...a };
|
54
|
+
for (const [key, value] of Object.entries(b)) {
|
55
|
+
if (isObject(value) && isObject(result[key])) {
|
56
|
+
result[key] = deepMerge(result[key], value);
|
57
|
+
} else {
|
58
|
+
result[key] = value;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
return result;
|
62
|
+
}
|
49
63
|
|
50
64
|
function getEnvironment() {
|
51
65
|
try {
|
@@ -150,7 +164,7 @@ function getFetchImplementation(userFetch) {
|
|
150
164
|
return fetchImpl;
|
151
165
|
}
|
152
166
|
|
153
|
-
const VERSION = "0.0.0-alpha.
|
167
|
+
const VERSION = "0.0.0-alpha.vf6a5dcf";
|
154
168
|
|
155
169
|
class ErrorWithCause extends Error {
|
156
170
|
constructor(message, options) {
|
@@ -207,15 +221,18 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
207
221
|
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
208
222
|
};
|
209
223
|
function buildBaseUrl({
|
224
|
+
endpoint,
|
210
225
|
path,
|
211
226
|
workspacesApiUrl,
|
212
227
|
apiUrl,
|
213
|
-
pathParams
|
228
|
+
pathParams = {}
|
214
229
|
}) {
|
215
|
-
if (
|
216
|
-
|
217
|
-
|
218
|
-
|
230
|
+
if (endpoint === "dataPlane") {
|
231
|
+
const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
232
|
+
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
233
|
+
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
234
|
+
}
|
235
|
+
return `${apiUrl}${path}`;
|
219
236
|
}
|
220
237
|
function hostHeader(url) {
|
221
238
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
@@ -231,14 +248,18 @@ async function fetch$1({
|
|
231
248
|
queryParams,
|
232
249
|
fetchImpl,
|
233
250
|
apiKey,
|
251
|
+
endpoint,
|
234
252
|
apiUrl,
|
235
253
|
workspacesApiUrl,
|
236
|
-
trace
|
254
|
+
trace,
|
255
|
+
signal,
|
256
|
+
clientID,
|
257
|
+
sessionID
|
237
258
|
}) {
|
238
259
|
return trace(
|
239
260
|
`${method.toUpperCase()} ${path}`,
|
240
261
|
async ({ setAttributes }) => {
|
241
|
-
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
262
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
242
263
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
243
264
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
244
265
|
setAttributes({
|
@@ -251,10 +272,13 @@ async function fetch$1({
|
|
251
272
|
headers: {
|
252
273
|
"Content-Type": "application/json",
|
253
274
|
"User-Agent": `Xata client-ts/${VERSION}`,
|
275
|
+
"X-Xata-Client-ID": clientID ?? "",
|
276
|
+
"X-Xata-Session-ID": sessionID ?? "",
|
254
277
|
...headers,
|
255
278
|
...hostHeader(fullUrl),
|
256
279
|
Authorization: `Bearer ${apiKey}`
|
257
|
-
}
|
280
|
+
},
|
281
|
+
signal
|
258
282
|
});
|
259
283
|
if (response.status === 204) {
|
260
284
|
return {};
|
@@ -290,278 +314,163 @@ function parseUrl(url) {
|
|
290
314
|
}
|
291
315
|
}
|
292
316
|
|
293
|
-
const
|
294
|
-
|
295
|
-
const
|
296
|
-
const
|
297
|
-
url: "/user/keys",
|
298
|
-
method: "get",
|
299
|
-
...variables
|
300
|
-
});
|
301
|
-
const createUserAPIKey = (variables) => fetch$1({
|
302
|
-
url: "/user/keys/{keyName}",
|
303
|
-
method: "post",
|
304
|
-
...variables
|
305
|
-
});
|
306
|
-
const deleteUserAPIKey = (variables) => fetch$1({
|
307
|
-
url: "/user/keys/{keyName}",
|
308
|
-
method: "delete",
|
309
|
-
...variables
|
310
|
-
});
|
311
|
-
const createWorkspace = (variables) => fetch$1({
|
312
|
-
url: "/workspaces",
|
313
|
-
method: "post",
|
314
|
-
...variables
|
315
|
-
});
|
316
|
-
const getWorkspacesList = (variables) => fetch$1({
|
317
|
-
url: "/workspaces",
|
318
|
-
method: "get",
|
319
|
-
...variables
|
320
|
-
});
|
321
|
-
const getWorkspace = (variables) => fetch$1({
|
322
|
-
url: "/workspaces/{workspaceId}",
|
323
|
-
method: "get",
|
324
|
-
...variables
|
325
|
-
});
|
326
|
-
const updateWorkspace = (variables) => fetch$1({
|
327
|
-
url: "/workspaces/{workspaceId}",
|
328
|
-
method: "put",
|
329
|
-
...variables
|
330
|
-
});
|
331
|
-
const deleteWorkspace = (variables) => fetch$1({
|
332
|
-
url: "/workspaces/{workspaceId}",
|
333
|
-
method: "delete",
|
334
|
-
...variables
|
335
|
-
});
|
336
|
-
const getWorkspaceMembersList = (variables) => fetch$1({
|
337
|
-
url: "/workspaces/{workspaceId}/members",
|
338
|
-
method: "get",
|
339
|
-
...variables
|
340
|
-
});
|
341
|
-
const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
|
342
|
-
const removeWorkspaceMember = (variables) => fetch$1({
|
343
|
-
url: "/workspaces/{workspaceId}/members/{userId}",
|
344
|
-
method: "delete",
|
345
|
-
...variables
|
346
|
-
});
|
347
|
-
const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
|
348
|
-
const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
|
349
|
-
const cancelWorkspaceMemberInvite = (variables) => fetch$1({
|
350
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
351
|
-
method: "delete",
|
352
|
-
...variables
|
353
|
-
});
|
354
|
-
const resendWorkspaceMemberInvite = (variables) => fetch$1({
|
355
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
|
356
|
-
method: "post",
|
357
|
-
...variables
|
358
|
-
});
|
359
|
-
const acceptWorkspaceMemberInvite = (variables) => fetch$1({
|
360
|
-
url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
|
361
|
-
method: "post",
|
362
|
-
...variables
|
363
|
-
});
|
364
|
-
const getDatabaseList = (variables) => fetch$1({
|
365
|
-
url: "/dbs",
|
366
|
-
method: "get",
|
367
|
-
...variables
|
368
|
-
});
|
369
|
-
const getBranchList = (variables) => fetch$1({
|
317
|
+
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
318
|
+
|
319
|
+
const dEPRECATEDgetDatabaseList = (variables, signal) => dataPlaneFetch({ url: "/dbs", method: "get", ...variables, signal });
|
320
|
+
const getBranchList = (variables, signal) => dataPlaneFetch({
|
370
321
|
url: "/dbs/{dbName}",
|
371
322
|
method: "get",
|
372
|
-
...variables
|
323
|
+
...variables,
|
324
|
+
signal
|
373
325
|
});
|
374
|
-
const
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
const deleteDatabase = (variables) => fetch$1({
|
380
|
-
url: "/dbs/{dbName}",
|
381
|
-
method: "delete",
|
382
|
-
...variables
|
383
|
-
});
|
384
|
-
const getDatabaseMetadata = (variables) => fetch$1({
|
385
|
-
url: "/dbs/{dbName}/metadata",
|
386
|
-
method: "get",
|
387
|
-
...variables
|
388
|
-
});
|
389
|
-
const updateDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
|
390
|
-
const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
|
391
|
-
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
392
|
-
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
393
|
-
const resolveBranch = (variables) => fetch$1({
|
394
|
-
url: "/dbs/{dbName}/resolveBranch",
|
395
|
-
method: "get",
|
396
|
-
...variables
|
397
|
-
});
|
398
|
-
const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
|
399
|
-
const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
|
400
|
-
const getMigrationRequest = (variables) => fetch$1({
|
401
|
-
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
402
|
-
method: "get",
|
403
|
-
...variables
|
404
|
-
});
|
405
|
-
const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
|
406
|
-
const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
|
407
|
-
const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
|
408
|
-
const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
|
409
|
-
const mergeMigrationRequest = (variables) => fetch$1({
|
410
|
-
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
411
|
-
method: "post",
|
412
|
-
...variables
|
413
|
-
});
|
414
|
-
const getBranchDetails = (variables) => fetch$1({
|
326
|
+
const dEPRECATEDcreateDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
|
327
|
+
const dEPRECATEDdeleteDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "delete", ...variables, signal });
|
328
|
+
const dEPRECATEDgetDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "get", ...variables, signal });
|
329
|
+
const dEPRECATEDupdateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
|
330
|
+
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
415
331
|
url: "/db/{dbBranchName}",
|
416
332
|
method: "get",
|
417
|
-
...variables
|
333
|
+
...variables,
|
334
|
+
signal
|
418
335
|
});
|
419
|
-
const createBranch = (variables) =>
|
420
|
-
const deleteBranch = (variables) =>
|
336
|
+
const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
|
337
|
+
const deleteBranch = (variables, signal) => dataPlaneFetch({
|
421
338
|
url: "/db/{dbBranchName}",
|
422
339
|
method: "delete",
|
423
|
-
...variables
|
340
|
+
...variables,
|
341
|
+
signal
|
424
342
|
});
|
425
|
-
const updateBranchMetadata = (variables) =>
|
343
|
+
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
426
344
|
url: "/db/{dbBranchName}/metadata",
|
427
345
|
method: "put",
|
428
|
-
...variables
|
346
|
+
...variables,
|
347
|
+
signal
|
429
348
|
});
|
430
|
-
const getBranchMetadata = (variables) =>
|
349
|
+
const getBranchMetadata = (variables, signal) => dataPlaneFetch({
|
431
350
|
url: "/db/{dbBranchName}/metadata",
|
432
351
|
method: "get",
|
433
|
-
...variables
|
434
|
-
|
435
|
-
const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
|
436
|
-
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
437
|
-
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
438
|
-
const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
|
439
|
-
const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
|
440
|
-
const updateBranchSchema = (variables) => fetch$1({
|
441
|
-
url: "/db/{dbBranchName}/schema/update",
|
442
|
-
method: "post",
|
443
|
-
...variables
|
352
|
+
...variables,
|
353
|
+
signal
|
444
354
|
});
|
445
|
-
const
|
446
|
-
const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
|
447
|
-
const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
|
448
|
-
const getBranchStats = (variables) => fetch$1({
|
355
|
+
const getBranchStats = (variables, signal) => dataPlaneFetch({
|
449
356
|
url: "/db/{dbBranchName}/stats",
|
450
357
|
method: "get",
|
451
|
-
...variables
|
358
|
+
...variables,
|
359
|
+
signal
|
360
|
+
});
|
361
|
+
const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
|
362
|
+
const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
|
363
|
+
const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
|
364
|
+
const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
|
365
|
+
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
366
|
+
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
367
|
+
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
368
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
369
|
+
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
370
|
+
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
371
|
+
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
372
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
373
|
+
method: "get",
|
374
|
+
...variables,
|
375
|
+
signal
|
452
376
|
});
|
453
|
-
const
|
377
|
+
const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
|
378
|
+
const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
|
379
|
+
const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
|
380
|
+
const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
|
381
|
+
const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
|
382
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
383
|
+
method: "post",
|
384
|
+
...variables,
|
385
|
+
signal
|
386
|
+
});
|
387
|
+
const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
|
388
|
+
const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
|
389
|
+
const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
|
390
|
+
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
391
|
+
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
392
|
+
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
393
|
+
const createTable = (variables, signal) => dataPlaneFetch({
|
454
394
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
455
395
|
method: "put",
|
456
|
-
...variables
|
396
|
+
...variables,
|
397
|
+
signal
|
457
398
|
});
|
458
|
-
const deleteTable = (variables) =>
|
399
|
+
const deleteTable = (variables, signal) => dataPlaneFetch({
|
459
400
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
460
401
|
method: "delete",
|
461
|
-
...variables
|
402
|
+
...variables,
|
403
|
+
signal
|
462
404
|
});
|
463
|
-
const updateTable = (variables) =>
|
464
|
-
|
465
|
-
method: "patch",
|
466
|
-
...variables
|
467
|
-
});
|
468
|
-
const getTableSchema = (variables) => fetch$1({
|
405
|
+
const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
|
406
|
+
const getTableSchema = (variables, signal) => dataPlaneFetch({
|
469
407
|
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
470
408
|
method: "get",
|
471
|
-
...variables
|
409
|
+
...variables,
|
410
|
+
signal
|
472
411
|
});
|
473
|
-
const setTableSchema = (variables) =>
|
474
|
-
|
475
|
-
method: "put",
|
476
|
-
...variables
|
477
|
-
});
|
478
|
-
const getTableColumns = (variables) => fetch$1({
|
412
|
+
const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
|
413
|
+
const getTableColumns = (variables, signal) => dataPlaneFetch({
|
479
414
|
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
480
415
|
method: "get",
|
481
|
-
...variables
|
482
|
-
|
483
|
-
const addTableColumn = (variables) => fetch$1({
|
484
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
485
|
-
method: "post",
|
486
|
-
...variables
|
416
|
+
...variables,
|
417
|
+
signal
|
487
418
|
});
|
488
|
-
const
|
419
|
+
const addTableColumn = (variables, signal) => dataPlaneFetch(
|
420
|
+
{ url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
|
421
|
+
);
|
422
|
+
const getColumn = (variables, signal) => dataPlaneFetch({
|
489
423
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
490
424
|
method: "get",
|
491
|
-
...variables
|
425
|
+
...variables,
|
426
|
+
signal
|
492
427
|
});
|
493
|
-
const
|
428
|
+
const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
|
429
|
+
const deleteColumn = (variables, signal) => dataPlaneFetch({
|
494
430
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
495
431
|
method: "delete",
|
496
|
-
...variables
|
497
|
-
|
498
|
-
const updateColumn = (variables) => fetch$1({
|
499
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
500
|
-
method: "patch",
|
501
|
-
...variables
|
432
|
+
...variables,
|
433
|
+
signal
|
502
434
|
});
|
503
|
-
const insertRecord = (variables) =>
|
504
|
-
const
|
505
|
-
const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
|
506
|
-
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
507
|
-
const deleteRecord = (variables) => fetch$1({
|
508
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
509
|
-
method: "delete",
|
510
|
-
...variables
|
511
|
-
});
|
512
|
-
const getRecord = (variables) => fetch$1({
|
435
|
+
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
436
|
+
const getRecord = (variables, signal) => dataPlaneFetch({
|
513
437
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
514
438
|
method: "get",
|
515
|
-
...variables
|
439
|
+
...variables,
|
440
|
+
signal
|
516
441
|
});
|
517
|
-
const
|
518
|
-
const
|
442
|
+
const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
|
443
|
+
const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
|
444
|
+
const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
|
445
|
+
const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
|
446
|
+
const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
|
447
|
+
const queryTable = (variables, signal) => dataPlaneFetch({
|
519
448
|
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
520
449
|
method: "post",
|
521
|
-
...variables
|
450
|
+
...variables,
|
451
|
+
signal
|
522
452
|
});
|
523
|
-
const
|
524
|
-
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
525
|
-
method: "post",
|
526
|
-
...variables
|
527
|
-
});
|
528
|
-
const searchBranch = (variables) => fetch$1({
|
453
|
+
const searchBranch = (variables, signal) => dataPlaneFetch({
|
529
454
|
url: "/db/{dbBranchName}/search",
|
530
455
|
method: "post",
|
531
|
-
...variables
|
456
|
+
...variables,
|
457
|
+
signal
|
532
458
|
});
|
533
|
-
const
|
534
|
-
url: "/db/{dbBranchName}/tables/{tableName}/
|
459
|
+
const searchTable = (variables, signal) => dataPlaneFetch({
|
460
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
535
461
|
method: "post",
|
536
|
-
...variables
|
462
|
+
...variables,
|
463
|
+
signal
|
537
464
|
});
|
538
|
-
const
|
539
|
-
|
540
|
-
|
541
|
-
createWorkspace,
|
542
|
-
getWorkspacesList,
|
543
|
-
getWorkspace,
|
544
|
-
updateWorkspace,
|
545
|
-
deleteWorkspace,
|
546
|
-
getWorkspaceMembersList,
|
547
|
-
updateWorkspaceMemberRole,
|
548
|
-
removeWorkspaceMember,
|
549
|
-
inviteWorkspaceMember,
|
550
|
-
updateWorkspaceMemberInvite,
|
551
|
-
cancelWorkspaceMemberInvite,
|
552
|
-
resendWorkspaceMemberInvite,
|
553
|
-
acceptWorkspaceMemberInvite
|
554
|
-
},
|
465
|
+
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
466
|
+
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
467
|
+
const operationsByTag$2 = {
|
555
468
|
database: {
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
getGitBranchesMapping,
|
562
|
-
addGitBranchesEntry,
|
563
|
-
removeGitBranchesEntry,
|
564
|
-
resolveBranch
|
469
|
+
dEPRECATEDgetDatabaseList,
|
470
|
+
dEPRECATEDcreateDatabase,
|
471
|
+
dEPRECATEDdeleteDatabase,
|
472
|
+
dEPRECATEDgetDatabaseMetadata,
|
473
|
+
dEPRECATEDupdateDatabaseMetadata
|
565
474
|
},
|
566
475
|
branch: {
|
567
476
|
getBranchList,
|
@@ -570,10 +479,35 @@ const operationsByTag = {
|
|
570
479
|
deleteBranch,
|
571
480
|
updateBranchMetadata,
|
572
481
|
getBranchMetadata,
|
573
|
-
getBranchStats
|
482
|
+
getBranchStats,
|
483
|
+
getGitBranchesMapping,
|
484
|
+
addGitBranchesEntry,
|
485
|
+
removeGitBranchesEntry,
|
486
|
+
resolveBranch
|
487
|
+
},
|
488
|
+
migrations: {
|
489
|
+
getBranchMigrationHistory,
|
490
|
+
getBranchMigrationPlan,
|
491
|
+
executeBranchMigrationPlan,
|
492
|
+
getBranchSchemaHistory,
|
493
|
+
compareBranchWithUserSchema,
|
494
|
+
compareBranchSchemas,
|
495
|
+
updateBranchSchema,
|
496
|
+
previewBranchSchemaEdit,
|
497
|
+
applyBranchSchemaEdit
|
498
|
+
},
|
499
|
+
records: {
|
500
|
+
branchTransaction,
|
501
|
+
insertRecord,
|
502
|
+
getRecord,
|
503
|
+
insertRecordWithID,
|
504
|
+
updateRecordWithID,
|
505
|
+
upsertRecordWithID,
|
506
|
+
deleteRecord,
|
507
|
+
bulkInsertTableRecords
|
574
508
|
},
|
575
509
|
migrationRequests: {
|
576
|
-
|
510
|
+
queryMigrationRequests,
|
577
511
|
createMigrationRequest,
|
578
512
|
getMigrationRequest,
|
579
513
|
updateMigrationRequest,
|
@@ -582,17 +516,6 @@ const operationsByTag = {
|
|
582
516
|
getMigrationRequestIsMerged,
|
583
517
|
mergeMigrationRequest
|
584
518
|
},
|
585
|
-
branchSchema: {
|
586
|
-
getBranchMigrationHistory,
|
587
|
-
executeBranchMigrationPlan,
|
588
|
-
getBranchMigrationPlan,
|
589
|
-
compareBranchWithUserSchema,
|
590
|
-
compareBranchSchemas,
|
591
|
-
updateBranchSchema,
|
592
|
-
previewBranchSchemaEdit,
|
593
|
-
applyBranchSchemaEdit,
|
594
|
-
getBranchSchemaHistory
|
595
|
-
},
|
596
519
|
table: {
|
597
520
|
createTable,
|
598
521
|
deleteTable,
|
@@ -602,24 +525,146 @@ const operationsByTag = {
|
|
602
525
|
getTableColumns,
|
603
526
|
addTableColumn,
|
604
527
|
getColumn,
|
605
|
-
|
606
|
-
|
528
|
+
updateColumn,
|
529
|
+
deleteColumn
|
607
530
|
},
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
531
|
+
searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
|
532
|
+
};
|
533
|
+
|
534
|
+
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
535
|
+
|
536
|
+
const getUser = (variables, signal) => controlPlaneFetch({
|
537
|
+
url: "/user",
|
538
|
+
method: "get",
|
539
|
+
...variables,
|
540
|
+
signal
|
541
|
+
});
|
542
|
+
const updateUser = (variables, signal) => controlPlaneFetch({
|
543
|
+
url: "/user",
|
544
|
+
method: "put",
|
545
|
+
...variables,
|
546
|
+
signal
|
547
|
+
});
|
548
|
+
const deleteUser = (variables, signal) => controlPlaneFetch({
|
549
|
+
url: "/user",
|
550
|
+
method: "delete",
|
551
|
+
...variables,
|
552
|
+
signal
|
553
|
+
});
|
554
|
+
const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
|
555
|
+
url: "/user/keys",
|
556
|
+
method: "get",
|
557
|
+
...variables,
|
558
|
+
signal
|
559
|
+
});
|
560
|
+
const createUserAPIKey = (variables, signal) => controlPlaneFetch({
|
561
|
+
url: "/user/keys/{keyName}",
|
562
|
+
method: "post",
|
563
|
+
...variables,
|
564
|
+
signal
|
565
|
+
});
|
566
|
+
const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
567
|
+
url: "/user/keys/{keyName}",
|
568
|
+
method: "delete",
|
569
|
+
...variables,
|
570
|
+
signal
|
571
|
+
});
|
572
|
+
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
573
|
+
url: "/workspaces",
|
574
|
+
method: "get",
|
575
|
+
...variables,
|
576
|
+
signal
|
577
|
+
});
|
578
|
+
const createWorkspace = (variables, signal) => controlPlaneFetch({
|
579
|
+
url: "/workspaces",
|
580
|
+
method: "post",
|
581
|
+
...variables,
|
582
|
+
signal
|
583
|
+
});
|
584
|
+
const getWorkspace = (variables, signal) => controlPlaneFetch({
|
585
|
+
url: "/workspaces/{workspaceId}",
|
586
|
+
method: "get",
|
587
|
+
...variables,
|
588
|
+
signal
|
589
|
+
});
|
590
|
+
const updateWorkspace = (variables, signal) => controlPlaneFetch({
|
591
|
+
url: "/workspaces/{workspaceId}",
|
592
|
+
method: "put",
|
593
|
+
...variables,
|
594
|
+
signal
|
595
|
+
});
|
596
|
+
const deleteWorkspace = (variables, signal) => controlPlaneFetch({
|
597
|
+
url: "/workspaces/{workspaceId}",
|
598
|
+
method: "delete",
|
599
|
+
...variables,
|
600
|
+
signal
|
601
|
+
});
|
602
|
+
const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
|
603
|
+
const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
|
604
|
+
const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
605
|
+
url: "/workspaces/{workspaceId}/members/{userId}",
|
606
|
+
method: "delete",
|
607
|
+
...variables,
|
608
|
+
signal
|
609
|
+
});
|
610
|
+
const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
|
611
|
+
const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
|
612
|
+
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
613
|
+
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
614
|
+
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
615
|
+
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
616
|
+
url: "/workspaces/{workspaceId}/dbs",
|
617
|
+
method: "get",
|
618
|
+
...variables,
|
619
|
+
signal
|
620
|
+
});
|
621
|
+
const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
|
622
|
+
const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
623
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
624
|
+
method: "delete",
|
625
|
+
...variables,
|
626
|
+
signal
|
627
|
+
});
|
628
|
+
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
629
|
+
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
630
|
+
const listRegions = (variables, signal) => controlPlaneFetch({
|
631
|
+
url: "/workspaces/{workspaceId}/regions",
|
632
|
+
method: "get",
|
633
|
+
...variables,
|
634
|
+
signal
|
635
|
+
});
|
636
|
+
const operationsByTag$1 = {
|
637
|
+
users: { getUser, updateUser, deleteUser },
|
638
|
+
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
639
|
+
workspaces: {
|
640
|
+
getWorkspacesList,
|
641
|
+
createWorkspace,
|
642
|
+
getWorkspace,
|
643
|
+
updateWorkspace,
|
644
|
+
deleteWorkspace,
|
645
|
+
getWorkspaceMembersList,
|
646
|
+
updateWorkspaceMemberRole,
|
647
|
+
removeWorkspaceMember
|
648
|
+
},
|
649
|
+
invites: {
|
650
|
+
inviteWorkspaceMember,
|
651
|
+
updateWorkspaceMemberInvite,
|
652
|
+
cancelWorkspaceMemberInvite,
|
653
|
+
acceptWorkspaceMemberInvite,
|
654
|
+
resendWorkspaceMemberInvite
|
655
|
+
},
|
656
|
+
databases: {
|
657
|
+
getDatabaseList,
|
658
|
+
createDatabase,
|
659
|
+
deleteDatabase,
|
660
|
+
getDatabaseMetadata,
|
661
|
+
updateDatabaseMetadata,
|
662
|
+
listRegions
|
620
663
|
}
|
621
664
|
};
|
622
665
|
|
666
|
+
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
667
|
+
|
623
668
|
function getHostUrl(provider, type) {
|
624
669
|
if (isHostProviderAlias(provider)) {
|
625
670
|
return providers[provider][type];
|
@@ -631,11 +676,11 @@ function getHostUrl(provider, type) {
|
|
631
676
|
const providers = {
|
632
677
|
production: {
|
633
678
|
main: "https://api.xata.io",
|
634
|
-
workspaces: "https://{workspaceId}.xata.sh"
|
679
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
635
680
|
},
|
636
681
|
staging: {
|
637
682
|
main: "https://staging.xatabase.co",
|
638
|
-
workspaces: "https://{workspaceId}.staging.xatabase.co"
|
683
|
+
workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
|
639
684
|
}
|
640
685
|
};
|
641
686
|
function isHostProviderAlias(alias) {
|
@@ -644,6 +689,25 @@ function isHostProviderAlias(alias) {
|
|
644
689
|
function isHostProviderBuilder(builder) {
|
645
690
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
646
691
|
}
|
692
|
+
function parseProviderString(provider = "production") {
|
693
|
+
if (isHostProviderAlias(provider)) {
|
694
|
+
return provider;
|
695
|
+
}
|
696
|
+
const [main, workspaces] = provider.split(",");
|
697
|
+
if (!main || !workspaces)
|
698
|
+
return null;
|
699
|
+
return { main, workspaces };
|
700
|
+
}
|
701
|
+
function parseWorkspacesUrlParts(url) {
|
702
|
+
if (!isString(url))
|
703
|
+
return null;
|
704
|
+
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
|
705
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
|
706
|
+
const match = url.match(regex) || url.match(regexStaging);
|
707
|
+
if (!match)
|
708
|
+
return null;
|
709
|
+
return { workspace: match[1], region: match[2] ?? "eu-west-1" };
|
710
|
+
}
|
647
711
|
|
648
712
|
var __accessCheck$7 = (obj, member, msg) => {
|
649
713
|
if (!member.has(obj))
|
@@ -687,21 +751,41 @@ class XataApiClient {
|
|
687
751
|
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
688
752
|
return __privateGet$7(this, _namespaces).user;
|
689
753
|
}
|
754
|
+
get authentication() {
|
755
|
+
if (!__privateGet$7(this, _namespaces).authentication)
|
756
|
+
__privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
|
757
|
+
return __privateGet$7(this, _namespaces).authentication;
|
758
|
+
}
|
690
759
|
get workspaces() {
|
691
760
|
if (!__privateGet$7(this, _namespaces).workspaces)
|
692
761
|
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
693
762
|
return __privateGet$7(this, _namespaces).workspaces;
|
694
763
|
}
|
695
|
-
get
|
696
|
-
if (!__privateGet$7(this, _namespaces).
|
697
|
-
__privateGet$7(this, _namespaces).
|
698
|
-
return __privateGet$7(this, _namespaces).
|
764
|
+
get invites() {
|
765
|
+
if (!__privateGet$7(this, _namespaces).invites)
|
766
|
+
__privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
|
767
|
+
return __privateGet$7(this, _namespaces).invites;
|
768
|
+
}
|
769
|
+
get database() {
|
770
|
+
if (!__privateGet$7(this, _namespaces).database)
|
771
|
+
__privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
|
772
|
+
return __privateGet$7(this, _namespaces).database;
|
699
773
|
}
|
700
774
|
get branches() {
|
701
775
|
if (!__privateGet$7(this, _namespaces).branches)
|
702
776
|
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
703
777
|
return __privateGet$7(this, _namespaces).branches;
|
704
778
|
}
|
779
|
+
get migrations() {
|
780
|
+
if (!__privateGet$7(this, _namespaces).migrations)
|
781
|
+
__privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
|
782
|
+
return __privateGet$7(this, _namespaces).migrations;
|
783
|
+
}
|
784
|
+
get migrationRequests() {
|
785
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
786
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
787
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
788
|
+
}
|
705
789
|
get tables() {
|
706
790
|
if (!__privateGet$7(this, _namespaces).tables)
|
707
791
|
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
@@ -712,15 +796,10 @@ class XataApiClient {
|
|
712
796
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
713
797
|
return __privateGet$7(this, _namespaces).records;
|
714
798
|
}
|
715
|
-
get
|
716
|
-
if (!__privateGet$7(this, _namespaces).
|
717
|
-
__privateGet$7(this, _namespaces).
|
718
|
-
return __privateGet$7(this, _namespaces).
|
719
|
-
}
|
720
|
-
get branchSchema() {
|
721
|
-
if (!__privateGet$7(this, _namespaces).branchSchema)
|
722
|
-
__privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
|
723
|
-
return __privateGet$7(this, _namespaces).branchSchema;
|
799
|
+
get searchAndFilter() {
|
800
|
+
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
801
|
+
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
802
|
+
return __privateGet$7(this, _namespaces).searchAndFilter;
|
724
803
|
}
|
725
804
|
}
|
726
805
|
_extraProps = new WeakMap();
|
@@ -732,24 +811,29 @@ class UserApi {
|
|
732
811
|
getUser() {
|
733
812
|
return operationsByTag.users.getUser({ ...this.extraProps });
|
734
813
|
}
|
735
|
-
updateUser(user) {
|
814
|
+
updateUser({ user }) {
|
736
815
|
return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
|
737
816
|
}
|
738
817
|
deleteUser() {
|
739
818
|
return operationsByTag.users.deleteUser({ ...this.extraProps });
|
740
819
|
}
|
820
|
+
}
|
821
|
+
class AuthenticationApi {
|
822
|
+
constructor(extraProps) {
|
823
|
+
this.extraProps = extraProps;
|
824
|
+
}
|
741
825
|
getUserAPIKeys() {
|
742
|
-
return operationsByTag.
|
826
|
+
return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
|
743
827
|
}
|
744
|
-
createUserAPIKey(
|
745
|
-
return operationsByTag.
|
746
|
-
pathParams: { keyName },
|
828
|
+
createUserAPIKey({ name }) {
|
829
|
+
return operationsByTag.authentication.createUserAPIKey({
|
830
|
+
pathParams: { keyName: name },
|
747
831
|
...this.extraProps
|
748
832
|
});
|
749
833
|
}
|
750
|
-
deleteUserAPIKey(
|
751
|
-
return operationsByTag.
|
752
|
-
pathParams: { keyName },
|
834
|
+
deleteUserAPIKey({ name }) {
|
835
|
+
return operationsByTag.authentication.deleteUserAPIKey({
|
836
|
+
pathParams: { keyName: name },
|
753
837
|
...this.extraProps
|
754
838
|
});
|
755
839
|
}
|
@@ -758,196 +842,248 @@ class WorkspaceApi {
|
|
758
842
|
constructor(extraProps) {
|
759
843
|
this.extraProps = extraProps;
|
760
844
|
}
|
761
|
-
|
845
|
+
getWorkspacesList() {
|
846
|
+
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
847
|
+
}
|
848
|
+
createWorkspace({ data }) {
|
762
849
|
return operationsByTag.workspaces.createWorkspace({
|
763
|
-
body:
|
850
|
+
body: data,
|
764
851
|
...this.extraProps
|
765
852
|
});
|
766
853
|
}
|
767
|
-
|
768
|
-
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
769
|
-
}
|
770
|
-
getWorkspace(workspaceId) {
|
854
|
+
getWorkspace({ workspace }) {
|
771
855
|
return operationsByTag.workspaces.getWorkspace({
|
772
|
-
pathParams: { workspaceId },
|
856
|
+
pathParams: { workspaceId: workspace },
|
773
857
|
...this.extraProps
|
774
858
|
});
|
775
859
|
}
|
776
|
-
updateWorkspace(
|
860
|
+
updateWorkspace({
|
861
|
+
workspace,
|
862
|
+
update
|
863
|
+
}) {
|
777
864
|
return operationsByTag.workspaces.updateWorkspace({
|
778
|
-
pathParams: { workspaceId },
|
779
|
-
body:
|
865
|
+
pathParams: { workspaceId: workspace },
|
866
|
+
body: update,
|
780
867
|
...this.extraProps
|
781
868
|
});
|
782
869
|
}
|
783
|
-
deleteWorkspace(
|
870
|
+
deleteWorkspace({ workspace }) {
|
784
871
|
return operationsByTag.workspaces.deleteWorkspace({
|
785
|
-
pathParams: { workspaceId },
|
872
|
+
pathParams: { workspaceId: workspace },
|
786
873
|
...this.extraProps
|
787
874
|
});
|
788
875
|
}
|
789
|
-
getWorkspaceMembersList(
|
876
|
+
getWorkspaceMembersList({ workspace }) {
|
790
877
|
return operationsByTag.workspaces.getWorkspaceMembersList({
|
791
|
-
pathParams: { workspaceId },
|
878
|
+
pathParams: { workspaceId: workspace },
|
792
879
|
...this.extraProps
|
793
880
|
});
|
794
881
|
}
|
795
|
-
updateWorkspaceMemberRole(
|
882
|
+
updateWorkspaceMemberRole({
|
883
|
+
workspace,
|
884
|
+
user,
|
885
|
+
role
|
886
|
+
}) {
|
796
887
|
return operationsByTag.workspaces.updateWorkspaceMemberRole({
|
797
|
-
pathParams: { workspaceId, userId },
|
888
|
+
pathParams: { workspaceId: workspace, userId: user },
|
798
889
|
body: { role },
|
799
890
|
...this.extraProps
|
800
891
|
});
|
801
892
|
}
|
802
|
-
removeWorkspaceMember(
|
893
|
+
removeWorkspaceMember({
|
894
|
+
workspace,
|
895
|
+
user
|
896
|
+
}) {
|
803
897
|
return operationsByTag.workspaces.removeWorkspaceMember({
|
804
|
-
pathParams: { workspaceId, userId },
|
898
|
+
pathParams: { workspaceId: workspace, userId: user },
|
805
899
|
...this.extraProps
|
806
900
|
});
|
807
901
|
}
|
808
|
-
|
809
|
-
|
810
|
-
|
902
|
+
}
|
903
|
+
class InvitesApi {
|
904
|
+
constructor(extraProps) {
|
905
|
+
this.extraProps = extraProps;
|
906
|
+
}
|
907
|
+
inviteWorkspaceMember({
|
908
|
+
workspace,
|
909
|
+
email,
|
910
|
+
role
|
911
|
+
}) {
|
912
|
+
return operationsByTag.invites.inviteWorkspaceMember({
|
913
|
+
pathParams: { workspaceId: workspace },
|
811
914
|
body: { email, role },
|
812
915
|
...this.extraProps
|
813
916
|
});
|
814
917
|
}
|
815
|
-
updateWorkspaceMemberInvite(
|
816
|
-
|
817
|
-
|
918
|
+
updateWorkspaceMemberInvite({
|
919
|
+
workspace,
|
920
|
+
invite,
|
921
|
+
role
|
922
|
+
}) {
|
923
|
+
return operationsByTag.invites.updateWorkspaceMemberInvite({
|
924
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
818
925
|
body: { role },
|
819
926
|
...this.extraProps
|
820
927
|
});
|
821
928
|
}
|
822
|
-
cancelWorkspaceMemberInvite(
|
823
|
-
|
824
|
-
|
929
|
+
cancelWorkspaceMemberInvite({
|
930
|
+
workspace,
|
931
|
+
invite
|
932
|
+
}) {
|
933
|
+
return operationsByTag.invites.cancelWorkspaceMemberInvite({
|
934
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
825
935
|
...this.extraProps
|
826
936
|
});
|
827
937
|
}
|
828
|
-
|
829
|
-
|
830
|
-
|
938
|
+
acceptWorkspaceMemberInvite({
|
939
|
+
workspace,
|
940
|
+
key
|
941
|
+
}) {
|
942
|
+
return operationsByTag.invites.acceptWorkspaceMemberInvite({
|
943
|
+
pathParams: { workspaceId: workspace, inviteKey: key },
|
831
944
|
...this.extraProps
|
832
945
|
});
|
833
946
|
}
|
834
|
-
|
835
|
-
|
836
|
-
|
947
|
+
resendWorkspaceMemberInvite({
|
948
|
+
workspace,
|
949
|
+
invite
|
950
|
+
}) {
|
951
|
+
return operationsByTag.invites.resendWorkspaceMemberInvite({
|
952
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
837
953
|
...this.extraProps
|
838
954
|
});
|
839
955
|
}
|
840
956
|
}
|
841
|
-
class
|
957
|
+
class BranchApi {
|
842
958
|
constructor(extraProps) {
|
843
959
|
this.extraProps = extraProps;
|
844
960
|
}
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
return operationsByTag.database.createDatabase({
|
853
|
-
pathParams: { workspace, dbName },
|
854
|
-
body: options,
|
855
|
-
...this.extraProps
|
856
|
-
});
|
857
|
-
}
|
858
|
-
deleteDatabase(workspace, dbName) {
|
859
|
-
return operationsByTag.database.deleteDatabase({
|
860
|
-
pathParams: { workspace, dbName },
|
861
|
-
...this.extraProps
|
862
|
-
});
|
863
|
-
}
|
864
|
-
getDatabaseMetadata(workspace, dbName) {
|
865
|
-
return operationsByTag.database.getDatabaseMetadata({
|
866
|
-
pathParams: { workspace, dbName },
|
867
|
-
...this.extraProps
|
868
|
-
});
|
869
|
-
}
|
870
|
-
updateDatabaseMetadata(workspace, dbName, options = {}) {
|
871
|
-
return operationsByTag.database.updateDatabaseMetadata({
|
872
|
-
pathParams: { workspace, dbName },
|
873
|
-
body: options,
|
874
|
-
...this.extraProps
|
875
|
-
});
|
876
|
-
}
|
877
|
-
getGitBranchesMapping(workspace, dbName) {
|
878
|
-
return operationsByTag.database.getGitBranchesMapping({
|
879
|
-
pathParams: { workspace, dbName },
|
961
|
+
getBranchList({
|
962
|
+
workspace,
|
963
|
+
region,
|
964
|
+
database
|
965
|
+
}) {
|
966
|
+
return operationsByTag.branch.getBranchList({
|
967
|
+
pathParams: { workspace, region, dbName: database },
|
880
968
|
...this.extraProps
|
881
969
|
});
|
882
970
|
}
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
971
|
+
getBranchDetails({
|
972
|
+
workspace,
|
973
|
+
region,
|
974
|
+
database,
|
975
|
+
branch
|
976
|
+
}) {
|
977
|
+
return operationsByTag.branch.getBranchDetails({
|
978
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
887
979
|
...this.extraProps
|
888
980
|
});
|
889
981
|
}
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
982
|
+
createBranch({
|
983
|
+
workspace,
|
984
|
+
region,
|
985
|
+
database,
|
986
|
+
branch,
|
987
|
+
from,
|
988
|
+
metadata
|
989
|
+
}) {
|
990
|
+
return operationsByTag.branch.createBranch({
|
991
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
992
|
+
body: { from, metadata },
|
894
993
|
...this.extraProps
|
895
994
|
});
|
896
995
|
}
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
996
|
+
deleteBranch({
|
997
|
+
workspace,
|
998
|
+
region,
|
999
|
+
database,
|
1000
|
+
branch
|
1001
|
+
}) {
|
1002
|
+
return operationsByTag.branch.deleteBranch({
|
1003
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
901
1004
|
...this.extraProps
|
902
1005
|
});
|
903
1006
|
}
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
1007
|
+
updateBranchMetadata({
|
1008
|
+
workspace,
|
1009
|
+
region,
|
1010
|
+
database,
|
1011
|
+
branch,
|
1012
|
+
metadata
|
1013
|
+
}) {
|
1014
|
+
return operationsByTag.branch.updateBranchMetadata({
|
1015
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1016
|
+
body: metadata,
|
912
1017
|
...this.extraProps
|
913
1018
|
});
|
914
1019
|
}
|
915
|
-
|
916
|
-
|
917
|
-
|
1020
|
+
getBranchMetadata({
|
1021
|
+
workspace,
|
1022
|
+
region,
|
1023
|
+
database,
|
1024
|
+
branch
|
1025
|
+
}) {
|
1026
|
+
return operationsByTag.branch.getBranchMetadata({
|
1027
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
918
1028
|
...this.extraProps
|
919
1029
|
});
|
920
1030
|
}
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
1031
|
+
getBranchStats({
|
1032
|
+
workspace,
|
1033
|
+
region,
|
1034
|
+
database,
|
1035
|
+
branch
|
1036
|
+
}) {
|
1037
|
+
return operationsByTag.branch.getBranchStats({
|
1038
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
926
1039
|
...this.extraProps
|
927
1040
|
});
|
928
1041
|
}
|
929
|
-
|
930
|
-
|
931
|
-
|
1042
|
+
getGitBranchesMapping({
|
1043
|
+
workspace,
|
1044
|
+
region,
|
1045
|
+
database
|
1046
|
+
}) {
|
1047
|
+
return operationsByTag.branch.getGitBranchesMapping({
|
1048
|
+
pathParams: { workspace, region, dbName: database },
|
932
1049
|
...this.extraProps
|
933
1050
|
});
|
934
1051
|
}
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
1052
|
+
addGitBranchesEntry({
|
1053
|
+
workspace,
|
1054
|
+
region,
|
1055
|
+
database,
|
1056
|
+
gitBranch,
|
1057
|
+
xataBranch
|
1058
|
+
}) {
|
1059
|
+
return operationsByTag.branch.addGitBranchesEntry({
|
1060
|
+
pathParams: { workspace, region, dbName: database },
|
1061
|
+
body: { gitBranch, xataBranch },
|
939
1062
|
...this.extraProps
|
940
1063
|
});
|
941
1064
|
}
|
942
|
-
|
943
|
-
|
944
|
-
|
1065
|
+
removeGitBranchesEntry({
|
1066
|
+
workspace,
|
1067
|
+
region,
|
1068
|
+
database,
|
1069
|
+
gitBranch
|
1070
|
+
}) {
|
1071
|
+
return operationsByTag.branch.removeGitBranchesEntry({
|
1072
|
+
pathParams: { workspace, region, dbName: database },
|
1073
|
+
queryParams: { gitBranch },
|
945
1074
|
...this.extraProps
|
946
1075
|
});
|
947
1076
|
}
|
948
|
-
|
949
|
-
|
950
|
-
|
1077
|
+
resolveBranch({
|
1078
|
+
workspace,
|
1079
|
+
region,
|
1080
|
+
database,
|
1081
|
+
gitBranch,
|
1082
|
+
fallbackBranch
|
1083
|
+
}) {
|
1084
|
+
return operationsByTag.branch.resolveBranch({
|
1085
|
+
pathParams: { workspace, region, dbName: database },
|
1086
|
+
queryParams: { gitBranch, fallbackBranch },
|
951
1087
|
...this.extraProps
|
952
1088
|
});
|
953
1089
|
}
|
@@ -956,67 +1092,134 @@ class TableApi {
|
|
956
1092
|
constructor(extraProps) {
|
957
1093
|
this.extraProps = extraProps;
|
958
1094
|
}
|
959
|
-
createTable(
|
1095
|
+
createTable({
|
1096
|
+
workspace,
|
1097
|
+
region,
|
1098
|
+
database,
|
1099
|
+
branch,
|
1100
|
+
table
|
1101
|
+
}) {
|
960
1102
|
return operationsByTag.table.createTable({
|
961
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1103
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
962
1104
|
...this.extraProps
|
963
1105
|
});
|
964
1106
|
}
|
965
|
-
deleteTable(
|
1107
|
+
deleteTable({
|
1108
|
+
workspace,
|
1109
|
+
region,
|
1110
|
+
database,
|
1111
|
+
branch,
|
1112
|
+
table
|
1113
|
+
}) {
|
966
1114
|
return operationsByTag.table.deleteTable({
|
967
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1115
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
968
1116
|
...this.extraProps
|
969
1117
|
});
|
970
1118
|
}
|
971
|
-
updateTable(
|
1119
|
+
updateTable({
|
1120
|
+
workspace,
|
1121
|
+
region,
|
1122
|
+
database,
|
1123
|
+
branch,
|
1124
|
+
table,
|
1125
|
+
update
|
1126
|
+
}) {
|
972
1127
|
return operationsByTag.table.updateTable({
|
973
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
974
|
-
body:
|
1128
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1129
|
+
body: update,
|
975
1130
|
...this.extraProps
|
976
1131
|
});
|
977
1132
|
}
|
978
|
-
getTableSchema(
|
1133
|
+
getTableSchema({
|
1134
|
+
workspace,
|
1135
|
+
region,
|
1136
|
+
database,
|
1137
|
+
branch,
|
1138
|
+
table
|
1139
|
+
}) {
|
979
1140
|
return operationsByTag.table.getTableSchema({
|
980
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1141
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
981
1142
|
...this.extraProps
|
982
1143
|
});
|
983
1144
|
}
|
984
|
-
setTableSchema(
|
1145
|
+
setTableSchema({
|
1146
|
+
workspace,
|
1147
|
+
region,
|
1148
|
+
database,
|
1149
|
+
branch,
|
1150
|
+
table,
|
1151
|
+
schema
|
1152
|
+
}) {
|
985
1153
|
return operationsByTag.table.setTableSchema({
|
986
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
987
|
-
body:
|
1154
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1155
|
+
body: schema,
|
988
1156
|
...this.extraProps
|
989
1157
|
});
|
990
1158
|
}
|
991
|
-
getTableColumns(
|
1159
|
+
getTableColumns({
|
1160
|
+
workspace,
|
1161
|
+
region,
|
1162
|
+
database,
|
1163
|
+
branch,
|
1164
|
+
table
|
1165
|
+
}) {
|
992
1166
|
return operationsByTag.table.getTableColumns({
|
993
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1167
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
994
1168
|
...this.extraProps
|
995
1169
|
});
|
996
1170
|
}
|
997
|
-
addTableColumn(
|
1171
|
+
addTableColumn({
|
1172
|
+
workspace,
|
1173
|
+
region,
|
1174
|
+
database,
|
1175
|
+
branch,
|
1176
|
+
table,
|
1177
|
+
column
|
1178
|
+
}) {
|
998
1179
|
return operationsByTag.table.addTableColumn({
|
999
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1180
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1000
1181
|
body: column,
|
1001
1182
|
...this.extraProps
|
1002
1183
|
});
|
1003
1184
|
}
|
1004
|
-
getColumn(
|
1185
|
+
getColumn({
|
1186
|
+
workspace,
|
1187
|
+
region,
|
1188
|
+
database,
|
1189
|
+
branch,
|
1190
|
+
table,
|
1191
|
+
column
|
1192
|
+
}) {
|
1005
1193
|
return operationsByTag.table.getColumn({
|
1006
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
|
1194
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1007
1195
|
...this.extraProps
|
1008
1196
|
});
|
1009
1197
|
}
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1198
|
+
updateColumn({
|
1199
|
+
workspace,
|
1200
|
+
region,
|
1201
|
+
database,
|
1202
|
+
branch,
|
1203
|
+
table,
|
1204
|
+
column,
|
1205
|
+
update
|
1206
|
+
}) {
|
1207
|
+
return operationsByTag.table.updateColumn({
|
1208
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1209
|
+
body: update,
|
1013
1210
|
...this.extraProps
|
1014
1211
|
});
|
1015
1212
|
}
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1213
|
+
deleteColumn({
|
1214
|
+
workspace,
|
1215
|
+
region,
|
1216
|
+
database,
|
1217
|
+
branch,
|
1218
|
+
table,
|
1219
|
+
column
|
1220
|
+
}) {
|
1221
|
+
return operationsByTag.table.deleteColumn({
|
1222
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1020
1223
|
...this.extraProps
|
1021
1224
|
});
|
1022
1225
|
}
|
@@ -1025,85 +1228,213 @@ class RecordsApi {
|
|
1025
1228
|
constructor(extraProps) {
|
1026
1229
|
this.extraProps = extraProps;
|
1027
1230
|
}
|
1028
|
-
insertRecord(
|
1231
|
+
insertRecord({
|
1232
|
+
workspace,
|
1233
|
+
region,
|
1234
|
+
database,
|
1235
|
+
branch,
|
1236
|
+
table,
|
1237
|
+
record,
|
1238
|
+
columns
|
1239
|
+
}) {
|
1029
1240
|
return operationsByTag.records.insertRecord({
|
1030
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1031
|
-
queryParams:
|
1241
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1242
|
+
queryParams: { columns },
|
1032
1243
|
body: record,
|
1033
1244
|
...this.extraProps
|
1034
1245
|
});
|
1035
1246
|
}
|
1036
|
-
|
1247
|
+
getRecord({
|
1248
|
+
workspace,
|
1249
|
+
region,
|
1250
|
+
database,
|
1251
|
+
branch,
|
1252
|
+
table,
|
1253
|
+
id,
|
1254
|
+
columns
|
1255
|
+
}) {
|
1256
|
+
return operationsByTag.records.getRecord({
|
1257
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1258
|
+
queryParams: { columns },
|
1259
|
+
...this.extraProps
|
1260
|
+
});
|
1261
|
+
}
|
1262
|
+
insertRecordWithID({
|
1263
|
+
workspace,
|
1264
|
+
region,
|
1265
|
+
database,
|
1266
|
+
branch,
|
1267
|
+
table,
|
1268
|
+
id,
|
1269
|
+
record,
|
1270
|
+
columns,
|
1271
|
+
createOnly,
|
1272
|
+
ifVersion
|
1273
|
+
}) {
|
1037
1274
|
return operationsByTag.records.insertRecordWithID({
|
1038
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1039
|
-
queryParams:
|
1275
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1276
|
+
queryParams: { columns, createOnly, ifVersion },
|
1040
1277
|
body: record,
|
1041
1278
|
...this.extraProps
|
1042
1279
|
});
|
1043
1280
|
}
|
1044
|
-
updateRecordWithID(
|
1281
|
+
updateRecordWithID({
|
1282
|
+
workspace,
|
1283
|
+
region,
|
1284
|
+
database,
|
1285
|
+
branch,
|
1286
|
+
table,
|
1287
|
+
id,
|
1288
|
+
record,
|
1289
|
+
columns,
|
1290
|
+
ifVersion
|
1291
|
+
}) {
|
1045
1292
|
return operationsByTag.records.updateRecordWithID({
|
1046
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1047
|
-
queryParams:
|
1293
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1294
|
+
queryParams: { columns, ifVersion },
|
1048
1295
|
body: record,
|
1049
1296
|
...this.extraProps
|
1050
1297
|
});
|
1051
1298
|
}
|
1052
|
-
upsertRecordWithID(
|
1299
|
+
upsertRecordWithID({
|
1300
|
+
workspace,
|
1301
|
+
region,
|
1302
|
+
database,
|
1303
|
+
branch,
|
1304
|
+
table,
|
1305
|
+
id,
|
1306
|
+
record,
|
1307
|
+
columns,
|
1308
|
+
ifVersion
|
1309
|
+
}) {
|
1053
1310
|
return operationsByTag.records.upsertRecordWithID({
|
1054
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1055
|
-
queryParams:
|
1311
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1312
|
+
queryParams: { columns, ifVersion },
|
1056
1313
|
body: record,
|
1057
1314
|
...this.extraProps
|
1058
1315
|
});
|
1059
1316
|
}
|
1060
|
-
deleteRecord(
|
1317
|
+
deleteRecord({
|
1318
|
+
workspace,
|
1319
|
+
region,
|
1320
|
+
database,
|
1321
|
+
branch,
|
1322
|
+
table,
|
1323
|
+
id,
|
1324
|
+
columns
|
1325
|
+
}) {
|
1061
1326
|
return operationsByTag.records.deleteRecord({
|
1062
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1063
|
-
queryParams:
|
1064
|
-
...this.extraProps
|
1065
|
-
});
|
1066
|
-
}
|
1067
|
-
getRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
1068
|
-
return operationsByTag.records.getRecord({
|
1069
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1070
|
-
queryParams: options,
|
1327
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1328
|
+
queryParams: { columns },
|
1071
1329
|
...this.extraProps
|
1072
1330
|
});
|
1073
1331
|
}
|
1074
|
-
bulkInsertTableRecords(
|
1332
|
+
bulkInsertTableRecords({
|
1333
|
+
workspace,
|
1334
|
+
region,
|
1335
|
+
database,
|
1336
|
+
branch,
|
1337
|
+
table,
|
1338
|
+
records,
|
1339
|
+
columns
|
1340
|
+
}) {
|
1075
1341
|
return operationsByTag.records.bulkInsertTableRecords({
|
1076
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1077
|
-
queryParams:
|
1342
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1343
|
+
queryParams: { columns },
|
1078
1344
|
body: { records },
|
1079
1345
|
...this.extraProps
|
1080
1346
|
});
|
1081
1347
|
}
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
...this.extraProps
|
1087
|
-
});
|
1088
|
-
}
|
1089
|
-
searchTable(workspace, database, branch, tableName, query) {
|
1090
|
-
return operationsByTag.records.searchTable({
|
1091
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1092
|
-
body: query,
|
1093
|
-
...this.extraProps
|
1094
|
-
});
|
1095
|
-
}
|
1096
|
-
searchBranch(workspace, database, branch, query) {
|
1097
|
-
return operationsByTag.records.searchBranch({
|
1098
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1099
|
-
body: query,
|
1100
|
-
...this.extraProps
|
1101
|
-
});
|
1348
|
+
}
|
1349
|
+
class SearchAndFilterApi {
|
1350
|
+
constructor(extraProps) {
|
1351
|
+
this.extraProps = extraProps;
|
1102
1352
|
}
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1353
|
+
queryTable({
|
1354
|
+
workspace,
|
1355
|
+
region,
|
1356
|
+
database,
|
1357
|
+
branch,
|
1358
|
+
table,
|
1359
|
+
filter,
|
1360
|
+
sort,
|
1361
|
+
page,
|
1362
|
+
columns
|
1363
|
+
}) {
|
1364
|
+
return operationsByTag.searchAndFilter.queryTable({
|
1365
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1366
|
+
body: { filter, sort, page, columns },
|
1367
|
+
...this.extraProps
|
1368
|
+
});
|
1369
|
+
}
|
1370
|
+
searchTable({
|
1371
|
+
workspace,
|
1372
|
+
region,
|
1373
|
+
database,
|
1374
|
+
branch,
|
1375
|
+
table,
|
1376
|
+
query,
|
1377
|
+
fuzziness,
|
1378
|
+
target,
|
1379
|
+
prefix,
|
1380
|
+
filter,
|
1381
|
+
highlight,
|
1382
|
+
boosters
|
1383
|
+
}) {
|
1384
|
+
return operationsByTag.searchAndFilter.searchTable({
|
1385
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1386
|
+
body: { query, fuzziness, target, prefix, filter, highlight, boosters },
|
1387
|
+
...this.extraProps
|
1388
|
+
});
|
1389
|
+
}
|
1390
|
+
searchBranch({
|
1391
|
+
workspace,
|
1392
|
+
region,
|
1393
|
+
database,
|
1394
|
+
branch,
|
1395
|
+
tables,
|
1396
|
+
query,
|
1397
|
+
fuzziness,
|
1398
|
+
prefix,
|
1399
|
+
highlight
|
1400
|
+
}) {
|
1401
|
+
return operationsByTag.searchAndFilter.searchBranch({
|
1402
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1403
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
1404
|
+
...this.extraProps
|
1405
|
+
});
|
1406
|
+
}
|
1407
|
+
summarizeTable({
|
1408
|
+
workspace,
|
1409
|
+
region,
|
1410
|
+
database,
|
1411
|
+
branch,
|
1412
|
+
table,
|
1413
|
+
filter,
|
1414
|
+
columns,
|
1415
|
+
summaries,
|
1416
|
+
sort,
|
1417
|
+
summariesFilter,
|
1418
|
+
page
|
1419
|
+
}) {
|
1420
|
+
return operationsByTag.searchAndFilter.summarizeTable({
|
1421
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1422
|
+
body: { filter, columns, summaries, sort, summariesFilter, page },
|
1423
|
+
...this.extraProps
|
1424
|
+
});
|
1425
|
+
}
|
1426
|
+
aggregateTable({
|
1427
|
+
workspace,
|
1428
|
+
region,
|
1429
|
+
database,
|
1430
|
+
branch,
|
1431
|
+
table,
|
1432
|
+
filter,
|
1433
|
+
aggs
|
1434
|
+
}) {
|
1435
|
+
return operationsByTag.searchAndFilter.aggregateTable({
|
1436
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1437
|
+
body: { filter, aggs },
|
1107
1438
|
...this.extraProps
|
1108
1439
|
});
|
1109
1440
|
}
|
@@ -1112,123 +1443,281 @@ class MigrationRequestsApi {
|
|
1112
1443
|
constructor(extraProps) {
|
1113
1444
|
this.extraProps = extraProps;
|
1114
1445
|
}
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1446
|
+
queryMigrationRequests({
|
1447
|
+
workspace,
|
1448
|
+
region,
|
1449
|
+
database,
|
1450
|
+
filter,
|
1451
|
+
sort,
|
1452
|
+
page,
|
1453
|
+
columns
|
1454
|
+
}) {
|
1455
|
+
return operationsByTag.migrationRequests.queryMigrationRequests({
|
1456
|
+
pathParams: { workspace, region, dbName: database },
|
1457
|
+
body: { filter, sort, page, columns },
|
1458
|
+
...this.extraProps
|
1459
|
+
});
|
1460
|
+
}
|
1461
|
+
createMigrationRequest({
|
1462
|
+
workspace,
|
1463
|
+
region,
|
1464
|
+
database,
|
1465
|
+
migration
|
1466
|
+
}) {
|
1123
1467
|
return operationsByTag.migrationRequests.createMigrationRequest({
|
1124
|
-
pathParams: { workspace, dbName: database },
|
1125
|
-
body:
|
1468
|
+
pathParams: { workspace, region, dbName: database },
|
1469
|
+
body: migration,
|
1126
1470
|
...this.extraProps
|
1127
1471
|
});
|
1128
1472
|
}
|
1129
|
-
getMigrationRequest(
|
1473
|
+
getMigrationRequest({
|
1474
|
+
workspace,
|
1475
|
+
region,
|
1476
|
+
database,
|
1477
|
+
migrationRequest
|
1478
|
+
}) {
|
1130
1479
|
return operationsByTag.migrationRequests.getMigrationRequest({
|
1131
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1480
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1132
1481
|
...this.extraProps
|
1133
1482
|
});
|
1134
1483
|
}
|
1135
|
-
updateMigrationRequest(
|
1484
|
+
updateMigrationRequest({
|
1485
|
+
workspace,
|
1486
|
+
region,
|
1487
|
+
database,
|
1488
|
+
migrationRequest,
|
1489
|
+
update
|
1490
|
+
}) {
|
1136
1491
|
return operationsByTag.migrationRequests.updateMigrationRequest({
|
1137
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1138
|
-
body:
|
1492
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1493
|
+
body: update,
|
1139
1494
|
...this.extraProps
|
1140
1495
|
});
|
1141
1496
|
}
|
1142
|
-
listMigrationRequestsCommits(
|
1497
|
+
listMigrationRequestsCommits({
|
1498
|
+
workspace,
|
1499
|
+
region,
|
1500
|
+
database,
|
1501
|
+
migrationRequest,
|
1502
|
+
page
|
1503
|
+
}) {
|
1143
1504
|
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
1144
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1145
|
-
body:
|
1505
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1506
|
+
body: { page },
|
1146
1507
|
...this.extraProps
|
1147
1508
|
});
|
1148
1509
|
}
|
1149
|
-
compareMigrationRequest(
|
1510
|
+
compareMigrationRequest({
|
1511
|
+
workspace,
|
1512
|
+
region,
|
1513
|
+
database,
|
1514
|
+
migrationRequest
|
1515
|
+
}) {
|
1150
1516
|
return operationsByTag.migrationRequests.compareMigrationRequest({
|
1151
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1517
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1152
1518
|
...this.extraProps
|
1153
1519
|
});
|
1154
1520
|
}
|
1155
|
-
getMigrationRequestIsMerged(
|
1521
|
+
getMigrationRequestIsMerged({
|
1522
|
+
workspace,
|
1523
|
+
region,
|
1524
|
+
database,
|
1525
|
+
migrationRequest
|
1526
|
+
}) {
|
1156
1527
|
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
1157
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1528
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1158
1529
|
...this.extraProps
|
1159
1530
|
});
|
1160
1531
|
}
|
1161
|
-
mergeMigrationRequest(
|
1532
|
+
mergeMigrationRequest({
|
1533
|
+
workspace,
|
1534
|
+
region,
|
1535
|
+
database,
|
1536
|
+
migrationRequest
|
1537
|
+
}) {
|
1162
1538
|
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
1163
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1539
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1164
1540
|
...this.extraProps
|
1165
1541
|
});
|
1166
1542
|
}
|
1167
1543
|
}
|
1168
|
-
class
|
1544
|
+
class MigrationsApi {
|
1169
1545
|
constructor(extraProps) {
|
1170
1546
|
this.extraProps = extraProps;
|
1171
1547
|
}
|
1172
|
-
getBranchMigrationHistory(
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1548
|
+
getBranchMigrationHistory({
|
1549
|
+
workspace,
|
1550
|
+
region,
|
1551
|
+
database,
|
1552
|
+
branch,
|
1553
|
+
limit,
|
1554
|
+
startFrom
|
1555
|
+
}) {
|
1556
|
+
return operationsByTag.migrations.getBranchMigrationHistory({
|
1557
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1558
|
+
body: { limit, startFrom },
|
1559
|
+
...this.extraProps
|
1560
|
+
});
|
1561
|
+
}
|
1562
|
+
getBranchMigrationPlan({
|
1563
|
+
workspace,
|
1564
|
+
region,
|
1565
|
+
database,
|
1566
|
+
branch,
|
1567
|
+
schema
|
1568
|
+
}) {
|
1569
|
+
return operationsByTag.migrations.getBranchMigrationPlan({
|
1570
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1571
|
+
body: schema,
|
1176
1572
|
...this.extraProps
|
1177
1573
|
});
|
1178
1574
|
}
|
1179
|
-
executeBranchMigrationPlan(
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1575
|
+
executeBranchMigrationPlan({
|
1576
|
+
workspace,
|
1577
|
+
region,
|
1578
|
+
database,
|
1579
|
+
branch,
|
1580
|
+
plan
|
1581
|
+
}) {
|
1582
|
+
return operationsByTag.migrations.executeBranchMigrationPlan({
|
1583
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1584
|
+
body: plan,
|
1183
1585
|
...this.extraProps
|
1184
1586
|
});
|
1185
1587
|
}
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1588
|
+
getBranchSchemaHistory({
|
1589
|
+
workspace,
|
1590
|
+
region,
|
1591
|
+
database,
|
1592
|
+
branch,
|
1593
|
+
page
|
1594
|
+
}) {
|
1595
|
+
return operationsByTag.migrations.getBranchSchemaHistory({
|
1596
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1597
|
+
body: { page },
|
1190
1598
|
...this.extraProps
|
1191
1599
|
});
|
1192
1600
|
}
|
1193
|
-
compareBranchWithUserSchema(
|
1194
|
-
|
1195
|
-
|
1601
|
+
compareBranchWithUserSchema({
|
1602
|
+
workspace,
|
1603
|
+
region,
|
1604
|
+
database,
|
1605
|
+
branch,
|
1606
|
+
schema
|
1607
|
+
}) {
|
1608
|
+
return operationsByTag.migrations.compareBranchWithUserSchema({
|
1609
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1196
1610
|
body: { schema },
|
1197
1611
|
...this.extraProps
|
1198
1612
|
});
|
1199
1613
|
}
|
1200
|
-
compareBranchSchemas(
|
1201
|
-
|
1202
|
-
|
1614
|
+
compareBranchSchemas({
|
1615
|
+
workspace,
|
1616
|
+
region,
|
1617
|
+
database,
|
1618
|
+
branch,
|
1619
|
+
compare,
|
1620
|
+
schema
|
1621
|
+
}) {
|
1622
|
+
return operationsByTag.migrations.compareBranchSchemas({
|
1623
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
1203
1624
|
body: { schema },
|
1204
1625
|
...this.extraProps
|
1205
1626
|
});
|
1206
1627
|
}
|
1207
|
-
updateBranchSchema(
|
1208
|
-
|
1209
|
-
|
1628
|
+
updateBranchSchema({
|
1629
|
+
workspace,
|
1630
|
+
region,
|
1631
|
+
database,
|
1632
|
+
branch,
|
1633
|
+
migration
|
1634
|
+
}) {
|
1635
|
+
return operationsByTag.migrations.updateBranchSchema({
|
1636
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1210
1637
|
body: migration,
|
1211
1638
|
...this.extraProps
|
1212
1639
|
});
|
1213
1640
|
}
|
1214
|
-
previewBranchSchemaEdit(
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1641
|
+
previewBranchSchemaEdit({
|
1642
|
+
workspace,
|
1643
|
+
region,
|
1644
|
+
database,
|
1645
|
+
branch,
|
1646
|
+
data
|
1647
|
+
}) {
|
1648
|
+
return operationsByTag.migrations.previewBranchSchemaEdit({
|
1649
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1650
|
+
body: data,
|
1218
1651
|
...this.extraProps
|
1219
1652
|
});
|
1220
1653
|
}
|
1221
|
-
applyBranchSchemaEdit(
|
1222
|
-
|
1223
|
-
|
1654
|
+
applyBranchSchemaEdit({
|
1655
|
+
workspace,
|
1656
|
+
region,
|
1657
|
+
database,
|
1658
|
+
branch,
|
1659
|
+
edits
|
1660
|
+
}) {
|
1661
|
+
return operationsByTag.migrations.applyBranchSchemaEdit({
|
1662
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1224
1663
|
body: { edits },
|
1225
1664
|
...this.extraProps
|
1226
1665
|
});
|
1227
1666
|
}
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1667
|
+
}
|
1668
|
+
class DatabaseApi {
|
1669
|
+
constructor(extraProps) {
|
1670
|
+
this.extraProps = extraProps;
|
1671
|
+
}
|
1672
|
+
getDatabaseList({ workspace }) {
|
1673
|
+
return operationsByTag.databases.getDatabaseList({
|
1674
|
+
pathParams: { workspaceId: workspace },
|
1675
|
+
...this.extraProps
|
1676
|
+
});
|
1677
|
+
}
|
1678
|
+
createDatabase({
|
1679
|
+
workspace,
|
1680
|
+
database,
|
1681
|
+
data
|
1682
|
+
}) {
|
1683
|
+
return operationsByTag.databases.createDatabase({
|
1684
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1685
|
+
body: data,
|
1686
|
+
...this.extraProps
|
1687
|
+
});
|
1688
|
+
}
|
1689
|
+
deleteDatabase({
|
1690
|
+
workspace,
|
1691
|
+
database
|
1692
|
+
}) {
|
1693
|
+
return operationsByTag.databases.deleteDatabase({
|
1694
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1695
|
+
...this.extraProps
|
1696
|
+
});
|
1697
|
+
}
|
1698
|
+
getDatabaseMetadata({
|
1699
|
+
workspace,
|
1700
|
+
database
|
1701
|
+
}) {
|
1702
|
+
return operationsByTag.databases.getDatabaseMetadata({
|
1703
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1704
|
+
...this.extraProps
|
1705
|
+
});
|
1706
|
+
}
|
1707
|
+
updateDatabaseMetadata({
|
1708
|
+
workspace,
|
1709
|
+
database,
|
1710
|
+
metadata
|
1711
|
+
}) {
|
1712
|
+
return operationsByTag.databases.updateDatabaseMetadata({
|
1713
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1714
|
+
body: metadata,
|
1715
|
+
...this.extraProps
|
1716
|
+
});
|
1717
|
+
}
|
1718
|
+
listRegions({ workspace }) {
|
1719
|
+
return operationsByTag.databases.listRegions({
|
1720
|
+
pathParams: { workspaceId: workspace },
|
1232
1721
|
...this.extraProps
|
1233
1722
|
});
|
1234
1723
|
}
|
@@ -1244,6 +1733,20 @@ class XataApiPlugin {
|
|
1244
1733
|
class XataPlugin {
|
1245
1734
|
}
|
1246
1735
|
|
1736
|
+
function generateUUID() {
|
1737
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
1738
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
1739
|
+
return v.toString(16);
|
1740
|
+
});
|
1741
|
+
}
|
1742
|
+
|
1743
|
+
function cleanFilter(filter) {
|
1744
|
+
if (!filter)
|
1745
|
+
return void 0;
|
1746
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
1747
|
+
return values.length > 0 ? filter : void 0;
|
1748
|
+
}
|
1749
|
+
|
1247
1750
|
var __accessCheck$6 = (obj, member, msg) => {
|
1248
1751
|
if (!member.has(obj))
|
1249
1752
|
throw TypeError("Cannot " + msg);
|
@@ -1357,9 +1860,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
|
|
1357
1860
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1358
1861
|
return value;
|
1359
1862
|
};
|
1360
|
-
var
|
1863
|
+
var __privateMethod$3 = (obj, member, method) => {
|
1864
|
+
__accessCheck$5(obj, member, "access private method");
|
1865
|
+
return method;
|
1866
|
+
};
|
1867
|
+
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
1361
1868
|
const _Query = class {
|
1362
1869
|
constructor(repository, table, data, rawParent) {
|
1870
|
+
__privateAdd$5(this, _cleanFilterConstraint);
|
1363
1871
|
__privateAdd$5(this, _table$1, void 0);
|
1364
1872
|
__privateAdd$5(this, _repository, void 0);
|
1365
1873
|
__privateAdd$5(this, _data, { filter: {} });
|
@@ -1378,7 +1886,7 @@ const _Query = class {
|
|
1378
1886
|
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
1379
1887
|
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
1380
1888
|
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
1381
|
-
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns
|
1889
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
|
1382
1890
|
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
1383
1891
|
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
1384
1892
|
this.any = this.any.bind(this);
|
@@ -1416,22 +1924,17 @@ const _Query = class {
|
|
1416
1924
|
}
|
1417
1925
|
filter(a, b) {
|
1418
1926
|
if (arguments.length === 1) {
|
1419
|
-
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
1927
|
+
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
1928
|
+
[column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
|
1929
|
+
}));
|
1420
1930
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1421
1931
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1422
1932
|
} else {
|
1423
|
-
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.
|
1933
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
|
1424
1934
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1425
1935
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1426
1936
|
}
|
1427
1937
|
}
|
1428
|
-
defaultFilter(column, value) {
|
1429
|
-
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
1430
|
-
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
1431
|
-
return { $includes: value };
|
1432
|
-
}
|
1433
|
-
return value;
|
1434
|
-
}
|
1435
1938
|
sort(column, direction = "asc") {
|
1436
1939
|
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
1437
1940
|
const sort = [...originalSort, { column, direction }];
|
@@ -1499,6 +2002,16 @@ const _Query = class {
|
|
1499
2002
|
throw new Error("No results found.");
|
1500
2003
|
return records[0];
|
1501
2004
|
}
|
2005
|
+
async summarize(params = {}) {
|
2006
|
+
const { summaries, summariesFilter, ...options } = params;
|
2007
|
+
const query = new _Query(
|
2008
|
+
__privateGet$5(this, _repository),
|
2009
|
+
__privateGet$5(this, _table$1),
|
2010
|
+
options,
|
2011
|
+
__privateGet$5(this, _data)
|
2012
|
+
);
|
2013
|
+
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
2014
|
+
}
|
1502
2015
|
cache(ttl) {
|
1503
2016
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1504
2017
|
}
|
@@ -1522,9 +2035,20 @@ let Query = _Query;
|
|
1522
2035
|
_table$1 = new WeakMap();
|
1523
2036
|
_repository = new WeakMap();
|
1524
2037
|
_data = new WeakMap();
|
2038
|
+
_cleanFilterConstraint = new WeakSet();
|
2039
|
+
cleanFilterConstraint_fn = function(column, value) {
|
2040
|
+
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
2041
|
+
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
2042
|
+
return { $includes: value };
|
2043
|
+
}
|
2044
|
+
if (columnType === "link" && isObject(value) && isString(value.id)) {
|
2045
|
+
return value.id;
|
2046
|
+
}
|
2047
|
+
return value;
|
2048
|
+
};
|
1525
2049
|
function cleanParent(data, parent) {
|
1526
2050
|
if (isCursorPaginationOptions(data.pagination)) {
|
1527
|
-
return { ...parent,
|
2051
|
+
return { ...parent, sort: void 0, filter: void 0 };
|
1528
2052
|
}
|
1529
2053
|
return parent;
|
1530
2054
|
}
|
@@ -1609,10 +2133,13 @@ class RestRepository extends Query {
|
|
1609
2133
|
__privateAdd$4(this, _schemaTables$2, void 0);
|
1610
2134
|
__privateAdd$4(this, _trace, void 0);
|
1611
2135
|
__privateSet$4(this, _table, options.table);
|
1612
|
-
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1613
2136
|
__privateSet$4(this, _db, options.db);
|
1614
2137
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
1615
2138
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
2139
|
+
__privateSet$4(this, _getFetchProps, async () => {
|
2140
|
+
const props = await options.pluginOptions.getFetchProps();
|
2141
|
+
return { ...props, sessionID: generateUUID() };
|
2142
|
+
});
|
1616
2143
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
1617
2144
|
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
1618
2145
|
return trace(name, fn, {
|
@@ -1623,8 +2150,9 @@ class RestRepository extends Query {
|
|
1623
2150
|
});
|
1624
2151
|
});
|
1625
2152
|
}
|
1626
|
-
async create(a, b, c) {
|
2153
|
+
async create(a, b, c, d) {
|
1627
2154
|
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
2155
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1628
2156
|
if (Array.isArray(a)) {
|
1629
2157
|
if (a.length === 0)
|
1630
2158
|
return [];
|
@@ -1635,13 +2163,13 @@ class RestRepository extends Query {
|
|
1635
2163
|
if (a === "")
|
1636
2164
|
throw new Error("The id can't be empty");
|
1637
2165
|
const columns = isStringArray(c) ? c : void 0;
|
1638
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
2166
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
1639
2167
|
}
|
1640
2168
|
if (isObject(a) && isString(a.id)) {
|
1641
2169
|
if (a.id === "")
|
1642
2170
|
throw new Error("The id can't be empty");
|
1643
2171
|
const columns = isStringArray(b) ? b : void 0;
|
1644
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
2172
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
1645
2173
|
}
|
1646
2174
|
if (isObject(a)) {
|
1647
2175
|
const columns = isStringArray(b) ? b : void 0;
|
@@ -1672,6 +2200,7 @@ class RestRepository extends Query {
|
|
1672
2200
|
pathParams: {
|
1673
2201
|
workspace: "{workspaceId}",
|
1674
2202
|
dbBranchName: "{dbBranch}",
|
2203
|
+
region: "{region}",
|
1675
2204
|
tableName: __privateGet$4(this, _table),
|
1676
2205
|
recordId: id
|
1677
2206
|
},
|
@@ -1679,7 +2208,7 @@ class RestRepository extends Query {
|
|
1679
2208
|
...fetchProps
|
1680
2209
|
});
|
1681
2210
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1682
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2211
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1683
2212
|
} catch (e) {
|
1684
2213
|
if (isObject(e) && e.status === 404) {
|
1685
2214
|
return null;
|
@@ -1709,8 +2238,9 @@ class RestRepository extends Query {
|
|
1709
2238
|
return result;
|
1710
2239
|
});
|
1711
2240
|
}
|
1712
|
-
async update(a, b, c) {
|
2241
|
+
async update(a, b, c, d) {
|
1713
2242
|
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
2243
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1714
2244
|
if (Array.isArray(a)) {
|
1715
2245
|
if (a.length === 0)
|
1716
2246
|
return [];
|
@@ -1722,18 +2252,18 @@ class RestRepository extends Query {
|
|
1722
2252
|
}
|
1723
2253
|
if (isString(a) && isObject(b)) {
|
1724
2254
|
const columns = isStringArray(c) ? c : void 0;
|
1725
|
-
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
|
2255
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
1726
2256
|
}
|
1727
2257
|
if (isObject(a) && isString(a.id)) {
|
1728
2258
|
const columns = isStringArray(b) ? b : void 0;
|
1729
|
-
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
2259
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
1730
2260
|
}
|
1731
2261
|
throw new Error("Invalid arguments for update method");
|
1732
2262
|
});
|
1733
2263
|
}
|
1734
|
-
async updateOrThrow(a, b, c) {
|
2264
|
+
async updateOrThrow(a, b, c, d) {
|
1735
2265
|
return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
|
1736
|
-
const result = await this.update(a, b, c);
|
2266
|
+
const result = await this.update(a, b, c, d);
|
1737
2267
|
if (Array.isArray(result)) {
|
1738
2268
|
const missingIds = compact(
|
1739
2269
|
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
@@ -1750,8 +2280,9 @@ class RestRepository extends Query {
|
|
1750
2280
|
return result;
|
1751
2281
|
});
|
1752
2282
|
}
|
1753
|
-
async createOrUpdate(a, b, c) {
|
2283
|
+
async createOrUpdate(a, b, c, d) {
|
1754
2284
|
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
2285
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1755
2286
|
if (Array.isArray(a)) {
|
1756
2287
|
if (a.length === 0)
|
1757
2288
|
return [];
|
@@ -1763,15 +2294,35 @@ class RestRepository extends Query {
|
|
1763
2294
|
}
|
1764
2295
|
if (isString(a) && isObject(b)) {
|
1765
2296
|
const columns = isStringArray(c) ? c : void 0;
|
1766
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
|
2297
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
1767
2298
|
}
|
1768
2299
|
if (isObject(a) && isString(a.id)) {
|
1769
2300
|
const columns = isStringArray(c) ? c : void 0;
|
1770
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
2301
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
1771
2302
|
}
|
1772
2303
|
throw new Error("Invalid arguments for createOrUpdate method");
|
1773
2304
|
});
|
1774
2305
|
}
|
2306
|
+
async createOrReplace(a, b, c, d) {
|
2307
|
+
return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
|
2308
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2309
|
+
if (Array.isArray(a)) {
|
2310
|
+
if (a.length === 0)
|
2311
|
+
return [];
|
2312
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2313
|
+
return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
|
2314
|
+
}
|
2315
|
+
if (isString(a) && isObject(b)) {
|
2316
|
+
const columns = isStringArray(c) ? c : void 0;
|
2317
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
2318
|
+
}
|
2319
|
+
if (isObject(a) && isString(a.id)) {
|
2320
|
+
const columns = isStringArray(c) ? c : void 0;
|
2321
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
2322
|
+
}
|
2323
|
+
throw new Error("Invalid arguments for createOrReplace method");
|
2324
|
+
});
|
2325
|
+
}
|
1775
2326
|
async delete(a, b) {
|
1776
2327
|
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
1777
2328
|
if (Array.isArray(a)) {
|
@@ -1813,7 +2364,12 @@ class RestRepository extends Query {
|
|
1813
2364
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
1814
2365
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1815
2366
|
const { records } = await searchTable({
|
1816
|
-
pathParams: {
|
2367
|
+
pathParams: {
|
2368
|
+
workspace: "{workspaceId}",
|
2369
|
+
dbBranchName: "{dbBranch}",
|
2370
|
+
region: "{region}",
|
2371
|
+
tableName: __privateGet$4(this, _table)
|
2372
|
+
},
|
1817
2373
|
body: {
|
1818
2374
|
query,
|
1819
2375
|
fuzziness: options.fuzziness,
|
@@ -1825,7 +2381,23 @@ class RestRepository extends Query {
|
|
1825
2381
|
...fetchProps
|
1826
2382
|
});
|
1827
2383
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1828
|
-
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
2384
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
2385
|
+
});
|
2386
|
+
}
|
2387
|
+
async aggregate(aggs, filter) {
|
2388
|
+
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
2389
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2390
|
+
const result = await aggregateTable({
|
2391
|
+
pathParams: {
|
2392
|
+
workspace: "{workspaceId}",
|
2393
|
+
dbBranchName: "{dbBranch}",
|
2394
|
+
region: "{region}",
|
2395
|
+
tableName: __privateGet$4(this, _table)
|
2396
|
+
},
|
2397
|
+
body: { aggs, filter },
|
2398
|
+
...fetchProps
|
2399
|
+
});
|
2400
|
+
return result;
|
1829
2401
|
});
|
1830
2402
|
}
|
1831
2403
|
async query(query) {
|
@@ -1834,24 +2406,54 @@ class RestRepository extends Query {
|
|
1834
2406
|
if (cacheQuery)
|
1835
2407
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
1836
2408
|
const data = query.getQueryOptions();
|
1837
|
-
const body = {
|
1838
|
-
filter: cleanFilter(data.filter),
|
1839
|
-
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1840
|
-
page: data.pagination,
|
1841
|
-
columns: data.columns
|
1842
|
-
};
|
1843
2409
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1844
2410
|
const { meta, records: objects } = await queryTable({
|
1845
|
-
pathParams: {
|
1846
|
-
|
2411
|
+
pathParams: {
|
2412
|
+
workspace: "{workspaceId}",
|
2413
|
+
dbBranchName: "{dbBranch}",
|
2414
|
+
region: "{region}",
|
2415
|
+
tableName: __privateGet$4(this, _table)
|
2416
|
+
},
|
2417
|
+
body: {
|
2418
|
+
filter: cleanFilter(data.filter),
|
2419
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2420
|
+
page: data.pagination,
|
2421
|
+
columns: data.columns ?? ["*"]
|
2422
|
+
},
|
1847
2423
|
...fetchProps
|
1848
2424
|
});
|
1849
2425
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1850
|
-
const records = objects.map(
|
2426
|
+
const records = objects.map(
|
2427
|
+
(record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
|
2428
|
+
);
|
1851
2429
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1852
2430
|
return new Page(query, meta, records);
|
1853
2431
|
});
|
1854
2432
|
}
|
2433
|
+
async summarizeTable(query, summaries, summariesFilter) {
|
2434
|
+
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
2435
|
+
const data = query.getQueryOptions();
|
2436
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2437
|
+
const result = await summarizeTable({
|
2438
|
+
pathParams: {
|
2439
|
+
workspace: "{workspaceId}",
|
2440
|
+
dbBranchName: "{dbBranch}",
|
2441
|
+
region: "{region}",
|
2442
|
+
tableName: __privateGet$4(this, _table)
|
2443
|
+
},
|
2444
|
+
body: {
|
2445
|
+
filter: cleanFilter(data.filter),
|
2446
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2447
|
+
columns: data.columns,
|
2448
|
+
page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
|
2449
|
+
summaries,
|
2450
|
+
summariesFilter
|
2451
|
+
},
|
2452
|
+
...fetchProps
|
2453
|
+
});
|
2454
|
+
return result;
|
2455
|
+
});
|
2456
|
+
}
|
1855
2457
|
}
|
1856
2458
|
_table = new WeakMap();
|
1857
2459
|
_getFetchProps = new WeakMap();
|
@@ -1867,6 +2469,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1867
2469
|
pathParams: {
|
1868
2470
|
workspace: "{workspaceId}",
|
1869
2471
|
dbBranchName: "{dbBranch}",
|
2472
|
+
region: "{region}",
|
1870
2473
|
tableName: __privateGet$4(this, _table)
|
1871
2474
|
},
|
1872
2475
|
queryParams: { columns },
|
@@ -1874,32 +2477,38 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1874
2477
|
...fetchProps
|
1875
2478
|
});
|
1876
2479
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1877
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2480
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1878
2481
|
};
|
1879
2482
|
_insertRecordWithId = new WeakSet();
|
1880
|
-
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
2483
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
1881
2484
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1882
2485
|
const record = transformObjectLinks(object);
|
1883
2486
|
const response = await insertRecordWithID({
|
1884
2487
|
pathParams: {
|
1885
2488
|
workspace: "{workspaceId}",
|
1886
2489
|
dbBranchName: "{dbBranch}",
|
2490
|
+
region: "{region}",
|
1887
2491
|
tableName: __privateGet$4(this, _table),
|
1888
2492
|
recordId
|
1889
2493
|
},
|
1890
2494
|
body: record,
|
1891
|
-
queryParams: { createOnly
|
2495
|
+
queryParams: { createOnly, columns, ifVersion },
|
1892
2496
|
...fetchProps
|
1893
2497
|
});
|
1894
2498
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1895
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2499
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1896
2500
|
};
|
1897
2501
|
_bulkInsertTableRecords = new WeakSet();
|
1898
2502
|
bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
1899
2503
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1900
2504
|
const records = objects.map((object) => transformObjectLinks(object));
|
1901
2505
|
const response = await bulkInsertTableRecords({
|
1902
|
-
pathParams: {
|
2506
|
+
pathParams: {
|
2507
|
+
workspace: "{workspaceId}",
|
2508
|
+
dbBranchName: "{dbBranch}",
|
2509
|
+
region: "{region}",
|
2510
|
+
tableName: __privateGet$4(this, _table)
|
2511
|
+
},
|
1903
2512
|
queryParams: { columns },
|
1904
2513
|
body: { records },
|
1905
2514
|
...fetchProps
|
@@ -1908,21 +2517,27 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
|
1908
2517
|
throw new Error("Request included columns but server didn't include them");
|
1909
2518
|
}
|
1910
2519
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1911
|
-
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
2520
|
+
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
|
1912
2521
|
};
|
1913
2522
|
_updateRecordWithID = new WeakSet();
|
1914
|
-
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2523
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
1915
2524
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1916
2525
|
const record = transformObjectLinks(object);
|
1917
2526
|
try {
|
1918
2527
|
const response = await updateRecordWithID({
|
1919
|
-
pathParams: {
|
1920
|
-
|
2528
|
+
pathParams: {
|
2529
|
+
workspace: "{workspaceId}",
|
2530
|
+
dbBranchName: "{dbBranch}",
|
2531
|
+
region: "{region}",
|
2532
|
+
tableName: __privateGet$4(this, _table),
|
2533
|
+
recordId
|
2534
|
+
},
|
2535
|
+
queryParams: { columns, ifVersion },
|
1921
2536
|
body: record,
|
1922
2537
|
...fetchProps
|
1923
2538
|
});
|
1924
2539
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1925
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2540
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1926
2541
|
} catch (e) {
|
1927
2542
|
if (isObject(e) && e.status === 404) {
|
1928
2543
|
return null;
|
@@ -1931,28 +2546,40 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
1931
2546
|
}
|
1932
2547
|
};
|
1933
2548
|
_upsertRecordWithID = new WeakSet();
|
1934
|
-
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2549
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
1935
2550
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1936
2551
|
const response = await upsertRecordWithID({
|
1937
|
-
pathParams: {
|
1938
|
-
|
2552
|
+
pathParams: {
|
2553
|
+
workspace: "{workspaceId}",
|
2554
|
+
dbBranchName: "{dbBranch}",
|
2555
|
+
region: "{region}",
|
2556
|
+
tableName: __privateGet$4(this, _table),
|
2557
|
+
recordId
|
2558
|
+
},
|
2559
|
+
queryParams: { columns, ifVersion },
|
1939
2560
|
body: object,
|
1940
2561
|
...fetchProps
|
1941
2562
|
});
|
1942
2563
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1943
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2564
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1944
2565
|
};
|
1945
2566
|
_deleteRecord = new WeakSet();
|
1946
2567
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
1947
2568
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1948
2569
|
try {
|
1949
2570
|
const response = await deleteRecord({
|
1950
|
-
pathParams: {
|
2571
|
+
pathParams: {
|
2572
|
+
workspace: "{workspaceId}",
|
2573
|
+
dbBranchName: "{dbBranch}",
|
2574
|
+
region: "{region}",
|
2575
|
+
tableName: __privateGet$4(this, _table),
|
2576
|
+
recordId
|
2577
|
+
},
|
1951
2578
|
queryParams: { columns },
|
1952
2579
|
...fetchProps
|
1953
2580
|
});
|
1954
2581
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1955
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2582
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1956
2583
|
} catch (e) {
|
1957
2584
|
if (isObject(e) && e.status === 404) {
|
1958
2585
|
return null;
|
@@ -1982,7 +2609,7 @@ getSchemaTables_fn$1 = async function() {
|
|
1982
2609
|
return __privateGet$4(this, _schemaTables$2);
|
1983
2610
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1984
2611
|
const { schema } = await getBranchDetails({
|
1985
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2612
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
1986
2613
|
...fetchProps
|
1987
2614
|
});
|
1988
2615
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
@@ -1995,7 +2622,7 @@ const transformObjectLinks = (object) => {
|
|
1995
2622
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1996
2623
|
}, {});
|
1997
2624
|
};
|
1998
|
-
const initObject = (db, schemaTables, table, object) => {
|
2625
|
+
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
1999
2626
|
const result = {};
|
2000
2627
|
const { xata, ...rest } = object ?? {};
|
2001
2628
|
Object.assign(result, rest);
|
@@ -2003,6 +2630,8 @@ const initObject = (db, schemaTables, table, object) => {
|
|
2003
2630
|
if (!columns)
|
2004
2631
|
console.error(`Table ${table} not found in schema`);
|
2005
2632
|
for (const column of columns ?? []) {
|
2633
|
+
if (!isValidColumn(selectedColumns, column))
|
2634
|
+
continue;
|
2006
2635
|
const value = result[column.name];
|
2007
2636
|
switch (column.type) {
|
2008
2637
|
case "datetime": {
|
@@ -2019,7 +2648,17 @@ const initObject = (db, schemaTables, table, object) => {
|
|
2019
2648
|
if (!linkTable) {
|
2020
2649
|
console.error(`Failed to parse link for field ${column.name}`);
|
2021
2650
|
} else if (isObject(value)) {
|
2022
|
-
|
2651
|
+
const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
|
2652
|
+
if (item === column.name) {
|
2653
|
+
return [...acc, "*"];
|
2654
|
+
}
|
2655
|
+
if (item.startsWith(`${column.name}.`)) {
|
2656
|
+
const [, ...path] = item.split(".");
|
2657
|
+
return [...acc, path.join(".")];
|
2658
|
+
}
|
2659
|
+
return acc;
|
2660
|
+
}, []);
|
2661
|
+
result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
|
2023
2662
|
} else {
|
2024
2663
|
result[column.name] = null;
|
2025
2664
|
}
|
@@ -2036,8 +2675,15 @@ const initObject = (db, schemaTables, table, object) => {
|
|
2036
2675
|
result.read = function(columns2) {
|
2037
2676
|
return db[table].read(result["id"], columns2);
|
2038
2677
|
};
|
2039
|
-
result.update = function(data,
|
2040
|
-
|
2678
|
+
result.update = function(data, b, c) {
|
2679
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2680
|
+
const ifVersion = parseIfVersion(b, c);
|
2681
|
+
return db[table].update(result["id"], data, columns2, { ifVersion });
|
2682
|
+
};
|
2683
|
+
result.replace = function(data, b, c) {
|
2684
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2685
|
+
const ifVersion = parseIfVersion(b, c);
|
2686
|
+
return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
|
2041
2687
|
};
|
2042
2688
|
result.delete = function() {
|
2043
2689
|
return db[table].delete(result["id"]);
|
@@ -2045,7 +2691,7 @@ const initObject = (db, schemaTables, table, object) => {
|
|
2045
2691
|
result.getMetadata = function() {
|
2046
2692
|
return xata;
|
2047
2693
|
};
|
2048
|
-
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
2694
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
|
2049
2695
|
Object.defineProperty(result, prop, { enumerable: false });
|
2050
2696
|
}
|
2051
2697
|
Object.freeze(result);
|
@@ -2061,11 +2707,22 @@ function extractId(value) {
|
|
2061
2707
|
return value.id;
|
2062
2708
|
return void 0;
|
2063
2709
|
}
|
2064
|
-
function
|
2065
|
-
if (
|
2066
|
-
return
|
2067
|
-
|
2068
|
-
|
2710
|
+
function isValidColumn(columns, column) {
|
2711
|
+
if (columns.includes("*"))
|
2712
|
+
return true;
|
2713
|
+
if (column.type === "link") {
|
2714
|
+
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
2715
|
+
return linkColumns.length > 0;
|
2716
|
+
}
|
2717
|
+
return columns.includes(column.name);
|
2718
|
+
}
|
2719
|
+
function parseIfVersion(...args) {
|
2720
|
+
for (const arg of args) {
|
2721
|
+
if (isObject(arg) && isNumber(arg.ifVersion)) {
|
2722
|
+
return arg.ifVersion;
|
2723
|
+
}
|
2724
|
+
}
|
2725
|
+
return void 0;
|
2069
2726
|
}
|
2070
2727
|
|
2071
2728
|
var __accessCheck$3 = (obj, member, msg) => {
|
@@ -2232,7 +2889,7 @@ class SearchPlugin extends XataPlugin {
|
|
2232
2889
|
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
2233
2890
|
return records.map((record) => {
|
2234
2891
|
const { table = "orphan" } = record.xata;
|
2235
|
-
return { table, record: initObject(this.db, schemaTables, table, record) };
|
2892
|
+
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
2236
2893
|
});
|
2237
2894
|
},
|
2238
2895
|
byTable: async (query, options = {}) => {
|
@@ -2241,7 +2898,7 @@ class SearchPlugin extends XataPlugin {
|
|
2241
2898
|
return records.reduce((acc, record) => {
|
2242
2899
|
const { table = "orphan" } = record.xata;
|
2243
2900
|
const items = acc[table] ?? [];
|
2244
|
-
const item = initObject(this.db, schemaTables, table, record);
|
2901
|
+
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
2245
2902
|
return { ...acc, [table]: [...items, item] };
|
2246
2903
|
}, {});
|
2247
2904
|
}
|
@@ -2254,7 +2911,7 @@ search_fn = async function(query, options, getFetchProps) {
|
|
2254
2911
|
const fetchProps = await getFetchProps();
|
2255
2912
|
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
2256
2913
|
const { records } = await searchBranch({
|
2257
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2914
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2258
2915
|
body: { tables, query, fuzziness, prefix, highlight },
|
2259
2916
|
...fetchProps
|
2260
2917
|
});
|
@@ -2266,7 +2923,7 @@ getSchemaTables_fn = async function(getFetchProps) {
|
|
2266
2923
|
return __privateGet$1(this, _schemaTables);
|
2267
2924
|
const fetchProps = await getFetchProps();
|
2268
2925
|
const { schema } = await getBranchDetails({
|
2269
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2926
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2270
2927
|
...fetchProps
|
2271
2928
|
});
|
2272
2929
|
__privateSet$1(this, _schemaTables, schema.tables);
|
@@ -2304,14 +2961,17 @@ async function resolveXataBranch(gitBranch, options) {
|
|
2304
2961
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2305
2962
|
);
|
2306
2963
|
const [protocol, , host, , dbName] = databaseURL.split("/");
|
2307
|
-
const
|
2964
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
2965
|
+
if (!urlParts)
|
2966
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
2967
|
+
const { workspace, region } = urlParts;
|
2308
2968
|
const { fallbackBranch } = getEnvironment();
|
2309
2969
|
const { branch } = await resolveBranch({
|
2310
2970
|
apiKey,
|
2311
2971
|
apiUrl: databaseURL,
|
2312
2972
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2313
2973
|
workspacesApiUrl: `${protocol}//${host}`,
|
2314
|
-
pathParams: { dbName, workspace },
|
2974
|
+
pathParams: { dbName, workspace, region },
|
2315
2975
|
queryParams: { gitBranch, fallbackBranch },
|
2316
2976
|
trace: defaultTrace
|
2317
2977
|
});
|
@@ -2329,15 +2989,17 @@ async function getDatabaseBranch(branch, options) {
|
|
2329
2989
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2330
2990
|
);
|
2331
2991
|
const [protocol, , host, , database] = databaseURL.split("/");
|
2332
|
-
const
|
2333
|
-
|
2992
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
2993
|
+
if (!urlParts)
|
2994
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
2995
|
+
const { workspace, region } = urlParts;
|
2334
2996
|
try {
|
2335
2997
|
return await getBranchDetails({
|
2336
2998
|
apiKey,
|
2337
2999
|
apiUrl: databaseURL,
|
2338
3000
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2339
3001
|
workspacesApiUrl: `${protocol}//${host}`,
|
2340
|
-
pathParams: { dbBranchName
|
3002
|
+
pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
|
2341
3003
|
trace: defaultTrace
|
2342
3004
|
});
|
2343
3005
|
} catch (err) {
|
@@ -2428,8 +3090,8 @@ const buildClient = (plugins) => {
|
|
2428
3090
|
if (!databaseURL) {
|
2429
3091
|
throw new Error("Option databaseURL is required");
|
2430
3092
|
}
|
2431
|
-
return { fetch, databaseURL, apiKey, branch, cache, trace };
|
2432
|
-
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
|
3093
|
+
return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID() };
|
3094
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
|
2433
3095
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
2434
3096
|
if (!branchValue)
|
2435
3097
|
throw new Error("Unable to resolve branch value");
|
@@ -2442,7 +3104,8 @@ const buildClient = (plugins) => {
|
|
2442
3104
|
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
|
2443
3105
|
return databaseURL + newPath;
|
2444
3106
|
},
|
2445
|
-
trace
|
3107
|
+
trace,
|
3108
|
+
clientID
|
2446
3109
|
};
|
2447
3110
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
2448
3111
|
if (__privateGet(this, _branch))
|
@@ -2554,5 +3217,5 @@ class XataError extends Error {
|
|
2554
3217
|
}
|
2555
3218
|
}
|
2556
3219
|
|
2557
|
-
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, applyBranchSchemaEdit, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals,
|
3220
|
+
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, branchTransaction, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, dEPRECATEDcreateDatabase, dEPRECATEDdeleteDatabase, dEPRECATEDgetDatabaseList, dEPRECATEDgetDatabaseMetadata, dEPRECATEDupdateDatabaseMetadata, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
|
2558
3221
|
//# sourceMappingURL=index.mjs.map
|