@xata.io/client 0.0.0-alpha.vfd1a215 → 0.0.0-alpha.vfd68d20
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 +104 -0
- package/README.md +8 -8
- package/Usage.md +7 -5
- package/dist/index.cjs +1403 -592
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4165 -1456
- package/dist/index.mjs +1388 -592
- package/dist/index.mjs.map +1 -1
- package/mod.ts +2 -0
- package/package.json +3 -3
- package/{rollup.config.js → rollup.config.mjs} +0 -0
- package/tsconfig.json +1 -1
package/dist/index.cjs
CHANGED
@@ -60,6 +60,9 @@ function isString(value) {
|
|
60
60
|
function isStringArray(value) {
|
61
61
|
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
62
62
|
}
|
63
|
+
function isNumber(value) {
|
64
|
+
return isDefined(value) && typeof value === "number";
|
65
|
+
}
|
63
66
|
function toBase64(value) {
|
64
67
|
try {
|
65
68
|
return btoa(value);
|
@@ -68,6 +71,17 @@ function toBase64(value) {
|
|
68
71
|
return buf.from(value).toString("base64");
|
69
72
|
}
|
70
73
|
}
|
74
|
+
function deepMerge(a, b) {
|
75
|
+
const result = { ...a };
|
76
|
+
for (const [key, value] of Object.entries(b)) {
|
77
|
+
if (isObject(value) && isObject(result[key])) {
|
78
|
+
result[key] = deepMerge(result[key], value);
|
79
|
+
} else {
|
80
|
+
result[key] = value;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
return result;
|
84
|
+
}
|
71
85
|
|
72
86
|
function getEnvironment() {
|
73
87
|
try {
|
@@ -102,6 +116,25 @@ function getEnvironment() {
|
|
102
116
|
fallbackBranch: getGlobalFallbackBranch()
|
103
117
|
};
|
104
118
|
}
|
119
|
+
function getEnableBrowserVariable() {
|
120
|
+
try {
|
121
|
+
if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
|
122
|
+
return process.env.XATA_ENABLE_BROWSER === "true";
|
123
|
+
}
|
124
|
+
} catch (err) {
|
125
|
+
}
|
126
|
+
try {
|
127
|
+
if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
|
128
|
+
return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
|
129
|
+
}
|
130
|
+
} catch (err) {
|
131
|
+
}
|
132
|
+
try {
|
133
|
+
return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
|
134
|
+
} catch (err) {
|
135
|
+
return void 0;
|
136
|
+
}
|
137
|
+
}
|
105
138
|
function getGlobalApiKey() {
|
106
139
|
try {
|
107
140
|
return XATA_API_KEY;
|
@@ -172,7 +205,7 @@ function getFetchImplementation(userFetch) {
|
|
172
205
|
return fetchImpl;
|
173
206
|
}
|
174
207
|
|
175
|
-
const VERSION = "0.0.0-alpha.
|
208
|
+
const VERSION = "0.0.0-alpha.vfd68d20";
|
176
209
|
|
177
210
|
class ErrorWithCause extends Error {
|
178
211
|
constructor(message, options) {
|
@@ -229,15 +262,18 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
229
262
|
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
230
263
|
};
|
231
264
|
function buildBaseUrl({
|
265
|
+
endpoint,
|
232
266
|
path,
|
233
267
|
workspacesApiUrl,
|
234
268
|
apiUrl,
|
235
|
-
pathParams
|
269
|
+
pathParams = {}
|
236
270
|
}) {
|
237
|
-
if (
|
238
|
-
|
239
|
-
|
240
|
-
|
271
|
+
if (endpoint === "dataPlane") {
|
272
|
+
const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
273
|
+
const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
|
274
|
+
return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
|
275
|
+
}
|
276
|
+
return `${apiUrl}${path}`;
|
241
277
|
}
|
242
278
|
function hostHeader(url) {
|
243
279
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
@@ -253,14 +289,19 @@ async function fetch$1({
|
|
253
289
|
queryParams,
|
254
290
|
fetchImpl,
|
255
291
|
apiKey,
|
292
|
+
endpoint,
|
256
293
|
apiUrl,
|
257
294
|
workspacesApiUrl,
|
258
|
-
trace
|
295
|
+
trace,
|
296
|
+
signal,
|
297
|
+
clientID,
|
298
|
+
sessionID,
|
299
|
+
fetchOptions = {}
|
259
300
|
}) {
|
260
301
|
return trace(
|
261
302
|
`${method.toUpperCase()} ${path}`,
|
262
303
|
async ({ setAttributes }) => {
|
263
|
-
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
304
|
+
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
264
305
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
265
306
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
266
307
|
setAttributes({
|
@@ -268,15 +309,19 @@ async function fetch$1({
|
|
268
309
|
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
269
310
|
});
|
270
311
|
const response = await fetchImpl(url, {
|
312
|
+
...fetchOptions,
|
271
313
|
method: method.toUpperCase(),
|
272
314
|
body: body ? JSON.stringify(body) : void 0,
|
273
315
|
headers: {
|
274
316
|
"Content-Type": "application/json",
|
275
317
|
"User-Agent": `Xata client-ts/${VERSION}`,
|
318
|
+
"X-Xata-Client-ID": clientID ?? "",
|
319
|
+
"X-Xata-Session-ID": sessionID ?? "",
|
276
320
|
...headers,
|
277
321
|
...hostHeader(fullUrl),
|
278
322
|
Authorization: `Bearer ${apiKey}`
|
279
|
-
}
|
323
|
+
},
|
324
|
+
signal
|
280
325
|
});
|
281
326
|
if (response.status === 204) {
|
282
327
|
return {};
|
@@ -312,271 +357,163 @@ function parseUrl(url) {
|
|
312
357
|
}
|
313
358
|
}
|
314
359
|
|
315
|
-
const
|
316
|
-
|
317
|
-
const
|
318
|
-
const
|
319
|
-
url: "/user/keys",
|
320
|
-
method: "get",
|
321
|
-
...variables
|
322
|
-
});
|
323
|
-
const createUserAPIKey = (variables) => fetch$1({
|
324
|
-
url: "/user/keys/{keyName}",
|
325
|
-
method: "post",
|
326
|
-
...variables
|
327
|
-
});
|
328
|
-
const deleteUserAPIKey = (variables) => fetch$1({
|
329
|
-
url: "/user/keys/{keyName}",
|
330
|
-
method: "delete",
|
331
|
-
...variables
|
332
|
-
});
|
333
|
-
const createWorkspace = (variables) => fetch$1({
|
334
|
-
url: "/workspaces",
|
335
|
-
method: "post",
|
336
|
-
...variables
|
337
|
-
});
|
338
|
-
const getWorkspacesList = (variables) => fetch$1({
|
339
|
-
url: "/workspaces",
|
340
|
-
method: "get",
|
341
|
-
...variables
|
342
|
-
});
|
343
|
-
const getWorkspace = (variables) => fetch$1({
|
344
|
-
url: "/workspaces/{workspaceId}",
|
345
|
-
method: "get",
|
346
|
-
...variables
|
347
|
-
});
|
348
|
-
const updateWorkspace = (variables) => fetch$1({
|
349
|
-
url: "/workspaces/{workspaceId}",
|
350
|
-
method: "put",
|
351
|
-
...variables
|
352
|
-
});
|
353
|
-
const deleteWorkspace = (variables) => fetch$1({
|
354
|
-
url: "/workspaces/{workspaceId}",
|
355
|
-
method: "delete",
|
356
|
-
...variables
|
357
|
-
});
|
358
|
-
const getWorkspaceMembersList = (variables) => fetch$1({
|
359
|
-
url: "/workspaces/{workspaceId}/members",
|
360
|
-
method: "get",
|
361
|
-
...variables
|
362
|
-
});
|
363
|
-
const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
|
364
|
-
const removeWorkspaceMember = (variables) => fetch$1({
|
365
|
-
url: "/workspaces/{workspaceId}/members/{userId}",
|
366
|
-
method: "delete",
|
367
|
-
...variables
|
368
|
-
});
|
369
|
-
const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
|
370
|
-
const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
|
371
|
-
const cancelWorkspaceMemberInvite = (variables) => fetch$1({
|
372
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
373
|
-
method: "delete",
|
374
|
-
...variables
|
375
|
-
});
|
376
|
-
const resendWorkspaceMemberInvite = (variables) => fetch$1({
|
377
|
-
url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
|
378
|
-
method: "post",
|
379
|
-
...variables
|
380
|
-
});
|
381
|
-
const acceptWorkspaceMemberInvite = (variables) => fetch$1({
|
382
|
-
url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
|
383
|
-
method: "post",
|
384
|
-
...variables
|
385
|
-
});
|
386
|
-
const getDatabaseList = (variables) => fetch$1({
|
387
|
-
url: "/dbs",
|
388
|
-
method: "get",
|
389
|
-
...variables
|
390
|
-
});
|
391
|
-
const getBranchList = (variables) => fetch$1({
|
392
|
-
url: "/dbs/{dbName}",
|
393
|
-
method: "get",
|
394
|
-
...variables
|
395
|
-
});
|
396
|
-
const createDatabase = (variables) => fetch$1({
|
397
|
-
url: "/dbs/{dbName}",
|
398
|
-
method: "put",
|
399
|
-
...variables
|
400
|
-
});
|
401
|
-
const deleteDatabase = (variables) => fetch$1({
|
360
|
+
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
361
|
+
|
362
|
+
const dEPRECATEDgetDatabaseList = (variables, signal) => dataPlaneFetch({ url: "/dbs", method: "get", ...variables, signal });
|
363
|
+
const getBranchList = (variables, signal) => dataPlaneFetch({
|
402
364
|
url: "/dbs/{dbName}",
|
403
|
-
method: "delete",
|
404
|
-
...variables
|
405
|
-
});
|
406
|
-
const getDatabaseMetadata = (variables) => fetch$1({
|
407
|
-
url: "/dbs/{dbName}/metadata",
|
408
|
-
method: "get",
|
409
|
-
...variables
|
410
|
-
});
|
411
|
-
const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
|
412
|
-
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
413
|
-
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
414
|
-
const resolveBranch = (variables) => fetch$1({
|
415
|
-
url: "/dbs/{dbName}/resolveBranch",
|
416
|
-
method: "get",
|
417
|
-
...variables
|
418
|
-
});
|
419
|
-
const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
|
420
|
-
const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
|
421
|
-
const getMigrationRequest = (variables) => fetch$1({
|
422
|
-
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
423
365
|
method: "get",
|
424
|
-
...variables
|
366
|
+
...variables,
|
367
|
+
signal
|
425
368
|
});
|
426
|
-
const
|
427
|
-
const
|
428
|
-
const
|
429
|
-
const
|
430
|
-
const
|
431
|
-
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
432
|
-
method: "post",
|
433
|
-
...variables
|
434
|
-
});
|
435
|
-
const getBranchDetails = (variables) => fetch$1({
|
369
|
+
const dEPRECATEDcreateDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
|
370
|
+
const dEPRECATEDdeleteDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "delete", ...variables, signal });
|
371
|
+
const dEPRECATEDgetDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "get", ...variables, signal });
|
372
|
+
const dEPRECATEDupdateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
|
373
|
+
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
436
374
|
url: "/db/{dbBranchName}",
|
437
375
|
method: "get",
|
438
|
-
...variables
|
376
|
+
...variables,
|
377
|
+
signal
|
439
378
|
});
|
440
|
-
const createBranch = (variables) =>
|
441
|
-
const deleteBranch = (variables) =>
|
379
|
+
const createBranch = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
|
380
|
+
const deleteBranch = (variables, signal) => dataPlaneFetch({
|
442
381
|
url: "/db/{dbBranchName}",
|
443
382
|
method: "delete",
|
444
|
-
...variables
|
383
|
+
...variables,
|
384
|
+
signal
|
445
385
|
});
|
446
|
-
const updateBranchMetadata = (variables) =>
|
386
|
+
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
447
387
|
url: "/db/{dbBranchName}/metadata",
|
448
388
|
method: "put",
|
449
|
-
...variables
|
389
|
+
...variables,
|
390
|
+
signal
|
450
391
|
});
|
451
|
-
const getBranchMetadata = (variables) =>
|
392
|
+
const getBranchMetadata = (variables, signal) => dataPlaneFetch({
|
452
393
|
url: "/db/{dbBranchName}/metadata",
|
453
394
|
method: "get",
|
454
|
-
...variables
|
455
|
-
|
456
|
-
const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
|
457
|
-
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
458
|
-
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
459
|
-
const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
|
460
|
-
const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
|
461
|
-
const updateBranchSchema = (variables) => fetch$1({
|
462
|
-
url: "/db/{dbBranchName}/schema/update",
|
463
|
-
method: "post",
|
464
|
-
...variables
|
395
|
+
...variables,
|
396
|
+
signal
|
465
397
|
});
|
466
|
-
const
|
467
|
-
const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
|
468
|
-
const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
|
469
|
-
const getBranchStats = (variables) => fetch$1({
|
398
|
+
const getBranchStats = (variables, signal) => dataPlaneFetch({
|
470
399
|
url: "/db/{dbBranchName}/stats",
|
471
400
|
method: "get",
|
472
|
-
...variables
|
401
|
+
...variables,
|
402
|
+
signal
|
473
403
|
});
|
474
|
-
const
|
404
|
+
const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
|
405
|
+
const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
|
406
|
+
const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
|
407
|
+
const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
|
408
|
+
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
409
|
+
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
410
|
+
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
411
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
412
|
+
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
413
|
+
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
414
|
+
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
415
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
416
|
+
method: "get",
|
417
|
+
...variables,
|
418
|
+
signal
|
419
|
+
});
|
420
|
+
const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
|
421
|
+
const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
|
422
|
+
const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
|
423
|
+
const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
|
424
|
+
const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
|
425
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
426
|
+
method: "post",
|
427
|
+
...variables,
|
428
|
+
signal
|
429
|
+
});
|
430
|
+
const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
|
431
|
+
const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
|
432
|
+
const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
|
433
|
+
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
434
|
+
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
435
|
+
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
436
|
+
const createTable = (variables, signal) => dataPlaneFetch({
|
475
437
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
476
438
|
method: "put",
|
477
|
-
...variables
|
439
|
+
...variables,
|
440
|
+
signal
|
478
441
|
});
|
479
|
-
const deleteTable = (variables) =>
|
442
|
+
const deleteTable = (variables, signal) => dataPlaneFetch({
|
480
443
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
481
444
|
method: "delete",
|
482
|
-
...variables
|
483
|
-
|
484
|
-
const updateTable = (variables) => fetch$1({
|
485
|
-
url: "/db/{dbBranchName}/tables/{tableName}",
|
486
|
-
method: "patch",
|
487
|
-
...variables
|
445
|
+
...variables,
|
446
|
+
signal
|
488
447
|
});
|
489
|
-
const
|
448
|
+
const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
|
449
|
+
const getTableSchema = (variables, signal) => dataPlaneFetch({
|
490
450
|
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
491
451
|
method: "get",
|
492
|
-
...variables
|
493
|
-
|
494
|
-
const setTableSchema = (variables) => fetch$1({
|
495
|
-
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
496
|
-
method: "put",
|
497
|
-
...variables
|
452
|
+
...variables,
|
453
|
+
signal
|
498
454
|
});
|
499
|
-
const
|
455
|
+
const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
|
456
|
+
const getTableColumns = (variables, signal) => dataPlaneFetch({
|
500
457
|
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
501
458
|
method: "get",
|
502
|
-
...variables
|
503
|
-
|
504
|
-
const addTableColumn = (variables) => fetch$1({
|
505
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
506
|
-
method: "post",
|
507
|
-
...variables
|
459
|
+
...variables,
|
460
|
+
signal
|
508
461
|
});
|
509
|
-
const
|
462
|
+
const addTableColumn = (variables, signal) => dataPlaneFetch(
|
463
|
+
{ url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
|
464
|
+
);
|
465
|
+
const getColumn = (variables, signal) => dataPlaneFetch({
|
510
466
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
511
467
|
method: "get",
|
512
|
-
...variables
|
468
|
+
...variables,
|
469
|
+
signal
|
513
470
|
});
|
514
|
-
const
|
471
|
+
const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
|
472
|
+
const deleteColumn = (variables, signal) => dataPlaneFetch({
|
515
473
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
516
474
|
method: "delete",
|
517
|
-
...variables
|
475
|
+
...variables,
|
476
|
+
signal
|
518
477
|
});
|
519
|
-
const
|
520
|
-
|
521
|
-
method: "patch",
|
522
|
-
...variables
|
523
|
-
});
|
524
|
-
const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
|
525
|
-
const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
|
526
|
-
const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
|
527
|
-
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
528
|
-
const deleteRecord = (variables) => fetch$1({
|
529
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
530
|
-
method: "delete",
|
531
|
-
...variables
|
532
|
-
});
|
533
|
-
const getRecord = (variables) => fetch$1({
|
478
|
+
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
479
|
+
const getRecord = (variables, signal) => dataPlaneFetch({
|
534
480
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
535
481
|
method: "get",
|
536
|
-
...variables
|
482
|
+
...variables,
|
483
|
+
signal
|
537
484
|
});
|
538
|
-
const
|
539
|
-
const
|
485
|
+
const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
|
486
|
+
const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
|
487
|
+
const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
|
488
|
+
const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
|
489
|
+
const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
|
490
|
+
const queryTable = (variables, signal) => dataPlaneFetch({
|
540
491
|
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
541
492
|
method: "post",
|
542
|
-
...variables
|
493
|
+
...variables,
|
494
|
+
signal
|
543
495
|
});
|
544
|
-
const
|
545
|
-
url: "/db/{dbBranchName}/
|
496
|
+
const searchBranch = (variables, signal) => dataPlaneFetch({
|
497
|
+
url: "/db/{dbBranchName}/search",
|
546
498
|
method: "post",
|
547
|
-
...variables
|
499
|
+
...variables,
|
500
|
+
signal
|
548
501
|
});
|
549
|
-
const
|
550
|
-
url: "/db/{dbBranchName}/search",
|
502
|
+
const searchTable = (variables, signal) => dataPlaneFetch({
|
503
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
551
504
|
method: "post",
|
552
|
-
...variables
|
505
|
+
...variables,
|
506
|
+
signal
|
553
507
|
});
|
554
|
-
const
|
555
|
-
|
556
|
-
|
557
|
-
createWorkspace,
|
558
|
-
getWorkspacesList,
|
559
|
-
getWorkspace,
|
560
|
-
updateWorkspace,
|
561
|
-
deleteWorkspace,
|
562
|
-
getWorkspaceMembersList,
|
563
|
-
updateWorkspaceMemberRole,
|
564
|
-
removeWorkspaceMember,
|
565
|
-
inviteWorkspaceMember,
|
566
|
-
updateWorkspaceMemberInvite,
|
567
|
-
cancelWorkspaceMemberInvite,
|
568
|
-
resendWorkspaceMemberInvite,
|
569
|
-
acceptWorkspaceMemberInvite
|
570
|
-
},
|
508
|
+
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
509
|
+
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
510
|
+
const operationsByTag$2 = {
|
571
511
|
database: {
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
addGitBranchesEntry,
|
578
|
-
removeGitBranchesEntry,
|
579
|
-
resolveBranch
|
512
|
+
dEPRECATEDgetDatabaseList,
|
513
|
+
dEPRECATEDcreateDatabase,
|
514
|
+
dEPRECATEDdeleteDatabase,
|
515
|
+
dEPRECATEDgetDatabaseMetadata,
|
516
|
+
dEPRECATEDupdateDatabaseMetadata
|
580
517
|
},
|
581
518
|
branch: {
|
582
519
|
getBranchList,
|
@@ -585,10 +522,35 @@ const operationsByTag = {
|
|
585
522
|
deleteBranch,
|
586
523
|
updateBranchMetadata,
|
587
524
|
getBranchMetadata,
|
588
|
-
getBranchStats
|
525
|
+
getBranchStats,
|
526
|
+
getGitBranchesMapping,
|
527
|
+
addGitBranchesEntry,
|
528
|
+
removeGitBranchesEntry,
|
529
|
+
resolveBranch
|
530
|
+
},
|
531
|
+
migrations: {
|
532
|
+
getBranchMigrationHistory,
|
533
|
+
getBranchMigrationPlan,
|
534
|
+
executeBranchMigrationPlan,
|
535
|
+
getBranchSchemaHistory,
|
536
|
+
compareBranchWithUserSchema,
|
537
|
+
compareBranchSchemas,
|
538
|
+
updateBranchSchema,
|
539
|
+
previewBranchSchemaEdit,
|
540
|
+
applyBranchSchemaEdit
|
541
|
+
},
|
542
|
+
records: {
|
543
|
+
branchTransaction,
|
544
|
+
insertRecord,
|
545
|
+
getRecord,
|
546
|
+
insertRecordWithID,
|
547
|
+
updateRecordWithID,
|
548
|
+
upsertRecordWithID,
|
549
|
+
deleteRecord,
|
550
|
+
bulkInsertTableRecords
|
589
551
|
},
|
590
552
|
migrationRequests: {
|
591
|
-
|
553
|
+
queryMigrationRequests,
|
592
554
|
createMigrationRequest,
|
593
555
|
getMigrationRequest,
|
594
556
|
updateMigrationRequest,
|
@@ -597,17 +559,6 @@ const operationsByTag = {
|
|
597
559
|
getMigrationRequestIsMerged,
|
598
560
|
mergeMigrationRequest
|
599
561
|
},
|
600
|
-
branchSchema: {
|
601
|
-
getBranchMigrationHistory,
|
602
|
-
executeBranchMigrationPlan,
|
603
|
-
getBranchMigrationPlan,
|
604
|
-
compareBranchWithUserSchema,
|
605
|
-
compareBranchSchemas,
|
606
|
-
updateBranchSchema,
|
607
|
-
previewBranchSchemaEdit,
|
608
|
-
applyBranchSchemaEdit,
|
609
|
-
getBranchSchemaHistory
|
610
|
-
},
|
611
562
|
table: {
|
612
563
|
createTable,
|
613
564
|
deleteTable,
|
@@ -617,23 +568,146 @@ const operationsByTag = {
|
|
617
568
|
getTableColumns,
|
618
569
|
addTableColumn,
|
619
570
|
getColumn,
|
620
|
-
|
621
|
-
|
571
|
+
updateColumn,
|
572
|
+
deleteColumn
|
622
573
|
},
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
574
|
+
searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
|
575
|
+
};
|
576
|
+
|
577
|
+
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
578
|
+
|
579
|
+
const getUser = (variables, signal) => controlPlaneFetch({
|
580
|
+
url: "/user",
|
581
|
+
method: "get",
|
582
|
+
...variables,
|
583
|
+
signal
|
584
|
+
});
|
585
|
+
const updateUser = (variables, signal) => controlPlaneFetch({
|
586
|
+
url: "/user",
|
587
|
+
method: "put",
|
588
|
+
...variables,
|
589
|
+
signal
|
590
|
+
});
|
591
|
+
const deleteUser = (variables, signal) => controlPlaneFetch({
|
592
|
+
url: "/user",
|
593
|
+
method: "delete",
|
594
|
+
...variables,
|
595
|
+
signal
|
596
|
+
});
|
597
|
+
const getUserAPIKeys = (variables, signal) => controlPlaneFetch({
|
598
|
+
url: "/user/keys",
|
599
|
+
method: "get",
|
600
|
+
...variables,
|
601
|
+
signal
|
602
|
+
});
|
603
|
+
const createUserAPIKey = (variables, signal) => controlPlaneFetch({
|
604
|
+
url: "/user/keys/{keyName}",
|
605
|
+
method: "post",
|
606
|
+
...variables,
|
607
|
+
signal
|
608
|
+
});
|
609
|
+
const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
|
610
|
+
url: "/user/keys/{keyName}",
|
611
|
+
method: "delete",
|
612
|
+
...variables,
|
613
|
+
signal
|
614
|
+
});
|
615
|
+
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
616
|
+
url: "/workspaces",
|
617
|
+
method: "get",
|
618
|
+
...variables,
|
619
|
+
signal
|
620
|
+
});
|
621
|
+
const createWorkspace = (variables, signal) => controlPlaneFetch({
|
622
|
+
url: "/workspaces",
|
623
|
+
method: "post",
|
624
|
+
...variables,
|
625
|
+
signal
|
626
|
+
});
|
627
|
+
const getWorkspace = (variables, signal) => controlPlaneFetch({
|
628
|
+
url: "/workspaces/{workspaceId}",
|
629
|
+
method: "get",
|
630
|
+
...variables,
|
631
|
+
signal
|
632
|
+
});
|
633
|
+
const updateWorkspace = (variables, signal) => controlPlaneFetch({
|
634
|
+
url: "/workspaces/{workspaceId}",
|
635
|
+
method: "put",
|
636
|
+
...variables,
|
637
|
+
signal
|
638
|
+
});
|
639
|
+
const deleteWorkspace = (variables, signal) => controlPlaneFetch({
|
640
|
+
url: "/workspaces/{workspaceId}",
|
641
|
+
method: "delete",
|
642
|
+
...variables,
|
643
|
+
signal
|
644
|
+
});
|
645
|
+
const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
|
646
|
+
const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
|
647
|
+
const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
648
|
+
url: "/workspaces/{workspaceId}/members/{userId}",
|
649
|
+
method: "delete",
|
650
|
+
...variables,
|
651
|
+
signal
|
652
|
+
});
|
653
|
+
const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
|
654
|
+
const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
|
655
|
+
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
|
656
|
+
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
|
657
|
+
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
|
658
|
+
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
659
|
+
url: "/workspaces/{workspaceId}/dbs",
|
660
|
+
method: "get",
|
661
|
+
...variables,
|
662
|
+
signal
|
663
|
+
});
|
664
|
+
const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
|
665
|
+
const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
666
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
667
|
+
method: "delete",
|
668
|
+
...variables,
|
669
|
+
signal
|
670
|
+
});
|
671
|
+
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
672
|
+
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
673
|
+
const listRegions = (variables, signal) => controlPlaneFetch({
|
674
|
+
url: "/workspaces/{workspaceId}/regions",
|
675
|
+
method: "get",
|
676
|
+
...variables,
|
677
|
+
signal
|
678
|
+
});
|
679
|
+
const operationsByTag$1 = {
|
680
|
+
users: { getUser, updateUser, deleteUser },
|
681
|
+
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
682
|
+
workspaces: {
|
683
|
+
getWorkspacesList,
|
684
|
+
createWorkspace,
|
685
|
+
getWorkspace,
|
686
|
+
updateWorkspace,
|
687
|
+
deleteWorkspace,
|
688
|
+
getWorkspaceMembersList,
|
689
|
+
updateWorkspaceMemberRole,
|
690
|
+
removeWorkspaceMember
|
691
|
+
},
|
692
|
+
invites: {
|
693
|
+
inviteWorkspaceMember,
|
694
|
+
updateWorkspaceMemberInvite,
|
695
|
+
cancelWorkspaceMemberInvite,
|
696
|
+
acceptWorkspaceMemberInvite,
|
697
|
+
resendWorkspaceMemberInvite
|
698
|
+
},
|
699
|
+
databases: {
|
700
|
+
getDatabaseList,
|
701
|
+
createDatabase,
|
702
|
+
deleteDatabase,
|
703
|
+
getDatabaseMetadata,
|
704
|
+
updateDatabaseMetadata,
|
705
|
+
listRegions
|
634
706
|
}
|
635
707
|
};
|
636
708
|
|
709
|
+
const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
710
|
+
|
637
711
|
function getHostUrl(provider, type) {
|
638
712
|
if (isHostProviderAlias(provider)) {
|
639
713
|
return providers[provider][type];
|
@@ -645,11 +719,11 @@ function getHostUrl(provider, type) {
|
|
645
719
|
const providers = {
|
646
720
|
production: {
|
647
721
|
main: "https://api.xata.io",
|
648
|
-
workspaces: "https://{workspaceId}.xata.sh"
|
722
|
+
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
649
723
|
},
|
650
724
|
staging: {
|
651
725
|
main: "https://staging.xatabase.co",
|
652
|
-
workspaces: "https://{workspaceId}.staging.xatabase.co"
|
726
|
+
workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
|
653
727
|
}
|
654
728
|
};
|
655
729
|
function isHostProviderAlias(alias) {
|
@@ -658,6 +732,25 @@ function isHostProviderAlias(alias) {
|
|
658
732
|
function isHostProviderBuilder(builder) {
|
659
733
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
660
734
|
}
|
735
|
+
function parseProviderString(provider = "production") {
|
736
|
+
if (isHostProviderAlias(provider)) {
|
737
|
+
return provider;
|
738
|
+
}
|
739
|
+
const [main, workspaces] = provider.split(",");
|
740
|
+
if (!main || !workspaces)
|
741
|
+
return null;
|
742
|
+
return { main, workspaces };
|
743
|
+
}
|
744
|
+
function parseWorkspacesUrlParts(url) {
|
745
|
+
if (!isString(url))
|
746
|
+
return null;
|
747
|
+
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))?\.xata\.sh.*/;
|
748
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))?\.xatabase\.co.*/;
|
749
|
+
const match = url.match(regex) || url.match(regexStaging);
|
750
|
+
if (!match)
|
751
|
+
return null;
|
752
|
+
return { workspace: match[1], region: match[2] ?? "eu-west-1" };
|
753
|
+
}
|
661
754
|
|
662
755
|
var __accessCheck$7 = (obj, member, msg) => {
|
663
756
|
if (!member.has(obj))
|
@@ -701,21 +794,41 @@ class XataApiClient {
|
|
701
794
|
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
702
795
|
return __privateGet$7(this, _namespaces).user;
|
703
796
|
}
|
797
|
+
get authentication() {
|
798
|
+
if (!__privateGet$7(this, _namespaces).authentication)
|
799
|
+
__privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
|
800
|
+
return __privateGet$7(this, _namespaces).authentication;
|
801
|
+
}
|
704
802
|
get workspaces() {
|
705
803
|
if (!__privateGet$7(this, _namespaces).workspaces)
|
706
804
|
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
707
805
|
return __privateGet$7(this, _namespaces).workspaces;
|
708
806
|
}
|
709
|
-
get
|
710
|
-
if (!__privateGet$7(this, _namespaces).
|
711
|
-
__privateGet$7(this, _namespaces).
|
712
|
-
return __privateGet$7(this, _namespaces).
|
807
|
+
get invites() {
|
808
|
+
if (!__privateGet$7(this, _namespaces).invites)
|
809
|
+
__privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
|
810
|
+
return __privateGet$7(this, _namespaces).invites;
|
811
|
+
}
|
812
|
+
get database() {
|
813
|
+
if (!__privateGet$7(this, _namespaces).database)
|
814
|
+
__privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
|
815
|
+
return __privateGet$7(this, _namespaces).database;
|
713
816
|
}
|
714
817
|
get branches() {
|
715
818
|
if (!__privateGet$7(this, _namespaces).branches)
|
716
819
|
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
717
820
|
return __privateGet$7(this, _namespaces).branches;
|
718
821
|
}
|
822
|
+
get migrations() {
|
823
|
+
if (!__privateGet$7(this, _namespaces).migrations)
|
824
|
+
__privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
|
825
|
+
return __privateGet$7(this, _namespaces).migrations;
|
826
|
+
}
|
827
|
+
get migrationRequests() {
|
828
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
829
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
830
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
831
|
+
}
|
719
832
|
get tables() {
|
720
833
|
if (!__privateGet$7(this, _namespaces).tables)
|
721
834
|
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
@@ -726,15 +839,10 @@ class XataApiClient {
|
|
726
839
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
727
840
|
return __privateGet$7(this, _namespaces).records;
|
728
841
|
}
|
729
|
-
get
|
730
|
-
if (!__privateGet$7(this, _namespaces).
|
731
|
-
__privateGet$7(this, _namespaces).
|
732
|
-
return __privateGet$7(this, _namespaces).
|
733
|
-
}
|
734
|
-
get branchSchema() {
|
735
|
-
if (!__privateGet$7(this, _namespaces).branchSchema)
|
736
|
-
__privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
|
737
|
-
return __privateGet$7(this, _namespaces).branchSchema;
|
842
|
+
get searchAndFilter() {
|
843
|
+
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
844
|
+
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
845
|
+
return __privateGet$7(this, _namespaces).searchAndFilter;
|
738
846
|
}
|
739
847
|
}
|
740
848
|
_extraProps = new WeakMap();
|
@@ -746,24 +854,29 @@ class UserApi {
|
|
746
854
|
getUser() {
|
747
855
|
return operationsByTag.users.getUser({ ...this.extraProps });
|
748
856
|
}
|
749
|
-
updateUser(user) {
|
857
|
+
updateUser({ user }) {
|
750
858
|
return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
|
751
859
|
}
|
752
860
|
deleteUser() {
|
753
861
|
return operationsByTag.users.deleteUser({ ...this.extraProps });
|
754
862
|
}
|
863
|
+
}
|
864
|
+
class AuthenticationApi {
|
865
|
+
constructor(extraProps) {
|
866
|
+
this.extraProps = extraProps;
|
867
|
+
}
|
755
868
|
getUserAPIKeys() {
|
756
|
-
return operationsByTag.
|
869
|
+
return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
|
757
870
|
}
|
758
|
-
createUserAPIKey(
|
759
|
-
return operationsByTag.
|
760
|
-
pathParams: { keyName },
|
871
|
+
createUserAPIKey({ name }) {
|
872
|
+
return operationsByTag.authentication.createUserAPIKey({
|
873
|
+
pathParams: { keyName: name },
|
761
874
|
...this.extraProps
|
762
875
|
});
|
763
876
|
}
|
764
|
-
deleteUserAPIKey(
|
765
|
-
return operationsByTag.
|
766
|
-
pathParams: { keyName },
|
877
|
+
deleteUserAPIKey({ name }) {
|
878
|
+
return operationsByTag.authentication.deleteUserAPIKey({
|
879
|
+
pathParams: { keyName: name },
|
767
880
|
...this.extraProps
|
768
881
|
});
|
769
882
|
}
|
@@ -772,189 +885,248 @@ class WorkspaceApi {
|
|
772
885
|
constructor(extraProps) {
|
773
886
|
this.extraProps = extraProps;
|
774
887
|
}
|
775
|
-
|
888
|
+
getWorkspacesList() {
|
889
|
+
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
890
|
+
}
|
891
|
+
createWorkspace({ data }) {
|
776
892
|
return operationsByTag.workspaces.createWorkspace({
|
777
|
-
body:
|
893
|
+
body: data,
|
778
894
|
...this.extraProps
|
779
895
|
});
|
780
896
|
}
|
781
|
-
|
782
|
-
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
783
|
-
}
|
784
|
-
getWorkspace(workspaceId) {
|
897
|
+
getWorkspace({ workspace }) {
|
785
898
|
return operationsByTag.workspaces.getWorkspace({
|
786
|
-
pathParams: { workspaceId },
|
899
|
+
pathParams: { workspaceId: workspace },
|
787
900
|
...this.extraProps
|
788
901
|
});
|
789
902
|
}
|
790
|
-
updateWorkspace(
|
903
|
+
updateWorkspace({
|
904
|
+
workspace,
|
905
|
+
update
|
906
|
+
}) {
|
791
907
|
return operationsByTag.workspaces.updateWorkspace({
|
792
|
-
pathParams: { workspaceId },
|
793
|
-
body:
|
908
|
+
pathParams: { workspaceId: workspace },
|
909
|
+
body: update,
|
794
910
|
...this.extraProps
|
795
911
|
});
|
796
912
|
}
|
797
|
-
deleteWorkspace(
|
913
|
+
deleteWorkspace({ workspace }) {
|
798
914
|
return operationsByTag.workspaces.deleteWorkspace({
|
799
|
-
pathParams: { workspaceId },
|
915
|
+
pathParams: { workspaceId: workspace },
|
800
916
|
...this.extraProps
|
801
917
|
});
|
802
918
|
}
|
803
|
-
getWorkspaceMembersList(
|
919
|
+
getWorkspaceMembersList({ workspace }) {
|
804
920
|
return operationsByTag.workspaces.getWorkspaceMembersList({
|
805
|
-
pathParams: { workspaceId },
|
921
|
+
pathParams: { workspaceId: workspace },
|
806
922
|
...this.extraProps
|
807
923
|
});
|
808
924
|
}
|
809
|
-
updateWorkspaceMemberRole(
|
925
|
+
updateWorkspaceMemberRole({
|
926
|
+
workspace,
|
927
|
+
user,
|
928
|
+
role
|
929
|
+
}) {
|
810
930
|
return operationsByTag.workspaces.updateWorkspaceMemberRole({
|
811
|
-
pathParams: { workspaceId, userId },
|
931
|
+
pathParams: { workspaceId: workspace, userId: user },
|
812
932
|
body: { role },
|
813
933
|
...this.extraProps
|
814
934
|
});
|
815
935
|
}
|
816
|
-
removeWorkspaceMember(
|
936
|
+
removeWorkspaceMember({
|
937
|
+
workspace,
|
938
|
+
user
|
939
|
+
}) {
|
817
940
|
return operationsByTag.workspaces.removeWorkspaceMember({
|
818
|
-
pathParams: { workspaceId, userId },
|
941
|
+
pathParams: { workspaceId: workspace, userId: user },
|
819
942
|
...this.extraProps
|
820
943
|
});
|
821
944
|
}
|
822
|
-
|
823
|
-
|
824
|
-
|
945
|
+
}
|
946
|
+
class InvitesApi {
|
947
|
+
constructor(extraProps) {
|
948
|
+
this.extraProps = extraProps;
|
949
|
+
}
|
950
|
+
inviteWorkspaceMember({
|
951
|
+
workspace,
|
952
|
+
email,
|
953
|
+
role
|
954
|
+
}) {
|
955
|
+
return operationsByTag.invites.inviteWorkspaceMember({
|
956
|
+
pathParams: { workspaceId: workspace },
|
825
957
|
body: { email, role },
|
826
958
|
...this.extraProps
|
827
959
|
});
|
828
960
|
}
|
829
|
-
updateWorkspaceMemberInvite(
|
830
|
-
|
831
|
-
|
961
|
+
updateWorkspaceMemberInvite({
|
962
|
+
workspace,
|
963
|
+
invite,
|
964
|
+
role
|
965
|
+
}) {
|
966
|
+
return operationsByTag.invites.updateWorkspaceMemberInvite({
|
967
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
832
968
|
body: { role },
|
833
969
|
...this.extraProps
|
834
970
|
});
|
835
971
|
}
|
836
|
-
cancelWorkspaceMemberInvite(
|
837
|
-
|
838
|
-
|
972
|
+
cancelWorkspaceMemberInvite({
|
973
|
+
workspace,
|
974
|
+
invite
|
975
|
+
}) {
|
976
|
+
return operationsByTag.invites.cancelWorkspaceMemberInvite({
|
977
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
839
978
|
...this.extraProps
|
840
979
|
});
|
841
980
|
}
|
842
|
-
|
843
|
-
|
844
|
-
|
981
|
+
acceptWorkspaceMemberInvite({
|
982
|
+
workspace,
|
983
|
+
key
|
984
|
+
}) {
|
985
|
+
return operationsByTag.invites.acceptWorkspaceMemberInvite({
|
986
|
+
pathParams: { workspaceId: workspace, inviteKey: key },
|
845
987
|
...this.extraProps
|
846
988
|
});
|
847
989
|
}
|
848
|
-
|
849
|
-
|
850
|
-
|
990
|
+
resendWorkspaceMemberInvite({
|
991
|
+
workspace,
|
992
|
+
invite
|
993
|
+
}) {
|
994
|
+
return operationsByTag.invites.resendWorkspaceMemberInvite({
|
995
|
+
pathParams: { workspaceId: workspace, inviteId: invite },
|
851
996
|
...this.extraProps
|
852
997
|
});
|
853
998
|
}
|
854
999
|
}
|
855
|
-
class
|
1000
|
+
class BranchApi {
|
856
1001
|
constructor(extraProps) {
|
857
1002
|
this.extraProps = extraProps;
|
858
1003
|
}
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
return operationsByTag.database.createDatabase({
|
867
|
-
pathParams: { workspace, dbName },
|
868
|
-
body: options,
|
869
|
-
...this.extraProps
|
870
|
-
});
|
871
|
-
}
|
872
|
-
deleteDatabase(workspace, dbName) {
|
873
|
-
return operationsByTag.database.deleteDatabase({
|
874
|
-
pathParams: { workspace, dbName },
|
875
|
-
...this.extraProps
|
876
|
-
});
|
877
|
-
}
|
878
|
-
getDatabaseMetadata(workspace, dbName) {
|
879
|
-
return operationsByTag.database.getDatabaseMetadata({
|
880
|
-
pathParams: { workspace, dbName },
|
1004
|
+
getBranchList({
|
1005
|
+
workspace,
|
1006
|
+
region,
|
1007
|
+
database
|
1008
|
+
}) {
|
1009
|
+
return operationsByTag.branch.getBranchList({
|
1010
|
+
pathParams: { workspace, region, dbName: database },
|
881
1011
|
...this.extraProps
|
882
1012
|
});
|
883
1013
|
}
|
884
|
-
|
885
|
-
|
886
|
-
|
1014
|
+
getBranchDetails({
|
1015
|
+
workspace,
|
1016
|
+
region,
|
1017
|
+
database,
|
1018
|
+
branch
|
1019
|
+
}) {
|
1020
|
+
return operationsByTag.branch.getBranchDetails({
|
1021
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
887
1022
|
...this.extraProps
|
888
1023
|
});
|
889
1024
|
}
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
1025
|
+
createBranch({
|
1026
|
+
workspace,
|
1027
|
+
region,
|
1028
|
+
database,
|
1029
|
+
branch,
|
1030
|
+
from,
|
1031
|
+
metadata
|
1032
|
+
}) {
|
1033
|
+
return operationsByTag.branch.createBranch({
|
1034
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1035
|
+
body: { from, metadata },
|
894
1036
|
...this.extraProps
|
895
1037
|
});
|
896
1038
|
}
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
1039
|
+
deleteBranch({
|
1040
|
+
workspace,
|
1041
|
+
region,
|
1042
|
+
database,
|
1043
|
+
branch
|
1044
|
+
}) {
|
1045
|
+
return operationsByTag.branch.deleteBranch({
|
1046
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
901
1047
|
...this.extraProps
|
902
1048
|
});
|
903
1049
|
}
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
1050
|
+
updateBranchMetadata({
|
1051
|
+
workspace,
|
1052
|
+
region,
|
1053
|
+
database,
|
1054
|
+
branch,
|
1055
|
+
metadata
|
1056
|
+
}) {
|
1057
|
+
return operationsByTag.branch.updateBranchMetadata({
|
1058
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1059
|
+
body: metadata,
|
908
1060
|
...this.extraProps
|
909
1061
|
});
|
910
1062
|
}
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
return operationsByTag.branch.
|
918
|
-
pathParams: { workspace,
|
1063
|
+
getBranchMetadata({
|
1064
|
+
workspace,
|
1065
|
+
region,
|
1066
|
+
database,
|
1067
|
+
branch
|
1068
|
+
}) {
|
1069
|
+
return operationsByTag.branch.getBranchMetadata({
|
1070
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
919
1071
|
...this.extraProps
|
920
1072
|
});
|
921
1073
|
}
|
922
|
-
|
923
|
-
|
924
|
-
|
1074
|
+
getBranchStats({
|
1075
|
+
workspace,
|
1076
|
+
region,
|
1077
|
+
database,
|
1078
|
+
branch
|
1079
|
+
}) {
|
1080
|
+
return operationsByTag.branch.getBranchStats({
|
1081
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
925
1082
|
...this.extraProps
|
926
1083
|
});
|
927
1084
|
}
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
1085
|
+
getGitBranchesMapping({
|
1086
|
+
workspace,
|
1087
|
+
region,
|
1088
|
+
database
|
1089
|
+
}) {
|
1090
|
+
return operationsByTag.branch.getGitBranchesMapping({
|
1091
|
+
pathParams: { workspace, region, dbName: database },
|
933
1092
|
...this.extraProps
|
934
1093
|
});
|
935
1094
|
}
|
936
|
-
|
937
|
-
|
938
|
-
|
1095
|
+
addGitBranchesEntry({
|
1096
|
+
workspace,
|
1097
|
+
region,
|
1098
|
+
database,
|
1099
|
+
gitBranch,
|
1100
|
+
xataBranch
|
1101
|
+
}) {
|
1102
|
+
return operationsByTag.branch.addGitBranchesEntry({
|
1103
|
+
pathParams: { workspace, region, dbName: database },
|
1104
|
+
body: { gitBranch, xataBranch },
|
939
1105
|
...this.extraProps
|
940
1106
|
});
|
941
1107
|
}
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1108
|
+
removeGitBranchesEntry({
|
1109
|
+
workspace,
|
1110
|
+
region,
|
1111
|
+
database,
|
1112
|
+
gitBranch
|
1113
|
+
}) {
|
1114
|
+
return operationsByTag.branch.removeGitBranchesEntry({
|
1115
|
+
pathParams: { workspace, region, dbName: database },
|
1116
|
+
queryParams: { gitBranch },
|
952
1117
|
...this.extraProps
|
953
1118
|
});
|
954
1119
|
}
|
955
|
-
|
956
|
-
|
957
|
-
|
1120
|
+
resolveBranch({
|
1121
|
+
workspace,
|
1122
|
+
region,
|
1123
|
+
database,
|
1124
|
+
gitBranch,
|
1125
|
+
fallbackBranch
|
1126
|
+
}) {
|
1127
|
+
return operationsByTag.branch.resolveBranch({
|
1128
|
+
pathParams: { workspace, region, dbName: database },
|
1129
|
+
queryParams: { gitBranch, fallbackBranch },
|
958
1130
|
...this.extraProps
|
959
1131
|
});
|
960
1132
|
}
|
@@ -963,67 +1135,134 @@ class TableApi {
|
|
963
1135
|
constructor(extraProps) {
|
964
1136
|
this.extraProps = extraProps;
|
965
1137
|
}
|
966
|
-
createTable(
|
1138
|
+
createTable({
|
1139
|
+
workspace,
|
1140
|
+
region,
|
1141
|
+
database,
|
1142
|
+
branch,
|
1143
|
+
table
|
1144
|
+
}) {
|
967
1145
|
return operationsByTag.table.createTable({
|
968
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1146
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
969
1147
|
...this.extraProps
|
970
1148
|
});
|
971
1149
|
}
|
972
|
-
deleteTable(
|
1150
|
+
deleteTable({
|
1151
|
+
workspace,
|
1152
|
+
region,
|
1153
|
+
database,
|
1154
|
+
branch,
|
1155
|
+
table
|
1156
|
+
}) {
|
973
1157
|
return operationsByTag.table.deleteTable({
|
974
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1158
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
975
1159
|
...this.extraProps
|
976
1160
|
});
|
977
1161
|
}
|
978
|
-
updateTable(
|
1162
|
+
updateTable({
|
1163
|
+
workspace,
|
1164
|
+
region,
|
1165
|
+
database,
|
1166
|
+
branch,
|
1167
|
+
table,
|
1168
|
+
update
|
1169
|
+
}) {
|
979
1170
|
return operationsByTag.table.updateTable({
|
980
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
981
|
-
body:
|
1171
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1172
|
+
body: update,
|
982
1173
|
...this.extraProps
|
983
1174
|
});
|
984
1175
|
}
|
985
|
-
getTableSchema(
|
1176
|
+
getTableSchema({
|
1177
|
+
workspace,
|
1178
|
+
region,
|
1179
|
+
database,
|
1180
|
+
branch,
|
1181
|
+
table
|
1182
|
+
}) {
|
986
1183
|
return operationsByTag.table.getTableSchema({
|
987
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1184
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
988
1185
|
...this.extraProps
|
989
1186
|
});
|
990
1187
|
}
|
991
|
-
setTableSchema(
|
1188
|
+
setTableSchema({
|
1189
|
+
workspace,
|
1190
|
+
region,
|
1191
|
+
database,
|
1192
|
+
branch,
|
1193
|
+
table,
|
1194
|
+
schema
|
1195
|
+
}) {
|
992
1196
|
return operationsByTag.table.setTableSchema({
|
993
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
994
|
-
body:
|
1197
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1198
|
+
body: schema,
|
995
1199
|
...this.extraProps
|
996
1200
|
});
|
997
1201
|
}
|
998
|
-
getTableColumns(
|
1202
|
+
getTableColumns({
|
1203
|
+
workspace,
|
1204
|
+
region,
|
1205
|
+
database,
|
1206
|
+
branch,
|
1207
|
+
table
|
1208
|
+
}) {
|
999
1209
|
return operationsByTag.table.getTableColumns({
|
1000
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1210
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1001
1211
|
...this.extraProps
|
1002
1212
|
});
|
1003
1213
|
}
|
1004
|
-
addTableColumn(
|
1214
|
+
addTableColumn({
|
1215
|
+
workspace,
|
1216
|
+
region,
|
1217
|
+
database,
|
1218
|
+
branch,
|
1219
|
+
table,
|
1220
|
+
column
|
1221
|
+
}) {
|
1005
1222
|
return operationsByTag.table.addTableColumn({
|
1006
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1223
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1007
1224
|
body: column,
|
1008
1225
|
...this.extraProps
|
1009
1226
|
});
|
1010
1227
|
}
|
1011
|
-
getColumn(
|
1228
|
+
getColumn({
|
1229
|
+
workspace,
|
1230
|
+
region,
|
1231
|
+
database,
|
1232
|
+
branch,
|
1233
|
+
table,
|
1234
|
+
column
|
1235
|
+
}) {
|
1012
1236
|
return operationsByTag.table.getColumn({
|
1013
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
|
1237
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1014
1238
|
...this.extraProps
|
1015
1239
|
});
|
1016
1240
|
}
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1241
|
+
updateColumn({
|
1242
|
+
workspace,
|
1243
|
+
region,
|
1244
|
+
database,
|
1245
|
+
branch,
|
1246
|
+
table,
|
1247
|
+
column,
|
1248
|
+
update
|
1249
|
+
}) {
|
1250
|
+
return operationsByTag.table.updateColumn({
|
1251
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1252
|
+
body: update,
|
1020
1253
|
...this.extraProps
|
1021
1254
|
});
|
1022
1255
|
}
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1256
|
+
deleteColumn({
|
1257
|
+
workspace,
|
1258
|
+
region,
|
1259
|
+
database,
|
1260
|
+
branch,
|
1261
|
+
table,
|
1262
|
+
column
|
1263
|
+
}) {
|
1264
|
+
return operationsByTag.table.deleteColumn({
|
1265
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
|
1027
1266
|
...this.extraProps
|
1028
1267
|
});
|
1029
1268
|
}
|
@@ -1032,78 +1271,215 @@ class RecordsApi {
|
|
1032
1271
|
constructor(extraProps) {
|
1033
1272
|
this.extraProps = extraProps;
|
1034
1273
|
}
|
1035
|
-
insertRecord(
|
1274
|
+
insertRecord({
|
1275
|
+
workspace,
|
1276
|
+
region,
|
1277
|
+
database,
|
1278
|
+
branch,
|
1279
|
+
table,
|
1280
|
+
record,
|
1281
|
+
columns
|
1282
|
+
}) {
|
1036
1283
|
return operationsByTag.records.insertRecord({
|
1037
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1038
|
-
queryParams:
|
1284
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1285
|
+
queryParams: { columns },
|
1039
1286
|
body: record,
|
1040
1287
|
...this.extraProps
|
1041
1288
|
});
|
1042
1289
|
}
|
1043
|
-
|
1290
|
+
getRecord({
|
1291
|
+
workspace,
|
1292
|
+
region,
|
1293
|
+
database,
|
1294
|
+
branch,
|
1295
|
+
table,
|
1296
|
+
id,
|
1297
|
+
columns
|
1298
|
+
}) {
|
1299
|
+
return operationsByTag.records.getRecord({
|
1300
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1301
|
+
queryParams: { columns },
|
1302
|
+
...this.extraProps
|
1303
|
+
});
|
1304
|
+
}
|
1305
|
+
insertRecordWithID({
|
1306
|
+
workspace,
|
1307
|
+
region,
|
1308
|
+
database,
|
1309
|
+
branch,
|
1310
|
+
table,
|
1311
|
+
id,
|
1312
|
+
record,
|
1313
|
+
columns,
|
1314
|
+
createOnly,
|
1315
|
+
ifVersion
|
1316
|
+
}) {
|
1044
1317
|
return operationsByTag.records.insertRecordWithID({
|
1045
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1046
|
-
queryParams:
|
1318
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1319
|
+
queryParams: { columns, createOnly, ifVersion },
|
1047
1320
|
body: record,
|
1048
1321
|
...this.extraProps
|
1049
1322
|
});
|
1050
1323
|
}
|
1051
|
-
updateRecordWithID(
|
1324
|
+
updateRecordWithID({
|
1325
|
+
workspace,
|
1326
|
+
region,
|
1327
|
+
database,
|
1328
|
+
branch,
|
1329
|
+
table,
|
1330
|
+
id,
|
1331
|
+
record,
|
1332
|
+
columns,
|
1333
|
+
ifVersion
|
1334
|
+
}) {
|
1052
1335
|
return operationsByTag.records.updateRecordWithID({
|
1053
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1054
|
-
queryParams:
|
1336
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1337
|
+
queryParams: { columns, ifVersion },
|
1055
1338
|
body: record,
|
1056
1339
|
...this.extraProps
|
1057
1340
|
});
|
1058
1341
|
}
|
1059
|
-
upsertRecordWithID(
|
1342
|
+
upsertRecordWithID({
|
1343
|
+
workspace,
|
1344
|
+
region,
|
1345
|
+
database,
|
1346
|
+
branch,
|
1347
|
+
table,
|
1348
|
+
id,
|
1349
|
+
record,
|
1350
|
+
columns,
|
1351
|
+
ifVersion
|
1352
|
+
}) {
|
1060
1353
|
return operationsByTag.records.upsertRecordWithID({
|
1061
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1062
|
-
queryParams:
|
1354
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1355
|
+
queryParams: { columns, ifVersion },
|
1063
1356
|
body: record,
|
1064
1357
|
...this.extraProps
|
1065
1358
|
});
|
1066
1359
|
}
|
1067
|
-
deleteRecord(
|
1360
|
+
deleteRecord({
|
1361
|
+
workspace,
|
1362
|
+
region,
|
1363
|
+
database,
|
1364
|
+
branch,
|
1365
|
+
table,
|
1366
|
+
id,
|
1367
|
+
columns
|
1368
|
+
}) {
|
1068
1369
|
return operationsByTag.records.deleteRecord({
|
1069
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1070
|
-
queryParams:
|
1071
|
-
...this.extraProps
|
1072
|
-
});
|
1073
|
-
}
|
1074
|
-
getRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
1075
|
-
return operationsByTag.records.getRecord({
|
1076
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1077
|
-
queryParams: options,
|
1370
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
|
1371
|
+
queryParams: { columns },
|
1078
1372
|
...this.extraProps
|
1079
1373
|
});
|
1080
1374
|
}
|
1081
|
-
bulkInsertTableRecords(
|
1375
|
+
bulkInsertTableRecords({
|
1376
|
+
workspace,
|
1377
|
+
region,
|
1378
|
+
database,
|
1379
|
+
branch,
|
1380
|
+
table,
|
1381
|
+
records,
|
1382
|
+
columns
|
1383
|
+
}) {
|
1082
1384
|
return operationsByTag.records.bulkInsertTableRecords({
|
1083
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1084
|
-
queryParams:
|
1385
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1386
|
+
queryParams: { columns },
|
1085
1387
|
body: { records },
|
1086
1388
|
...this.extraProps
|
1087
1389
|
});
|
1088
1390
|
}
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
...this.extraProps
|
1094
|
-
});
|
1095
|
-
}
|
1096
|
-
searchTable(workspace, database, branch, tableName, query) {
|
1097
|
-
return operationsByTag.records.searchTable({
|
1098
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1099
|
-
body: query,
|
1100
|
-
...this.extraProps
|
1101
|
-
});
|
1391
|
+
}
|
1392
|
+
class SearchAndFilterApi {
|
1393
|
+
constructor(extraProps) {
|
1394
|
+
this.extraProps = extraProps;
|
1102
1395
|
}
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1396
|
+
queryTable({
|
1397
|
+
workspace,
|
1398
|
+
region,
|
1399
|
+
database,
|
1400
|
+
branch,
|
1401
|
+
table,
|
1402
|
+
filter,
|
1403
|
+
sort,
|
1404
|
+
page,
|
1405
|
+
columns,
|
1406
|
+
consistency
|
1407
|
+
}) {
|
1408
|
+
return operationsByTag.searchAndFilter.queryTable({
|
1409
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1410
|
+
body: { filter, sort, page, columns, consistency },
|
1411
|
+
...this.extraProps
|
1412
|
+
});
|
1413
|
+
}
|
1414
|
+
searchTable({
|
1415
|
+
workspace,
|
1416
|
+
region,
|
1417
|
+
database,
|
1418
|
+
branch,
|
1419
|
+
table,
|
1420
|
+
query,
|
1421
|
+
fuzziness,
|
1422
|
+
target,
|
1423
|
+
prefix,
|
1424
|
+
filter,
|
1425
|
+
highlight,
|
1426
|
+
boosters
|
1427
|
+
}) {
|
1428
|
+
return operationsByTag.searchAndFilter.searchTable({
|
1429
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1430
|
+
body: { query, fuzziness, target, prefix, filter, highlight, boosters },
|
1431
|
+
...this.extraProps
|
1432
|
+
});
|
1433
|
+
}
|
1434
|
+
searchBranch({
|
1435
|
+
workspace,
|
1436
|
+
region,
|
1437
|
+
database,
|
1438
|
+
branch,
|
1439
|
+
tables,
|
1440
|
+
query,
|
1441
|
+
fuzziness,
|
1442
|
+
prefix,
|
1443
|
+
highlight
|
1444
|
+
}) {
|
1445
|
+
return operationsByTag.searchAndFilter.searchBranch({
|
1446
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1447
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
1448
|
+
...this.extraProps
|
1449
|
+
});
|
1450
|
+
}
|
1451
|
+
summarizeTable({
|
1452
|
+
workspace,
|
1453
|
+
region,
|
1454
|
+
database,
|
1455
|
+
branch,
|
1456
|
+
table,
|
1457
|
+
filter,
|
1458
|
+
columns,
|
1459
|
+
summaries,
|
1460
|
+
sort,
|
1461
|
+
summariesFilter,
|
1462
|
+
page,
|
1463
|
+
consistency
|
1464
|
+
}) {
|
1465
|
+
return operationsByTag.searchAndFilter.summarizeTable({
|
1466
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1467
|
+
body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
|
1468
|
+
...this.extraProps
|
1469
|
+
});
|
1470
|
+
}
|
1471
|
+
aggregateTable({
|
1472
|
+
workspace,
|
1473
|
+
region,
|
1474
|
+
database,
|
1475
|
+
branch,
|
1476
|
+
table,
|
1477
|
+
filter,
|
1478
|
+
aggs
|
1479
|
+
}) {
|
1480
|
+
return operationsByTag.searchAndFilter.aggregateTable({
|
1481
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
|
1482
|
+
body: { filter, aggs },
|
1107
1483
|
...this.extraProps
|
1108
1484
|
});
|
1109
1485
|
}
|
@@ -1112,123 +1488,281 @@ class MigrationRequestsApi {
|
|
1112
1488
|
constructor(extraProps) {
|
1113
1489
|
this.extraProps = extraProps;
|
1114
1490
|
}
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1491
|
+
queryMigrationRequests({
|
1492
|
+
workspace,
|
1493
|
+
region,
|
1494
|
+
database,
|
1495
|
+
filter,
|
1496
|
+
sort,
|
1497
|
+
page,
|
1498
|
+
columns
|
1499
|
+
}) {
|
1500
|
+
return operationsByTag.migrationRequests.queryMigrationRequests({
|
1501
|
+
pathParams: { workspace, region, dbName: database },
|
1502
|
+
body: { filter, sort, page, columns },
|
1503
|
+
...this.extraProps
|
1504
|
+
});
|
1505
|
+
}
|
1506
|
+
createMigrationRequest({
|
1507
|
+
workspace,
|
1508
|
+
region,
|
1509
|
+
database,
|
1510
|
+
migration
|
1511
|
+
}) {
|
1123
1512
|
return operationsByTag.migrationRequests.createMigrationRequest({
|
1124
|
-
pathParams: { workspace, dbName: database },
|
1125
|
-
body:
|
1513
|
+
pathParams: { workspace, region, dbName: database },
|
1514
|
+
body: migration,
|
1126
1515
|
...this.extraProps
|
1127
1516
|
});
|
1128
1517
|
}
|
1129
|
-
getMigrationRequest(
|
1518
|
+
getMigrationRequest({
|
1519
|
+
workspace,
|
1520
|
+
region,
|
1521
|
+
database,
|
1522
|
+
migrationRequest
|
1523
|
+
}) {
|
1130
1524
|
return operationsByTag.migrationRequests.getMigrationRequest({
|
1131
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1525
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1132
1526
|
...this.extraProps
|
1133
1527
|
});
|
1134
1528
|
}
|
1135
|
-
updateMigrationRequest(
|
1529
|
+
updateMigrationRequest({
|
1530
|
+
workspace,
|
1531
|
+
region,
|
1532
|
+
database,
|
1533
|
+
migrationRequest,
|
1534
|
+
update
|
1535
|
+
}) {
|
1136
1536
|
return operationsByTag.migrationRequests.updateMigrationRequest({
|
1137
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1138
|
-
body:
|
1537
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1538
|
+
body: update,
|
1139
1539
|
...this.extraProps
|
1140
1540
|
});
|
1141
1541
|
}
|
1142
|
-
listMigrationRequestsCommits(
|
1542
|
+
listMigrationRequestsCommits({
|
1543
|
+
workspace,
|
1544
|
+
region,
|
1545
|
+
database,
|
1546
|
+
migrationRequest,
|
1547
|
+
page
|
1548
|
+
}) {
|
1143
1549
|
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
1144
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1145
|
-
body:
|
1550
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1551
|
+
body: { page },
|
1146
1552
|
...this.extraProps
|
1147
1553
|
});
|
1148
1554
|
}
|
1149
|
-
compareMigrationRequest(
|
1555
|
+
compareMigrationRequest({
|
1556
|
+
workspace,
|
1557
|
+
region,
|
1558
|
+
database,
|
1559
|
+
migrationRequest
|
1560
|
+
}) {
|
1150
1561
|
return operationsByTag.migrationRequests.compareMigrationRequest({
|
1151
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1562
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1152
1563
|
...this.extraProps
|
1153
1564
|
});
|
1154
1565
|
}
|
1155
|
-
getMigrationRequestIsMerged(
|
1566
|
+
getMigrationRequestIsMerged({
|
1567
|
+
workspace,
|
1568
|
+
region,
|
1569
|
+
database,
|
1570
|
+
migrationRequest
|
1571
|
+
}) {
|
1156
1572
|
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
1157
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1573
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1158
1574
|
...this.extraProps
|
1159
1575
|
});
|
1160
1576
|
}
|
1161
|
-
mergeMigrationRequest(
|
1577
|
+
mergeMigrationRequest({
|
1578
|
+
workspace,
|
1579
|
+
region,
|
1580
|
+
database,
|
1581
|
+
migrationRequest
|
1582
|
+
}) {
|
1162
1583
|
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
1163
|
-
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1584
|
+
pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
|
1164
1585
|
...this.extraProps
|
1165
1586
|
});
|
1166
1587
|
}
|
1167
1588
|
}
|
1168
|
-
class
|
1589
|
+
class MigrationsApi {
|
1169
1590
|
constructor(extraProps) {
|
1170
1591
|
this.extraProps = extraProps;
|
1171
1592
|
}
|
1172
|
-
getBranchMigrationHistory(
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1593
|
+
getBranchMigrationHistory({
|
1594
|
+
workspace,
|
1595
|
+
region,
|
1596
|
+
database,
|
1597
|
+
branch,
|
1598
|
+
limit,
|
1599
|
+
startFrom
|
1600
|
+
}) {
|
1601
|
+
return operationsByTag.migrations.getBranchMigrationHistory({
|
1602
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1603
|
+
body: { limit, startFrom },
|
1604
|
+
...this.extraProps
|
1605
|
+
});
|
1606
|
+
}
|
1607
|
+
getBranchMigrationPlan({
|
1608
|
+
workspace,
|
1609
|
+
region,
|
1610
|
+
database,
|
1611
|
+
branch,
|
1612
|
+
schema
|
1613
|
+
}) {
|
1614
|
+
return operationsByTag.migrations.getBranchMigrationPlan({
|
1615
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1616
|
+
body: schema,
|
1176
1617
|
...this.extraProps
|
1177
1618
|
});
|
1178
1619
|
}
|
1179
|
-
executeBranchMigrationPlan(
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1620
|
+
executeBranchMigrationPlan({
|
1621
|
+
workspace,
|
1622
|
+
region,
|
1623
|
+
database,
|
1624
|
+
branch,
|
1625
|
+
plan
|
1626
|
+
}) {
|
1627
|
+
return operationsByTag.migrations.executeBranchMigrationPlan({
|
1628
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1629
|
+
body: plan,
|
1183
1630
|
...this.extraProps
|
1184
1631
|
});
|
1185
1632
|
}
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1633
|
+
getBranchSchemaHistory({
|
1634
|
+
workspace,
|
1635
|
+
region,
|
1636
|
+
database,
|
1637
|
+
branch,
|
1638
|
+
page
|
1639
|
+
}) {
|
1640
|
+
return operationsByTag.migrations.getBranchSchemaHistory({
|
1641
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1642
|
+
body: { page },
|
1190
1643
|
...this.extraProps
|
1191
1644
|
});
|
1192
1645
|
}
|
1193
|
-
compareBranchWithUserSchema(
|
1194
|
-
|
1195
|
-
|
1646
|
+
compareBranchWithUserSchema({
|
1647
|
+
workspace,
|
1648
|
+
region,
|
1649
|
+
database,
|
1650
|
+
branch,
|
1651
|
+
schema
|
1652
|
+
}) {
|
1653
|
+
return operationsByTag.migrations.compareBranchWithUserSchema({
|
1654
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1196
1655
|
body: { schema },
|
1197
1656
|
...this.extraProps
|
1198
1657
|
});
|
1199
1658
|
}
|
1200
|
-
compareBranchSchemas(
|
1201
|
-
|
1202
|
-
|
1659
|
+
compareBranchSchemas({
|
1660
|
+
workspace,
|
1661
|
+
region,
|
1662
|
+
database,
|
1663
|
+
branch,
|
1664
|
+
compare,
|
1665
|
+
schema
|
1666
|
+
}) {
|
1667
|
+
return operationsByTag.migrations.compareBranchSchemas({
|
1668
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
1203
1669
|
body: { schema },
|
1204
1670
|
...this.extraProps
|
1205
1671
|
});
|
1206
1672
|
}
|
1207
|
-
updateBranchSchema(
|
1208
|
-
|
1209
|
-
|
1673
|
+
updateBranchSchema({
|
1674
|
+
workspace,
|
1675
|
+
region,
|
1676
|
+
database,
|
1677
|
+
branch,
|
1678
|
+
migration
|
1679
|
+
}) {
|
1680
|
+
return operationsByTag.migrations.updateBranchSchema({
|
1681
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1210
1682
|
body: migration,
|
1211
1683
|
...this.extraProps
|
1212
1684
|
});
|
1213
1685
|
}
|
1214
|
-
previewBranchSchemaEdit(
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1686
|
+
previewBranchSchemaEdit({
|
1687
|
+
workspace,
|
1688
|
+
region,
|
1689
|
+
database,
|
1690
|
+
branch,
|
1691
|
+
data
|
1692
|
+
}) {
|
1693
|
+
return operationsByTag.migrations.previewBranchSchemaEdit({
|
1694
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1695
|
+
body: data,
|
1218
1696
|
...this.extraProps
|
1219
1697
|
});
|
1220
1698
|
}
|
1221
|
-
applyBranchSchemaEdit(
|
1222
|
-
|
1223
|
-
|
1699
|
+
applyBranchSchemaEdit({
|
1700
|
+
workspace,
|
1701
|
+
region,
|
1702
|
+
database,
|
1703
|
+
branch,
|
1704
|
+
edits
|
1705
|
+
}) {
|
1706
|
+
return operationsByTag.migrations.applyBranchSchemaEdit({
|
1707
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1224
1708
|
body: { edits },
|
1225
1709
|
...this.extraProps
|
1226
1710
|
});
|
1227
1711
|
}
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1712
|
+
}
|
1713
|
+
class DatabaseApi {
|
1714
|
+
constructor(extraProps) {
|
1715
|
+
this.extraProps = extraProps;
|
1716
|
+
}
|
1717
|
+
getDatabaseList({ workspace }) {
|
1718
|
+
return operationsByTag.databases.getDatabaseList({
|
1719
|
+
pathParams: { workspaceId: workspace },
|
1720
|
+
...this.extraProps
|
1721
|
+
});
|
1722
|
+
}
|
1723
|
+
createDatabase({
|
1724
|
+
workspace,
|
1725
|
+
database,
|
1726
|
+
data
|
1727
|
+
}) {
|
1728
|
+
return operationsByTag.databases.createDatabase({
|
1729
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1730
|
+
body: data,
|
1731
|
+
...this.extraProps
|
1732
|
+
});
|
1733
|
+
}
|
1734
|
+
deleteDatabase({
|
1735
|
+
workspace,
|
1736
|
+
database
|
1737
|
+
}) {
|
1738
|
+
return operationsByTag.databases.deleteDatabase({
|
1739
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1740
|
+
...this.extraProps
|
1741
|
+
});
|
1742
|
+
}
|
1743
|
+
getDatabaseMetadata({
|
1744
|
+
workspace,
|
1745
|
+
database
|
1746
|
+
}) {
|
1747
|
+
return operationsByTag.databases.getDatabaseMetadata({
|
1748
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1749
|
+
...this.extraProps
|
1750
|
+
});
|
1751
|
+
}
|
1752
|
+
updateDatabaseMetadata({
|
1753
|
+
workspace,
|
1754
|
+
database,
|
1755
|
+
metadata
|
1756
|
+
}) {
|
1757
|
+
return operationsByTag.databases.updateDatabaseMetadata({
|
1758
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1759
|
+
body: metadata,
|
1760
|
+
...this.extraProps
|
1761
|
+
});
|
1762
|
+
}
|
1763
|
+
listRegions({ workspace }) {
|
1764
|
+
return operationsByTag.databases.listRegions({
|
1765
|
+
pathParams: { workspaceId: workspace },
|
1232
1766
|
...this.extraProps
|
1233
1767
|
});
|
1234
1768
|
}
|
@@ -1244,6 +1778,20 @@ class XataApiPlugin {
|
|
1244
1778
|
class XataPlugin {
|
1245
1779
|
}
|
1246
1780
|
|
1781
|
+
function generateUUID() {
|
1782
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
1783
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
1784
|
+
return v.toString(16);
|
1785
|
+
});
|
1786
|
+
}
|
1787
|
+
|
1788
|
+
function cleanFilter(filter) {
|
1789
|
+
if (!filter)
|
1790
|
+
return void 0;
|
1791
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
1792
|
+
return values.length > 0 ? filter : void 0;
|
1793
|
+
}
|
1794
|
+
|
1247
1795
|
var __accessCheck$6 = (obj, member, msg) => {
|
1248
1796
|
if (!member.has(obj))
|
1249
1797
|
throw TypeError("Cannot " + msg);
|
@@ -1276,11 +1824,11 @@ class Page {
|
|
1276
1824
|
async previousPage(size, offset) {
|
1277
1825
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
1278
1826
|
}
|
1279
|
-
async
|
1280
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
1827
|
+
async startPage(size, offset) {
|
1828
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
1281
1829
|
}
|
1282
|
-
async
|
1283
|
-
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset,
|
1830
|
+
async endPage(size, offset) {
|
1831
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
1284
1832
|
}
|
1285
1833
|
hasNextPage() {
|
1286
1834
|
return this.meta.page.more;
|
@@ -1292,7 +1840,7 @@ const PAGINATION_DEFAULT_SIZE = 20;
|
|
1292
1840
|
const PAGINATION_MAX_OFFSET = 800;
|
1293
1841
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
1294
1842
|
function isCursorPaginationOptions(options) {
|
1295
|
-
return isDefined(options) && (isDefined(options.
|
1843
|
+
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
1296
1844
|
}
|
1297
1845
|
const _RecordArray = class extends Array {
|
1298
1846
|
constructor(...args) {
|
@@ -1324,12 +1872,12 @@ const _RecordArray = class extends Array {
|
|
1324
1872
|
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
1325
1873
|
return new _RecordArray(newPage);
|
1326
1874
|
}
|
1327
|
-
async
|
1328
|
-
const newPage = await __privateGet$6(this, _page).
|
1875
|
+
async startPage(size, offset) {
|
1876
|
+
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
1329
1877
|
return new _RecordArray(newPage);
|
1330
1878
|
}
|
1331
|
-
async
|
1332
|
-
const newPage = await __privateGet$6(this, _page).
|
1879
|
+
async endPage(size, offset) {
|
1880
|
+
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
1333
1881
|
return new _RecordArray(newPage);
|
1334
1882
|
}
|
1335
1883
|
hasNextPage() {
|
@@ -1357,9 +1905,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
|
|
1357
1905
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1358
1906
|
return value;
|
1359
1907
|
};
|
1360
|
-
var
|
1908
|
+
var __privateMethod$3 = (obj, member, method) => {
|
1909
|
+
__accessCheck$5(obj, member, "access private method");
|
1910
|
+
return method;
|
1911
|
+
};
|
1912
|
+
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
1361
1913
|
const _Query = class {
|
1362
1914
|
constructor(repository, table, data, rawParent) {
|
1915
|
+
__privateAdd$5(this, _cleanFilterConstraint);
|
1363
1916
|
__privateAdd$5(this, _table$1, void 0);
|
1364
1917
|
__privateAdd$5(this, _repository, void 0);
|
1365
1918
|
__privateAdd$5(this, _data, { filter: {} });
|
@@ -1378,9 +1931,10 @@ const _Query = class {
|
|
1378
1931
|
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
1379
1932
|
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
1380
1933
|
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
1381
|
-
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns
|
1934
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
|
1382
1935
|
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
1383
1936
|
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
1937
|
+
__privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
|
1384
1938
|
this.any = this.any.bind(this);
|
1385
1939
|
this.all = this.all.bind(this);
|
1386
1940
|
this.not = this.not.bind(this);
|
@@ -1416,22 +1970,17 @@ const _Query = class {
|
|
1416
1970
|
}
|
1417
1971
|
filter(a, b) {
|
1418
1972
|
if (arguments.length === 1) {
|
1419
|
-
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
1973
|
+
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
1974
|
+
[column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
|
1975
|
+
}));
|
1420
1976
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1421
1977
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1422
1978
|
} else {
|
1423
|
-
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.
|
1979
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
|
1424
1980
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1425
1981
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1426
1982
|
}
|
1427
1983
|
}
|
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
1984
|
sort(column, direction = "asc") {
|
1436
1985
|
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
1437
1986
|
const sort = [...originalSort, { column, direction }];
|
@@ -1466,11 +2015,20 @@ const _Query = class {
|
|
1466
2015
|
}
|
1467
2016
|
}
|
1468
2017
|
async getMany(options = {}) {
|
1469
|
-
const
|
2018
|
+
const { pagination = {}, ...rest } = options;
|
2019
|
+
const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
|
2020
|
+
const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
|
2021
|
+
let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
|
2022
|
+
const results = [...page.records];
|
2023
|
+
while (page.hasNextPage() && results.length < size) {
|
2024
|
+
page = await page.nextPage();
|
2025
|
+
results.push(...page.records);
|
2026
|
+
}
|
1470
2027
|
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
1471
2028
|
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
1472
2029
|
}
|
1473
|
-
|
2030
|
+
const array = new RecordArray(page, results.slice(0, size));
|
2031
|
+
return array;
|
1474
2032
|
}
|
1475
2033
|
async getAll(options = {}) {
|
1476
2034
|
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
@@ -1484,19 +2042,35 @@ const _Query = class {
|
|
1484
2042
|
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1485
2043
|
return records[0] ?? null;
|
1486
2044
|
}
|
2045
|
+
async getFirstOrThrow(options = {}) {
|
2046
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
2047
|
+
if (records[0] === void 0)
|
2048
|
+
throw new Error("No results found.");
|
2049
|
+
return records[0];
|
2050
|
+
}
|
2051
|
+
async summarize(params = {}) {
|
2052
|
+
const { summaries, summariesFilter, ...options } = params;
|
2053
|
+
const query = new _Query(
|
2054
|
+
__privateGet$5(this, _repository),
|
2055
|
+
__privateGet$5(this, _table$1),
|
2056
|
+
options,
|
2057
|
+
__privateGet$5(this, _data)
|
2058
|
+
);
|
2059
|
+
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
2060
|
+
}
|
1487
2061
|
cache(ttl) {
|
1488
2062
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1489
2063
|
}
|
1490
2064
|
nextPage(size, offset) {
|
1491
|
-
return this.
|
2065
|
+
return this.startPage(size, offset);
|
1492
2066
|
}
|
1493
2067
|
previousPage(size, offset) {
|
1494
|
-
return this.
|
2068
|
+
return this.startPage(size, offset);
|
1495
2069
|
}
|
1496
|
-
|
2070
|
+
startPage(size, offset) {
|
1497
2071
|
return this.getPaginated({ pagination: { size, offset } });
|
1498
2072
|
}
|
1499
|
-
|
2073
|
+
endPage(size, offset) {
|
1500
2074
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
1501
2075
|
}
|
1502
2076
|
hasNextPage() {
|
@@ -1507,9 +2081,20 @@ let Query = _Query;
|
|
1507
2081
|
_table$1 = new WeakMap();
|
1508
2082
|
_repository = new WeakMap();
|
1509
2083
|
_data = new WeakMap();
|
2084
|
+
_cleanFilterConstraint = new WeakSet();
|
2085
|
+
cleanFilterConstraint_fn = function(column, value) {
|
2086
|
+
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
2087
|
+
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
2088
|
+
return { $includes: value };
|
2089
|
+
}
|
2090
|
+
if (columnType === "link" && isObject(value) && isString(value.id)) {
|
2091
|
+
return value.id;
|
2092
|
+
}
|
2093
|
+
return value;
|
2094
|
+
};
|
1510
2095
|
function cleanParent(data, parent) {
|
1511
2096
|
if (isCursorPaginationOptions(data.pagination)) {
|
1512
|
-
return { ...parent,
|
2097
|
+
return { ...parent, sort: void 0, filter: void 0 };
|
1513
2098
|
}
|
1514
2099
|
return parent;
|
1515
2100
|
}
|
@@ -1594,10 +2179,13 @@ class RestRepository extends Query {
|
|
1594
2179
|
__privateAdd$4(this, _schemaTables$2, void 0);
|
1595
2180
|
__privateAdd$4(this, _trace, void 0);
|
1596
2181
|
__privateSet$4(this, _table, options.table);
|
1597
|
-
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1598
2182
|
__privateSet$4(this, _db, options.db);
|
1599
2183
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
1600
2184
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
2185
|
+
__privateSet$4(this, _getFetchProps, async () => {
|
2186
|
+
const props = await options.pluginOptions.getFetchProps();
|
2187
|
+
return { ...props, sessionID: generateUUID() };
|
2188
|
+
});
|
1601
2189
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
1602
2190
|
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
1603
2191
|
return trace(name, fn, {
|
@@ -1608,8 +2196,9 @@ class RestRepository extends Query {
|
|
1608
2196
|
});
|
1609
2197
|
});
|
1610
2198
|
}
|
1611
|
-
async create(a, b, c) {
|
2199
|
+
async create(a, b, c, d) {
|
1612
2200
|
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
2201
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1613
2202
|
if (Array.isArray(a)) {
|
1614
2203
|
if (a.length === 0)
|
1615
2204
|
return [];
|
@@ -1620,13 +2209,13 @@ class RestRepository extends Query {
|
|
1620
2209
|
if (a === "")
|
1621
2210
|
throw new Error("The id can't be empty");
|
1622
2211
|
const columns = isStringArray(c) ? c : void 0;
|
1623
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
2212
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
1624
2213
|
}
|
1625
2214
|
if (isObject(a) && isString(a.id)) {
|
1626
2215
|
if (a.id === "")
|
1627
2216
|
throw new Error("The id can't be empty");
|
1628
2217
|
const columns = isStringArray(b) ? b : void 0;
|
1629
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
2218
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
1630
2219
|
}
|
1631
2220
|
if (isObject(a)) {
|
1632
2221
|
const columns = isStringArray(b) ? b : void 0;
|
@@ -1657,6 +2246,7 @@ class RestRepository extends Query {
|
|
1657
2246
|
pathParams: {
|
1658
2247
|
workspace: "{workspaceId}",
|
1659
2248
|
dbBranchName: "{dbBranch}",
|
2249
|
+
region: "{region}",
|
1660
2250
|
tableName: __privateGet$4(this, _table),
|
1661
2251
|
recordId: id
|
1662
2252
|
},
|
@@ -1664,7 +2254,7 @@ class RestRepository extends Query {
|
|
1664
2254
|
...fetchProps
|
1665
2255
|
});
|
1666
2256
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1667
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2257
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1668
2258
|
} catch (e) {
|
1669
2259
|
if (isObject(e) && e.status === 404) {
|
1670
2260
|
return null;
|
@@ -1675,8 +2265,28 @@ class RestRepository extends Query {
|
|
1675
2265
|
return null;
|
1676
2266
|
});
|
1677
2267
|
}
|
1678
|
-
async
|
2268
|
+
async readOrThrow(a, b) {
|
2269
|
+
return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
|
2270
|
+
const result = await this.read(a, b);
|
2271
|
+
if (Array.isArray(result)) {
|
2272
|
+
const missingIds = compact(
|
2273
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2274
|
+
);
|
2275
|
+
if (missingIds.length > 0) {
|
2276
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
2277
|
+
}
|
2278
|
+
return result;
|
2279
|
+
}
|
2280
|
+
if (result === null) {
|
2281
|
+
const id = extractId(a) ?? "unknown";
|
2282
|
+
throw new Error(`Record with id ${id} not found`);
|
2283
|
+
}
|
2284
|
+
return result;
|
2285
|
+
});
|
2286
|
+
}
|
2287
|
+
async update(a, b, c, d) {
|
1679
2288
|
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
2289
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1680
2290
|
if (Array.isArray(a)) {
|
1681
2291
|
if (a.length === 0)
|
1682
2292
|
return [];
|
@@ -1688,17 +2298,37 @@ class RestRepository extends Query {
|
|
1688
2298
|
}
|
1689
2299
|
if (isString(a) && isObject(b)) {
|
1690
2300
|
const columns = isStringArray(c) ? c : void 0;
|
1691
|
-
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
|
2301
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
1692
2302
|
}
|
1693
2303
|
if (isObject(a) && isString(a.id)) {
|
1694
2304
|
const columns = isStringArray(b) ? b : void 0;
|
1695
|
-
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
2305
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
1696
2306
|
}
|
1697
2307
|
throw new Error("Invalid arguments for update method");
|
1698
2308
|
});
|
1699
2309
|
}
|
1700
|
-
async
|
2310
|
+
async updateOrThrow(a, b, c, d) {
|
2311
|
+
return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
|
2312
|
+
const result = await this.update(a, b, c, d);
|
2313
|
+
if (Array.isArray(result)) {
|
2314
|
+
const missingIds = compact(
|
2315
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2316
|
+
);
|
2317
|
+
if (missingIds.length > 0) {
|
2318
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
2319
|
+
}
|
2320
|
+
return result;
|
2321
|
+
}
|
2322
|
+
if (result === null) {
|
2323
|
+
const id = extractId(a) ?? "unknown";
|
2324
|
+
throw new Error(`Record with id ${id} not found`);
|
2325
|
+
}
|
2326
|
+
return result;
|
2327
|
+
});
|
2328
|
+
}
|
2329
|
+
async createOrUpdate(a, b, c, d) {
|
1701
2330
|
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
2331
|
+
const ifVersion = parseIfVersion(b, c, d);
|
1702
2332
|
if (Array.isArray(a)) {
|
1703
2333
|
if (a.length === 0)
|
1704
2334
|
return [];
|
@@ -1710,15 +2340,35 @@ class RestRepository extends Query {
|
|
1710
2340
|
}
|
1711
2341
|
if (isString(a) && isObject(b)) {
|
1712
2342
|
const columns = isStringArray(c) ? c : void 0;
|
1713
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
|
2343
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
1714
2344
|
}
|
1715
2345
|
if (isObject(a) && isString(a.id)) {
|
1716
2346
|
const columns = isStringArray(c) ? c : void 0;
|
1717
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
2347
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
1718
2348
|
}
|
1719
2349
|
throw new Error("Invalid arguments for createOrUpdate method");
|
1720
2350
|
});
|
1721
2351
|
}
|
2352
|
+
async createOrReplace(a, b, c, d) {
|
2353
|
+
return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
|
2354
|
+
const ifVersion = parseIfVersion(b, c, d);
|
2355
|
+
if (Array.isArray(a)) {
|
2356
|
+
if (a.length === 0)
|
2357
|
+
return [];
|
2358
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2359
|
+
return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
|
2360
|
+
}
|
2361
|
+
if (isString(a) && isObject(b)) {
|
2362
|
+
const columns = isStringArray(c) ? c : void 0;
|
2363
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
2364
|
+
}
|
2365
|
+
if (isObject(a) && isString(a.id)) {
|
2366
|
+
const columns = isStringArray(c) ? c : void 0;
|
2367
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
2368
|
+
}
|
2369
|
+
throw new Error("Invalid arguments for createOrReplace method");
|
2370
|
+
});
|
2371
|
+
}
|
1722
2372
|
async delete(a, b) {
|
1723
2373
|
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
1724
2374
|
if (Array.isArray(a)) {
|
@@ -1738,11 +2388,34 @@ class RestRepository extends Query {
|
|
1738
2388
|
throw new Error("Invalid arguments for delete method");
|
1739
2389
|
});
|
1740
2390
|
}
|
2391
|
+
async deleteOrThrow(a, b) {
|
2392
|
+
return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
|
2393
|
+
const result = await this.delete(a, b);
|
2394
|
+
if (Array.isArray(result)) {
|
2395
|
+
const missingIds = compact(
|
2396
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2397
|
+
);
|
2398
|
+
if (missingIds.length > 0) {
|
2399
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
2400
|
+
}
|
2401
|
+
return result;
|
2402
|
+
} else if (result === null) {
|
2403
|
+
const id = extractId(a) ?? "unknown";
|
2404
|
+
throw new Error(`Record with id ${id} not found`);
|
2405
|
+
}
|
2406
|
+
return result;
|
2407
|
+
});
|
2408
|
+
}
|
1741
2409
|
async search(query, options = {}) {
|
1742
2410
|
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
1743
2411
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1744
2412
|
const { records } = await searchTable({
|
1745
|
-
pathParams: {
|
2413
|
+
pathParams: {
|
2414
|
+
workspace: "{workspaceId}",
|
2415
|
+
dbBranchName: "{dbBranch}",
|
2416
|
+
region: "{region}",
|
2417
|
+
tableName: __privateGet$4(this, _table)
|
2418
|
+
},
|
1746
2419
|
body: {
|
1747
2420
|
query,
|
1748
2421
|
fuzziness: options.fuzziness,
|
@@ -1754,7 +2427,23 @@ class RestRepository extends Query {
|
|
1754
2427
|
...fetchProps
|
1755
2428
|
});
|
1756
2429
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1757
|
-
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
2430
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
2431
|
+
});
|
2432
|
+
}
|
2433
|
+
async aggregate(aggs, filter) {
|
2434
|
+
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
2435
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2436
|
+
const result = await aggregateTable({
|
2437
|
+
pathParams: {
|
2438
|
+
workspace: "{workspaceId}",
|
2439
|
+
dbBranchName: "{dbBranch}",
|
2440
|
+
region: "{region}",
|
2441
|
+
tableName: __privateGet$4(this, _table)
|
2442
|
+
},
|
2443
|
+
body: { aggs, filter },
|
2444
|
+
...fetchProps
|
2445
|
+
});
|
2446
|
+
return result;
|
1758
2447
|
});
|
1759
2448
|
}
|
1760
2449
|
async query(query) {
|
@@ -1763,24 +2452,55 @@ class RestRepository extends Query {
|
|
1763
2452
|
if (cacheQuery)
|
1764
2453
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
1765
2454
|
const data = query.getQueryOptions();
|
1766
|
-
const body = {
|
1767
|
-
filter: cleanFilter(data.filter),
|
1768
|
-
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1769
|
-
page: data.pagination,
|
1770
|
-
columns: data.columns
|
1771
|
-
};
|
1772
2455
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1773
2456
|
const { meta, records: objects } = await queryTable({
|
1774
|
-
pathParams: {
|
1775
|
-
|
2457
|
+
pathParams: {
|
2458
|
+
workspace: "{workspaceId}",
|
2459
|
+
dbBranchName: "{dbBranch}",
|
2460
|
+
region: "{region}",
|
2461
|
+
tableName: __privateGet$4(this, _table)
|
2462
|
+
},
|
2463
|
+
body: {
|
2464
|
+
filter: cleanFilter(data.filter),
|
2465
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2466
|
+
page: data.pagination,
|
2467
|
+
columns: data.columns ?? ["*"]
|
2468
|
+
},
|
2469
|
+
fetchOptions: data.fetchOptions,
|
1776
2470
|
...fetchProps
|
1777
2471
|
});
|
1778
2472
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1779
|
-
const records = objects.map(
|
2473
|
+
const records = objects.map(
|
2474
|
+
(record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
|
2475
|
+
);
|
1780
2476
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1781
2477
|
return new Page(query, meta, records);
|
1782
2478
|
});
|
1783
2479
|
}
|
2480
|
+
async summarizeTable(query, summaries, summariesFilter) {
|
2481
|
+
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
2482
|
+
const data = query.getQueryOptions();
|
2483
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2484
|
+
const result = await summarizeTable({
|
2485
|
+
pathParams: {
|
2486
|
+
workspace: "{workspaceId}",
|
2487
|
+
dbBranchName: "{dbBranch}",
|
2488
|
+
region: "{region}",
|
2489
|
+
tableName: __privateGet$4(this, _table)
|
2490
|
+
},
|
2491
|
+
body: {
|
2492
|
+
filter: cleanFilter(data.filter),
|
2493
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2494
|
+
columns: data.columns,
|
2495
|
+
page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
|
2496
|
+
summaries,
|
2497
|
+
summariesFilter
|
2498
|
+
},
|
2499
|
+
...fetchProps
|
2500
|
+
});
|
2501
|
+
return result;
|
2502
|
+
});
|
2503
|
+
}
|
1784
2504
|
}
|
1785
2505
|
_table = new WeakMap();
|
1786
2506
|
_getFetchProps = new WeakMap();
|
@@ -1796,6 +2516,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1796
2516
|
pathParams: {
|
1797
2517
|
workspace: "{workspaceId}",
|
1798
2518
|
dbBranchName: "{dbBranch}",
|
2519
|
+
region: "{region}",
|
1799
2520
|
tableName: __privateGet$4(this, _table)
|
1800
2521
|
},
|
1801
2522
|
queryParams: { columns },
|
@@ -1803,32 +2524,38 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1803
2524
|
...fetchProps
|
1804
2525
|
});
|
1805
2526
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1806
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2527
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1807
2528
|
};
|
1808
2529
|
_insertRecordWithId = new WeakSet();
|
1809
|
-
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
2530
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
1810
2531
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1811
2532
|
const record = transformObjectLinks(object);
|
1812
2533
|
const response = await insertRecordWithID({
|
1813
2534
|
pathParams: {
|
1814
2535
|
workspace: "{workspaceId}",
|
1815
2536
|
dbBranchName: "{dbBranch}",
|
2537
|
+
region: "{region}",
|
1816
2538
|
tableName: __privateGet$4(this, _table),
|
1817
2539
|
recordId
|
1818
2540
|
},
|
1819
2541
|
body: record,
|
1820
|
-
queryParams: { createOnly
|
2542
|
+
queryParams: { createOnly, columns, ifVersion },
|
1821
2543
|
...fetchProps
|
1822
2544
|
});
|
1823
2545
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1824
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2546
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1825
2547
|
};
|
1826
2548
|
_bulkInsertTableRecords = new WeakSet();
|
1827
2549
|
bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
1828
2550
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1829
2551
|
const records = objects.map((object) => transformObjectLinks(object));
|
1830
2552
|
const response = await bulkInsertTableRecords({
|
1831
|
-
pathParams: {
|
2553
|
+
pathParams: {
|
2554
|
+
workspace: "{workspaceId}",
|
2555
|
+
dbBranchName: "{dbBranch}",
|
2556
|
+
region: "{region}",
|
2557
|
+
tableName: __privateGet$4(this, _table)
|
2558
|
+
},
|
1832
2559
|
queryParams: { columns },
|
1833
2560
|
body: { records },
|
1834
2561
|
...fetchProps
|
@@ -1837,21 +2564,27 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
|
1837
2564
|
throw new Error("Request included columns but server didn't include them");
|
1838
2565
|
}
|
1839
2566
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1840
|
-
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
2567
|
+
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
|
1841
2568
|
};
|
1842
2569
|
_updateRecordWithID = new WeakSet();
|
1843
|
-
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2570
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
1844
2571
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1845
2572
|
const record = transformObjectLinks(object);
|
1846
2573
|
try {
|
1847
2574
|
const response = await updateRecordWithID({
|
1848
|
-
pathParams: {
|
1849
|
-
|
2575
|
+
pathParams: {
|
2576
|
+
workspace: "{workspaceId}",
|
2577
|
+
dbBranchName: "{dbBranch}",
|
2578
|
+
region: "{region}",
|
2579
|
+
tableName: __privateGet$4(this, _table),
|
2580
|
+
recordId
|
2581
|
+
},
|
2582
|
+
queryParams: { columns, ifVersion },
|
1850
2583
|
body: record,
|
1851
2584
|
...fetchProps
|
1852
2585
|
});
|
1853
2586
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1854
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2587
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1855
2588
|
} catch (e) {
|
1856
2589
|
if (isObject(e) && e.status === 404) {
|
1857
2590
|
return null;
|
@@ -1860,28 +2593,40 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
1860
2593
|
}
|
1861
2594
|
};
|
1862
2595
|
_upsertRecordWithID = new WeakSet();
|
1863
|
-
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2596
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
1864
2597
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1865
2598
|
const response = await upsertRecordWithID({
|
1866
|
-
pathParams: {
|
1867
|
-
|
2599
|
+
pathParams: {
|
2600
|
+
workspace: "{workspaceId}",
|
2601
|
+
dbBranchName: "{dbBranch}",
|
2602
|
+
region: "{region}",
|
2603
|
+
tableName: __privateGet$4(this, _table),
|
2604
|
+
recordId
|
2605
|
+
},
|
2606
|
+
queryParams: { columns, ifVersion },
|
1868
2607
|
body: object,
|
1869
2608
|
...fetchProps
|
1870
2609
|
});
|
1871
2610
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1872
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2611
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1873
2612
|
};
|
1874
2613
|
_deleteRecord = new WeakSet();
|
1875
2614
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
1876
2615
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1877
2616
|
try {
|
1878
2617
|
const response = await deleteRecord({
|
1879
|
-
pathParams: {
|
2618
|
+
pathParams: {
|
2619
|
+
workspace: "{workspaceId}",
|
2620
|
+
dbBranchName: "{dbBranch}",
|
2621
|
+
region: "{region}",
|
2622
|
+
tableName: __privateGet$4(this, _table),
|
2623
|
+
recordId
|
2624
|
+
},
|
1880
2625
|
queryParams: { columns },
|
1881
2626
|
...fetchProps
|
1882
2627
|
});
|
1883
2628
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1884
|
-
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
2629
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1885
2630
|
} catch (e) {
|
1886
2631
|
if (isObject(e) && e.status === 404) {
|
1887
2632
|
return null;
|
@@ -1911,7 +2656,7 @@ getSchemaTables_fn$1 = async function() {
|
|
1911
2656
|
return __privateGet$4(this, _schemaTables$2);
|
1912
2657
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1913
2658
|
const { schema } = await getBranchDetails({
|
1914
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2659
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
1915
2660
|
...fetchProps
|
1916
2661
|
});
|
1917
2662
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
@@ -1924,7 +2669,7 @@ const transformObjectLinks = (object) => {
|
|
1924
2669
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1925
2670
|
}, {});
|
1926
2671
|
};
|
1927
|
-
const initObject = (db, schemaTables, table, object) => {
|
2672
|
+
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
1928
2673
|
const result = {};
|
1929
2674
|
const { xata, ...rest } = object ?? {};
|
1930
2675
|
Object.assign(result, rest);
|
@@ -1932,6 +2677,8 @@ const initObject = (db, schemaTables, table, object) => {
|
|
1932
2677
|
if (!columns)
|
1933
2678
|
console.error(`Table ${table} not found in schema`);
|
1934
2679
|
for (const column of columns ?? []) {
|
2680
|
+
if (!isValidColumn(selectedColumns, column))
|
2681
|
+
continue;
|
1935
2682
|
const value = result[column.name];
|
1936
2683
|
switch (column.type) {
|
1937
2684
|
case "datetime": {
|
@@ -1948,17 +2695,42 @@ const initObject = (db, schemaTables, table, object) => {
|
|
1948
2695
|
if (!linkTable) {
|
1949
2696
|
console.error(`Failed to parse link for field ${column.name}`);
|
1950
2697
|
} else if (isObject(value)) {
|
1951
|
-
|
2698
|
+
const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
|
2699
|
+
if (item === column.name) {
|
2700
|
+
return [...acc, "*"];
|
2701
|
+
}
|
2702
|
+
if (item.startsWith(`${column.name}.`)) {
|
2703
|
+
const [, ...path] = item.split(".");
|
2704
|
+
return [...acc, path.join(".")];
|
2705
|
+
}
|
2706
|
+
return acc;
|
2707
|
+
}, []);
|
2708
|
+
result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
|
2709
|
+
} else {
|
2710
|
+
result[column.name] = null;
|
1952
2711
|
}
|
1953
2712
|
break;
|
1954
2713
|
}
|
2714
|
+
default:
|
2715
|
+
result[column.name] = value ?? null;
|
2716
|
+
if (column.notNull === true && value === null) {
|
2717
|
+
console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
|
2718
|
+
}
|
2719
|
+
break;
|
1955
2720
|
}
|
1956
2721
|
}
|
1957
2722
|
result.read = function(columns2) {
|
1958
2723
|
return db[table].read(result["id"], columns2);
|
1959
2724
|
};
|
1960
|
-
result.update = function(data,
|
1961
|
-
|
2725
|
+
result.update = function(data, b, c) {
|
2726
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2727
|
+
const ifVersion = parseIfVersion(b, c);
|
2728
|
+
return db[table].update(result["id"], data, columns2, { ifVersion });
|
2729
|
+
};
|
2730
|
+
result.replace = function(data, b, c) {
|
2731
|
+
const columns2 = isStringArray(b) ? b : ["*"];
|
2732
|
+
const ifVersion = parseIfVersion(b, c);
|
2733
|
+
return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
|
1962
2734
|
};
|
1963
2735
|
result.delete = function() {
|
1964
2736
|
return db[table].delete(result["id"]);
|
@@ -1966,7 +2738,7 @@ const initObject = (db, schemaTables, table, object) => {
|
|
1966
2738
|
result.getMetadata = function() {
|
1967
2739
|
return xata;
|
1968
2740
|
};
|
1969
|
-
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
2741
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
|
1970
2742
|
Object.defineProperty(result, prop, { enumerable: false });
|
1971
2743
|
}
|
1972
2744
|
Object.freeze(result);
|
@@ -1982,11 +2754,22 @@ function extractId(value) {
|
|
1982
2754
|
return value.id;
|
1983
2755
|
return void 0;
|
1984
2756
|
}
|
1985
|
-
function
|
1986
|
-
if (
|
1987
|
-
return
|
1988
|
-
|
1989
|
-
|
2757
|
+
function isValidColumn(columns, column) {
|
2758
|
+
if (columns.includes("*"))
|
2759
|
+
return true;
|
2760
|
+
if (column.type === "link") {
|
2761
|
+
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
2762
|
+
return linkColumns.length > 0;
|
2763
|
+
}
|
2764
|
+
return columns.includes(column.name);
|
2765
|
+
}
|
2766
|
+
function parseIfVersion(...args) {
|
2767
|
+
for (const arg of args) {
|
2768
|
+
if (isObject(arg) && isNumber(arg.ifVersion)) {
|
2769
|
+
return arg.ifVersion;
|
2770
|
+
}
|
2771
|
+
}
|
2772
|
+
return void 0;
|
1990
2773
|
}
|
1991
2774
|
|
1992
2775
|
var __accessCheck$3 = (obj, member, msg) => {
|
@@ -2153,7 +2936,7 @@ class SearchPlugin extends XataPlugin {
|
|
2153
2936
|
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
2154
2937
|
return records.map((record) => {
|
2155
2938
|
const { table = "orphan" } = record.xata;
|
2156
|
-
return { table, record: initObject(this.db, schemaTables, table, record) };
|
2939
|
+
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
2157
2940
|
});
|
2158
2941
|
},
|
2159
2942
|
byTable: async (query, options = {}) => {
|
@@ -2162,7 +2945,7 @@ class SearchPlugin extends XataPlugin {
|
|
2162
2945
|
return records.reduce((acc, record) => {
|
2163
2946
|
const { table = "orphan" } = record.xata;
|
2164
2947
|
const items = acc[table] ?? [];
|
2165
|
-
const item = initObject(this.db, schemaTables, table, record);
|
2948
|
+
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
2166
2949
|
return { ...acc, [table]: [...items, item] };
|
2167
2950
|
}, {});
|
2168
2951
|
}
|
@@ -2175,7 +2958,7 @@ search_fn = async function(query, options, getFetchProps) {
|
|
2175
2958
|
const fetchProps = await getFetchProps();
|
2176
2959
|
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
2177
2960
|
const { records } = await searchBranch({
|
2178
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2961
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2179
2962
|
body: { tables, query, fuzziness, prefix, highlight },
|
2180
2963
|
...fetchProps
|
2181
2964
|
});
|
@@ -2187,7 +2970,7 @@ getSchemaTables_fn = async function(getFetchProps) {
|
|
2187
2970
|
return __privateGet$1(this, _schemaTables);
|
2188
2971
|
const fetchProps = await getFetchProps();
|
2189
2972
|
const { schema } = await getBranchDetails({
|
2190
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2973
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
2191
2974
|
...fetchProps
|
2192
2975
|
});
|
2193
2976
|
__privateSet$1(this, _schemaTables, schema.tables);
|
@@ -2225,14 +3008,17 @@ async function resolveXataBranch(gitBranch, options) {
|
|
2225
3008
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2226
3009
|
);
|
2227
3010
|
const [protocol, , host, , dbName] = databaseURL.split("/");
|
2228
|
-
const
|
3011
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
3012
|
+
if (!urlParts)
|
3013
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3014
|
+
const { workspace, region } = urlParts;
|
2229
3015
|
const { fallbackBranch } = getEnvironment();
|
2230
3016
|
const { branch } = await resolveBranch({
|
2231
3017
|
apiKey,
|
2232
3018
|
apiUrl: databaseURL,
|
2233
3019
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2234
3020
|
workspacesApiUrl: `${protocol}//${host}`,
|
2235
|
-
pathParams: { dbName, workspace },
|
3021
|
+
pathParams: { dbName, workspace, region },
|
2236
3022
|
queryParams: { gitBranch, fallbackBranch },
|
2237
3023
|
trace: defaultTrace
|
2238
3024
|
});
|
@@ -2250,15 +3036,17 @@ async function getDatabaseBranch(branch, options) {
|
|
2250
3036
|
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2251
3037
|
);
|
2252
3038
|
const [protocol, , host, , database] = databaseURL.split("/");
|
2253
|
-
const
|
2254
|
-
|
3039
|
+
const urlParts = parseWorkspacesUrlParts(host);
|
3040
|
+
if (!urlParts)
|
3041
|
+
throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
|
3042
|
+
const { workspace, region } = urlParts;
|
2255
3043
|
try {
|
2256
3044
|
return await getBranchDetails({
|
2257
3045
|
apiKey,
|
2258
3046
|
apiUrl: databaseURL,
|
2259
3047
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2260
3048
|
workspacesApiUrl: `${protocol}//${host}`,
|
2261
|
-
pathParams: { dbBranchName
|
3049
|
+
pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
|
2262
3050
|
trace: defaultTrace
|
2263
3051
|
});
|
2264
3052
|
} catch (err) {
|
@@ -2337,6 +3125,13 @@ const buildClient = (plugins) => {
|
|
2337
3125
|
return { databaseURL, branch };
|
2338
3126
|
}
|
2339
3127
|
}, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
3128
|
+
const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
|
3129
|
+
const isBrowser = typeof window !== "undefined";
|
3130
|
+
if (isBrowser && !enableBrowser) {
|
3131
|
+
throw new Error(
|
3132
|
+
"You are trying to use Xata from the browser, which is potentially a non-secure environment. If you understand the security concerns, such as leaking your credentials, pass `enableBrowser: true` to the client options to remove this error."
|
3133
|
+
);
|
3134
|
+
}
|
2340
3135
|
const fetch = getFetchImplementation(options?.fetch);
|
2341
3136
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
2342
3137
|
const apiKey = options?.apiKey || getAPIKey();
|
@@ -2349,8 +3144,8 @@ const buildClient = (plugins) => {
|
|
2349
3144
|
if (!databaseURL) {
|
2350
3145
|
throw new Error("Option databaseURL is required");
|
2351
3146
|
}
|
2352
|
-
return { fetch, databaseURL, apiKey, branch, cache, trace };
|
2353
|
-
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
|
3147
|
+
return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser };
|
3148
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace, clientID }) {
|
2354
3149
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
2355
3150
|
if (!branchValue)
|
2356
3151
|
throw new Error("Unable to resolve branch value");
|
@@ -2363,7 +3158,8 @@ const buildClient = (plugins) => {
|
|
2363
3158
|
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
|
2364
3159
|
return databaseURL + newPath;
|
2365
3160
|
},
|
2366
|
-
trace
|
3161
|
+
trace,
|
3162
|
+
clientID
|
2367
3163
|
};
|
2368
3164
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
2369
3165
|
if (__privateGet(this, _branch))
|
@@ -2497,7 +3293,9 @@ exports.XataPlugin = XataPlugin;
|
|
2497
3293
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
2498
3294
|
exports.addGitBranchesEntry = addGitBranchesEntry;
|
2499
3295
|
exports.addTableColumn = addTableColumn;
|
3296
|
+
exports.aggregateTable = aggregateTable;
|
2500
3297
|
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
3298
|
+
exports.branchTransaction = branchTransaction;
|
2501
3299
|
exports.buildClient = buildClient;
|
2502
3300
|
exports.buildWorkerRunner = buildWorkerRunner;
|
2503
3301
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
@@ -2512,6 +3310,11 @@ exports.createMigrationRequest = createMigrationRequest;
|
|
2512
3310
|
exports.createTable = createTable;
|
2513
3311
|
exports.createUserAPIKey = createUserAPIKey;
|
2514
3312
|
exports.createWorkspace = createWorkspace;
|
3313
|
+
exports.dEPRECATEDcreateDatabase = dEPRECATEDcreateDatabase;
|
3314
|
+
exports.dEPRECATEDdeleteDatabase = dEPRECATEDdeleteDatabase;
|
3315
|
+
exports.dEPRECATEDgetDatabaseList = dEPRECATEDgetDatabaseList;
|
3316
|
+
exports.dEPRECATEDgetDatabaseMetadata = dEPRECATEDgetDatabaseMetadata;
|
3317
|
+
exports.dEPRECATEDupdateDatabaseMetadata = dEPRECATEDupdateDatabaseMetadata;
|
2515
3318
|
exports.deleteBranch = deleteBranch;
|
2516
3319
|
exports.deleteColumn = deleteColumn;
|
2517
3320
|
exports.deleteDatabase = deleteDatabase;
|
@@ -2541,6 +3344,7 @@ exports.getDatabaseList = getDatabaseList;
|
|
2541
3344
|
exports.getDatabaseMetadata = getDatabaseMetadata;
|
2542
3345
|
exports.getDatabaseURL = getDatabaseURL;
|
2543
3346
|
exports.getGitBranchesMapping = getGitBranchesMapping;
|
3347
|
+
exports.getHostUrl = getHostUrl;
|
2544
3348
|
exports.getMigrationRequest = getMigrationRequest;
|
2545
3349
|
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
2546
3350
|
exports.getRecord = getRecord;
|
@@ -2565,6 +3369,8 @@ exports.insertRecordWithID = insertRecordWithID;
|
|
2565
3369
|
exports.inviteWorkspaceMember = inviteWorkspaceMember;
|
2566
3370
|
exports.is = is;
|
2567
3371
|
exports.isCursorPaginationOptions = isCursorPaginationOptions;
|
3372
|
+
exports.isHostProviderAlias = isHostProviderAlias;
|
3373
|
+
exports.isHostProviderBuilder = isHostProviderBuilder;
|
2568
3374
|
exports.isIdentifiable = isIdentifiable;
|
2569
3375
|
exports.isNot = isNot;
|
2570
3376
|
exports.isXataRecord = isXataRecord;
|
@@ -2572,15 +3378,18 @@ exports.le = le;
|
|
2572
3378
|
exports.lessEquals = lessEquals;
|
2573
3379
|
exports.lessThan = lessThan;
|
2574
3380
|
exports.lessThanEquals = lessThanEquals;
|
2575
|
-
exports.listMigrationRequests = listMigrationRequests;
|
2576
3381
|
exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
|
3382
|
+
exports.listRegions = listRegions;
|
2577
3383
|
exports.lt = lt;
|
2578
3384
|
exports.lte = lte;
|
2579
3385
|
exports.mergeMigrationRequest = mergeMigrationRequest;
|
2580
3386
|
exports.notExists = notExists;
|
2581
3387
|
exports.operationsByTag = operationsByTag;
|
3388
|
+
exports.parseProviderString = parseProviderString;
|
3389
|
+
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
2582
3390
|
exports.pattern = pattern;
|
2583
3391
|
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
3392
|
+
exports.queryMigrationRequests = queryMigrationRequests;
|
2584
3393
|
exports.queryTable = queryTable;
|
2585
3394
|
exports.removeGitBranchesEntry = removeGitBranchesEntry;
|
2586
3395
|
exports.removeWorkspaceMember = removeWorkspaceMember;
|
@@ -2591,9 +3400,11 @@ exports.searchTable = searchTable;
|
|
2591
3400
|
exports.serialize = serialize;
|
2592
3401
|
exports.setTableSchema = setTableSchema;
|
2593
3402
|
exports.startsWith = startsWith;
|
3403
|
+
exports.summarizeTable = summarizeTable;
|
2594
3404
|
exports.updateBranchMetadata = updateBranchMetadata;
|
2595
3405
|
exports.updateBranchSchema = updateBranchSchema;
|
2596
3406
|
exports.updateColumn = updateColumn;
|
3407
|
+
exports.updateDatabaseMetadata = updateDatabaseMetadata;
|
2597
3408
|
exports.updateMigrationRequest = updateMigrationRequest;
|
2598
3409
|
exports.updateRecordWithID = updateRecordWithID;
|
2599
3410
|
exports.updateTable = updateTable;
|