datahike 0.8.1879 → 0.8.1882
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/boring.core.js +2 -2
- package/boring.data.js +7 -7
- package/boring.options.js +16 -16
- package/boring.reader.js +4 -4
- package/boring.writer.js +2 -2
- package/browser/datahike.js +3600 -3594
- package/cljs.cache.js +10 -10
- package/cljs.cache.wrapped.js +7 -7
- package/cljs.core.async.impl.channels.js +8 -8
- package/cljs.core.async.impl.dispatch.js +3 -3
- package/cljs.core.async.impl.ioc_helpers.js +2 -2
- package/cljs.core.async.impl.timers.js +5 -5
- package/cljs.core.async.js +15 -16
- package/cljs.core.js +521 -520
- package/cljs.nodejs.js +1 -1
- package/cljs.reader.js +12 -12
- package/cljs.spec.alpha.js +74 -74
- package/cljs.tools.reader.edn.js +26 -26
- package/cljs.tools.reader.impl.commons.js +7 -7
- package/cljs.tools.reader.impl.errors.js +10 -10
- package/cljs.tools.reader.impl.inspect.js +4 -4
- package/cljs.tools.reader.impl.utils.js +3 -3
- package/cljs.tools.reader.js +2 -2
- package/cljs.tools.reader.reader_types.js +1 -1
- package/cljs_env.js +16 -16
- package/cljs_node_io.core.js +11 -11
- package/cljs_node_io.file.js +26 -26
- package/cljs_node_io.fs.js +1 -1
- package/clojure.data.js +14 -14
- package/clojure.set.js +2 -2
- package/clojure.string.js +13 -13
- package/clojure.walk.js +3 -3
- package/datahike.api.impl.js +33 -33
- package/datahike.api.js +5 -5
- package/datahike.array.js +9 -9
- package/datahike.attr_preds.js +1 -1
- package/datahike.bitemporal.predicate.js +1 -1
- package/datahike.config.js +49 -49
- package/datahike.connections.js +4 -4
- package/datahike.connector.js +76 -76
- package/datahike.constants.js +20 -21
- package/datahike.core.js +1 -1
- package/datahike.datom.js +17 -17
- package/datahike.db.interface.js +11 -11
- package/datahike.db.js +93 -93
- package/datahike.db.search.js +49 -49
- package/datahike.db.transaction.js +11 -10
- package/datahike.db.utils.js +45 -45
- package/datahike.env.js +4 -4
- package/datahike.gc.js +12 -12
- package/datahike.gc_roots.js +1 -1
- package/datahike.impl.entity.js +16 -16
- package/datahike.index.interface.js +12 -12
- package/datahike.index.js +1 -1
- package/datahike.index.persistent_set.js +171 -171
- package/datahike.index.persistent_set.warm.js +1 -1
- package/datahike.index.secondary.js +5 -5
- package/datahike.js.api.js +260 -260
- package/datahike.js.convert.js +1 -1
- package/datahike.lru.js +6 -6
- package/datahike.metrics.js +10 -10
- package/datahike.online_gc.js +2 -2
- package/datahike.optimistic.js +12 -12
- package/datahike.pull_api.js +7 -7
- package/datahike.query.analyze.js +4 -4
- package/datahike.query.estimate.js +2 -2
- package/datahike.query.execute.js +7 -7
- package/datahike.query.ir.js +6 -6
- package/datahike.query.js +1386 -1387
- package/datahike.query.logical.js +2 -2
- package/datahike.query.lower.js +2 -2
- package/datahike.query.plan.js +12 -12
- package/datahike.query.relation.js +1 -1
- package/datahike.query.resolve.js +1 -1
- package/datahike.query_stats.js +1 -1
- package/datahike.readers.js +10 -10
- package/datahike.remote.js +1 -1
- package/datahike.schema.js +48 -48
- package/datahike.schema_cache.js +3 -3
- package/datahike.store.js +62 -62
- package/datahike.tools.js +5 -5
- package/datahike.tx_preds.js +1 -1
- package/datahike.versioning.js +4 -4
- package/datahike.writer.js +812 -809
- package/datahike.writing.js +52 -52
- package/datalog.parser.impl.js +4 -4
- package/datalog.parser.impl.proto.js +1 -1
- package/datalog.parser.impl.util.js +1 -1
- package/datalog.parser.js +1 -1
- package/datalog.parser.pull.js +3 -3
- package/datalog.parser.type.js +31 -31
- package/fress.api.js +1 -1
- package/fress.impl.adler32.js +4 -4
- package/fress.impl.bigdec.js +2 -2
- package/fress.impl.buffer.js +4 -4
- package/fress.impl.raw_input.js +1 -1
- package/fress.impl.raw_output.js +4 -4
- package/fress.impl.table.js +1 -1
- package/fress.reader.js +15 -15
- package/fress.util.js +11 -11
- package/fress.writer.js +24 -24
- package/geheimnis.aes.js +1 -1
- package/hasch.benc.js +3 -3
- package/hasch.core.js +11 -11
- package/hasch.platform.js +17 -17
- package/index.d.ts +2 -0
- package/is.simm.partial_cps.sequence.js +5 -5
- package/kabel/datahike.js +5244 -5239
- package/konserve.compressor.js +16 -16
- package/konserve.core.js +53 -53
- package/konserve.encryptor.js +11 -11
- package/konserve.gc.js +1 -1
- package/konserve.gc_guard.js +1 -1
- package/konserve.impl.defaults.js +15 -15
- package/konserve.impl.storage_layout.js +3 -3
- package/konserve.memory.js +1 -1
- package/konserve.metrics.js +6 -6
- package/konserve.node_filestore.js +605 -605
- package/konserve.protocols.js +7 -7
- package/konserve.serializers.js +18 -18
- package/konserve.store.js +97 -97
- package/konserve.tiered.js +10 -10
- package/konserve.utils.js +6 -6
- package/org.replikativ.persistent_sorted_set.branch.js +3 -3
- package/org.replikativ.persistent_sorted_set.btset.js +366 -366
- package/org.replikativ.persistent_sorted_set.fressian.js +5 -5
- package/org.replikativ.persistent_sorted_set.impl.boundary.js +1 -1
- package/org.replikativ.persistent_sorted_set.impl.nodes.js +2 -2
- package/org.replikativ.persistent_sorted_set.js +1 -1
- package/org.replikativ.persistent_sorted_set.leaf.js +1 -1
- package/org.replikativ.persistent_sorted_set.util.js +1 -1
- package/org.replikativ.persistent_sorted_set.warm.js +1 -1
- package/package.json +1 -1
- package/remote/api.generated.d.ts +1 -1
- package/remote/core.d.ts +8 -1
- package/remote/index.d.ts +4 -2
- package/remote/index.js +68 -9
- package/remote/index.mjs +67 -10
- package/replikativ.logging.js +1 -1
- package/replikativ.metrics.js +1 -1
- package/s3/datahike.js +4468 -4462
- package/superv.async.js +26 -26
- package/tailrecursion.priority_map.js +16 -16
- package/taoensso.trove.console.js +4 -4
- package/taoensso.trove.js +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var window=global;var $CLJS=require("./cljs_env.js");require("./cljs.core.js");require("./org.replikativ.persistent_sorted_set.impl.nodes.js");require("./fress.api.js");require("./org.replikativ.persistent_sorted_set.leaf.js");require("./org.replikativ.persistent_sorted_set.branch.js");require("./org.replikativ.persistent_sorted_set.btset.js");
|
|
2
|
-
'use strict';var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
$CLJS.
|
|
6
|
-
|
|
2
|
+
'use strict';var SF,Sla,Tla,Vla;$CLJS.RF=function(a,b){return $CLJS.gy(a,b)};SF=function(a){if(a!=null&&a.Ho!=null)a=a.Ho(a);else{var b=SF[$CLJS.ab(a==null?null:a)];if(b!=null)a=b.g?b.g(a):b.call(null,a);else if(b=SF._,b!=null)a=b.g?b.g(a):b.call(null,a);else throw $CLJS.Xb("PBoundary.-descriptor",a);}return a};
|
|
3
|
+
Sla=function(a){if(a.address==null)throw $CLJS.ul("PSS root must be flushed before serialization",new $CLJS.S(null,1,[$CLJS.Wm,$CLJS.Rla],null));var b=a.K,c=function(){var d=$CLJS.jB.g(b);return $CLJS.u(d)?SF(d):null}();a=new $CLJS.S(null,5,[$CLJS.Hk,$CLJS.tf(a),$CLJS.OF,a.address,$CLJS.Zm,a.U,$CLJS.kB,$CLJS.kB.g(b),$CLJS.AB,function(){var d=$CLJS.AB.g(b);return $CLJS.u(d)?d:0}()],null);a=$CLJS.u($CLJS.QF.g(b))?$CLJS.ak.i(a,$CLJS.QF,$CLJS.QF.g(b)):a;return $CLJS.u(c)?$CLJS.ak.i(a,$CLJS.jB,c):a};
|
|
4
|
+
Tla=function(a){var b=a.K;a=function(){var d=$CLJS.jB.g(b);return $CLJS.u(d)?SF(d):null}();var c=new $CLJS.S(null,2,[$CLJS.kB,$CLJS.kB.g(b),$CLJS.AB,function(){var d=$CLJS.AB.g(b);return $CLJS.u(d)?d:0}()],null);c=$CLJS.u($CLJS.QF.g(b))?$CLJS.ak.i(c,$CLJS.QF,$CLJS.QF.g(b)):c;return $CLJS.u(a)?$CLJS.ak.i(c,$CLJS.jB,a):c};
|
|
5
|
+
$CLJS.Ula=function(a){var b=a.ya;if(b==null)return null;for(var c=a.keys.length,d=a.level===1,e=0,f=$CLJS.eh;;){if(e>=c)return $CLJS.Xe(f)>0?f:null;var g=b[e];if(g==null){var h=f;e+=1;f=h}else h=e+1,f=$CLJS.ak.i(f,e,new $CLJS.S(null,4,[$CLJS.Zm,$CLJS.Zm.g(g),$CLJS.mB,$CLJS.mB.g(g),$CLJS.qB,d?$CLJS.MC($CLJS.qB.g(g)):$CLJS.qB.g(g),$CLJS.xB,a.keys[e]],null)),e=h}};
|
|
6
|
+
Vla=function(a){var b=$CLJS.Ho.l;if(a instanceof $CLJS.NC){var c=$CLJS.Ula(a);var d=new $CLJS.S(null,4,[$CLJS.zp,a.Yi(null),$CLJS.zm,$CLJS.Fi(a.keys),$CLJS.uB,$CLJS.Fi(a.ua),$CLJS.rB,a.tc],null);d=a.pa!=null?$CLJS.ak.i(d,$CLJS.mB,a.pa):d;c=$CLJS.u(c)?$CLJS.ak.i(d,$CLJS.om,c):d}else c=new $CLJS.S(null,1,[$CLJS.zm,$CLJS.Fi(a.keys)],null),c=a.pa!=null?$CLJS.ak.i(c,$CLJS.mB,a.pa):c;return b.call($CLJS.Ho,$CLJS.hf([c,Tla(a)]))};$CLJS.Wla=$CLJS.dh([$CLJS.HC,function(a,b){$CLJS.dy(a,"pss/leaf",1);return $CLJS.RF(a,Vla(b))},$CLJS.NC,function(a,b){$CLJS.dy(a,"pss/branch",1);return $CLJS.RF(a,Vla(b))}]);$CLJS.Xla=$CLJS.dh([$CLJS.hD,function(a,b){$CLJS.dy(a,"pss/set",1);return $CLJS.RF(a,Sla(b))}]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var window=global;var $CLJS=require("./cljs_env.js");require("./cljs.core.js");
|
|
2
|
-
'use strict';$CLJS.
|
|
2
|
+
'use strict';$CLJS.jB=new $CLJS.H(null,"boundary","boundary",-2000996754);$CLJS.Oka=$CLJS.xh(null);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
var window=global;var $CLJS=require("./cljs_env.js");require("./cljs.core.js");require("./org.replikativ.persistent_sorted_set.impl.boundary.js");require("./org.replikativ.persistent_sorted_set.leaf.js");require("./org.replikativ.persistent_sorted_set.branch.js");require("./org.replikativ.persistent_sorted_set.btset.js");
|
|
2
|
-
'use strict';$CLJS.
|
|
3
|
-
$CLJS.
|
|
2
|
+
'use strict';$CLJS.LF=new $CLJS.H(null,"default-bf","default-bf",-1431077803);$CLJS.MF=new $CLJS.H(null,"resolve-measure","resolve-measure",1235395818);$CLJS.NF=new $CLJS.H(null,"resolve-cmp","resolve-cmp",125224489);$CLJS.Ola=new $CLJS.H(null,"mk-settings","mk-settings",-829192421);$CLJS.Pla=new $CLJS.H("pss","storage-id","pss/storage-id",1127028971);$CLJS.Qla=new $CLJS.H(null,"measure-ops","measure-ops",188679997);$CLJS.OF=new $CLJS.H(null,"address","address",559499426);
|
|
3
|
+
$CLJS.Rla=new $CLJS.H(null,"must-be-flushed","must-be-flushed",468354549);$CLJS.PF=new $CLJS.H(null,"resolve-storage","resolve-storage",1895103074);$CLJS.QF=new $CLJS.H(null,"ref-type","ref-type",-1367328851);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var window=global;var $CLJS=require("./cljs_env.js");require("./cljs.core.js");require("./clojure.string.js");require("./org.replikativ.persistent_sorted_set.btset.js");
|
|
2
|
-
'use strict';$CLJS.
|
|
2
|
+
'use strict';$CLJS.MD=function(a,b,c){return $CLJS.gD(a,b,c)};$CLJS.pla=new $CLJS.S(null,2,[$CLJS.kB,512,$CLJS.AB,0],null);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var window=global;var $CLJS=require("./cljs_env.js");require("./cljs.core.js");require("./clojure.string.js");require("./org.replikativ.persistent_sorted_set.impl.boundary.js");require("./org.replikativ.persistent_sorted_set.util.js");
|
|
2
|
-
'use strict';$CLJS.
|
|
2
|
+
'use strict';$CLJS.lB=new $CLJS.H(null,"removed-out","removed-out",780264512);$CLJS.mB=new $CLJS.H(null,"measure","measure",-1857519826);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var window=global;var $CLJS=require("./cljs_env.js");require("./cljs.core.js");require("./clojure.string.js");
|
|
2
|
-
'use strict';$CLJS.
|
|
2
|
+
'use strict';$CLJS.kB=new $CLJS.H(null,"branching-factor","branching-factor",1903198601);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var window=global;var $CLJS=require("./cljs_env.js");require("./cljs.core.js");require("./org.replikativ.persistent_sorted_set.btset.js");require("./org.replikativ.persistent_sorted_set.branch.js");require("./org.replikativ.persistent_sorted_set.util.js");require("./clojure.string.js");
|
|
2
|
-
'use strict';$CLJS.
|
|
2
|
+
'use strict';$CLJS.Yla=new $CLJS.H(null,"done","done",-889844188);$CLJS.TF=new $CLJS.H(null,"depth","depth",1768663640);
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"types" : "index.d.ts",
|
|
18
18
|
"author" : "Christian Weilbach",
|
|
19
19
|
"files" : [ "*.js", "!test*.js", "*.js.map", "browser/datahike.js", "browser/index.mjs", "browser/index.js", "s3/datahike.js", "s3/index.mjs", "s3/index.js", "kabel/datahike.js", "kabel/index.mjs", "kabel/index.js", "remote/index.mjs", "remote/index.js", "remote/*.d.ts", "index.d.ts", "kabel.d.ts", "README.md", "LICENSE", "THIRD_PARTY_LICENSES.md" ],
|
|
20
|
-
"version" : "0.8.
|
|
20
|
+
"version" : "0.8.1882",
|
|
21
21
|
"publishConfig" : {
|
|
22
22
|
"access" : "public",
|
|
23
23
|
"registry" : "https://registry.npmjs.org/"
|
|
@@ -145,7 +145,7 @@ export declare function seekDatoms(db: Database, indexOrOptions: ":eavt" | ":aev
|
|
|
145
145
|
*/
|
|
146
146
|
export declare function since(arg0: Database, arg1: number | Date): Promise<Database>;
|
|
147
147
|
/**
|
|
148
|
-
* Applies transaction to the database and updates connection. Blocks until committed. WARNING: Do not call from listener callbacks or transaction functions — use transact! instead to avoid deadlocks.
|
|
148
|
+
* Applies transaction to the database and updates connection. Blocks until committed. The map form accepts :tx-options {:allow-index-backfill? true} to permit index/uniqueness backfill for this transaction only; it does not change the database config. WARNING: Do not call from listener callbacks or transaction functions — use transact! instead to avoid deadlocks.
|
|
149
149
|
*/
|
|
150
150
|
export declare function transact(arg0: Connection, arg1: Transaction[] | WithArgs): Promise<TransactionReport>;
|
|
151
151
|
/**
|
package/remote/core.d.ts
CHANGED
|
@@ -52,6 +52,9 @@ export type Transaction = [":db/add", EntityId, Attribute, any] | [":db/retract"
|
|
|
52
52
|
export interface WithArgs {
|
|
53
53
|
"tx-data": Transaction[];
|
|
54
54
|
"tx-meta"?: any;
|
|
55
|
+
"tx-options"?: {
|
|
56
|
+
"allow-index-backfill?"?: boolean;
|
|
57
|
+
} | null;
|
|
55
58
|
}
|
|
56
59
|
export interface QueryArgs {
|
|
57
60
|
query: string | any[] | Record<string, any>;
|
|
@@ -124,7 +127,11 @@ export interface RemoteReport {
|
|
|
124
127
|
error?: Error;
|
|
125
128
|
status?: number;
|
|
126
129
|
}
|
|
127
|
-
export declare function
|
|
130
|
+
export declare function configureCache({ maxEntries }: {
|
|
131
|
+
maxEntries: number;
|
|
132
|
+
}): void;
|
|
133
|
+
export declare function clearCache(): void;
|
|
134
|
+
export declare function request(route: string, referentiallyTransparent: boolean, args: unknown[], create?: boolean): Promise<any>;
|
|
128
135
|
export declare function uuid(value: string): DatahikeUuid;
|
|
129
136
|
export declare function randomUuid(): DatahikeUuid;
|
|
130
137
|
export declare function isPromise(value: any): value is Promise<unknown>;
|
package/remote/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { isPromise, listen, randomUuid, unlisten, uuid } from "./core.js";
|
|
1
|
+
import { clearCache, configureCache, isPromise, listen, randomUuid, unlisten, uuid } from "./core.js";
|
|
2
2
|
export * from "./api.generated.js";
|
|
3
3
|
export type * from "./core.js";
|
|
4
|
-
export { isPromise, listen, randomUuid, unlisten, uuid };
|
|
4
|
+
export { clearCache, configureCache, isPromise, listen, randomUuid, unlisten, uuid };
|
|
5
5
|
declare const _default: {
|
|
6
|
+
clearCache: typeof clearCache;
|
|
7
|
+
configureCache: typeof configureCache;
|
|
6
8
|
isPromise: typeof isPromise;
|
|
7
9
|
listen: typeof listen;
|
|
8
10
|
randomUuid: typeof randomUuid;
|
package/remote/index.js
CHANGED
|
@@ -37,6 +37,8 @@ exports.validAll = validAll;
|
|
|
37
37
|
exports.validAt = validAt;
|
|
38
38
|
exports.validBetween = validBetween;
|
|
39
39
|
exports.validDuring = validDuring;
|
|
40
|
+
exports.clearCache = clearCache;
|
|
41
|
+
exports.configureCache = configureCache;
|
|
40
42
|
exports.isPromise = isPromise;
|
|
41
43
|
exports.listen = listen;
|
|
42
44
|
exports.randomUuid = randomUuid;
|
|
@@ -46,6 +48,8 @@ const tagSymbol = Symbol("datahike.tag");
|
|
|
46
48
|
const rawSymbol = Symbol("datahike.raw");
|
|
47
49
|
const peerSymbol = Symbol("datahike.peer");
|
|
48
50
|
const uuidSymbol = Symbol("datahike.uuid");
|
|
51
|
+
const resultCache = new Map();
|
|
52
|
+
let maxCacheEntries = 128;
|
|
49
53
|
const handleTags = new Set([
|
|
50
54
|
"!datahike/Connection",
|
|
51
55
|
"!datahike/DB",
|
|
@@ -130,6 +134,37 @@ function encodeValue(value) {
|
|
|
130
134
|
}
|
|
131
135
|
return value;
|
|
132
136
|
}
|
|
137
|
+
function cacheableArguments(value) {
|
|
138
|
+
let database = false;
|
|
139
|
+
let connection = false;
|
|
140
|
+
const visit = (item) => {
|
|
141
|
+
if (!Array.isArray(item)) {
|
|
142
|
+
if (item !== null && typeof item === "object")
|
|
143
|
+
Object.values(item).forEach(visit);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (item[0] === "!datahike/Connection")
|
|
147
|
+
connection = true;
|
|
148
|
+
if (["!datahike/DB", "!datahike/HistoricalDB", "!datahike/SinceDB", "!datahike/AsOfDB"].includes(item[0])) {
|
|
149
|
+
database = true;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
item.forEach(visit);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
visit(value);
|
|
156
|
+
return database && !connection;
|
|
157
|
+
}
|
|
158
|
+
function configureCache({ maxEntries }) {
|
|
159
|
+
if (!Number.isInteger(maxEntries) || maxEntries < 0)
|
|
160
|
+
throw new RangeError("maxEntries must be a non-negative integer.");
|
|
161
|
+
maxCacheEntries = maxEntries;
|
|
162
|
+
while (resultCache.size > maxEntries)
|
|
163
|
+
resultCache.delete(resultCache.keys().next().value);
|
|
164
|
+
}
|
|
165
|
+
function clearCache() {
|
|
166
|
+
resultCache.clear();
|
|
167
|
+
}
|
|
133
168
|
function peerFromArgs(args) {
|
|
134
169
|
const peers = new Set();
|
|
135
170
|
const first = args[0];
|
|
@@ -210,10 +245,22 @@ async function responseValue(response, target, peer) {
|
|
|
210
245
|
}
|
|
211
246
|
return decoded;
|
|
212
247
|
}
|
|
213
|
-
|
|
248
|
+
function request(route, referentiallyTransparent, args, create = false) {
|
|
214
249
|
const peer = peerFromArgs(args);
|
|
215
|
-
const
|
|
216
|
-
const
|
|
250
|
+
const encodedArgs = encodeValue(normalizeSetArguments(route, withoutCredentials(args)));
|
|
251
|
+
const encodedString = JSON.stringify(encodedArgs);
|
|
252
|
+
const encoded = new TextEncoder().encode(encodedString);
|
|
253
|
+
const cacheKey = `${route}\0${encodedString}`;
|
|
254
|
+
const cacheable = referentiallyTransparent && maxCacheEntries > 0 && cacheableArguments(encodedArgs);
|
|
255
|
+
if (cacheable) {
|
|
256
|
+
const cached = resultCache.get(cacheKey);
|
|
257
|
+
if (cached) {
|
|
258
|
+
resultCache.delete(cacheKey);
|
|
259
|
+
resultCache.set(cacheKey, cached);
|
|
260
|
+
return cached;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const asGet = referentiallyTransparent && encoded.byteLength <= 2048;
|
|
217
264
|
const base = `${peer.url}/${route}`;
|
|
218
265
|
const target = asGet ? `${base}?args=${base64url(encoded)}&f=json` : base;
|
|
219
266
|
const headers = { Accept: "application/json" };
|
|
@@ -221,15 +268,27 @@ async function request(route, readable, args, create = false) {
|
|
|
221
268
|
headers["Content-Type"] = "application/json";
|
|
222
269
|
if (peer.token)
|
|
223
270
|
headers.Authorization = `token ${peer.token}`;
|
|
224
|
-
const
|
|
271
|
+
const promise = fetch(target, {
|
|
225
272
|
method: asGet ? "GET" : "POST",
|
|
226
273
|
headers,
|
|
227
274
|
...(asGet ? {} : { body: encoded }),
|
|
275
|
+
}).then((response) => responseValue(response, target, peer)).then((result) => {
|
|
276
|
+
if (create && result !== null && typeof result === "object")
|
|
277
|
+
result["remote-peer"] = peer;
|
|
278
|
+
return result;
|
|
228
279
|
});
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
280
|
+
if (cacheable) {
|
|
281
|
+
const cached = promise.catch((error) => {
|
|
282
|
+
if (resultCache.get(cacheKey) === cached)
|
|
283
|
+
resultCache.delete(cacheKey);
|
|
284
|
+
throw error;
|
|
285
|
+
});
|
|
286
|
+
resultCache.set(cacheKey, cached);
|
|
287
|
+
if (resultCache.size > maxCacheEntries)
|
|
288
|
+
resultCache.delete(resultCache.keys().next().value);
|
|
289
|
+
return cached;
|
|
290
|
+
}
|
|
291
|
+
return promise;
|
|
233
292
|
}
|
|
234
293
|
function uuid(value) {
|
|
235
294
|
const out = { value };
|
|
@@ -518,6 +577,6 @@ function validBetween(...args) {
|
|
|
518
577
|
function validDuring(...args) {
|
|
519
578
|
return request("valid-during", true, args, false);
|
|
520
579
|
}
|
|
521
|
-
exports.default = { asOf, branch, branchAsDb, branches, commitAsDb, commitId, connect, createDatabase, databaseExists, datoms, db, deleteBranch, deleteDatabase, entity, entityDb, gcStorage, history, indexRange, loadEntities, mergeDb, metrics, parentCommitIds, pull, pullMany, q, queryStats, release, reverseSchema, rseekDatoms, schema, seekDatoms, since, transact, validAll, validAt, validBetween, validDuring, isPromise, listen, randomUuid, unlisten, uuid };
|
|
580
|
+
exports.default = { asOf, branch, branchAsDb, branches, commitAsDb, commitId, connect, createDatabase, databaseExists, datoms, db, deleteBranch, deleteDatabase, entity, entityDb, gcStorage, history, indexRange, loadEntities, mergeDb, metrics, parentCommitIds, pull, pullMany, q, queryStats, release, reverseSchema, rseekDatoms, schema, seekDatoms, since, transact, validAll, validAt, validBetween, validDuring, clearCache, configureCache, isPromise, listen, randomUuid, unlisten, uuid };
|
|
522
581
|
|
|
523
582
|
module.exports = exports.default;
|
package/remote/index.mjs
CHANGED
|
@@ -2,6 +2,8 @@ const tagSymbol = Symbol("datahike.tag");
|
|
|
2
2
|
const rawSymbol = Symbol("datahike.raw");
|
|
3
3
|
const peerSymbol = Symbol("datahike.peer");
|
|
4
4
|
const uuidSymbol = Symbol("datahike.uuid");
|
|
5
|
+
const resultCache = new Map();
|
|
6
|
+
let maxCacheEntries = 128;
|
|
5
7
|
const handleTags = new Set([
|
|
6
8
|
"!datahike/Connection",
|
|
7
9
|
"!datahike/DB",
|
|
@@ -86,6 +88,37 @@ function encodeValue(value) {
|
|
|
86
88
|
}
|
|
87
89
|
return value;
|
|
88
90
|
}
|
|
91
|
+
function cacheableArguments(value) {
|
|
92
|
+
let database = false;
|
|
93
|
+
let connection = false;
|
|
94
|
+
const visit = (item) => {
|
|
95
|
+
if (!Array.isArray(item)) {
|
|
96
|
+
if (item !== null && typeof item === "object")
|
|
97
|
+
Object.values(item).forEach(visit);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (item[0] === "!datahike/Connection")
|
|
101
|
+
connection = true;
|
|
102
|
+
if (["!datahike/DB", "!datahike/HistoricalDB", "!datahike/SinceDB", "!datahike/AsOfDB"].includes(item[0])) {
|
|
103
|
+
database = true;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
item.forEach(visit);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
visit(value);
|
|
110
|
+
return database && !connection;
|
|
111
|
+
}
|
|
112
|
+
function configureCache({ maxEntries }) {
|
|
113
|
+
if (!Number.isInteger(maxEntries) || maxEntries < 0)
|
|
114
|
+
throw new RangeError("maxEntries must be a non-negative integer.");
|
|
115
|
+
maxCacheEntries = maxEntries;
|
|
116
|
+
while (resultCache.size > maxEntries)
|
|
117
|
+
resultCache.delete(resultCache.keys().next().value);
|
|
118
|
+
}
|
|
119
|
+
function clearCache() {
|
|
120
|
+
resultCache.clear();
|
|
121
|
+
}
|
|
89
122
|
function peerFromArgs(args) {
|
|
90
123
|
const peers = new Set();
|
|
91
124
|
const first = args[0];
|
|
@@ -166,10 +199,22 @@ async function responseValue(response, target, peer) {
|
|
|
166
199
|
}
|
|
167
200
|
return decoded;
|
|
168
201
|
}
|
|
169
|
-
|
|
202
|
+
function request(route, referentiallyTransparent, args, create = false) {
|
|
170
203
|
const peer = peerFromArgs(args);
|
|
171
|
-
const
|
|
172
|
-
const
|
|
204
|
+
const encodedArgs = encodeValue(normalizeSetArguments(route, withoutCredentials(args)));
|
|
205
|
+
const encodedString = JSON.stringify(encodedArgs);
|
|
206
|
+
const encoded = new TextEncoder().encode(encodedString);
|
|
207
|
+
const cacheKey = `${route}\0${encodedString}`;
|
|
208
|
+
const cacheable = referentiallyTransparent && maxCacheEntries > 0 && cacheableArguments(encodedArgs);
|
|
209
|
+
if (cacheable) {
|
|
210
|
+
const cached = resultCache.get(cacheKey);
|
|
211
|
+
if (cached) {
|
|
212
|
+
resultCache.delete(cacheKey);
|
|
213
|
+
resultCache.set(cacheKey, cached);
|
|
214
|
+
return cached;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const asGet = referentiallyTransparent && encoded.byteLength <= 2048;
|
|
173
218
|
const base = `${peer.url}/${route}`;
|
|
174
219
|
const target = asGet ? `${base}?args=${base64url(encoded)}&f=json` : base;
|
|
175
220
|
const headers = { Accept: "application/json" };
|
|
@@ -177,15 +222,27 @@ async function request(route, readable, args, create = false) {
|
|
|
177
222
|
headers["Content-Type"] = "application/json";
|
|
178
223
|
if (peer.token)
|
|
179
224
|
headers.Authorization = `token ${peer.token}`;
|
|
180
|
-
const
|
|
225
|
+
const promise = fetch(target, {
|
|
181
226
|
method: asGet ? "GET" : "POST",
|
|
182
227
|
headers,
|
|
183
228
|
...(asGet ? {} : { body: encoded }),
|
|
229
|
+
}).then((response) => responseValue(response, target, peer)).then((result) => {
|
|
230
|
+
if (create && result !== null && typeof result === "object")
|
|
231
|
+
result["remote-peer"] = peer;
|
|
232
|
+
return result;
|
|
184
233
|
});
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
234
|
+
if (cacheable) {
|
|
235
|
+
const cached = promise.catch((error) => {
|
|
236
|
+
if (resultCache.get(cacheKey) === cached)
|
|
237
|
+
resultCache.delete(cacheKey);
|
|
238
|
+
throw error;
|
|
239
|
+
});
|
|
240
|
+
resultCache.set(cacheKey, cached);
|
|
241
|
+
if (resultCache.size > maxCacheEntries)
|
|
242
|
+
resultCache.delete(resultCache.keys().next().value);
|
|
243
|
+
return cached;
|
|
244
|
+
}
|
|
245
|
+
return promise;
|
|
189
246
|
}
|
|
190
247
|
function uuid(value) {
|
|
191
248
|
const out = { value };
|
|
@@ -476,5 +533,5 @@ export function validDuring(...args) {
|
|
|
476
533
|
return request("valid-during", true, args, false);
|
|
477
534
|
}
|
|
478
535
|
|
|
479
|
-
export { isPromise, listen, randomUuid, unlisten, uuid };
|
|
480
|
-
export default { asOf, branch, branchAsDb, branches, commitAsDb, commitId, connect, createDatabase, databaseExists, datoms, db, deleteBranch, deleteDatabase, entity, entityDb, gcStorage, history, indexRange, loadEntities, mergeDb, metrics, parentCommitIds, pull, pullMany, q, queryStats, release, reverseSchema, rseekDatoms, schema, seekDatoms, since, transact, validAll, validAt, validBetween, validDuring, isPromise, listen, randomUuid, unlisten, uuid };
|
|
536
|
+
export { clearCache, configureCache, isPromise, listen, randomUuid, unlisten, uuid };
|
|
537
|
+
export default { asOf, branch, branchAsDb, branches, commitAsDb, commitId, connect, createDatabase, databaseExists, datoms, db, deleteBranch, deleteDatabase, entity, entityDb, gcStorage, history, indexRange, loadEntities, mergeDb, metrics, parentCommitIds, pull, pullMany, q, queryStats, release, reverseSchema, rseekDatoms, schema, seekDatoms, since, transact, validAll, validAt, validBetween, validDuring, clearCache, configureCache, isPromise, listen, randomUuid, unlisten, uuid };
|
package/replikativ.logging.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var window=global;var $CLJS=require("./cljs_env.js");require("./cljs.core.js");require("./taoensso.trove.js");
|
|
2
|
-
'use strict';$CLJS.
|
|
2
|
+
'use strict';$CLJS.Fp=new $CLJS.H(null,"ref","ref",1289896967);$CLJS.Gp=new $CLJS.H(null,"conn","conn",278309663);$CLJS.Hp=new $CLJS.H(null,"warn","warn",-436710552);$CLJS.Ip=new $CLJS.H(null,"eavt","eavt",-666437073);
|
package/replikativ.metrics.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var window=global;var $CLJS=require("./cljs_env.js");require("./cljs.core.js");
|
|
2
|
-
'use strict';$CLJS.
|
|
2
|
+
'use strict';$CLJS.GO=new $CLJS.H(null,"counter","counter",804008177);$CLJS.HO=new $CLJS.H(null,"help","help",-439233446);$CLJS.IO=new $CLJS.H(null,"gauge","gauge",63470758);$CLJS.JO=new $CLJS.H(null,"series","series",600710694);$CLJS.Ura=new $CLJS.H(null,"sum","sum",136986814);$CLJS.KO=new $CLJS.H(null,"histogram","histogram",44258148);$CLJS.LO=new $CLJS.H(null,"buckets","buckets",-1916554731);$CLJS.Vra=new $CLJS.N(null,13,5,$CLJS.R,[.001,.0025,.005,.01,.025,.05,.1,.25,.5,1,2.5,5,10],null);$CLJS.MO=$CLJS.xh($CLJS.eh);
|