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