@xata.io/client 0.0.0-alpha.vf2696e7 → 0.0.0-alpha.vf350c0a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/index.cjs +244 -134
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +260 -71
- package/dist/index.mjs +241 -135
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
@@ -38,7 +38,10 @@ function getEnvVariable(name) {
|
|
38
38
|
}
|
39
39
|
async function getGitBranch() {
|
40
40
|
try {
|
41
|
-
|
41
|
+
if (typeof require === "function") {
|
42
|
+
const req = require;
|
43
|
+
return req("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
|
44
|
+
}
|
42
45
|
} catch (err) {
|
43
46
|
}
|
44
47
|
try {
|
@@ -252,6 +255,14 @@ const deleteDatabase = (variables) => fetch$1({
|
|
252
255
|
method: "delete",
|
253
256
|
...variables
|
254
257
|
});
|
258
|
+
const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
|
259
|
+
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
260
|
+
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
261
|
+
const resolveBranch = (variables) => fetch$1({
|
262
|
+
url: "/dbs/{dbName}/resolveBranch",
|
263
|
+
method: "get",
|
264
|
+
...variables
|
265
|
+
});
|
255
266
|
const getBranchDetails = (variables) => fetch$1({
|
256
267
|
url: "/db/{dbBranchName}",
|
257
268
|
method: "get",
|
@@ -380,7 +391,15 @@ const operationsByTag = {
|
|
380
391
|
resendWorkspaceMemberInvite,
|
381
392
|
acceptWorkspaceMemberInvite
|
382
393
|
},
|
383
|
-
database: {
|
394
|
+
database: {
|
395
|
+
getDatabaseList,
|
396
|
+
createDatabase,
|
397
|
+
deleteDatabase,
|
398
|
+
getGitBranchesMapping,
|
399
|
+
addGitBranchesEntry,
|
400
|
+
removeGitBranchesEntry,
|
401
|
+
resolveBranch
|
402
|
+
},
|
384
403
|
branch: {
|
385
404
|
getBranchList,
|
386
405
|
getBranchDetails,
|
@@ -447,7 +466,7 @@ var __accessCheck$7 = (obj, member, msg) => {
|
|
447
466
|
if (!member.has(obj))
|
448
467
|
throw TypeError("Cannot " + msg);
|
449
468
|
};
|
450
|
-
var __privateGet$
|
469
|
+
var __privateGet$7 = (obj, member, getter) => {
|
451
470
|
__accessCheck$7(obj, member, "read from private field");
|
452
471
|
return getter ? getter.call(obj) : member.get(obj);
|
453
472
|
};
|
@@ -456,7 +475,7 @@ var __privateAdd$7 = (obj, member, value) => {
|
|
456
475
|
throw TypeError("Cannot add the same private member more than once");
|
457
476
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
458
477
|
};
|
459
|
-
var __privateSet$
|
478
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
460
479
|
__accessCheck$7(obj, member, "write to private field");
|
461
480
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
462
481
|
return value;
|
@@ -471,7 +490,7 @@ class XataApiClient {
|
|
471
490
|
if (!apiKey) {
|
472
491
|
throw new Error("Could not resolve a valid apiKey");
|
473
492
|
}
|
474
|
-
__privateSet$
|
493
|
+
__privateSet$6(this, _extraProps, {
|
475
494
|
apiUrl: getHostUrl(provider, "main"),
|
476
495
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
477
496
|
fetchImpl: getFetchImplementation(options.fetch),
|
@@ -479,34 +498,34 @@ class XataApiClient {
|
|
479
498
|
});
|
480
499
|
}
|
481
500
|
get user() {
|
482
|
-
if (!__privateGet$
|
483
|
-
__privateGet$
|
484
|
-
return __privateGet$
|
501
|
+
if (!__privateGet$7(this, _namespaces).user)
|
502
|
+
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
503
|
+
return __privateGet$7(this, _namespaces).user;
|
485
504
|
}
|
486
505
|
get workspaces() {
|
487
|
-
if (!__privateGet$
|
488
|
-
__privateGet$
|
489
|
-
return __privateGet$
|
506
|
+
if (!__privateGet$7(this, _namespaces).workspaces)
|
507
|
+
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
508
|
+
return __privateGet$7(this, _namespaces).workspaces;
|
490
509
|
}
|
491
510
|
get databases() {
|
492
|
-
if (!__privateGet$
|
493
|
-
__privateGet$
|
494
|
-
return __privateGet$
|
511
|
+
if (!__privateGet$7(this, _namespaces).databases)
|
512
|
+
__privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
|
513
|
+
return __privateGet$7(this, _namespaces).databases;
|
495
514
|
}
|
496
515
|
get branches() {
|
497
|
-
if (!__privateGet$
|
498
|
-
__privateGet$
|
499
|
-
return __privateGet$
|
516
|
+
if (!__privateGet$7(this, _namespaces).branches)
|
517
|
+
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
518
|
+
return __privateGet$7(this, _namespaces).branches;
|
500
519
|
}
|
501
520
|
get tables() {
|
502
|
-
if (!__privateGet$
|
503
|
-
__privateGet$
|
504
|
-
return __privateGet$
|
521
|
+
if (!__privateGet$7(this, _namespaces).tables)
|
522
|
+
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
523
|
+
return __privateGet$7(this, _namespaces).tables;
|
505
524
|
}
|
506
525
|
get records() {
|
507
|
-
if (!__privateGet$
|
508
|
-
__privateGet$
|
509
|
-
return __privateGet$
|
526
|
+
if (!__privateGet$7(this, _namespaces).records)
|
527
|
+
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
528
|
+
return __privateGet$7(this, _namespaces).records;
|
510
529
|
}
|
511
530
|
}
|
512
531
|
_extraProps = new WeakMap();
|
@@ -640,6 +659,33 @@ class DatabaseApi {
|
|
640
659
|
...this.extraProps
|
641
660
|
});
|
642
661
|
}
|
662
|
+
getGitBranchesMapping(workspace, dbName) {
|
663
|
+
return operationsByTag.database.getGitBranchesMapping({
|
664
|
+
pathParams: { workspace, dbName },
|
665
|
+
...this.extraProps
|
666
|
+
});
|
667
|
+
}
|
668
|
+
addGitBranchesEntry(workspace, dbName, body) {
|
669
|
+
return operationsByTag.database.addGitBranchesEntry({
|
670
|
+
pathParams: { workspace, dbName },
|
671
|
+
body,
|
672
|
+
...this.extraProps
|
673
|
+
});
|
674
|
+
}
|
675
|
+
removeGitBranchesEntry(workspace, dbName, gitBranch) {
|
676
|
+
return operationsByTag.database.removeGitBranchesEntry({
|
677
|
+
pathParams: { workspace, dbName },
|
678
|
+
queryParams: { gitBranch },
|
679
|
+
...this.extraProps
|
680
|
+
});
|
681
|
+
}
|
682
|
+
resolveBranch(workspace, dbName, gitBranch) {
|
683
|
+
return operationsByTag.database.resolveBranch({
|
684
|
+
pathParams: { workspace, dbName },
|
685
|
+
queryParams: { gitBranch },
|
686
|
+
...this.extraProps
|
687
|
+
});
|
688
|
+
}
|
643
689
|
}
|
644
690
|
class BranchApi {
|
645
691
|
constructor(extraProps) {
|
@@ -865,7 +911,7 @@ var __accessCheck$6 = (obj, member, msg) => {
|
|
865
911
|
if (!member.has(obj))
|
866
912
|
throw TypeError("Cannot " + msg);
|
867
913
|
};
|
868
|
-
var __privateGet$
|
914
|
+
var __privateGet$6 = (obj, member, getter) => {
|
869
915
|
__accessCheck$6(obj, member, "read from private field");
|
870
916
|
return getter ? getter.call(obj) : member.get(obj);
|
871
917
|
};
|
@@ -874,7 +920,7 @@ var __privateAdd$6 = (obj, member, value) => {
|
|
874
920
|
throw TypeError("Cannot add the same private member more than once");
|
875
921
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
876
922
|
};
|
877
|
-
var __privateSet$
|
923
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
878
924
|
__accessCheck$6(obj, member, "write to private field");
|
879
925
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
880
926
|
return value;
|
@@ -883,21 +929,21 @@ var _query;
|
|
883
929
|
class Page {
|
884
930
|
constructor(query, meta, records = []) {
|
885
931
|
__privateAdd$6(this, _query, void 0);
|
886
|
-
__privateSet$
|
932
|
+
__privateSet$5(this, _query, query);
|
887
933
|
this.meta = meta;
|
888
934
|
this.records = records;
|
889
935
|
}
|
890
936
|
async nextPage(size, offset) {
|
891
|
-
return __privateGet$
|
937
|
+
return __privateGet$6(this, _query).getPaginated({ page: { size, offset, after: this.meta.page.cursor } });
|
892
938
|
}
|
893
939
|
async previousPage(size, offset) {
|
894
|
-
return __privateGet$
|
940
|
+
return __privateGet$6(this, _query).getPaginated({ page: { size, offset, before: this.meta.page.cursor } });
|
895
941
|
}
|
896
942
|
async firstPage(size, offset) {
|
897
|
-
return __privateGet$
|
943
|
+
return __privateGet$6(this, _query).getPaginated({ page: { size, offset, first: this.meta.page.cursor } });
|
898
944
|
}
|
899
945
|
async lastPage(size, offset) {
|
900
|
-
return __privateGet$
|
946
|
+
return __privateGet$6(this, _query).getPaginated({ page: { size, offset, last: this.meta.page.cursor } });
|
901
947
|
}
|
902
948
|
hasNextPage() {
|
903
949
|
return this.meta.page.more;
|
@@ -913,7 +959,7 @@ var __accessCheck$5 = (obj, member, msg) => {
|
|
913
959
|
if (!member.has(obj))
|
914
960
|
throw TypeError("Cannot " + msg);
|
915
961
|
};
|
916
|
-
var __privateGet$
|
962
|
+
var __privateGet$5 = (obj, member, getter) => {
|
917
963
|
__accessCheck$5(obj, member, "read from private field");
|
918
964
|
return getter ? getter.call(obj) : member.get(obj);
|
919
965
|
};
|
@@ -922,7 +968,7 @@ var __privateAdd$5 = (obj, member, value) => {
|
|
922
968
|
throw TypeError("Cannot add the same private member more than once");
|
923
969
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
924
970
|
};
|
925
|
-
var __privateSet$
|
971
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
926
972
|
__accessCheck$5(obj, member, "write to private field");
|
927
973
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
928
974
|
return value;
|
@@ -935,21 +981,21 @@ const _Query = class {
|
|
935
981
|
__privateAdd$5(this, _data, { filter: {} });
|
936
982
|
this.meta = { page: { cursor: "start", more: true } };
|
937
983
|
this.records = [];
|
938
|
-
__privateSet$
|
984
|
+
__privateSet$4(this, _table$1, table);
|
939
985
|
if (repository) {
|
940
|
-
__privateSet$
|
986
|
+
__privateSet$4(this, _repository, repository);
|
941
987
|
} else {
|
942
|
-
__privateSet$
|
988
|
+
__privateSet$4(this, _repository, this);
|
943
989
|
}
|
944
|
-
__privateGet$
|
945
|
-
__privateGet$
|
946
|
-
__privateGet$
|
947
|
-
__privateGet$
|
948
|
-
__privateGet$
|
949
|
-
__privateGet$
|
950
|
-
__privateGet$
|
951
|
-
__privateGet$
|
952
|
-
__privateGet$
|
990
|
+
__privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
991
|
+
__privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
|
992
|
+
__privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
|
993
|
+
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
994
|
+
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
995
|
+
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
996
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
|
997
|
+
__privateGet$5(this, _data).page = data.page ?? parent?.page;
|
998
|
+
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
953
999
|
this.any = this.any.bind(this);
|
954
1000
|
this.all = this.all.bind(this);
|
955
1001
|
this.not = this.not.bind(this);
|
@@ -960,50 +1006,50 @@ const _Query = class {
|
|
960
1006
|
Object.defineProperty(this, "repository", { enumerable: false });
|
961
1007
|
}
|
962
1008
|
getQueryOptions() {
|
963
|
-
return __privateGet$
|
1009
|
+
return __privateGet$5(this, _data);
|
964
1010
|
}
|
965
1011
|
key() {
|
966
|
-
const { columns = [], filter = {}, sort = [], page = {} } = __privateGet$
|
1012
|
+
const { columns = [], filter = {}, sort = [], page = {} } = __privateGet$5(this, _data);
|
967
1013
|
const key = JSON.stringify({ columns, filter, sort, page });
|
968
1014
|
return toBase64(key);
|
969
1015
|
}
|
970
1016
|
any(...queries) {
|
971
1017
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
972
|
-
return new _Query(__privateGet$
|
1018
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
973
1019
|
}
|
974
1020
|
all(...queries) {
|
975
1021
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
976
|
-
return new _Query(__privateGet$
|
1022
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
977
1023
|
}
|
978
1024
|
not(...queries) {
|
979
1025
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
980
|
-
return new _Query(__privateGet$
|
1026
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
981
1027
|
}
|
982
1028
|
none(...queries) {
|
983
1029
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
984
|
-
return new _Query(__privateGet$
|
1030
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
985
1031
|
}
|
986
1032
|
filter(a, b) {
|
987
1033
|
if (arguments.length === 1) {
|
988
1034
|
const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
|
989
|
-
const $all = compact([__privateGet$
|
990
|
-
return new _Query(__privateGet$
|
1035
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1036
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
991
1037
|
} else {
|
992
|
-
const $all = compact([__privateGet$
|
993
|
-
return new _Query(__privateGet$
|
1038
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
|
1039
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
994
1040
|
}
|
995
1041
|
}
|
996
1042
|
sort(column, direction) {
|
997
|
-
const originalSort = [__privateGet$
|
1043
|
+
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
998
1044
|
const sort = [...originalSort, { column, direction }];
|
999
|
-
return new _Query(__privateGet$
|
1045
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
1000
1046
|
}
|
1001
1047
|
select(columns) {
|
1002
|
-
return new _Query(__privateGet$
|
1048
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { columns }, __privateGet$5(this, _data));
|
1003
1049
|
}
|
1004
1050
|
getPaginated(options = {}) {
|
1005
|
-
const query = new _Query(__privateGet$
|
1006
|
-
return __privateGet$
|
1051
|
+
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
1052
|
+
return __privateGet$5(this, _repository).query(query);
|
1007
1053
|
}
|
1008
1054
|
async *[Symbol.asyncIterator]() {
|
1009
1055
|
for await (const [record] of this.getIterator(1)) {
|
@@ -1036,7 +1082,7 @@ const _Query = class {
|
|
1036
1082
|
return records[0] || null;
|
1037
1083
|
}
|
1038
1084
|
cache(ttl) {
|
1039
|
-
return new _Query(__privateGet$
|
1085
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1040
1086
|
}
|
1041
1087
|
nextPage(size, offset) {
|
1042
1088
|
return this.firstPage(size, offset);
|
@@ -1093,7 +1139,7 @@ var __accessCheck$4 = (obj, member, msg) => {
|
|
1093
1139
|
if (!member.has(obj))
|
1094
1140
|
throw TypeError("Cannot " + msg);
|
1095
1141
|
};
|
1096
|
-
var __privateGet$
|
1142
|
+
var __privateGet$4 = (obj, member, getter) => {
|
1097
1143
|
__accessCheck$4(obj, member, "read from private field");
|
1098
1144
|
return getter ? getter.call(obj) : member.get(obj);
|
1099
1145
|
};
|
@@ -1102,7 +1148,7 @@ var __privateAdd$4 = (obj, member, value) => {
|
|
1102
1148
|
throw TypeError("Cannot add the same private member more than once");
|
1103
1149
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1104
1150
|
};
|
1105
|
-
var __privateSet$
|
1151
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
1106
1152
|
__accessCheck$4(obj, member, "write to private field");
|
1107
1153
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1108
1154
|
return value;
|
@@ -1111,7 +1157,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
1111
1157
|
__accessCheck$4(obj, member, "access private method");
|
1112
1158
|
return method;
|
1113
1159
|
};
|
1114
|
-
var _table,
|
1160
|
+
var _table, _getFetchProps, _cache, _schemaColumns, _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, _getSchemaColumns, getSchemaColumns_fn;
|
1115
1161
|
class Repository extends Query {
|
1116
1162
|
}
|
1117
1163
|
class RestRepository extends Query {
|
@@ -1128,15 +1174,15 @@ class RestRepository extends Query {
|
|
1128
1174
|
__privateAdd$4(this, _getCacheRecord);
|
1129
1175
|
__privateAdd$4(this, _setCacheQuery);
|
1130
1176
|
__privateAdd$4(this, _getCacheQuery);
|
1177
|
+
__privateAdd$4(this, _getSchemaColumns);
|
1131
1178
|
__privateAdd$4(this, _table, void 0);
|
1132
|
-
__privateAdd$4(this, _links, void 0);
|
1133
1179
|
__privateAdd$4(this, _getFetchProps, void 0);
|
1134
1180
|
__privateAdd$4(this, _cache, void 0);
|
1135
|
-
|
1136
|
-
__privateSet$
|
1137
|
-
__privateSet$
|
1181
|
+
__privateAdd$4(this, _schemaColumns, void 0);
|
1182
|
+
__privateSet$3(this, _table, options.table);
|
1183
|
+
__privateSet$3(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1138
1184
|
this.db = options.db;
|
1139
|
-
__privateSet$
|
1185
|
+
__privateSet$3(this, _cache, options.pluginOptions.cache);
|
1140
1186
|
}
|
1141
1187
|
async create(a, b) {
|
1142
1188
|
if (Array.isArray(a)) {
|
@@ -1169,13 +1215,14 @@ class RestRepository extends Query {
|
|
1169
1215
|
const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, recordId);
|
1170
1216
|
if (cacheRecord)
|
1171
1217
|
return cacheRecord;
|
1172
|
-
const fetchProps = await __privateGet$
|
1218
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1173
1219
|
try {
|
1174
1220
|
const response = await getRecord({
|
1175
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1221
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1176
1222
|
...fetchProps
|
1177
1223
|
});
|
1178
|
-
|
1224
|
+
const columns = await __privateMethod$2(this, _getSchemaColumns, getSchemaColumns_fn).call(this);
|
1225
|
+
return initObject(this.db, columns, __privateGet$4(this, _table), response);
|
1179
1226
|
} catch (e) {
|
1180
1227
|
if (isObject(e) && e.status === 404) {
|
1181
1228
|
return null;
|
@@ -1246,13 +1293,14 @@ class RestRepository extends Query {
|
|
1246
1293
|
throw new Error("Invalid arguments for delete method");
|
1247
1294
|
}
|
1248
1295
|
async search(query, options = {}) {
|
1249
|
-
const fetchProps = await __privateGet$
|
1296
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1250
1297
|
const { records } = await searchBranch({
|
1251
1298
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1252
|
-
body: { tables: [__privateGet$
|
1299
|
+
body: { tables: [__privateGet$4(this, _table)], query, fuzziness: options.fuzziness },
|
1253
1300
|
...fetchProps
|
1254
1301
|
});
|
1255
|
-
|
1302
|
+
const columns = await __privateMethod$2(this, _getSchemaColumns, getSchemaColumns_fn).call(this);
|
1303
|
+
return records.map((item) => initObject(this.db, columns, __privateGet$4(this, _table), item));
|
1256
1304
|
}
|
1257
1305
|
async query(query) {
|
1258
1306
|
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
@@ -1265,30 +1313,31 @@ class RestRepository extends Query {
|
|
1265
1313
|
page: data.page,
|
1266
1314
|
columns: data.columns
|
1267
1315
|
};
|
1268
|
-
const fetchProps = await __privateGet$
|
1316
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1269
1317
|
const { meta, records: objects } = await queryTable({
|
1270
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1318
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1271
1319
|
body,
|
1272
1320
|
...fetchProps
|
1273
1321
|
});
|
1274
|
-
const
|
1322
|
+
const columns = await __privateMethod$2(this, _getSchemaColumns, getSchemaColumns_fn).call(this);
|
1323
|
+
const records = objects.map((record) => initObject(this.db, columns, __privateGet$4(this, _table), record));
|
1275
1324
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1276
1325
|
return new Page(query, meta, records);
|
1277
1326
|
}
|
1278
1327
|
}
|
1279
1328
|
_table = new WeakMap();
|
1280
|
-
_links = new WeakMap();
|
1281
1329
|
_getFetchProps = new WeakMap();
|
1282
1330
|
_cache = new WeakMap();
|
1331
|
+
_schemaColumns = new WeakMap();
|
1283
1332
|
_insertRecordWithoutId = new WeakSet();
|
1284
1333
|
insertRecordWithoutId_fn = async function(object) {
|
1285
|
-
const fetchProps = await __privateGet$
|
1334
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1286
1335
|
const record = transformObjectLinks(object);
|
1287
1336
|
const response = await insertRecord({
|
1288
1337
|
pathParams: {
|
1289
1338
|
workspace: "{workspaceId}",
|
1290
1339
|
dbBranchName: "{dbBranch}",
|
1291
|
-
tableName: __privateGet$
|
1340
|
+
tableName: __privateGet$4(this, _table)
|
1292
1341
|
},
|
1293
1342
|
body: record,
|
1294
1343
|
...fetchProps
|
@@ -1301,13 +1350,13 @@ insertRecordWithoutId_fn = async function(object) {
|
|
1301
1350
|
};
|
1302
1351
|
_insertRecordWithId = new WeakSet();
|
1303
1352
|
insertRecordWithId_fn = async function(recordId, object) {
|
1304
|
-
const fetchProps = await __privateGet$
|
1353
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1305
1354
|
const record = transformObjectLinks(object);
|
1306
1355
|
const response = await insertRecordWithID({
|
1307
1356
|
pathParams: {
|
1308
1357
|
workspace: "{workspaceId}",
|
1309
1358
|
dbBranchName: "{dbBranch}",
|
1310
|
-
tableName: __privateGet$
|
1359
|
+
tableName: __privateGet$4(this, _table),
|
1311
1360
|
recordId
|
1312
1361
|
},
|
1313
1362
|
body: record,
|
@@ -1322,10 +1371,10 @@ insertRecordWithId_fn = async function(recordId, object) {
|
|
1322
1371
|
};
|
1323
1372
|
_bulkInsertTableRecords = new WeakSet();
|
1324
1373
|
bulkInsertTableRecords_fn = async function(objects) {
|
1325
|
-
const fetchProps = await __privateGet$
|
1374
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1326
1375
|
const records = objects.map((object) => transformObjectLinks(object));
|
1327
1376
|
const response = await bulkInsertTableRecords({
|
1328
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1377
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1329
1378
|
body: { records },
|
1330
1379
|
...fetchProps
|
1331
1380
|
});
|
@@ -1337,10 +1386,10 @@ bulkInsertTableRecords_fn = async function(objects) {
|
|
1337
1386
|
};
|
1338
1387
|
_updateRecordWithID = new WeakSet();
|
1339
1388
|
updateRecordWithID_fn = async function(recordId, object) {
|
1340
|
-
const fetchProps = await __privateGet$
|
1389
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1341
1390
|
const record = transformObjectLinks(object);
|
1342
1391
|
const response = await updateRecordWithID({
|
1343
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1392
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1344
1393
|
body: record,
|
1345
1394
|
...fetchProps
|
1346
1395
|
});
|
@@ -1351,9 +1400,9 @@ updateRecordWithID_fn = async function(recordId, object) {
|
|
1351
1400
|
};
|
1352
1401
|
_upsertRecordWithID = new WeakSet();
|
1353
1402
|
upsertRecordWithID_fn = async function(recordId, object) {
|
1354
|
-
const fetchProps = await __privateGet$
|
1403
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1355
1404
|
const response = await upsertRecordWithID({
|
1356
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1405
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1357
1406
|
body: object,
|
1358
1407
|
...fetchProps
|
1359
1408
|
});
|
@@ -1364,51 +1413,62 @@ upsertRecordWithID_fn = async function(recordId, object) {
|
|
1364
1413
|
};
|
1365
1414
|
_deleteRecord = new WeakSet();
|
1366
1415
|
deleteRecord_fn = async function(recordId) {
|
1367
|
-
const fetchProps = await __privateGet$
|
1416
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1368
1417
|
await deleteRecord({
|
1369
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1418
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1370
1419
|
...fetchProps
|
1371
1420
|
});
|
1372
1421
|
};
|
1373
1422
|
_invalidateCache = new WeakSet();
|
1374
1423
|
invalidateCache_fn = async function(recordId) {
|
1375
|
-
await __privateGet$
|
1376
|
-
const cacheItems = await __privateGet$
|
1424
|
+
await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
1425
|
+
const cacheItems = await __privateGet$4(this, _cache).getAll();
|
1377
1426
|
const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
|
1378
1427
|
for (const [key, value] of queries) {
|
1379
1428
|
const ids = getIds(value);
|
1380
1429
|
if (ids.includes(recordId))
|
1381
|
-
await __privateGet$
|
1430
|
+
await __privateGet$4(this, _cache).delete(key);
|
1382
1431
|
}
|
1383
1432
|
};
|
1384
1433
|
_setCacheRecord = new WeakSet();
|
1385
1434
|
setCacheRecord_fn = async function(record) {
|
1386
|
-
if (!__privateGet$
|
1435
|
+
if (!__privateGet$4(this, _cache).cacheRecords)
|
1387
1436
|
return;
|
1388
|
-
await __privateGet$
|
1437
|
+
await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
|
1389
1438
|
};
|
1390
1439
|
_getCacheRecord = new WeakSet();
|
1391
1440
|
getCacheRecord_fn = async function(recordId) {
|
1392
|
-
if (!__privateGet$
|
1441
|
+
if (!__privateGet$4(this, _cache).cacheRecords)
|
1393
1442
|
return null;
|
1394
|
-
return __privateGet$
|
1443
|
+
return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
1395
1444
|
};
|
1396
1445
|
_setCacheQuery = new WeakSet();
|
1397
1446
|
setCacheQuery_fn = async function(query, meta, records) {
|
1398
|
-
await __privateGet$
|
1447
|
+
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
1399
1448
|
};
|
1400
1449
|
_getCacheQuery = new WeakSet();
|
1401
1450
|
getCacheQuery_fn = async function(query) {
|
1402
|
-
const key = `query_${__privateGet$
|
1403
|
-
const result = await __privateGet$
|
1451
|
+
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
1452
|
+
const result = await __privateGet$4(this, _cache).get(key);
|
1404
1453
|
if (!result)
|
1405
1454
|
return null;
|
1406
|
-
const { cache: ttl = __privateGet$
|
1455
|
+
const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
|
1407
1456
|
if (!ttl || ttl < 0)
|
1408
1457
|
return result;
|
1409
1458
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
1410
1459
|
return hasExpired ? null : result;
|
1411
1460
|
};
|
1461
|
+
_getSchemaColumns = new WeakSet();
|
1462
|
+
getSchemaColumns_fn = async function() {
|
1463
|
+
if (__privateGet$4(this, _schemaColumns))
|
1464
|
+
return __privateGet$4(this, _schemaColumns);
|
1465
|
+
const { columns } = await getTableSchema({
|
1466
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1467
|
+
...await __privateGet$4(this, _getFetchProps).call(this)
|
1468
|
+
});
|
1469
|
+
__privateSet$3(this, _schemaColumns, columns);
|
1470
|
+
return columns;
|
1471
|
+
};
|
1412
1472
|
const transformObjectLinks = (object) => {
|
1413
1473
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
1414
1474
|
if (key === "xata")
|
@@ -1416,15 +1476,30 @@ const transformObjectLinks = (object) => {
|
|
1416
1476
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1417
1477
|
}, {});
|
1418
1478
|
};
|
1419
|
-
const initObject = (db,
|
1479
|
+
const initObject = (db, columns, table, object) => {
|
1420
1480
|
const result = {};
|
1421
1481
|
Object.assign(result, object);
|
1422
|
-
const
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1482
|
+
for (const column of columns) {
|
1483
|
+
const value = result[column.name];
|
1484
|
+
switch (column.type) {
|
1485
|
+
case "datetime": {
|
1486
|
+
const date = new Date(value);
|
1487
|
+
if (isNaN(date.getTime())) {
|
1488
|
+
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
1489
|
+
} else {
|
1490
|
+
result[column.name] = date;
|
1491
|
+
}
|
1492
|
+
break;
|
1493
|
+
}
|
1494
|
+
case "link": {
|
1495
|
+
const linkTable = column.link?.table;
|
1496
|
+
if (!linkTable) {
|
1497
|
+
console.error(`Failed to parse link for field ${column.name}`);
|
1498
|
+
} else if (value && isObject(value)) {
|
1499
|
+
result[column.name] = initObject(db, columns, linkTable, value);
|
1500
|
+
}
|
1501
|
+
break;
|
1502
|
+
}
|
1428
1503
|
}
|
1429
1504
|
}
|
1430
1505
|
result.read = function() {
|
@@ -1456,7 +1531,7 @@ var __accessCheck$3 = (obj, member, msg) => {
|
|
1456
1531
|
if (!member.has(obj))
|
1457
1532
|
throw TypeError("Cannot " + msg);
|
1458
1533
|
};
|
1459
|
-
var __privateGet$
|
1534
|
+
var __privateGet$3 = (obj, member, getter) => {
|
1460
1535
|
__accessCheck$3(obj, member, "read from private field");
|
1461
1536
|
return getter ? getter.call(obj) : member.get(obj);
|
1462
1537
|
};
|
@@ -1465,7 +1540,7 @@ var __privateAdd$3 = (obj, member, value) => {
|
|
1465
1540
|
throw TypeError("Cannot add the same private member more than once");
|
1466
1541
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1467
1542
|
};
|
1468
|
-
var __privateSet$
|
1543
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
1469
1544
|
__accessCheck$3(obj, member, "write to private field");
|
1470
1545
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1471
1546
|
return value;
|
@@ -1474,30 +1549,30 @@ var _map;
|
|
1474
1549
|
class SimpleCache {
|
1475
1550
|
constructor(options = {}) {
|
1476
1551
|
__privateAdd$3(this, _map, void 0);
|
1477
|
-
__privateSet$
|
1552
|
+
__privateSet$2(this, _map, /* @__PURE__ */ new Map());
|
1478
1553
|
this.capacity = options.max ?? 500;
|
1479
1554
|
this.cacheRecords = options.cacheRecords ?? true;
|
1480
1555
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
1481
1556
|
}
|
1482
1557
|
async getAll() {
|
1483
|
-
return Object.fromEntries(__privateGet$
|
1558
|
+
return Object.fromEntries(__privateGet$3(this, _map));
|
1484
1559
|
}
|
1485
1560
|
async get(key) {
|
1486
|
-
return __privateGet$
|
1561
|
+
return __privateGet$3(this, _map).get(key) ?? null;
|
1487
1562
|
}
|
1488
1563
|
async set(key, value) {
|
1489
1564
|
await this.delete(key);
|
1490
|
-
__privateGet$
|
1491
|
-
if (__privateGet$
|
1492
|
-
const leastRecentlyUsed = __privateGet$
|
1565
|
+
__privateGet$3(this, _map).set(key, value);
|
1566
|
+
if (__privateGet$3(this, _map).size > this.capacity) {
|
1567
|
+
const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
|
1493
1568
|
await this.delete(leastRecentlyUsed);
|
1494
1569
|
}
|
1495
1570
|
}
|
1496
1571
|
async delete(key) {
|
1497
|
-
__privateGet$
|
1572
|
+
__privateGet$3(this, _map).delete(key);
|
1498
1573
|
}
|
1499
1574
|
async clear() {
|
1500
|
-
return __privateGet$
|
1575
|
+
return __privateGet$3(this, _map).clear();
|
1501
1576
|
}
|
1502
1577
|
}
|
1503
1578
|
_map = new WeakMap();
|
@@ -1525,7 +1600,7 @@ var __accessCheck$2 = (obj, member, msg) => {
|
|
1525
1600
|
if (!member.has(obj))
|
1526
1601
|
throw TypeError("Cannot " + msg);
|
1527
1602
|
};
|
1528
|
-
var __privateGet$
|
1603
|
+
var __privateGet$2 = (obj, member, getter) => {
|
1529
1604
|
__accessCheck$2(obj, member, "read from private field");
|
1530
1605
|
return getter ? getter.call(obj) : member.get(obj);
|
1531
1606
|
};
|
@@ -1536,26 +1611,24 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
1536
1611
|
};
|
1537
1612
|
var _tables;
|
1538
1613
|
class SchemaPlugin extends XataPlugin {
|
1539
|
-
constructor(
|
1614
|
+
constructor(tableNames) {
|
1540
1615
|
super();
|
1541
|
-
this.links = links;
|
1542
1616
|
this.tableNames = tableNames;
|
1543
1617
|
__privateAdd$2(this, _tables, {});
|
1544
1618
|
}
|
1545
1619
|
build(pluginOptions) {
|
1546
|
-
const links = this.links;
|
1547
1620
|
const db = new Proxy({}, {
|
1548
1621
|
get: (_target, table) => {
|
1549
1622
|
if (!isString(table))
|
1550
1623
|
throw new Error("Invalid table name");
|
1551
|
-
if (!__privateGet$
|
1552
|
-
__privateGet$
|
1624
|
+
if (!__privateGet$2(this, _tables)[table]) {
|
1625
|
+
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
|
1553
1626
|
}
|
1554
|
-
return __privateGet$
|
1627
|
+
return __privateGet$2(this, _tables)[table];
|
1555
1628
|
}
|
1556
1629
|
});
|
1557
1630
|
for (const table of this.tableNames ?? []) {
|
1558
|
-
db[table] = new RestRepository({ db, pluginOptions, table
|
1631
|
+
db[table] = new RestRepository({ db, pluginOptions, table });
|
1559
1632
|
}
|
1560
1633
|
return db;
|
1561
1634
|
}
|
@@ -1566,44 +1639,65 @@ var __accessCheck$1 = (obj, member, msg) => {
|
|
1566
1639
|
if (!member.has(obj))
|
1567
1640
|
throw TypeError("Cannot " + msg);
|
1568
1641
|
};
|
1642
|
+
var __privateGet$1 = (obj, member, getter) => {
|
1643
|
+
__accessCheck$1(obj, member, "read from private field");
|
1644
|
+
return getter ? getter.call(obj) : member.get(obj);
|
1645
|
+
};
|
1569
1646
|
var __privateAdd$1 = (obj, member, value) => {
|
1570
1647
|
if (member.has(obj))
|
1571
1648
|
throw TypeError("Cannot add the same private member more than once");
|
1572
1649
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1573
1650
|
};
|
1651
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
1652
|
+
__accessCheck$1(obj, member, "write to private field");
|
1653
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
1654
|
+
return value;
|
1655
|
+
};
|
1574
1656
|
var __privateMethod$1 = (obj, member, method) => {
|
1575
1657
|
__accessCheck$1(obj, member, "access private method");
|
1576
1658
|
return method;
|
1577
1659
|
};
|
1578
|
-
var _search, search_fn;
|
1660
|
+
var _schema, _search, search_fn, _getSchema, getSchema_fn;
|
1579
1661
|
class SearchPlugin extends XataPlugin {
|
1580
|
-
constructor(db
|
1662
|
+
constructor(db) {
|
1581
1663
|
super();
|
1582
1664
|
this.db = db;
|
1583
|
-
this.links = links;
|
1584
1665
|
__privateAdd$1(this, _search);
|
1666
|
+
__privateAdd$1(this, _getSchema);
|
1667
|
+
__privateAdd$1(this, _schema, void 0);
|
1585
1668
|
}
|
1586
1669
|
build({ getFetchProps }) {
|
1587
1670
|
return {
|
1588
1671
|
all: async (query, options = {}) => {
|
1589
1672
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1673
|
+
const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
|
1590
1674
|
return records.map((record) => {
|
1591
1675
|
const { table = "orphan" } = record.xata;
|
1592
|
-
|
1676
|
+
const columns = schema.tables.find((t) => t.name === table)?.columns;
|
1677
|
+
if (!columns) {
|
1678
|
+
console.error(`No schema columns found for table ${table}`);
|
1679
|
+
}
|
1680
|
+
return { table, record: initObject(this.db, columns ?? [], table, record) };
|
1593
1681
|
});
|
1594
1682
|
},
|
1595
1683
|
byTable: async (query, options = {}) => {
|
1596
1684
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1685
|
+
const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
|
1597
1686
|
return records.reduce((acc, record) => {
|
1598
1687
|
const { table = "orphan" } = record.xata;
|
1688
|
+
const columns = schema.tables.find((t) => t.name === table)?.columns;
|
1689
|
+
if (!columns) {
|
1690
|
+
console.error(`No schema columns found for table ${table}`);
|
1691
|
+
}
|
1599
1692
|
const items = acc[table] ?? [];
|
1600
|
-
const item = initObject(this.db,
|
1693
|
+
const item = initObject(this.db, columns ?? [], table, record);
|
1601
1694
|
return { ...acc, [table]: [...items, item] };
|
1602
1695
|
}, {});
|
1603
1696
|
}
|
1604
1697
|
};
|
1605
1698
|
}
|
1606
1699
|
}
|
1700
|
+
_schema = new WeakMap();
|
1607
1701
|
_search = new WeakSet();
|
1608
1702
|
search_fn = async function(query, options, getFetchProps) {
|
1609
1703
|
const fetchProps = await getFetchProps();
|
@@ -1615,6 +1709,18 @@ search_fn = async function(query, options, getFetchProps) {
|
|
1615
1709
|
});
|
1616
1710
|
return records;
|
1617
1711
|
};
|
1712
|
+
_getSchema = new WeakSet();
|
1713
|
+
getSchema_fn = async function(getFetchProps) {
|
1714
|
+
if (__privateGet$1(this, _schema))
|
1715
|
+
return __privateGet$1(this, _schema);
|
1716
|
+
const fetchProps = await getFetchProps();
|
1717
|
+
const { schema } = await getBranchDetails({
|
1718
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1719
|
+
...fetchProps
|
1720
|
+
});
|
1721
|
+
__privateSet$1(this, _schema, schema);
|
1722
|
+
return schema;
|
1723
|
+
};
|
1618
1724
|
|
1619
1725
|
const isBranchStrategyBuilder = (strategy) => {
|
1620
1726
|
return typeof strategy === "function";
|
@@ -1723,7 +1829,7 @@ var __privateMethod = (obj, member, method) => {
|
|
1723
1829
|
const buildClient = (plugins) => {
|
1724
1830
|
var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
1725
1831
|
return _a = class {
|
1726
|
-
constructor(options = {},
|
1832
|
+
constructor(options = {}, tables) {
|
1727
1833
|
__privateAdd(this, _parseOptions);
|
1728
1834
|
__privateAdd(this, _getFetchProps);
|
1729
1835
|
__privateAdd(this, _evaluateBranch);
|
@@ -1733,8 +1839,8 @@ const buildClient = (plugins) => {
|
|
1733
1839
|
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
1734
1840
|
cache: safeOptions.cache
|
1735
1841
|
};
|
1736
|
-
const db = new SchemaPlugin(
|
1737
|
-
const search = new SearchPlugin(db
|
1842
|
+
const db = new SchemaPlugin(tables).build(pluginOptions);
|
1843
|
+
const search = new SearchPlugin(db).build(pluginOptions);
|
1738
1844
|
this.db = db;
|
1739
1845
|
this.search = search;
|
1740
1846
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
@@ -1825,6 +1931,7 @@ exports.XataApiPlugin = XataApiPlugin;
|
|
1825
1931
|
exports.XataError = XataError;
|
1826
1932
|
exports.XataPlugin = XataPlugin;
|
1827
1933
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
1934
|
+
exports.addGitBranchesEntry = addGitBranchesEntry;
|
1828
1935
|
exports.addTableColumn = addTableColumn;
|
1829
1936
|
exports.buildClient = buildClient;
|
1830
1937
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
@@ -1859,6 +1966,7 @@ exports.getCurrentBranchDetails = getCurrentBranchDetails;
|
|
1859
1966
|
exports.getCurrentBranchName = getCurrentBranchName;
|
1860
1967
|
exports.getDatabaseList = getDatabaseList;
|
1861
1968
|
exports.getDatabaseURL = getDatabaseURL;
|
1969
|
+
exports.getGitBranchesMapping = getGitBranchesMapping;
|
1862
1970
|
exports.getRecord = getRecord;
|
1863
1971
|
exports.getTableColumns = getTableColumns;
|
1864
1972
|
exports.getTableSchema = getTableSchema;
|
@@ -1887,8 +1995,10 @@ exports.notExists = notExists;
|
|
1887
1995
|
exports.operationsByTag = operationsByTag;
|
1888
1996
|
exports.pattern = pattern;
|
1889
1997
|
exports.queryTable = queryTable;
|
1998
|
+
exports.removeGitBranchesEntry = removeGitBranchesEntry;
|
1890
1999
|
exports.removeWorkspaceMember = removeWorkspaceMember;
|
1891
2000
|
exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
|
2001
|
+
exports.resolveBranch = resolveBranch;
|
1892
2002
|
exports.searchBranch = searchBranch;
|
1893
2003
|
exports.setTableSchema = setTableSchema;
|
1894
2004
|
exports.startsWith = startsWith;
|