@xata.io/client 0.0.0-alpha.vf38f30b → 0.0.0-alpha.vf6c3bd7
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/.eslintrc.cjs +1 -2
- package/CHANGELOG.md +76 -0
- package/dist/index.cjs +547 -222
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +559 -123
- package/dist/index.mjs +541 -223
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -2
- package/tsconfig.json +1 -0
package/dist/index.mjs
CHANGED
@@ -7,8 +7,18 @@ function compact(arr) {
|
|
7
7
|
function isObject(value) {
|
8
8
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
9
9
|
}
|
10
|
+
function isDefined(value) {
|
11
|
+
return value !== null && value !== void 0;
|
12
|
+
}
|
10
13
|
function isString(value) {
|
11
|
-
return value
|
14
|
+
return isDefined(value) && typeof value === "string";
|
15
|
+
}
|
16
|
+
function toBase64(value) {
|
17
|
+
try {
|
18
|
+
return btoa(value);
|
19
|
+
} catch (err) {
|
20
|
+
return Buffer.from(value).toString("base64");
|
21
|
+
}
|
12
22
|
}
|
13
23
|
|
14
24
|
function getEnvVariable(name) {
|
@@ -27,7 +37,10 @@ function getEnvVariable(name) {
|
|
27
37
|
}
|
28
38
|
async function getGitBranch() {
|
29
39
|
try {
|
30
|
-
|
40
|
+
if (typeof require === "function") {
|
41
|
+
const req = require;
|
42
|
+
return req("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
|
43
|
+
}
|
31
44
|
} catch (err) {
|
32
45
|
}
|
33
46
|
try {
|
@@ -60,7 +73,12 @@ function getFetchImplementation(userFetch) {
|
|
60
73
|
return fetchImpl;
|
61
74
|
}
|
62
75
|
|
63
|
-
class
|
76
|
+
class ErrorWithCause extends Error {
|
77
|
+
constructor(message, options) {
|
78
|
+
super(message, options);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
class FetcherError extends ErrorWithCause {
|
64
82
|
constructor(status, data) {
|
65
83
|
super(getMessage(data));
|
66
84
|
this.status = status;
|
@@ -241,6 +259,14 @@ const deleteDatabase = (variables) => fetch$1({
|
|
241
259
|
method: "delete",
|
242
260
|
...variables
|
243
261
|
});
|
262
|
+
const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
|
263
|
+
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
264
|
+
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
265
|
+
const resolveBranch = (variables) => fetch$1({
|
266
|
+
url: "/dbs/{dbName}/resolveBranch",
|
267
|
+
method: "get",
|
268
|
+
...variables
|
269
|
+
});
|
244
270
|
const getBranchDetails = (variables) => fetch$1({
|
245
271
|
url: "/db/{dbBranchName}",
|
246
272
|
method: "get",
|
@@ -348,6 +374,11 @@ const queryTable = (variables) => fetch$1({
|
|
348
374
|
method: "post",
|
349
375
|
...variables
|
350
376
|
});
|
377
|
+
const searchTable = (variables) => fetch$1({
|
378
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
379
|
+
method: "post",
|
380
|
+
...variables
|
381
|
+
});
|
351
382
|
const searchBranch = (variables) => fetch$1({
|
352
383
|
url: "/db/{dbBranchName}/search",
|
353
384
|
method: "post",
|
@@ -369,7 +400,15 @@ const operationsByTag = {
|
|
369
400
|
resendWorkspaceMemberInvite,
|
370
401
|
acceptWorkspaceMemberInvite
|
371
402
|
},
|
372
|
-
database: {
|
403
|
+
database: {
|
404
|
+
getDatabaseList,
|
405
|
+
createDatabase,
|
406
|
+
deleteDatabase,
|
407
|
+
getGitBranchesMapping,
|
408
|
+
addGitBranchesEntry,
|
409
|
+
removeGitBranchesEntry,
|
410
|
+
resolveBranch
|
411
|
+
},
|
373
412
|
branch: {
|
374
413
|
getBranchList,
|
375
414
|
getBranchDetails,
|
@@ -403,6 +442,7 @@ const operationsByTag = {
|
|
403
442
|
getRecord,
|
404
443
|
bulkInsertTableRecords,
|
405
444
|
queryTable,
|
445
|
+
searchTable,
|
406
446
|
searchBranch
|
407
447
|
}
|
408
448
|
};
|
@@ -432,35 +472,35 @@ function isValidBuilder(builder) {
|
|
432
472
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
433
473
|
}
|
434
474
|
|
435
|
-
var __accessCheck$
|
475
|
+
var __accessCheck$7 = (obj, member, msg) => {
|
436
476
|
if (!member.has(obj))
|
437
477
|
throw TypeError("Cannot " + msg);
|
438
478
|
};
|
439
|
-
var __privateGet$
|
440
|
-
__accessCheck$
|
479
|
+
var __privateGet$7 = (obj, member, getter) => {
|
480
|
+
__accessCheck$7(obj, member, "read from private field");
|
441
481
|
return getter ? getter.call(obj) : member.get(obj);
|
442
482
|
};
|
443
|
-
var __privateAdd$
|
483
|
+
var __privateAdd$7 = (obj, member, value) => {
|
444
484
|
if (member.has(obj))
|
445
485
|
throw TypeError("Cannot add the same private member more than once");
|
446
486
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
447
487
|
};
|
448
|
-
var __privateSet$
|
449
|
-
__accessCheck$
|
488
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
489
|
+
__accessCheck$7(obj, member, "write to private field");
|
450
490
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
451
491
|
return value;
|
452
492
|
};
|
453
493
|
var _extraProps, _namespaces;
|
454
494
|
class XataApiClient {
|
455
495
|
constructor(options = {}) {
|
456
|
-
__privateAdd$
|
457
|
-
__privateAdd$
|
496
|
+
__privateAdd$7(this, _extraProps, void 0);
|
497
|
+
__privateAdd$7(this, _namespaces, {});
|
458
498
|
const provider = options.host ?? "production";
|
459
499
|
const apiKey = options?.apiKey ?? getAPIKey();
|
460
500
|
if (!apiKey) {
|
461
501
|
throw new Error("Could not resolve a valid apiKey");
|
462
502
|
}
|
463
|
-
__privateSet$
|
503
|
+
__privateSet$6(this, _extraProps, {
|
464
504
|
apiUrl: getHostUrl(provider, "main"),
|
465
505
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
466
506
|
fetchImpl: getFetchImplementation(options.fetch),
|
@@ -468,34 +508,34 @@ class XataApiClient {
|
|
468
508
|
});
|
469
509
|
}
|
470
510
|
get user() {
|
471
|
-
if (!__privateGet$
|
472
|
-
__privateGet$
|
473
|
-
return __privateGet$
|
511
|
+
if (!__privateGet$7(this, _namespaces).user)
|
512
|
+
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
513
|
+
return __privateGet$7(this, _namespaces).user;
|
474
514
|
}
|
475
515
|
get workspaces() {
|
476
|
-
if (!__privateGet$
|
477
|
-
__privateGet$
|
478
|
-
return __privateGet$
|
516
|
+
if (!__privateGet$7(this, _namespaces).workspaces)
|
517
|
+
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
518
|
+
return __privateGet$7(this, _namespaces).workspaces;
|
479
519
|
}
|
480
520
|
get databases() {
|
481
|
-
if (!__privateGet$
|
482
|
-
__privateGet$
|
483
|
-
return __privateGet$
|
521
|
+
if (!__privateGet$7(this, _namespaces).databases)
|
522
|
+
__privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
|
523
|
+
return __privateGet$7(this, _namespaces).databases;
|
484
524
|
}
|
485
525
|
get branches() {
|
486
|
-
if (!__privateGet$
|
487
|
-
__privateGet$
|
488
|
-
return __privateGet$
|
526
|
+
if (!__privateGet$7(this, _namespaces).branches)
|
527
|
+
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
528
|
+
return __privateGet$7(this, _namespaces).branches;
|
489
529
|
}
|
490
530
|
get tables() {
|
491
|
-
if (!__privateGet$
|
492
|
-
__privateGet$
|
493
|
-
return __privateGet$
|
531
|
+
if (!__privateGet$7(this, _namespaces).tables)
|
532
|
+
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
533
|
+
return __privateGet$7(this, _namespaces).tables;
|
494
534
|
}
|
495
535
|
get records() {
|
496
|
-
if (!__privateGet$
|
497
|
-
__privateGet$
|
498
|
-
return __privateGet$
|
536
|
+
if (!__privateGet$7(this, _namespaces).records)
|
537
|
+
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
538
|
+
return __privateGet$7(this, _namespaces).records;
|
499
539
|
}
|
500
540
|
}
|
501
541
|
_extraProps = new WeakMap();
|
@@ -629,6 +669,33 @@ class DatabaseApi {
|
|
629
669
|
...this.extraProps
|
630
670
|
});
|
631
671
|
}
|
672
|
+
getGitBranchesMapping(workspace, dbName) {
|
673
|
+
return operationsByTag.database.getGitBranchesMapping({
|
674
|
+
pathParams: { workspace, dbName },
|
675
|
+
...this.extraProps
|
676
|
+
});
|
677
|
+
}
|
678
|
+
addGitBranchesEntry(workspace, dbName, body) {
|
679
|
+
return operationsByTag.database.addGitBranchesEntry({
|
680
|
+
pathParams: { workspace, dbName },
|
681
|
+
body,
|
682
|
+
...this.extraProps
|
683
|
+
});
|
684
|
+
}
|
685
|
+
removeGitBranchesEntry(workspace, dbName, gitBranch) {
|
686
|
+
return operationsByTag.database.removeGitBranchesEntry({
|
687
|
+
pathParams: { workspace, dbName },
|
688
|
+
queryParams: { gitBranch },
|
689
|
+
...this.extraProps
|
690
|
+
});
|
691
|
+
}
|
692
|
+
resolveBranch(workspace, dbName, gitBranch) {
|
693
|
+
return operationsByTag.database.resolveBranch({
|
694
|
+
pathParams: { workspace, dbName },
|
695
|
+
queryParams: { gitBranch },
|
696
|
+
...this.extraProps
|
697
|
+
});
|
698
|
+
}
|
632
699
|
}
|
633
700
|
class BranchApi {
|
634
701
|
constructor(extraProps) {
|
@@ -646,10 +713,10 @@ class BranchApi {
|
|
646
713
|
...this.extraProps
|
647
714
|
});
|
648
715
|
}
|
649
|
-
createBranch(workspace, database, branch, from
|
716
|
+
createBranch(workspace, database, branch, from, options = {}) {
|
650
717
|
return operationsByTag.branch.createBranch({
|
651
718
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
652
|
-
queryParams: { from },
|
719
|
+
queryParams: isString(from) ? { from } : void 0,
|
653
720
|
body: options,
|
654
721
|
...this.extraProps
|
655
722
|
});
|
@@ -831,6 +898,13 @@ class RecordsApi {
|
|
831
898
|
...this.extraProps
|
832
899
|
});
|
833
900
|
}
|
901
|
+
searchTable(workspace, database, branch, tableName, query) {
|
902
|
+
return operationsByTag.records.searchTable({
|
903
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
904
|
+
body: query,
|
905
|
+
...this.extraProps
|
906
|
+
});
|
907
|
+
}
|
834
908
|
searchBranch(workspace, database, branch, query) {
|
835
909
|
return operationsByTag.records.searchBranch({
|
836
910
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
@@ -850,43 +924,43 @@ class XataApiPlugin {
|
|
850
924
|
class XataPlugin {
|
851
925
|
}
|
852
926
|
|
853
|
-
var __accessCheck$
|
927
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
854
928
|
if (!member.has(obj))
|
855
929
|
throw TypeError("Cannot " + msg);
|
856
930
|
};
|
857
|
-
var __privateGet$
|
858
|
-
__accessCheck$
|
931
|
+
var __privateGet$6 = (obj, member, getter) => {
|
932
|
+
__accessCheck$6(obj, member, "read from private field");
|
859
933
|
return getter ? getter.call(obj) : member.get(obj);
|
860
934
|
};
|
861
|
-
var __privateAdd$
|
935
|
+
var __privateAdd$6 = (obj, member, value) => {
|
862
936
|
if (member.has(obj))
|
863
937
|
throw TypeError("Cannot add the same private member more than once");
|
864
938
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
865
939
|
};
|
866
|
-
var __privateSet$
|
867
|
-
__accessCheck$
|
940
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
941
|
+
__accessCheck$6(obj, member, "write to private field");
|
868
942
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
869
943
|
return value;
|
870
944
|
};
|
871
945
|
var _query;
|
872
946
|
class Page {
|
873
947
|
constructor(query, meta, records = []) {
|
874
|
-
__privateAdd$
|
875
|
-
__privateSet$
|
948
|
+
__privateAdd$6(this, _query, void 0);
|
949
|
+
__privateSet$5(this, _query, query);
|
876
950
|
this.meta = meta;
|
877
951
|
this.records = records;
|
878
952
|
}
|
879
953
|
async nextPage(size, offset) {
|
880
|
-
return __privateGet$
|
954
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
881
955
|
}
|
882
956
|
async previousPage(size, offset) {
|
883
|
-
return __privateGet$
|
957
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
884
958
|
}
|
885
959
|
async firstPage(size, offset) {
|
886
|
-
return __privateGet$
|
960
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
|
887
961
|
}
|
888
962
|
async lastPage(size, offset) {
|
889
|
-
return __privateGet$
|
963
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
|
890
964
|
}
|
891
965
|
hasNextPage() {
|
892
966
|
return this.meta.page.more;
|
@@ -897,47 +971,52 @@ const PAGINATION_MAX_SIZE = 200;
|
|
897
971
|
const PAGINATION_DEFAULT_SIZE = 200;
|
898
972
|
const PAGINATION_MAX_OFFSET = 800;
|
899
973
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
974
|
+
function isCursorPaginationOptions(options) {
|
975
|
+
return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
|
976
|
+
}
|
900
977
|
|
901
|
-
var __accessCheck$
|
978
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
902
979
|
if (!member.has(obj))
|
903
980
|
throw TypeError("Cannot " + msg);
|
904
981
|
};
|
905
|
-
var __privateGet$
|
906
|
-
__accessCheck$
|
982
|
+
var __privateGet$5 = (obj, member, getter) => {
|
983
|
+
__accessCheck$5(obj, member, "read from private field");
|
907
984
|
return getter ? getter.call(obj) : member.get(obj);
|
908
985
|
};
|
909
|
-
var __privateAdd$
|
986
|
+
var __privateAdd$5 = (obj, member, value) => {
|
910
987
|
if (member.has(obj))
|
911
988
|
throw TypeError("Cannot add the same private member more than once");
|
912
989
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
913
990
|
};
|
914
|
-
var __privateSet$
|
915
|
-
__accessCheck$
|
991
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
992
|
+
__accessCheck$5(obj, member, "write to private field");
|
916
993
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
917
994
|
return value;
|
918
995
|
};
|
919
996
|
var _table$1, _repository, _data;
|
920
997
|
const _Query = class {
|
921
|
-
constructor(repository, table, data,
|
922
|
-
__privateAdd$
|
923
|
-
__privateAdd$
|
924
|
-
__privateAdd$
|
998
|
+
constructor(repository, table, data, rawParent) {
|
999
|
+
__privateAdd$5(this, _table$1, void 0);
|
1000
|
+
__privateAdd$5(this, _repository, void 0);
|
1001
|
+
__privateAdd$5(this, _data, { filter: {} });
|
925
1002
|
this.meta = { page: { cursor: "start", more: true } };
|
926
1003
|
this.records = [];
|
927
|
-
__privateSet$
|
1004
|
+
__privateSet$4(this, _table$1, table);
|
928
1005
|
if (repository) {
|
929
|
-
__privateSet$
|
1006
|
+
__privateSet$4(this, _repository, repository);
|
930
1007
|
} else {
|
931
|
-
__privateSet$
|
1008
|
+
__privateSet$4(this, _repository, this);
|
932
1009
|
}
|
933
|
-
|
934
|
-
__privateGet$
|
935
|
-
__privateGet$
|
936
|
-
__privateGet$
|
937
|
-
__privateGet$
|
938
|
-
__privateGet$
|
939
|
-
__privateGet$
|
940
|
-
__privateGet$
|
1010
|
+
const parent = cleanParent(data, rawParent);
|
1011
|
+
__privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
1012
|
+
__privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
|
1013
|
+
__privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
|
1014
|
+
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
1015
|
+
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
1016
|
+
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
1017
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
|
1018
|
+
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
1019
|
+
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
941
1020
|
this.any = this.any.bind(this);
|
942
1021
|
this.all = this.all.bind(this);
|
943
1022
|
this.not = this.not.bind(this);
|
@@ -948,75 +1027,85 @@ const _Query = class {
|
|
948
1027
|
Object.defineProperty(this, "repository", { enumerable: false });
|
949
1028
|
}
|
950
1029
|
getQueryOptions() {
|
951
|
-
return __privateGet$
|
1030
|
+
return __privateGet$5(this, _data);
|
1031
|
+
}
|
1032
|
+
key() {
|
1033
|
+
const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$5(this, _data);
|
1034
|
+
const key = JSON.stringify({ columns, filter, sort, pagination });
|
1035
|
+
return toBase64(key);
|
952
1036
|
}
|
953
1037
|
any(...queries) {
|
954
1038
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
955
|
-
return new _Query(__privateGet$
|
1039
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
956
1040
|
}
|
957
1041
|
all(...queries) {
|
958
1042
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
959
|
-
return new _Query(__privateGet$
|
1043
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
960
1044
|
}
|
961
1045
|
not(...queries) {
|
962
1046
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
963
|
-
return new _Query(__privateGet$
|
1047
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
964
1048
|
}
|
965
1049
|
none(...queries) {
|
966
1050
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
967
|
-
return new _Query(__privateGet$
|
1051
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
968
1052
|
}
|
969
1053
|
filter(a, b) {
|
970
1054
|
if (arguments.length === 1) {
|
971
1055
|
const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
|
972
|
-
const $all = compact([__privateGet$
|
973
|
-
return new _Query(__privateGet$
|
1056
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1057
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
974
1058
|
} else {
|
975
|
-
const $all = compact([__privateGet$
|
976
|
-
return new _Query(__privateGet$
|
1059
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
|
1060
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
977
1061
|
}
|
978
1062
|
}
|
979
1063
|
sort(column, direction) {
|
980
|
-
const originalSort = [__privateGet$
|
1064
|
+
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
981
1065
|
const sort = [...originalSort, { column, direction }];
|
982
|
-
return new _Query(__privateGet$
|
1066
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
983
1067
|
}
|
984
1068
|
select(columns) {
|
985
|
-
return new _Query(__privateGet$
|
1069
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { columns }, __privateGet$5(this, _data));
|
986
1070
|
}
|
987
1071
|
getPaginated(options = {}) {
|
988
|
-
const query = new _Query(__privateGet$
|
989
|
-
return __privateGet$
|
1072
|
+
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
1073
|
+
return __privateGet$5(this, _repository).query(query);
|
990
1074
|
}
|
991
1075
|
async *[Symbol.asyncIterator]() {
|
992
|
-
for await (const [record] of this.getIterator(1)) {
|
1076
|
+
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
993
1077
|
yield record;
|
994
1078
|
}
|
995
1079
|
}
|
996
|
-
async *getIterator(
|
997
|
-
|
998
|
-
let
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1080
|
+
async *getIterator(options = {}) {
|
1081
|
+
const { batchSize = 1 } = options;
|
1082
|
+
let page = await this.getPaginated({ ...options, pagination: { size: batchSize, offset: 0 } });
|
1083
|
+
let more = page.hasNextPage();
|
1084
|
+
yield page.records;
|
1085
|
+
while (more) {
|
1086
|
+
page = await page.nextPage();
|
1087
|
+
more = page.hasNextPage();
|
1088
|
+
yield page.records;
|
1004
1089
|
}
|
1005
1090
|
}
|
1006
1091
|
async getMany(options = {}) {
|
1007
1092
|
const { records } = await this.getPaginated(options);
|
1008
1093
|
return records;
|
1009
1094
|
}
|
1010
|
-
async getAll(
|
1095
|
+
async getAll(options = {}) {
|
1096
|
+
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
1011
1097
|
const results = [];
|
1012
|
-
for await (const page of this.getIterator(
|
1098
|
+
for await (const page of this.getIterator({ ...rest, batchSize })) {
|
1013
1099
|
results.push(...page);
|
1014
1100
|
}
|
1015
1101
|
return results;
|
1016
1102
|
}
|
1017
|
-
async
|
1018
|
-
const records = await this.getMany({ ...options,
|
1019
|
-
return records[0]
|
1103
|
+
async getFirst(options = {}) {
|
1104
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1105
|
+
return records[0] ?? null;
|
1106
|
+
}
|
1107
|
+
cache(ttl) {
|
1108
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1020
1109
|
}
|
1021
1110
|
nextPage(size, offset) {
|
1022
1111
|
return this.firstPage(size, offset);
|
@@ -1025,10 +1114,10 @@ const _Query = class {
|
|
1025
1114
|
return this.firstPage(size, offset);
|
1026
1115
|
}
|
1027
1116
|
firstPage(size, offset) {
|
1028
|
-
return this.getPaginated({
|
1117
|
+
return this.getPaginated({ pagination: { size, offset } });
|
1029
1118
|
}
|
1030
1119
|
lastPage(size, offset) {
|
1031
|
-
return this.getPaginated({
|
1120
|
+
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
1032
1121
|
}
|
1033
1122
|
hasNextPage() {
|
1034
1123
|
return this.meta.page.more;
|
@@ -1038,6 +1127,12 @@ let Query = _Query;
|
|
1038
1127
|
_table$1 = new WeakMap();
|
1039
1128
|
_repository = new WeakMap();
|
1040
1129
|
_data = new WeakMap();
|
1130
|
+
function cleanParent(data, parent) {
|
1131
|
+
if (isCursorPaginationOptions(data.pagination)) {
|
1132
|
+
return { ...parent, sorting: void 0, filter: void 0 };
|
1133
|
+
}
|
1134
|
+
return parent;
|
1135
|
+
}
|
1041
1136
|
|
1042
1137
|
function isIdentifiable(x) {
|
1043
1138
|
return isObject(x) && isString(x?.id);
|
@@ -1069,169 +1164,229 @@ function buildSortFilter(filter) {
|
|
1069
1164
|
}
|
1070
1165
|
}
|
1071
1166
|
|
1072
|
-
var __accessCheck$
|
1167
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
1073
1168
|
if (!member.has(obj))
|
1074
1169
|
throw TypeError("Cannot " + msg);
|
1075
1170
|
};
|
1076
|
-
var __privateGet$
|
1077
|
-
__accessCheck$
|
1171
|
+
var __privateGet$4 = (obj, member, getter) => {
|
1172
|
+
__accessCheck$4(obj, member, "read from private field");
|
1078
1173
|
return getter ? getter.call(obj) : member.get(obj);
|
1079
1174
|
};
|
1080
|
-
var __privateAdd$
|
1175
|
+
var __privateAdd$4 = (obj, member, value) => {
|
1081
1176
|
if (member.has(obj))
|
1082
1177
|
throw TypeError("Cannot add the same private member more than once");
|
1083
1178
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1084
1179
|
};
|
1085
|
-
var __privateSet$
|
1086
|
-
__accessCheck$
|
1180
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
1181
|
+
__accessCheck$4(obj, member, "write to private field");
|
1087
1182
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1088
1183
|
return value;
|
1089
1184
|
};
|
1090
1185
|
var __privateMethod$2 = (obj, member, method) => {
|
1091
|
-
__accessCheck$
|
1186
|
+
__accessCheck$4(obj, member, "access private method");
|
1092
1187
|
return method;
|
1093
1188
|
};
|
1094
|
-
var _table,
|
1189
|
+
var _table, _getFetchProps, _cache, _schema$1, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _invalidateCache, invalidateCache_fn, _setCacheRecord, setCacheRecord_fn, _getCacheRecord, getCacheRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchema$1, getSchema_fn$1;
|
1095
1190
|
class Repository extends Query {
|
1096
1191
|
}
|
1097
1192
|
class RestRepository extends Query {
|
1098
1193
|
constructor(options) {
|
1099
1194
|
super(null, options.table, {});
|
1100
|
-
__privateAdd$
|
1101
|
-
__privateAdd$
|
1102
|
-
__privateAdd$
|
1103
|
-
__privateAdd$
|
1104
|
-
__privateAdd$
|
1105
|
-
__privateAdd$
|
1106
|
-
__privateAdd$
|
1107
|
-
__privateAdd$
|
1108
|
-
__privateAdd$
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1195
|
+
__privateAdd$4(this, _insertRecordWithoutId);
|
1196
|
+
__privateAdd$4(this, _insertRecordWithId);
|
1197
|
+
__privateAdd$4(this, _bulkInsertTableRecords);
|
1198
|
+
__privateAdd$4(this, _updateRecordWithID);
|
1199
|
+
__privateAdd$4(this, _upsertRecordWithID);
|
1200
|
+
__privateAdd$4(this, _deleteRecord);
|
1201
|
+
__privateAdd$4(this, _invalidateCache);
|
1202
|
+
__privateAdd$4(this, _setCacheRecord);
|
1203
|
+
__privateAdd$4(this, _getCacheRecord);
|
1204
|
+
__privateAdd$4(this, _setCacheQuery);
|
1205
|
+
__privateAdd$4(this, _getCacheQuery);
|
1206
|
+
__privateAdd$4(this, _getSchema$1);
|
1207
|
+
__privateAdd$4(this, _table, void 0);
|
1208
|
+
__privateAdd$4(this, _getFetchProps, void 0);
|
1209
|
+
__privateAdd$4(this, _cache, void 0);
|
1210
|
+
__privateAdd$4(this, _schema$1, void 0);
|
1211
|
+
__privateSet$3(this, _table, options.table);
|
1212
|
+
__privateSet$3(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1112
1213
|
this.db = options.db;
|
1214
|
+
__privateSet$3(this, _cache, options.pluginOptions.cache);
|
1113
1215
|
}
|
1114
1216
|
async create(a, b) {
|
1115
1217
|
if (Array.isArray(a)) {
|
1116
|
-
|
1218
|
+
if (a.length === 0)
|
1219
|
+
return [];
|
1220
|
+
const records = await __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a);
|
1221
|
+
await Promise.all(records.map((record) => __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record)));
|
1222
|
+
return records;
|
1117
1223
|
}
|
1118
1224
|
if (isString(a) && isObject(b)) {
|
1119
1225
|
if (a === "")
|
1120
1226
|
throw new Error("The id can't be empty");
|
1121
|
-
|
1227
|
+
const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b);
|
1228
|
+
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1229
|
+
return record;
|
1122
1230
|
}
|
1123
1231
|
if (isObject(a) && isString(a.id)) {
|
1124
1232
|
if (a.id === "")
|
1125
1233
|
throw new Error("The id can't be empty");
|
1126
|
-
|
1234
|
+
const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 });
|
1235
|
+
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1236
|
+
return record;
|
1127
1237
|
}
|
1128
1238
|
if (isObject(a)) {
|
1129
|
-
|
1239
|
+
const record = await __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a);
|
1240
|
+
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1241
|
+
return record;
|
1130
1242
|
}
|
1131
1243
|
throw new Error("Invalid arguments for create method");
|
1132
1244
|
}
|
1133
|
-
async read(
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1245
|
+
async read(a) {
|
1246
|
+
if (Array.isArray(a)) {
|
1247
|
+
if (a.length === 0)
|
1248
|
+
return [];
|
1249
|
+
return this.getAll({ filter: { id: { $any: a } } });
|
1250
|
+
}
|
1251
|
+
if (isString(a)) {
|
1252
|
+
const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, a);
|
1253
|
+
if (cacheRecord)
|
1254
|
+
return cacheRecord;
|
1255
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1256
|
+
try {
|
1257
|
+
const response = await getRecord({
|
1258
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: a },
|
1259
|
+
...fetchProps
|
1260
|
+
});
|
1261
|
+
const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
|
1262
|
+
return initObject(this.db, schema, __privateGet$4(this, _table), response);
|
1263
|
+
} catch (e) {
|
1264
|
+
if (isObject(e) && e.status === 404) {
|
1265
|
+
return null;
|
1266
|
+
}
|
1267
|
+
throw e;
|
1144
1268
|
}
|
1145
|
-
throw e;
|
1146
1269
|
}
|
1147
1270
|
}
|
1148
1271
|
async update(a, b) {
|
1149
1272
|
if (Array.isArray(a)) {
|
1273
|
+
if (a.length === 0)
|
1274
|
+
return [];
|
1150
1275
|
if (a.length > 100) {
|
1151
1276
|
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1152
1277
|
}
|
1153
1278
|
return Promise.all(a.map((object) => this.update(object)));
|
1154
1279
|
}
|
1155
1280
|
if (isString(a) && isObject(b)) {
|
1156
|
-
|
1281
|
+
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
|
1282
|
+
const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b);
|
1283
|
+
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1284
|
+
return record;
|
1157
1285
|
}
|
1158
1286
|
if (isObject(a) && isString(a.id)) {
|
1159
|
-
|
1287
|
+
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
|
1288
|
+
const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
|
1289
|
+
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1290
|
+
return record;
|
1160
1291
|
}
|
1161
1292
|
throw new Error("Invalid arguments for update method");
|
1162
1293
|
}
|
1163
1294
|
async createOrUpdate(a, b) {
|
1164
1295
|
if (Array.isArray(a)) {
|
1296
|
+
if (a.length === 0)
|
1297
|
+
return [];
|
1165
1298
|
if (a.length > 100) {
|
1166
1299
|
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1167
1300
|
}
|
1168
1301
|
return Promise.all(a.map((object) => this.createOrUpdate(object)));
|
1169
1302
|
}
|
1170
1303
|
if (isString(a) && isObject(b)) {
|
1171
|
-
|
1304
|
+
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
|
1305
|
+
const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b);
|
1306
|
+
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1307
|
+
return record;
|
1172
1308
|
}
|
1173
1309
|
if (isObject(a) && isString(a.id)) {
|
1174
|
-
|
1310
|
+
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
|
1311
|
+
const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
|
1312
|
+
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1313
|
+
return record;
|
1175
1314
|
}
|
1176
1315
|
throw new Error("Invalid arguments for createOrUpdate method");
|
1177
1316
|
}
|
1178
|
-
async delete(
|
1179
|
-
if (Array.isArray(
|
1180
|
-
if (
|
1317
|
+
async delete(a) {
|
1318
|
+
if (Array.isArray(a)) {
|
1319
|
+
if (a.length === 0)
|
1320
|
+
return;
|
1321
|
+
if (a.length > 100) {
|
1181
1322
|
console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
|
1182
1323
|
}
|
1183
|
-
await Promise.all(
|
1324
|
+
await Promise.all(a.map((id) => this.delete(id)));
|
1184
1325
|
return;
|
1185
1326
|
}
|
1186
|
-
if (isString(
|
1187
|
-
await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this,
|
1327
|
+
if (isString(a)) {
|
1328
|
+
await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
|
1329
|
+
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
|
1188
1330
|
return;
|
1189
1331
|
}
|
1190
|
-
if (isObject(
|
1191
|
-
await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this,
|
1332
|
+
if (isObject(a) && isString(a.id)) {
|
1333
|
+
await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
|
1334
|
+
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
|
1192
1335
|
return;
|
1193
1336
|
}
|
1194
1337
|
throw new Error("Invalid arguments for delete method");
|
1195
1338
|
}
|
1196
1339
|
async search(query, options = {}) {
|
1197
|
-
const fetchProps = await __privateGet$
|
1198
|
-
const { records } = await
|
1199
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1200
|
-
body: {
|
1340
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1341
|
+
const { records } = await searchTable({
|
1342
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1343
|
+
body: {
|
1344
|
+
query,
|
1345
|
+
fuzziness: options.fuzziness,
|
1346
|
+
highlight: options.highlight,
|
1347
|
+
filter: options.filter
|
1348
|
+
},
|
1201
1349
|
...fetchProps
|
1202
1350
|
});
|
1203
|
-
|
1351
|
+
const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
|
1352
|
+
return records.map((item) => initObject(this.db, schema, __privateGet$4(this, _table), item));
|
1204
1353
|
}
|
1205
1354
|
async query(query) {
|
1355
|
+
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
1356
|
+
if (cacheQuery)
|
1357
|
+
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
1206
1358
|
const data = query.getQueryOptions();
|
1207
1359
|
const body = {
|
1208
1360
|
filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
|
1209
|
-
sort: data.sort ? buildSortFilter(data.sort) : void 0,
|
1210
|
-
page: data.
|
1361
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1362
|
+
page: data.pagination,
|
1211
1363
|
columns: data.columns
|
1212
1364
|
};
|
1213
|
-
const fetchProps = await __privateGet$
|
1365
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1214
1366
|
const { meta, records: objects } = await queryTable({
|
1215
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1367
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1216
1368
|
body,
|
1217
1369
|
...fetchProps
|
1218
1370
|
});
|
1219
|
-
const
|
1371
|
+
const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
|
1372
|
+
const records = objects.map((record) => initObject(this.db, schema, __privateGet$4(this, _table), record));
|
1373
|
+
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1220
1374
|
return new Page(query, meta, records);
|
1221
1375
|
}
|
1222
1376
|
}
|
1223
1377
|
_table = new WeakMap();
|
1224
|
-
_links = new WeakMap();
|
1225
1378
|
_getFetchProps = new WeakMap();
|
1379
|
+
_cache = new WeakMap();
|
1380
|
+
_schema$1 = new WeakMap();
|
1226
1381
|
_insertRecordWithoutId = new WeakSet();
|
1227
1382
|
insertRecordWithoutId_fn = async function(object) {
|
1228
|
-
const fetchProps = await __privateGet$
|
1383
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1229
1384
|
const record = transformObjectLinks(object);
|
1230
1385
|
const response = await insertRecord({
|
1231
1386
|
pathParams: {
|
1232
1387
|
workspace: "{workspaceId}",
|
1233
1388
|
dbBranchName: "{dbBranch}",
|
1234
|
-
tableName: __privateGet$
|
1389
|
+
tableName: __privateGet$4(this, _table)
|
1235
1390
|
},
|
1236
1391
|
body: record,
|
1237
1392
|
...fetchProps
|
@@ -1244,13 +1399,13 @@ insertRecordWithoutId_fn = async function(object) {
|
|
1244
1399
|
};
|
1245
1400
|
_insertRecordWithId = new WeakSet();
|
1246
1401
|
insertRecordWithId_fn = async function(recordId, object) {
|
1247
|
-
const fetchProps = await __privateGet$
|
1402
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1248
1403
|
const record = transformObjectLinks(object);
|
1249
1404
|
const response = await insertRecordWithID({
|
1250
1405
|
pathParams: {
|
1251
1406
|
workspace: "{workspaceId}",
|
1252
1407
|
dbBranchName: "{dbBranch}",
|
1253
|
-
tableName: __privateGet$
|
1408
|
+
tableName: __privateGet$4(this, _table),
|
1254
1409
|
recordId
|
1255
1410
|
},
|
1256
1411
|
body: record,
|
@@ -1265,10 +1420,10 @@ insertRecordWithId_fn = async function(recordId, object) {
|
|
1265
1420
|
};
|
1266
1421
|
_bulkInsertTableRecords = new WeakSet();
|
1267
1422
|
bulkInsertTableRecords_fn = async function(objects) {
|
1268
|
-
const fetchProps = await __privateGet$
|
1423
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1269
1424
|
const records = objects.map((object) => transformObjectLinks(object));
|
1270
1425
|
const response = await bulkInsertTableRecords({
|
1271
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1426
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1272
1427
|
body: { records },
|
1273
1428
|
...fetchProps
|
1274
1429
|
});
|
@@ -1280,10 +1435,10 @@ bulkInsertTableRecords_fn = async function(objects) {
|
|
1280
1435
|
};
|
1281
1436
|
_updateRecordWithID = new WeakSet();
|
1282
1437
|
updateRecordWithID_fn = async function(recordId, object) {
|
1283
|
-
const fetchProps = await __privateGet$
|
1438
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1284
1439
|
const record = transformObjectLinks(object);
|
1285
1440
|
const response = await updateRecordWithID({
|
1286
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1441
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1287
1442
|
body: record,
|
1288
1443
|
...fetchProps
|
1289
1444
|
});
|
@@ -1294,9 +1449,9 @@ updateRecordWithID_fn = async function(recordId, object) {
|
|
1294
1449
|
};
|
1295
1450
|
_upsertRecordWithID = new WeakSet();
|
1296
1451
|
upsertRecordWithID_fn = async function(recordId, object) {
|
1297
|
-
const fetchProps = await __privateGet$
|
1452
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1298
1453
|
const response = await upsertRecordWithID({
|
1299
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1454
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1300
1455
|
body: object,
|
1301
1456
|
...fetchProps
|
1302
1457
|
});
|
@@ -1307,11 +1462,62 @@ upsertRecordWithID_fn = async function(recordId, object) {
|
|
1307
1462
|
};
|
1308
1463
|
_deleteRecord = new WeakSet();
|
1309
1464
|
deleteRecord_fn = async function(recordId) {
|
1310
|
-
const fetchProps = await __privateGet$
|
1465
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1311
1466
|
await deleteRecord({
|
1312
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1467
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1468
|
+
...fetchProps
|
1469
|
+
});
|
1470
|
+
};
|
1471
|
+
_invalidateCache = new WeakSet();
|
1472
|
+
invalidateCache_fn = async function(recordId) {
|
1473
|
+
await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
1474
|
+
const cacheItems = await __privateGet$4(this, _cache).getAll();
|
1475
|
+
const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
|
1476
|
+
for (const [key, value] of queries) {
|
1477
|
+
const ids = getIds(value);
|
1478
|
+
if (ids.includes(recordId))
|
1479
|
+
await __privateGet$4(this, _cache).delete(key);
|
1480
|
+
}
|
1481
|
+
};
|
1482
|
+
_setCacheRecord = new WeakSet();
|
1483
|
+
setCacheRecord_fn = async function(record) {
|
1484
|
+
if (!__privateGet$4(this, _cache).cacheRecords)
|
1485
|
+
return;
|
1486
|
+
await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
|
1487
|
+
};
|
1488
|
+
_getCacheRecord = new WeakSet();
|
1489
|
+
getCacheRecord_fn = async function(recordId) {
|
1490
|
+
if (!__privateGet$4(this, _cache).cacheRecords)
|
1491
|
+
return null;
|
1492
|
+
return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
1493
|
+
};
|
1494
|
+
_setCacheQuery = new WeakSet();
|
1495
|
+
setCacheQuery_fn = async function(query, meta, records) {
|
1496
|
+
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
1497
|
+
};
|
1498
|
+
_getCacheQuery = new WeakSet();
|
1499
|
+
getCacheQuery_fn = async function(query) {
|
1500
|
+
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
1501
|
+
const result = await __privateGet$4(this, _cache).get(key);
|
1502
|
+
if (!result)
|
1503
|
+
return null;
|
1504
|
+
const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
|
1505
|
+
if (ttl < 0)
|
1506
|
+
return null;
|
1507
|
+
const hasExpired = result.date.getTime() + ttl < Date.now();
|
1508
|
+
return hasExpired ? null : result;
|
1509
|
+
};
|
1510
|
+
_getSchema$1 = new WeakSet();
|
1511
|
+
getSchema_fn$1 = async function() {
|
1512
|
+
if (__privateGet$4(this, _schema$1))
|
1513
|
+
return __privateGet$4(this, _schema$1);
|
1514
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1515
|
+
const { schema } = await getBranchDetails({
|
1516
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1313
1517
|
...fetchProps
|
1314
1518
|
});
|
1519
|
+
__privateSet$3(this, _schema$1, schema);
|
1520
|
+
return schema;
|
1315
1521
|
};
|
1316
1522
|
const transformObjectLinks = (object) => {
|
1317
1523
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
@@ -1320,15 +1526,33 @@ const transformObjectLinks = (object) => {
|
|
1320
1526
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1321
1527
|
}, {});
|
1322
1528
|
};
|
1323
|
-
const initObject = (db,
|
1529
|
+
const initObject = (db, schema, table, object) => {
|
1324
1530
|
const result = {};
|
1325
1531
|
Object.assign(result, object);
|
1326
|
-
const
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1532
|
+
const { columns } = schema.tables.find(({ name }) => name === table) ?? {};
|
1533
|
+
if (!columns)
|
1534
|
+
console.error(`Table ${table} not found in schema`);
|
1535
|
+
for (const column of columns ?? []) {
|
1536
|
+
const value = result[column.name];
|
1537
|
+
switch (column.type) {
|
1538
|
+
case "datetime": {
|
1539
|
+
const date = value !== void 0 ? new Date(value) : void 0;
|
1540
|
+
if (date && isNaN(date.getTime())) {
|
1541
|
+
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
1542
|
+
} else if (date) {
|
1543
|
+
result[column.name] = date;
|
1544
|
+
}
|
1545
|
+
break;
|
1546
|
+
}
|
1547
|
+
case "link": {
|
1548
|
+
const linkTable = column.link?.table;
|
1549
|
+
if (!linkTable) {
|
1550
|
+
console.error(`Failed to parse link for field ${column.name}`);
|
1551
|
+
} else if (isObject(value)) {
|
1552
|
+
result[column.name] = initObject(db, schema, linkTable, value);
|
1553
|
+
}
|
1554
|
+
break;
|
1555
|
+
}
|
1332
1556
|
}
|
1333
1557
|
}
|
1334
1558
|
result.read = function() {
|
@@ -1346,6 +1570,65 @@ const initObject = (db, links, table, object) => {
|
|
1346
1570
|
Object.freeze(result);
|
1347
1571
|
return result;
|
1348
1572
|
};
|
1573
|
+
function getIds(value) {
|
1574
|
+
if (Array.isArray(value)) {
|
1575
|
+
return value.map((item) => getIds(item)).flat();
|
1576
|
+
}
|
1577
|
+
if (!isObject(value))
|
1578
|
+
return [];
|
1579
|
+
const nestedIds = Object.values(value).map((item) => getIds(item)).flat();
|
1580
|
+
return isString(value.id) ? [value.id, ...nestedIds] : nestedIds;
|
1581
|
+
}
|
1582
|
+
|
1583
|
+
var __accessCheck$3 = (obj, member, msg) => {
|
1584
|
+
if (!member.has(obj))
|
1585
|
+
throw TypeError("Cannot " + msg);
|
1586
|
+
};
|
1587
|
+
var __privateGet$3 = (obj, member, getter) => {
|
1588
|
+
__accessCheck$3(obj, member, "read from private field");
|
1589
|
+
return getter ? getter.call(obj) : member.get(obj);
|
1590
|
+
};
|
1591
|
+
var __privateAdd$3 = (obj, member, value) => {
|
1592
|
+
if (member.has(obj))
|
1593
|
+
throw TypeError("Cannot add the same private member more than once");
|
1594
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1595
|
+
};
|
1596
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
1597
|
+
__accessCheck$3(obj, member, "write to private field");
|
1598
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
1599
|
+
return value;
|
1600
|
+
};
|
1601
|
+
var _map;
|
1602
|
+
class SimpleCache {
|
1603
|
+
constructor(options = {}) {
|
1604
|
+
__privateAdd$3(this, _map, void 0);
|
1605
|
+
__privateSet$2(this, _map, /* @__PURE__ */ new Map());
|
1606
|
+
this.capacity = options.max ?? 500;
|
1607
|
+
this.cacheRecords = options.cacheRecords ?? true;
|
1608
|
+
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
1609
|
+
}
|
1610
|
+
async getAll() {
|
1611
|
+
return Object.fromEntries(__privateGet$3(this, _map));
|
1612
|
+
}
|
1613
|
+
async get(key) {
|
1614
|
+
return __privateGet$3(this, _map).get(key) ?? null;
|
1615
|
+
}
|
1616
|
+
async set(key, value) {
|
1617
|
+
await this.delete(key);
|
1618
|
+
__privateGet$3(this, _map).set(key, value);
|
1619
|
+
if (__privateGet$3(this, _map).size > this.capacity) {
|
1620
|
+
const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
|
1621
|
+
await this.delete(leastRecentlyUsed);
|
1622
|
+
}
|
1623
|
+
}
|
1624
|
+
async delete(key) {
|
1625
|
+
__privateGet$3(this, _map).delete(key);
|
1626
|
+
}
|
1627
|
+
async clear() {
|
1628
|
+
return __privateGet$3(this, _map).clear();
|
1629
|
+
}
|
1630
|
+
}
|
1631
|
+
_map = new WeakMap();
|
1349
1632
|
|
1350
1633
|
const gt = (value) => ({ $gt: value });
|
1351
1634
|
const ge = (value) => ({ $ge: value });
|
@@ -1370,7 +1653,7 @@ var __accessCheck$2 = (obj, member, msg) => {
|
|
1370
1653
|
if (!member.has(obj))
|
1371
1654
|
throw TypeError("Cannot " + msg);
|
1372
1655
|
};
|
1373
|
-
var __privateGet$
|
1656
|
+
var __privateGet$2 = (obj, member, getter) => {
|
1374
1657
|
__accessCheck$2(obj, member, "read from private field");
|
1375
1658
|
return getter ? getter.call(obj) : member.get(obj);
|
1376
1659
|
};
|
@@ -1381,26 +1664,24 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
1381
1664
|
};
|
1382
1665
|
var _tables;
|
1383
1666
|
class SchemaPlugin extends XataPlugin {
|
1384
|
-
constructor(
|
1667
|
+
constructor(tableNames) {
|
1385
1668
|
super();
|
1386
|
-
this.links = links;
|
1387
1669
|
this.tableNames = tableNames;
|
1388
1670
|
__privateAdd$2(this, _tables, {});
|
1389
1671
|
}
|
1390
|
-
build(
|
1391
|
-
const { getFetchProps } = options;
|
1392
|
-
const links = this.links;
|
1672
|
+
build(pluginOptions) {
|
1393
1673
|
const db = new Proxy({}, {
|
1394
1674
|
get: (_target, table) => {
|
1395
1675
|
if (!isString(table))
|
1396
1676
|
throw new Error("Invalid table name");
|
1397
|
-
if (
|
1398
|
-
__privateGet$
|
1399
|
-
|
1677
|
+
if (__privateGet$2(this, _tables)[table] === void 0) {
|
1678
|
+
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
|
1679
|
+
}
|
1680
|
+
return __privateGet$2(this, _tables)[table];
|
1400
1681
|
}
|
1401
1682
|
});
|
1402
1683
|
for (const table of this.tableNames ?? []) {
|
1403
|
-
db[table] = new RestRepository({ db,
|
1684
|
+
db[table] = new RestRepository({ db, pluginOptions, table });
|
1404
1685
|
}
|
1405
1686
|
return db;
|
1406
1687
|
}
|
@@ -1411,55 +1692,80 @@ var __accessCheck$1 = (obj, member, msg) => {
|
|
1411
1692
|
if (!member.has(obj))
|
1412
1693
|
throw TypeError("Cannot " + msg);
|
1413
1694
|
};
|
1695
|
+
var __privateGet$1 = (obj, member, getter) => {
|
1696
|
+
__accessCheck$1(obj, member, "read from private field");
|
1697
|
+
return getter ? getter.call(obj) : member.get(obj);
|
1698
|
+
};
|
1414
1699
|
var __privateAdd$1 = (obj, member, value) => {
|
1415
1700
|
if (member.has(obj))
|
1416
1701
|
throw TypeError("Cannot add the same private member more than once");
|
1417
1702
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1418
1703
|
};
|
1704
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
1705
|
+
__accessCheck$1(obj, member, "write to private field");
|
1706
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
1707
|
+
return value;
|
1708
|
+
};
|
1419
1709
|
var __privateMethod$1 = (obj, member, method) => {
|
1420
1710
|
__accessCheck$1(obj, member, "access private method");
|
1421
1711
|
return method;
|
1422
1712
|
};
|
1423
|
-
var _search, search_fn;
|
1713
|
+
var _schema, _search, search_fn, _getSchema, getSchema_fn;
|
1424
1714
|
class SearchPlugin extends XataPlugin {
|
1425
|
-
constructor(db
|
1715
|
+
constructor(db) {
|
1426
1716
|
super();
|
1427
1717
|
this.db = db;
|
1428
|
-
this.links = links;
|
1429
1718
|
__privateAdd$1(this, _search);
|
1719
|
+
__privateAdd$1(this, _getSchema);
|
1720
|
+
__privateAdd$1(this, _schema, void 0);
|
1430
1721
|
}
|
1431
1722
|
build({ getFetchProps }) {
|
1432
1723
|
return {
|
1433
1724
|
all: async (query, options = {}) => {
|
1434
1725
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1726
|
+
const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
|
1435
1727
|
return records.map((record) => {
|
1436
1728
|
const { table = "orphan" } = record.xata;
|
1437
|
-
return { table, record: initObject(this.db,
|
1729
|
+
return { table, record: initObject(this.db, schema, table, record) };
|
1438
1730
|
});
|
1439
1731
|
},
|
1440
1732
|
byTable: async (query, options = {}) => {
|
1441
1733
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1734
|
+
const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
|
1442
1735
|
return records.reduce((acc, record) => {
|
1443
1736
|
const { table = "orphan" } = record.xata;
|
1444
1737
|
const items = acc[table] ?? [];
|
1445
|
-
const item = initObject(this.db,
|
1738
|
+
const item = initObject(this.db, schema, table, record);
|
1446
1739
|
return { ...acc, [table]: [...items, item] };
|
1447
1740
|
}, {});
|
1448
1741
|
}
|
1449
1742
|
};
|
1450
1743
|
}
|
1451
1744
|
}
|
1745
|
+
_schema = new WeakMap();
|
1452
1746
|
_search = new WeakSet();
|
1453
1747
|
search_fn = async function(query, options, getFetchProps) {
|
1454
1748
|
const fetchProps = await getFetchProps();
|
1455
|
-
const { tables, fuzziness } = options ?? {};
|
1749
|
+
const { tables, fuzziness, highlight } = options ?? {};
|
1456
1750
|
const { records } = await searchBranch({
|
1457
1751
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1458
|
-
body: { tables, query, fuzziness },
|
1752
|
+
body: { tables, query, fuzziness, highlight },
|
1459
1753
|
...fetchProps
|
1460
1754
|
});
|
1461
1755
|
return records;
|
1462
1756
|
};
|
1757
|
+
_getSchema = new WeakSet();
|
1758
|
+
getSchema_fn = async function(getFetchProps) {
|
1759
|
+
if (__privateGet$1(this, _schema))
|
1760
|
+
return __privateGet$1(this, _schema);
|
1761
|
+
const fetchProps = await getFetchProps();
|
1762
|
+
const { schema } = await getBranchDetails({
|
1763
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1764
|
+
...fetchProps
|
1765
|
+
});
|
1766
|
+
__privateSet$1(this, _schema, schema);
|
1767
|
+
return schema;
|
1768
|
+
};
|
1463
1769
|
|
1464
1770
|
const isBranchStrategyBuilder = (strategy) => {
|
1465
1771
|
return typeof strategy === "function";
|
@@ -1471,30 +1777,39 @@ const envBranchNames = [
|
|
1471
1777
|
"CF_PAGES_BRANCH",
|
1472
1778
|
"BRANCH"
|
1473
1779
|
];
|
1474
|
-
const defaultBranch = "main";
|
1475
1780
|
async function getCurrentBranchName(options) {
|
1476
|
-
const env =
|
1477
|
-
if (env)
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
return defaultBranch;
|
1781
|
+
const env = getBranchByEnvVariable();
|
1782
|
+
if (env) {
|
1783
|
+
const details = await getDatabaseBranch(env, options);
|
1784
|
+
if (details)
|
1785
|
+
return env;
|
1786
|
+
console.warn(`Branch ${env} not found in Xata. Ignoring...`);
|
1787
|
+
}
|
1788
|
+
const gitBranch = await getGitBranch();
|
1789
|
+
return resolveXataBranch(gitBranch, options);
|
1486
1790
|
}
|
1487
1791
|
async function getCurrentBranchDetails(options) {
|
1488
|
-
const
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1792
|
+
const branch = await getCurrentBranchName(options);
|
1793
|
+
return getDatabaseBranch(branch, options);
|
1794
|
+
}
|
1795
|
+
async function resolveXataBranch(gitBranch, options) {
|
1796
|
+
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1797
|
+
const apiKey = options?.apiKey || getAPIKey();
|
1798
|
+
if (!databaseURL)
|
1799
|
+
throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
|
1800
|
+
if (!apiKey)
|
1801
|
+
throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
|
1802
|
+
const [protocol, , host, , dbName] = databaseURL.split("/");
|
1803
|
+
const [workspace] = host.split(".");
|
1804
|
+
const { branch } = await resolveBranch({
|
1805
|
+
apiKey,
|
1806
|
+
apiUrl: databaseURL,
|
1807
|
+
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1808
|
+
workspacesApiUrl: `${protocol}//${host}`,
|
1809
|
+
pathParams: { dbName, workspace },
|
1810
|
+
queryParams: { gitBranch, fallbackBranch: getEnvVariable("XATA_FALLBACK_BRANCH") }
|
1811
|
+
});
|
1812
|
+
return branch;
|
1498
1813
|
}
|
1499
1814
|
async function getDatabaseBranch(branch, options) {
|
1500
1815
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
@@ -1568,22 +1883,24 @@ var __privateMethod = (obj, member, method) => {
|
|
1568
1883
|
const buildClient = (plugins) => {
|
1569
1884
|
var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
1570
1885
|
return _a = class {
|
1571
|
-
constructor(options = {},
|
1886
|
+
constructor(options = {}, tables) {
|
1572
1887
|
__privateAdd(this, _parseOptions);
|
1573
1888
|
__privateAdd(this, _getFetchProps);
|
1574
1889
|
__privateAdd(this, _evaluateBranch);
|
1575
1890
|
__privateAdd(this, _branch, void 0);
|
1576
1891
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
1577
|
-
const
|
1578
|
-
|
1579
|
-
|
1580
|
-
}
|
1892
|
+
const pluginOptions = {
|
1893
|
+
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
1894
|
+
cache: safeOptions.cache
|
1895
|
+
};
|
1896
|
+
const db = new SchemaPlugin(tables).build(pluginOptions);
|
1897
|
+
const search = new SearchPlugin(db).build(pluginOptions);
|
1581
1898
|
this.db = db;
|
1582
1899
|
this.search = search;
|
1583
1900
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
1584
|
-
if (
|
1901
|
+
if (namespace === void 0)
|
1585
1902
|
continue;
|
1586
|
-
const result = namespace.build(
|
1903
|
+
const result = namespace.build(pluginOptions);
|
1587
1904
|
if (result instanceof Promise) {
|
1588
1905
|
void result.then((namespace2) => {
|
1589
1906
|
this[key] = namespace2;
|
@@ -1597,11 +1914,12 @@ const buildClient = (plugins) => {
|
|
1597
1914
|
const fetch = getFetchImplementation(options?.fetch);
|
1598
1915
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1599
1916
|
const apiKey = options?.apiKey || getAPIKey();
|
1600
|
-
const
|
1917
|
+
const cache = options?.cache ?? new SimpleCache({ cacheRecords: false, defaultQueryTTL: 0 });
|
1918
|
+
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
1601
1919
|
if (!databaseURL || !apiKey) {
|
1602
1920
|
throw new Error("Options databaseURL and apiKey are required");
|
1603
1921
|
}
|
1604
|
-
return { fetch, databaseURL, apiKey, branch };
|
1922
|
+
return { fetch, databaseURL, apiKey, branch, cache };
|
1605
1923
|
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
|
1606
1924
|
fetch,
|
1607
1925
|
apiKey,
|
@@ -1624,7 +1942,7 @@ const buildClient = (plugins) => {
|
|
1624
1942
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
1625
1943
|
if (__privateGet(this, _branch))
|
1626
1944
|
return __privateGet(this, _branch);
|
1627
|
-
if (
|
1945
|
+
if (param === void 0)
|
1628
1946
|
return void 0;
|
1629
1947
|
const strategies = Array.isArray(param) ? [...param] : [param];
|
1630
1948
|
const evaluateBranch = async (strategy) => {
|
@@ -1649,5 +1967,5 @@ class XataError extends Error {
|
|
1649
1967
|
}
|
1650
1968
|
}
|
1651
1969
|
|
1652
|
-
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, Repository, RestRepository, SchemaPlugin, SearchPlugin, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeWorkspaceMember, resendWorkspaceMemberInvite, searchBranch, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
|
1970
|
+
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, Repository, RestRepository, SchemaPlugin, SearchPlugin, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
|
1653
1971
|
//# sourceMappingURL=index.mjs.map
|