datahike 0.8.1864 → 0.8.1866
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/README.md +79 -0
- package/boring.data.js +1 -1
- package/boring.options.js +7 -7
- package/browser/datahike.js +2480 -2480
- package/cljs.cache.js +4 -4
- package/cljs.cache.wrapped.js +1 -1
- 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 +2 -2
- package/cljs.core.async.js +15 -15
- package/cljs.core.js +165 -164
- package/cljs.reader.js +11 -11
- package/cljs.spec.alpha.js +71 -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 +2 -2
- package/cljs.tools.reader.js +2 -2
- package/cljs.tools.reader.reader_types.js +1 -1
- package/cljs_env.js +8 -8
- package/cljs_node_io.core.js +7 -7
- package/cljs_node_io.file.js +10 -10
- package/clojure.data.js +14 -14
- package/clojure.set.js +1 -1
- package/clojure.string.js +9 -6
- package/clojure.walk.js +25 -26
- package/datahike.api.impl.js +30 -30
- package/datahike.api.js +15 -15
- package/datahike.api.specification.js +90 -90
- package/datahike.api.types.js +17 -17
- package/datahike.array.js +4 -4
- package/datahike.attr_preds.js +1 -1
- package/datahike.bitemporal.predicate.js +1 -1
- package/datahike.config.js +47 -47
- package/datahike.connections.js +3 -3
- package/datahike.connector.js +78 -78
- package/datahike.constants.js +2 -2
- package/datahike.core.js +1 -1
- package/datahike.datom.js +6 -7
- package/datahike.db.interface.js +11 -11
- package/datahike.db.js +90 -90
- package/datahike.db.search.js +47 -47
- package/datahike.db.transaction.js +11 -11
- package/datahike.db.utils.js +48 -48
- package/datahike.env.js +4 -4
- package/datahike.gc.js +12 -12
- package/datahike.gc_roots.js +2 -2
- package/datahike.impl.entity.js +16 -16
- package/datahike.index.interface.js +11 -11
- package/datahike.index.js +1 -1
- package/datahike.index.persistent_set.js +156 -156
- package/datahike.index.persistent_set.warm.js +1 -1
- package/datahike.index.secondary.js +5 -5
- package/datahike.js.api.js +209 -209
- package/datahike.lru.js +6 -6
- package/datahike.metrics.js +10 -10
- package/datahike.migrate.ids.js +1 -1
- 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 +5 -5
- package/datahike.query.js +1202 -1202
- 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_stats.js +1 -1
- package/datahike.readers.js +11 -11
- package/datahike.schema.js +48 -47
- package/datahike.schema_cache.js +3 -3
- package/datahike.store.js +59 -59
- package/datahike.tools.js +1 -1
- package/datahike.tx_preds.js +1 -1
- package/datahike.versioning.js +3 -3
- package/datahike.writer.js +775 -775
- 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 +26 -26
- package/fress.reader.js +3 -3
- package/fress.util.js +8 -8
- package/fress.writer.js +5 -5
- package/hasch.benc.js +2 -2
- package/hasch.core.js +5 -5
- package/hasch.platform.js +11 -11
- package/index.d.ts +27 -1
- package/is.simm.partial_cps.sequence.js +1 -1
- package/kabel/datahike.js +5790 -0
- package/kabel/index.js +3 -0
- package/kabel/index.mjs +82 -0
- package/kabel.d.ts +72 -0
- package/konserve.compressor.js +3 -3
- package/konserve.core.js +50 -50
- package/konserve.encryptor.js +6 -6
- package/konserve.gc.js +1 -1
- package/konserve.gc_guard.js +1 -1
- package/konserve.impl.defaults.js +3 -3
- package/konserve.impl.storage_layout.js +1 -1
- package/konserve.metrics.js +4 -4
- package/konserve.node_filestore.js +450 -450
- package/konserve.protocols.js +2 -2
- package/konserve.serializers.js +10 -10
- package/konserve.store.js +79 -79
- package/konserve.tiered.js +1 -1
- package/konserve.utils.js +5 -5
- package/malli.core.js +270 -270
- package/malli.error.js +32 -32
- package/malli.impl.util.js +1 -1
- package/malli.registry.js +1 -1
- package/malli.util.js +1 -1
- package/org.replikativ.persistent_sorted_set.btset.js +249 -249
- package/org.replikativ.persistent_sorted_set.fressian.js +5 -5
- package/org.replikativ.persistent_sorted_set.impl.nodes.js +2 -2
- package/org.replikativ.persistent_sorted_set.warm.js +1 -1
- package/package.json +13 -3
- package/replikativ.logging.js +1 -1
- package/replikativ.metrics.js +1 -1
- package/s3/datahike.js +4438 -4437
- package/superv.async.js +15 -15
- package/tailrecursion.priority_map.js +9 -9
- package/taoensso.trove.console.js +2 -2
- package/taoensso.trove.js +1 -1
package/README.md
CHANGED
|
@@ -89,6 +89,85 @@ initial level (for example, `DATAHIKE_LOG_LEVEL=off node app.js`).
|
|
|
89
89
|
|
|
90
90
|
## Documentation
|
|
91
91
|
|
|
92
|
+
### Replicated browser client (Kabel + IndexedDB)
|
|
93
|
+
|
|
94
|
+
Use the opt-in `datahike/kabel` entry when the browser should keep a local
|
|
95
|
+
queryable replica and send writes to a Datahike server over Kabel. The store ID
|
|
96
|
+
must identify the same database on the client and server.
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import * as d from 'datahike/kabel';
|
|
100
|
+
|
|
101
|
+
const storeId = d.uuid('550e8400-e29b-41d4-a716-446655440000');
|
|
102
|
+
const serverId = d.uuid('aaaaaaaa-0000-0000-0000-000000000001');
|
|
103
|
+
const peer = d.createKabelPeer(d.randomUuid(), { token: accessToken });
|
|
104
|
+
|
|
105
|
+
await d.connectKabelPeer(peer, 'wss://data.example.com');
|
|
106
|
+
|
|
107
|
+
const conn = await d.connect({
|
|
108
|
+
store: {
|
|
109
|
+
backend: ':tiered',
|
|
110
|
+
id: storeId,
|
|
111
|
+
'frontend-config': { backend: ':memory', id: storeId },
|
|
112
|
+
'backend-config': {
|
|
113
|
+
backend: ':indexeddb',
|
|
114
|
+
id: storeId,
|
|
115
|
+
name: 'my-app'
|
|
116
|
+
},
|
|
117
|
+
'write-policy': ':write-through'
|
|
118
|
+
},
|
|
119
|
+
writer: {
|
|
120
|
+
backend: ':kabel',
|
|
121
|
+
'peer-id': serverId,
|
|
122
|
+
'local-peer': peer
|
|
123
|
+
}
|
|
124
|
+
}, { 'sync?': false });
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The matching standalone-server configuration is:
|
|
128
|
+
|
|
129
|
+
```clojure
|
|
130
|
+
{:kabel {:host "127.0.0.1"
|
|
131
|
+
:port 47296
|
|
132
|
+
:peer-id #uuid "aaaaaaaa-0000-0000-0000-000000000001"
|
|
133
|
+
:jwt {:alg :HS256
|
|
134
|
+
:secret "application-jwt-secret"
|
|
135
|
+
:required-claims {:iss "my-app" :aud "datahike"}}
|
|
136
|
+
:store {:backend :file :path "/var/lib/datahike/browser-databases"}}}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The application issues the JWT. Datahike validates it but does not provide a
|
|
140
|
+
user database or login flow. What an authenticated subject may do is decided
|
|
141
|
+
by the same permissions the HTTP routes enforce (the server's `:system-db`
|
|
142
|
+
relationships): a transaction is a `:transact` on its database, a store
|
|
143
|
+
subscription a `:read`, database creation and deletion their own operations.
|
|
144
|
+
A server without a permissions database admits every authenticated subject.
|
|
145
|
+
|
|
146
|
+
`token` may be a function returning the current token, or a promise of one;
|
|
147
|
+
it is read at every connection and again to refresh the token before it
|
|
148
|
+
expires. `maintainKabelPeer` keeps the peer connected across drops and reports
|
|
149
|
+
`connecting`, `connected`, `authenticated`, `disconnected`, `failed` and
|
|
150
|
+
`stopped` to `onStatus`. `invokeRemote` calls a function the server serves,
|
|
151
|
+
`registerRemoteFn` serves one from the page.
|
|
152
|
+
|
|
153
|
+
Who may read, write, create or delete a database is decided by the server's
|
|
154
|
+
permissions, managed over its HTTP API. The whole setup, server container to
|
|
155
|
+
first query, permissions and your own server functions, is in
|
|
156
|
+
[Browser replicas](https://github.com/replikativ/datahike/blob/main/doc/browser-replicas.md),
|
|
157
|
+
including what is not there yet: no durable offline write queue, no multi-tab
|
|
158
|
+
coordination, and a store subscription has to be remade after a reconnection.
|
|
159
|
+
|
|
160
|
+
This follows the ClojureScript API directly: asynchronous browser and remote
|
|
161
|
+
stores use `{ 'sync?': false }`; an in-memory database can continue to use
|
|
162
|
+
`{ 'sync?': true }`. Applications can put a domain API in front of Datahike
|
|
163
|
+
instead when they do not need database queries in the browser.
|
|
164
|
+
|
|
165
|
+
Writes issued while disconnected wait for the connection in memory and are
|
|
166
|
+
lost on a page reload; there is no durable offline write queue yet, and tabs
|
|
167
|
+
do not coordinate.
|
|
168
|
+
Restoring a connection across a page reload and coordinating one replica among
|
|
169
|
+
multiple tabs or Web Workers are not yet part of the supported lifecycle.
|
|
170
|
+
|
|
92
171
|
### S3-compatible storage in browsers
|
|
93
172
|
|
|
94
173
|
Import the opt-in build when a browser should persist Datahike directly to
|
package/boring.data.js
CHANGED
|
@@ -3,6 +3,6 @@ var window=global;var $CLJS=require("./cljs_env.js");require("./cljs.core.js");
|
|
|
3
3
|
$CLJS.FB=new $CLJS.H("boring","max-depth-exceeded","boring/max-depth-exceeded",1648120233);$CLJS.GB=new $CLJS.H(null,"numerator","numerator",-160761104);$CLJS.HB=new $CLJS.H(null,"max-depth","max-depth",127060793);$CLJS.IB=new $CLJS.H(null,"max-items","max-items",-1969244147);$CLJS.JB=new $CLJS.H(null,"fallback","fallback",761637929);$CLJS.KB=new $CLJS.H(null,"denominator","denominator",-804365096);$CLJS.LB=new $CLJS.H("boring","handler-failed","boring/handler-failed",1798888153);
|
|
4
4
|
$CLJS.MB=new $CLJS.H(null,"n","n",562130025);$CLJS.m=$CLJS.AB.prototype;$CLJS.m.aa=function(a,b){return this.G(null,b,null)};$CLJS.m.G=function(a,b,c){switch(b instanceof $CLJS.H?b.D:null){case "n":return this.n;default:return $CLJS.of(this.j,b,c)}};$CLJS.m.ja=function(a,b,c){return $CLJS.ec(function(d,e){var f=$CLJS.B(e,0,null);e=$CLJS.B(e,1,null);return b.i?b.i(d,f,e):b.call(null,d,f,e)},c,this)};
|
|
5
5
|
$CLJS.m.P=function(a,b,c){return $CLJS.Qk(b,function(d){return $CLJS.Qk(b,$CLJS.Tk,""," ","",c,d)},"#boring.data.SimpleValue{",", ","}",c,$CLJS.ei.h(new $CLJS.N(null,1,5,$CLJS.O,[new $CLJS.N(null,2,5,$CLJS.O,[$CLJS.MB,this.n],null)],null),this.j))};$CLJS.m.fa=function(){return new $CLJS.fj(this,1,new $CLJS.N(null,1,5,$CLJS.O,[$CLJS.MB],null),$CLJS.u(this.j)?$CLJS.Nd(this.j):$CLJS.jh())};$CLJS.m.O=function(){return this.u};$CLJS.m.X=function(){return 1+$CLJS.Ve(this.j)};
|
|
6
|
-
$CLJS.m.Z=function(){var a=this.A;return a!=null?a:this.A=a=1404098260^$CLJS.ye(this)};$CLJS.m.U=function(a,b){return b!=null&&this.constructor===b.constructor&&$CLJS.A.h(this.n,b.n)&&$CLJS.A.h(this.j,b.j)};$CLJS.m.ia=function(a,b){return $CLJS.Vf(new $CLJS.uk(null,new $CLJS.S(null,1,[$CLJS.MB,null],null),null),b)?$CLJS.
|
|
6
|
+
$CLJS.m.Z=function(){var a=this.A;return a!=null?a:this.A=a=1404098260^$CLJS.ye(this)};$CLJS.m.U=function(a,b){return b!=null&&this.constructor===b.constructor&&$CLJS.A.h(this.n,b.n)&&$CLJS.A.h(this.j,b.j)};$CLJS.m.ia=function(a,b){return $CLJS.Vf(new $CLJS.uk(null,new $CLJS.S(null,1,[$CLJS.MB,null],null),null),b)?$CLJS.To.h($CLJS.Wc($CLJS.mj.h($CLJS.bh,this),this.u),b):new $CLJS.AB(this.n,this.u,$CLJS.hh($CLJS.To.h(this.j,b)),null)};
|
|
7
7
|
$CLJS.m.ea=function(a,b){switch(b instanceof $CLJS.H?b.D:null){case "n":return!0;default:return $CLJS.Vf(this.j,b)}};$CLJS.m.K=function(a,b,c){return $CLJS.u($CLJS.M.h?$CLJS.M.h($CLJS.MB,b):$CLJS.M.call(null,$CLJS.MB,b))?new $CLJS.AB(c,this.u,this.j,null):new $CLJS.AB(this.n,this.u,$CLJS.ek.i(this.j,b,c),null)};$CLJS.m.V=function(){return $CLJS.y($CLJS.ei.h(new $CLJS.N(null,1,5,$CLJS.O,[new $CLJS.ij($CLJS.MB,this.n,null)],null),this.j))};
|
|
8
8
|
$CLJS.m.S=function(a,b){return new $CLJS.AB(this.n,b,this.j,this.A)};$CLJS.m.ba=function(a,b){return $CLJS.Lf(b)?this.K(null,$CLJS.lf(b,0),$CLJS.lf(b,1)):$CLJS.ec($CLJS.mc,this,b)};$CLJS.NB=new $CLJS.AB(23,null,null,null);
|
package/boring.options.js
CHANGED
|
@@ -9,10 +9,10 @@ Hla=new $CLJS.H(null,"chunk-size","chunk-size",-205934374);$CLJS.pC=new $CLJS.H(
|
|
|
9
9
|
null);
|
|
10
10
|
$CLJS.sC=new $CLJS.S(null,5,[$CLJS.hC,new $CLJS.uk(null,new $CLJS.S(null,2,[$CLJS.jC,null,$CLJS.qC,null],null),null),sla,new $CLJS.uk(null,new $CLJS.S(null,4,[$CLJS.cC,null,$CLJS.jC,null,$CLJS.qC,null,$CLJS.dC,null],null),null),xla,new $CLJS.uk(null,new $CLJS.S(null,5,[$CLJS.cC,null,$CLJS.iC,null,$CLJS.jC,null,$CLJS.qC,null,$CLJS.dC,null],null),null),$CLJS.qC,new $CLJS.uk(null,new $CLJS.S(null,5,[$CLJS.cC,null,$CLJS.iC,null,$CLJS.jC,null,$CLJS.qC,null,$CLJS.dC,null],null),null),Cla,new $CLJS.uk(null,new $CLJS.S(null,
|
|
11
11
|
5,[$CLJS.cC,null,$CLJS.iC,null,$CLJS.jC,null,$CLJS.qC,null,$CLJS.dC,null],null),null)],null);$CLJS.Mla=new $CLJS.S(null,1,[$CLJS.vla,!0],null);$CLJS.Nla=$CLJS.wf($CLJS.hC.g($CLJS.rC),$CLJS.Mla);
|
|
12
|
-
$CLJS.tC=$CLJS.Wj([zla,$CLJS.Ila,$CLJS.cC,$CLJS.lC,$CLJS.tla,$CLJS.
|
|
13
|
-
null),new $CLJS.S(null,2,[$CLJS.
|
|
14
|
-
$CLJS.T.g(2147483647)+" (0 turns indexing off)"],null),new $CLJS.S(null,2,[$CLJS.
|
|
15
|
-
2,[fC,null,$CLJS.nC,null],null),null),$CLJS.oC,":preserve-width or :shortest"],null),new $CLJS.S(null,2,[$CLJS.
|
|
16
|
-
null),null),$CLJS.oC,":trusted or :ignore"],null),new $CLJS.S(null,2,[$CLJS.
|
|
17
|
-
new $CLJS.S(null,2,[Dla,null,ola,null],null),null);b=b.g?b.g(a):b.call(null,a);return $CLJS.u(b)?b:$CLJS.uf(a)},$CLJS.oC,":date, :instant, or a function of epoch millis"],null),new $CLJS.S(null,2,[$CLJS.
|
|
18
|
-
2,[$CLJS.
|
|
12
|
+
$CLJS.tC=$CLJS.Wj([zla,$CLJS.Ila,$CLJS.cC,$CLJS.lC,$CLJS.tla,$CLJS.pn,$CLJS.mla,$CLJS.ula,$CLJS.Vn,$CLJS.IB,$CLJS.iC,$CLJS.jC,$CLJS.qla,$CLJS.kla,$CLJS.qC,Lla,$CLJS.HB,Hla,$CLJS.lla,$CLJS.Kla,$CLJS.Gla,$CLJS.kC,$CLJS.dC],[new $CLJS.S(null,2,[$CLJS.Om,new $CLJS.uk(null,new $CLJS.S(null,2,[nla,null,Fla,null],null),null),$CLJS.oC,":local-date or :sql-date"],null),new $CLJS.S(null,2,[$CLJS.Om,function(a){return $B(a,0,2147483647)},$CLJS.oC,"a non-negative integer no greater than "+$CLJS.T.g(2147483647)],
|
|
13
|
+
null),new $CLJS.S(null,2,[$CLJS.Om,aC,$CLJS.oC,"true or false"],null),new $CLJS.S(null,2,[$CLJS.Om,aC,$CLJS.oC,"true or false"],null),new $CLJS.S(null,2,[$CLJS.Om,function(a){var b=new $CLJS.uk(null,new $CLJS.S(null,2,[$CLJS.JB,null,$CLJS.yo,null],null),null);b=b.g?b.g(a):b.call(null,a);return $CLJS.u(b)?b:jla(a)},$CLJS.oC,":fallback, :error, or a function of [name payload]"],null),new $CLJS.S(null,2,[$CLJS.Om,function(a){return $B(a,0,2147483647)},$CLJS.oC,"a non-negative integer no greater than "+
|
|
14
|
+
$CLJS.T.g(2147483647)+" (0 turns indexing off)"],null),new $CLJS.S(null,2,[$CLJS.Om,aC,$CLJS.oC,"true or false"],null),new $CLJS.S(null,2,[$CLJS.Om,aC,$CLJS.oC,"true or false"],null),new $CLJS.S(null,2,[$CLJS.Om,function(a){return a==null||$CLJS.Jf(a)},$CLJS.oC,"a registry map from boring/tag-registry"],null),new $CLJS.S(null,2,[$CLJS.Om,function(a){return $B(a,0,Number.MAX_SAFE_INTEGER)},$CLJS.oC,"a non-negative integer (0 means unlimited)"],null),new $CLJS.S(null,2,[$CLJS.Om,new $CLJS.uk(null,new $CLJS.S(null,
|
|
15
|
+
2,[fC,null,$CLJS.nC,null],null),null),$CLJS.oC,":preserve-width or :shortest"],null),new $CLJS.S(null,2,[$CLJS.Om,new $CLJS.uk(null,new $CLJS.S(null,2,[mC,null,$CLJS.gC,null],null),null),$CLJS.oC,":rfc8949 or :rfc7049"],null),new $CLJS.S(null,2,[$CLJS.Om,aC,$CLJS.oC,"true or false"],null),new $CLJS.S(null,2,[$CLJS.Om,aC,$CLJS.oC,"true or false"],null),new $CLJS.S(null,2,[$CLJS.Om,aC,$CLJS.oC,"true or false"],null),new $CLJS.S(null,2,[$CLJS.Om,new $CLJS.uk(null,new $CLJS.S(null,2,[Ela,null,Bla,null],
|
|
16
|
+
null),null),$CLJS.oC,":trusted or :ignore"],null),new $CLJS.S(null,2,[$CLJS.Om,function(a){return $B(a,1,2048)},$CLJS.oC,"a positive integer no greater than "+$CLJS.T.g(2048)+" (the decoder recurses per level, and a limit the host stack cannot honour is not a limit)"],null),new $CLJS.S(null,2,[$CLJS.Om,function(a){return $B(a,1,2147483647)},$CLJS.oC,"a positive integer"],null),new $CLJS.S(null,2,[$CLJS.Om,aC,$CLJS.oC,"true or false"],null),new $CLJS.S(null,2,[$CLJS.Om,function(a){var b=new $CLJS.uk(null,
|
|
17
|
+
new $CLJS.S(null,2,[Dla,null,ola,null],null),null);b=b.g?b.g(a):b.call(null,a);return $CLJS.u(b)?b:$CLJS.uf(a)},$CLJS.oC,":date, :instant, or a function of epoch millis"],null),new $CLJS.S(null,2,[$CLJS.Om,function(a){return a==null||$CLJS.A.h($CLJS.pla,a)||jla(a)},$CLJS.oC,"nil, :placeholder, or a function"],null),new $CLJS.S(null,3,[$CLJS.Om,function(a){return $CLJS.Vf($CLJS.rC,a)},$CLJS.vm,$CLJS.wla,$CLJS.oC,"one of :clojure, :interop, :archival, :canonical, :canonical-rfc7049"],null),new $CLJS.S(null,
|
|
18
|
+
2,[$CLJS.Om,aC,$CLJS.oC,"true or false"],null)]);$CLJS.Ola=$CLJS.Og($CLJS.jg(function(a,b,c){return $CLJS.oj.i(a,b,$CLJS.Om.g(c))},$CLJS.pd($CLJS.bh),$CLJS.tC));
|