@xata.io/client 0.29.0 → 0.29.2
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/.turbo/turbo-add-version.log +1 -1
- package/.turbo/turbo-build.log +3 -3
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +343 -299
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +409 -88
- package/dist/index.mjs +337 -297
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -246,7 +246,7 @@ var __accessCheck$8 = (obj, member, msg) => {
|
|
246
246
|
if (!member.has(obj))
|
247
247
|
throw TypeError("Cannot " + msg);
|
248
248
|
};
|
249
|
-
var __privateGet$
|
249
|
+
var __privateGet$7 = (obj, member, getter) => {
|
250
250
|
__accessCheck$8(obj, member, "read from private field");
|
251
251
|
return getter ? getter.call(obj) : member.get(obj);
|
252
252
|
};
|
@@ -255,7 +255,7 @@ var __privateAdd$8 = (obj, member, value) => {
|
|
255
255
|
throw TypeError("Cannot add the same private member more than once");
|
256
256
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
257
257
|
};
|
258
|
-
var __privateSet$
|
258
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
259
259
|
__accessCheck$8(obj, member, "write to private field");
|
260
260
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
261
261
|
return value;
|
@@ -281,19 +281,19 @@ class ApiRequestPool {
|
|
281
281
|
__privateAdd$8(this, _fetch, void 0);
|
282
282
|
__privateAdd$8(this, _queue, void 0);
|
283
283
|
__privateAdd$8(this, _concurrency, void 0);
|
284
|
-
__privateSet$
|
285
|
-
__privateSet$
|
284
|
+
__privateSet$6(this, _queue, []);
|
285
|
+
__privateSet$6(this, _concurrency, concurrency);
|
286
286
|
this.running = 0;
|
287
287
|
this.started = 0;
|
288
288
|
}
|
289
289
|
setFetch(fetch2) {
|
290
|
-
__privateSet$
|
290
|
+
__privateSet$6(this, _fetch, fetch2);
|
291
291
|
}
|
292
292
|
getFetch() {
|
293
|
-
if (!__privateGet$
|
293
|
+
if (!__privateGet$7(this, _fetch)) {
|
294
294
|
throw new Error("Fetch not set");
|
295
295
|
}
|
296
|
-
return __privateGet$
|
296
|
+
return __privateGet$7(this, _fetch);
|
297
297
|
}
|
298
298
|
request(url, options) {
|
299
299
|
const start = /* @__PURE__ */ new Date();
|
@@ -325,19 +325,19 @@ _queue = new WeakMap();
|
|
325
325
|
_concurrency = new WeakMap();
|
326
326
|
_enqueue = new WeakSet();
|
327
327
|
enqueue_fn = function(task) {
|
328
|
-
const promise = new Promise((resolve) => __privateGet$
|
328
|
+
const promise = new Promise((resolve) => __privateGet$7(this, _queue).push(resolve)).finally(() => {
|
329
329
|
this.started--;
|
330
330
|
this.running++;
|
331
331
|
}).then(() => task()).finally(() => {
|
332
332
|
this.running--;
|
333
|
-
const next = __privateGet$
|
333
|
+
const next = __privateGet$7(this, _queue).shift();
|
334
334
|
if (next !== void 0) {
|
335
335
|
this.started++;
|
336
336
|
next();
|
337
337
|
}
|
338
338
|
});
|
339
|
-
if (this.running + this.started < __privateGet$
|
340
|
-
const next = __privateGet$
|
339
|
+
if (this.running + this.started < __privateGet$7(this, _concurrency)) {
|
340
|
+
const next = __privateGet$7(this, _queue).shift();
|
341
341
|
if (next !== void 0) {
|
342
342
|
this.started++;
|
343
343
|
next();
|
@@ -526,7 +526,7 @@ function defaultOnOpen(response) {
|
|
526
526
|
}
|
527
527
|
}
|
528
528
|
|
529
|
-
const VERSION = "0.29.
|
529
|
+
const VERSION = "0.29.2";
|
530
530
|
|
531
531
|
class ErrorWithCause extends Error {
|
532
532
|
constructor(message, options) {
|
@@ -845,26 +845,29 @@ function parseUrl(url) {
|
|
845
845
|
|
846
846
|
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
847
847
|
|
848
|
-
const applyMigration = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/
|
849
|
-
const
|
850
|
-
url: "/db/{dbBranchName}/
|
851
|
-
method: "
|
848
|
+
const applyMigration = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/apply", method: "post", ...variables, signal });
|
849
|
+
const adaptTable = (variables, signal) => dataPlaneFetch({
|
850
|
+
url: "/db/{dbBranchName}/migrations/adapt/{tableName}",
|
851
|
+
method: "post",
|
852
852
|
...variables,
|
853
853
|
signal
|
854
854
|
});
|
855
|
-
const
|
856
|
-
|
855
|
+
const getBranchMigrationJobStatus = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/status", method: "get", ...variables, signal });
|
856
|
+
const getMigrationJobStatus = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/jobs/{jobId}", method: "get", ...variables, signal });
|
857
|
+
const getMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/history", method: "get", ...variables, signal });
|
858
|
+
const getBranchList = (variables, signal) => dataPlaneFetch({
|
859
|
+
url: "/dbs/{dbName}",
|
857
860
|
method: "get",
|
858
861
|
...variables,
|
859
862
|
signal
|
860
863
|
});
|
861
|
-
const
|
862
|
-
|
863
|
-
url: "/dbs/{dbName}",
|
864
|
+
const getDatabaseSettings = (variables, signal) => dataPlaneFetch({
|
865
|
+
url: "/dbs/{dbName}/settings",
|
864
866
|
method: "get",
|
865
867
|
...variables,
|
866
868
|
signal
|
867
869
|
});
|
870
|
+
const updateDatabaseSettings = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/settings", method: "patch", ...variables, signal });
|
868
871
|
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
869
872
|
url: "/db/{dbBranchName}",
|
870
873
|
method: "get",
|
@@ -1078,11 +1081,25 @@ const sqlQuery = (variables, signal) => dataPlaneFetch({
|
|
1078
1081
|
signal
|
1079
1082
|
});
|
1080
1083
|
const operationsByTag$2 = {
|
1081
|
-
|
1084
|
+
migrations: {
|
1082
1085
|
applyMigration,
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
+
adaptTable,
|
1087
|
+
getBranchMigrationJobStatus,
|
1088
|
+
getMigrationJobStatus,
|
1089
|
+
getMigrationHistory,
|
1090
|
+
getSchema,
|
1091
|
+
getBranchMigrationHistory,
|
1092
|
+
getBranchMigrationPlan,
|
1093
|
+
executeBranchMigrationPlan,
|
1094
|
+
getBranchSchemaHistory,
|
1095
|
+
compareBranchWithUserSchema,
|
1096
|
+
compareBranchSchemas,
|
1097
|
+
updateBranchSchema,
|
1098
|
+
previewBranchSchemaEdit,
|
1099
|
+
applyBranchSchemaEdit,
|
1100
|
+
pushBranchMigrations
|
1101
|
+
},
|
1102
|
+
branch: {
|
1086
1103
|
getBranchList,
|
1087
1104
|
getBranchDetails,
|
1088
1105
|
createBranch,
|
@@ -1096,19 +1113,7 @@ const operationsByTag$2 = {
|
|
1096
1113
|
removeGitBranchesEntry,
|
1097
1114
|
resolveBranch
|
1098
1115
|
},
|
1099
|
-
|
1100
|
-
getSchema,
|
1101
|
-
getBranchMigrationHistory,
|
1102
|
-
getBranchMigrationPlan,
|
1103
|
-
executeBranchMigrationPlan,
|
1104
|
-
getBranchSchemaHistory,
|
1105
|
-
compareBranchWithUserSchema,
|
1106
|
-
compareBranchSchemas,
|
1107
|
-
updateBranchSchema,
|
1108
|
-
previewBranchSchemaEdit,
|
1109
|
-
applyBranchSchemaEdit,
|
1110
|
-
pushBranchMigrations
|
1111
|
-
},
|
1116
|
+
database: { getDatabaseSettings, updateDatabaseSettings },
|
1112
1117
|
migrationRequests: {
|
1113
1118
|
queryMigrationRequests,
|
1114
1119
|
createMigrationRequest,
|
@@ -1347,7 +1352,7 @@ var __accessCheck$7 = (obj, member, msg) => {
|
|
1347
1352
|
if (!member.has(obj))
|
1348
1353
|
throw TypeError("Cannot " + msg);
|
1349
1354
|
};
|
1350
|
-
var __privateGet$
|
1355
|
+
var __privateGet$6 = (obj, member, getter) => {
|
1351
1356
|
__accessCheck$7(obj, member, "read from private field");
|
1352
1357
|
return getter ? getter.call(obj) : member.get(obj);
|
1353
1358
|
};
|
@@ -1356,7 +1361,7 @@ var __privateAdd$7 = (obj, member, value) => {
|
|
1356
1361
|
throw TypeError("Cannot add the same private member more than once");
|
1357
1362
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1358
1363
|
};
|
1359
|
-
var __privateSet$
|
1364
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
1360
1365
|
__accessCheck$7(obj, member, "write to private field");
|
1361
1366
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1362
1367
|
return value;
|
@@ -1373,7 +1378,7 @@ class XataApiClient {
|
|
1373
1378
|
if (!apiKey) {
|
1374
1379
|
throw new Error("Could not resolve a valid apiKey");
|
1375
1380
|
}
|
1376
|
-
__privateSet$
|
1381
|
+
__privateSet$5(this, _extraProps, {
|
1377
1382
|
apiUrl: getHostUrl(provider, "main"),
|
1378
1383
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
1379
1384
|
fetch: getFetchImplementation(options.fetch),
|
@@ -1385,64 +1390,64 @@ class XataApiClient {
|
|
1385
1390
|
});
|
1386
1391
|
}
|
1387
1392
|
get user() {
|
1388
|
-
if (!__privateGet$
|
1389
|
-
__privateGet$
|
1390
|
-
return __privateGet$
|
1393
|
+
if (!__privateGet$6(this, _namespaces).user)
|
1394
|
+
__privateGet$6(this, _namespaces).user = new UserApi(__privateGet$6(this, _extraProps));
|
1395
|
+
return __privateGet$6(this, _namespaces).user;
|
1391
1396
|
}
|
1392
1397
|
get authentication() {
|
1393
|
-
if (!__privateGet$
|
1394
|
-
__privateGet$
|
1395
|
-
return __privateGet$
|
1398
|
+
if (!__privateGet$6(this, _namespaces).authentication)
|
1399
|
+
__privateGet$6(this, _namespaces).authentication = new AuthenticationApi(__privateGet$6(this, _extraProps));
|
1400
|
+
return __privateGet$6(this, _namespaces).authentication;
|
1396
1401
|
}
|
1397
1402
|
get workspaces() {
|
1398
|
-
if (!__privateGet$
|
1399
|
-
__privateGet$
|
1400
|
-
return __privateGet$
|
1403
|
+
if (!__privateGet$6(this, _namespaces).workspaces)
|
1404
|
+
__privateGet$6(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$6(this, _extraProps));
|
1405
|
+
return __privateGet$6(this, _namespaces).workspaces;
|
1401
1406
|
}
|
1402
1407
|
get invites() {
|
1403
|
-
if (!__privateGet$
|
1404
|
-
__privateGet$
|
1405
|
-
return __privateGet$
|
1408
|
+
if (!__privateGet$6(this, _namespaces).invites)
|
1409
|
+
__privateGet$6(this, _namespaces).invites = new InvitesApi(__privateGet$6(this, _extraProps));
|
1410
|
+
return __privateGet$6(this, _namespaces).invites;
|
1406
1411
|
}
|
1407
1412
|
get database() {
|
1408
|
-
if (!__privateGet$
|
1409
|
-
__privateGet$
|
1410
|
-
return __privateGet$
|
1413
|
+
if (!__privateGet$6(this, _namespaces).database)
|
1414
|
+
__privateGet$6(this, _namespaces).database = new DatabaseApi(__privateGet$6(this, _extraProps));
|
1415
|
+
return __privateGet$6(this, _namespaces).database;
|
1411
1416
|
}
|
1412
1417
|
get branches() {
|
1413
|
-
if (!__privateGet$
|
1414
|
-
__privateGet$
|
1415
|
-
return __privateGet$
|
1418
|
+
if (!__privateGet$6(this, _namespaces).branches)
|
1419
|
+
__privateGet$6(this, _namespaces).branches = new BranchApi(__privateGet$6(this, _extraProps));
|
1420
|
+
return __privateGet$6(this, _namespaces).branches;
|
1416
1421
|
}
|
1417
1422
|
get migrations() {
|
1418
|
-
if (!__privateGet$
|
1419
|
-
__privateGet$
|
1420
|
-
return __privateGet$
|
1423
|
+
if (!__privateGet$6(this, _namespaces).migrations)
|
1424
|
+
__privateGet$6(this, _namespaces).migrations = new MigrationsApi(__privateGet$6(this, _extraProps));
|
1425
|
+
return __privateGet$6(this, _namespaces).migrations;
|
1421
1426
|
}
|
1422
1427
|
get migrationRequests() {
|
1423
|
-
if (!__privateGet$
|
1424
|
-
__privateGet$
|
1425
|
-
return __privateGet$
|
1428
|
+
if (!__privateGet$6(this, _namespaces).migrationRequests)
|
1429
|
+
__privateGet$6(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$6(this, _extraProps));
|
1430
|
+
return __privateGet$6(this, _namespaces).migrationRequests;
|
1426
1431
|
}
|
1427
1432
|
get tables() {
|
1428
|
-
if (!__privateGet$
|
1429
|
-
__privateGet$
|
1430
|
-
return __privateGet$
|
1433
|
+
if (!__privateGet$6(this, _namespaces).tables)
|
1434
|
+
__privateGet$6(this, _namespaces).tables = new TableApi(__privateGet$6(this, _extraProps));
|
1435
|
+
return __privateGet$6(this, _namespaces).tables;
|
1431
1436
|
}
|
1432
1437
|
get records() {
|
1433
|
-
if (!__privateGet$
|
1434
|
-
__privateGet$
|
1435
|
-
return __privateGet$
|
1438
|
+
if (!__privateGet$6(this, _namespaces).records)
|
1439
|
+
__privateGet$6(this, _namespaces).records = new RecordsApi(__privateGet$6(this, _extraProps));
|
1440
|
+
return __privateGet$6(this, _namespaces).records;
|
1436
1441
|
}
|
1437
1442
|
get files() {
|
1438
|
-
if (!__privateGet$
|
1439
|
-
__privateGet$
|
1440
|
-
return __privateGet$
|
1443
|
+
if (!__privateGet$6(this, _namespaces).files)
|
1444
|
+
__privateGet$6(this, _namespaces).files = new FilesApi(__privateGet$6(this, _extraProps));
|
1445
|
+
return __privateGet$6(this, _namespaces).files;
|
1441
1446
|
}
|
1442
1447
|
get searchAndFilter() {
|
1443
|
-
if (!__privateGet$
|
1444
|
-
__privateGet$
|
1445
|
-
return __privateGet$
|
1448
|
+
if (!__privateGet$6(this, _namespaces).searchAndFilter)
|
1449
|
+
__privateGet$6(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$6(this, _extraProps));
|
1450
|
+
return __privateGet$6(this, _namespaces).searchAndFilter;
|
1446
1451
|
}
|
1447
1452
|
}
|
1448
1453
|
_extraProps = new WeakMap();
|
@@ -1744,6 +1749,30 @@ class BranchApi {
|
|
1744
1749
|
...this.extraProps
|
1745
1750
|
});
|
1746
1751
|
}
|
1752
|
+
pgRollMigrationHistory({
|
1753
|
+
workspace,
|
1754
|
+
region,
|
1755
|
+
database,
|
1756
|
+
branch
|
1757
|
+
}) {
|
1758
|
+
return operationsByTag.migrations.getMigrationHistory({
|
1759
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1760
|
+
...this.extraProps
|
1761
|
+
});
|
1762
|
+
}
|
1763
|
+
applyMigration({
|
1764
|
+
workspace,
|
1765
|
+
region,
|
1766
|
+
database,
|
1767
|
+
branch,
|
1768
|
+
migration
|
1769
|
+
}) {
|
1770
|
+
return operationsByTag.migrations.applyMigration({
|
1771
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1772
|
+
body: migration,
|
1773
|
+
...this.extraProps
|
1774
|
+
});
|
1775
|
+
}
|
1747
1776
|
}
|
1748
1777
|
class TableApi {
|
1749
1778
|
constructor(extraProps) {
|
@@ -2557,6 +2586,17 @@ class MigrationsApi {
|
|
2557
2586
|
...this.extraProps
|
2558
2587
|
});
|
2559
2588
|
}
|
2589
|
+
getSchema({
|
2590
|
+
workspace,
|
2591
|
+
region,
|
2592
|
+
database,
|
2593
|
+
branch
|
2594
|
+
}) {
|
2595
|
+
return operationsByTag.migrations.getSchema({
|
2596
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2597
|
+
...this.extraProps
|
2598
|
+
});
|
2599
|
+
}
|
2560
2600
|
}
|
2561
2601
|
class DatabaseApi {
|
2562
2602
|
constructor(extraProps) {
|
@@ -2862,7 +2902,7 @@ var __accessCheck$6 = (obj, member, msg) => {
|
|
2862
2902
|
if (!member.has(obj))
|
2863
2903
|
throw TypeError("Cannot " + msg);
|
2864
2904
|
};
|
2865
|
-
var __privateGet$
|
2905
|
+
var __privateGet$5 = (obj, member, getter) => {
|
2866
2906
|
__accessCheck$6(obj, member, "read from private field");
|
2867
2907
|
return getter ? getter.call(obj) : member.get(obj);
|
2868
2908
|
};
|
@@ -2871,7 +2911,7 @@ var __privateAdd$6 = (obj, member, value) => {
|
|
2871
2911
|
throw TypeError("Cannot add the same private member more than once");
|
2872
2912
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
2873
2913
|
};
|
2874
|
-
var __privateSet$
|
2914
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
2875
2915
|
__accessCheck$6(obj, member, "write to private field");
|
2876
2916
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
2877
2917
|
return value;
|
@@ -2880,9 +2920,9 @@ var _query, _page;
|
|
2880
2920
|
class Page {
|
2881
2921
|
constructor(query, meta, records = []) {
|
2882
2922
|
__privateAdd$6(this, _query, void 0);
|
2883
|
-
__privateSet$
|
2923
|
+
__privateSet$4(this, _query, query);
|
2884
2924
|
this.meta = meta;
|
2885
|
-
this.records = new
|
2925
|
+
this.records = new PageRecordArray(this, records);
|
2886
2926
|
}
|
2887
2927
|
/**
|
2888
2928
|
* Retrieves the next page of results.
|
@@ -2891,7 +2931,7 @@ class Page {
|
|
2891
2931
|
* @returns The next page or results.
|
2892
2932
|
*/
|
2893
2933
|
async nextPage(size, offset) {
|
2894
|
-
return __privateGet$
|
2934
|
+
return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
2895
2935
|
}
|
2896
2936
|
/**
|
2897
2937
|
* Retrieves the previous page of results.
|
@@ -2900,7 +2940,7 @@ class Page {
|
|
2900
2940
|
* @returns The previous page or results.
|
2901
2941
|
*/
|
2902
2942
|
async previousPage(size, offset) {
|
2903
|
-
return __privateGet$
|
2943
|
+
return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
2904
2944
|
}
|
2905
2945
|
/**
|
2906
2946
|
* Retrieves the start page of results.
|
@@ -2909,7 +2949,7 @@ class Page {
|
|
2909
2949
|
* @returns The start page or results.
|
2910
2950
|
*/
|
2911
2951
|
async startPage(size, offset) {
|
2912
|
-
return __privateGet$
|
2952
|
+
return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
2913
2953
|
}
|
2914
2954
|
/**
|
2915
2955
|
* Retrieves the end page of results.
|
@@ -2918,7 +2958,7 @@ class Page {
|
|
2918
2958
|
* @returns The end page or results.
|
2919
2959
|
*/
|
2920
2960
|
async endPage(size, offset) {
|
2921
|
-
return __privateGet$
|
2961
|
+
return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
2922
2962
|
}
|
2923
2963
|
/**
|
2924
2964
|
* Shortcut method to check if there will be additional results if the next page of results is retrieved.
|
@@ -2936,11 +2976,38 @@ const PAGINATION_DEFAULT_OFFSET = 0;
|
|
2936
2976
|
function isCursorPaginationOptions(options) {
|
2937
2977
|
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
2938
2978
|
}
|
2939
|
-
|
2979
|
+
class RecordArray extends Array {
|
2940
2980
|
constructor(...args) {
|
2941
|
-
super(...
|
2981
|
+
super(...RecordArray.parseConstructorParams(...args));
|
2982
|
+
}
|
2983
|
+
static parseConstructorParams(...args) {
|
2984
|
+
if (args.length === 1 && typeof args[0] === "number") {
|
2985
|
+
return new Array(args[0]);
|
2986
|
+
}
|
2987
|
+
if (args.length <= 1 && Array.isArray(args[0] ?? [])) {
|
2988
|
+
const result = args[0] ?? [];
|
2989
|
+
return new Array(...result);
|
2990
|
+
}
|
2991
|
+
return new Array(...args);
|
2992
|
+
}
|
2993
|
+
toArray() {
|
2994
|
+
return new Array(...this);
|
2995
|
+
}
|
2996
|
+
toSerializable() {
|
2997
|
+
return JSON.parse(this.toString());
|
2998
|
+
}
|
2999
|
+
toString() {
|
3000
|
+
return JSON.stringify(this.toArray());
|
3001
|
+
}
|
3002
|
+
map(callbackfn, thisArg) {
|
3003
|
+
return this.toArray().map(callbackfn, thisArg);
|
3004
|
+
}
|
3005
|
+
}
|
3006
|
+
const _PageRecordArray = class _PageRecordArray extends Array {
|
3007
|
+
constructor(...args) {
|
3008
|
+
super(..._PageRecordArray.parseConstructorParams(...args));
|
2942
3009
|
__privateAdd$6(this, _page, void 0);
|
2943
|
-
__privateSet$
|
3010
|
+
__privateSet$4(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
|
2944
3011
|
}
|
2945
3012
|
static parseConstructorParams(...args) {
|
2946
3013
|
if (args.length === 1 && typeof args[0] === "number") {
|
@@ -2970,8 +3037,8 @@ const _RecordArray = class _RecordArray extends Array {
|
|
2970
3037
|
* @returns A new array of objects
|
2971
3038
|
*/
|
2972
3039
|
async nextPage(size, offset) {
|
2973
|
-
const newPage = await __privateGet$
|
2974
|
-
return new
|
3040
|
+
const newPage = await __privateGet$5(this, _page).nextPage(size, offset);
|
3041
|
+
return new _PageRecordArray(newPage);
|
2975
3042
|
}
|
2976
3043
|
/**
|
2977
3044
|
* Retrieve previous page of records
|
@@ -2979,8 +3046,8 @@ const _RecordArray = class _RecordArray extends Array {
|
|
2979
3046
|
* @returns A new array of objects
|
2980
3047
|
*/
|
2981
3048
|
async previousPage(size, offset) {
|
2982
|
-
const newPage = await __privateGet$
|
2983
|
-
return new
|
3049
|
+
const newPage = await __privateGet$5(this, _page).previousPage(size, offset);
|
3050
|
+
return new _PageRecordArray(newPage);
|
2984
3051
|
}
|
2985
3052
|
/**
|
2986
3053
|
* Retrieve start page of records
|
@@ -2988,8 +3055,8 @@ const _RecordArray = class _RecordArray extends Array {
|
|
2988
3055
|
* @returns A new array of objects
|
2989
3056
|
*/
|
2990
3057
|
async startPage(size, offset) {
|
2991
|
-
const newPage = await __privateGet$
|
2992
|
-
return new
|
3058
|
+
const newPage = await __privateGet$5(this, _page).startPage(size, offset);
|
3059
|
+
return new _PageRecordArray(newPage);
|
2993
3060
|
}
|
2994
3061
|
/**
|
2995
3062
|
* Retrieve end page of records
|
@@ -2997,24 +3064,24 @@ const _RecordArray = class _RecordArray extends Array {
|
|
2997
3064
|
* @returns A new array of objects
|
2998
3065
|
*/
|
2999
3066
|
async endPage(size, offset) {
|
3000
|
-
const newPage = await __privateGet$
|
3001
|
-
return new
|
3067
|
+
const newPage = await __privateGet$5(this, _page).endPage(size, offset);
|
3068
|
+
return new _PageRecordArray(newPage);
|
3002
3069
|
}
|
3003
3070
|
/**
|
3004
3071
|
* @returns Boolean indicating if there is a next page
|
3005
3072
|
*/
|
3006
3073
|
hasNextPage() {
|
3007
|
-
return __privateGet$
|
3074
|
+
return __privateGet$5(this, _page).meta.page.more;
|
3008
3075
|
}
|
3009
3076
|
};
|
3010
3077
|
_page = new WeakMap();
|
3011
|
-
let
|
3078
|
+
let PageRecordArray = _PageRecordArray;
|
3012
3079
|
|
3013
3080
|
var __accessCheck$5 = (obj, member, msg) => {
|
3014
3081
|
if (!member.has(obj))
|
3015
3082
|
throw TypeError("Cannot " + msg);
|
3016
3083
|
};
|
3017
|
-
var __privateGet$
|
3084
|
+
var __privateGet$4 = (obj, member, getter) => {
|
3018
3085
|
__accessCheck$5(obj, member, "read from private field");
|
3019
3086
|
return getter ? getter.call(obj) : member.get(obj);
|
3020
3087
|
};
|
@@ -3023,7 +3090,7 @@ var __privateAdd$5 = (obj, member, value) => {
|
|
3023
3090
|
throw TypeError("Cannot add the same private member more than once");
|
3024
3091
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
3025
3092
|
};
|
3026
|
-
var __privateSet$
|
3093
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
3027
3094
|
__accessCheck$5(obj, member, "write to private field");
|
3028
3095
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
3029
3096
|
return value;
|
@@ -3041,25 +3108,25 @@ const _Query = class _Query {
|
|
3041
3108
|
__privateAdd$5(this, _data, { filter: {} });
|
3042
3109
|
// Implements pagination
|
3043
3110
|
this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
|
3044
|
-
this.records = new
|
3045
|
-
__privateSet$
|
3111
|
+
this.records = new PageRecordArray(this, []);
|
3112
|
+
__privateSet$3(this, _table$1, table);
|
3046
3113
|
if (repository) {
|
3047
|
-
__privateSet$
|
3114
|
+
__privateSet$3(this, _repository, repository);
|
3048
3115
|
} else {
|
3049
|
-
__privateSet$
|
3116
|
+
__privateSet$3(this, _repository, this);
|
3050
3117
|
}
|
3051
3118
|
const parent = cleanParent(data, rawParent);
|
3052
|
-
__privateGet$
|
3053
|
-
__privateGet$
|
3054
|
-
__privateGet$
|
3055
|
-
__privateGet$
|
3056
|
-
__privateGet$
|
3057
|
-
__privateGet$
|
3058
|
-
__privateGet$
|
3059
|
-
__privateGet$
|
3060
|
-
__privateGet$
|
3061
|
-
__privateGet$
|
3062
|
-
__privateGet$
|
3119
|
+
__privateGet$4(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
3120
|
+
__privateGet$4(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
|
3121
|
+
__privateGet$4(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
|
3122
|
+
__privateGet$4(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
3123
|
+
__privateGet$4(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
3124
|
+
__privateGet$4(this, _data).sort = data.sort ?? parent?.sort;
|
3125
|
+
__privateGet$4(this, _data).columns = data.columns ?? parent?.columns;
|
3126
|
+
__privateGet$4(this, _data).consistency = data.consistency ?? parent?.consistency;
|
3127
|
+
__privateGet$4(this, _data).pagination = data.pagination ?? parent?.pagination;
|
3128
|
+
__privateGet$4(this, _data).cache = data.cache ?? parent?.cache;
|
3129
|
+
__privateGet$4(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
|
3063
3130
|
this.any = this.any.bind(this);
|
3064
3131
|
this.all = this.all.bind(this);
|
3065
3132
|
this.not = this.not.bind(this);
|
@@ -3070,10 +3137,10 @@ const _Query = class _Query {
|
|
3070
3137
|
Object.defineProperty(this, "repository", { enumerable: false });
|
3071
3138
|
}
|
3072
3139
|
getQueryOptions() {
|
3073
|
-
return __privateGet$
|
3140
|
+
return __privateGet$4(this, _data);
|
3074
3141
|
}
|
3075
3142
|
key() {
|
3076
|
-
const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$
|
3143
|
+
const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$4(this, _data);
|
3077
3144
|
const key = JSON.stringify({ columns, filter, sort, pagination });
|
3078
3145
|
return toBase64(key);
|
3079
3146
|
}
|
@@ -3084,7 +3151,7 @@ const _Query = class _Query {
|
|
3084
3151
|
*/
|
3085
3152
|
any(...queries) {
|
3086
3153
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
3087
|
-
return new _Query(__privateGet$
|
3154
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $any } }, __privateGet$4(this, _data));
|
3088
3155
|
}
|
3089
3156
|
/**
|
3090
3157
|
* Builds a new query object representing a logical AND between the given subqueries.
|
@@ -3093,7 +3160,7 @@ const _Query = class _Query {
|
|
3093
3160
|
*/
|
3094
3161
|
all(...queries) {
|
3095
3162
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
3096
|
-
return new _Query(__privateGet$
|
3163
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
|
3097
3164
|
}
|
3098
3165
|
/**
|
3099
3166
|
* Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
|
@@ -3102,7 +3169,7 @@ const _Query = class _Query {
|
|
3102
3169
|
*/
|
3103
3170
|
not(...queries) {
|
3104
3171
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
3105
|
-
return new _Query(__privateGet$
|
3172
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $not } }, __privateGet$4(this, _data));
|
3106
3173
|
}
|
3107
3174
|
/**
|
3108
3175
|
* Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
|
@@ -3111,25 +3178,25 @@ const _Query = class _Query {
|
|
3111
3178
|
*/
|
3112
3179
|
none(...queries) {
|
3113
3180
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
3114
|
-
return new _Query(__privateGet$
|
3181
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $none } }, __privateGet$4(this, _data));
|
3115
3182
|
}
|
3116
3183
|
filter(a, b) {
|
3117
3184
|
if (arguments.length === 1) {
|
3118
3185
|
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
3119
3186
|
[column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
|
3120
3187
|
}));
|
3121
|
-
const $all = compact([__privateGet$
|
3122
|
-
return new _Query(__privateGet$
|
3188
|
+
const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
|
3189
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
|
3123
3190
|
} else {
|
3124
3191
|
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
|
3125
|
-
const $all = compact([__privateGet$
|
3126
|
-
return new _Query(__privateGet$
|
3192
|
+
const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
|
3193
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
|
3127
3194
|
}
|
3128
3195
|
}
|
3129
3196
|
sort(column, direction = "asc") {
|
3130
|
-
const originalSort = [__privateGet$
|
3197
|
+
const originalSort = [__privateGet$4(this, _data).sort ?? []].flat();
|
3131
3198
|
const sort = [...originalSort, { column, direction }];
|
3132
|
-
return new _Query(__privateGet$
|
3199
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { sort }, __privateGet$4(this, _data));
|
3133
3200
|
}
|
3134
3201
|
/**
|
3135
3202
|
* Builds a new query specifying the set of columns to be returned in the query response.
|
@@ -3138,15 +3205,15 @@ const _Query = class _Query {
|
|
3138
3205
|
*/
|
3139
3206
|
select(columns) {
|
3140
3207
|
return new _Query(
|
3141
|
-
__privateGet$
|
3142
|
-
__privateGet$
|
3208
|
+
__privateGet$4(this, _repository),
|
3209
|
+
__privateGet$4(this, _table$1),
|
3143
3210
|
{ columns },
|
3144
|
-
__privateGet$
|
3211
|
+
__privateGet$4(this, _data)
|
3145
3212
|
);
|
3146
3213
|
}
|
3147
3214
|
getPaginated(options = {}) {
|
3148
|
-
const query = new _Query(__privateGet$
|
3149
|
-
return __privateGet$
|
3215
|
+
const query = new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), options, __privateGet$4(this, _data));
|
3216
|
+
return __privateGet$4(this, _repository).query(query);
|
3150
3217
|
}
|
3151
3218
|
/**
|
3152
3219
|
* Get results in an iterator
|
@@ -3183,7 +3250,7 @@ const _Query = class _Query {
|
|
3183
3250
|
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
3184
3251
|
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
3185
3252
|
}
|
3186
|
-
const array = new
|
3253
|
+
const array = new PageRecordArray(page, results.slice(0, size));
|
3187
3254
|
return array;
|
3188
3255
|
}
|
3189
3256
|
async getAll(options = {}) {
|
@@ -3192,7 +3259,7 @@ const _Query = class _Query {
|
|
3192
3259
|
for await (const page of this.getIterator({ ...rest, batchSize })) {
|
3193
3260
|
results.push(...page);
|
3194
3261
|
}
|
3195
|
-
return results;
|
3262
|
+
return new RecordArray(results);
|
3196
3263
|
}
|
3197
3264
|
async getFirst(options = {}) {
|
3198
3265
|
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
@@ -3207,12 +3274,12 @@ const _Query = class _Query {
|
|
3207
3274
|
async summarize(params = {}) {
|
3208
3275
|
const { summaries, summariesFilter, ...options } = params;
|
3209
3276
|
const query = new _Query(
|
3210
|
-
__privateGet$
|
3211
|
-
__privateGet$
|
3277
|
+
__privateGet$4(this, _repository),
|
3278
|
+
__privateGet$4(this, _table$1),
|
3212
3279
|
options,
|
3213
|
-
__privateGet$
|
3280
|
+
__privateGet$4(this, _data)
|
3214
3281
|
);
|
3215
|
-
return __privateGet$
|
3282
|
+
return __privateGet$4(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
3216
3283
|
}
|
3217
3284
|
/**
|
3218
3285
|
* Builds a new query object adding a cache TTL in milliseconds.
|
@@ -3220,7 +3287,7 @@ const _Query = class _Query {
|
|
3220
3287
|
* @returns A new Query object.
|
3221
3288
|
*/
|
3222
3289
|
cache(ttl) {
|
3223
|
-
return new _Query(__privateGet$
|
3290
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { cache: ttl }, __privateGet$4(this, _data));
|
3224
3291
|
}
|
3225
3292
|
/**
|
3226
3293
|
* Retrieve next page of records
|
@@ -3266,7 +3333,7 @@ _repository = new WeakMap();
|
|
3266
3333
|
_data = new WeakMap();
|
3267
3334
|
_cleanFilterConstraint = new WeakSet();
|
3268
3335
|
cleanFilterConstraint_fn = function(column, value) {
|
3269
|
-
const columnType = __privateGet$
|
3336
|
+
const columnType = __privateGet$4(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
3270
3337
|
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
3271
3338
|
return { $includes: value };
|
3272
3339
|
}
|
@@ -3356,7 +3423,7 @@ var __accessCheck$4 = (obj, member, msg) => {
|
|
3356
3423
|
if (!member.has(obj))
|
3357
3424
|
throw TypeError("Cannot " + msg);
|
3358
3425
|
};
|
3359
|
-
var __privateGet$
|
3426
|
+
var __privateGet$3 = (obj, member, getter) => {
|
3360
3427
|
__accessCheck$4(obj, member, "read from private field");
|
3361
3428
|
return getter ? getter.call(obj) : member.get(obj);
|
3362
3429
|
};
|
@@ -3365,7 +3432,7 @@ var __privateAdd$4 = (obj, member, value) => {
|
|
3365
3432
|
throw TypeError("Cannot add the same private member more than once");
|
3366
3433
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
3367
3434
|
};
|
3368
|
-
var __privateSet$
|
3435
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
3369
3436
|
__accessCheck$4(obj, member, "write to private field");
|
3370
3437
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
3371
3438
|
return value;
|
@@ -3374,7 +3441,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
3374
3441
|
__accessCheck$4(obj, member, "access private method");
|
3375
3442
|
return method;
|
3376
3443
|
};
|
3377
|
-
var _table, _getFetchProps, _db, _cache, _schemaTables
|
3444
|
+
var _table, _getFetchProps, _db, _cache, _schemaTables, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _insertRecords, insertRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _updateRecords, updateRecords_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _deleteRecords, deleteRecords_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables, getSchemaTables_fn, _transformObjectToApi, transformObjectToApi_fn;
|
3378
3445
|
const BULK_OPERATION_MAX_SIZE = 1e3;
|
3379
3446
|
class Repository extends Query {
|
3380
3447
|
}
|
@@ -3395,31 +3462,31 @@ class RestRepository extends Query {
|
|
3395
3462
|
__privateAdd$4(this, _deleteRecords);
|
3396
3463
|
__privateAdd$4(this, _setCacheQuery);
|
3397
3464
|
__privateAdd$4(this, _getCacheQuery);
|
3398
|
-
__privateAdd$4(this, _getSchemaTables
|
3465
|
+
__privateAdd$4(this, _getSchemaTables);
|
3399
3466
|
__privateAdd$4(this, _transformObjectToApi);
|
3400
3467
|
__privateAdd$4(this, _table, void 0);
|
3401
3468
|
__privateAdd$4(this, _getFetchProps, void 0);
|
3402
3469
|
__privateAdd$4(this, _db, void 0);
|
3403
3470
|
__privateAdd$4(this, _cache, void 0);
|
3404
|
-
__privateAdd$4(this, _schemaTables
|
3471
|
+
__privateAdd$4(this, _schemaTables, void 0);
|
3405
3472
|
__privateAdd$4(this, _trace, void 0);
|
3406
|
-
__privateSet$
|
3407
|
-
__privateSet$
|
3408
|
-
__privateSet$
|
3409
|
-
__privateSet$
|
3410
|
-
__privateSet$
|
3473
|
+
__privateSet$2(this, _table, options.table);
|
3474
|
+
__privateSet$2(this, _db, options.db);
|
3475
|
+
__privateSet$2(this, _cache, options.pluginOptions.cache);
|
3476
|
+
__privateSet$2(this, _schemaTables, options.schemaTables);
|
3477
|
+
__privateSet$2(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
|
3411
3478
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
3412
|
-
__privateSet$
|
3479
|
+
__privateSet$2(this, _trace, async (name, fn, options2 = {}) => {
|
3413
3480
|
return trace(name, fn, {
|
3414
3481
|
...options2,
|
3415
|
-
[TraceAttributes.TABLE]: __privateGet$
|
3482
|
+
[TraceAttributes.TABLE]: __privateGet$3(this, _table),
|
3416
3483
|
[TraceAttributes.KIND]: "sdk-operation",
|
3417
3484
|
[TraceAttributes.VERSION]: VERSION
|
3418
3485
|
});
|
3419
3486
|
});
|
3420
3487
|
}
|
3421
3488
|
async create(a, b, c, d) {
|
3422
|
-
return __privateGet$
|
3489
|
+
return __privateGet$3(this, _trace).call(this, "create", async () => {
|
3423
3490
|
const ifVersion = parseIfVersion(b, c, d);
|
3424
3491
|
if (Array.isArray(a)) {
|
3425
3492
|
if (a.length === 0)
|
@@ -3449,7 +3516,7 @@ class RestRepository extends Query {
|
|
3449
3516
|
});
|
3450
3517
|
}
|
3451
3518
|
async read(a, b) {
|
3452
|
-
return __privateGet$
|
3519
|
+
return __privateGet$3(this, _trace).call(this, "read", async () => {
|
3453
3520
|
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3454
3521
|
if (Array.isArray(a)) {
|
3455
3522
|
if (a.length === 0)
|
@@ -3470,17 +3537,17 @@ class RestRepository extends Query {
|
|
3470
3537
|
workspace: "{workspaceId}",
|
3471
3538
|
dbBranchName: "{dbBranch}",
|
3472
3539
|
region: "{region}",
|
3473
|
-
tableName: __privateGet$
|
3540
|
+
tableName: __privateGet$3(this, _table),
|
3474
3541
|
recordId: id
|
3475
3542
|
},
|
3476
3543
|
queryParams: { columns },
|
3477
|
-
...__privateGet$
|
3544
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3478
3545
|
});
|
3479
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3546
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3480
3547
|
return initObject(
|
3481
|
-
__privateGet$
|
3548
|
+
__privateGet$3(this, _db),
|
3482
3549
|
schemaTables,
|
3483
|
-
__privateGet$
|
3550
|
+
__privateGet$3(this, _table),
|
3484
3551
|
response,
|
3485
3552
|
columns
|
3486
3553
|
);
|
@@ -3495,7 +3562,7 @@ class RestRepository extends Query {
|
|
3495
3562
|
});
|
3496
3563
|
}
|
3497
3564
|
async readOrThrow(a, b) {
|
3498
|
-
return __privateGet$
|
3565
|
+
return __privateGet$3(this, _trace).call(this, "readOrThrow", async () => {
|
3499
3566
|
const result = await this.read(a, b);
|
3500
3567
|
if (Array.isArray(result)) {
|
3501
3568
|
const missingIds = compact(
|
@@ -3514,7 +3581,7 @@ class RestRepository extends Query {
|
|
3514
3581
|
});
|
3515
3582
|
}
|
3516
3583
|
async update(a, b, c, d) {
|
3517
|
-
return __privateGet$
|
3584
|
+
return __privateGet$3(this, _trace).call(this, "update", async () => {
|
3518
3585
|
const ifVersion = parseIfVersion(b, c, d);
|
3519
3586
|
if (Array.isArray(a)) {
|
3520
3587
|
if (a.length === 0)
|
@@ -3547,7 +3614,7 @@ class RestRepository extends Query {
|
|
3547
3614
|
});
|
3548
3615
|
}
|
3549
3616
|
async updateOrThrow(a, b, c, d) {
|
3550
|
-
return __privateGet$
|
3617
|
+
return __privateGet$3(this, _trace).call(this, "updateOrThrow", async () => {
|
3551
3618
|
const result = await this.update(a, b, c, d);
|
3552
3619
|
if (Array.isArray(result)) {
|
3553
3620
|
const missingIds = compact(
|
@@ -3566,7 +3633,7 @@ class RestRepository extends Query {
|
|
3566
3633
|
});
|
3567
3634
|
}
|
3568
3635
|
async createOrUpdate(a, b, c, d) {
|
3569
|
-
return __privateGet$
|
3636
|
+
return __privateGet$3(this, _trace).call(this, "createOrUpdate", async () => {
|
3570
3637
|
const ifVersion = parseIfVersion(b, c, d);
|
3571
3638
|
if (Array.isArray(a)) {
|
3572
3639
|
if (a.length === 0)
|
@@ -3601,7 +3668,7 @@ class RestRepository extends Query {
|
|
3601
3668
|
});
|
3602
3669
|
}
|
3603
3670
|
async createOrReplace(a, b, c, d) {
|
3604
|
-
return __privateGet$
|
3671
|
+
return __privateGet$3(this, _trace).call(this, "createOrReplace", async () => {
|
3605
3672
|
const ifVersion = parseIfVersion(b, c, d);
|
3606
3673
|
if (Array.isArray(a)) {
|
3607
3674
|
if (a.length === 0)
|
@@ -3633,7 +3700,7 @@ class RestRepository extends Query {
|
|
3633
3700
|
});
|
3634
3701
|
}
|
3635
3702
|
async delete(a, b) {
|
3636
|
-
return __privateGet$
|
3703
|
+
return __privateGet$3(this, _trace).call(this, "delete", async () => {
|
3637
3704
|
if (Array.isArray(a)) {
|
3638
3705
|
if (a.length === 0)
|
3639
3706
|
return [];
|
@@ -3659,7 +3726,7 @@ class RestRepository extends Query {
|
|
3659
3726
|
});
|
3660
3727
|
}
|
3661
3728
|
async deleteOrThrow(a, b) {
|
3662
|
-
return __privateGet$
|
3729
|
+
return __privateGet$3(this, _trace).call(this, "deleteOrThrow", async () => {
|
3663
3730
|
const result = await this.delete(a, b);
|
3664
3731
|
if (Array.isArray(result)) {
|
3665
3732
|
const missingIds = compact(
|
@@ -3677,13 +3744,13 @@ class RestRepository extends Query {
|
|
3677
3744
|
});
|
3678
3745
|
}
|
3679
3746
|
async search(query, options = {}) {
|
3680
|
-
return __privateGet$
|
3747
|
+
return __privateGet$3(this, _trace).call(this, "search", async () => {
|
3681
3748
|
const { records, totalCount } = await searchTable({
|
3682
3749
|
pathParams: {
|
3683
3750
|
workspace: "{workspaceId}",
|
3684
3751
|
dbBranchName: "{dbBranch}",
|
3685
3752
|
region: "{region}",
|
3686
|
-
tableName: __privateGet$
|
3753
|
+
tableName: __privateGet$3(this, _table)
|
3687
3754
|
},
|
3688
3755
|
body: {
|
3689
3756
|
query,
|
@@ -3695,23 +3762,23 @@ class RestRepository extends Query {
|
|
3695
3762
|
page: options.page,
|
3696
3763
|
target: options.target
|
3697
3764
|
},
|
3698
|
-
...__privateGet$
|
3765
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3699
3766
|
});
|
3700
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3767
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3701
3768
|
return {
|
3702
|
-
records: records.map((item) => initObject(__privateGet$
|
3769
|
+
records: records.map((item) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), item, ["*"])),
|
3703
3770
|
totalCount
|
3704
3771
|
};
|
3705
3772
|
});
|
3706
3773
|
}
|
3707
3774
|
async vectorSearch(column, query, options) {
|
3708
|
-
return __privateGet$
|
3775
|
+
return __privateGet$3(this, _trace).call(this, "vectorSearch", async () => {
|
3709
3776
|
const { records, totalCount } = await vectorSearchTable({
|
3710
3777
|
pathParams: {
|
3711
3778
|
workspace: "{workspaceId}",
|
3712
3779
|
dbBranchName: "{dbBranch}",
|
3713
3780
|
region: "{region}",
|
3714
|
-
tableName: __privateGet$
|
3781
|
+
tableName: __privateGet$3(this, _table)
|
3715
3782
|
},
|
3716
3783
|
body: {
|
3717
3784
|
column,
|
@@ -3720,32 +3787,32 @@ class RestRepository extends Query {
|
|
3720
3787
|
size: options?.size,
|
3721
3788
|
filter: options?.filter
|
3722
3789
|
},
|
3723
|
-
...__privateGet$
|
3790
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3724
3791
|
});
|
3725
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3792
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3726
3793
|
return {
|
3727
|
-
records: records.map((item) => initObject(__privateGet$
|
3794
|
+
records: records.map((item) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), item, ["*"])),
|
3728
3795
|
totalCount
|
3729
3796
|
};
|
3730
3797
|
});
|
3731
3798
|
}
|
3732
3799
|
async aggregate(aggs, filter) {
|
3733
|
-
return __privateGet$
|
3800
|
+
return __privateGet$3(this, _trace).call(this, "aggregate", async () => {
|
3734
3801
|
const result = await aggregateTable({
|
3735
3802
|
pathParams: {
|
3736
3803
|
workspace: "{workspaceId}",
|
3737
3804
|
dbBranchName: "{dbBranch}",
|
3738
3805
|
region: "{region}",
|
3739
|
-
tableName: __privateGet$
|
3806
|
+
tableName: __privateGet$3(this, _table)
|
3740
3807
|
},
|
3741
3808
|
body: { aggs, filter },
|
3742
|
-
...__privateGet$
|
3809
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3743
3810
|
});
|
3744
3811
|
return result;
|
3745
3812
|
});
|
3746
3813
|
}
|
3747
3814
|
async query(query) {
|
3748
|
-
return __privateGet$
|
3815
|
+
return __privateGet$3(this, _trace).call(this, "query", async () => {
|
3749
3816
|
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
3750
3817
|
if (cacheQuery)
|
3751
3818
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
@@ -3755,7 +3822,7 @@ class RestRepository extends Query {
|
|
3755
3822
|
workspace: "{workspaceId}",
|
3756
3823
|
dbBranchName: "{dbBranch}",
|
3757
3824
|
region: "{region}",
|
3758
|
-
tableName: __privateGet$
|
3825
|
+
tableName: __privateGet$3(this, _table)
|
3759
3826
|
},
|
3760
3827
|
body: {
|
3761
3828
|
filter: cleanFilter(data.filter),
|
@@ -3765,14 +3832,14 @@ class RestRepository extends Query {
|
|
3765
3832
|
consistency: data.consistency
|
3766
3833
|
},
|
3767
3834
|
fetchOptions: data.fetchOptions,
|
3768
|
-
...__privateGet$
|
3835
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3769
3836
|
});
|
3770
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3837
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3771
3838
|
const records = objects.map(
|
3772
3839
|
(record) => initObject(
|
3773
|
-
__privateGet$
|
3840
|
+
__privateGet$3(this, _db),
|
3774
3841
|
schemaTables,
|
3775
|
-
__privateGet$
|
3842
|
+
__privateGet$3(this, _table),
|
3776
3843
|
record,
|
3777
3844
|
data.columns ?? ["*"]
|
3778
3845
|
)
|
@@ -3782,14 +3849,14 @@ class RestRepository extends Query {
|
|
3782
3849
|
});
|
3783
3850
|
}
|
3784
3851
|
async summarizeTable(query, summaries, summariesFilter) {
|
3785
|
-
return __privateGet$
|
3852
|
+
return __privateGet$3(this, _trace).call(this, "summarize", async () => {
|
3786
3853
|
const data = query.getQueryOptions();
|
3787
3854
|
const result = await summarizeTable({
|
3788
3855
|
pathParams: {
|
3789
3856
|
workspace: "{workspaceId}",
|
3790
3857
|
dbBranchName: "{dbBranch}",
|
3791
3858
|
region: "{region}",
|
3792
|
-
tableName: __privateGet$
|
3859
|
+
tableName: __privateGet$3(this, _table)
|
3793
3860
|
},
|
3794
3861
|
body: {
|
3795
3862
|
filter: cleanFilter(data.filter),
|
@@ -3800,13 +3867,13 @@ class RestRepository extends Query {
|
|
3800
3867
|
summaries,
|
3801
3868
|
summariesFilter
|
3802
3869
|
},
|
3803
|
-
...__privateGet$
|
3870
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3804
3871
|
});
|
3805
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3872
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3806
3873
|
return {
|
3807
3874
|
...result,
|
3808
3875
|
summaries: result.summaries.map(
|
3809
|
-
(summary) => initObject(__privateGet$
|
3876
|
+
(summary) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), summary, data.columns ?? [])
|
3810
3877
|
)
|
3811
3878
|
};
|
3812
3879
|
});
|
@@ -3818,7 +3885,7 @@ class RestRepository extends Query {
|
|
3818
3885
|
workspace: "{workspaceId}",
|
3819
3886
|
dbBranchName: "{dbBranch}",
|
3820
3887
|
region: "{region}",
|
3821
|
-
tableName: __privateGet$
|
3888
|
+
tableName: __privateGet$3(this, _table),
|
3822
3889
|
sessionId: options?.sessionId
|
3823
3890
|
},
|
3824
3891
|
body: {
|
@@ -3828,7 +3895,7 @@ class RestRepository extends Query {
|
|
3828
3895
|
search: options?.searchType === "keyword" ? options?.search : void 0,
|
3829
3896
|
vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
|
3830
3897
|
},
|
3831
|
-
...__privateGet$
|
3898
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3832
3899
|
};
|
3833
3900
|
if (options?.onMessage) {
|
3834
3901
|
fetchSSERequest({
|
@@ -3849,7 +3916,7 @@ _table = new WeakMap();
|
|
3849
3916
|
_getFetchProps = new WeakMap();
|
3850
3917
|
_db = new WeakMap();
|
3851
3918
|
_cache = new WeakMap();
|
3852
|
-
_schemaTables
|
3919
|
+
_schemaTables = new WeakMap();
|
3853
3920
|
_trace = new WeakMap();
|
3854
3921
|
_insertRecordWithoutId = new WeakSet();
|
3855
3922
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
@@ -3859,14 +3926,14 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
3859
3926
|
workspace: "{workspaceId}",
|
3860
3927
|
dbBranchName: "{dbBranch}",
|
3861
3928
|
region: "{region}",
|
3862
|
-
tableName: __privateGet$
|
3929
|
+
tableName: __privateGet$3(this, _table)
|
3863
3930
|
},
|
3864
3931
|
queryParams: { columns },
|
3865
3932
|
body: record,
|
3866
|
-
...__privateGet$
|
3933
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3867
3934
|
});
|
3868
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3869
|
-
return initObject(__privateGet$
|
3935
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3936
|
+
return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
|
3870
3937
|
};
|
3871
3938
|
_insertRecordWithId = new WeakSet();
|
3872
3939
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
@@ -3878,21 +3945,21 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
|
|
3878
3945
|
workspace: "{workspaceId}",
|
3879
3946
|
dbBranchName: "{dbBranch}",
|
3880
3947
|
region: "{region}",
|
3881
|
-
tableName: __privateGet$
|
3948
|
+
tableName: __privateGet$3(this, _table),
|
3882
3949
|
recordId
|
3883
3950
|
},
|
3884
3951
|
body: record,
|
3885
3952
|
queryParams: { createOnly, columns, ifVersion },
|
3886
|
-
...__privateGet$
|
3953
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3887
3954
|
});
|
3888
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3889
|
-
return initObject(__privateGet$
|
3955
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3956
|
+
return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
|
3890
3957
|
};
|
3891
3958
|
_insertRecords = new WeakSet();
|
3892
3959
|
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
3893
3960
|
const operations = await promiseMap(objects, async (object) => {
|
3894
3961
|
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3895
|
-
return { insert: { table: __privateGet$
|
3962
|
+
return { insert: { table: __privateGet$3(this, _table), record, createOnly, ifVersion } };
|
3896
3963
|
});
|
3897
3964
|
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
3898
3965
|
const ids = [];
|
@@ -3904,7 +3971,7 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
|
3904
3971
|
region: "{region}"
|
3905
3972
|
},
|
3906
3973
|
body: { operations: operations2 },
|
3907
|
-
...__privateGet$
|
3974
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3908
3975
|
});
|
3909
3976
|
for (const result of results) {
|
3910
3977
|
if (result.operation === "insert") {
|
@@ -3927,15 +3994,15 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
3927
3994
|
workspace: "{workspaceId}",
|
3928
3995
|
dbBranchName: "{dbBranch}",
|
3929
3996
|
region: "{region}",
|
3930
|
-
tableName: __privateGet$
|
3997
|
+
tableName: __privateGet$3(this, _table),
|
3931
3998
|
recordId
|
3932
3999
|
},
|
3933
4000
|
queryParams: { columns, ifVersion },
|
3934
4001
|
body: record,
|
3935
|
-
...__privateGet$
|
4002
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3936
4003
|
});
|
3937
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3938
|
-
return initObject(__privateGet$
|
4004
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
4005
|
+
return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
|
3939
4006
|
} catch (e) {
|
3940
4007
|
if (isObject(e) && e.status === 404) {
|
3941
4008
|
return null;
|
@@ -3947,7 +4014,7 @@ _updateRecords = new WeakSet();
|
|
3947
4014
|
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
3948
4015
|
const operations = await promiseMap(objects, async ({ id, ...object }) => {
|
3949
4016
|
const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3950
|
-
return { update: { table: __privateGet$
|
4017
|
+
return { update: { table: __privateGet$3(this, _table), id, ifVersion, upsert, fields } };
|
3951
4018
|
});
|
3952
4019
|
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
3953
4020
|
const ids = [];
|
@@ -3959,7 +4026,7 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
|
3959
4026
|
region: "{region}"
|
3960
4027
|
},
|
3961
4028
|
body: { operations: operations2 },
|
3962
|
-
...__privateGet$
|
4029
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3963
4030
|
});
|
3964
4031
|
for (const result of results) {
|
3965
4032
|
if (result.operation === "update") {
|
@@ -3980,15 +4047,15 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
3980
4047
|
workspace: "{workspaceId}",
|
3981
4048
|
dbBranchName: "{dbBranch}",
|
3982
4049
|
region: "{region}",
|
3983
|
-
tableName: __privateGet$
|
4050
|
+
tableName: __privateGet$3(this, _table),
|
3984
4051
|
recordId
|
3985
4052
|
},
|
3986
4053
|
queryParams: { columns, ifVersion },
|
3987
4054
|
body: object,
|
3988
|
-
...__privateGet$
|
4055
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3989
4056
|
});
|
3990
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3991
|
-
return initObject(__privateGet$
|
4057
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
4058
|
+
return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
|
3992
4059
|
};
|
3993
4060
|
_deleteRecord = new WeakSet();
|
3994
4061
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
@@ -4000,14 +4067,14 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
4000
4067
|
workspace: "{workspaceId}",
|
4001
4068
|
dbBranchName: "{dbBranch}",
|
4002
4069
|
region: "{region}",
|
4003
|
-
tableName: __privateGet$
|
4070
|
+
tableName: __privateGet$3(this, _table),
|
4004
4071
|
recordId
|
4005
4072
|
},
|
4006
4073
|
queryParams: { columns },
|
4007
|
-
...__privateGet$
|
4074
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
4008
4075
|
});
|
4009
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
4010
|
-
return initObject(__privateGet$
|
4076
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
4077
|
+
return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
|
4011
4078
|
} catch (e) {
|
4012
4079
|
if (isObject(e) && e.status === 404) {
|
4013
4080
|
return null;
|
@@ -4018,7 +4085,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
4018
4085
|
_deleteRecords = new WeakSet();
|
4019
4086
|
deleteRecords_fn = async function(recordIds) {
|
4020
4087
|
const chunkedOperations = chunk(
|
4021
|
-
compact(recordIds).map((id) => ({ delete: { table: __privateGet$
|
4088
|
+
compact(recordIds).map((id) => ({ delete: { table: __privateGet$3(this, _table), id } })),
|
4022
4089
|
BULK_OPERATION_MAX_SIZE
|
4023
4090
|
);
|
4024
4091
|
for (const operations of chunkedOperations) {
|
@@ -4029,44 +4096,44 @@ deleteRecords_fn = async function(recordIds) {
|
|
4029
4096
|
region: "{region}"
|
4030
4097
|
},
|
4031
4098
|
body: { operations },
|
4032
|
-
...__privateGet$
|
4099
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
4033
4100
|
});
|
4034
4101
|
}
|
4035
4102
|
};
|
4036
4103
|
_setCacheQuery = new WeakSet();
|
4037
4104
|
setCacheQuery_fn = async function(query, meta, records) {
|
4038
|
-
await __privateGet$
|
4105
|
+
await __privateGet$3(this, _cache)?.set(`query_${__privateGet$3(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
|
4039
4106
|
};
|
4040
4107
|
_getCacheQuery = new WeakSet();
|
4041
4108
|
getCacheQuery_fn = async function(query) {
|
4042
|
-
const key = `query_${__privateGet$
|
4043
|
-
const result = await __privateGet$
|
4109
|
+
const key = `query_${__privateGet$3(this, _table)}:${query.key()}`;
|
4110
|
+
const result = await __privateGet$3(this, _cache)?.get(key);
|
4044
4111
|
if (!result)
|
4045
4112
|
return null;
|
4046
|
-
const defaultTTL = __privateGet$
|
4113
|
+
const defaultTTL = __privateGet$3(this, _cache)?.defaultQueryTTL ?? -1;
|
4047
4114
|
const { cache: ttl = defaultTTL } = query.getQueryOptions();
|
4048
4115
|
if (ttl < 0)
|
4049
4116
|
return null;
|
4050
4117
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
4051
4118
|
return hasExpired ? null : result;
|
4052
4119
|
};
|
4053
|
-
_getSchemaTables
|
4054
|
-
getSchemaTables_fn
|
4055
|
-
if (__privateGet$
|
4056
|
-
return __privateGet$
|
4120
|
+
_getSchemaTables = new WeakSet();
|
4121
|
+
getSchemaTables_fn = async function() {
|
4122
|
+
if (__privateGet$3(this, _schemaTables))
|
4123
|
+
return __privateGet$3(this, _schemaTables);
|
4057
4124
|
const { schema } = await getBranchDetails({
|
4058
4125
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4059
|
-
...__privateGet$
|
4126
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
4060
4127
|
});
|
4061
|
-
__privateSet$
|
4128
|
+
__privateSet$2(this, _schemaTables, schema.tables);
|
4062
4129
|
return schema.tables;
|
4063
4130
|
};
|
4064
4131
|
_transformObjectToApi = new WeakSet();
|
4065
4132
|
transformObjectToApi_fn = async function(object) {
|
4066
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
4067
|
-
const schema = schemaTables.find((table) => table.name === __privateGet$
|
4133
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
4134
|
+
const schema = schemaTables.find((table) => table.name === __privateGet$3(this, _table));
|
4068
4135
|
if (!schema)
|
4069
|
-
throw new Error(`Table ${__privateGet$
|
4136
|
+
throw new Error(`Table ${__privateGet$3(this, _table)} not found in schema`);
|
4070
4137
|
const result = {};
|
4071
4138
|
for (const [key, value] of Object.entries(object)) {
|
4072
4139
|
if (key === "xata")
|
@@ -4222,7 +4289,7 @@ var __accessCheck$3 = (obj, member, msg) => {
|
|
4222
4289
|
if (!member.has(obj))
|
4223
4290
|
throw TypeError("Cannot " + msg);
|
4224
4291
|
};
|
4225
|
-
var __privateGet$
|
4292
|
+
var __privateGet$2 = (obj, member, getter) => {
|
4226
4293
|
__accessCheck$3(obj, member, "read from private field");
|
4227
4294
|
return getter ? getter.call(obj) : member.get(obj);
|
4228
4295
|
};
|
@@ -4231,7 +4298,7 @@ var __privateAdd$3 = (obj, member, value) => {
|
|
4231
4298
|
throw TypeError("Cannot add the same private member more than once");
|
4232
4299
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
4233
4300
|
};
|
4234
|
-
var __privateSet$
|
4301
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
4235
4302
|
__accessCheck$3(obj, member, "write to private field");
|
4236
4303
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
4237
4304
|
return value;
|
@@ -4240,29 +4307,29 @@ var _map;
|
|
4240
4307
|
class SimpleCache {
|
4241
4308
|
constructor(options = {}) {
|
4242
4309
|
__privateAdd$3(this, _map, void 0);
|
4243
|
-
__privateSet$
|
4310
|
+
__privateSet$1(this, _map, /* @__PURE__ */ new Map());
|
4244
4311
|
this.capacity = options.max ?? 500;
|
4245
4312
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
4246
4313
|
}
|
4247
4314
|
async getAll() {
|
4248
|
-
return Object.fromEntries(__privateGet$
|
4315
|
+
return Object.fromEntries(__privateGet$2(this, _map));
|
4249
4316
|
}
|
4250
4317
|
async get(key) {
|
4251
|
-
return __privateGet$
|
4318
|
+
return __privateGet$2(this, _map).get(key) ?? null;
|
4252
4319
|
}
|
4253
4320
|
async set(key, value) {
|
4254
4321
|
await this.delete(key);
|
4255
|
-
__privateGet$
|
4256
|
-
if (__privateGet$
|
4257
|
-
const leastRecentlyUsed = __privateGet$
|
4322
|
+
__privateGet$2(this, _map).set(key, value);
|
4323
|
+
if (__privateGet$2(this, _map).size > this.capacity) {
|
4324
|
+
const leastRecentlyUsed = __privateGet$2(this, _map).keys().next().value;
|
4258
4325
|
await this.delete(leastRecentlyUsed);
|
4259
4326
|
}
|
4260
4327
|
}
|
4261
4328
|
async delete(key) {
|
4262
|
-
__privateGet$
|
4329
|
+
__privateGet$2(this, _map).delete(key);
|
4263
4330
|
}
|
4264
4331
|
async clear() {
|
4265
|
-
return __privateGet$
|
4332
|
+
return __privateGet$2(this, _map).clear();
|
4266
4333
|
}
|
4267
4334
|
}
|
4268
4335
|
_map = new WeakMap();
|
@@ -4299,7 +4366,7 @@ var __accessCheck$2 = (obj, member, msg) => {
|
|
4299
4366
|
if (!member.has(obj))
|
4300
4367
|
throw TypeError("Cannot " + msg);
|
4301
4368
|
};
|
4302
|
-
var __privateGet$
|
4369
|
+
var __privateGet$1 = (obj, member, getter) => {
|
4303
4370
|
__accessCheck$2(obj, member, "read from private field");
|
4304
4371
|
return getter ? getter.call(obj) : member.get(obj);
|
4305
4372
|
};
|
@@ -4308,18 +4375,11 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
4308
4375
|
throw TypeError("Cannot add the same private member more than once");
|
4309
4376
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
4310
4377
|
};
|
4311
|
-
var
|
4312
|
-
__accessCheck$2(obj, member, "write to private field");
|
4313
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
4314
|
-
return value;
|
4315
|
-
};
|
4316
|
-
var _tables, _schemaTables$1;
|
4378
|
+
var _tables;
|
4317
4379
|
class SchemaPlugin extends XataPlugin {
|
4318
|
-
constructor(
|
4380
|
+
constructor() {
|
4319
4381
|
super();
|
4320
4382
|
__privateAdd$2(this, _tables, {});
|
4321
|
-
__privateAdd$2(this, _schemaTables$1, void 0);
|
4322
|
-
__privateSet$2(this, _schemaTables$1, schemaTables);
|
4323
4383
|
}
|
4324
4384
|
build(pluginOptions) {
|
4325
4385
|
const db = new Proxy(
|
@@ -4328,22 +4388,21 @@ class SchemaPlugin extends XataPlugin {
|
|
4328
4388
|
get: (_target, table) => {
|
4329
4389
|
if (!isString(table))
|
4330
4390
|
throw new Error("Invalid table name");
|
4331
|
-
if (__privateGet$
|
4332
|
-
__privateGet$
|
4391
|
+
if (__privateGet$1(this, _tables)[table] === void 0) {
|
4392
|
+
__privateGet$1(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
|
4333
4393
|
}
|
4334
|
-
return __privateGet$
|
4394
|
+
return __privateGet$1(this, _tables)[table];
|
4335
4395
|
}
|
4336
4396
|
}
|
4337
4397
|
);
|
4338
|
-
const tableNames =
|
4398
|
+
const tableNames = pluginOptions.tables?.map(({ name }) => name) ?? [];
|
4339
4399
|
for (const table of tableNames) {
|
4340
|
-
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables:
|
4400
|
+
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
|
4341
4401
|
}
|
4342
4402
|
return db;
|
4343
4403
|
}
|
4344
4404
|
}
|
4345
4405
|
_tables = new WeakMap();
|
4346
|
-
_schemaTables$1 = new WeakMap();
|
4347
4406
|
|
4348
4407
|
class FilesPlugin extends XataPlugin {
|
4349
4408
|
build(pluginOptions) {
|
@@ -4423,54 +4482,40 @@ var __accessCheck$1 = (obj, member, msg) => {
|
|
4423
4482
|
if (!member.has(obj))
|
4424
4483
|
throw TypeError("Cannot " + msg);
|
4425
4484
|
};
|
4426
|
-
var __privateGet$1 = (obj, member, getter) => {
|
4427
|
-
__accessCheck$1(obj, member, "read from private field");
|
4428
|
-
return getter ? getter.call(obj) : member.get(obj);
|
4429
|
-
};
|
4430
4485
|
var __privateAdd$1 = (obj, member, value) => {
|
4431
4486
|
if (member.has(obj))
|
4432
4487
|
throw TypeError("Cannot add the same private member more than once");
|
4433
4488
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
4434
4489
|
};
|
4435
|
-
var __privateSet$1 = (obj, member, value, setter) => {
|
4436
|
-
__accessCheck$1(obj, member, "write to private field");
|
4437
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
4438
|
-
return value;
|
4439
|
-
};
|
4440
4490
|
var __privateMethod$1 = (obj, member, method) => {
|
4441
4491
|
__accessCheck$1(obj, member, "access private method");
|
4442
4492
|
return method;
|
4443
4493
|
};
|
4444
|
-
var
|
4494
|
+
var _search, search_fn;
|
4445
4495
|
class SearchPlugin extends XataPlugin {
|
4446
|
-
constructor(db
|
4496
|
+
constructor(db) {
|
4447
4497
|
super();
|
4448
4498
|
this.db = db;
|
4449
4499
|
__privateAdd$1(this, _search);
|
4450
|
-
__privateAdd$1(this, _getSchemaTables);
|
4451
|
-
__privateAdd$1(this, _schemaTables, void 0);
|
4452
|
-
__privateSet$1(this, _schemaTables, schemaTables);
|
4453
4500
|
}
|
4454
4501
|
build(pluginOptions) {
|
4455
4502
|
return {
|
4456
4503
|
all: async (query, options = {}) => {
|
4457
4504
|
const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4458
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
4459
4505
|
return {
|
4460
4506
|
totalCount,
|
4461
4507
|
records: records.map((record) => {
|
4462
4508
|
const { table = "orphan" } = record.xata;
|
4463
|
-
return { table, record: initObject(this.db,
|
4509
|
+
return { table, record: initObject(this.db, pluginOptions.tables, table, record, ["*"]) };
|
4464
4510
|
})
|
4465
4511
|
};
|
4466
4512
|
},
|
4467
4513
|
byTable: async (query, options = {}) => {
|
4468
4514
|
const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
|
4469
|
-
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
|
4470
4515
|
const records = rawRecords.reduce((acc, record) => {
|
4471
4516
|
const { table = "orphan" } = record.xata;
|
4472
4517
|
const items = acc[table] ?? [];
|
4473
|
-
const item = initObject(this.db,
|
4518
|
+
const item = initObject(this.db, pluginOptions.tables, table, record, ["*"]);
|
4474
4519
|
return { ...acc, [table]: [...items, item] };
|
4475
4520
|
}, {});
|
4476
4521
|
return { totalCount, records };
|
@@ -4478,29 +4523,17 @@ class SearchPlugin extends XataPlugin {
|
|
4478
4523
|
};
|
4479
4524
|
}
|
4480
4525
|
}
|
4481
|
-
_schemaTables = new WeakMap();
|
4482
4526
|
_search = new WeakSet();
|
4483
4527
|
search_fn = async function(query, options, pluginOptions) {
|
4484
4528
|
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
4485
4529
|
const { records, totalCount } = await searchBranch({
|
4486
4530
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4487
|
-
// @ts-
|
4531
|
+
// @ts-expect-error Filter properties do not match inferred type
|
4488
4532
|
body: { tables, query, fuzziness, prefix, highlight, page },
|
4489
4533
|
...pluginOptions
|
4490
4534
|
});
|
4491
4535
|
return { records, totalCount };
|
4492
4536
|
};
|
4493
|
-
_getSchemaTables = new WeakSet();
|
4494
|
-
getSchemaTables_fn = async function(pluginOptions) {
|
4495
|
-
if (__privateGet$1(this, _schemaTables))
|
4496
|
-
return __privateGet$1(this, _schemaTables);
|
4497
|
-
const { schema } = await getBranchDetails({
|
4498
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4499
|
-
...pluginOptions
|
4500
|
-
});
|
4501
|
-
__privateSet$1(this, _schemaTables, schema.tables);
|
4502
|
-
return schema.tables;
|
4503
|
-
};
|
4504
4537
|
|
4505
4538
|
function escapeElement(elementRepresentation) {
|
4506
4539
|
const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
@@ -4567,12 +4600,17 @@ class SQLPlugin extends XataPlugin {
|
|
4567
4600
|
throw new Error("Invalid usage of `xata.sql`. Please use it as a tagged template or with an object.");
|
4568
4601
|
}
|
4569
4602
|
const { statement, params, consistency } = prepareParams(query, parameters);
|
4570
|
-
const {
|
4603
|
+
const {
|
4604
|
+
records,
|
4605
|
+
rows,
|
4606
|
+
warning,
|
4607
|
+
columns = []
|
4608
|
+
} = await sqlQuery({
|
4571
4609
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4572
4610
|
body: { statement, params, consistency },
|
4573
4611
|
...pluginOptions
|
4574
4612
|
});
|
4575
|
-
return { records, warning, columns };
|
4613
|
+
return { records, rows, warning, columns };
|
4576
4614
|
};
|
4577
4615
|
}
|
4578
4616
|
}
|
@@ -4623,7 +4661,7 @@ var __privateMethod = (obj, member, method) => {
|
|
4623
4661
|
const buildClient = (plugins) => {
|
4624
4662
|
var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
|
4625
4663
|
return _a = class {
|
4626
|
-
constructor(options = {},
|
4664
|
+
constructor(options = {}, tables) {
|
4627
4665
|
__privateAdd(this, _parseOptions);
|
4628
4666
|
__privateAdd(this, _getFetchProps);
|
4629
4667
|
__privateAdd(this, _options, void 0);
|
@@ -4632,13 +4670,15 @@ const buildClient = (plugins) => {
|
|
4632
4670
|
const pluginOptions = {
|
4633
4671
|
...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
4634
4672
|
cache: safeOptions.cache,
|
4635
|
-
host: safeOptions.host
|
4673
|
+
host: safeOptions.host,
|
4674
|
+
tables
|
4636
4675
|
};
|
4637
|
-
const db = new SchemaPlugin(
|
4638
|
-
const search = new SearchPlugin(db
|
4676
|
+
const db = new SchemaPlugin().build(pluginOptions);
|
4677
|
+
const search = new SearchPlugin(db).build(pluginOptions);
|
4639
4678
|
const transactions = new TransactionPlugin().build(pluginOptions);
|
4640
4679
|
const sql = new SQLPlugin().build(pluginOptions);
|
4641
4680
|
const files = new FilesPlugin().build(pluginOptions);
|
4681
|
+
this.schema = { tables };
|
4642
4682
|
this.db = db;
|
4643
4683
|
this.search = search;
|
4644
4684
|
this.transactions = transactions;
|
@@ -4660,7 +4700,7 @@ const buildClient = (plugins) => {
|
|
4660
4700
|
const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
|
4661
4701
|
if (isBrowser && !enableBrowser) {
|
4662
4702
|
throw new Error(
|
4663
|
-
"You are trying to use Xata from the browser, which is potentially a non-secure environment.
|
4703
|
+
"You are trying to use Xata from the browser, which is potentially a non-secure environment. How to fix: https://xata.io/docs/messages/api-key-browser-error"
|
4664
4704
|
);
|
4665
4705
|
}
|
4666
4706
|
const fetch = getFetchImplementation(options?.fetch);
|
@@ -4814,5 +4854,5 @@ class XataError extends Error {
|
|
4814
4854
|
}
|
4815
4855
|
}
|
4816
4856
|
|
4817
|
-
export { BaseClient, FetcherError, FilesPlugin, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SQLPlugin, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, TransactionPlugin, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, applyMigration, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createCluster, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteOAuthAccessToken, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteUserOAuthClient, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, fileUpload, ge, getAPIKey, getAuthorizationCode, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getCluster, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getSchema, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getUserOAuthAccessTokens, getUserOAuthClients, getWorkspace, getWorkspaceMembersList, getWorkspacesList, grantAuthorizationCode, greaterEquals, greaterThan, greaterThanEquals, gt, gte, iContains, iPattern, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isValidExpandedColumn, isValidSelectableColumns, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listClusters, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern,
|
4857
|
+
export { BaseClient, FetcherError, FilesPlugin, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, PageRecordArray, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SQLPlugin, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, TransactionPlugin, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, adaptTable, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, applyMigration, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createCluster, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteOAuthAccessToken, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteUserOAuthClient, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, fileUpload, ge, getAPIKey, getAuthorizationCode, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationJobStatus, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getCluster, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseSettings, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationHistory, getMigrationJobStatus, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getSchema, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getUserOAuthAccessTokens, getUserOAuthClients, getWorkspace, getWorkspaceMembersList, getWorkspacesList, grantAuthorizationCode, greaterEquals, greaterThan, greaterThanEquals, gt, gte, iContains, iPattern, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isValidExpandedColumn, isValidSelectableColumns, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listClusters, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, transformImage, updateBranchMetadata, updateBranchSchema, updateCluster, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateDatabaseSettings, updateMigrationRequest, updateOAuthAccessToken, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
|
4818
4858
|
//# sourceMappingURL=index.mjs.map
|