@xata.io/client 0.29.0 → 0.29.1
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 +4 -4
- package/CHANGELOG.md +12 -0
- package/dist/index.cjs +298 -267
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +136 -24
- package/dist/index.mjs +298 -268
- 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.1";
|
530
530
|
|
531
531
|
class ErrorWithCause extends Error {
|
532
532
|
constructor(message, options) {
|
@@ -1347,7 +1347,7 @@ var __accessCheck$7 = (obj, member, msg) => {
|
|
1347
1347
|
if (!member.has(obj))
|
1348
1348
|
throw TypeError("Cannot " + msg);
|
1349
1349
|
};
|
1350
|
-
var __privateGet$
|
1350
|
+
var __privateGet$6 = (obj, member, getter) => {
|
1351
1351
|
__accessCheck$7(obj, member, "read from private field");
|
1352
1352
|
return getter ? getter.call(obj) : member.get(obj);
|
1353
1353
|
};
|
@@ -1356,7 +1356,7 @@ var __privateAdd$7 = (obj, member, value) => {
|
|
1356
1356
|
throw TypeError("Cannot add the same private member more than once");
|
1357
1357
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1358
1358
|
};
|
1359
|
-
var __privateSet$
|
1359
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
1360
1360
|
__accessCheck$7(obj, member, "write to private field");
|
1361
1361
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1362
1362
|
return value;
|
@@ -1373,7 +1373,7 @@ class XataApiClient {
|
|
1373
1373
|
if (!apiKey) {
|
1374
1374
|
throw new Error("Could not resolve a valid apiKey");
|
1375
1375
|
}
|
1376
|
-
__privateSet$
|
1376
|
+
__privateSet$5(this, _extraProps, {
|
1377
1377
|
apiUrl: getHostUrl(provider, "main"),
|
1378
1378
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
1379
1379
|
fetch: getFetchImplementation(options.fetch),
|
@@ -1385,64 +1385,64 @@ class XataApiClient {
|
|
1385
1385
|
});
|
1386
1386
|
}
|
1387
1387
|
get user() {
|
1388
|
-
if (!__privateGet$
|
1389
|
-
__privateGet$
|
1390
|
-
return __privateGet$
|
1388
|
+
if (!__privateGet$6(this, _namespaces).user)
|
1389
|
+
__privateGet$6(this, _namespaces).user = new UserApi(__privateGet$6(this, _extraProps));
|
1390
|
+
return __privateGet$6(this, _namespaces).user;
|
1391
1391
|
}
|
1392
1392
|
get authentication() {
|
1393
|
-
if (!__privateGet$
|
1394
|
-
__privateGet$
|
1395
|
-
return __privateGet$
|
1393
|
+
if (!__privateGet$6(this, _namespaces).authentication)
|
1394
|
+
__privateGet$6(this, _namespaces).authentication = new AuthenticationApi(__privateGet$6(this, _extraProps));
|
1395
|
+
return __privateGet$6(this, _namespaces).authentication;
|
1396
1396
|
}
|
1397
1397
|
get workspaces() {
|
1398
|
-
if (!__privateGet$
|
1399
|
-
__privateGet$
|
1400
|
-
return __privateGet$
|
1398
|
+
if (!__privateGet$6(this, _namespaces).workspaces)
|
1399
|
+
__privateGet$6(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$6(this, _extraProps));
|
1400
|
+
return __privateGet$6(this, _namespaces).workspaces;
|
1401
1401
|
}
|
1402
1402
|
get invites() {
|
1403
|
-
if (!__privateGet$
|
1404
|
-
__privateGet$
|
1405
|
-
return __privateGet$
|
1403
|
+
if (!__privateGet$6(this, _namespaces).invites)
|
1404
|
+
__privateGet$6(this, _namespaces).invites = new InvitesApi(__privateGet$6(this, _extraProps));
|
1405
|
+
return __privateGet$6(this, _namespaces).invites;
|
1406
1406
|
}
|
1407
1407
|
get database() {
|
1408
|
-
if (!__privateGet$
|
1409
|
-
__privateGet$
|
1410
|
-
return __privateGet$
|
1408
|
+
if (!__privateGet$6(this, _namespaces).database)
|
1409
|
+
__privateGet$6(this, _namespaces).database = new DatabaseApi(__privateGet$6(this, _extraProps));
|
1410
|
+
return __privateGet$6(this, _namespaces).database;
|
1411
1411
|
}
|
1412
1412
|
get branches() {
|
1413
|
-
if (!__privateGet$
|
1414
|
-
__privateGet$
|
1415
|
-
return __privateGet$
|
1413
|
+
if (!__privateGet$6(this, _namespaces).branches)
|
1414
|
+
__privateGet$6(this, _namespaces).branches = new BranchApi(__privateGet$6(this, _extraProps));
|
1415
|
+
return __privateGet$6(this, _namespaces).branches;
|
1416
1416
|
}
|
1417
1417
|
get migrations() {
|
1418
|
-
if (!__privateGet$
|
1419
|
-
__privateGet$
|
1420
|
-
return __privateGet$
|
1418
|
+
if (!__privateGet$6(this, _namespaces).migrations)
|
1419
|
+
__privateGet$6(this, _namespaces).migrations = new MigrationsApi(__privateGet$6(this, _extraProps));
|
1420
|
+
return __privateGet$6(this, _namespaces).migrations;
|
1421
1421
|
}
|
1422
1422
|
get migrationRequests() {
|
1423
|
-
if (!__privateGet$
|
1424
|
-
__privateGet$
|
1425
|
-
return __privateGet$
|
1423
|
+
if (!__privateGet$6(this, _namespaces).migrationRequests)
|
1424
|
+
__privateGet$6(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$6(this, _extraProps));
|
1425
|
+
return __privateGet$6(this, _namespaces).migrationRequests;
|
1426
1426
|
}
|
1427
1427
|
get tables() {
|
1428
|
-
if (!__privateGet$
|
1429
|
-
__privateGet$
|
1430
|
-
return __privateGet$
|
1428
|
+
if (!__privateGet$6(this, _namespaces).tables)
|
1429
|
+
__privateGet$6(this, _namespaces).tables = new TableApi(__privateGet$6(this, _extraProps));
|
1430
|
+
return __privateGet$6(this, _namespaces).tables;
|
1431
1431
|
}
|
1432
1432
|
get records() {
|
1433
|
-
if (!__privateGet$
|
1434
|
-
__privateGet$
|
1435
|
-
return __privateGet$
|
1433
|
+
if (!__privateGet$6(this, _namespaces).records)
|
1434
|
+
__privateGet$6(this, _namespaces).records = new RecordsApi(__privateGet$6(this, _extraProps));
|
1435
|
+
return __privateGet$6(this, _namespaces).records;
|
1436
1436
|
}
|
1437
1437
|
get files() {
|
1438
|
-
if (!__privateGet$
|
1439
|
-
__privateGet$
|
1440
|
-
return __privateGet$
|
1438
|
+
if (!__privateGet$6(this, _namespaces).files)
|
1439
|
+
__privateGet$6(this, _namespaces).files = new FilesApi(__privateGet$6(this, _extraProps));
|
1440
|
+
return __privateGet$6(this, _namespaces).files;
|
1441
1441
|
}
|
1442
1442
|
get searchAndFilter() {
|
1443
|
-
if (!__privateGet$
|
1444
|
-
__privateGet$
|
1445
|
-
return __privateGet$
|
1443
|
+
if (!__privateGet$6(this, _namespaces).searchAndFilter)
|
1444
|
+
__privateGet$6(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$6(this, _extraProps));
|
1445
|
+
return __privateGet$6(this, _namespaces).searchAndFilter;
|
1446
1446
|
}
|
1447
1447
|
}
|
1448
1448
|
_extraProps = new WeakMap();
|
@@ -1744,6 +1744,30 @@ class BranchApi {
|
|
1744
1744
|
...this.extraProps
|
1745
1745
|
});
|
1746
1746
|
}
|
1747
|
+
pgRollMigrationHistory({
|
1748
|
+
workspace,
|
1749
|
+
region,
|
1750
|
+
database,
|
1751
|
+
branch
|
1752
|
+
}) {
|
1753
|
+
return operationsByTag.branch.pgRollMigrationHistory({
|
1754
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1755
|
+
...this.extraProps
|
1756
|
+
});
|
1757
|
+
}
|
1758
|
+
applyMigration({
|
1759
|
+
workspace,
|
1760
|
+
region,
|
1761
|
+
database,
|
1762
|
+
branch,
|
1763
|
+
migration
|
1764
|
+
}) {
|
1765
|
+
return operationsByTag.branch.applyMigration({
|
1766
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1767
|
+
body: migration,
|
1768
|
+
...this.extraProps
|
1769
|
+
});
|
1770
|
+
}
|
1747
1771
|
}
|
1748
1772
|
class TableApi {
|
1749
1773
|
constructor(extraProps) {
|
@@ -2557,6 +2581,17 @@ class MigrationsApi {
|
|
2557
2581
|
...this.extraProps
|
2558
2582
|
});
|
2559
2583
|
}
|
2584
|
+
getSchema({
|
2585
|
+
workspace,
|
2586
|
+
region,
|
2587
|
+
database,
|
2588
|
+
branch
|
2589
|
+
}) {
|
2590
|
+
return operationsByTag.migrations.getSchema({
|
2591
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2592
|
+
...this.extraProps
|
2593
|
+
});
|
2594
|
+
}
|
2560
2595
|
}
|
2561
2596
|
class DatabaseApi {
|
2562
2597
|
constructor(extraProps) {
|
@@ -2862,7 +2897,7 @@ var __accessCheck$6 = (obj, member, msg) => {
|
|
2862
2897
|
if (!member.has(obj))
|
2863
2898
|
throw TypeError("Cannot " + msg);
|
2864
2899
|
};
|
2865
|
-
var __privateGet$
|
2900
|
+
var __privateGet$5 = (obj, member, getter) => {
|
2866
2901
|
__accessCheck$6(obj, member, "read from private field");
|
2867
2902
|
return getter ? getter.call(obj) : member.get(obj);
|
2868
2903
|
};
|
@@ -2871,7 +2906,7 @@ var __privateAdd$6 = (obj, member, value) => {
|
|
2871
2906
|
throw TypeError("Cannot add the same private member more than once");
|
2872
2907
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
2873
2908
|
};
|
2874
|
-
var __privateSet$
|
2909
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
2875
2910
|
__accessCheck$6(obj, member, "write to private field");
|
2876
2911
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
2877
2912
|
return value;
|
@@ -2880,9 +2915,9 @@ var _query, _page;
|
|
2880
2915
|
class Page {
|
2881
2916
|
constructor(query, meta, records = []) {
|
2882
2917
|
__privateAdd$6(this, _query, void 0);
|
2883
|
-
__privateSet$
|
2918
|
+
__privateSet$4(this, _query, query);
|
2884
2919
|
this.meta = meta;
|
2885
|
-
this.records = new
|
2920
|
+
this.records = new PageRecordArray(this, records);
|
2886
2921
|
}
|
2887
2922
|
/**
|
2888
2923
|
* Retrieves the next page of results.
|
@@ -2891,7 +2926,7 @@ class Page {
|
|
2891
2926
|
* @returns The next page or results.
|
2892
2927
|
*/
|
2893
2928
|
async nextPage(size, offset) {
|
2894
|
-
return __privateGet$
|
2929
|
+
return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
2895
2930
|
}
|
2896
2931
|
/**
|
2897
2932
|
* Retrieves the previous page of results.
|
@@ -2900,7 +2935,7 @@ class Page {
|
|
2900
2935
|
* @returns The previous page or results.
|
2901
2936
|
*/
|
2902
2937
|
async previousPage(size, offset) {
|
2903
|
-
return __privateGet$
|
2938
|
+
return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
2904
2939
|
}
|
2905
2940
|
/**
|
2906
2941
|
* Retrieves the start page of results.
|
@@ -2909,7 +2944,7 @@ class Page {
|
|
2909
2944
|
* @returns The start page or results.
|
2910
2945
|
*/
|
2911
2946
|
async startPage(size, offset) {
|
2912
|
-
return __privateGet$
|
2947
|
+
return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
2913
2948
|
}
|
2914
2949
|
/**
|
2915
2950
|
* Retrieves the end page of results.
|
@@ -2918,7 +2953,7 @@ class Page {
|
|
2918
2953
|
* @returns The end page or results.
|
2919
2954
|
*/
|
2920
2955
|
async endPage(size, offset) {
|
2921
|
-
return __privateGet$
|
2956
|
+
return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
2922
2957
|
}
|
2923
2958
|
/**
|
2924
2959
|
* Shortcut method to check if there will be additional results if the next page of results is retrieved.
|
@@ -2936,11 +2971,38 @@ const PAGINATION_DEFAULT_OFFSET = 0;
|
|
2936
2971
|
function isCursorPaginationOptions(options) {
|
2937
2972
|
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
2938
2973
|
}
|
2939
|
-
|
2974
|
+
class RecordArray extends Array {
|
2940
2975
|
constructor(...args) {
|
2941
|
-
super(...
|
2976
|
+
super(...RecordArray.parseConstructorParams(...args));
|
2977
|
+
}
|
2978
|
+
static parseConstructorParams(...args) {
|
2979
|
+
if (args.length === 1 && typeof args[0] === "number") {
|
2980
|
+
return new Array(args[0]);
|
2981
|
+
}
|
2982
|
+
if (args.length <= 1 && Array.isArray(args[0] ?? [])) {
|
2983
|
+
const result = args[0] ?? [];
|
2984
|
+
return new Array(...result);
|
2985
|
+
}
|
2986
|
+
return new Array(...args);
|
2987
|
+
}
|
2988
|
+
toArray() {
|
2989
|
+
return new Array(...this);
|
2990
|
+
}
|
2991
|
+
toSerializable() {
|
2992
|
+
return JSON.parse(this.toString());
|
2993
|
+
}
|
2994
|
+
toString() {
|
2995
|
+
return JSON.stringify(this.toArray());
|
2996
|
+
}
|
2997
|
+
map(callbackfn, thisArg) {
|
2998
|
+
return this.toArray().map(callbackfn, thisArg);
|
2999
|
+
}
|
3000
|
+
}
|
3001
|
+
const _PageRecordArray = class _PageRecordArray extends Array {
|
3002
|
+
constructor(...args) {
|
3003
|
+
super(..._PageRecordArray.parseConstructorParams(...args));
|
2942
3004
|
__privateAdd$6(this, _page, void 0);
|
2943
|
-
__privateSet$
|
3005
|
+
__privateSet$4(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
|
2944
3006
|
}
|
2945
3007
|
static parseConstructorParams(...args) {
|
2946
3008
|
if (args.length === 1 && typeof args[0] === "number") {
|
@@ -2970,8 +3032,8 @@ const _RecordArray = class _RecordArray extends Array {
|
|
2970
3032
|
* @returns A new array of objects
|
2971
3033
|
*/
|
2972
3034
|
async nextPage(size, offset) {
|
2973
|
-
const newPage = await __privateGet$
|
2974
|
-
return new
|
3035
|
+
const newPage = await __privateGet$5(this, _page).nextPage(size, offset);
|
3036
|
+
return new _PageRecordArray(newPage);
|
2975
3037
|
}
|
2976
3038
|
/**
|
2977
3039
|
* Retrieve previous page of records
|
@@ -2979,8 +3041,8 @@ const _RecordArray = class _RecordArray extends Array {
|
|
2979
3041
|
* @returns A new array of objects
|
2980
3042
|
*/
|
2981
3043
|
async previousPage(size, offset) {
|
2982
|
-
const newPage = await __privateGet$
|
2983
|
-
return new
|
3044
|
+
const newPage = await __privateGet$5(this, _page).previousPage(size, offset);
|
3045
|
+
return new _PageRecordArray(newPage);
|
2984
3046
|
}
|
2985
3047
|
/**
|
2986
3048
|
* Retrieve start page of records
|
@@ -2988,8 +3050,8 @@ const _RecordArray = class _RecordArray extends Array {
|
|
2988
3050
|
* @returns A new array of objects
|
2989
3051
|
*/
|
2990
3052
|
async startPage(size, offset) {
|
2991
|
-
const newPage = await __privateGet$
|
2992
|
-
return new
|
3053
|
+
const newPage = await __privateGet$5(this, _page).startPage(size, offset);
|
3054
|
+
return new _PageRecordArray(newPage);
|
2993
3055
|
}
|
2994
3056
|
/**
|
2995
3057
|
* Retrieve end page of records
|
@@ -2997,24 +3059,24 @@ const _RecordArray = class _RecordArray extends Array {
|
|
2997
3059
|
* @returns A new array of objects
|
2998
3060
|
*/
|
2999
3061
|
async endPage(size, offset) {
|
3000
|
-
const newPage = await __privateGet$
|
3001
|
-
return new
|
3062
|
+
const newPage = await __privateGet$5(this, _page).endPage(size, offset);
|
3063
|
+
return new _PageRecordArray(newPage);
|
3002
3064
|
}
|
3003
3065
|
/**
|
3004
3066
|
* @returns Boolean indicating if there is a next page
|
3005
3067
|
*/
|
3006
3068
|
hasNextPage() {
|
3007
|
-
return __privateGet$
|
3069
|
+
return __privateGet$5(this, _page).meta.page.more;
|
3008
3070
|
}
|
3009
3071
|
};
|
3010
3072
|
_page = new WeakMap();
|
3011
|
-
let
|
3073
|
+
let PageRecordArray = _PageRecordArray;
|
3012
3074
|
|
3013
3075
|
var __accessCheck$5 = (obj, member, msg) => {
|
3014
3076
|
if (!member.has(obj))
|
3015
3077
|
throw TypeError("Cannot " + msg);
|
3016
3078
|
};
|
3017
|
-
var __privateGet$
|
3079
|
+
var __privateGet$4 = (obj, member, getter) => {
|
3018
3080
|
__accessCheck$5(obj, member, "read from private field");
|
3019
3081
|
return getter ? getter.call(obj) : member.get(obj);
|
3020
3082
|
};
|
@@ -3023,7 +3085,7 @@ var __privateAdd$5 = (obj, member, value) => {
|
|
3023
3085
|
throw TypeError("Cannot add the same private member more than once");
|
3024
3086
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
3025
3087
|
};
|
3026
|
-
var __privateSet$
|
3088
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
3027
3089
|
__accessCheck$5(obj, member, "write to private field");
|
3028
3090
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
3029
3091
|
return value;
|
@@ -3041,25 +3103,25 @@ const _Query = class _Query {
|
|
3041
3103
|
__privateAdd$5(this, _data, { filter: {} });
|
3042
3104
|
// Implements pagination
|
3043
3105
|
this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
|
3044
|
-
this.records = new
|
3045
|
-
__privateSet$
|
3106
|
+
this.records = new PageRecordArray(this, []);
|
3107
|
+
__privateSet$3(this, _table$1, table);
|
3046
3108
|
if (repository) {
|
3047
|
-
__privateSet$
|
3109
|
+
__privateSet$3(this, _repository, repository);
|
3048
3110
|
} else {
|
3049
|
-
__privateSet$
|
3111
|
+
__privateSet$3(this, _repository, this);
|
3050
3112
|
}
|
3051
3113
|
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$
|
3114
|
+
__privateGet$4(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
3115
|
+
__privateGet$4(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
|
3116
|
+
__privateGet$4(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
|
3117
|
+
__privateGet$4(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
3118
|
+
__privateGet$4(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
3119
|
+
__privateGet$4(this, _data).sort = data.sort ?? parent?.sort;
|
3120
|
+
__privateGet$4(this, _data).columns = data.columns ?? parent?.columns;
|
3121
|
+
__privateGet$4(this, _data).consistency = data.consistency ?? parent?.consistency;
|
3122
|
+
__privateGet$4(this, _data).pagination = data.pagination ?? parent?.pagination;
|
3123
|
+
__privateGet$4(this, _data).cache = data.cache ?? parent?.cache;
|
3124
|
+
__privateGet$4(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
|
3063
3125
|
this.any = this.any.bind(this);
|
3064
3126
|
this.all = this.all.bind(this);
|
3065
3127
|
this.not = this.not.bind(this);
|
@@ -3070,10 +3132,10 @@ const _Query = class _Query {
|
|
3070
3132
|
Object.defineProperty(this, "repository", { enumerable: false });
|
3071
3133
|
}
|
3072
3134
|
getQueryOptions() {
|
3073
|
-
return __privateGet$
|
3135
|
+
return __privateGet$4(this, _data);
|
3074
3136
|
}
|
3075
3137
|
key() {
|
3076
|
-
const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$
|
3138
|
+
const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$4(this, _data);
|
3077
3139
|
const key = JSON.stringify({ columns, filter, sort, pagination });
|
3078
3140
|
return toBase64(key);
|
3079
3141
|
}
|
@@ -3084,7 +3146,7 @@ const _Query = class _Query {
|
|
3084
3146
|
*/
|
3085
3147
|
any(...queries) {
|
3086
3148
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
3087
|
-
return new _Query(__privateGet$
|
3149
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $any } }, __privateGet$4(this, _data));
|
3088
3150
|
}
|
3089
3151
|
/**
|
3090
3152
|
* Builds a new query object representing a logical AND between the given subqueries.
|
@@ -3093,7 +3155,7 @@ const _Query = class _Query {
|
|
3093
3155
|
*/
|
3094
3156
|
all(...queries) {
|
3095
3157
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
3096
|
-
return new _Query(__privateGet$
|
3158
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
|
3097
3159
|
}
|
3098
3160
|
/**
|
3099
3161
|
* Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
|
@@ -3102,7 +3164,7 @@ const _Query = class _Query {
|
|
3102
3164
|
*/
|
3103
3165
|
not(...queries) {
|
3104
3166
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
3105
|
-
return new _Query(__privateGet$
|
3167
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $not } }, __privateGet$4(this, _data));
|
3106
3168
|
}
|
3107
3169
|
/**
|
3108
3170
|
* Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
|
@@ -3111,25 +3173,25 @@ const _Query = class _Query {
|
|
3111
3173
|
*/
|
3112
3174
|
none(...queries) {
|
3113
3175
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
3114
|
-
return new _Query(__privateGet$
|
3176
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $none } }, __privateGet$4(this, _data));
|
3115
3177
|
}
|
3116
3178
|
filter(a, b) {
|
3117
3179
|
if (arguments.length === 1) {
|
3118
3180
|
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
3119
3181
|
[column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
|
3120
3182
|
}));
|
3121
|
-
const $all = compact([__privateGet$
|
3122
|
-
return new _Query(__privateGet$
|
3183
|
+
const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
|
3184
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
|
3123
3185
|
} else {
|
3124
3186
|
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$
|
3187
|
+
const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
|
3188
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
|
3127
3189
|
}
|
3128
3190
|
}
|
3129
3191
|
sort(column, direction = "asc") {
|
3130
|
-
const originalSort = [__privateGet$
|
3192
|
+
const originalSort = [__privateGet$4(this, _data).sort ?? []].flat();
|
3131
3193
|
const sort = [...originalSort, { column, direction }];
|
3132
|
-
return new _Query(__privateGet$
|
3194
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { sort }, __privateGet$4(this, _data));
|
3133
3195
|
}
|
3134
3196
|
/**
|
3135
3197
|
* Builds a new query specifying the set of columns to be returned in the query response.
|
@@ -3138,15 +3200,15 @@ const _Query = class _Query {
|
|
3138
3200
|
*/
|
3139
3201
|
select(columns) {
|
3140
3202
|
return new _Query(
|
3141
|
-
__privateGet$
|
3142
|
-
__privateGet$
|
3203
|
+
__privateGet$4(this, _repository),
|
3204
|
+
__privateGet$4(this, _table$1),
|
3143
3205
|
{ columns },
|
3144
|
-
__privateGet$
|
3206
|
+
__privateGet$4(this, _data)
|
3145
3207
|
);
|
3146
3208
|
}
|
3147
3209
|
getPaginated(options = {}) {
|
3148
|
-
const query = new _Query(__privateGet$
|
3149
|
-
return __privateGet$
|
3210
|
+
const query = new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), options, __privateGet$4(this, _data));
|
3211
|
+
return __privateGet$4(this, _repository).query(query);
|
3150
3212
|
}
|
3151
3213
|
/**
|
3152
3214
|
* Get results in an iterator
|
@@ -3183,7 +3245,7 @@ const _Query = class _Query {
|
|
3183
3245
|
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
3184
3246
|
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
3185
3247
|
}
|
3186
|
-
const array = new
|
3248
|
+
const array = new PageRecordArray(page, results.slice(0, size));
|
3187
3249
|
return array;
|
3188
3250
|
}
|
3189
3251
|
async getAll(options = {}) {
|
@@ -3192,7 +3254,7 @@ const _Query = class _Query {
|
|
3192
3254
|
for await (const page of this.getIterator({ ...rest, batchSize })) {
|
3193
3255
|
results.push(...page);
|
3194
3256
|
}
|
3195
|
-
return results;
|
3257
|
+
return new RecordArray(results);
|
3196
3258
|
}
|
3197
3259
|
async getFirst(options = {}) {
|
3198
3260
|
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
@@ -3207,12 +3269,12 @@ const _Query = class _Query {
|
|
3207
3269
|
async summarize(params = {}) {
|
3208
3270
|
const { summaries, summariesFilter, ...options } = params;
|
3209
3271
|
const query = new _Query(
|
3210
|
-
__privateGet$
|
3211
|
-
__privateGet$
|
3272
|
+
__privateGet$4(this, _repository),
|
3273
|
+
__privateGet$4(this, _table$1),
|
3212
3274
|
options,
|
3213
|
-
__privateGet$
|
3275
|
+
__privateGet$4(this, _data)
|
3214
3276
|
);
|
3215
|
-
return __privateGet$
|
3277
|
+
return __privateGet$4(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
3216
3278
|
}
|
3217
3279
|
/**
|
3218
3280
|
* Builds a new query object adding a cache TTL in milliseconds.
|
@@ -3220,7 +3282,7 @@ const _Query = class _Query {
|
|
3220
3282
|
* @returns A new Query object.
|
3221
3283
|
*/
|
3222
3284
|
cache(ttl) {
|
3223
|
-
return new _Query(__privateGet$
|
3285
|
+
return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { cache: ttl }, __privateGet$4(this, _data));
|
3224
3286
|
}
|
3225
3287
|
/**
|
3226
3288
|
* Retrieve next page of records
|
@@ -3266,7 +3328,7 @@ _repository = new WeakMap();
|
|
3266
3328
|
_data = new WeakMap();
|
3267
3329
|
_cleanFilterConstraint = new WeakSet();
|
3268
3330
|
cleanFilterConstraint_fn = function(column, value) {
|
3269
|
-
const columnType = __privateGet$
|
3331
|
+
const columnType = __privateGet$4(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
3270
3332
|
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
3271
3333
|
return { $includes: value };
|
3272
3334
|
}
|
@@ -3356,7 +3418,7 @@ var __accessCheck$4 = (obj, member, msg) => {
|
|
3356
3418
|
if (!member.has(obj))
|
3357
3419
|
throw TypeError("Cannot " + msg);
|
3358
3420
|
};
|
3359
|
-
var __privateGet$
|
3421
|
+
var __privateGet$3 = (obj, member, getter) => {
|
3360
3422
|
__accessCheck$4(obj, member, "read from private field");
|
3361
3423
|
return getter ? getter.call(obj) : member.get(obj);
|
3362
3424
|
};
|
@@ -3365,7 +3427,7 @@ var __privateAdd$4 = (obj, member, value) => {
|
|
3365
3427
|
throw TypeError("Cannot add the same private member more than once");
|
3366
3428
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
3367
3429
|
};
|
3368
|
-
var __privateSet$
|
3430
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
3369
3431
|
__accessCheck$4(obj, member, "write to private field");
|
3370
3432
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
3371
3433
|
return value;
|
@@ -3374,7 +3436,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
3374
3436
|
__accessCheck$4(obj, member, "access private method");
|
3375
3437
|
return method;
|
3376
3438
|
};
|
3377
|
-
var _table, _getFetchProps, _db, _cache, _schemaTables
|
3439
|
+
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
3440
|
const BULK_OPERATION_MAX_SIZE = 1e3;
|
3379
3441
|
class Repository extends Query {
|
3380
3442
|
}
|
@@ -3395,31 +3457,31 @@ class RestRepository extends Query {
|
|
3395
3457
|
__privateAdd$4(this, _deleteRecords);
|
3396
3458
|
__privateAdd$4(this, _setCacheQuery);
|
3397
3459
|
__privateAdd$4(this, _getCacheQuery);
|
3398
|
-
__privateAdd$4(this, _getSchemaTables
|
3460
|
+
__privateAdd$4(this, _getSchemaTables);
|
3399
3461
|
__privateAdd$4(this, _transformObjectToApi);
|
3400
3462
|
__privateAdd$4(this, _table, void 0);
|
3401
3463
|
__privateAdd$4(this, _getFetchProps, void 0);
|
3402
3464
|
__privateAdd$4(this, _db, void 0);
|
3403
3465
|
__privateAdd$4(this, _cache, void 0);
|
3404
|
-
__privateAdd$4(this, _schemaTables
|
3466
|
+
__privateAdd$4(this, _schemaTables, void 0);
|
3405
3467
|
__privateAdd$4(this, _trace, void 0);
|
3406
|
-
__privateSet$
|
3407
|
-
__privateSet$
|
3408
|
-
__privateSet$
|
3409
|
-
__privateSet$
|
3410
|
-
__privateSet$
|
3468
|
+
__privateSet$2(this, _table, options.table);
|
3469
|
+
__privateSet$2(this, _db, options.db);
|
3470
|
+
__privateSet$2(this, _cache, options.pluginOptions.cache);
|
3471
|
+
__privateSet$2(this, _schemaTables, options.schemaTables);
|
3472
|
+
__privateSet$2(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
|
3411
3473
|
const trace = options.pluginOptions.trace ?? defaultTrace;
|
3412
|
-
__privateSet$
|
3474
|
+
__privateSet$2(this, _trace, async (name, fn, options2 = {}) => {
|
3413
3475
|
return trace(name, fn, {
|
3414
3476
|
...options2,
|
3415
|
-
[TraceAttributes.TABLE]: __privateGet$
|
3477
|
+
[TraceAttributes.TABLE]: __privateGet$3(this, _table),
|
3416
3478
|
[TraceAttributes.KIND]: "sdk-operation",
|
3417
3479
|
[TraceAttributes.VERSION]: VERSION
|
3418
3480
|
});
|
3419
3481
|
});
|
3420
3482
|
}
|
3421
3483
|
async create(a, b, c, d) {
|
3422
|
-
return __privateGet$
|
3484
|
+
return __privateGet$3(this, _trace).call(this, "create", async () => {
|
3423
3485
|
const ifVersion = parseIfVersion(b, c, d);
|
3424
3486
|
if (Array.isArray(a)) {
|
3425
3487
|
if (a.length === 0)
|
@@ -3449,7 +3511,7 @@ class RestRepository extends Query {
|
|
3449
3511
|
});
|
3450
3512
|
}
|
3451
3513
|
async read(a, b) {
|
3452
|
-
return __privateGet$
|
3514
|
+
return __privateGet$3(this, _trace).call(this, "read", async () => {
|
3453
3515
|
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3454
3516
|
if (Array.isArray(a)) {
|
3455
3517
|
if (a.length === 0)
|
@@ -3470,17 +3532,17 @@ class RestRepository extends Query {
|
|
3470
3532
|
workspace: "{workspaceId}",
|
3471
3533
|
dbBranchName: "{dbBranch}",
|
3472
3534
|
region: "{region}",
|
3473
|
-
tableName: __privateGet$
|
3535
|
+
tableName: __privateGet$3(this, _table),
|
3474
3536
|
recordId: id
|
3475
3537
|
},
|
3476
3538
|
queryParams: { columns },
|
3477
|
-
...__privateGet$
|
3539
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3478
3540
|
});
|
3479
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3541
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3480
3542
|
return initObject(
|
3481
|
-
__privateGet$
|
3543
|
+
__privateGet$3(this, _db),
|
3482
3544
|
schemaTables,
|
3483
|
-
__privateGet$
|
3545
|
+
__privateGet$3(this, _table),
|
3484
3546
|
response,
|
3485
3547
|
columns
|
3486
3548
|
);
|
@@ -3495,7 +3557,7 @@ class RestRepository extends Query {
|
|
3495
3557
|
});
|
3496
3558
|
}
|
3497
3559
|
async readOrThrow(a, b) {
|
3498
|
-
return __privateGet$
|
3560
|
+
return __privateGet$3(this, _trace).call(this, "readOrThrow", async () => {
|
3499
3561
|
const result = await this.read(a, b);
|
3500
3562
|
if (Array.isArray(result)) {
|
3501
3563
|
const missingIds = compact(
|
@@ -3514,7 +3576,7 @@ class RestRepository extends Query {
|
|
3514
3576
|
});
|
3515
3577
|
}
|
3516
3578
|
async update(a, b, c, d) {
|
3517
|
-
return __privateGet$
|
3579
|
+
return __privateGet$3(this, _trace).call(this, "update", async () => {
|
3518
3580
|
const ifVersion = parseIfVersion(b, c, d);
|
3519
3581
|
if (Array.isArray(a)) {
|
3520
3582
|
if (a.length === 0)
|
@@ -3547,7 +3609,7 @@ class RestRepository extends Query {
|
|
3547
3609
|
});
|
3548
3610
|
}
|
3549
3611
|
async updateOrThrow(a, b, c, d) {
|
3550
|
-
return __privateGet$
|
3612
|
+
return __privateGet$3(this, _trace).call(this, "updateOrThrow", async () => {
|
3551
3613
|
const result = await this.update(a, b, c, d);
|
3552
3614
|
if (Array.isArray(result)) {
|
3553
3615
|
const missingIds = compact(
|
@@ -3566,7 +3628,7 @@ class RestRepository extends Query {
|
|
3566
3628
|
});
|
3567
3629
|
}
|
3568
3630
|
async createOrUpdate(a, b, c, d) {
|
3569
|
-
return __privateGet$
|
3631
|
+
return __privateGet$3(this, _trace).call(this, "createOrUpdate", async () => {
|
3570
3632
|
const ifVersion = parseIfVersion(b, c, d);
|
3571
3633
|
if (Array.isArray(a)) {
|
3572
3634
|
if (a.length === 0)
|
@@ -3601,7 +3663,7 @@ class RestRepository extends Query {
|
|
3601
3663
|
});
|
3602
3664
|
}
|
3603
3665
|
async createOrReplace(a, b, c, d) {
|
3604
|
-
return __privateGet$
|
3666
|
+
return __privateGet$3(this, _trace).call(this, "createOrReplace", async () => {
|
3605
3667
|
const ifVersion = parseIfVersion(b, c, d);
|
3606
3668
|
if (Array.isArray(a)) {
|
3607
3669
|
if (a.length === 0)
|
@@ -3633,7 +3695,7 @@ class RestRepository extends Query {
|
|
3633
3695
|
});
|
3634
3696
|
}
|
3635
3697
|
async delete(a, b) {
|
3636
|
-
return __privateGet$
|
3698
|
+
return __privateGet$3(this, _trace).call(this, "delete", async () => {
|
3637
3699
|
if (Array.isArray(a)) {
|
3638
3700
|
if (a.length === 0)
|
3639
3701
|
return [];
|
@@ -3659,7 +3721,7 @@ class RestRepository extends Query {
|
|
3659
3721
|
});
|
3660
3722
|
}
|
3661
3723
|
async deleteOrThrow(a, b) {
|
3662
|
-
return __privateGet$
|
3724
|
+
return __privateGet$3(this, _trace).call(this, "deleteOrThrow", async () => {
|
3663
3725
|
const result = await this.delete(a, b);
|
3664
3726
|
if (Array.isArray(result)) {
|
3665
3727
|
const missingIds = compact(
|
@@ -3677,13 +3739,13 @@ class RestRepository extends Query {
|
|
3677
3739
|
});
|
3678
3740
|
}
|
3679
3741
|
async search(query, options = {}) {
|
3680
|
-
return __privateGet$
|
3742
|
+
return __privateGet$3(this, _trace).call(this, "search", async () => {
|
3681
3743
|
const { records, totalCount } = await searchTable({
|
3682
3744
|
pathParams: {
|
3683
3745
|
workspace: "{workspaceId}",
|
3684
3746
|
dbBranchName: "{dbBranch}",
|
3685
3747
|
region: "{region}",
|
3686
|
-
tableName: __privateGet$
|
3748
|
+
tableName: __privateGet$3(this, _table)
|
3687
3749
|
},
|
3688
3750
|
body: {
|
3689
3751
|
query,
|
@@ -3695,23 +3757,23 @@ class RestRepository extends Query {
|
|
3695
3757
|
page: options.page,
|
3696
3758
|
target: options.target
|
3697
3759
|
},
|
3698
|
-
...__privateGet$
|
3760
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3699
3761
|
});
|
3700
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3762
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3701
3763
|
return {
|
3702
|
-
records: records.map((item) => initObject(__privateGet$
|
3764
|
+
records: records.map((item) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), item, ["*"])),
|
3703
3765
|
totalCount
|
3704
3766
|
};
|
3705
3767
|
});
|
3706
3768
|
}
|
3707
3769
|
async vectorSearch(column, query, options) {
|
3708
|
-
return __privateGet$
|
3770
|
+
return __privateGet$3(this, _trace).call(this, "vectorSearch", async () => {
|
3709
3771
|
const { records, totalCount } = await vectorSearchTable({
|
3710
3772
|
pathParams: {
|
3711
3773
|
workspace: "{workspaceId}",
|
3712
3774
|
dbBranchName: "{dbBranch}",
|
3713
3775
|
region: "{region}",
|
3714
|
-
tableName: __privateGet$
|
3776
|
+
tableName: __privateGet$3(this, _table)
|
3715
3777
|
},
|
3716
3778
|
body: {
|
3717
3779
|
column,
|
@@ -3720,32 +3782,32 @@ class RestRepository extends Query {
|
|
3720
3782
|
size: options?.size,
|
3721
3783
|
filter: options?.filter
|
3722
3784
|
},
|
3723
|
-
...__privateGet$
|
3785
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3724
3786
|
});
|
3725
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3787
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3726
3788
|
return {
|
3727
|
-
records: records.map((item) => initObject(__privateGet$
|
3789
|
+
records: records.map((item) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), item, ["*"])),
|
3728
3790
|
totalCount
|
3729
3791
|
};
|
3730
3792
|
});
|
3731
3793
|
}
|
3732
3794
|
async aggregate(aggs, filter) {
|
3733
|
-
return __privateGet$
|
3795
|
+
return __privateGet$3(this, _trace).call(this, "aggregate", async () => {
|
3734
3796
|
const result = await aggregateTable({
|
3735
3797
|
pathParams: {
|
3736
3798
|
workspace: "{workspaceId}",
|
3737
3799
|
dbBranchName: "{dbBranch}",
|
3738
3800
|
region: "{region}",
|
3739
|
-
tableName: __privateGet$
|
3801
|
+
tableName: __privateGet$3(this, _table)
|
3740
3802
|
},
|
3741
3803
|
body: { aggs, filter },
|
3742
|
-
...__privateGet$
|
3804
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3743
3805
|
});
|
3744
3806
|
return result;
|
3745
3807
|
});
|
3746
3808
|
}
|
3747
3809
|
async query(query) {
|
3748
|
-
return __privateGet$
|
3810
|
+
return __privateGet$3(this, _trace).call(this, "query", async () => {
|
3749
3811
|
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
3750
3812
|
if (cacheQuery)
|
3751
3813
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
@@ -3755,7 +3817,7 @@ class RestRepository extends Query {
|
|
3755
3817
|
workspace: "{workspaceId}",
|
3756
3818
|
dbBranchName: "{dbBranch}",
|
3757
3819
|
region: "{region}",
|
3758
|
-
tableName: __privateGet$
|
3820
|
+
tableName: __privateGet$3(this, _table)
|
3759
3821
|
},
|
3760
3822
|
body: {
|
3761
3823
|
filter: cleanFilter(data.filter),
|
@@ -3765,14 +3827,14 @@ class RestRepository extends Query {
|
|
3765
3827
|
consistency: data.consistency
|
3766
3828
|
},
|
3767
3829
|
fetchOptions: data.fetchOptions,
|
3768
|
-
...__privateGet$
|
3830
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3769
3831
|
});
|
3770
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3832
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3771
3833
|
const records = objects.map(
|
3772
3834
|
(record) => initObject(
|
3773
|
-
__privateGet$
|
3835
|
+
__privateGet$3(this, _db),
|
3774
3836
|
schemaTables,
|
3775
|
-
__privateGet$
|
3837
|
+
__privateGet$3(this, _table),
|
3776
3838
|
record,
|
3777
3839
|
data.columns ?? ["*"]
|
3778
3840
|
)
|
@@ -3782,14 +3844,14 @@ class RestRepository extends Query {
|
|
3782
3844
|
});
|
3783
3845
|
}
|
3784
3846
|
async summarizeTable(query, summaries, summariesFilter) {
|
3785
|
-
return __privateGet$
|
3847
|
+
return __privateGet$3(this, _trace).call(this, "summarize", async () => {
|
3786
3848
|
const data = query.getQueryOptions();
|
3787
3849
|
const result = await summarizeTable({
|
3788
3850
|
pathParams: {
|
3789
3851
|
workspace: "{workspaceId}",
|
3790
3852
|
dbBranchName: "{dbBranch}",
|
3791
3853
|
region: "{region}",
|
3792
|
-
tableName: __privateGet$
|
3854
|
+
tableName: __privateGet$3(this, _table)
|
3793
3855
|
},
|
3794
3856
|
body: {
|
3795
3857
|
filter: cleanFilter(data.filter),
|
@@ -3800,13 +3862,13 @@ class RestRepository extends Query {
|
|
3800
3862
|
summaries,
|
3801
3863
|
summariesFilter
|
3802
3864
|
},
|
3803
|
-
...__privateGet$
|
3865
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3804
3866
|
});
|
3805
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3867
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3806
3868
|
return {
|
3807
3869
|
...result,
|
3808
3870
|
summaries: result.summaries.map(
|
3809
|
-
(summary) => initObject(__privateGet$
|
3871
|
+
(summary) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), summary, data.columns ?? [])
|
3810
3872
|
)
|
3811
3873
|
};
|
3812
3874
|
});
|
@@ -3818,7 +3880,7 @@ class RestRepository extends Query {
|
|
3818
3880
|
workspace: "{workspaceId}",
|
3819
3881
|
dbBranchName: "{dbBranch}",
|
3820
3882
|
region: "{region}",
|
3821
|
-
tableName: __privateGet$
|
3883
|
+
tableName: __privateGet$3(this, _table),
|
3822
3884
|
sessionId: options?.sessionId
|
3823
3885
|
},
|
3824
3886
|
body: {
|
@@ -3828,7 +3890,7 @@ class RestRepository extends Query {
|
|
3828
3890
|
search: options?.searchType === "keyword" ? options?.search : void 0,
|
3829
3891
|
vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
|
3830
3892
|
},
|
3831
|
-
...__privateGet$
|
3893
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3832
3894
|
};
|
3833
3895
|
if (options?.onMessage) {
|
3834
3896
|
fetchSSERequest({
|
@@ -3849,7 +3911,7 @@ _table = new WeakMap();
|
|
3849
3911
|
_getFetchProps = new WeakMap();
|
3850
3912
|
_db = new WeakMap();
|
3851
3913
|
_cache = new WeakMap();
|
3852
|
-
_schemaTables
|
3914
|
+
_schemaTables = new WeakMap();
|
3853
3915
|
_trace = new WeakMap();
|
3854
3916
|
_insertRecordWithoutId = new WeakSet();
|
3855
3917
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
@@ -3859,14 +3921,14 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
3859
3921
|
workspace: "{workspaceId}",
|
3860
3922
|
dbBranchName: "{dbBranch}",
|
3861
3923
|
region: "{region}",
|
3862
|
-
tableName: __privateGet$
|
3924
|
+
tableName: __privateGet$3(this, _table)
|
3863
3925
|
},
|
3864
3926
|
queryParams: { columns },
|
3865
3927
|
body: record,
|
3866
|
-
...__privateGet$
|
3928
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3867
3929
|
});
|
3868
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3869
|
-
return initObject(__privateGet$
|
3930
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3931
|
+
return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
|
3870
3932
|
};
|
3871
3933
|
_insertRecordWithId = new WeakSet();
|
3872
3934
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
@@ -3878,21 +3940,21 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
|
|
3878
3940
|
workspace: "{workspaceId}",
|
3879
3941
|
dbBranchName: "{dbBranch}",
|
3880
3942
|
region: "{region}",
|
3881
|
-
tableName: __privateGet$
|
3943
|
+
tableName: __privateGet$3(this, _table),
|
3882
3944
|
recordId
|
3883
3945
|
},
|
3884
3946
|
body: record,
|
3885
3947
|
queryParams: { createOnly, columns, ifVersion },
|
3886
|
-
...__privateGet$
|
3948
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3887
3949
|
});
|
3888
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3889
|
-
return initObject(__privateGet$
|
3950
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
3951
|
+
return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
|
3890
3952
|
};
|
3891
3953
|
_insertRecords = new WeakSet();
|
3892
3954
|
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
3893
3955
|
const operations = await promiseMap(objects, async (object) => {
|
3894
3956
|
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3895
|
-
return { insert: { table: __privateGet$
|
3957
|
+
return { insert: { table: __privateGet$3(this, _table), record, createOnly, ifVersion } };
|
3896
3958
|
});
|
3897
3959
|
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
3898
3960
|
const ids = [];
|
@@ -3904,7 +3966,7 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
|
3904
3966
|
region: "{region}"
|
3905
3967
|
},
|
3906
3968
|
body: { operations: operations2 },
|
3907
|
-
...__privateGet$
|
3969
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3908
3970
|
});
|
3909
3971
|
for (const result of results) {
|
3910
3972
|
if (result.operation === "insert") {
|
@@ -3927,15 +3989,15 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
3927
3989
|
workspace: "{workspaceId}",
|
3928
3990
|
dbBranchName: "{dbBranch}",
|
3929
3991
|
region: "{region}",
|
3930
|
-
tableName: __privateGet$
|
3992
|
+
tableName: __privateGet$3(this, _table),
|
3931
3993
|
recordId
|
3932
3994
|
},
|
3933
3995
|
queryParams: { columns, ifVersion },
|
3934
3996
|
body: record,
|
3935
|
-
...__privateGet$
|
3997
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3936
3998
|
});
|
3937
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3938
|
-
return initObject(__privateGet$
|
3999
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
4000
|
+
return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
|
3939
4001
|
} catch (e) {
|
3940
4002
|
if (isObject(e) && e.status === 404) {
|
3941
4003
|
return null;
|
@@ -3947,7 +4009,7 @@ _updateRecords = new WeakSet();
|
|
3947
4009
|
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
3948
4010
|
const operations = await promiseMap(objects, async ({ id, ...object }) => {
|
3949
4011
|
const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3950
|
-
return { update: { table: __privateGet$
|
4012
|
+
return { update: { table: __privateGet$3(this, _table), id, ifVersion, upsert, fields } };
|
3951
4013
|
});
|
3952
4014
|
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
3953
4015
|
const ids = [];
|
@@ -3959,7 +4021,7 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
|
3959
4021
|
region: "{region}"
|
3960
4022
|
},
|
3961
4023
|
body: { operations: operations2 },
|
3962
|
-
...__privateGet$
|
4024
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3963
4025
|
});
|
3964
4026
|
for (const result of results) {
|
3965
4027
|
if (result.operation === "update") {
|
@@ -3980,15 +4042,15 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
3980
4042
|
workspace: "{workspaceId}",
|
3981
4043
|
dbBranchName: "{dbBranch}",
|
3982
4044
|
region: "{region}",
|
3983
|
-
tableName: __privateGet$
|
4045
|
+
tableName: __privateGet$3(this, _table),
|
3984
4046
|
recordId
|
3985
4047
|
},
|
3986
4048
|
queryParams: { columns, ifVersion },
|
3987
4049
|
body: object,
|
3988
|
-
...__privateGet$
|
4050
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
3989
4051
|
});
|
3990
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
3991
|
-
return initObject(__privateGet$
|
4052
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
4053
|
+
return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
|
3992
4054
|
};
|
3993
4055
|
_deleteRecord = new WeakSet();
|
3994
4056
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
@@ -4000,14 +4062,14 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
4000
4062
|
workspace: "{workspaceId}",
|
4001
4063
|
dbBranchName: "{dbBranch}",
|
4002
4064
|
region: "{region}",
|
4003
|
-
tableName: __privateGet$
|
4065
|
+
tableName: __privateGet$3(this, _table),
|
4004
4066
|
recordId
|
4005
4067
|
},
|
4006
4068
|
queryParams: { columns },
|
4007
|
-
...__privateGet$
|
4069
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
4008
4070
|
});
|
4009
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
4010
|
-
return initObject(__privateGet$
|
4071
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
4072
|
+
return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
|
4011
4073
|
} catch (e) {
|
4012
4074
|
if (isObject(e) && e.status === 404) {
|
4013
4075
|
return null;
|
@@ -4018,7 +4080,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
4018
4080
|
_deleteRecords = new WeakSet();
|
4019
4081
|
deleteRecords_fn = async function(recordIds) {
|
4020
4082
|
const chunkedOperations = chunk(
|
4021
|
-
compact(recordIds).map((id) => ({ delete: { table: __privateGet$
|
4083
|
+
compact(recordIds).map((id) => ({ delete: { table: __privateGet$3(this, _table), id } })),
|
4022
4084
|
BULK_OPERATION_MAX_SIZE
|
4023
4085
|
);
|
4024
4086
|
for (const operations of chunkedOperations) {
|
@@ -4029,44 +4091,44 @@ deleteRecords_fn = async function(recordIds) {
|
|
4029
4091
|
region: "{region}"
|
4030
4092
|
},
|
4031
4093
|
body: { operations },
|
4032
|
-
...__privateGet$
|
4094
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
4033
4095
|
});
|
4034
4096
|
}
|
4035
4097
|
};
|
4036
4098
|
_setCacheQuery = new WeakSet();
|
4037
4099
|
setCacheQuery_fn = async function(query, meta, records) {
|
4038
|
-
await __privateGet$
|
4100
|
+
await __privateGet$3(this, _cache)?.set(`query_${__privateGet$3(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
|
4039
4101
|
};
|
4040
4102
|
_getCacheQuery = new WeakSet();
|
4041
4103
|
getCacheQuery_fn = async function(query) {
|
4042
|
-
const key = `query_${__privateGet$
|
4043
|
-
const result = await __privateGet$
|
4104
|
+
const key = `query_${__privateGet$3(this, _table)}:${query.key()}`;
|
4105
|
+
const result = await __privateGet$3(this, _cache)?.get(key);
|
4044
4106
|
if (!result)
|
4045
4107
|
return null;
|
4046
|
-
const defaultTTL = __privateGet$
|
4108
|
+
const defaultTTL = __privateGet$3(this, _cache)?.defaultQueryTTL ?? -1;
|
4047
4109
|
const { cache: ttl = defaultTTL } = query.getQueryOptions();
|
4048
4110
|
if (ttl < 0)
|
4049
4111
|
return null;
|
4050
4112
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
4051
4113
|
return hasExpired ? null : result;
|
4052
4114
|
};
|
4053
|
-
_getSchemaTables
|
4054
|
-
getSchemaTables_fn
|
4055
|
-
if (__privateGet$
|
4056
|
-
return __privateGet$
|
4115
|
+
_getSchemaTables = new WeakSet();
|
4116
|
+
getSchemaTables_fn = async function() {
|
4117
|
+
if (__privateGet$3(this, _schemaTables))
|
4118
|
+
return __privateGet$3(this, _schemaTables);
|
4057
4119
|
const { schema } = await getBranchDetails({
|
4058
4120
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4059
|
-
...__privateGet$
|
4121
|
+
...__privateGet$3(this, _getFetchProps).call(this)
|
4060
4122
|
});
|
4061
|
-
__privateSet$
|
4123
|
+
__privateSet$2(this, _schemaTables, schema.tables);
|
4062
4124
|
return schema.tables;
|
4063
4125
|
};
|
4064
4126
|
_transformObjectToApi = new WeakSet();
|
4065
4127
|
transformObjectToApi_fn = async function(object) {
|
4066
|
-
const schemaTables = await __privateMethod$2(this, _getSchemaTables
|
4067
|
-
const schema = schemaTables.find((table) => table.name === __privateGet$
|
4128
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
|
4129
|
+
const schema = schemaTables.find((table) => table.name === __privateGet$3(this, _table));
|
4068
4130
|
if (!schema)
|
4069
|
-
throw new Error(`Table ${__privateGet$
|
4131
|
+
throw new Error(`Table ${__privateGet$3(this, _table)} not found in schema`);
|
4070
4132
|
const result = {};
|
4071
4133
|
for (const [key, value] of Object.entries(object)) {
|
4072
4134
|
if (key === "xata")
|
@@ -4222,7 +4284,7 @@ var __accessCheck$3 = (obj, member, msg) => {
|
|
4222
4284
|
if (!member.has(obj))
|
4223
4285
|
throw TypeError("Cannot " + msg);
|
4224
4286
|
};
|
4225
|
-
var __privateGet$
|
4287
|
+
var __privateGet$2 = (obj, member, getter) => {
|
4226
4288
|
__accessCheck$3(obj, member, "read from private field");
|
4227
4289
|
return getter ? getter.call(obj) : member.get(obj);
|
4228
4290
|
};
|
@@ -4231,7 +4293,7 @@ var __privateAdd$3 = (obj, member, value) => {
|
|
4231
4293
|
throw TypeError("Cannot add the same private member more than once");
|
4232
4294
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
4233
4295
|
};
|
4234
|
-
var __privateSet$
|
4296
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
4235
4297
|
__accessCheck$3(obj, member, "write to private field");
|
4236
4298
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
4237
4299
|
return value;
|
@@ -4240,29 +4302,29 @@ var _map;
|
|
4240
4302
|
class SimpleCache {
|
4241
4303
|
constructor(options = {}) {
|
4242
4304
|
__privateAdd$3(this, _map, void 0);
|
4243
|
-
__privateSet$
|
4305
|
+
__privateSet$1(this, _map, /* @__PURE__ */ new Map());
|
4244
4306
|
this.capacity = options.max ?? 500;
|
4245
4307
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
4246
4308
|
}
|
4247
4309
|
async getAll() {
|
4248
|
-
return Object.fromEntries(__privateGet$
|
4310
|
+
return Object.fromEntries(__privateGet$2(this, _map));
|
4249
4311
|
}
|
4250
4312
|
async get(key) {
|
4251
|
-
return __privateGet$
|
4313
|
+
return __privateGet$2(this, _map).get(key) ?? null;
|
4252
4314
|
}
|
4253
4315
|
async set(key, value) {
|
4254
4316
|
await this.delete(key);
|
4255
|
-
__privateGet$
|
4256
|
-
if (__privateGet$
|
4257
|
-
const leastRecentlyUsed = __privateGet$
|
4317
|
+
__privateGet$2(this, _map).set(key, value);
|
4318
|
+
if (__privateGet$2(this, _map).size > this.capacity) {
|
4319
|
+
const leastRecentlyUsed = __privateGet$2(this, _map).keys().next().value;
|
4258
4320
|
await this.delete(leastRecentlyUsed);
|
4259
4321
|
}
|
4260
4322
|
}
|
4261
4323
|
async delete(key) {
|
4262
|
-
__privateGet$
|
4324
|
+
__privateGet$2(this, _map).delete(key);
|
4263
4325
|
}
|
4264
4326
|
async clear() {
|
4265
|
-
return __privateGet$
|
4327
|
+
return __privateGet$2(this, _map).clear();
|
4266
4328
|
}
|
4267
4329
|
}
|
4268
4330
|
_map = new WeakMap();
|
@@ -4299,7 +4361,7 @@ var __accessCheck$2 = (obj, member, msg) => {
|
|
4299
4361
|
if (!member.has(obj))
|
4300
4362
|
throw TypeError("Cannot " + msg);
|
4301
4363
|
};
|
4302
|
-
var __privateGet$
|
4364
|
+
var __privateGet$1 = (obj, member, getter) => {
|
4303
4365
|
__accessCheck$2(obj, member, "read from private field");
|
4304
4366
|
return getter ? getter.call(obj) : member.get(obj);
|
4305
4367
|
};
|
@@ -4308,18 +4370,11 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
4308
4370
|
throw TypeError("Cannot add the same private member more than once");
|
4309
4371
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
4310
4372
|
};
|
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;
|
4373
|
+
var _tables;
|
4317
4374
|
class SchemaPlugin extends XataPlugin {
|
4318
|
-
constructor(
|
4375
|
+
constructor() {
|
4319
4376
|
super();
|
4320
4377
|
__privateAdd$2(this, _tables, {});
|
4321
|
-
__privateAdd$2(this, _schemaTables$1, void 0);
|
4322
|
-
__privateSet$2(this, _schemaTables$1, schemaTables);
|
4323
4378
|
}
|
4324
4379
|
build(pluginOptions) {
|
4325
4380
|
const db = new Proxy(
|
@@ -4328,22 +4383,21 @@ class SchemaPlugin extends XataPlugin {
|
|
4328
4383
|
get: (_target, table) => {
|
4329
4384
|
if (!isString(table))
|
4330
4385
|
throw new Error("Invalid table name");
|
4331
|
-
if (__privateGet$
|
4332
|
-
__privateGet$
|
4386
|
+
if (__privateGet$1(this, _tables)[table] === void 0) {
|
4387
|
+
__privateGet$1(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
|
4333
4388
|
}
|
4334
|
-
return __privateGet$
|
4389
|
+
return __privateGet$1(this, _tables)[table];
|
4335
4390
|
}
|
4336
4391
|
}
|
4337
4392
|
);
|
4338
|
-
const tableNames =
|
4393
|
+
const tableNames = pluginOptions.tables?.map(({ name }) => name) ?? [];
|
4339
4394
|
for (const table of tableNames) {
|
4340
|
-
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables:
|
4395
|
+
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
|
4341
4396
|
}
|
4342
4397
|
return db;
|
4343
4398
|
}
|
4344
4399
|
}
|
4345
4400
|
_tables = new WeakMap();
|
4346
|
-
_schemaTables$1 = new WeakMap();
|
4347
4401
|
|
4348
4402
|
class FilesPlugin extends XataPlugin {
|
4349
4403
|
build(pluginOptions) {
|
@@ -4423,54 +4477,40 @@ var __accessCheck$1 = (obj, member, msg) => {
|
|
4423
4477
|
if (!member.has(obj))
|
4424
4478
|
throw TypeError("Cannot " + msg);
|
4425
4479
|
};
|
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
4480
|
var __privateAdd$1 = (obj, member, value) => {
|
4431
4481
|
if (member.has(obj))
|
4432
4482
|
throw TypeError("Cannot add the same private member more than once");
|
4433
4483
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
4434
4484
|
};
|
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
4485
|
var __privateMethod$1 = (obj, member, method) => {
|
4441
4486
|
__accessCheck$1(obj, member, "access private method");
|
4442
4487
|
return method;
|
4443
4488
|
};
|
4444
|
-
var
|
4489
|
+
var _search, search_fn;
|
4445
4490
|
class SearchPlugin extends XataPlugin {
|
4446
|
-
constructor(db
|
4491
|
+
constructor(db) {
|
4447
4492
|
super();
|
4448
4493
|
this.db = db;
|
4449
4494
|
__privateAdd$1(this, _search);
|
4450
|
-
__privateAdd$1(this, _getSchemaTables);
|
4451
|
-
__privateAdd$1(this, _schemaTables, void 0);
|
4452
|
-
__privateSet$1(this, _schemaTables, schemaTables);
|
4453
4495
|
}
|
4454
4496
|
build(pluginOptions) {
|
4455
4497
|
return {
|
4456
4498
|
all: async (query, options = {}) => {
|
4457
4499
|
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
4500
|
return {
|
4460
4501
|
totalCount,
|
4461
4502
|
records: records.map((record) => {
|
4462
4503
|
const { table = "orphan" } = record.xata;
|
4463
|
-
return { table, record: initObject(this.db,
|
4504
|
+
return { table, record: initObject(this.db, pluginOptions.tables, table, record, ["*"]) };
|
4464
4505
|
})
|
4465
4506
|
};
|
4466
4507
|
},
|
4467
4508
|
byTable: async (query, options = {}) => {
|
4468
4509
|
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
4510
|
const records = rawRecords.reduce((acc, record) => {
|
4471
4511
|
const { table = "orphan" } = record.xata;
|
4472
4512
|
const items = acc[table] ?? [];
|
4473
|
-
const item = initObject(this.db,
|
4513
|
+
const item = initObject(this.db, pluginOptions.tables, table, record, ["*"]);
|
4474
4514
|
return { ...acc, [table]: [...items, item] };
|
4475
4515
|
}, {});
|
4476
4516
|
return { totalCount, records };
|
@@ -4478,29 +4518,17 @@ class SearchPlugin extends XataPlugin {
|
|
4478
4518
|
};
|
4479
4519
|
}
|
4480
4520
|
}
|
4481
|
-
_schemaTables = new WeakMap();
|
4482
4521
|
_search = new WeakSet();
|
4483
4522
|
search_fn = async function(query, options, pluginOptions) {
|
4484
4523
|
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
4485
4524
|
const { records, totalCount } = await searchBranch({
|
4486
4525
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4487
|
-
// @ts-
|
4526
|
+
// @ts-expect-error Filter properties do not match inferred type
|
4488
4527
|
body: { tables, query, fuzziness, prefix, highlight, page },
|
4489
4528
|
...pluginOptions
|
4490
4529
|
});
|
4491
4530
|
return { records, totalCount };
|
4492
4531
|
};
|
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
4532
|
|
4505
4533
|
function escapeElement(elementRepresentation) {
|
4506
4534
|
const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
@@ -4623,7 +4651,7 @@ var __privateMethod = (obj, member, method) => {
|
|
4623
4651
|
const buildClient = (plugins) => {
|
4624
4652
|
var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
|
4625
4653
|
return _a = class {
|
4626
|
-
constructor(options = {},
|
4654
|
+
constructor(options = {}, tables) {
|
4627
4655
|
__privateAdd(this, _parseOptions);
|
4628
4656
|
__privateAdd(this, _getFetchProps);
|
4629
4657
|
__privateAdd(this, _options, void 0);
|
@@ -4632,13 +4660,15 @@ const buildClient = (plugins) => {
|
|
4632
4660
|
const pluginOptions = {
|
4633
4661
|
...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
4634
4662
|
cache: safeOptions.cache,
|
4635
|
-
host: safeOptions.host
|
4663
|
+
host: safeOptions.host,
|
4664
|
+
tables
|
4636
4665
|
};
|
4637
|
-
const db = new SchemaPlugin(
|
4638
|
-
const search = new SearchPlugin(db
|
4666
|
+
const db = new SchemaPlugin().build(pluginOptions);
|
4667
|
+
const search = new SearchPlugin(db).build(pluginOptions);
|
4639
4668
|
const transactions = new TransactionPlugin().build(pluginOptions);
|
4640
4669
|
const sql = new SQLPlugin().build(pluginOptions);
|
4641
4670
|
const files = new FilesPlugin().build(pluginOptions);
|
4671
|
+
this.schema = { tables };
|
4642
4672
|
this.db = db;
|
4643
4673
|
this.search = search;
|
4644
4674
|
this.transactions = transactions;
|
@@ -4814,5 +4844,5 @@ class XataError extends Error {
|
|
4814
4844
|
}
|
4815
4845
|
}
|
4816
4846
|
|
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, pgRollJobStatus, pgRollMigrationHistory, pgRollStatus, 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, updateMigrationRequest, updateOAuthAccessToken, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
|
4847
|
+
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, 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, pgRollJobStatus, pgRollMigrationHistory, pgRollStatus, 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, updateMigrationRequest, updateOAuthAccessToken, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
|
4818
4848
|
//# sourceMappingURL=index.mjs.map
|