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