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